[PD-cvs] pd/src s_midi_alsa.c,1.1.2.2.2.6,1.1.2.2.2.6.2.1
Mathieu Bouchard
matju at users.sourceforge.net
Wed Dec 20 11:34:41 CET 2006
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6360
Modified Files:
Tag: desiredata
s_midi_alsa.c
Log Message:
reformatted; removed unused vars
Index: s_midi_alsa.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_midi_alsa.c,v
retrieving revision 1.1.2.2.2.6
retrieving revision 1.1.2.2.2.6.2.1
diff -C2 -d -r1.1.2.2.2.6 -r1.1.2.2.2.6.2.1
*** s_midi_alsa.c 30 Nov 2005 13:36:58 -0000 1.1.2.2.2.6
--- s_midi_alsa.c 20 Dec 2006 10:34:39 -0000 1.1.2.2.2.6.2.1
***************
*** 23,35 ****
static int alsa_nmidiout;
static int alsa_midioutfd[MAXMIDIOUTDEV];
-
static snd_seq_t *midi_handle;
-
static snd_midi_event_t *midiev;
!
!
! static unsigned short CombineBytes(unsigned char First, unsigned char Second)
! {
unsigned short _14bit;
_14bit = (unsigned short)Second;
--- 23,30 ----
static int alsa_nmidiout;
static int alsa_midioutfd[MAXMIDIOUTDEV];
static snd_seq_t *midi_handle;
static snd_midi_event_t *midiev;
! static unsigned short CombineBytes(unsigned char First, unsigned char Second) {
unsigned short _14bit;
_14bit = (unsigned short)Second;
***************
*** 39,46 ****
}
! void sys_alsa_do_open_midi(int nmidiin, int *midiinvec,
! int nmidiout, int *midioutvec)
! {
!
char portname[50];
int err = 0;
--- 34,38 ----
}
! void sys_alsa_do_open_midi(int nmidiin, int *midiinvec, int nmidiout, int *midioutvec) {
char portname[50];
int err = 0;
***************
*** 57,107 ****
if (nmidiout == 0 && nmidiin == 0) return;
!
! if(nmidiin>MAXMIDIINDEV )
! {
post("midi input ports reduced to maximum %d", MAXMIDIINDEV);
nmidiin=MAXMIDIINDEV;
! }
! if(nmidiout>MAXMIDIOUTDEV)
! {
post("midi output ports reduced to maximum %d", MAXMIDIOUTDEV);
nmidiout=MAXMIDIOUTDEV;
! }
!
! if (nmidiin>0 && nmidiout>0)
! err = snd_seq_open(&midi_handle,"default",SND_SEQ_OPEN_DUPLEX,0);
! else if (nmidiin > 0)
! err = snd_seq_open(&midi_handle,"default",SND_SEQ_OPEN_INPUT,0);
! else if (nmidiout > 0)
! err = snd_seq_open(&midi_handle,"default",SND_SEQ_OPEN_OUTPUT,0);
!
! if (err!=0)
! {
sys_setalarm(1000000);
post("couldn't open alsa sequencer");
return;
}
! for (i=0;i<nmidiin;i++)
! {
int port;
sprintf(portname,"Pure Data Midi-In %d",i+1);
port = snd_seq_create_simple_port(midi_handle,portname,
! SND_SEQ_PORT_CAP_WRITE |SND_SEQ_PORT_CAP_SUBS_WRITE,
! SND_SEQ_PORT_TYPE_APPLICATION);
! alsa_midiinfd[i] = port;
! if (port < 0) goto error;
}
!
! for (i=0;i<nmidiout;i++)
! {
int port;
sprintf(portname,"Pure Data Midi-Out %d",i+1);
port = snd_seq_create_simple_port(midi_handle,portname,
! SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ,
! SND_SEQ_PORT_TYPE_APPLICATION);
! alsa_midioutfd[i] = port;
! if (port < 0) goto error;
}
-
snd_seq_client_info_malloc(&alsainfo);
snd_seq_get_client_info(midi_handle,alsainfo);
--- 49,84 ----
if (nmidiout == 0 && nmidiin == 0) return;
! if(nmidiin>MAXMIDIINDEV ) {
post("midi input ports reduced to maximum %d", MAXMIDIINDEV);
nmidiin=MAXMIDIINDEV;
! }
! if(nmidiout>MAXMIDIOUTDEV) {
post("midi output ports reduced to maximum %d", MAXMIDIOUTDEV);
nmidiout=MAXMIDIOUTDEV;
! }
! if (nmidiin>0 && nmidiout>0) err = snd_seq_open(&midi_handle,"default",SND_SEQ_OPEN_DUPLEX,0);
! else if (nmidiin > 0) err = snd_seq_open(&midi_handle,"default",SND_SEQ_OPEN_INPUT,0);
! else if (nmidiout > 0) err = snd_seq_open(&midi_handle,"default",SND_SEQ_OPEN_OUTPUT,0);
! if (err!=0) {
sys_setalarm(1000000);
post("couldn't open alsa sequencer");
return;
}
! for (i=0;i<nmidiin;i++) {
int port;
sprintf(portname,"Pure Data Midi-In %d",i+1);
port = snd_seq_create_simple_port(midi_handle,portname,
! SND_SEQ_PORT_CAP_WRITE |SND_SEQ_PORT_CAP_SUBS_WRITE, SND_SEQ_PORT_TYPE_APPLICATION);
! alsa_midiinfd[i] = port;
! if (port < 0) goto error;
}
! for (i=0;i<nmidiout;i++) {
int port;
sprintf(portname,"Pure Data Midi-Out %d",i+1);
port = snd_seq_create_simple_port(midi_handle,portname,
! SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ, SND_SEQ_PORT_TYPE_APPLICATION);
! alsa_midioutfd[i] = port;
! if (port < 0) goto error;
}
snd_seq_client_info_malloc(&alsainfo);
snd_seq_get_client_info(midi_handle,alsainfo);
***************
*** 191,226 ****
if (portno >= 0 && portno < alsa_nmidiout)
{
! if (a >= 224) // pitchbend
! {
channel = a-224;
snd_seq_ev_set_pitchbend(&ev,channel,CombineBytes(b,c));
! }
! else if (a >= 208) // touch
! {
channel = a-208;
snd_seq_ev_set_chanpress(&ev,channel,b);
! }
! else if (a >= 192) // program
! {
channel = a-192;
snd_seq_ev_set_pgmchange(&ev,channel,b);
! }
! else if (a >= 176) // controller
! {
channel = a-176;
snd_seq_ev_set_controller(&ev,channel,b,c);
! }
! else if (a >= 160) // polytouch
! {
channel = a-160;
snd_seq_ev_set_keypress(&ev,channel,b,c);
! }
! else if (a >= 144) // note
! {
channel = a-144;
! if (c)
! snd_seq_ev_set_noteon(&ev,channel,b,c);
! else
! snd_seq_ev_set_noteoff(&ev,channel,b,c);
}
snd_seq_ev_set_direct(&ev);
--- 168,190 ----
if (portno >= 0 && portno < alsa_nmidiout)
{
! if (a >= 224) { // pitchbend
channel = a-224;
snd_seq_ev_set_pitchbend(&ev,channel,CombineBytes(b,c));
! } else if (a >= 208) { // touch
channel = a-208;
snd_seq_ev_set_chanpress(&ev,channel,b);
! } else if (a >= 192) { // program
channel = a-192;
snd_seq_ev_set_pgmchange(&ev,channel,b);
! } else if (a >= 176) { // controller
channel = a-176;
snd_seq_ev_set_controller(&ev,channel,b,c);
! } else if (a >= 160) { // polytouch
channel = a-160;
snd_seq_ev_set_keypress(&ev,channel,b,c);
! } else if (a >= 144) { // note
channel = a-144;
! if (c) snd_seq_ev_set_noteon(&ev,channel,b,c);
! else snd_seq_ev_set_noteoff(&ev,channel,b,c);
}
snd_seq_ev_set_direct(&ev);
***************
*** 239,243 ****
{
// repack into 1 byte char and put somewhere to point at
- unsigned char data = (unsigned char)byte;
unsigned char *dataptr = malloc(1);
memcpy(dataptr,&byte,1);
--- 203,206 ----
***************
*** 259,271 ****
int i;
snd_seq_event_t *midievent = NULL;
-
if (alsa_nmidiout == 0 && alsa_nmidiin == 0) return;
-
snd_midi_event_init(midiev);
-
if (!alsa_nmidiout && !alsa_nmidiin) return;
count = snd_seq_event_input_pending(midi_handle,1);
! if (count != 0)
! count = snd_seq_event_input(midi_handle,&midievent);
if (midievent != NULL)
{
--- 222,230 ----
int i;
snd_seq_event_t *midievent = NULL;
if (alsa_nmidiout == 0 && alsa_nmidiin == 0) return;
snd_midi_event_init(midiev);
if (!alsa_nmidiout && !alsa_nmidiin) return;
count = snd_seq_event_input_pending(midi_handle,1);
! if (count != 0) count = snd_seq_event_input(midi_handle,&midievent);
if (midievent != NULL)
{
***************
*** 278,292 ****
}
! void sys_alsa_close_midi()
! {
alsa_nmidiin = alsa_nmidiout = 0;
! if(midi_handle)
! {
snd_seq_close(midi_handle);
! if(midiev)
! {
! snd_midi_event_free(midiev);
! }
! }
}
--- 237,246 ----
}
! void sys_alsa_close_midi() {
alsa_nmidiin = alsa_nmidiout = 0;
! if(midi_handle) {
snd_seq_close(midi_handle);
! if(midiev) snd_midi_event_free(midiev);
! }
}
***************
*** 294,302 ****
static int alsa_nmidiindevs, alsa_nmidioutdevs, alsa_initted;
! void midi_alsa_init(void)
! {
! int i;
! if (alsa_initted)
! return;
alsa_initted = 1;
}
--- 248,253 ----
static int alsa_nmidiindevs, alsa_nmidioutdevs, alsa_initted;
! void midi_alsa_init(void) {
! if (alsa_initted) return;
alsa_initted = 1;
}
***************
*** 306,319 ****
{
int i, ndev;
! if ((ndev = alsa_nmidiindevs) > maxndev)
! ndev = maxndev;
! for (i = 0; i < ndev; i++)
! sprintf(indevlist + i * devdescsize, "ALSA MIDI device #%d", i+1);
*nindevs = ndev;
!
! if ((ndev = alsa_nmidioutdevs) > maxndev)
! ndev = maxndev;
! for (i = 0; i < ndev; i++)
! sprintf(outdevlist + i * devdescsize, "ALSA MIDI device #%d", i+1);
*noutdevs = ndev;
}
--- 257,265 ----
{
int i, ndev;
! if ((ndev = alsa_nmidiindevs) > maxndev) ndev = maxndev;
! for (i = 0; i < ndev; i++) sprintf(indevlist + i * devdescsize, "ALSA MIDI device #%d", i+1);
*nindevs = ndev;
! if ((ndev = alsa_nmidioutdevs) > maxndev) ndev = maxndev;
! for (i = 0; i < ndev; i++) sprintf(outdevlist + i * devdescsize, "ALSA MIDI device #%d", i+1);
*noutdevs = ndev;
}
More information about the Pd-cvs
mailing list