Playing arbitrary waveforms and/or .WAV files

Playing arbitrary waveforms and/or .WAV files

Postby GoVirtual » Sat Jun 02, 2012 9:13 pm

Hello,

Just got my shiny new Audio Codec Shield today and have been playing with is using a Maple.

All of the examples work as described, very neat project.

Question: does this shield provide for the ability to create custom waveforms/sounds, and can I play a .WAV file through the output somehow? If so, is there a pointer in the documentation or library for this?

Thanks in advance

GP
GoVirtual
 
Posts: 2
Joined: Sat Jun 02, 2012 9:11 pm

Re: Playing arbitrary waveforms and/or .WAV files

Postby guest » Sun Jun 03, 2012 12:20 pm

you can play arbitrary waveforms
but right now there is only support for waveforms stored in memory
so you cant read them out of an SD card or something like that

if you take a look at the sine_generator example
there is a line that says this:
Code: Select all
int16 sinewave[] __FLASH__ = {
  #include <sinetable.inc>
};


this puts a wavetable into program memory
the wavetable is stored in the folder ../AudioCodec_Maple
so all you have to do
is put your wavetable in that same directory
and then change your call to it above

the difficult part might be creating the wavetable
you need a text file with comma seperated values (CSV)
you can export .CSV from most spreadsheet programs
or generate them in puredata

the limiting factor is the memory length
the maple has 128k
so at 16b/44k thats a bit more than a second of sample time
which is pretty good for a wavetable synth
but not adequate for recorded sound playback

we are looking into getting SD card read capability
but i cant gaurantee that it will work

also
if you have questions about creating a wavetable
please post back and i can probably help out
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Playing arbitrary waveforms and/or .WAV files

Postby GoVirtual » Sun Jun 03, 2012 7:02 pm

Thank you for the reply.

How about dynamically generating tones at specific intervals and frequencies? Is this something that can be done natively by the library without having to load an external wavetable?

For example, if I wanted to generate a 200Hz sound on the left channel and a 190Hz sound on the right channel, both of which persist for exactly one second, is that possible using this method?
GoVirtual
 
Posts: 2
Joined: Sat Jun 02, 2012 9:11 pm

Re: Playing arbitrary waveforms and/or .WAV files

Postby guest » Sun Jun 03, 2012 7:09 pm

we dont have a "tone" library right now
but it shouldnt be bad to hack something like that
the sine_generator example makes tones of variable frequencies
controlled by one of the mod pots
you could set the frequency instead by a fixed value
and then have it go through the loop a fixed number of times
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Playing arbitrary waveforms and/or .WAV files

Postby chipaudette » Sun Jun 10, 2012 5:25 pm

You could totally compute your waveform on-the-fly if that's what you wanted to do. Granted, it is certainly faster and easier to use wavetable lookup than to call the sine function from the C math library, but at the Maple's fast speed, I bet it can do a sine call within the interrupt service routine.

If it turns out that it's not fast enough (which would surprise me), you can use the wavetable lookup to generate a sine at arbitrary frequencies. The example code is intended to be simple, so it ends up discretizing the available frequencies by quite a bit. If you want to do (nearly) arbitrary frequencies, google "32-bit phase accumulator wavetable". When i did the search, I liked the article that showed up from Nuts and Volts (http://nutsvolts.texterity.com/nutsvolt ... pg=29#pg29).

Depending upon how much experience you have in this area, you may need to do more reading (or less) to do this phase accumulator thing as a method of better using a wavetable. So, as I said at the beginning, you can probably just use the sine function from the math.h C/C++ library and not have to deal with any of these complications.

Good luck.

Chip
chipaudette
 
Posts: 5
Joined: Fri Jan 27, 2012 8:14 am

Re: Playing arbitrary waveforms and/or .WAV files

Postby vaxon » Mon Jun 11, 2012 10:24 am

Its not too tough to convert Wavs to csv.

Cool Edit pro 2 can output ascii. then you can take that, put it in a spreadsheet to convert the numbers to integers, then open that file in a text editor that can replace line breaks with commas.
(The program "Wavosaur" as well as a few others can output text as well but always gave me weird results. Cool Edit always worked and reminded me of the '90s so I went with it.)

I'm sure there's a much simpler way if I made a pyton script or something but this gets the job done.
vaxon
 
Posts: 4
Joined: Mon Jun 11, 2012 10:01 am


Return to Audio Codec Shield

Who is online

Users browsing this forum: No registered users and 1 guest


cron