hi,
Look at the sample sound for ARM board MCB2130, how to make this sound data (data.c)? in the sample DTMF "1", "5", "9" and "D" is in SoundaData array variable.
If I want to generate data for freq say 350Hz (single frequency) how to make it? so I can put in the array variable similar such as SoundData.
thanks, Rudy
For a simple, single frequency, you could create the data using your favourite spreadsheet program...
For a simple, dual-frequency, you could create the data using your favourite spreadsheet program ;)
This page includes some information on how to read the samples from a WAV file:
www.lightlink.com/.../WAVE.html
Spreadsheet programs may work, but I don't find them the tool of choice.
Matlab or its free software lookalike GNU Octave work very well.
A lot of people - being developers - would probably consider using a free compiler for Linux or Windows and write a few lines of code to generate the required curve form and print as an initialized C array for inclusion in the source code of the target firmware.
The trivial file format of normal WAV files would also allow the generated curve form to be trivially tested with WinAmp or any other available audio player.
"The trivial file format of normal WAV files would also allow the generated curve form to be trivially tested with WinAmp or any other available audio player"
Or, in the other direction, any available audio recording software could be used to capture "real" sounds to a WAV file, and then a simple 'C' program could extract the data samples...
Guys,
Thank you for the information. I will try it and update the result.
I found that for single frequency sound, I don't need to use any data. What I do, only change the value of DAC from 0x0000 to 0xFFFF and back again from 0xFFFF to 0x0000 every interrupt on T0. The triggered int time is the only key to change.
I tried to generate sound code using PC's sound recorder, then save it as in format of PCM, 8Khz, 8bit Mono. Extract the data in the file and put it in the code, but the sound is not clear as in PC.
I am using following link for extract data (I wrote program in delphi to extract data) www.lightlink.com/.../WAVE.html (as suggested by Christoph Franck) and ccrma.stanford.edu/.../
Any one can help me?
best regards, Rudy
Note that emitting 0x0000 and 0xffff will emit a square wave. Unless you have a low-pass filter, your output will contain large amounts of energy in overtone frequencies, besides the base frequency.
A problem when handling PCM data is to make sure that you don't have a signed/unsigned problem.
The sound recorder is one way, but best when you want to capture speech messages or music. For DTMF or similar, it is normally easier to just sum the sine waves in a C program, and let the program emit the data in text form for direct inclusion in the source code. Wieh you compute the frequencies matematically, it will also be trivial to create a sound clip that has the perfect number of samples for looped playback, i.e. where the clip has n samples and the n+1 sample should have been identical to the first sample.
A square wave is not a single-frequency sound. It's one fundamental frequency with lots of harmonics. Depending on your application, this might be relevant.
Getting the sound to sound "clear" requires fairly strict timing with little jitter. Even more so if your chip doesn't have DMA facilities to move the sound data to the DAC.
You might have to connect an oscilloscope (and/or a frequency analyzer, or an oscilloscope that can calculate a spectrum) to the DAC to examine the output waveform. Start with simple sine/triangle/sawtooth waves and see if they a re-created without distortion.
Personally, I'd use Matlab (expensive) or GNU Octave (free, and for this purpose pretty much indistinguishable from Matlab, so don't buy a four- to five-figure Matlab license just for this purpose :) ) to generate the waveforms.