I am trying out synth waveforms using teensy3.1 and the audio adaptor.
I can get it to work fine using the samples downloaded from your links.
I also tried converting some sound samples for arbitrary sounds from wav files and find alot of aliasing. I know it is mentioned on the forum....
I thought if I used wavs sampled at 44.1 that played at 44.1 on a PC , and teensy was sampling at 44.1 there would not be a problem.
What would be the difference in Audacity playing a 44.1 wave or teensy playing it.??...both at 44.1.
I understand teensy is playing it from a data array in memory and Audacity is playing direct from the file.
If I have a wav file of frequency 441 Hz say that gives me 100 samples for 1 period. To create the data array for teensy I need 256 samples (256 + 1 same start and end, an array of 257).
So I opened the wav file in Audacity and run the Effects Low pass filter corner freq. 2000 Hz and 48 db/octave rolloff. I know I think the filtering should actually be done at the analogue stage of recording before it is digitized, but I only had a digital wav file to start with.
I then copied a section of the audio, to the clipboard, set the project rate to (256 x 44100 / 100) = 112896, then opened a new mono track and pasted in the audio data. That gave me 257 samples for 1 period of the waveform. I exported the data for 1 period using Audacity sample data export, opened it in a spreadsheet, multiplied the values by 65535, appended a comma after each one and copied this into a header file in the Arduino IDE. And all compiled and worked providing I keep the corner freq about 2000 Hz. It sounds not bad just a bit "muffled".
When I record the playback from teensy using Audacity I get 100 samples again for the waveform at that freq. 440 Hz. and the waveform doesn't look too bad.
This is the bit puzzling me.....I don't seem to be using all to values put in the 257 array..??....when I play the recorded freq of the sound..??
I did a rough test and recorded teensy output in Audacity, and viewed it at 44.1 sample rate in audacity.
Playing a 440 sound sample of 257 sample points for a 1 period in the teensy array gave me....
maxFREQ = 1200;
wave0.begin(0.3, wavefreq, WAVEFORM_ARBITRARY);
wave0.arbitraryWaveform(mysound[3], maxFREQ);
wave0.frequency(100); .......
etc...etc for 100, 171, 200, 257, 300, 440 freqs ..............
Freq...100 gave 440 samples for 1 period playback.
Freq...171 gave 257 samples for 1 period playback....this is full table..??
Freq...200 gave 220 samples for 1 period playback.
Freq...257 gave 172 samples for 1 period playback.
Freq...300 gave 148 samples for 1 period playback.
Freq...440 gave 100 samples for 1 period playback.
The teensy sounded frequency and measured frequency always was correct for each.
Maybe someone can through some light on this and what is the best way to convert an already recorded wav sound file to a data array.
Generally 44100 sound files are anti-alliased at 20 khz OR 22050 files are anti-aliased at 10 khz already.
Thanks for your help......
I can get it to work fine using the samples downloaded from your links.
I also tried converting some sound samples for arbitrary sounds from wav files and find alot of aliasing. I know it is mentioned on the forum....
I thought if I used wavs sampled at 44.1 that played at 44.1 on a PC , and teensy was sampling at 44.1 there would not be a problem.
What would be the difference in Audacity playing a 44.1 wave or teensy playing it.??...both at 44.1.
I understand teensy is playing it from a data array in memory and Audacity is playing direct from the file.
If I have a wav file of frequency 441 Hz say that gives me 100 samples for 1 period. To create the data array for teensy I need 256 samples (256 + 1 same start and end, an array of 257).
So I opened the wav file in Audacity and run the Effects Low pass filter corner freq. 2000 Hz and 48 db/octave rolloff. I know I think the filtering should actually be done at the analogue stage of recording before it is digitized, but I only had a digital wav file to start with.
I then copied a section of the audio, to the clipboard, set the project rate to (256 x 44100 / 100) = 112896, then opened a new mono track and pasted in the audio data. That gave me 257 samples for 1 period of the waveform. I exported the data for 1 period using Audacity sample data export, opened it in a spreadsheet, multiplied the values by 65535, appended a comma after each one and copied this into a header file in the Arduino IDE. And all compiled and worked providing I keep the corner freq about 2000 Hz. It sounds not bad just a bit "muffled".
When I record the playback from teensy using Audacity I get 100 samples again for the waveform at that freq. 440 Hz. and the waveform doesn't look too bad.
This is the bit puzzling me.....I don't seem to be using all to values put in the 257 array..??....when I play the recorded freq of the sound..??
I did a rough test and recorded teensy output in Audacity, and viewed it at 44.1 sample rate in audacity.
Playing a 440 sound sample of 257 sample points for a 1 period in the teensy array gave me....
maxFREQ = 1200;
wave0.begin(0.3, wavefreq, WAVEFORM_ARBITRARY);
wave0.arbitraryWaveform(mysound[3], maxFREQ);
wave0.frequency(100); .......
etc...etc for 100, 171, 200, 257, 300, 440 freqs ..............
Freq...100 gave 440 samples for 1 period playback.
Freq...171 gave 257 samples for 1 period playback....this is full table..??
Freq...200 gave 220 samples for 1 period playback.
Freq...257 gave 172 samples for 1 period playback.
Freq...300 gave 148 samples for 1 period playback.
Freq...440 gave 100 samples for 1 period playback.
The teensy sounded frequency and measured frequency always was correct for each.
Maybe someone can through some light on this and what is the best way to convert an already recorded wav sound file to a data array.
Generally 44100 sound files are anti-alliased at 20 khz OR 22050 files are anti-aliased at 10 khz already.
Thanks for your help......