Csound Csound-dev Csound-tekno Search About

[Csnd] Midi in on Linux

Date2011-01-28 10:34
FromErik de Castro Lopo
Subject[Csnd] Midi in on Linux
Hi all,

I've got a midi keyboard connected to a USB/Midi interface and I'm
running csound as:

    csound -d -+rtaudio=alsa -o dac -+rtmidi=alsa --midi-device=hw:1,0 \
        miditest.csd

with the miditest.csd file included below.

Unfortunately, I'm not getting any sound, even though I know this has
worked in the past. When I run it I get:

    PortMIDI real time MIDI plugin for Csound
    virtual_keyboard real time MIDI plugin for Csound
    PortAudio real-time audio module for Csound
    0dBFS level = 32768.0
    Csound version 5.13 (double samples) Jan 25 2011
    libsndfile-1.0.23
    UnifiedCSD:  Examples/Midi/miditest.csd
    STARTING FILE
    Creating options
    Creating orchestra
    Creating score
    orchname:  /tmp/csound-T6wme8.orc
    scorename: /tmp/csound-Nk02PQ.sco
    rtaudio: ALSA module enabled
    rtmidi: ALSA module enabled
    RAWWAVE_PATH: /usr/share/stk/rawwaves/
    orch compiler:
            instr   10
    Elapsed time at end of orchestra compile: real: 0.001s, CPU: 0.000s
    sorting score ...
            ... done
    Elapsed time at end of score sort: real: 0.001s, CPU: 0.000s
    Csound version 5.13 (double samples) Jan 25 2011
    midi channel 1 using instr 10
    midi channel 2 using instr 10
    midi channel 3 using instr 10
    midi channel 4 using instr 10
    midi channel 5 using instr 10
    midi channel 6 using instr 10
    midi channel 7 using instr 10
    midi channel 8 using instr 10
    midi channel 9 using instr 10
    midi channel 10 using instr 10
    midi channel 11 using instr 10
    midi channel 12 using instr 10
    midi channel 13 using instr 10
    midi channel 14 using instr 10
    midi channel 15 using instr 10
    midi channel 16 using instr 10
    displays suppressed
    0dBFS level = 32768.0
    ALSA: opened MIDI input device 'hw:1,0'
    orch now loaded
    audio buffered in 256 sample-frame blocks
    ALSA: -B 1024 not allowed on this device; using 1881 instead
    ALSA: -b 256 not allowed on this device; using 940 instead
    ALSA output: total buffer size: 1881, period size: 940
    writing 1024-byte blks of shorts to dac
    SECTION 1:
    ftable 1:
    ftable 2:
    B  0.000 .. 30.000 T 30.000 TT 30.000 M:      0.0      0.0
    Score finished in csoundPerform().
    inactive allocs returned to freespace
    end of score.              overall amps:      0.0      0.0
               overall samples out of range:        0        0
    0 errors in performance
    Elapsed time at end of performance: real: 30.007s, CPU: 2.470s
    5168 1024-byte soundblks of shorts written to dac


It finds the midi device and the lights on the interface flash
when I play notes on the midi keyboard.

Regular CSD files containing an ORC and a SCO section work fine.

Clues anyone?

Cheers,
Erik






sr		=	44100
kr		=	4410
ksmps	=	10
nchnls	=	2

instr 10
	iamp	ampmidi	5000
	icps	cpsmidi

	printf_i "Freq : %f\n", 1, icps

	agate	linenr	iamp,0.01,0.1,0.01
	asig	oscil	agate,icps,1
	outs	asig, asig
endin




;Score for simple MIDI instrument
f1 0 8192 10 1

;exponential curve for amp scaling
f2 0 129 5 .1 129 1

;Can be used with MIDI files up to 30 seconds long.
f0	30
e



Date2011-01-28 11:02
FromAndres Cabrera
SubjectRe: [Csnd] Midi in on Linux
Hi,

Csound uses the alsa rawmidi interface, so you probably need to load
the virmidi module to have a bridge with alsaseq, which is where the
keyboard will probably be:

modprobe snd-virmidi

You can also use -Ma (instead of --midi-device) to receive from all
available MIDI ports.

Cheers,
Andres

On Fri, Jan 28, 2011 at 10:34 AM, Erik de Castro Lopo
 wrote:
