Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22063/pd/src
Modified Files: configure.in g_all_guis.c g_numbox.c m_glob.c makefile makefile.dependencies notes.txt s_inter.c s_main.c s_midi.c s_stuff.h u_main.tk u_pdsend.c x_connective.c Added Files: s_midi_alsa.c Log Message: fixed bugs, adopted some patches.
Index: configure.in =================================================================== RCS file: /cvsroot/pure-data/pd/src/configure.in,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** configure.in 25 Jun 2005 02:49:08 -0000 1.11 --- configure.in 16 Jul 2005 01:43:18 -0000 1.12 *************** *** 14,17 **** --- 14,18 ---- AC_SUBST(SYSSRC) AC_SUBST(TCLTK_FRAMEWORKS_PATH) + AC_SUBST(TCLTK_FRAMEWORKS_PATH) AC_SUBST(STRIPFLAG) AC_SUBST(GUINAME) *************** *** 170,177 **** if test x$alsa == "xyes"; then ! SYSSRC=$SYSSRC" s_audio_alsa.c s_audio_alsamm.c" MORECFLAGS=$MORECFLAGS" -DPA_USE_ALSA -DUSEAPI_ALSA" LDFLAGS=$LDFLAGS" -lasound" fi if test x$portaudio == "xyes";
--- 171,180 ---- if test x$alsa == "xyes"; then ! SYSSRC=$SYSSRC" s_audio_alsa.c s_audio_alsamm.c s_midi_alsa.c" MORECFLAGS=$MORECFLAGS" -DPA_USE_ALSA -DUSEAPI_ALSA" LDFLAGS=$LDFLAGS" -lasound" fi + + if test x$portaudio == "xyes";
*************** *** 211,214 **** --- 214,235 ---- else OPT_CFLAGS="-O6 -funroll-loops -fomit-frame-pointer" + + if test x$jack == "xyes"; + then + LDFLAGS=$LDFLAGS" -lrt -ljack" + fi + if test x$jack == "xrun"; + then + LDFLAGS=$LDFLAGS" -lrt -ljack" + fi + fi + + if test x$jack == "xyes"; + then + LDFLAGS=$LDFLAGS" -lrt -ljack" + fi + if test x$jack == "xrun"; + then + LDFLAGS=$LDFLAGS" -lrt -ljack" fi echo OPT_CFLAGS --------------- $OPT_CFLAGS *************** *** 245,249 **** -I../portmidi/porttime \ -Wno-error \ ! -DUSEAPI_PORTAUDIO -DPA_BIG_ENDIAN -DPA19" SYSSRC="s_midi_pm.c s_audio_pa.c \ s_audio_pablio.c \ --- 266,270 ---- -I../portmidi/porttime \ -Wno-error \ ! -DUSEAPI_PORTAUDIO -DPA_BIG_ENDIAN -DPA19 -DPA_USE_COREAUDIO" SYSSRC="s_midi_pm.c s_audio_pa.c \ s_audio_pablio.c \
Index: s_main.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_main.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** s_main.c 8 Jul 2005 00:02:45 -0000 1.13 --- s_main.c 16 Jul 2005 01:43:18 -0000 1.14 *************** *** 3,7 **** * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
! char pd_version[] = "Pd version 0.39 TEST 3\n"; char pd_compiletime[] = __TIME__; char pd_compiledate[] = __DATE__; --- 3,7 ---- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
! char pd_version[] = "Pd version 0.39 TEST 4\n"; char pd_compiletime[] = __TIME__; char pd_compiledate[] = __DATE__; *************** *** 347,350 **** --- 347,354 ---- "-nomidiout -- suppress MIDI output\n", "-nomidi -- suppress MIDI input and output\n", + #ifdef USEAPI_ALSA + "-alsamidi -- use ALSA midi API\n", + #endif +
"\nother flags:\n", *************** *** 605,608 **** --- 609,617 ---- argc -= 2; argv +=2; } + else if (!strcmp(*argv, "-alsamidi")) + { + sys_set_midi_api(API_ALSA); + argc--; argv++; + } #endif #ifdef USEAPI_JACK
Index: u_main.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/u_main.tk,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** u_main.tk 8 Jul 2005 00:02:45 -0000 1.12 --- u_main.tk 16 Jul 2005 01:43:18 -0000 1.13 *************** *** 45,48 **** --- 45,54 ---- # turn on James Tittle II's fast drawing (wait until I can test this...): # set tk::mac::useCGDrawing 1 + # set minimum line size for anti-aliasing. If set to 1 or 0, then every + # line will be anti-aliased. While this makes connections and circles in + # [bng] and such look really good, it makes boxes and messages look out of + # focus. Setting this to 2 makes it so the thick audio rate connections + # are anti-aliased. hans@at.or.at 2005-06-09 + set tk::mac::CGAntialiasLimit 2 global pd_guidir global pd_tearoff *************** *** 339,346 **** global pd_guidir global pd_myversion ! global pd_font3 set name [format ".help%d" $doc_number] toplevel $name ! text $name.text -relief raised -bd 2 -font $pd_font3 \ -yscrollcommand "$name.scroll set" -background white scrollbar $name.scroll -command "$name.text yview" --- 345,352 ---- global pd_guidir global pd_myversion ! # global pd_font3 set name [format ".help%d" $doc_number] toplevel $name ! text $name.text -relief raised -bd 2 -font -*-times-regular--normal--14-* \ -yscrollcommand "$name.scroll set" -background white scrollbar $name.scroll -command "$name.text yview" *************** *** 452,456 ****
proc menu_addstd {mbar} { ! global pd_apilist pd_nt pd_tearoff # the "Audio" menu $mbar.audio add command -label {audio ON} -accelerator [accel_munge "Ctrl+/"] \ --- 458,462 ----
proc menu_addstd {mbar} { ! global pd_apilist pd_midiapilist pd_nt pd_tearoff # the "Audio" menu $mbar.audio add command -label {audio ON} -accelerator [accel_munge "Ctrl+/"] \ *************** *** 464,467 **** --- 470,479 ---- -command {pd [concat pd audio-setapi $pd_whichapi ;]} } + for {set x 0} {$x<[llength $pd_midiapilist]} {incr x} { + $mbar.audio add radiobutton -label [lindex [lindex $pd_midiapilist $x] 0] \ + -command {menu_midi 0} -variable pd_whichmidiapi \ + -value [lindex [lindex $pd_midiapilist $x] 1]\ + -command {pd [concat pd midi-setapi $pd_whichmidiapi ;]} + } if {$pd_nt != 2} { $mbar.audio add command -label {Audio settings...} \ *************** *** 3113,3117 ****
text $name.text -relief raised -bd 2 -height 40 -width 60 \ ! -yscrollcommand "$name.scroll set" -font pd_font3 scrollbar $name.scroll -command "$name.text yview" pack $name.scroll -side right -fill y --- 3125,3129 ----
text $name.text -relief raised -bd 2 -height 40 -width 60 \ ! -yscrollcommand "$name.scroll set" -font $pd_font3 scrollbar $name.scroll -command "$name.text yview" pack $name.scroll -side right -fill y *************** *** 3183,3200 ****
# tb: user defined typefaces ! proc pdtk_pd_startup {version apilist fontname} { # puts stderr [concat $version $apilist $fontname] ! global pd_myversion pd_apilist set pd_myversion $version set pd_apilist $apilist ! global pd_font1 pd_font2 pd_font3 pd_font4 pd_font5 pd_font6 pd_font7
! set pd_font1 [format -*-%s-bold--normal--8-* $fontname] ! set pd_font2 [format -*-%s-bold--normal--10-* $fontname] ! set pd_font3 [format -*-%s-bold--normal--12-* $fontname] ! set pd_font4 [format -*-%s-bold--normal--14-* $fontname] ! set pd_font5 [format -*-%s-bold--normal--16-* $fontname] ! set pd_font6 [format -*-%s-bold--normal--24-* $fontname] ! set pd_font7 [format -*-%s-bold--normal--36-* $fontname]
set width1 [font measure $pd_font1 x] --- 3195,3213 ----
# tb: user defined typefaces ! proc pdtk_pd_startup {version apilist midiapilist fontname} { # puts stderr [concat $version $apilist $fontname] ! global pd_myversion pd_apilist pd_midiapilist set pd_myversion $version set pd_apilist $apilist ! set pd_midiapilist $midiapilist ! global pd_font1 pd_font2 pd_font3 pd_font4 pd_font5 pd_font6 pd_font7
! set pd_font1 [format -*-%s-bold--normal--8-* $fontname] ! set pd_font2 [format -*-%s-bold--normal--10-* $fontname] ! set pd_font3 [format -*-%s-bold--normal--12-* $fontname] ! set pd_font4 [format -*-%s-bold--normal--14-* $fontname] ! set pd_font5 [format -*-%s-bold--normal--16-* $fontname] ! set pd_font6 [format -*-%s-bold--normal--24-* $fontname] ! set pd_font7 [format -*-%s-bold--normal--36-* $fontname]
set width1 [font measure $pd_font1 x] *************** *** 3677,3685 **** }
! ####################### midi dialog ##################3
proc midi_apply {id} { global midi_indev1 midi_indev2 midi_indev3 midi_indev4 ! global midi_outdev1 midi_outdev2 midi_outdev3 midi_outdev4
pd [concat pd midi-dialog \ --- 3690,3698 ---- }
! ####################### midi dialog ##################
proc midi_apply {id} { global midi_indev1 midi_indev2 midi_indev3 midi_indev4 ! global midi_outdev1 midi_outdev2 midi_outdev3 midi_outdev4 midi_alsain midi_alsaout
pd [concat pd midi-dialog \ *************** *** 3692,3695 **** --- 3705,3710 ---- $midi_outdev3 \ $midi_outdev4 \ + $midi_alsain \ + $midi_alsaout \ ;] } *************** *** 3728,3732 **** # controls for opening several devices; if not, we get an extra button to # turn longform on and restart the dialog. - proc pdtk_midi_dialog {id indevlist indev1 indev2 indev3 indev4 \ outdevlist outdev1 outdev2 outdev3 outdev4 longform} { --- 3743,3746 ---- *************** *** 3734,3737 **** --- 3748,3752 ---- global midi_outdev1 midi_outdev2 midi_outdev3 midi_outdev4 global midi_indevlist midi_outdevlist + global midi_alsain midi_alsaout
set midi_indev1 $indev1 *************** *** 3745,3748 **** --- 3760,3765 ---- set midi_indevlist $indevlist set midi_outdevlist $outdevlist + set midi_alsain [llength $indevlist] + set midi_alsaout [llength $outdevlist]
toplevel $id *************** *** 3858,3861 **** --- 3875,4020 ---- }
+ proc pdtk_alsa_midi_dialog {id indevlist indev1 indev2 indev3 indev4 \ + outdevlist outdev1 outdev2 outdev3 outdev4 longform alsa} { + global midi_indev1 midi_indev2 midi_indev3 midi_indev4 + global midi_outdev1 midi_outdev2 midi_outdev3 midi_outdev4 + global midi_indevlist midi_outdevlist + global midi_alsain midi_alsaout + + set midi_indev1 $indev1 + set midi_indev2 $indev2 + set midi_indev3 $indev3 + set midi_indev4 $indev4 + set midi_outdev1 $outdev1 + set midi_outdev2 $outdev2 + set midi_outdev3 $outdev3 + set midi_outdev4 $outdev4 + set midi_indevlist $indevlist + set midi_outdevlist $outdevlist + set midi_alsain [llength $indevlist] + set midi_alsaout [llength $outdevlist] + + toplevel $id + wm title $id {midi} + wm protocol $id WM_DELETE_WINDOW [concat midi_cancel $id] + + frame $id.buttonframe + pack $id.buttonframe -side bottom -fill x -pady 2m + button $id.buttonframe.cancel -text {Cancel}\ + -command "midi_cancel $id" + button $id.buttonframe.apply -text {Apply}\ + -command "midi_apply $id" + button $id.buttonframe.ok -text {OK}\ + -command "midi_ok $id" + pack $id.buttonframe.cancel -side left -expand 1 + pack $id.buttonframe.apply -side left -expand 1 + pack $id.buttonframe.ok -side left -expand 1 + + frame $id.in1f + pack $id.in1f -side top + + if {$alsa == 0} { + # input device 1 + label $id.in1f.l1 -text "input device 1:" + button $id.in1f.x1 -text [lindex $indevlist $midi_indev1] \ + -command [list midi_popup $id $id.in1f.x1 midi_indev1 $indevlist] + pack $id.in1f.l1 $id.in1f.x1 -side left + + # input device 2 + if {$longform && [llength $indevlist] > 2} { + frame $id.in2f + pack $id.in2f -side top + + label $id.in2f.l1 -text "input device 2:" + button $id.in2f.x1 -text [lindex $indevlist $midi_indev2] \ + -command [list midi_popup $id $id.in2f.x1 midi_indev2 $indevlist] + pack $id.in2f.l1 $id.in2f.x1 -side left + } + + # input device 3 + if {$longform && [llength $indevlist] > 3} { + frame $id.in3f + pack $id.in3f -side top + + label $id.in3f.l1 -text "input device 3:" + button $id.in3f.x1 -text [lindex $indevlist $midi_indev3] \ + -command [list midi_popup $id $id.in3f.x1 midi_indev3 $indevlist] + pack $id.in3f.l1 $id.in3f.x1 -side left + } + + # input device 4 + if {$longform && [llength $indevlist] > 4} { + frame $id.in4f + pack $id.in4f -side top + + label $id.in4f.l1 -text "input device 4:" + button $id.in4f.x1 -text [lindex $indevlist $midi_indev4] \ + -command [list midi_popup $id $id.in4f.x1 midi_indev4 $indevlist] + pack $id.in4f.l1 $id.in4f.x1 -side left + } + + # output device 1 + + frame $id.out1f + pack $id.out1f -side top + label $id.out1f.l1 -text "output device 1:" + button $id.out1f.x1 -text [lindex $outdevlist $midi_outdev1] \ + -command [list midi_popup $id $id.out1f.x1 midi_outdev1 $outdevlist] + pack $id.out1f.l1 $id.out1f.x1 -side left + + # output device 2 + if {$longform && [llength $indevlist] > 2} { + frame $id.out2f + pack $id.out2f -side top + label $id.out2f.l1 -text "output device 2:" + button $id.out2f.x1 -text [lindex $outdevlist $midi_outdev2] \ + -command \ + [list midi_popup $id $id.out2f.x1 midi_outdev2 $outdevlist] + pack $id.out2f.l1 $id.out2f.x1 -side left + } + + # output device 3 + if {$longform && [llength $indevlist] > 3} { + frame $id.out3f + pack $id.out3f -side top + label $id.out3f.l1 -text "output device 3:" + button $id.out3f.x1 -text [lindex $outdevlist $midi_outdev3] \ + -command \ + [list midi_popup $id $id.out3f.x1 midi_outdev3 $outdevlist] + pack $id.out3f.l1 $id.out3f.x1 -side left + } + + # output device 4 + if {$longform && [llength $indevlist] > 4} { + frame $id.out4f + pack $id.out4f -side top + label $id.out4f.l1 -text "output device 4:" + button $id.out4f.x1 -text [lindex $outdevlist $midi_outdev4] \ + -command \ + [list midi_popup $id $id.out4f.x1 midi_outdev4 $outdevlist] + pack $id.out4f.l1 $id.out4f.x1 -side left + } + + # if not the "long form" make a button to + # restart with longform set. + + if {$longform == 0} { + frame $id.longbutton + pack $id.longbutton -side top + button $id.longbutton.b -text {use multiple alsa devices} \ + -command {pd pd midi-properties 1 ;} + pack $id.longbutton.b + } + } + if {$alsa} { + label $id.in1f.l1 -text "In Channels:" + entry $id.in1f.x1 -textvariable midi_alsain -width 4 + pack $id.in1f.l1 $id.in1f.x1 -side left + label $id.in1f.l2 -text "Out Channels:" + entry $id.in1f.x2 -textvariable midi_alsaout -width 4 + pack $id.in1f.l2 $id.in1f.x2 -side left + } + } + ############ pdtk_path_dialog -- dialog window for search path #########
Index: s_stuff.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_stuff.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** s_stuff.h 28 Nov 2004 21:20:43 -0000 1.6 --- s_stuff.h 16 Jul 2005 01:43:18 -0000 1.7 *************** *** 96,99 **** --- 96,101 ---- int *pnmidioutdev, int *pmidioutdev);
+ void sys_get_midi_apis(char *buf); + void sys_reopen_midi( void); void sys_close_midi( void); *************** *** 110,113 **** --- 112,131 ---- int nmidioutdev, int *midioutdev);
+ #ifdef USEAPI_ALSA + EXTERN void sys_alsa_putmidimess(int portno, int a, int b, int c); + EXTERN void sys_alsa_putmidibyte(int portno, int a); + EXTERN void sys_alsa_poll_midi(void); + EXTERN void sys_alsa_setmiditimediff(double inbuftime, double outbuftime); + EXTERN void sys_alsa_midibytein(int portno, int byte); + EXTERN void sys_alsa_close_midi( void); + + + /* implemented in the system dependent MIDI code (s_midi_pm.c, etc. ) */ + void midi_alsa_getdevs(char *indevlist, int *nindevs, + char *outdevlist, int *noutdevs, int maxndev, int devdescsize); + void sys_alsa_do_open_midi(int nmidiindev, int *midiindev, + int nmidioutdev, int *midioutdev); + #endif + /* m_sched.c */ EXTERN void sys_log_error(int type); *************** *** 234,237 **** --- 252,256 ----
void sys_listmididevs(void); + void sys_set_midi_api(int whichapi); void sys_set_audio_api(int whichapi); void sys_get_audio_apis(char *buf);
Index: s_inter.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_inter.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** s_inter.c 30 May 2005 03:04:18 -0000 1.9 --- s_inter.c 16 Jul 2005 01:43:18 -0000 1.10 *************** *** 852,856 **** int stdinpipe[2]; #endif ! /* create an empty FD poll list */ sys_fdpoll = (t_fdpoll *)t_getbytes(0); --- 852,856 ---- int stdinpipe[2]; #endif ! fprintf(stderr, "gui; %s\n", guidir); /* create an empty FD poll list */ sys_fdpoll = (t_fdpoll *)t_getbytes(0); *************** *** 1030,1033 **** --- 1030,1036 ---- char *homedir = getenv("HOME"), filename[250]; struct stat statbuf; + sprintf(filename, "%s/../../MacOS/Pd", guidir); + if (stat(filename, &statbuf) >= 0) + goto foundit; if (!homedir || strlen(homedir) > 150) goto nohomedir; *************** *** 1197,1201 **** if (!sys_nogui) { ! char buf[256]; sys_socketreceiver = socketreceiver_new(0, 0, 0, 0); sys_addpollfn(sys_guisock, (t_fdpollfn)socketreceiver_read, --- 1200,1204 ---- if (!sys_nogui) { ! char buf[256], buf2[256]; sys_socketreceiver = socketreceiver_new(0, 0, 0, 0); sys_addpollfn(sys_guisock, (t_fdpollfn)socketreceiver_read, *************** *** 1208,1212 **** #endif sys_get_audio_apis(buf); ! sys_vgui("pdtk_pd_startup {%s} %s {%s}\n", pd_version, buf, sys_font); } --- 1211,1216 ---- #endif sys_get_audio_apis(buf); ! sys_get_midi_apis(buf2); ! sys_vgui("pdtk_pd_startup {%s} %s %s {%s}\n", pd_version, buf, buf2, sys_font); }
Index: s_midi.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_midi.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** s_midi.c 8 Jul 2005 00:02:45 -0000 1.6 --- s_midi.c 16 Jul 2005 01:43:18 -0000 1.7 *************** *** 43,46 **** --- 43,48 ---- static double sys_midiinittime;
+ int sys_midiapi = API_DEFAULT; + /* this is our current estimate for at what "system" real time the current logical time's output should occur. */ *************** *** 100,108 **** { int portno = midi_outqueue[midi_outtail].q_portno; ! if (midi_outqueue[midi_outtail].q_onebyte) ! sys_putmidibyte(portno, midi_outqueue[midi_outtail].q_byte1); ! else sys_putmidimess(portno, midi_outqueue[midi_outtail].q_byte1, ! midi_outqueue[midi_outtail].q_byte2, ! midi_outqueue[midi_outtail].q_byte3); midi_outtail = (midi_outtail + 1 == MIDIQSIZE ? 0 : midi_outtail + 1); } --- 102,123 ---- { int portno = midi_outqueue[midi_outtail].q_portno; ! #ifdef USEAPI_ALSA ! if (sys_midiapi == API_ALSA) ! { ! if (midi_outqueue[midi_outtail].q_onebyte) ! sys_alsa_putmidibyte(portno, midi_outqueue[midi_outtail].q_byte1); ! else sys_alsa_putmidimess(portno, midi_outqueue[midi_outtail].q_byte1, ! midi_outqueue[midi_outtail].q_byte2, ! midi_outqueue[midi_outtail].q_byte3); ! } ! else ! #endif /* ALSA */ ! { ! if (midi_outqueue[midi_outtail].q_onebyte) ! sys_putmidibyte(portno, midi_outqueue[midi_outtail].q_byte1); ! else sys_putmidimess(portno, midi_outqueue[midi_outtail].q_byte1, ! midi_outqueue[midi_outtail].q_byte2, ! midi_outqueue[midi_outtail].q_byte3); ! } midi_outtail = (midi_outtail + 1 == MIDIQSIZE ? 0 : midi_outtail + 1); } *************** *** 442,445 **** --- 457,465 ---- lasttime = newtime; #endif + #ifdef USEAPI_ALSA + if (sys_midiapi == API_ALSA) + sys_alsa_poll_midi(); + else + #endif /* ALSA */ sys_poll_midi(); /* OS dependent poll for MIDI input */ sys_pollmidioutqueue(); *************** *** 449,452 **** --- 469,475 ---- /******************** dialog window and device listing ********************/
+ #ifdef USEAPI_ALSA + void midi_alsa_init( void); + #endif #ifdef USEAPI_OSS void midi_oss_init( void); *************** *** 459,462 **** --- 482,500 ---- static int midi_midioutdev[MAXMIDIOUTDEV];
+ + void sys_get_midi_apis(char *buf) + { + int n = 0; + strcpy(buf, "{ "); + sprintf(buf + strlen(buf), "{default-MIDI %d} ", API_DEFAULT); n++; + #ifdef USEAPI_ALSA + sprintf(buf + strlen(buf), "{ALSA-MIDI %d} ", API_ALSA); n++; + #endif + strcat(buf, "}"); + /* then again, if only one API (or none) we don't offer any choice. */ + if (n < 2) + strcpy(buf, "{}"); + + } void sys_get_midi_params(int *pnmidiindev, int *pmidiindev, int *pnmidioutdev, int *pmidioutdev) *************** *** 487,497 **** --- 525,546 ---- int nmidioutdev, int *midioutdev, int enable) { + #ifdef USEAPI_ALSA + midi_alsa_init(); + #endif #ifdef USEAPI_OSS midi_oss_init(); #endif if (enable) + #ifdef USEAPI_ALSA + if (sys_midiapi == API_ALSA) + sys_alsa_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev); + else + #endif /* ALSA */ sys_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev); sys_save_midi_params(nmidiindev, midiindev, nmidioutdev, midioutdev); + + sys_vgui("set pd_whichmidiapi %d\n", sys_midiapi); + }
*************** *** 515,518 **** --- 564,573 ---- int nindevs = 0, noutdevs = 0, i;
+ #ifdef USEAPI_ALSA + if (sys_midiapi == API_ALSA) + midi_alsa_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, + MAXNDEV, DEVDESCSIZE); + else + #endif /* ALSA */ midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, MAXNDEV, DEVDESCSIZE); *************** *** 536,539 **** --- 591,638 ---- }
+ void sys_set_midi_api(int which) + { + sys_midiapi = which; + if (sys_verbose) + post("sys_midiapi %d", sys_midiapi); + } + + void glob_midi_properties(t_pd *dummy, t_floatarg flongform); + + void glob_midi_setapi(void *dummy, t_floatarg f) + { + int newapi = f; + if (newapi) + { + if (newapi == sys_midiapi) + { + //if (!midi_isopen()) + // s_reopen_midi(); + } + else + { + #ifdef USEAPI_ALSA + if (sys_midiapi == API_ALSA) + sys_alsa_close_midi(); + else + #endif + sys_close_midi(); + sys_midiapi = newapi; + /* bash device params back to default */ + midi_nmidiindev = midi_nmidioutdev = 1; + //midi_midiindev[0] = midi_midioutdev[0] = DEFAULTMIDIDEV; + //midi_midichindev[0] = midi_midichoutdev[0] = SYS_DEFAULTCH; + sys_reopen_midi(); + } + + glob_midi_properties(0, 0); + } + else //if (midi_isopen()) + { + sys_close_midi(); + //midi_state = 0; + } + } + extern t_class *glob_pdobject;
*************** *** 590,593 **** --- 689,705 ---- midioutdev4 = (noutdev > 3 && midioutdev[3]>=0 ? midioutdev[3]+1 : 0);
+ #ifdef USEAPI_ALSA + if (sys_midiapi == API_ALSA) + sprintf(buf, + "pdtk_alsa_midi_dialog %%s \ + %s %d %d %d %d %s %d %d %d %d \ + %d 1\n", + indevliststring, + midiindev1, midiindev2, midiindev3, midiindev4, + outdevliststring, + midioutdev1, midioutdev2, midioutdev3, midioutdev4, + (flongform != 0)); + else + #endif sprintf(buf, "pdtk_midi_dialog %%s \ *************** *** 599,602 **** --- 711,715 ---- midioutdev1, midioutdev2, midioutdev3, midioutdev4, (flongform != 0)); + gfxstub_deleteforkey(0); gfxstub_new(&glob_pdobject, (void *)glob_midi_properties, buf); *************** *** 610,613 **** --- 723,727 ---- int i, nindev, noutdev; int newmidiindev[4], newmidioutdev[4]; + int alsadevin, alsadevout;
for (i = 0; i < 4; i++) *************** *** 633,638 **** } }
- sys_close_midi(); - sys_open_midi(nindev, newmidiindev, noutdev, newmidioutdev, 1); } --- 747,765 ---- } } + alsadevin = atom_getintarg(8, argc, argv); + alsadevout = atom_getintarg(9, argc, argv); + + #ifdef USEAPI_ALSA + if (sys_midiapi == API_ALSA) + { + sys_alsa_close_midi(); + sys_open_midi(alsadevin, newmidiindev, alsadevout, newmidioutdev, 1); + } + else + #endif + { + sys_close_midi(); + sys_open_midi(nindev, newmidiindev, noutdev, newmidioutdev, 1); + }
}
Index: g_all_guis.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_all_guis.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** g_all_guis.c 18 May 2005 04:28:50 -0000 1.6 --- g_all_guis.c 16 Jul 2005 01:43:18 -0000 1.7 *************** *** 354,360 **** iemgui->x_snd_unexpanded = snd; iemgui->x_snd = snd = canvas_realizedollar(iemgui->x_glist, snd); - post("send: before %s, after %s", iemgui->x_snd_unexpanded->s_name, - iemgui->x_snd->s_name); - iemgui->x_fsf.x_snd_able = sndable; iemgui_verify_snd_ne_rcv(iemgui); --- 354,357 ----
Index: makefile =================================================================== RCS file: /cvsroot/pure-data/pd/src/makefile,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** makefile 30 May 2005 04:37:25 -0000 1.13 --- makefile 16 Jul 2005 01:43:18 -0000 1.14 *************** *** 29,33 **** # the sources
! SYSSRC += s_midi_oss.c s_audio_oss.c s_audio_alsa.c s_audio_alsamm.c
SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \ --- 29,33 ---- # the sources
! SYSSRC += s_midi_oss.c s_audio_oss.c s_audio_alsa.c s_audio_alsamm.c s_midi_alsa.c
SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \ *************** *** 98,106 ****
#this is for Max OSX only... ! $(BIN_DIR)/pdtcl: $(GOBJ) $(GSRC) ! cd ../obj; libtool -dynamic -o $(BIN_DIR)/pdtcl $(GOBJ) \ ! ../../Frameworks/Tk.framework/Versions/Current/Tk \ ! ../../Frameworks/Tcl.framework/Versions/Current/Tcl \ ! /usr/lib/libSystem.B.dylib
externs: --- 98,112 ----
#this is for Max OSX only... ! $(BIN_DIR)/libPdTcl.dylib: $(GOBJ) $(GSRC) ! cd ../obj && $(CC) -dynamiclib -read_only_relocs warning \ ! -o $(BIN_DIR)/libPdTcl.dylib $(GOBJ) \ ! -F \ ! -framework Tcl -framework Tk -framework System \ ! -Wl,-install_name,@executable_path/../Resources/bin/libPdTcl.dylib ! install_name_tool -change /Tcl.framework/Versions/8.4/Tcl\ ! @executable_path/../Frameworks/Tcl.framework/Versions/8.4/Tcl \ ! -change /Tk.framework/Versions/8.4/Tk \ ! @executable_path/../Frameworks/Tk.framework/Versions/8.4/Tk \ ! ../bin/libPdTcl.dylib
externs:
Index: notes.txt =================================================================== RCS file: /cvsroot/pure-data/pd/src/notes.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** notes.txt 8 Jul 2005 00:02:44 -0000 1.14 --- notes.txt 16 Jul 2005 01:43:18 -0000 1.15 *************** *** 17,25 **** ------------ 0.39 --------- problems: ! array dimension change gives TK erro (doesn't update) ! throwing new array on canvas makes red rectangle? ! dialog doesn't start array dialog, just canvas one arrays that don't fit in bounds don't update (same as red rectangle problem?) !
flag for array to suppress printing name --- 17,24 ---- ------------ 0.39 --------- problems: ! TK commands to nonexistent windows? (maybe fixed) ! array name changes don't show up on parent arrays that don't fit in bounds don't update (same as red rectangle problem?) ! what about upsampling inlet~s? ask Pd list...
flag for array to suppress printing name
--- NEW FILE: s_midi_alsa.c --- /* Copyright (c) 1997-1999 Guenter Geiger, Miller Puckette, Larry Troxler, * Winfried Ritsch, Karl MacMillan, and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
/* MIDI I/O for Linux using ALSA */
#include <stdio.h> #ifdef UNISTD #include <unistd.h> #endif #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <alsa/asoundlib.h> #include "m_pd.h" #include "s_stuff.h"
static int alsa_nmidiin; static int alsa_midiinfd[MAXMIDIINDEV]; 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; _14bit <<= 7; _14bit |= (unsigned short)First; return(_14bit); }
void sys_alsa_do_open_midi(int nmidiin, int *midiinvec, int nmidiout, int *midioutvec) {
char portname[50]; int err = 0; int client; int i; alsa_nmidiin = 0; alsa_nmidiout = 0;
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<nmidiout;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<nmidiin;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); alsa_midioutfd[i] = port; if (port < 0) goto error; }
if (nmidiout == 0 && nmidiin == 0) return; snd_seq_client_info_t *alsainfo; snd_seq_client_info_malloc(&alsainfo); snd_seq_get_client_info(midi_handle,alsainfo); snd_seq_client_info_set_name(alsainfo,"Pure Data"); client = snd_seq_client_info_get_client(alsainfo); snd_seq_set_client_info(midi_handle,alsainfo); snd_seq_client_info_free(alsainfo); post("Opened Alsa Client %d in:%d out:%d",client,nmidiin,nmidiout); sys_setalarm(0); snd_midi_event_new(20,&midiev); alsa_nmidiout = nmidiout; alsa_nmidiin = nmidiin; return; error: sys_setalarm(1000000); post("couldn't open alsa MIDI output device"); return; }
#define md_msglen(x) (((x)<0xC0)?2:((x)<0xE0)?1:((x)<0xF0)?2:\ ((x)==0xF2)?2:((x)<0xF4)?1:0)
void sys_alsa_putmidimess(int portno, int a, int b, int c) { int channel; snd_seq_event_t ev; snd_seq_ev_clear(&ev); 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); snd_seq_ev_set_subs(&ev); snd_seq_ev_set_source(&ev,alsa_midioutfd[portno]); snd_seq_event_output_direct(midi_handle,&ev); } //post("%d %d %d\n",a,b,c); }
void sys_alsa_putmidibyte(int portno, int byte) { snd_seq_event_t ev; snd_seq_ev_clear(&ev); if (portno >= 0 && portno < alsa_nmidiout) { // 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_direct(&ev); snd_seq_ev_set_subs(&ev); snd_seq_ev_set_source(&ev,alsa_midioutfd[portno]); snd_seq_event_output_direct(midi_handle,&ev); } }
/* this version uses the asynchronous "read()" ... */ void sys_alsa_poll_midi(void) { char buf[20]; int count, alsa_source; 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) { count = snd_midi_event_decode(midiev,buf,20,midievent); alsa_source = midievent->dest.port; for(i=0;i<count;i++) sys_midibytein(alsa_source, (buf[i] & 0xff)); //post("received %d midi bytes\n",count); } }
void sys_alsa_close_midi() { alsa_nmidiin = alsa_nmidiout = 0; snd_seq_close(midi_handle); snd_midi_event_free(midiev); }
#define NSEARCH 10 static int alsa_nmidiindevs, alsa_nmidioutdevs, alsa_initted;
void midi_alsa_init(void) { int i; if (alsa_initted) return; alsa_initted = 1; }
void midi_alsa_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *noutdevs, int maxndev, int devdescsize) { 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; }
Index: makefile.dependencies =================================================================== RCS file: /cvsroot/pure-data/pd/src/makefile.dependencies,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** makefile.dependencies 30 May 2005 04:37:25 -0000 1.5 --- makefile.dependencies 16 Jul 2005 01:43:18 -0000 1.6 *************** *** 1035,1036 **** --- 1035,1069 ---- /usr/include/bits/ioctl-types.h /usr/include/sys/ttydefaults.h \ /usr/include/sched.h s_audio_alsa.h + s_midi_alsa.o: s_midi_alsa.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/alsa/asoundlib.h /usr/include/string.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /usr/include/assert.h /usr/include/sys/poll.h /usr/include/bits/poll.h \ + /usr/include/alsa/asoundef.h /usr/include/alsa/version.h \ + /usr/include/alsa/global.h /usr/include/alsa/input.h \ + /usr/include/alsa/output.h /usr/include/alsa/error.h \ + /usr/include/alsa/conf.h /usr/include/alsa/pcm.h \ + /usr/include/alsa/rawmidi.h /usr/include/alsa/timer.h \ + /usr/include/alsa/hwdep.h /usr/include/alsa/control.h \ + /usr/include/alsa/mixer.h /usr/include/alsa/seq_event.h \ + /usr/include/alsa/seq.h /usr/include/alsa/seqmid.h \ + /usr/include/alsa/seq_midi_event.h /usr/include/alsa/conv.h \ + /usr/include/alsa/instr.h m_pd.h s_stuff.h
Index: x_connective.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/x_connective.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** x_connective.c 30 May 2005 03:04:19 -0000 1.5 --- x_connective.c 16 Jul 2005 01:43:18 -0000 1.6 *************** *** 506,510 **** { float f; ! if (!argc) return; f = atom_getfloat(argv); for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) --- 506,514 ---- { float f; ! if (!argc) /* empty lists go out reject outlet */ ! { ! outlet_bang(x->x_rejectout); ! return; ! } f = atom_getfloat(argv); for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) *************** *** 581,585 **** int n; t_routeelement *e; ! t_route *x = (t_route *)pd_new(route_class); t_atom a; if (argc == 0) --- 585,590 ---- int n; t_routeelement *e; ! t_route *x; ! t_atom a; if (argc == 0) *************** *** 589,592 **** --- 594,604 ---- argv = &a; } + for (n = 1; n < argc; n++) + if (argv[n].a_type != argv[0].a_type) + { + error("route: creation with mixed argument types failed"); + return (0); + } + x = (t_route *)pd_new(route_class); x->x_type = argv[0].a_type; x->x_nelement = argc;
Index: u_pdsend.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/u_pdsend.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** u_pdsend.c 6 Sep 2004 20:20:36 -0000 1.2 --- u_pdsend.c 16 Jul 2005 01:43:18 -0000 1.3 *************** *** 106,110 **** while (1) { ! char buf[BUFSIZE], *bp, nsent, nsend; if (!fgets(buf, BUFSIZE, stdin)) break; --- 106,111 ---- while (1) { ! char buf[BUFSIZE], *bp; ! int nsent, nsend; if (!fgets(buf, BUFSIZE, stdin)) break;
Index: g_numbox.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_numbox.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** g_numbox.c 25 Jun 2005 02:49:15 -0000 1.5 --- g_numbox.c 16 Jul 2005 01:43:18 -0000 1.6 *************** *** 37,41 **** static void my_numbox_tick_reset(t_my_numbox *x) { ! if(x->x_gui.x_fsf.x_change && x->x_gui.x_glist) { x->x_gui.x_fsf.x_change = 0; --- 37,41 ---- static void my_numbox_tick_reset(t_my_numbox *x) { ! if(x->x_gui.x_fsf.x_change && x->x_gui.x_glist) { x->x_gui.x_fsf.x_change = 0;
Index: m_glob.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_glob.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** m_glob.c 6 Sep 2004 20:20:35 -0000 1.4 --- m_glob.c 16 Jul 2005 01:43:18 -0000 1.5 *************** *** 24,27 **** --- 24,28 ---- void glob_midi_properties(t_pd *dummy, t_floatarg flongform); void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv); + void glob_midi_setapi(t_pd *dummy, t_floatarg f); void glob_start_path_dialog(t_pd *dummy, t_floatarg flongform); void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv); *************** *** 94,97 **** --- 95,100 ---- class_addmethod(glob_pdobject, (t_method)glob_audio_setapi, gensym("audio-setapi"), A_FLOAT, 0); + class_addmethod(glob_pdobject, (t_method)glob_midi_setapi, + gensym("midi-setapi"), A_FLOAT, 0); class_addmethod(glob_pdobject, (t_method)glob_midi_properties, gensym("midi-properties"), A_DEFFLOAT, 0);