Pandora Pandora Musical Instrument


oclbdk

Still Fresh
Joined
Oct 5, 2008
Messages
10
I'd like to create a sort of musical instrument out of the Pandora. I thought rather than going with the traditional piano found on devices with touch-screens, my program would utilize the gaming controls to adjust pitch/volume.

I am using SDL with C++ and I've looked at several libraries but cannot figure out how to create and output musical notes on the fly. I'm thinking it would be better to generate the notes based on the pitch and volume data from the controls rather than loading WAVs, so that the user is not restricted to a certain octave and other issues like that.

Anyone have an idea where I could start?
 
That probably depends on the sound system the Pandora uses, like ALSA or OSS. I'm looking into it, it's probably going to be fairly complicated.
I'm pretty sure there's a way to use the ALSA API to put customized data into soundbuffers, but I don't know anything about ALSA.

http://www.linuxjournal.com/article/6735

This article seems relevant, and I would also suggest looking for any tutorials or documentation at the ALSA website.
 
Well, the simplest way is to just generate some sort of sine/square/sawtooth wave on the fly.
If you want more complicated sounds, you could use a wave file as a basis, and use a library like http://www.surina.net/soundtouch/ to modulate the amplitude and frequency. Or you could try to interface with a synthesizer like TiMidity++ or cSound, probably by using MIDI.
 
I don't think you'll need to care about the underlying sound system.

As for sound libraries, SDL is fine for most purposes, but portaudio is really good for sound applications.
 
I don't think SDL can generate sounds in realtime like you're thinking of, portaudio looks like it would be really good for that sort of thing. Although it uses OSS. <_<

Csound is probably the simplest option, but I also know nothing about that.
 
lulzfish said:
I don't think SDL can generate sounds in realtime like you're thinking of, portaudio looks like it would be really good for that sort of thing. Although it uses OSS. <_<

Csound is probably the simplest option, but I also know nothing about that.
Well, you can fill your buffer from a callback function in SDL just like PortAudio can, though PortAudio seems a bit more specialized for the task. PortAudio can use several backends, in V19 it has ALSA, OSS and Jack for Linux. And cSound would probably be one of the hardest to get started with, since it's a pretty large and general purpose sound processing system, not just some library you plug in to play sounds.
 
Last edited by a moderator:
Zynaddsubfx: definitely possible! I'll get it going as soon as I get a Pandora in my hands .. or if not before then, using my BeagleBoard, which is currently being used for new development of a synth engine ..

KorgKaossilator-like app? Definitely possible, and probably quite easy to do.

I, for one, am mainly getting a Pandora to write music applications. I think its an ideal device for synthesis, sequencing, sample-playback, and effects processing, so for me its going to be *all about Audio* on the Pandora, personally. Of course, I'll play whatever games are good, too, heh heh .. but mostly I'll be hacking code for music-making.
 
I was talking to someone today who said he'd like to port his DS sequencer to Pandora, and perhaps write some other audio toys too. The more of this stuff the better!
 
Well I've had a crack at this recently and managed to make some nice sounding notes. All music notes really are, are sine-waves with harmonics, so these sites may help:
http://www.phy.mtu.edu/~suits/notefreqs.html
http://en.wikipedia.org/wiki/Harmonic_series_(music)

As for the implementation, I put the data into sound buffers for openal and repeated playing the buffer until the note stopped, I'm sure this wouldn't be that difficult in alsa or oss but since I never used them I don't know.

After that you need to look at things like velocity and after-touch to get your notes sounding better and find ways to make them sound more varied since simple sine-waves with harmonics just sounds like an electric piano.

If you do get stuck I have some sample code that I can show you.
 
When I was playing around with a guitar app on the DS, I just took the sound of a guitar string being plucked, then multiplied it by a number to get different notes. You can look up frequencies for different scales pretty easily on the web. That way I had a nice round, organic sound for the note, but only one file to worry about.
 
Hey guys, thanks for all the links. I've read through them and realize there is a lot more to this than I thought. After reading through tutorials on the various libraries that you guys sent me, as well as the source code for the Tuner tool for the n800 (http://n770galaxy.blogspot.com/2007/04/tuner-tool-on-n800.html -- really awesome! maybe get a port of that to the Pandora also? :D), I am completely lost on how to do it in C/C++. I can barely follow what any of the variable names or what the functions do exactly. Do you think there's a more gentle introduction to audio programming anywhere? lol I guess I really should learn all the terminology first.

I searched some more and found tkSnack (http://www.speech.kth.se/snack/) for Python which seems most like what I was looking for, even though it's not in C/C++. This code snippet seems most like what I need (http://www.daniweb.com/code/snippet414.html). I tried it out and flatmush is right, it doesn't sound too good. I think I'm going to end up doing what Yamara did and just record a piano key and use that sound as a base for different frequencies.

Also, just to be clear, what I'm planning isn't a full-featured synthesizer, and I don't even know if I'm going to code the functionality for the sounds to be played. My program is like the equivalent of a touchscreen piano, but instead of pressing onscreen "keys," you play the notes on the directional pad -- press up for an A, up and right simultaneously for a B, right for a C, etc.

Thanks again guys, I've learned so much! haha
 
Back
Top