Cabbage Logo
Back to Cabbage Site

Not into audio processing, only MIDI and Sequencing

I have this working pretty well now.

Right now you can start/pause playback, and set the speed of playback. I can add some other things. I have written a complimentary midi info opcode that will let you know the file type, the number of tracks, the number of second per quarter note, etc.

I’ve pushed this now if you want to test it. I’ve pasted the simple .csd file I was using for testing below. The new installers should appear here when they are finished building.
https://dev.azure.com/rorywalsh/cabbage/_build/results?buildId=2477&view=results

<Cabbage>
form caption("Untitled") size(400, 300), colour(40), guiMode("queue") pluginId("def1")
rslider bounds(20, 10, 60, 60) channel("transpose") range(-24, 24, 0, 1, 1), text("Transpose")
checkbox bounds(156, 10, 100, 30) channel("play"), text("Play"), 
rslider bounds(88, 10, 60, 60) channel("speed") range(.5, 2, 1, 1, 0.001), text("Speed")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -m0d
</CsOptions>
<CsInstruments>010 
; Initialize the global variables. 
ksmps = 128
nchnls = 2
0dbfs = 1


instr 1
    SMidifile init "/Users/rwalsh/Desktop/Prelude1.mid"
    cabbageMidiInfo SMidifile   ;print info about the midi file
    kEventIndex = 0
    kNoteIndex init 0
    iSkipTime = 0
    
    ;returns arrays of MIDI event data - kstatus[], kchan[], kNote[], kVel[]
    ;kNumEvents is the number of event in a single k-cycle
    ;kTrig is a trigger signal - it is 1 when a new event has been sent, otherwise it's 0
    kstatus[], kchan[], kNote[], kVel[], kNumEvents, kTrig cabbageMidiReader SMidifile, 1, cabbageGetValue("play"), cabbageGetValue("speed"), iSkipTime
    knotelength    init    0
    knoteontime    init    0


;printk2 kNumEvents
    if kTrig == 1 then
        while kEventIndex < kNumEvents do
            if (kstatus[kEventIndex] == 128) then            //note off
                turnoff2 2, 1, 1
            elseif (kstatus[kEventIndex] == 144) then        //note on 
                event "i", 2, 0, 10, kNote[kEventIndex]+cabbageGetValue:k("transpose"), kVel[kEventIndex]/127       
            endif
            kEventIndex += 1
        od
    endif
endin

instr 2
    kEnv madsr 0.1, .2, .6, .1 
    a1 oscili kEnv*p5, cpsmidinn(p4), 1
    outs a1*.01, a1*.01
endin


</CsInstruments>
<CsScore>
f1 0 4096 10 1 0 .25 0 .17
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
i1 0 [60*60*24*7] 
;i3 0 10
</CsScore>
</CsoundSynthesizer>

Awesome, great job! I will give it a try as soon as possible. I will try to look into adding cSound/Cabbage projects to my build system and see if there’s any issues to be reported.

By the way, did you try this with more dense Midi files with 10 tracks or more?

No, but you can set the team you want to read. It’s over of the input parameters:

… Midifile, track, play, skipTime