> Hi all,
>
> I've got a midi keyboard connected to a USB/Midi interface and I'm
> running csound as:
>
>    csound -d -+rtaudio=alsa -o dac -+rtmidi=alsa --midi-device=hw:1,0 \
>        miditest.csd
>
> with the miditest.csd file included below.
>
> Unfortunately, I'm not getting any sound, even though I know this has
> worked in the past. When I run it I get:
>
>    PortMIDI real time MIDI plugin for Csound
>    virtual_keyboard real time MIDI plugin for Csound
>    PortAudio real-time audio module for Csound
>    0dBFS level = 32768.0
>    Csound version 5.13 (double samples) Jan 25 2011
>    libsndfile-1.0.23
>    UnifiedCSD:  Examples/Midi/miditest.csd
>    STARTING FILE
>    Creating options
>    Creating orchestra
>    Creating score
>    orchname:  /tmp/csound-T6wme8.orc
>    scorename: /tmp/csound-Nk02PQ.sco
>    rtaudio: ALSA module enabled
>    rtmidi: ALSA module enabled
>    RAWWAVE_PATH: /usr/share/stk/rawwaves/
>    orch compiler:
>            instr   10
>    Elapsed time at end of orchestra compile: real: 0.001s, CPU: 0.000s
>    sorting score ...
>            ... done
>    Elapsed time at end of score sort: real: 0.001s, CPU: 0.000s
>    Csound version 5.13 (double samples) Jan 25 2011
>    midi channel 1 using instr 10
>    midi channel 2 using instr 10
>    midi channel 3 using instr 10
>    midi channel 4 using instr 10
>    midi channel 5 using instr 10
>    midi channel 6 using instr 10
>    midi channel 7 using instr 10
>    midi channel 8 using instr 10
>    midi channel 9 using instr 10
>    midi channel 10 using instr 10
>    midi channel 11 using instr 10
>    midi channel 12 using instr 10
>    midi channel 13 using instr 10
>    midi channel 14 using instr 10
>    midi channel 15 using instr 10
>    midi channel 16 using instr 10
>    displays suppressed
>    0dBFS level = 32768.0
>    ALSA: opened MIDI input device 'hw:1,0'
>    orch now loaded
>    audio buffered in 256 sample-frame blocks
>    ALSA: -B 1024 not allowed on this device; using 1881 instead
>    ALSA: -b 256 not allowed on this device; using 940 instead
>    ALSA output: total buffer size: 1881, period size: 940
>    writing 1024-byte blks of shorts to dac
>    SECTION 1:
>    ftable 1:
>    ftable 2:
>    B  0.000 .. 30.000 T 30.000 TT 30.000 M:      0.0      0.0
>    Score finished in csoundPerform().
>    inactive allocs returned to freespace
>    end of score.              overall amps:      0.0      0.0
>               overall samples out of range:        0        0
>    0 errors in performance
>    Elapsed time at end of performance: real: 30.007s, CPU: 2.470s
>    5168 1024-byte soundblks of shorts written to dac
>
>
> It finds the midi device and the lights on the interface flash
> when I play notes on the midi keyboard.
>
> Regular CSD files containing an ORC and a SCO section work fine.
>
> Clues anyone?
>
> Cheers,
> Erik
>
>
> 
> 
> 
> 
> sr              =       44100
> kr              =       4410
> ksmps   =       10
> nchnls  =       2
>
> instr 10
>        iamp    ampmidi 5000
>        icps    cpsmidi
>
>        printf_i "Freq : %f\n", 1, icps
>
>        agate   linenr  iamp,0.01,0.1,0.01
>        asig    oscil   agate,icps,1
>        outs    asig, asig
> endin
>
> 
> 
>
> ;Score for simple MIDI instrument
> f1 0 8192 10 1
>
> ;exponential curve for amp scaling
> f2 0 129 5 .1 129 1
>
> ;Can be used with MIDI files up to 30 seconds long.
> f0      30
> e
>
> 
> 
>
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2011-01-28 22:18
FromErik de Castro Lopo
SubjectRe: [Csnd] Midi in on Linux
Andres Cabrera wrote:

> Csound uses the alsa rawmidi interface, so you probably need to load
> the virmidi module to have a bridge with alsaseq, which is where the
> keyboard will probably be:
> 
> modprobe snd-virmidi

Thanks Andres, that was the missing ingredient.

Let the fun resume.

Cheers,
Erik