Csound Csound-dev Csound-tekno Search About

[Csnd] Python Score + CsBeats

Date2013-04-02 04:26
FromJacob Joaquin
Subject[Csnd] Python Score + CsBeats
Hey everyone,

One of the goals of Python Score is to be able to operate with other score environments, including CsBeats. While I suspected this was possible to do, I haven't really yet created an example that proves it can be done. Until now.

As it turns it, it's really quite easy with CsBeats since it's possible to pipe CsBeats scores into the command-line utility csbeats, returning a classical Csound score. Python Score is 100% combatible with classic Csound scores.

This is where it gets interesting, imho. Once Python Score has collected the output of programs like CsBeats, it can further process the score data. In the following code excerpt, the CsBeats score is converted and placed into the Python score timeline. Then it's run through an event delay, which inserts the converted score into Python Score again offset by 0.3 beats, with a reduced amplitude. And finally, all the amplitudes are reduced again to eliminate clipping.


    # Convert CsBeats score to classical Csound score and insert into score
    converted_score = csbeats(csbeats_score)
    score(converted_score)

    # Add converted score again offset by 0.3 beats with amplitude
    # reduced by 10 dB
    with cue(0.3):
        p_callback('i', [101, 102, 103], 5, lambda x: x - 10)
        score(converted_score)

    # Reduce volume by 6 dB
    pmap('i', [101, 102, 103], 5, lambda x: x - 6)


The full example is here.
https://github.com/jacobjoaquin/csd/blob/master/demo/pysco/csbeats_pysco.csd

Best,
Jake