#103263 - Kaitain - Wed Sep 20, 2006 1:37 pm
Hi.
I'm trying to build some kind of musical instrument NOT based in samples. In order to do that, I need to play different waveforms and modify it's values in realtime.
Im a bit newbee in programming and homebrew, so I started with PAlibs. My first question is: can I use PAlib and libnds at he same time?
Because of the real time modifying, I can't do this using sound files: i have to create the waveform in real time. So, if I'm able to build and array with the info of, lets say, a sine wave, should be possible to play that?
(With PALibs, all I've seen are functions to play sound files. As I can gather, with libnds the same problem remains).
Is maybe possible to send to the sound functions something different that a sound file (like for example, the values that are inside an array)? Is there any function able to do that?
Making this possible sould turn the NDS in a powerfull synthetisher!!
Any help/suggestion will be very appreciated.
Thank you in advance.
^_^V
#103270 - dub3000 - Wed Sep 20, 2006 2:38 pm
the DS has a couple of channels that can do square waves with variable duty cycle - i used this with a theramin app i built.
otherwise, i think you'd just stream the generated sound into a circular buffer, like mp3 playback. not sure of what kind of latency to expect, i'd guess it'd be pretty low.
keep in mind you need to use fixed point math everywhere - you don't have much overhead for doing high quality sound. it ends up being like 10bit 33kHz output anyway, possibly lower - the DACs on the DS aren't exactly audiophile grade.
#103290 - OOPMan - Wed Sep 20, 2006 6:15 pm
I don't think there's any reason why you can't use PAlib and libnds. I would imagine that most of PAlib is built on top of libnds anyway...
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#103294 - Kaitain - Wed Sep 20, 2006 6:45 pm
Thanks a lot for your quick response.
"otherwise, i think you'd just stream the generated sound into a circular buffer, like mp3 playback. not sure of what kind of latency to expect, i'd guess it'd be pretty low. "
Ok, that's exactly what I'd like to do. Do you know how can I pass the content of a variable to the sound system? Is there any function that can do that?
Thanks
#103316 - Kaitain - Wed Sep 20, 2006 10:32 pm
Another idea: maybe if I modify the code of the function PA_PlaySound, just avoiding the steps of opening and closing the file, and accessing directly o the variables inside, I'd manage to lower the latency.
Does anybody know where I can find the source code of that function?
Thank you.
#103328 - tepples - Wed Sep 20, 2006 11:21 pm
You can send commands and data back and forth using shared memory synchronized either by values of VCOUNT (only one CPU should have access to a block of memory on any given scanline) or through the FIFO.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#103361 - OOPMan - Thu Sep 21, 2006 9:27 am
Erm, PALib is an open-source library last time I checked...
*checks again*
Bah, the website is giving me issues...
Anyone else able to confirm this?
Well, if the library is open, then just grab the source...
If not, well, you'll have to ask the developer...
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#103400 - josath - Thu Sep 21, 2006 4:23 pm
OOPMan wrote: |
Erm, PALib is an open-source library last time I checked...
*checks again*
Bah, the website is giving me issues...
Anyone else able to confirm this?
Well, if the library is open, then just grab the source...
If not, well, you'll have to ask the developer... |
it's a bit tough to get the source. last time i checked, there are 3 versions:
the latest version is ONLY in .exe format. you should be able to extract the source with a little bit of work.
there's a 3 month old source version on sourceforge
and a 6 month old version in CVS
though this may have changed by now.
#103415 - !cube - Thu Sep 21, 2006 7:09 pm
As someone already pointed out, what you need to do is play a looping sound and treat the sound data as a ringbuffer and mix audio data into that array in vertical blank or with a faster interrupt for a smaller latency. The thing is however that you're confined into using fixed point math and pretty much just simple wavetable synthesis since doing anything else in realtime with a 67MHz cpu is going to be too slow.
The problem with wavetable synthesis is that to get it sounding good requires quite a lot of memory and that is a luxury one doesn't have with DS.
#103424 - mastertop101 - Thu Sep 21, 2006 8:59 pm
josath wrote: |
it's a bit tough to get the source. last time i checked, there are 3 versions:
the latest version is ONLY in .exe format. you should be able to extract the source with a little bit of work.
there's a 3 month old source version on sourceforge
and a 6 month old version in CVS
though this may have changed by now. |
Hum..? if you run the exe, it gives you the source and installs PAlib, you can compilate (is it really a word ?) palib back..
#103457 - tepples - Fri Sep 22, 2006 3:33 am
!cube wrote: |
The thing is however that you're confined into using fixed point math and pretty much just simple wavetable synthesis since doing anything else in realtime with a 67MHz cpu is going to be too slow. |
Which of the following is too slow in fixed-point arithmetic? - Simple subtractive synthesis (e.g. TB-303 emulation)
- FM synthesis (e.g. Yamaha OPL series emulation)
- Karplus-Strong (echo based) synthesis
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#103492 - !cube - Fri Sep 22, 2006 9:22 am
tepples wrote: |
Which of the following is too slow in fixed-point arithmetic? - Simple subtractive synthesis (e.g. TB-303 emulation)
- FM synthesis (e.g. Yamaha OPL series emulation)
- Karplus-Strong (echo based) synthesis
|
Ok, maybe I should have put it differently: anything having larger polyphony, effects and non-aliasing oscillators with a 67MHz is going to be slow.. which is what I figured he wants to do.
Making a simple TB-303 emulator or using Karplus-Strong for a single string instrument is perfectly feasible even with a slow cpu and using just fixed point. OPL2 should be possible since it has only two operators but going to OPL3 will most probably already be out of the picture due to added operators and voice count.