Last year, I finally weened myself completely off of Perl and learned Python in its place. Colors have never been brighter. There is such an elegance to Python, and I would love to see this in a computer music language.
The following mockup code is what you would get if your combined the awesome powers of Csound with the beauty of Python. I’m taking some liberties. The example is ignorant of i, k and a-rate. Instead of an orchestra/score pair, everything is combined as one file. And I’m introducing a concept for scheduling events, @, which tells when to do something.
#!/usr/bin/env slipmat import Wavetable from Gen import sine from Pitch import cpspch def sine_arp(dur, amp, pitch, lfo_freq): this['dur'] = dur pitch = cpspch(pitch) notes = [0, 3, 7, 8] arp = Wavetable.osc(1, lfo_freq, notes) freq = pitch + pitch * 2 ** (arp / 12.0) osc = Wavetable.osc(amp, pitch, sine(1000)) output osc def ping(amp=1.0, freq=262): this['dur'] = 0.5 output Wavetable.osc(amp, freq, sine(32)) if __name__ == '__main__': def harmonic_pattern(freq=100): @0 ping(1.0, freq) @1 ping(0.8, freq * 2) @2 ping(0.6, freq * 3) @3 ping(0.4, freq * 4) @4 ping(0.2, freq * 5) sine_arp(4, 0.5, 8.00, 1 / 4) @4 sine_arp(4, 0.5, 7.07, 1 / 4) @8 harmonic_pattern() @13 harmonic_patten(cpspch(7.00)) @18 ping()
I’ll comeback with a commented version of this in a few days. Though unlikely, it is my hope that some of you will take the time to try to figure out what is going on. My philosophy is that code should be human readable, and that syntax can help reinforce this.
Hey Jacob, I really like your idea. It makes working with csound very much
like supercollider or common music. In fact I have been working on
something similar. It would be great to have the readability of a score but be able to spawn algorithmic processes as well. Maybe also integrate some
computation math library.
Ultimately I assume the python script generates a .csd file that csound runs.
There is already something like this, it’s pysndobj
http://www.kgw.tu-berlin.de/~lac2007/papers/lac07_lazzarini.pdf
it could have been developed further if 1)days had 36 to 48 hours 2) I wasn’t so lazy 3)there was no csound5
Victor
@apalomba: I’d love to hear more about what you’re doing. As of right now, the code you see is purely fantasy. So it does nothing. I have experimented with writing a language that translates into Csound, but the more I play with it, the more I think it would be better to rebuild a new language from nearly the ground up. Not that I’m qualified. :)
@Victor: Very nice read. I’ll probably read it again tonight. Certainly some overlap. I think the big difference, besides pysndobj being real and this being fantasyland, is that my mockup wouldn’t actually be python, but a new language that heavily steals from it, but makes fundamental changes in order to better suit audio and music.
…or look at SuperCollider… (supercollider.sf.net). All these things are implemented already (scheduling, patterns, etc.). Slightly different syntax (more like C), naming conventions (eg. cpspch -> midicps) but also lots of familiar things for csound user.
“code should be human readable, and that syntax can help reinforce this”
yes, python enforces some coding patterns, but it’s really up to programmer to produce clean code. Constraints could help, but from time to time some more expressive and concise phrases are also helpful :)
regards from SC camp!
ak
@ak: SuperCollider will be a major topic of discussion here.
And I completely agree that it is still up to the programmer to produce clean code. I’ve read poor python code, as well as really clean perl code. Though some languages do have a tendency to be cleaner than others. Expressive and concise phrases, that too!
Pingback: Slipmat » Importing Modules and Reusing Code