Csound Csound-dev Csound-tekno Search About

[CSOUND-DEV:5470] Re: MIDI in cs5

Date2004-12-04 11:55
FromIain Duncan
Subject[CSOUND-DEV:5470] Re: MIDI in cs5
I have some very large full duplex midi ensembles that I can test with 
on Linux.

iain


jpff@codemist.co.uk wrote:
> I would like to move the incorporation of the portmidi library into
> Csound into a higher gear.  I have code that is supposed to work but
> at present I am not set up to have direct MIDI input to any of my
> machines.  So I would like someone with MIDI interests to test and
> comment (or do it all).  If one sets usePortMIDI=1 it tries to build
> this code rather than the original midirecv.c
>   Any takers?
> ==John ffitch
> 
> 

Date2004-12-04 17:57
Fromjpff@codemist.co.uk
Subject[CSOUND-DEV:5467] MIDI in cs5
I would like to move the incorporation of the portmidi library into
Csound into a higher gear.  I have code that is supposed to work but
at present I am not set up to have direct MIDI input to any of my
machines.  So I would like someone with MIDI interests to test and
comment (or do it all).  If one sets usePortMIDI=1 it tries to build
this code rather than the original midirecv.c
  Any takers?
==John ffitch

Date2004-12-05 01:21
Fromsteven yi
Subject[CSOUND-DEV:5471] SConstruct changes
Hi All,

I've made the change in the SConstruct for useFLTK to this:

if (commonEnvironment['useFLTK'] == 1 and fltkFound):

instead of:

if (commonEnvironment['useFLTK'] and fltkFound):

I've made this change before but it's been overwritten (a few times 
now... sigh).  Please do not overwrite this.  A prior email some months 
ago explained the case though I can not find it now. With the old code, 
the check is only to see if that value is true, which it will with 
anything but False or 0.  When values are given at the commandline, such as:

scons useFLTK=0

that 0 comes in as a string and not a number ("0" instead of 0), so the 
check passes though the intention is to set as false, and SCons will try 
to use FLTK anyways. 

Thanks,
steven

Date2004-12-05 01:53
Fromsteven yi
Subject[CSOUND-DEV:5472] More SConstruct changes - PortMIDI
Hi All,

I made further changes to the SConstruct file so that the configuration 
option usePortMIDI would work for me (Redhat Fedora Core 2, python 2.3). 

After compiling, I tested it out and didn't get any response from my 
midi controller (Oxygen8 USB).  I looked at pmidi.c but couldn't figure 
out what to pass in on the commandline for a device number. 

With csound4, things are working. I used a commandline of:

csound --sched -W -d -o dac -b128 -B256 -M /dev/midi01 mycsd.csd

with csound5, I tried:

csound5 --sched -W -d -o dac1 -b128 -B256 -M /dev/midi01 mycsd.csd

with variants, trying "-M 1", "-M /dev/midi01", "-M midi01", and other 
numbers for the items.  Csound never complained with any of those 
values, but neither did it respond to any midi information.

It seems like it'd be useful to do as it's been done for portaudio and 
have a function to list the devices. 

Will experiment further to see if it's not all user error on my part.

Thanks,
steven

Date2004-12-05 07:58
FromIain Duncan
Subject[CSOUND-DEV:5480] Re: [off-topic]
I'd say use Python.

Iain

Josep MComajuncosas wrote:
> Hi all,
> What library do you recommend me (c++, w2k) to read, manipulate and save
> standard midi files?
> 
> Thanks in advance!
> Josep M Comajuncosas
> 
> 

Date2004-12-05 13:00
Fromjpff@codemist.co.uk
Subject[CSOUND-DEV:5473] Re: SConstruct changes
I find this whole syntax of conditionals in scons confusing.  Why does
one have to say
    if (commonEnvironment['useFLTK'] == 1 and fltkFound):
but
    if (commonEnvironment['useportMIDI'] == 1 and portmidiFound):
does not?

==John ffitch

Date2004-12-05 13:05
Fromjpff@codemist.co.uk
Subject[CSOUND-DEV:5474] Re: More SConstruct changes - PortMIDI
I changed the code to list MIDI devices.  As far as I can tell midi
devices are numbered, but as I do not have any the opening of a MIDI
port just fails.  I would expect a command line of
     csound5 --sched -W -d -o dac1 -b128 -B256 -M 1 mycsd.csd
==John ffitch

Date2004-12-05 14:15
From"Josep MComajuncosas"
Subject[CSOUND-DEV:5475] [off-topic]
Hi all,
What library do you recommend me (c++, w2k) to read, manipulate and save
standard midi files?

Thanks in advance!
Josep M Comajuncosas

Date2004-12-05 17:18
Fromsteven yi
Subject[CSOUND-DEV:5479] Re: SConstruct changes
I switched useFLTK == 1 because by default, useFLTK is set to an integer 
1 in:

opts.Add('useFLTK',
    'Set to 1 to use FLTK for graphs and widget opcodes.',
    1)

When checking for usePortMIDI, I set it to userPortMIDI != 0 as:

opts.Add('usePortMIDI',
    'Use portmidi library rather than internal MIDI (experimental).',
    0)

is originally set to 0.  If I check for integer 1, as in:

if (commonEnvironment['usePortMIDI'] == 1 and portmidiFound):

this fails as for on my system, usePortMIDI ends up being "1" and not 1 when set on the commandline.  

I've made the changes as this is how it is on my system.  I know that on other systems it might not be the case that values set at the commandline come in as strings, however, it is the case for me.  The changes I put in should work for everyone. I'd recommend the following:

When using configuration options, make tests against them compare against their default values.  

This seems to be what I've had to do to make sure things will work for me here on my Fedora Core 2 system and also have it work elsewhere.

Thanks,
steven



jpff@codemist.co.uk wrote:

>I find this whole syntax of conditionals in scons confusing.  Why does
>one have to say
>    if (commonEnvironment['useFLTK'] == 1 and fltkFound):
>but
>    if (commonEnvironment['useportMIDI'] == 1 and portmidiFound):
>does not?
>
>==John ffitch
>
>
>
>  
>

Date2004-12-05 21:06
Fromsteven yi
Subject[CSOUND-DEV:5482] PortMIDI
Hi John and all,

Thanks for adding the listing of portmidi devices.  I'm using (I 
believe) the correct device number now (-M 1) and things seem to be 
opening correctly, but when running, all I get is the following error:

sensMIDI: retval errno 11

I tried calling Pm_GetErrorText on the number but got an invalid error 
number.

I added some code  to check if the Pm_OpenInput returned a non-zero 
(commited the code to CVS), but there is no error being reported, so the 
stream seems to be opening alright. 

I'm not sure the following is correct in pmidi.c:

 if ((retval=Pm_Poll(midistream))) {
        if (retval<0) printf(Str(X_1185,"sensMIDI: retval errno %d\n"), 
errno);
        if (retval == 0) {
          long n = Pm_Read(midistream, bufp, MBUFSIZ);
          bufp = mbuf;
          endatp = mbuf + n;
          return n;
        }
        else {
          printf(Str(X_1185,"sensMIDI: retval errno %d\n"),errno);
        }
      }
      return 0;

it seems to me that it should check if retval == 1, as the docs for 
Pm_Poll say it returns TRUE, FALSE, or and error number, and TRUE is set 
to 1.  Am I incorrect?

Thanks,
steven