midiarp — Generates arpeggios based on currently held MIDI notes.
midiarp constructs arpeggios based currently held MIDI notes. The opcode will output notes in the form of MIDI note numbers, and a metronomic signal that can be used to sequence the notes. Users can choose the rate at which the notes are generated, and may also choose from a set of arpeggio patterns.
kRate -- sets the rate in cycles per second at which new notes will be generated.
kMode -- Optional. Sets the mode of the arpeggio. 0 for up and down, 1, for up, 2 for down, and 3 for random. If left out, it will default to mode 0, up and down.
kMideNoteNum -- the current note number in the arpeggio pattern.
kTrigger -- a metronomic pulse that can be used to trigger playback of the notes in the arpeggio. This signal will output a 1 followed by 0s on each cycle. The frequency is set using the kRate input parameter.
Note | |
---|---|
It is important that the instrument which holds the midiarp opcode is not continuously triggered on each new MIDI note. To prevent this from happening use the massign opcode, as shown in the example below. |
This example shows how midiarp can be used to trigger arpeggios using a secondary instrument for playback. Instrument 100 listens to incoming MIDI notes, and then triggers playback using instrument 200. massign is used to prevent instrument 100 from being triggered each time a new MIDI note is pressed. This examples uses the file midiarp.csd.
Example 588. Example of the midiarp opcode
<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform ; Audio out Audio in No messages -odac -d -m0d --midi-key-cps=4 --midi-velocity-amp=5 -F midiChords.mid ; For Non-realtime ouput leave only the line below: ; -o midiin.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; Initialize the global variables. sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 massign 1, -1; prevent triggering of instrument with MIDI instr 200 kMode = 0 kTempo = 8 kNote, kTrigger midiarp kTempo kFilterFreq lfo 2000, .05, 1 ;if kTrigger is 1 trigger instrument 300 to play if kTrigger==1 then event "i", 300, 0, .5, .5, kNote, abs(kFilterFreq)+200 endif endin instr 300 kEnv expon p4, p3, .001 aOut vco2 kEnv, cpsmidinn(p5) ;convert note number to cps aFilter moogladder aOut, p6, .2 outs aFilter, aFilter endin </CsInstruments> <CsScore> i200 0 60 </CsScore> </CsoundSynthesizer>