|
Of course it can be read from memory - that's how media players play files; they read them into memory and play them. The question is what are you using to play the sound? Are you interop'ing with the Windows Media Player typelib (having created an RCW, or Runtime Callable Wrapper - i.e., an "interop assembly")? If so, then no. Typelibs are meant to expose functionality to callers in a typically simple manner. Most callers would never need to play a file from memory.
If you were using the Managed DirectX[^] assemblies, however, you could use a MemoryStream as input to a DirectSound Buffer or another suitable class. Download and install the DirectX SDK, along with the managed assemblies for interoperability with the .NET Framework written from the ground up (not just simple inteorp assemblies or wrappers like some projects used before Managed DirectX 9).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Sorry I didn't make myself clear, the problem is I'm not sure how to play it, I've figured out the ADPCM header now, so the problem is playing the actual sound. DirectX seems to be the best way to go, can you give me a link to a tutorial or something?
|
|
|
|
|
I understood that you didn't know how to play it. Follow the link I already gave you in my first reply for documentation, downloads, and articles. If you are looking for addition tutorials I suggest you search either this site using the search textbox above (although I'll warn you that most of the articles about DirectX wrap the older APIs themselves instead of using Managed DirectX) or google.
If you're sure this sound will always be a simple PCM audio clip you could P/Invoke the rather extensive set of Windows Multimedia APIs, which you can read about at http://msdn.microsoft.com/library/en-us/dnanchor/html/anch_WindowsMultimedia.asp[^].
If you're not sure about the encoding of the file (i.e., whether it's MP3, WMA, or anything else) then you should use DirectX which enumerates and uses all the audio and video codecs installed on teh system without having to worry about decoding the data yourself into waveform.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I'm looking through the MSDN now. I think I can see a problem though, the WaveFormatTag only has PCM, does it only support uncompressed PCM, or does it also allow ADPCM? Also do you know of anywhere that has documentation on the ADPCM WAVE header? I've found general documentation on the WAVE (RIFF) format, but there's inconsistancies, such as Block Align being Bit Rate / 8 * Channels. This would mean 4bit ADPCM block aling would be 0.5, in a sample ADPCM file I've encoded the value is 512 (format was 22.050 mono)
|
|
|
|
|
The best place to find this information is in the headers. Download and install the Platform SDK[^] and find the APIs that would use the header information (typically a struct). At the bottom of the documentation for these APIs is listed which header they are declared in. With some digging you can find the actual structs. This is what I did when I wrote an icon extractor (that extracts the actual icon data - not an HICON ) to find the icon structure.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have an assignment to traverse a parent-child chain of controls that are arranged so that the master parent has one child, and then that child has a child, and then that child has one child, and then that child has one child. In other words, the arrangement is similar to that of a russian doll, where there is a hollow man, which contains another hollow man, and so on until you reach the center. Now the code, the code is all incorporated inside of a single click event. Would it be similar to?
private int ctrl_click(object sender, EventArgs e)
{
Control ctrl_hold;
int intControlCounter = 1;
while (ctrl.HasChildren == true)
{
if (ctrl.HasChildren)
{
intControlCounter += 1;
ctrl_hold = ctrl;
}
else
{
exit while;
}
}
}
When there is a control arranged in a chain of parent-child relationships, even if there were code such as: ctrl.HasChildren.count, it would only return a result of 1. How would I traverse the chain of controls arranged in such a way and come back with a result of the number of controls? Would REALLY APPRECIATE some assistance, as Microsoft did not document the parent-child relationship code very well.
|
|
|
|
|
You have to recursively search through alle controls.
Some code (untested)
<br />
public int GetCount(Control control) {<br />
int count = 0;<br />
foreach (Control childControl in control) {<br />
count += GetCount(childControl);<br />
}<br />
return count + 1;
}<br />
|
|
|
|
|
Thank you, Robert ! ! ! Your sample code got me pointed in a totally different direction, that enabled me to solve the problem. I appreciate it.
|
|
|
|
|
Hi all, I found this article in CodeProject:
http://www.codeproject.com/csharp/FTwin32Timers.asp[^]
I was wondering if anyone else could back this up (i.e. encoutered the problem), and the most important thing:
In the article, it says that the "other" timers DIDN'T work. Does anyone understand which timers the author is talking about? Maybe System.Threading.Timer objects? Or maybe something else?
Thanks.
/=/=/=/= Sagmam =\=\=\=\
|
|
|
|
|
sagmam wrote:
I was wondering if anyone else could back this up (i.e. encoutered the problem)
I can't confirm the problem. However, the article refers to the .NET Framework 1.0 and there has been a Service Pack release after the article was published (so, maybe there has been a bug in one/all of the timer classes, however, there are no timer bugs mentioned in the lists of bugs).
sagmam wrote:
Does anyone understand which timers the author is talking about?
I don't know which one the author meant but there are three timer classes in the .NET Framework 1.1 (see also Comparing the Timer Classes in the .NET Framework Class Library[^]):
System.Threading.Timer[^]
System.Timers.Timer[^]
System.Windows.Forms.Timer[^]
Best regards
Dennis
|
|
|
|
|
Thanks Dennis.
I know about these three, and I read the article, however, it doesn't talk about any issues with them - only about how to use them, etc. Apparently, the article I was talking about claims that there are issues with one or more of these classes, and I don't know which or why....
Take care,
/=/=/=/= Sagmam =\=\=\=\
|
|
|
|
|
Hello all,
I bind a combobox with columne in database.but i need to display first selection blank.
Thanks
hay
|
|
|
|
|
Steps
1) Add a blank space to combobox items
Ex: cboProducts.Items.Add("");
2) Use a datareader to fetch the required column data from the database.
3) Then loop through the datareader data using Read() method, while doing this add required column values to the items of Combobox.
I hope This will do.
If you directly bind the combobox using Datasource and Displaymember properties You may not get blank line.
- Send me if you have any suggetions or other work arounds
|
|
|
|
|
|
Yes you can. Ive only made a quick view at the article but i think I should be easily done with it. The method SaveToDocumentFormat receives an object to be persisted. You can just pass an array of objects (e.g. an array of customers) into the method and it should serialize them all into one file. Even an ArrayList should work.
|
|
|
|
|
How can I dynamically install Microsoft loopback adapter programatically in C#, if so, can i have multi-instances of it?
and what would be the way to configure its IP address, media type, etc. through run-time.
|
|
|
|
|
I have a dataset which contain only one DataTable. In my Business logic, I am selecting one data row from the data table which is there in my dataset.
When I try to modify the data in data row it is modifying successfully. like wise I am getting all required result for consecutive updation,add,deletion etc.
I can able see the changes that I made in dataset. And it reflects in user interface. The problem is , when I try to update data back to database it execute the Update method successfully. If I try to see the data in database it doesn't shows any updated data. I am using Asacommandbuilder to get all relavent command while passing a Sellect command.
I am using Sybase as database(Ianywhere Client).
No error no updation. Really I am getting mad. Any Idea ?
Sreejith Nair
[ My Articles ]
|
|
|
|
|
I am displaying images as thumbnails from a folder on a panel. On click of any of the images i need the name of the image file being clicked. Here is how i am displaying the images:
string [] fileEntries = Directory.GetFiles(utils.imgfolderpath);
int j=fileEntries.Length;
for(int i=0; i
|
|
|
|
|
Hi,
when you draw your images remember their locations. In this case I would hold a Rectangle array to store this information. E.g:
(some field)
<br />
Rectangle[] rects = new Rectangle[NrOfImages];<br />
(in the loop)
<br />
rects[i] = new Rectangle(x, y, width, height);<br />
To determine the clicked image:
<br />
int resultIndex = -1;<br />
for (int i = 0; i < rects.Length; i++) {<br />
if (Rects.Contains(new Point(MouseX, MouseY)) {<br />
resultIndex = i;<br />
break;<br />
}<br />
}<br />
if (i >= 0) <br />
|
|
|
|
|
Thanks a lot for the help Robert.
|
|
|
|
|
Can I remote an abstract class with remoting feature of C#.
|
|
|
|
|
|
|
Hey Everyone,
I am new to C#. I am writing a small application. This application will read a method name from a flat file. Then call the method in another class library with the same name as the one read.
Example, I have a method "add" in the flat file. and the other library is "Math", then my aplpication should call "Math.add", the other library may change and so the flat file.
This is something similar to dlsym that I used in my c/c++ programs on unix. Can something similar be done here.
Thanks in advance,
Regards,
JItesh
|
|
|
|
|