midiarp

midiarp — Generates arpeggios based on currently held MIDI notes.

Description

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.

Syntax

kMidiNoteNum, kCountermidiarp kRate[, kMode]

Initialization

kRate -- sets the rate at which new notes will be generated and controls the frequency of the metronomic pulse signal.

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.

Performance

kMideNoteNum -- the current note number in the arpeggio pattern.

kCounter -- 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] 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.

Example

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 549. Example of the midiarp opcode

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in    No messages
-odac 	-d    -m0d     -M0  -+rtmidi=virtual ;;;RT audio I/O with MIDI in
; For Non-realtime ouput leave only the line below:
; -o midiin.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

massign 1, -1; prevent triggering of instrument with MIDI

instr 100
kMode = 3
kTempo = 6
kNote, kCounter midiarp kTempo

kFilterFreq oscil 2000, .05
;if kCounter is 1 trigger instrument 2 to play
if kCounter==1 then 	
	event "i", 200, 0, 2, kNote, kFilterFreq+2200
endif

endin

instr 200
kEnv expon .4, p3, .001
aOut vco2 kEnv, cpsmidinn(p4)*2		;convert note number to cps
aFilter moogladder aOut, p5, 0
outs aFilter, aFilter
endin

</CsInstruments>
<CsScore>
i100 0 1000
</CsScore>
</CsoundSynthesizer>


Credits

Author: Rory Walsh
2017