FLOSS Manuals

 English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

CSOUND Español

RECEIVING EVENTS BY MIDIIN

RECIBIR EVENTOS POR MIDIIN

Csound provides a variety of opcodes, such as cpsmidi, ampmidi and ctrl7, which facilitate the reading of incoming midi data into Csound with minimal fuss. These opcodes allow us to read in midi information without us having to worry about parsing status bytes and so on. Occasionally though when more complex midi interaction is required, it might be advantageous for us to scan all raw midi information that is coming into Csound. The midiin opcode allows us to do this.

Csound proporciona una variedad de opcodes, como cpsmidi, ampmidi y ctrl7, que facilitan la lectura de los datos MIDI entrantes en Csound con un mínimo de alboroto. Estos opcodes nos permiten leer en la información MIDI sin que tengamos que preocuparnos por analizar los bytes de estado y así sucesivamente. Ocasionalmente, aunque cuando se requiere una interacción midi más compleja, puede ser ventajoso para nosotros escanear toda la información MIDI cruda que está entrando en Csound. El opcode midiin nos permite hacer esto.

In the next example a simple midi monitor is constructed. Incoming midi events are printed to the terminal with some formatting to make them readable. We can disable Csound's default instrument triggering mechanism (which in this example we don't want to use) by writing the line:

En el ejemplo siguiente se construye un monitor midi simple. Los eventos midi entrantes se imprimen en el terminal con algún formato para que sean legibles. Podemos desactivar el mecanismo de activación de instrumentos por defecto de Csounds (que en este ejemplo no queremos usar) escribiendo la línea:

massign 0,0

just after the header statement (sometimes referred to as instrument 0).

Justo después de la instrucción de cabecera (a veces denominada instrumento 0).

For this example to work you will need to ensure that you have activated live midi input within Csound, either by using the -M flag or from within the QuteCsound configuration menu. You will also need to make sure that you have a midi keyboard or controller connected. You may also want to include the -m0 flag which will disable some of Csound's additional messaging output and therefore allow our midi printout to be presented more clearly.

Para que este ejemplo funcione, deberá asegurarse de que ha activado la entrada midi en directo dentro de Csound, utilizando el indicador -M o desde el menú de configuración de QuteCsound. También tendrá que asegurarse de que tiene un teclado MIDI o controlador conectado. También es posible que desee incluir el indicador -m0 que desactivará algunas de las salidas de mensajería adicionales de Csounds y por lo tanto permitirá que nuestra impresión de midi se presente con mayor claridad.

The status byte tells us what sort of midi information has been received. For example, a value of 144 tells us that a midi note event has been received, a value of 176 tells us that a midi controller event has been received, a value of 224 tells us that pitch bend has been received and so on.

El byte de estado nos indica qué tipo de información MIDI se ha recibido. Por ejemplo, un valor de 144 nos dice que se ha recibido un evento de nota midi, un valor de 176 nos dice que se ha recibido un evento de controlador midi, un valor de 224 nos dice que se ha recibido un pitch bend, etc.

The meaning of the two data bytes depends on what sort of status byte has been received. For example if a midi note event has been received then data byte 1 gives us the note velocity and data byte 2 gives us the note number. If a midi controller event has been received then data byte 1 gives us the controller number and data byte 2 gives us the controller value.

   El significado de los dos bytes de datos depende de qué tipo de byte de estado se ha recibido. Por ejemplo, si se ha recibido un evento de nota midi, entonces el byte de datos 1 nos da la velocidad de la nota y el byte de datos 2 nos da el número de la nota. Si se ha recibido un evento de controlador midi, entonces el byte de datos 1 nos da el número de controlador y el byte de datos 2 nos da el valor de controlador.

EXAMPLE 07A01_midiin_print.csd

<CsoundSynthesizer>
<CsOptions>
-Ma -m0
; activates all midi devices, suppress note printings
</CsOptions>

<CsInstruments>
; Example by Iain McCurdy

; no audio so 'sr' or 'nchnls' aren't relevant
ksmps = 32

; using massign with these arguments disables default instrument triggering
massign	0,0

  instr 1
