The patch is below.
WARNING: I did not test the patch itself. The sources from which it
was made have been lying around on my disk for years, so they've
almost certainly been altered by the little gremlins that live in my
machine and flip bits while I sleep at night.
It probably won't apply, and if it does, it will probably cause your
computer to explode.
You have been warned!
It's all an ugly hack by the way, not meant for distribution. Much of
it deals with the move from g++-2 to g++-3, the rest is the alsa_seq
stuff. It looks like I wrapped my changes in #ifdef USE_ALSA_SEQ but
i don't know if I define that in any of the Makefiles. I may have set
it on the command line (I'm lazy like that).
If I could think of any more disclaimers, I would include them.
Perhaps a real Linux audio developer will pick this up, add proper
jack support, etc.
diff -Naur juno-1.0.1/gmoog/Makefile juno-1.0.1-alsa/gmoog/Makefile
--- juno-1.0.1/gmoog/Makefile 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/gmoog/Makefile 2005-11-07 21:46:33.000000000 -0500
@@ -45,7 +45,7 @@
.depend: Makefile
touch .depend
- makedepend -f .depend $(INCLUDE_DIRS) -I/usr/include/g++-2 $(shell
gtk-config --cflags) *.C *.c
+ makedepend -f .depend $(INCLUDE_DIRS) -I/usr/include/g++-3 $(shell
gtk-config --cflags) *.C *.c
.PHONY: objs
diff -Naur juno-1.0.1/gmoog/Scope.C juno-1.0.1-alsa/gmoog/Scope.C
--- juno-1.0.1/gmoog/Scope.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/gmoog/Scope.C 2005-11-07 21:46:33.000000000 -0500
@@ -34,8 +34,8 @@
Scope::Scope()
{
- addInput( "sync", NULL );
- addInput( "sig", NULL );
+ addInput( "sync", (moog_callback_t)NULL );
+ addInput( "sig", (moog_callback_t)NULL );
showing = 0;
mainWindow = NULL;
diff -Naur juno-1.0.1/juno6/juno_synth.C juno-1.0.1-alsa/juno6/juno_synth.C
--- juno-1.0.1/juno6/juno_synth.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/juno6/juno_synth.C 2005-11-07 21:46:33.000000000 -0500
@@ -210,7 +210,8 @@
void turnOnArpeggio(bool on)
{
- MoogObject *target = (on) ? arpeggio : junoControl;
+ // MoogObject *target = (on) ? arpeggio : junoControl;
+ MoogObject *target = (MoogObject*)(on) ? (MoogObject*)arpeggio :
(MoogObject*)junoControl;
if (voice0)
voice0->attachVoice(target);
diff -Naur juno-1.0.1/juno6/juno_wrappers.C
juno-1.0.1-alsa/juno6/juno_wrappers.C
--- juno-1.0.1/juno6/juno_wrappers.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/juno6/juno_wrappers.C 2005-11-07 21:46:33.000000000 -0500
@@ -94,7 +94,7 @@
if (midiInput)
{
- addInput(tmp2, NULL);
+ addInput(tmp2, (moog_callback_t)NULL);
PATCH(midiInput, tmp1, this, tmp2);
}
pitchOutputs[i] = junoControl->getOutput(tmp2);
diff -Naur juno-1.0.1/juno6/Makefile juno-1.0.1-alsa/juno6/Makefile
--- juno-1.0.1/juno6/Makefile 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/juno6/Makefile 2005-11-07 21:46:33.000000000 -0500
@@ -3,7 +3,8 @@
GTK_CFLAGS=$(shell gtk-config --cflags)
INCLUDE_PATH=-I.. -Iumg/base/include $(GTK_CFLAGS)
CPPFLAGS=$(INCLUDE_PATH) $(GTK_CFLAGS) -Wall $(OPTIMIZE) $(DEBUG) $(PROFILE)
-LDFLAGS= -L../moog -L../gmoog -L../util -L/usr/local/lib -lgmoog
-lmoog -lmoogutil $(shell gtk-config --libs) -lgthread
+LDFLAGS= -L../moog -L../gmoog -L../util -L/usr/local/lib -lgmoog
-lmoog -lmoogutil $(shell gtk-config --libs) -lgthread -lasound
+
PROGS=juno6 list_patches copy_patch
@@ -37,6 +38,6 @@
.depend: Makefile
touch .depend
- makedepend -f .depend $(INCLUDE_PATH) -I/usr/include/g++-2 *.C *.c
+ makedepend -f .depend $(INCLUDE_PATH) -I/usr/include/g++-3 *.C *.c
include .depend
diff -Naur juno-1.0.1/libgmoog/Makefile juno-1.0.1-alsa/libgmoog/Makefile
--- juno-1.0.1/libgmoog/Makefile 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/libgmoog/Makefile 2005-11-07 21:46:33.000000000 -0500
@@ -45,7 +45,7 @@
.depend: Makefile
touch .depend
- makedepend -f .depend $(INCLUDE_DIRS) -I/usr/include/g++-2 $(shell
gtk-config --cflags) *.C *.c
+ makedepend -f .depend $(INCLUDE_DIRS) -I/usr/include/g++-3 $(shell
gtk-config --cflags) *.C *.c
.PHONY: objs
diff -Naur juno-1.0.1/libgmoog/Scope.C juno-1.0.1-alsa/libgmoog/Scope.C
--- juno-1.0.1/libgmoog/Scope.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/libgmoog/Scope.C 2005-11-07 21:46:33.000000000 -0500
@@ -34,8 +34,8 @@
Scope::Scope()
{
- addInput( "sync", NULL );
- addInput( "sig", NULL );
+ addInput( "sync", (moog_callback_t)NULL );
+ addInput( "sig", (moog_callback_t)NULL );
showing = 0;
mainWindow = NULL;
diff -Naur juno-1.0.1/libmoog/IIR2.C juno-1.0.1-alsa/libmoog/IIR2.C
--- juno-1.0.1/libmoog/IIR2.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/libmoog/IIR2.C 2005-11-07 21:46:33.000000000 -0500
@@ -25,7 +25,7 @@
cx[0] = cx[1] = cy[0] = cy[1] = 0;
x[0] = x[1] = y[0] = y[1] = 0;
- addInput("sig", NULL);
+ addInput("sig", (moog_callback_t)NULL);
addOutput("sig", true);
output = getOutput(0);
diff -Naur juno-1.0.1/libmoog/Makefile juno-1.0.1-alsa/libmoog/Makefile
--- juno-1.0.1/libmoog/Makefile 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/libmoog/Makefile 2005-11-07 21:46:33.000000000 -0500
@@ -76,7 +76,7 @@
.depend: Makefile
touch .depend
- makedepend -f .depend $(INCLUDE_DIRS) -I/usr/include/g++-2 *.C *.c
+ makedepend -f .depend $(INCLUDE_DIRS) -I/usr/include/g++-3 *.C *.c
.PHONY: objs depend
diff -Naur juno-1.0.1/libmoog/MidiInput.C juno-1.0.1-alsa/libmoog/MidiInput.C
--- juno-1.0.1/libmoog/MidiInput.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/libmoog/MidiInput.C 2005-11-07 21:46:33.000000000 -0500
@@ -26,6 +26,32 @@
#include "Scheduler.h"
#include "pitch.h"
+#define USE_ALSA_SEQ
+#ifdef USE_ALSA_SEQ
+#include <alsa/asoundlib.h>
+snd_seq_t *hseq;
+
+snd_seq_t *open_seq() {
+
+ snd_seq_t *seq_handle;
+ int portid;
+
+ if (snd_seq_open(&seq_handle, "hw", SND_SEQ_OPEN_DUPLEX, 0) < 0) {
+ fprintf(stderr, "Error opening ALSA sequencer.\n");
+ exit(1);
+ }
+ snd_seq_set_client_name(seq_handle, "j6");
+ if ((portid = snd_seq_create_simple_port(seq_handle, "j6",
+ SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
+ SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
+ fprintf(stderr, "Error creating sequencer port.\n");
+ exit(1);
+ }
+ return(seq_handle);
+}
+
+#else
+
#define READ1 if ( !inCommand )\
{\
read( midiFd, &data[ 0 ], 1 );\
@@ -41,6 +67,8 @@
read( midiFd, &data[ 1 ], 1 );\
}\
+#endif
+
void* midi_input_run( void* data )
{
return(((MidiInput *)data)->run());
@@ -56,8 +84,14 @@
pthread_mutex_init(&startStopLock, NULL);
lastNote = -1;
+#ifndef USE_ALSA_SEQ
if ( openDevice( device, MIDI_READ ) < 0 )
return;
+#else
+ if (!(hseq = open_seq()))
+ return;
+ midiFd = 99;
+#endif
addOutput( "bend", false );
@@ -112,6 +146,7 @@
{
running = 1;
pthread_create( &midiThread, NULL, midi_input_run, this );
+ debug(DEBUG_APPMSG1, "Midi thread started");
}
pthread_mutex_unlock(&startStopLock);
}
@@ -129,6 +164,7 @@
pthread_mutex_unlock(&startStopLock);
}
+#ifndef USE_ALSA_SEQ
void*
MidiInput::run()
{
@@ -161,9 +197,9 @@
channel = tmp & 0x0F;
inCommand = 0;
}
-
+
switch( cmd )
- {
+ {
case MIDI_NOTEOFF: //0x80
READ2;
doNoteOff( channel, data[0], data[1] );
@@ -234,6 +270,79 @@
/* not reached */
return( NULL );
}
+#else
+void*
+MidiInput::run()
+{
+ char ctlName[ 10 ]; //format is "ctl00-000"
+
+ snd_seq_event_t *ev;
+
+ while( running )
+ {
+ snd_seq_event_input(hseq, &ev);
+
+ switch( ev->type )
+ {
+ case SND_SEQ_EVENT_NOTEOFF: //0x80
+ doNoteOff( ev->data.control.channel, ev->data.note.note, 0 );
+ break;
+
+ case SND_SEQ_EVENT_NOTEON: //0x90
+// debug( DEBUG_APPMSG1, "NOTEON ch=%d note=%d vel=%d\n",
ev->data.control.channel, ev->data.note.note, ev->data.note.velocity);
+ if ( ev->data.note.velocity == 0 )
+ {
+ doNoteOff( ev->data.control.channel, ev->data.note.note, 0 );
+ }
+ else
+ {
+ doNoteOn( ev->data.control.channel, ev->data.note.note,
+ ev->data.note.velocity );
+ }
+ break;
+
+ case SND_SEQ_EVENT_KEYPRESS: //0xA0
+// debug( DEBUG_STATUS, "KEY PRESSURE ch=%d note=%d amount=%d\n",
+// channel, cmd, data[ 0 ] );
+ break;
+
+ case SND_SEQ_EVENT_CONTROLLER: //0xB0
+// debug( DEBUG_APPMSG1, "CTL ch=%d ctl=%d val=%d\n",
ev->data.control.channel, ev->data.control.param,
ev->data.control.value);
+ sprintf( ctlName, "ctl%d-%d", ev->data.control.channel,
+ ev->data.control.param );
+ {
+ Output* out;
+ out = MoogObject::getOutput( ctlName );
+ if ( out != NULL )
+ out->setData( ev->data.control.value / 127.0);
+ }
+
+ break;
+
+ case SND_SEQ_EVENT_PGMCHANGE: //0xC0
+// debug( DEBUG_STATUS, "PGM_CHANGE %d %d\n", channel, data[ 0 ] );
+ break;
+
+ case SND_SEQ_EVENT_CHANPRESS: //0xD0
+// debug( DEBUG_STATUS, "CHN_PRESSURE %d %d\n", channel, data[ 0 ] );
+ break;
+
+ case SND_SEQ_EVENT_PITCHBEND: //0xE0
+ doPitchBend( ev->data.control.value ); //FIXME: channel?
+ break;
+
+ default:
+ //debug( DEBUG_STATUS, "[%d]\n", cmd );
+ break;
+ }
+ }
+
+ pthread_exit(0);
+
+ /* not reached */
+ return( NULL );
+}
+#endif
void
MidiInput::doNoteOn( unsigned int c, unsigned int n, unsigned int v )
diff -Naur juno-1.0.1/libmoog/MoogObject.C juno-1.0.1-alsa/libmoog/MoogObject.C
--- juno-1.0.1/libmoog/MoogObject.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/libmoog/MoogObject.C 2005-11-07 21:46:33.000000000 -0500
@@ -53,7 +53,8 @@
if (io == OUTPUT)
{
- bool continuousOutput = va_arg(va, bool);
+ //PC bool continuousOutput = va_arg(va, bool);
+ bool continuousOutput = va_arg(va, int);
addOutput(name, continuousOutput);
}
else
diff -Naur juno-1.0.1/libmoog/Oscillator.C juno-1.0.1-alsa/libmoog/Oscillator.C
--- juno-1.0.1/libmoog/Oscillator.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/libmoog/Oscillator.C 2005-11-07 21:46:33.000000000 -0500
@@ -46,7 +46,7 @@
init( w );
}
-Oscillator::Oscillator( DataBlock* w, double frq, double amp = 1,
double zro = 0 )
+Oscillator::Oscillator( DataBlock* w, double frq, double amp, double zro)
{
init( w );
set( I_OSC_FRQ, frq );
diff -Naur juno-1.0.1/libmoogutil/String.C juno-1.0.1-alsa/libmoogutil/String.C
--- juno-1.0.1/libmoogutil/String.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/libmoogutil/String.C 2005-11-07 21:46:33.000000000 -0500
@@ -346,7 +346,8 @@
case 'c':
maxlen += 1;
- (void)va_arg(ap, char);
+ //PC (void)va_arg(ap, char);
+ (void)va_arg(ap, int);
break;
case 's':
diff -Naur juno-1.0.1/Makefile.include juno-1.0.1-alsa/Makefile.include
--- juno-1.0.1/Makefile.include 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/Makefile.include 2005-11-07 21:46:33.000000000 -0500
@@ -8,17 +8,18 @@
PROFILE=-pg
endif
-ifeq ($(USE_DEBUG), n)
-DEBUG=
-else
+#ifeq ($(USE_DEBUG), n)
+#DEBUG=
+#else
DEBUG=-g
-endif
+#endif
-ifeq ($(USE_OPTIMIZE), max)
-OPTIMIZE=-O6 -fomit-frame-pointer -m486 -ffast-math
-else
-OPTIMIZE=-O2
-endif
+#ifeq ($(USE_OPTIMIZE), max)
+#OPTIMIZE=-O6 -fomit-frame-pointer -m486 -ffast-math
+#else
+#OPTIMIZE=-O2
+#endif
+OPTIMIZE=-O0
CC=gcc
diff -Naur juno-1.0.1/moog/IIR2.C juno-1.0.1-alsa/moog/IIR2.C
--- juno-1.0.1/moog/IIR2.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/moog/IIR2.C 2005-11-07 21:46:33.000000000 -0500
@@ -25,7 +25,7 @@
cx[0] = cx[1] = cy[0] = cy[1] = 0;
x[0] = x[1] = y[0] = y[1] = 0;
- addInput("sig", NULL);
+ addInput("sig", (moog_callback_t)NULL);
addOutput("sig", true);
output = getOutput(0);
diff -Naur juno-1.0.1/moog/Makefile juno-1.0.1-alsa/moog/Makefile
--- juno-1.0.1/moog/Makefile 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/moog/Makefile 2005-11-07 21:46:33.000000000 -0500
@@ -76,7 +76,7 @@
.depend: Makefile
touch .depend
- makedepend -f .depend $(INCLUDE_DIRS) -I/usr/include/g++-2 *.C *.c
+ makedepend -f .depend $(INCLUDE_DIRS) -I/usr/include/g++-3 *.C *.c
.PHONY: objs depend
diff -Naur juno-1.0.1/moog/MidiInput.C juno-1.0.1-alsa/moog/MidiInput.C
--- juno-1.0.1/moog/MidiInput.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/moog/MidiInput.C 2005-11-07 21:46:33.000000000 -0500
@@ -26,6 +26,32 @@
#include "Scheduler.h"
#include "pitch.h"
+#define USE_ALSA_SEQ
+#ifdef USE_ALSA_SEQ
+#include <alsa/asoundlib.h>
+snd_seq_t *hseq;
+
+snd_seq_t *open_seq() {
+
+ snd_seq_t *seq_handle;
+ int portid;
+
+ if (snd_seq_open(&seq_handle, "hw", SND_SEQ_OPEN_DUPLEX, 0) < 0) {
+ fprintf(stderr, "Error opening ALSA sequencer.\n");
+ exit(1);
+ }
+ snd_seq_set_client_name(seq_handle, "j6");
+ if ((portid = snd_seq_create_simple_port(seq_handle, "j6",
+ SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
+ SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
+ fprintf(stderr, "Error creating sequencer port.\n");
+ exit(1);
+ }
+ return(seq_handle);
+}
+
+#else
+
#define READ1 if ( !inCommand )\
{\
read( midiFd, &data[ 0 ], 1 );\
@@ -41,6 +67,8 @@
read( midiFd, &data[ 1 ], 1 );\
}\
+#endif
+
void* midi_input_run( void* data )
{
return(((MidiInput *)data)->run());
@@ -56,8 +84,14 @@
pthread_mutex_init(&startStopLock, NULL);
lastNote = -1;
+#ifndef USE_ALSA_SEQ
if ( openDevice( device, MIDI_READ ) < 0 )
return;
+#else
+ if (!(hseq = open_seq()))
+ return;
+ midiFd = 99;
+#endif
addOutput( "bend", false );
@@ -112,6 +146,7 @@
{
running = 1;
pthread_create( &midiThread, NULL, midi_input_run, this );
+ debug(DEBUG_APPMSG1, "Midi thread started");
}
pthread_mutex_unlock(&startStopLock);
}
@@ -129,6 +164,7 @@
pthread_mutex_unlock(&startStopLock);
}
+#ifndef USE_ALSA_SEQ
void*
MidiInput::run()
{
@@ -161,9 +197,9 @@
channel = tmp & 0x0F;
inCommand = 0;
}
-
+
switch( cmd )
- {
+ {
case MIDI_NOTEOFF: //0x80
READ2;
doNoteOff( channel, data[0], data[1] );
@@ -234,6 +270,79 @@
/* not reached */
return( NULL );
}
+#else
+void*
+MidiInput::run()
+{
+ char ctlName[ 10 ]; //format is "ctl00-000"
+
+ snd_seq_event_t *ev;
+
+ while( running )
+ {
+ snd_seq_event_input(hseq, &ev);
+
+ switch( ev->type )
+ {
+ case SND_SEQ_EVENT_NOTEOFF: //0x80
+ doNoteOff( ev->data.control.channel, ev->data.note.note, 0 );
+ break;
+
+ case SND_SEQ_EVENT_NOTEON: //0x90
+// debug( DEBUG_APPMSG1, "NOTEON ch=%d note=%d vel=%d\n",
ev->data.control.channel, ev->data.note.note, ev->data.note.velocity);
+ if ( ev->data.note.velocity == 0 )
+ {
+ doNoteOff( ev->data.control.channel, ev->data.note.note, 0 );
+ }
+ else
+ {
+ doNoteOn( ev->data.control.channel, ev->data.note.note,
+ ev->data.note.velocity );
+ }
+ break;
+
+ case SND_SEQ_EVENT_KEYPRESS: //0xA0
+// debug( DEBUG_STATUS, "KEY PRESSURE ch=%d note=%d amount=%d\n",
+// channel, cmd, data[ 0 ] );
+ break;
+
+ case SND_SEQ_EVENT_CONTROLLER: //0xB0
+// debug( DEBUG_APPMSG1, "CTL ch=%d ctl=%d val=%d\n",
ev->data.control.channel, ev->data.control.param,
ev->data.control.value);
+ sprintf( ctlName, "ctl%d-%d", ev->data.control.channel,
+ ev->data.control.param );
+ {
+ Output* out;
+ out = MoogObject::getOutput( ctlName );
+ if ( out != NULL )
+ out->setData( ev->data.control.value / 127.0);
+ }
+
+ break;
+
+ case SND_SEQ_EVENT_PGMCHANGE: //0xC0
+// debug( DEBUG_STATUS, "PGM_CHANGE %d %d\n", channel, data[ 0 ] );
+ break;
+
+ case SND_SEQ_EVENT_CHANPRESS: //0xD0
+// debug( DEBUG_STATUS, "CHN_PRESSURE %d %d\n", channel, data[ 0 ] );
+ break;
+
+ case SND_SEQ_EVENT_PITCHBEND: //0xE0
+ doPitchBend( ev->data.control.value ); //FIXME: channel?
+ break;
+
+ default:
+ //debug( DEBUG_STATUS, "[%d]\n", cmd );
+ break;
+ }
+ }
+
+ pthread_exit(0);
+
+ /* not reached */
+ return( NULL );
+}
+#endif
void
MidiInput::doNoteOn( unsigned int c, unsigned int n, unsigned int v )
diff -Naur juno-1.0.1/moog/MoogObject.C juno-1.0.1-alsa/moog/MoogObject.C
--- juno-1.0.1/moog/MoogObject.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/moog/MoogObject.C 2005-11-07 21:46:33.000000000 -0500
@@ -53,7 +53,8 @@
if (io == OUTPUT)
{
- bool continuousOutput = va_arg(va, bool);
+ //PC bool continuousOutput = va_arg(va, bool);
+ bool continuousOutput = va_arg(va, int);
addOutput(name, continuousOutput);
}
else
diff -Naur juno-1.0.1/moog/Oscillator.C juno-1.0.1-alsa/moog/Oscillator.C
--- juno-1.0.1/moog/Oscillator.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/moog/Oscillator.C 2005-11-07 21:46:33.000000000 -0500
@@ -46,7 +46,7 @@
init( w );
}
-Oscillator::Oscillator( DataBlock* w, double frq, double amp = 1,
double zro = 0 )
+Oscillator::Oscillator( DataBlock* w, double frq, double amp, double zro)
{
init( w );
set( I_OSC_FRQ, frq );
diff -Naur juno-1.0.1/util/String.C juno-1.0.1-alsa/util/String.C
--- juno-1.0.1/util/String.C 2005-11-07 21:46:51.000000000 -0500
+++ juno-1.0.1-alsa/util/String.C 2005-11-07 21:46:33.000000000 -0500
@@ -346,7 +346,8 @@
case 'c':
maxlen += 1;
- (void)va_arg(ap, char);
+ //PC (void)va_arg(ap, char);
+ (void)va_arg(ap, int);
break;
case 's':
Received on Tue Nov 8 08:15:05 2005
This archive was generated by hypermail 2.1.8 : Tue Nov 08 2005 - 08:15:05 EET