From what I can make out, playing an audio sound is a function of playing a certain number of samples for a certain period of time on a given frequency. The value returned from the sine function is between -1 and 1. However, the sound card expects a value that is stored in one byte i. To put the value into this range, we multiply by and, with the floor function, round down.
Only sound card manufacturers deal with the actual process of creating sound, so the info about the software logic is a little hard to get and a lot of device manufacturers keep their code a proprietary secret. But for people like us who want to learn the actual process of making sound, this is the holy grail.
So negative values in the signal can mess this up? I was able to run the code, and tried on a piano sequence, but it comes out noisy.. My data range is from , Not really. In line , you are reading into the data buffer the audio data for all channels I was using a 2 channel example and it was 4 bytes ; however inside the for loop [ line ] looping over each channel you are always using the data for the first channel.
I had to modify this so that each channel data was recorded correctly. Can you clarify? I still get a noisy data from my player, but thats a different issue.
Its been a few years since I wrote the code so I will have to go over it once to see if there is any issue. At first glance, what you say could be correct, because the channel loop is using the same data extract in every iteration.
I believe the pointer within the data array should be incremented within the channel loop. If you have already made the change and its working fine , you could probably post the fix. I will go over the code in the next couple of days and apply your fix.
No, I dont have it working satisfactorily. Once I have it working, I will be happy to share — in fact we are hoping to use this this for an open source educational toolkit.
I got the parser working yesterday. There are two issues with your original code. One I mentioned above, where for multiple channels, you need to update the pointer. Secondly, this code wont work correctly for negative signal values. For this you need to do the following where you do the endian conversion:. I have a version for C I can send you with these changes. I will send a link to that with acknowledgements for your approval. If your issue has been resolved, please mark an useful post as answer.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey. Ask a question. Quick access. Search related threads. Remove From My Forums. Answered by:. Archived Forums. Thank you anyway. Add a comment. The simplest way possible, you can simply change: wr. Write "RIFF" ; to: wr.
Write "RIFF". ToArray ; Writing a string in a binary file, it will include the length of the string so that it can be deserialized back into a string later. Dave Cousineau Dave Cousineau I lack the proper WAV data, but try replacing the part of your code where you generate the header with this code replace appropriately : wr.
Write Encoding. Write 0 ; wr. GetBytes "fmt " ; wr. Write "data" ;. Jason Jason 6, 5 5 gold badges 38 38 silver badges 54 54 bronze badges.
I get an error the second one I mentioned above. It may be my data, but I'm pretty certain the correct number of bytes get written to the file, so at worst the result should be noise. I even changed the last line to be of the same format as the other strings. I rearranged some things I didn't understand your chunk sizes, for example, so I used mine , and the result actually worked! I don't know why though. Anyway, thank you. Yeah, I was trying to make my own recorder to use for Google's Voice Recognition like a sort of desktop assistant.
It took me a few hours to weed through the specifics of the WAV format too. Glad you got it figured out. Just wanted to add another suggestion although a few more lines is: binaryWriter.
Write 'R' ; binaryWriter. Write 'I' ; binaryWriter. Play ; Console. WriteLine "repeat? ReadAllBytes "name. Improve this question. Antaios Antaios 4 4 bronze badges. What's all that Math. Pow code do? You have comments that indicate indicate you are doing some bit and byte twizzling.
What's Math. Pow doing there — Flydog Then it goes to the k-1 -th iteration. Add a comment. Active Oldest Votes.
0コメント