Can I run a csound instrument in a microcontroller?

I'm wondering if there is a way to write an instrument in csound, and upload it to a microcontroller, such as the Arduino. Make Magazine sells a small keyboard for the Arduino.
Since the Arduino runs on AVR-C, and can be expanded with C++ libraries, I was hoping there was a way to load a CSound instrument to the Arduino, to play it with the little keyboard. (I would probably build larger, more playable keys.)

I'm more of a hardware guy, and don't know much programming - so I'm coming for help.
Can this be done?
Would I need to upload an entire csound library to the arduino, or could an individual instrument be compiled just for the arduino?
Or would a whole new version of csound need to be written, like was done for the OLPC?
(I would need your help with that, since I'm just getting the hang of if, then, and loops.)
Would csound have to be stripped down to run on the Arduino hardware? (16MHz, ATmega168 microprocessor)

Aside from myself, this could benefit the open source music community.

Unlikely, I think

The Arduino looks like a nice little gadget (saw it at the Maker Faire) but it'd be a tall order to use Csound on it.

For a start, an Instrument in an Orchestra file isn't really compiled -- in the sense of generated machine code. It is rather turned into some in-memory lists of the opcodes to be invoked. As I remember, the references in the lists are just pointers to the (current) memory locations of the opcodes, so it would be hard to keep a precompiled version around.

The opcodes themselves are of course compiled C code, but they are all present in the executable (well in version 5 many are in runtime libraries, but the idea is the same). I suppose it would be possible to set up some scheme that would make an executable with just the desired opcodes, but it would not be simple. (I couldn't track down how much memory an Arduino may have. It may not be enough for anything the size of even a trimmed Csound. Dunno.)

Finally there's the question of audio. It looks as if the board has a simple PWM output, (and that mini-synth kit you refer to has audio out) but driving it from Csound would likely be a lot of work.

Sorry to be a wet blanket, but...(:-/)

memory, other specs

The Arduino Duemilanove they're selling in the Maker Shed online uses an Atmega328, has 32k flash, 2k RAM, and 1k EEPROM for saving data

For more storage and audio output I could look at the Waveshield http://www.ladyada.net/make/waveshield/index.html that offers both an SD card slot and an audio DAC (quality is a little low, but thats ok.)

perhaps it would be possible to crate a simple opcode library to fit. although the csound libraries may be too big. One option may be to add custom hardware to add more memory.

My pessimistic side says it may be simpler to go with a hardware solution instead of csound, such as the soundgin ic from http://oopic.com/soundgin/

Csound on the Arduino

As far as I can tell, running Csound or any conceivable "scaled-down" version of Csound on an Arduino machine would be virtually impossible. The processors are not designed in any way for audio work especially with the precision that Csound uses.

From what I saw on the Arduino site and in the ATmega328 techspecs, these are 8-bit microprocessors. This implies that they use 8-bit integers for arithmetic operations. Csound really requires at least 32-bit integers. And Csound does not use integers for audio calculations, it uses floating-point numbers. I did not see any floating-point operations in the ATmega instruction set.

Even if you wrote a custom audio compiler from scratch that compiled Csound-like code (or whatever) into machine code for these devices, my opinion is that they would be seriously underpowered. 16 MHz is very slow by modern standards. It would probably be about the speed of the original IBM PC. (That might have had a slower clock speed but it was a 16-bit processor). So, whatever blips and bleeps an IBM PC was capable of would be about the limit. 32K of RAM would be pretty limiting too. For comparison, the previous major version of Csound (Csound 4) required about 1MB of RAM to do anything.

The prospect of running Csound on a mobile device is a very compelling one! I think you would have much more success trying to get it to run on your cellphone or iPhone/iPod Touch though. Those have much more powerful processors and better audio capabilities.

Interestingly, the Wikipedia article for the Arduino mentions using the platform to build custom controllers for several open-source music applications (Pd, Supercollider, etc.). This is a much more suitable job for it, as it does not involve any audio processing, just sending control signals to a computer running the audio software. Something like this could be hacked up with Csound no doubt.

A more appropriate hardware platform for an "embedded Csound" project would be a board with one or more DSP chips on it. There used to be software for compiling custom audio algorithms to PC soundcards such as the Audiomedia cards and other DSP boards. And their was a version of Csound that ran on such a board called "Extended Csound". Most such DSP coprocessor boards from the '90s though are now much slower than a general-purpose computer running Csound. An interesting modern platform that is comparable to the parallel, multiple-DSP architectures of the past is the IBM "Cell processor" which can be found inside of every Playstation 3. Csound already can be run on a PS3's main CPU, but if you wanted to port Csound to the PS3 in such a way that it would utilize all of the coprocessor cores that are optimized for audio and graphics processing, then that would be a formidable combination, indeed! I would buy a PS3 in a heartbeat to run that ;-)

Good luck with whatever projects you take on!

Anthony

avanafil z pak generic viagra cialis online viagra online pharmacy uk z-pak zpack generic cialis staxyn cialis uk kamagra uk z pack buy zithromax z-pack Canadian pharmacy ed pills cheap generic viagra zpak viagra uk buy viagra uk ed drugs Canadian pharmacy viagra