midremot
Prev | Orchestra Opcodes and Operators | Next

## midremot

midremot — An opcode which can be used to implement a remote midi orchestra. This opcode will send midi events from a source machine to one destination.

## Description

With the midremot and midglobal opcodes you are able to perform instruments on remote machines and control them from a master machine. The remote opcodes are implemented using the master/client model. All the machines involved contain the same orchestra but only the master machine contains the information of the midi score. During the performance the master machine sends the midi events to the clients. The midremot opcode will send events from a source machine to one destination if you want to send events to many destinations (broadcast) use the midglobal opcode instead. These two opcodes can be used in combination.

## Syntax

    midremot idestination, isource, instrnum [,instrnum...]

## Initialization

idestination -- a string that is the intended host computer (e.g. 192.168.0.100). This is the destination host which receives the events from the given instrument.

isource -- a string that is the intended host computer (e.g. 192.168.0.100). This is the source host which generates the events of the given instrument and sends it to the address given by idestination.

instrnum -- a list of instrument numbers which will be played on the destination machine

## Examples

Here is an example of the midremot opcode. It uses the files insremot.csd.

Example 373. Example of the insremot opcode.

The example shows a Bach fugue played on 4 remote computers. The master machine is named "192.168.1.100", client1 "192.168.1.101" and so on. Start the clients on each machine (they will be waiting to receive the events from the master machine) and then start the master. Here is the command on linux to start a client (csound -dm0 -odac -+rtaudio=alsa midremot.csd -+rtmidi=Null), and the command on the master machine will look like this (csound -dm0 -odac -+rtaudio=alsa midremot.csd -F midremot.mid).

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    ; Audio out   Audio in
    -odac           -iadc     ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o midremot.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>
    sr	= 44100
    kr	= 441
    ksmps	= 100
    nchnls = 2

    massign 1,1
    massign 2,2
    massign 3,3
    massign 4,4
    massign 5,5

    ga1 init 0
    ga2 init 0

    gi1	sfload	   "19Trumpet.sf2"

    gi2	sfload	   "01hpschd.sf2"

    gi3	sfload	   "07AcousticGuitar.sf2"

    gi4	sfload	   "22Bassoon.sf2"

    gitab	ftgen	1,0,1024,10,1

    midremot "192.168.1.100", "192.168.1.101", 1
    midremot "192.168.1.100", "192.168.1.102", 2
    midremot "192.168.1.100", "192.168.1.103", 3

    midglobal "192.168.1.100", 5

    	instr 1
    	sfpassign	   0, gi1
    ifreq	cpsmidi
    iamp	ampmidi 10
    inum	notnum
    ivel	veloc
    kamp	linsegr	1,1,1,.1,0
    kfreq	init	1
    a1,a2	sfplay	ivel,inum,kamp*iamp,kfreq,0,0
    	outs	a1,a2
    vincr ga1, a1*.5
    vincr ga2, a2*.5
    	endin

    	instr 2
    	sfpassign	0,    gi2
    ifreq	cpsmidi
    iamp	ampmidi 15
    inum	notnum
    ivel	veloc
    kamp	linsegr	1,1,1,.1,0
    kfreq	init	1
    a1,a2	sfplay	ivel,inum,kamp*iamp,kfreq,0,0
    	outs	a1,a2
    vincr ga1, a1*.4
    vincr ga2, a2*.4
    	endin

    	instr 3
    	sfpassign	0,    gi3
    ifreq	cpsmidi
    iamp	ampmidi 10
    inum	notnum
    ivel	veloc
    kamp	linsegr	1,1,1,.1,0
    kfreq	init	1
    a1,a2	sfplay	ivel,inum,kamp*iamp,kfreq,0,0
    	outs	a1,a2
    vincr ga1, a1*.5
    vincr ga2, a2*.5
    	endin

    	instr 4
    	sfpassign	0,    gi4
    ifreq	cpsmidi
    iamp	ampmidi 15
    inum	notnum
    ivel	veloc
    kamp	linsegr	1,1,1,.1,0
    kfreq	init	1
    a1,a2	sfplay	ivel,inum,kamp*iamp,kfreq,0,0
    	outs	a1,a2
    vincr ga1, a1*.5
    vincr ga2, a2*.5
    	endin

    instr	5
          kamp midic7 1,0,1
          denorm ga1
          denorm ga2
    aL, aR  reverbsc ga1, ga2, .9, 16000, sr, 0.5
            outs aL, aR
    	ga1	=	0
         ga2   =     0
    endin

    </CsInstruments>
    <CsScore>
    ; Score
    f0  160
    </CsScore>
    </CsoundSynthesizer>

## See also

insglobal, insremot, midglobal, remoteport

## Credits

Author: Simon Schampijer
2006

New in version 5.03

Prev | Up | Next
miditempo | Home | midglobal