aboutsummaryrefslogtreecommitdiff
path: root/pd
diff options
context:
space:
mode:
authorMiller Puckette <millerpuckette@users.sourceforge.net>2007-08-02 00:33:50 +0000
committerMiller Puckette <millerpuckette@users.sourceforge.net>2007-08-02 00:33:50 +0000
commitd94dbe2eca3ace84a23bfff30c729662a4486a5a (patch)
tree5868261a1706a36112b5927f2d013613fe4f5971 /pd
parent4e5ef76c3a0a96b04eaf605af434094896984319 (diff)
fix name clash in s_audio_jack.c (again) and applied some sourceforge patches
svn path=/trunk/; revision=8342
Diffstat (limited to 'pd')
-rw-r--r--pd/extra/pique/pique.c.old148
-rw-r--r--pd/portaudio/pa_win_wdmks/pa_win_wdmks.c2
-rw-r--r--pd/portaudio/pablio/ringbuffer.c2
-rw-r--r--pd/portaudio/pablio/ringbuffer.h2
-rw-r--r--pd/portmidi/pm_mac/pmmacosxcm.c10
-rw-r--r--pd/src/configure.in10
-rw-r--r--pd/src/g_rtext.c2
-rw-r--r--pd/src/makefile.in16
-rw-r--r--pd/src/s_audio_jack.c4
-rw-r--r--pd/src/s_file.c46
-rw-r--r--pd/src/s_midi.c14
-rw-r--r--pd/src/s_midi_alsa.c86
-rw-r--r--pd/src/s_midi_pm.c41
-rw-r--r--pd/src/u_main.tk6
-rw-r--r--pd/src/x_midi.c12
-rw-r--r--pd/src/x_misc.c7
16 files changed, 215 insertions, 193 deletions
diff --git a/pd/extra/pique/pique.c.old b/pd/extra/pique/pique.c.old
deleted file mode 100644
index 75afc38c..00000000
--- a/pd/extra/pique/pique.c.old
+++ /dev/null
@@ -1,148 +0,0 @@
-/* Copyright (c) 1998 The Regents of the University of California. The
-contents of this file are free for any use, but BOTH THE AUTHOR AND UCSD
-DISCLAIM ALL WARRANTIES related to it. Although not written in Java, this
-still should not be used to control any machinery containing a sharp blade or
-combustible materiel, or as part of any life support system or weapon. */
-
-#include "m_pd.h"
-#include <math.h>
-
-static t_class *pique_class;
-
-typedef struct _pique
-{
- t_object x_obj;
-} t_pique;
-
-static void *pique_new(void)
-{
- t_pique *x = (t_pique *)pd_new(pique_class);
- return (x);
-}
-
- /* we aren't measuring phase yet */
-static void pique_doit(int npts, t_float *fpreal, t_float *fpimag,
- int npeak, t_float *fpfreq, t_float *fpamp)
-{
- float srate = sys_getsr(); /* not sure how to get this correctly */
- float oneovern = 1.0/ (float)npts;
- float fperbin = srate * oneovern;
- float pow1, pow2 = 0, pow3 = 0, pow4 = 0, pow5 = 0;
- float re1, re2 = 0, re3 = *fpreal;
- float im1, im2 = 0, im3 = 0, powthresh;
- int count, peakcount = 0, n2 = (npts >> 1);
- float *fp1, *fp2;
- for (count = n2, fp1 = fpreal, fp2 = fpimag, powthresh = 0;
- count--; fp1++, fp2++)
- powthresh += (*fp1) * (*fp1) + (*fp2) * (*fp2) ;
- powthresh *= 0.00001;
- for (count = 1; count < n2; count++)
- {
- float windreal, windimag, pi = 3.14159;
- float detune, pidetune, ampcorrect, freqout, ampout;
- float rpeak, rpeaknext, rpeakprev;
- float ipeak, ipeaknext, ipeakprev;
- fpreal++;
- fpimag++;
- re1 = re2;
- re2 = re3;
- re3 = *fpreal;
- im1 = im2;
- im2 = im3;
- im3 = *fpimag;
- if (count < 2) continue;
- pow1 = pow2;
- pow2 = pow3;
- pow3 = pow4;
- pow4 = pow5;
- /* get Hanning-windowed spectrum by convolution */
- windreal = re2 - 0.5 * (re1 + re3);
- windimag = im2 - 0.5 * (im1 + im3);
- pow5 = windreal * windreal + windimag * windimag;
- /* if (count < 30) post("power %f", pow5); */
- if (count < 5) continue;
- /* check for a peak. The actual bin is count-3. */
- if (pow3 <= pow2 || pow3 <= pow4 || pow3 <= pow1 || pow3 <= pow5
- || pow3 < powthresh)
- continue;
- /* go back for the raw FFT values around the peak. */
- rpeak = fpreal[-3];
- rpeaknext = fpreal[-2];
- rpeakprev = fpreal[-4];
- ipeak = fpimag[-3];
- ipeaknext = fpimag[-2];
- ipeakprev = fpimag[-4];
-
- detune = ((rpeakprev - rpeaknext) *
- (2.0 * rpeak - rpeakprev - rpeaknext) +
- (ipeakprev - ipeaknext) *
- (2.0 * ipeak - ipeakprev - ipeaknext)) /
- (4.0 * pow3);
- /* if (count < 30) post("detune %f", detune); */
- if (detune > 0.7 || detune < -0.7) continue;
- /* the frequency is the sum of the bin frequency and detuning */
- freqout = fperbin * ((float)(count-3) + detune);
- *fpfreq++ = freqout;
- pidetune = pi * detune;
- if (pidetune < 0.01 && pidetune > -0.01) ampcorrect = 1;
- else ampcorrect = 1.0 / (sin(pidetune)/pidetune + 0.5 *
- (sin(pidetune + pi)/(pidetune+pi) +
- sin(pidetune-pi)/(pidetune-pi)));
- /* amplitude is peak height, corrected for Hanning window shape.
- Multiply by 2 to get real-sinusoid peak amplitude */
- ampout = 2. * oneovern * sqrt(pow3) * ampcorrect;
- *fpamp++ = ampout;
- /* post("peak %f %f", freqout, ampout); */
- if (++peakcount == npeak) break;
- }
- while (peakcount < npeak)
- {
- *fpfreq++ = 0;
- *fpamp++ = 0;
- peakcount++;
- }
-}
-
-static void pique_list(t_pique *x, t_symbol *s, int argc, t_atom *argv)
-{
- int npts = atom_getintarg(0, argc, argv);
- t_symbol *symreal = atom_getsymbolarg(1, argc, argv);
- t_symbol *symimag = atom_getsymbolarg(2, argc, argv);
- int npeak = atom_getintarg(3, argc, argv);
- t_symbol *symfreq = atom_getsymbolarg(4, argc, argv);
- t_symbol *symamp = atom_getsymbolarg(5, argc, argv);
- t_garray *a, *afreq, *aamp;
- int n;
- t_float *fpreal, *fpimag, *fpfreq, *fpamp, *fpphase;
- if (npts < 8 || npeak < 1) error("pique: bad npoints or npeak");
- else if (!(a = (t_garray *)pd_findbyclass(symreal, garray_class)) ||
- !garray_getfloatarray(a, &n, &fpreal) ||
- n < npts)
- error("%s: missing or bad array", symreal->s_name);
- else if (!(a = (t_garray *)pd_findbyclass(symimag, garray_class)) ||
- !garray_getfloatarray(a, &n, &fpimag) ||
- n < npts)
- error("%s: missing or bad array", symimag->s_name);
- else if (!(afreq = (t_garray *)pd_findbyclass(symfreq, garray_class)) ||
- !garray_getfloatarray(afreq, &n, &fpfreq) ||
- n < npeak)
- error("%s: missing or bad array", symfreq->s_name);
- else if (!(aamp = (t_garray *)pd_findbyclass(symamp, garray_class)) ||
- !garray_getfloatarray(aamp, &n, &fpamp) ||
- n < npeak)
- error("%s: missing or bad array", symamp->s_name);
- else
- {
- pique_doit(npts, fpreal, fpimag, npeak, fpfreq, fpamp);
- garray_redraw(afreq);
- garray_redraw(aamp);
- }
-}
-
-void pique_setup(void)
-{
- pique_class = class_new(gensym("pique"), pique_new, 0,
- sizeof(t_pique), 0, 0);
- class_addlist(pique_class, pique_list);
-}
-
diff --git a/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c b/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c
index c542f50c..45e6e662 100644
--- a/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c
+++ b/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c
@@ -1,5 +1,5 @@
/*
- * $Id: pa_win_wdmks.c,v 1.21 2007-07-24 04:53:36 millerpuckette Exp $
+ * $Id: pa_win_wdmks.c,v 1.22 2007-08-02 00:33:49 millerpuckette Exp $
* PortAudio Windows WDM-KS interface
*
* Author: Andrew Baldwin
diff --git a/pd/portaudio/pablio/ringbuffer.c b/pd/portaudio/pablio/ringbuffer.c
index 9b944970..34360aa9 100644
--- a/pd/portaudio/pablio/ringbuffer.c
+++ b/pd/portaudio/pablio/ringbuffer.c
@@ -1,5 +1,5 @@
/*
- * $Id: ringbuffer.c,v 1.20 2007-07-24 04:53:36 millerpuckette Exp $
+ * $Id: ringbuffer.c,v 1.21 2007-08-02 00:33:49 millerpuckette Exp $
* ringbuffer.c
* Ring Buffer utility..
*
diff --git a/pd/portaudio/pablio/ringbuffer.h b/pd/portaudio/pablio/ringbuffer.h
index 3aee18e2..d84ab305 100644
--- a/pd/portaudio/pablio/ringbuffer.h
+++ b/pd/portaudio/pablio/ringbuffer.h
@@ -6,7 +6,7 @@ extern "C"
#endif /* __cplusplus */
/*
- * $Id: ringbuffer.h,v 1.21 2007-07-24 04:53:36 millerpuckette Exp $
+ * $Id: ringbuffer.h,v 1.22 2007-08-02 00:33:49 millerpuckette Exp $
* ringbuffer.h
* Ring Buffer utility..
*
diff --git a/pd/portmidi/pm_mac/pmmacosxcm.c b/pd/portmidi/pm_mac/pmmacosxcm.c
index 1ce7ab1f..58e1b90b 100644
--- a/pd/portmidi/pm_mac/pmmacosxcm.c
+++ b/pd/portmidi/pm_mac/pmmacosxcm.c
@@ -5,7 +5,7 @@
* and subsequent work by Andrew Zeldis and Zico Kolter
* and Roger B. Dannenberg
*
- * $Id: pmmacosxcm.c,v 1.21 2007-07-24 04:53:36 millerpuckette Exp $
+ * $Id: pmmacosxcm.c,v 1.22 2007-08-02 00:33:49 millerpuckette Exp $
*/
/* Notes:
@@ -456,6 +456,14 @@ midi_end_sysex(PmInternal *midi, PmTimestamp when)
if (m->sysex_timestamp < m->last_time) m->sysex_timestamp = m->last_time;
/* now send what's in the buffer */
+ if (m->packet == NULL) {
+ /* if flush has been called in the meantime, packet list is NULL */
+ m->packet = MIDIPacketListInit(m->packetList);
+ /* this can never fail, right? failure would indicate something
+ unrecoverable */
+ assert(m->packet);
+ }
+
err = send_packet(midi, m->sysex_buffer, m->sysex_byte_count,
m->sysex_timestamp);
m->sysex_byte_count = 0;
diff --git a/pd/src/configure.in b/pd/src/configure.in
index fb757526..6ea60a50 100644
--- a/pd/src/configure.in
+++ b/pd/src/configure.in
@@ -419,5 +419,15 @@ AC_TRY_LINK( [
fi
## }JMZ: end of large-file support section
+if test -d ../obj
+then echo -n
+else mkdir ../obj
+fi
+
+if test -d ../bin
+then echo -n
+else mkdir ../bin
+fi
+
AC_OUTPUT(makefile)
diff --git a/pd/src/g_rtext.c b/pd/src/g_rtext.c
index 28becbdb..cbb0ba88 100644
--- a/pd/src/g_rtext.c
+++ b/pd/src/g_rtext.c
@@ -442,7 +442,7 @@ void rtext_key(t_rtext *x, int keynum, t_symbol *keysym)
/* at Guenter's suggestion, use 'n>31' to test wither a character might
be printable in whatever 8-bit character set we find ourselves. */
- if (n == '\n' || n > 31)
+ if (n == '\n' || (n > 31 && n != 127))
{
newsize = x->x_bufsize+1;
x->x_buf = resizebytes(x->x_buf, x->x_bufsize, newsize);
diff --git a/pd/src/makefile.in b/pd/src/makefile.in
index 33ac2b99..d77d4ac4 100644
--- a/pd/src/makefile.in
+++ b/pd/src/makefile.in
@@ -146,14 +146,14 @@ $(BIN_DIR)/pdtcl.dll: $(GOBJ)
strip --strip-unneeded $(BIN_DIR)/pdtcl.dll
externs:
- cd ../extra/bonk~;make @EXTERNTARGET@
- cd ../extra/choice;make @EXTERNTARGET@
- cd ../extra/expr~;make @EXTERNTARGET@
- cd ../extra/fiddle~;make @EXTERNTARGET@
- cd ../extra/loop~;make @EXTERNTARGET@
- cd ../extra/lrshift~;make @EXTERNTARGET@
- cd ../extra/pique;make @EXTERNTARGET@
- cd ../extra/sigmund~;make @EXTERNTARGET@
+ make -C ../extra/bonk~ @EXTERNTARGET@
+ make -C ../extra/choice @EXTERNTARGET@
+ make -C ../extra/expr~ @EXTERNTARGET@
+ make -C ../extra/fiddle~ @EXTERNTARGET@
+ make -C ../extra/loop~ @EXTERNTARGET@
+ make -C ../extra/lrshift~ @EXTERNTARGET@
+ make -C ../extra/pique @EXTERNTARGET@
+ make -C ../extra/sigmund~ @EXTERNTARGET@
BINARYMODE=@binarymode@
diff --git a/pd/src/s_audio_jack.c b/pd/src/s_audio_jack.c
index a6df3968..92f652e9 100644
--- a/pd/src/s_audio_jack.c
+++ b/pd/src/s_audio_jack.c
@@ -194,7 +194,7 @@ static int jack_connect_ports(char* client)
}
-void jack_error_callback(const char *desc) {
+void pd_jack_error_callback(const char *desc) {
return;
}
@@ -244,7 +244,7 @@ jack_open_audio(int inchans, int outchans, int rate)
jack_set_process_callback (jack_client, process, 0);
- jack_set_error_function (jack_error_callback);
+ jack_set_error_function (pd_jack_error_callback);
#ifdef JACK_XRUN
jack_set_xrun_callback (jack_client, jack_xrun, NULL);
diff --git a/pd/src/s_file.c b/pd/src/s_file.c
index e954eb5d..53d71bfa 100644
--- a/pd/src/s_file.c
+++ b/pd/src/s_file.c
@@ -42,10 +42,20 @@ static void sys_initloadpreferences( void)
{
char filenamebuf[MAXPDSTRING], *homedir = getenv("HOME");
int fd, length;
-
- if (!homedir)
- return;
- snprintf(filenamebuf, MAXPDSTRING, "%s/.pdsettings", homedir);
+ char user_prefs_file[MAXPDSTRING]; /* user prefs file */
+ /* default prefs embedded in the package */
+ char default_prefs_file[MAXPDSTRING];
+ struct stat statbuf;
+
+ snprintf(default_prefs_file, MAXPDSTRING, "%s/default.pdsettings",
+ sys_libdir->s_name);
+ if (homedir)
+ snprintf(user_prefs_file, MAXPDSTRING, "%s/.pdsettings", homedir);
+ if (stat(user_prefs_file, &statbuf) == 0)
+ strncpy(filenamebuf, user_prefs_file, MAXPDSTRING);
+ else if (stat(default_prefs_file, &statbuf) == 0)
+ strncpy(filenamebuf, default_prefs_file, MAXPDSTRING);
+ else return;
filenamebuf[MAXPDSTRING-1] = 0;
if ((fd = open(filenamebuf, 0)) < 0)
{
@@ -215,7 +225,21 @@ static int sys_getpreference(const char *key, char *value, int size)
{
char cmdbuf[256];
int nread = 0, nleft = size;
- snprintf(cmdbuf, 256, "defaults read org.puredata.pd %s 2> /dev/null\n", key);
+ char embedded_prefs[MAXPDSTRING];
+ char user_prefs[MAXPDSTRING];
+ char *homedir = getenv("HOME");
+ struct stat statbuf;
+ /* the 'defaults' command expects the filename without .plist at the
+ end */
+ snprintf(embedded_prefs, MAXPDSTRING, "%s/../org.puredata.pd",
+ sys_libdir->s_name);
+ snprintf(user_prefs, MAXPDSTRING,
+ "%s/Library/Preferences/org.puredata.pd.plist", homedir);
+ if (stat(user_prefs, &statbuf) == 0)
+ snprintf(cmdbuf, 256, "defaults read org.puredata.pd %s 2> /dev/null\n",
+ key);
+ else snprintf(cmdbuf, 256, "defaults read %s %s 2> /dev/null\n",
+ embedded_prefs, key);
FILE *fp = popen(cmdbuf, "r");
while (nread < size)
{
@@ -272,8 +296,9 @@ void sys_loadpreferences( void)
if (sys_getpreference("audioapi", prefbuf, MAXPDSTRING)
&& sscanf(prefbuf, "%d", &api) > 0)
sys_set_audio_api(api);
+ /* JMZ/MB: brackets for initializing */
if (sys_getpreference("noaudioin", prefbuf, MAXPDSTRING) &&
- (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))) /* JMZ/MB: brackets for initializing */
+ (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True")))
naudioindev = 0;
else
{
@@ -290,8 +315,9 @@ void sys_loadpreferences( void)
if (naudioindev == 0)
naudioindev = -1;
}
+ /* JMZ/MB: brackets for initializing */
if (sys_getpreference("noaudioout", prefbuf, MAXPDSTRING) &&
- (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))) /* JMZ/MB: brackets for initializing */
+ (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True")))
naudiooutdev = 0;
else
{
@@ -315,8 +341,9 @@ void sys_loadpreferences( void)
naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, advance, 0);
/* load MIDI preferences */
+ /* JMZ/MB: brackets for initializing */
if (sys_getpreference("nomidiin", prefbuf, MAXPDSTRING) &&
- (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))) /* JMZ/MB: brackets for initializing */
+ (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True")))
nmidiindev = 0;
else for (i = 0, nmidiindev = 0; i < MAXMIDIINDEV; i++)
{
@@ -327,8 +354,9 @@ void sys_loadpreferences( void)
break;
nmidiindev++;
}
+ /* JMZ/MB: brackets for initializing */
if (sys_getpreference("nomidiout", prefbuf, MAXPDSTRING) &&
- (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))) /* JMZ/MB: brackets for initializing */
+ (!strcmp(prefbuf, ".") || !strcmp(prefbuf, "True")))
nmidioutdev = 0;
else for (i = 0, nmidioutdev = 0; i < MAXMIDIOUTDEV; i++)
{
diff --git a/pd/src/s_midi.c b/pd/src/s_midi.c
index 508b3ff2..52dab7b0 100644
--- a/pd/src/s_midi.c
+++ b/pd/src/s_midi.c
@@ -236,6 +236,20 @@ void outmidi_mclk(int portno)
sys_queuemidimess(portno, 1, 0xf8, 0,0);
}
+void outmidi_byte(int portno, int value)
+{
+#ifdef USEAPI_ALSA
+ if (sys_midiapi == API_ALSA)
+ {
+ sys_alsa_putmidibyte(portno, value);
+ }
+ else
+#endif
+ {
+ sys_putmidibyte(portno, value);
+ }
+}
+
/* ------------------------- MIDI input queue handling ------------------ */
typedef struct midiparser
{
diff --git a/pd/src/s_midi_alsa.c b/pd/src/s_midi_alsa.c
index 1d19c111..dcc50006 100644
--- a/pd/src/s_midi_alsa.c
+++ b/pd/src/s_midi_alsa.c
@@ -47,8 +47,16 @@ void sys_alsa_do_open_midi(int nmidiin, int *midiinvec,
int client;
int i;
snd_seq_client_info_t *alsainfo;
+ /* do we want to connect pd automatically with other devices ?; see below! */
+ /* LATER: think about a flag to enable/disable automatic connection
+ * (sometimes it could be a pain)
+ */
+ int autoconnect = 1;
alsa_nmidiin = 0;
alsa_nmidiout = 0;
+
+ if (nmidiout == 0 && nmidiin == 0) return;
+
if(nmidiin>MAXMIDIINDEV )
{
post("midi input ports reduced to maximum %d", MAXMIDIINDEV);
@@ -73,25 +81,28 @@ void sys_alsa_do_open_midi(int nmidiin, int *midiinvec,
post("couldn't open alsa sequencer");
return;
}
- for (i=0;i<nmidiout;i++)
+ 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);
+ 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<nmidiin;i++)
+ 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_SUBS_READ | SND_SEQ_PORT_CAP_READ, SND_SEQ_PORT_TYPE_APPLICATION);
+ 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;
}
- if (nmidiout == 0 && nmidiin == 0) return;
snd_seq_client_info_malloc(&alsainfo);
snd_seq_get_client_info(midi_handle,alsainfo);
snd_seq_client_info_set_name(alsainfo,"Pure Data");
@@ -103,8 +114,67 @@ void sys_alsa_do_open_midi(int nmidiin, int *midiinvec,
snd_midi_event_new(20,&midiev);
alsa_nmidiout = nmidiout;
alsa_nmidiin = nmidiin;
+
+ /* JMZ: connect all available devices to pd */
+ if (autoconnect)
+ {
+
+ snd_seq_client_info_t *cinfo;
+ snd_seq_port_info_t *pinfo;
+
+ snd_seq_port_subscribe_t *subs;
+ snd_seq_addr_t other, topd, frompd;
+ /* since i don't know how to connect multiple ports
+ * (connect everything to each port, modulo,...),
+ * i only fully connect where we have only one single port
+ */
+ if(alsa_nmidiin)
+ {
+ topd.client =client;
+ topd.port =alsa_midiinfd[0];
+ }
+ if(alsa_nmidiout)
+ {
+ frompd.client =client;
+ frompd.port =alsa_midioutfd[0];
+ }
+
+ snd_seq_port_subscribe_alloca(&subs);
+
+ snd_seq_client_info_alloca(&cinfo);
+ snd_seq_port_info_alloca(&pinfo);
+ snd_seq_client_info_set_client(cinfo, -1);
+ while (snd_seq_query_next_client(midi_handle, cinfo) >= 0)
+ {
+ /* reset query info */
+ int client_id=snd_seq_client_info_get_client(cinfo);
+
+ if((SND_SEQ_CLIENT_SYSTEM != client_id)&&(client != client_id))
+ { /* skipping port 0 and ourself */
+ snd_seq_port_info_set_client(pinfo, client_id);
+ snd_seq_port_info_set_port(pinfo, -1);
+ while (snd_seq_query_next_port(midi_handle, pinfo) >= 0)
+ {
+ other.client=client_id;
+ other.port =snd_seq_port_info_get_port(pinfo);
+ if(1==alsa_nmidiin) /* only autoconnect 1st port */
+ {
+ snd_seq_port_subscribe_set_sender(subs, &other);
+ snd_seq_port_subscribe_set_dest(subs, &topd);
+ snd_seq_subscribe_port(midi_handle, subs);
+ }
+ if(1==alsa_nmidiout) /* only autoconnect 1st port */
+ {
+ snd_seq_port_subscribe_set_sender(subs, &frompd);
+ snd_seq_port_subscribe_set_dest(subs, &other);
+ snd_seq_subscribe_port(midi_handle, subs);
+ }
+ }
+ }
+ }
+ }
return;
- error:
+ error:
sys_setalarm(1000000);
post("couldn't open alsa MIDI output device");
return;
@@ -169,10 +239,8 @@ void sys_alsa_putmidibyte(int portno, int byte)
{
// 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);
- snd_seq_ev_set_sysex(&ev,1,dataptr); //...set_variable *should* have worked but didn't
+ snd_seq_ev_set_sysex(&ev,1,&data); //...set_variable *should* have worked but didn't
snd_seq_ev_set_direct(&ev);
snd_seq_ev_set_subs(&ev);
snd_seq_ev_set_source(&ev,alsa_midioutfd[portno]);
diff --git a/pd/src/s_midi_pm.c b/pd/src/s_midi_pm.c
index a79c839b..b0993268 100644
--- a/pd/src/s_midi_pm.c
+++ b/pd/src/s_midi_pm.c
@@ -140,7 +140,7 @@ void sys_putmidibyte(int portno, int byte)
writemidi4(mac_midioutdevlist[portno], byte, 0, 0, 0);
else if (byte == 0xf0)
{
- mess[0] = 0xf7;
+ mess[0] = 0xf0;
nbytes = 1;
sysex = 1;
}
@@ -209,6 +209,38 @@ void sys_putmidibyte(int portno, int byte)
}
}
+/* this is non-zero if we are in the middle of transmitting sysex */
+
+int nd_sysex_mode=0;
+
+/* send in 4 bytes of sysex data. if one of the bytes is 0xF7 (sysex end) stop and unset nd_sysex_mode */
+void nd_sysex_inword(int midiindev, int status, int data1, int data2, int data3)
+{
+ if (nd_sysex_mode) {
+ sys_midibytein(midiindev, status);
+ if (status == 0xF7)
+ nd_sysex_mode = 0;
+ }
+
+ if (nd_sysex_mode) {
+ sys_midibytein(midiindev, data1);
+ if (data1 == 0xF7)
+ nd_sysex_mode = 0;
+ }
+
+ if (nd_sysex_mode) {
+ sys_midibytein(midiindev, data2);
+ if (data2 == 0xF7)
+ nd_sysex_mode = 0;
+ }
+
+ if (nd_sysex_mode) {
+ sys_midibytein(midiindev, data3);
+ if (data3 == 0xF7)
+ nd_sysex_mode = 0;
+ }
+}
+
void sys_poll_midi(void)
{
int i, nmess;
@@ -221,6 +253,7 @@ void sys_poll_midi(void)
int status = Pm_MessageStatus(buffer.message);
int data1 = Pm_MessageData1(buffer.message);
int data2 = Pm_MessageData2(buffer.message);
+ int data3 = ((buffer.message >> 24) & 0xFF);
int msgtype = (status >> 4) - 8;
switch (msgtype)
{
@@ -239,8 +272,12 @@ void sys_poll_midi(void)
sys_midibytein(i, data1);
break;
case 7:
- sys_midibytein(i, status);
+ nd_sysex_mode=1;
+ nd_sysex_inword(i, status, data1, data2, data3);
break;
+ default:
+ if (nd_sysex_mode)
+ nd_sysex_inword(i, status, data1, data2, data3);
}
}
}
diff --git a/pd/src/u_main.tk b/pd/src/u_main.tk
index 8c43905b..b44aedab 100644
--- a/pd/src/u_main.tk
+++ b/pd/src/u_main.tk
@@ -434,16 +434,16 @@ proc menu_doc_browser {dir} {
proc doc_make_listbox {base dir count} {
# check for [file readable]?
- if { [info tclversion] >= 8.5 } {
+ #if { [info tclversion] >= 8.5 } {
# requires Tcl 8.5 but probably deals with special chars better
# destroy {expand}[lrange [winfo children $base] [expr {2 * $count}] end]
- } else {
+ #} else {
if { [catch { eval destroy [lrange [winfo children $base] \
[expr { 2 * $count }] end] } \
errorMessage] } {
puts stderr "doc_make_listbox: error listing $dir\n"
}
- }
+ #}
# exportselection 0 looks good, but selection gets easily out-of-sync
set current_listbox [listbox "[set b "$base.listbox$count"]-list" -yscrollcommand \
[list "$b-scroll" set] -height 20 -exportselection 0]
diff --git a/pd/src/x_midi.c b/pd/src/x_midi.c
index b985041d..3e25cf4e 100644
--- a/pd/src/x_midi.c
+++ b/pd/src/x_midi.c
@@ -12,6 +12,8 @@ void outmidi_pitchbend(int portno, int channel, int value);
void outmidi_aftertouch(int portno, int channel, int value);
void outmidi_polyaftertouch(int portno, int channel, int pitch, int value);
void outmidi_mclk(int portno);
+void outmidi_byte(int portno, int value);
+
/* ----------------------- midiin and sysexin ------------------------- */
@@ -32,8 +34,8 @@ static void *midiin_new( void)
x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
pd_bind(&x->x_obj.ob_pd, midiin_sym);
-#ifndef __linux__
- pd_error(x, "midiin: works under Linux only");
+#ifdef WIN32
+ pd_error(x, "midiin: windows: not supported");
#endif
return (x);
}
@@ -55,8 +57,8 @@ static void *sysexin_new( void)
x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
pd_bind(&x->x_obj.ob_pd, sysexin_sym);
-#ifndef __linux__
- pd_error(x, "sysexin: works under Linux only");
+#ifdef WIN32
+ pd_error(x, "sysexin: windows: not supported");
#endif
return (x);
}
@@ -678,7 +680,7 @@ static void *midiout_new(t_floatarg portno)
static void midiout_float(t_midiout *x, t_floatarg f)
{
- sys_putmidibyte(x->x_portno - 1, f);
+ outmidi_byte(x->x_portno - 1, f);
}
static void midiout_setup(void)
diff --git a/pd/src/x_misc.c b/pd/src/x_misc.c
index 411304fa..0c894c72 100644
--- a/pd/src/x_misc.c
+++ b/pd/src/x_misc.c
@@ -22,7 +22,10 @@
#endif
#if defined (__APPLE__) || defined (__FreeBSD__)
-#define HZ CLK_TCK
+#define CLOCKHZ CLK_TCK
+#endif
+#if defined (__linux__)
+#define CLOCKHZ sysconf(_SC_CLK_TCK)
#endif
/* -------------------------- random ------------------------------ */
@@ -230,7 +233,7 @@ static void cputime_bang2(t_cputime *x)
times(&newcputime);
elapsedcpu = 1000 * (
newcputime.tms_utime + newcputime.tms_stime -
- x->x_setcputime.tms_utime - x->x_setcputime.tms_stime) / HZ;
+ x->x_setcputime.tms_utime - x->x_setcputime.tms_stime) / CLOCKHZ;
outlet_float(x->x_obj.ob_outlet, elapsedcpu);
#endif
#ifdef MSW