kstatus, kchan, kdata1, kdata2  midiin            ;read in midi
ktrigger  changed  kstatus, kchan, kdata1, kdata2 ;trigger if midi data changes
 if ktrigger=1 && kstatus!=0 then          ;if status byte is non-zero...
; -- print midi data to the terminal with formatting --
 printks "status:%d%tchannel:%d%tdata1:%d%tdata2:%d%n"\
                                    ,0,kstatus,kchan,kdata1,kdata2
 endif
  endin

</CsInstruments>
<CsScore>
i 1 0 3600 ; instr 1 plays for 1 hour
</CsScore>
</CsoundSynthesizer>

The principle advantage of using the midiin opcode is that, unlike opcodes such as cpsmidi, ampmidi and ctrl7 which only receive specific midi data types on a specific channel, midiin 'listens' to all incoming data including system exclusive messages. In situations where elaborate Csound instrument triggering mappings that are beyond the capabilities of the default triggering mechanism are required, then the use of midiin might be beneficial.

La principal ventaja de usar el opcode midiin es que, a diferencia de opcodes como cpsmidi, ampmidi y ctrl7 que sólo reciben tipos de datos midi específicos en un canal específico, midiin escucha todos los datos entrantes incluyendo mensajes exclusivos del sistema. En situaciones en las que se requieren asignaciones elaboradas de disparo de instrumentos Csound que están más allá de las capacidades del mecanismo de disparo por defecto, entonces el uso de midiin podría ser beneficioso.

 

RECEIVING EVENTS BY MIDIIN Csound provides a variety of opcodes, such as cpsmidi, ampmidi and ctrl7, which facilitate the reading of incoming midi data into Csound with minimal fuss. These opcodes allow us to read in midi information without us having to worry about parsing status bytes and so on. Occasionally though when more complex midi interaction is required, it might be advantageous for us to scan all raw midi information that is coming into Csound. The midiin opcode allows us to do this. In the next example a simple midi monitor is constructed. Incoming midi events are printed to the terminal with some formatting to make them readable. We can disable Csound's default instrument triggering mechanism (which in this example we don't want to use) by writing the line: massign 0,0 just after the header statement (sometimes referred to as instrument 0). For this example to work you will need to ensure that you have activated live midi input within Csound, either by using the -M flag or from within the QuteCsound configuration menu. You will also need to make sure that you have a midi keyboard or controller connected. You may also want to include the -m0 flag which will disable some of Csound's additional messaging output and therefore allow our midi printout to be presented more clearly. The status byte tells us what sort of midi information has been received. For example, a value of 144 tells us that a midi note event has been received, a value of 176 tells us that a midi controller event has been received, a value of 224 tells us that pitch bend has been received and so on. The meaning of the two data bytes depends on what sort of status byte has been received. For example if a midi note event has been received then data byte 1 gives us the note velocity and data byte 2 gives us the note number. If a midi controller event has been received then data byte 1 gives us the controller number and data byte 2 gives us the controller value. EXAMPLE 07A01_midiin_print.csd -Ma -m0 ; activates all midi devices, suppress note printings ; Example by Iain McCurdy ; no audio so 'sr' or 'nchnls' aren't relevant ksmps = 32 ; using massign with these arguments disables default instrument triggering massign 0,0 instr 1 kstatus, kchan, kdata1, kdata2 midiin ;read in midi ktrigger changed kstatus, kchan, kdata1, kdata2 ;trigger if midi data changes if ktrigger=1 && kstatus!=0 then ;if status byte is non-zero... ; -- print midi data to the terminal with formatting -- printks "status:%d%tchannel:%d%tdata1:%d%tdata2:%d%n"\ ,0,kstatus,kchan,kdata1,kdata2 endif endin i 1 0 3600 ; instr 1 plays for 1 hour The principle advantage of using the midiin opcode is that, unlike opcodes such as cpsmidi, ampmidi and ctrl7 which only receive specific midi data types on a specific channel, midiin 'listens' to all incoming data including system exclusive messages. In situations where elaborate Csound instrument triggering mappings that are beyond the capabilities of the default triggering mechanism are required, then the use of midiin might be beneficial.

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.