|
I am trying to find some code examples or source code that would show me how to create a pure tone in C# and assign it to a DirectSound buffer so that I can play it.
I have searched on Google for tone generators and sine wave generation etc but there is nothing that shows me how to create the tone from scratch. DirectSound allows me to read, create, and play a wav or other media formated file by creating a DirectSound device and playing it in a buffer, but I can't find anything on creating a tone from scratch.
I need to be able to create a tone from scratch at a certian frequency.. play it for a specific time be able to control the panning from right to left and control the volume. I am pretty sure I know how to do all of the the manipulation once I have the tone playing. I just need help with the actual generation.
Any ideas or help would be appreciated.
Mike.
|
|
|
|
|
|
I'm C# newbie and I'm jumping right into Database programming. I need to retrieve a GUID column from a DataGrid/DataSet/DataView and I have this problem.
Can you cast String to Guid? and Guid to String?
norm
|
|
|
|
|
You can do both approach's
Guid myGuid = Guid.NewGuid();
string mystring = myGuid.ToString();
or
string myString = "{9729A19E-55FE-4fd9-F5B1-E0212209A0C4}";
Guid myGuid = new Guid(myString);
SB
|
|
|
|
|
yes, but i dont think you can cast...
Guid gdMsgID;
String strMsgID;
//Testing 1: This will NOT work. CS0030: Cannot convert type 'System.Guid' to 'string'
gdMsgID = Guid.NewGuid();
strMsgID = (String) gdMsgID;
//Testing 2: Again, this will NOT work. CS0030: Cannot convert type 'string' to 'System.Guid'
gdMsgID = (Guid) strMsgID;
norm
|
|
|
|
|
im looking to add a spell checker type system to my program. I have found a few user made ones before but i they all basicly like a script (enter the word at a website and then downloading the results) it worked fine..but i want it to work offline as well. So my question is...does anyone know where i can find a complete dictionary....in text or strings (atlest maybe then i can make some kind of interface)....this might possibly the only un-awnserable question on CodeProject.
P.S: Why create my own? so then i can say i did it of course...
Thanks Alot
Jesse M.
The Code Project Is Your Friend...
|
|
|
|
|
WordNet[^]
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Philip Fitzsimons wrote:
WordNet[^]
The best "GPL" dictionary I have found online. The DB setup was a bit tricky at first, but I read a bit of the PROLOG stuff, it was rather logical.
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
Hi!
I have four 'basic' structures, and I have one 'collection' structure, which contains my 'basic' structures. This works fine until I make a structure array into my 'collection' structure. So, now I'm asking help, how should I define this structure array inside another structure?
See code:
using System;<br />
using System.Runtime.InteropServices;<br />
using Microsoft.Win32;<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public class MSSD<br />
{ <br />
public byte msf;<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]<br />
public byte[] mso;<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]<br />
public byte[] ovn;<br />
public byte br;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public class FHPD<br />
{<br />
public byte spul;<br />
public byte spm;<br />
public byte spss;<br />
public byte spls;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public class RHPD<br />
{<br />
public byte spul;<br />
public byte spm;<br />
public byte spss;<br />
public byte spls;<br />
public byte sps;<br />
public byte spd;<br />
public byte ac;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public class HPD<br />
{<br />
public byte csr;<br />
public byte csl;<br />
public byte cgr;<br />
public byte crl;<br />
public byte rtron;<br />
public byte rtroff;<br />
public byte rtlon;<br />
public byte rtloff;<br />
public byte moo;<br />
public byte arf;<br />
public byte alf;<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]<br />
public uint[] qrp;<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]<br />
public uint[] qlp;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public sealed class PAD<br />
{<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]<br />
public byte[] sn;<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]<br />
public byte[] ct;<br />
[MarshalAs(UnmanagedType.Struct)]<br />
public MSSD mss = new MSSD();<br />
[MarshalAs(UnmanagedType.Struct)]<br />
public FHPD fhpd = new FHPD();<br />
[MarshalAs(UnmanagedType.Struct)]<br />
public RHPD rhpd = new RHPD();<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = UnmanagedType.Struct)]<br />
public HPD[] hpd;<br />
<br />
public PAD()<br />
{<br />
<br />
}<br />
<br />
public void sizeOfPAD()<br />
{<br />
int si = Marshal.SizeOf(this);<br />
Console.WriteLine("the size of PAD is " + si +" bytes.");<br />
}<br />
}
Please, help me!
br. Juha Ka
|
|
|
|
|
|
Hello,
I am using one third party control.
When I am going to place that control on my form it is showing following error.
An exception occurred while trying to creating an instance of "XPMenus.Menus.MenuControl". The Exception was "the type of intializer for
"XPMenus.Menus.MenuControl" threw an exception.
chito.
|
|
|
|
|
chito wrote:
the type of intializer for
"XPMenus.Menus.MenuControl"
This basically means that there was an exception thrown in the static constructor of the XPMenus.Menus.MenuControl class. A static constructor is generally used to initialize some global/static data for the class because it is called before the first time the class is used (if I remember correctly).
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
public void ExeQueryCmdArray(NewDBClass.DbName dbName, String[] sQuery)
{
this.dbNameCache = dbName;
this.DbInstance(dbName);
OleDbCommand cmdCommon1 ;
OleDbCommand cmdCommon2 ;
OleDbCommand cmdCommon3 ;
try
{
this.conOleDb.Open();
this.transOleDb = this.conOleDb.BeginTransaction();
switch (sQuery.Length)
{
case 2:
cmdCommon1 = new OleDbCommand(sQuery[0],conOleDb,transOleDb);
cmdCommon2 = new OleDbCommand(sQuery[1],conOleDb,transOleDb);
cmdCommon1.ExecuteNonQuery();
cmdCommon2.ExecuteNonQuery();
break;
case 3:
cmdCommon1 = new OleDbCommand(sQuery[0],conOleDb,transOleDb);
cmdCommon2 = new OleDbCommand(sQuery[1],conOleDb,transOleDb);
cmdCommon3 = new OleDbCommand(sQuery[2],conOleDb,transOleDb);
cmdCommon1.ExecuteNonQuery();
cmdCommon2.ExecuteNonQuery();
cmdCommon3.ExecuteNonQuery();
break;
}
this.transOleDb.Commit();
}
catch(System.Data.OleDb.OleDbException oe)
{
ExceptionClass.PrintException(oe.Message);
this.transOleDb.Rollback();
}
catch(System.Exception e)
{
ExceptionClass.PrintException(e.Message);
this.transOleDb.Rollback();
}
finally
{
this.conOleDb.Close();
}
}
I use Access Database, and I want to execute various Insert and Update Query strings.
As you know, That code is very annoying me. So, I'd like to change using [for Loop].
But, I don't know How To...
Is there anyone can help me..
Thanks!!
|
|
|
|
|
bania wrote:
switch (sQuery.Length) { case 2: cmdCommon1 = new OleDbCommand(sQuery[0],conOleDb,transOleDb); cmdCommon2 = new OleDbCommand(sQuery[1],conOleDb,transOleDb); cmdCommon1.ExecuteNonQuery(); cmdCommon2.ExecuteNonQuery(); break; case 3: cmdCommon1 = new OleDbCommand(sQuery[0],conOleDb,transOleDb); cmdCommon2 = new OleDbCommand(sQuery[1],conOleDb,transOleDb); cmdCommon3 = new OleDbCommand(sQuery[2],conOleDb,transOleDb); cmdCommon1.ExecuteNonQuery(); cmdCommon2.ExecuteNonQuery(); cmdCommon3.ExecuteNonQuery(); break; }
Replace with:
foreach (string q in sQuery)
{
new OleDbCommand (q, conOleDb,transOleDb).ExecuteNonQuery();
}
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
I made it!!
Thank you...
|
|
|
|
|
Hi,
does Datagrid's Row has a tag property ? like control (Label/text) has a Tag (objecT) property which can store any object associate with it. so the same way I need to store an object with
each and every row of the datagrid ?
how do i do that?
Paresh
|
|
|
|
|
I was reading Joel Neubeck's article on watermarking (http://www.codeproject.com/csharp/Watermark.asp) and found it very interesting and helpful.
But I was left with the question, is there a method available that enables the drawing of text diagonally on an image, or even rotated 90 degrees for a vertical effect (such as vertically drawn up the right hand side of the graphic).
Any info would be great!
Thanks.
Bill Koch
|
|
|
|
|
an idea,
the best idea would be create a image in memory ,
get the graphics handle from it. write a text you want.
write to image.
now on picture box set that image and you can rotate that image.
the another option would be
1) get the graphics handle g
2) write a drawstring say letter 'a'
3) now u need the rotation algorithm to do that.
Paresh
|
|
|
|
|
wkoch wrote:
But I was left with the question, is there a method available that enables the drawing of text diagonally on an image, or even rotated 90 degrees for a vertical effect (such as vertically drawn up the right hand side of the graphic).
The Transform property on the Graphics object should let you rotate, translate, or scale all drawing done using that Graphics object by assigning the proper Matrix to it.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Thanks for the tip. That worked out great!
I adapted it to VB, but basically I had to add the following lines:
Dim myMatrix As New Matrix()
Dim rotatePoint As New PointF(xPos, yPos)
'Rotate the matrix "Me.Angle" degrees
myMatrix.RotateAt(Me.Angle, rotatePoint, MatrixOrder.Append)
' Draw the rectangle to the screen again after applying the
' transform.
grPhoto.Transform = myMatrix
'draw the string of text onto the graphics object.
grPhoto.DrawString(mWMString, crFont, semiTransBrush2, rotatePoint, StrFormat) 'string of text
'font
'Brush
'Position
''prep the image for saving.
imgPhoto = bmPhoto
|
|
|
|
|
Hi,
I'm trying to direct acces to MDDraw surface memory.
I'm using Lock() method but I don't understand it.
I was doing same thing in C++ and DX7..
Unmanaged Lock() returns pointer to memory and informations about format, but managed Lock() returns 2-dimensional array of byte (width and height of this array is same as size of the surface, but this is not enough for saving color in 32bit format).
Following code does nothing:
Byte[,] btData=surfaceBack.Lock(LockFlags.SurfaceMemoryPointer|LockFlags.Wait);
for(int x=0; x<100; x++)
{
for (int y=0; y<100; y++)
{
btData[x,y]=(byte)x;
}
}
srfBack.Unlock(btData);
Thank you for help.
[edit] MSDN : Surface.Lock() http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_m/directx/ref/ns/microsoft.directx.directdraw/c/surface/m/lock0.asp[^][/edit]
i'm only pointer to myself
|
|
|
|
|
While building an icon editor to get the feel for graphics handling I came upon a problem.
I have a panel that is has been grided out with lines, 32x32, which as you draw updates a Bitmap which is 64x64. When I go to save the icon I I convert it down to a 32x32 Bitmap and the attempt to save it.
If I take the saved file and load it into an image editor the image comes out fine. However, when I try and reload the Icon via new Icon(FileName) I get this Exception.
An unhandled exception of type 'System.ArgumentException' occurred in system.drawing.dll<br />
<br />
Additional information: The argument 'picture' must be a picture that can be used as a Icon.<br />
When looking at the file in the folder view it shows the Windows "Unassociatated Icon".
If I save the Image in Bitmap format it shows the Image next to the file, but
it still throws the Exception when reloading. Also if I build a release it throughs an error on the icon that says
Error generating Win32 resource: Error reading icon 'E:\Programming\Icons Plus\Icons Plus\bin\Debug\myIcon2.ico' -- The data is invalid. <br />
Any ideas on how to get the image saved properly so that it can be used as an Icon.
|
|
|
|
|
it drawing.dll won't accept if its 8 bit image.
make it 16 bit or higher.
Paresh
|
|
|
|
|
Thanks: Worked Like A Charm
|
|
|
|
|
Which PixelFormat should be used. As long as I set it to put out a BMP the Icon "works". That is unless I set it to the application Icon.
I need to set the ImageFormat to .Icon. When I do that I get a "Unassoicated Icon" instead.
|
|
|
|