Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jwilkes/purr-data
  • aggraef/purr-data
  • samthursfield/purr-data
  • prakhar/purr-data
  • yadu05/purr-data
  • NegiAkash890/purr-data
  • prateekpardeshi/purr-data
  • Shruti3004/purr-data
  • hidimpu/purr-data
  • Atseosi/purr-data
  • piyushjasaiwal/purr-data
  • deveshprasad/purr-data
  • skm_7/purr-data
  • sankt/purr-data
  • ashim_tom/purr-data
  • dineshsoni02/purr-data
  • chaitanya1-coder/purr-data
  • Nitish0007/purr-data
  • nitin/purr-data
  • shuvam09/purr-data
  • gabrielabittencourt/purr-data
  • sivasai/purr-data
  • flachyjoe/purr-data
  • ishankaler/purr-data
  • prateek/purr-data
  • RukshanJS/purr-data
  • rajatshrm648/purr-data
  • Srashti/purr-data
  • Paarth/purr-data
  • AniruddhaGawali/purr-data
  • brittneyjuliet/purr-data
  • prakharagarwal1/purr-data
  • Shreyanshpaliwalcmsmn/purr-data
  • k_amrut/purr-data
  • AyushAnand/purr-data
  • Va16hav07/purr-data
36 results
Show changes
Showing
with 781 additions and 395 deletions
......@@ -67,7 +67,7 @@ ORIGDIR=pd-$(LIBRARY_NAME)_$(LIBRARY_VERSION)
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
CPU := $(shell uname -p)
ifeq ($(CPU),arm) # iPhone/iPod Touch
ifeq ($(CPU),arm-iphone) # iPhone/iPod Touch
SOURCES += $(SOURCES_iphoneos)
EXTENSION = pd_darwin
OS = iphoneos
......@@ -97,8 +97,8 @@ ifeq ($(UNAME),Darwin)
FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
SOURCES += $(SOURCES_iphoneos)
endif
CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
CFLAGS += $(FAT_FLAGS) -fPIC
LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
# if the 'pd' binary exists, check the linking against it to aid with stripping
LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
LIBS += -lc
......
......@@ -92,7 +92,7 @@ ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION)
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
CPU := $(shell uname -p)
ifeq ($(CPU),arm) # iPhone/iPod Touch
ifeq ($(CPU),arm-iphone) # iPhone/iPod Touch
SOURCES += $(SOURCES_iphoneos)
EXTENSION = pd_darwin
SHARED_EXTENSION = dylib
......@@ -130,7 +130,7 @@ ifeq ($(UNAME),Darwin)
FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
endif
endif
ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
ALL_CFLAGS += $(FAT_FLAGS) -fPIC
# if the 'pd' binary exists, check the linking against it to aid with stripping
BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
......
......@@ -523,7 +523,7 @@ ifeq ($(system), Darwin)
/Applications/Pd-extended*.app/Contents/Resources/include/pdextended \
/Applications/Pd*.app/Contents/Resources/src))
extension = pd_darwin
cpp.flags := -DUNIX -DMACOSX -I /sw/include
cpp.flags := -DUNIX -DMACOSX
c.flags :=
c.ldflags := -undefined suppress -flat_namespace -bundle
c.ldlibs := -lc
......
#N canvas 8 25 1015 671 10;
#X text 35 71 A soundfont player using If I Were You \, from www.iiwu.org
#N canvas 645 66 561 627 10;
#X obj 0 595 cnv 15 552 21 empty \$0-pddp.cnv.footer empty 20 12 0
14 #dcdcdc #404040 0;
#X obj 0 0 cnv 15 552 40 empty \$0-pddp.cnv.header fluid~ 3 12 0 18
#c4dcdc #000000 0;
#X obj 0 294 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 8 12 0 13
#dcdcdc #000000 0;
#N canvas 484 286 496 371 META 0;
#X text 12 5 KEYWORDS synthesizer soundfont;
#X text 12 25 LICENSE GPLv2+;
#X text 12 75 AUTHOR Frank Barknecht \, Jonathan Wilkes \, Albert Gräf
;
#X text 170 296 fluid~ wants channel # first: should I change this?
#X text 12 115 RELEASE_DATE 2003 \, 2016 \, 2020;
#X text 12 45 DESCRIPTION MIDI synthesizer using fluidsynth;
#X text 12 95 WEBSITE http://www.fluidsynth.org/;
#X text 12 135 HELP_PATCH_AUTHORS Albert Gräf \, based on an earlier
help patch by Frank Barknecht and others.;
#X restore 500 597 pd META;
#X obj 0 441 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlets 8 12 0
13 #dcdcdc #000000 0;
#X obj 0 510 cnv 3 550 3 empty \$0-pddp.cnv.argument arguments 8 12
0 13 #dcdcdc #000000 0;
#X obj 0 568 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 8 12
0 13 #dcdcdc #000000 0;
#X obj 78 303 cnv 17 3 130 empty \$0-pddp.cnv.let.0 0 5 9 0 16 #dcdcdc
#9c9c9c 0;
#X obj 78 450 cnv 17 3 17 empty \$0-pddp.cnv.let.n l 5 9 0 16 #dcdcdc
#9c9c9c 0;
#X obj 78 472 cnv 17 3 17 empty \$0-pddp.cnv.let.r r 5 9 0 16 #dcdcdc
#9c9c9c 0;
#X text 98 450 signal;
#X obj 4 597 pddp/pddplink all_about_help_patches.pd -text Usage Guide
;
#X text 287 518 Program change ( prog or p + chan + value);
#X text 170 246 Note messages start with note \, n or with nothing
(pure list input): chan + note + velocity;
#X obj 36 34 cnv 15 102 32 empty empty empty 20 12 1 14 -1 -66577 0
#X obj 492 12 fluid~;
#X text 11 23 soundfont synthesizer based on fluidsynth;
#X obj 14 118 output~;
#X obj 14 89 fluid~ -smmf TimGM6mb;
#X text 164 61 Download Tim Brechbill's small (~6MB) GM soundfont here:
;
#X obj 37 35 cnv 15 100 30 empty empty fluid~ 20 15 1 14 -257472 -66577
0;
#X obj 593 18 cnv 15 374 160 empty empty empty 20 12 1 14 -1 -66577
0;
#X text 181 120 load soundfonts. Creation argument is possible as well:
#X obj 164 91 pddp/pddplink https://musescore.org/en/handbook/soundfonts-and-sfz-files#list
-text More soundfonts here (musescore.org);
#X obj 14 60 r \$0-fluid;
#X msg 90 60 help;
#X text 98 473 signal;
#X text 168 449 - [fluid~] outputs a stereo signal to its two signal
outlets.;
#X text 79 519 1) -smmf;
#X text 79 536 2) symbol;
#X text 168 519 - (optional) enables SMMF mode.;
#X text 98 303 sym f f f;
#X text 180 390 - load the given soundfont file (automatic .sf2 extension).
;
#X obj 594 19 cnv 15 372 158 empty Notes Soundfonts 20 12 1 14 -228992
-66577 0;
#X msg 650 109 load /usr/lib/awe/sfbank/2gmgsmt.sf2;
#X msg 644 89 load \$1;
#X obj 644 67 openpanel;
#X obj 644 47 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
-1;
#X obj 629 134 s \$0-iiwu;
#X obj 375 146 fluid~ notavail.sf2;
#X obj 593 182 cnv 15 374 160 empty empty empty 20 12 1 14 -1 -66577
0;
#X obj 594 183 cnv 15 372 158 empty Notes Notes 20 12 1 14 -228992
-66577 0;
#X obj 837 224 notein;
#X obj 837 246 pack 0 0 0;
#X msg 695 288 n 1 60 0;
#X obj 640 311 s \$0-iiwu;
#X obj 695 244 bang;
#X msg 837 268 \$3 \$1 \$2;
#X obj 837 290 s \$0-iiwu;
#X obj 593 345 cnv 15 374 160 empty empty empty 20 12 1 14 -1 -66577
0;
#X text 159 413 Controller Change: control or c or cc + chan + cc#
+ value;
#X obj 594 346 cnv 15 372 158 empty Notes Controller_Change/Pitch_Bend
20 12 1 14 -228992 -66577 0;
#X obj 632 473 s \$0-iiwu;
#X floatatom 632 388 5 0 0 0 - - -, f 5;
#X msg 649 441 c 2 \$1;
#X msg 632 407 control 1 2 \$1;
#X obj 593 509 cnv 15 374 160 empty empty empty 20 12 1 14 -1 -66577
#X text 168 536 - (optional) any other symbol specifies a soundfont
file to be loaded at creation time.;
#X text 216 415 - reinitialize \, load the given soundfont file if
any.;
#X obj 15 196 notein;
#X obj 15 221 pack 0 0 0;
#X msg 15 246 \$3 \$1 \$2;
#X text 15 172 MIDI input (legacy mode):;
#X obj 95 221 pack 0 0 0;
#X obj 95 196 ctlin;
#X obj 175 196 bendin 0 1;
#X obj 175 221 pack 0 0;
#X msg 95 246 cc \$3 \$2 \$1;
#X floatatom 264 221 5 0 0 0 - - -, f 5;
#X msg 264 245 prog 1 \$1;
#X floatatom 341 221 5 0 0 0 - - -, f 5;
#X msg 341 245 bank 1 \$1;
#X text 261 200 prog change;
#X text 339 200 bank select;
#X msg 175 246 b \$2 \$1;
#X obj 15 271 s \$0-legacy;
#N canvas 769 250 453 354 switch 0;
#X obj 40 110 r \$0-legacy;
#X obj 40 135 spigot 1;
#X obj 121 110 r \$0-smmf;
#X obj 121 135 spigot;
#X obj 85 15 inlet;
#X obj 85 40 t f f;
#X obj 85 65 == 0;
#X obj 154 65 != 0;
#X obj 40 160 outlet;
#X connect 0 0 1 0;
#X connect 1 0 8 0;
#X connect 2 0 3 0;
#X connect 3 0 8 0;
#X connect 4 0 5 0;
#X connect 5 0 6 0;
#X connect 5 1 7 0;
#X connect 6 0 1 1;
#X connect 7 0 3 1;
#X restore 460 159 pd switch;
#X obj 460 134 tgl 15 0 empty empty smmf-mode 17 7 0 10 #fcfcfc #000000
#000000 0 1;
#X obj 460 184 s \$0-fluid;
#X obj 460 86 midi-input;
#X obj 460 111 s \$0-smmf;
#X text 182 113 SMMF mode supports all voice messages and sysex (useful
for transmitting MTS tuning data). This is usually to be preferred
because it offers more capabilities. See:, f 42;
#X text 168 303 - MIDI message. In "legacy" mode (default) \, args
are channel \, first and second data byte (if any) \, and the supported
message selectors are (shortcuts in parentheses): note (n \, list)
\, control (c \, cc) \, prog (p). In SMMF mode (-smmf) \, all SMMF
voice messages and sysex are supported (most legacy messages still
continue to work as well)., f 62;
#X obj 264 270 s \$0-fluid;
#N canvas 1990 266 450 302 generators 0;
#X obj 22 64 cnv 15 302 110 empty empty empty 20 12 1 14 #000000 #404040
0;
#X obj 594 510 cnv 15 372 158 empty Notes Program_Change 20 12 1 14
-228992 -66577 0;
#X obj 703 627 s \$0-iiwu;
#X msg 703 580 prog 1 \$1;
#X msg 783 580 p 2 \$1;
#X floatatom 703 550 5 0 0 0 - - -, f 5;
#X obj 695 202 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1
-1;
#X floatatom 783 550 5 0 0 0 - - -, f 5;
#X floatatom 673 388 5 0 0 0 - - -, f 5;
#X msg 695 222 note 1 60 120;
#X obj 741 388 ctlin;
#X obj 741 410 pack 0 0 0;
#X obj 856 396 bendin;
#X obj 856 418 pack 0 0;
#X obj 856 462 s \$0-iiwu;
#X msg 856 440 bend \$2 \$1;
#X text 159 445 Pitch Bend works the same: bend or b + chan + val;
#X msg 857 574 bank 1 \$1;
#X floatatom 857 555 5 0 0 0 - - -, f 5;
#X text 857 595 bank select;
#X obj 789 187 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 715 187 metro 1000;
#X obj 40 261 cnv 15 102 32 empty empty empty 20 12 1 14 -1 -66577
0;
#X obj 41 262 cnv 15 100 30 empty empty empty 20 15 1 14 -257472 -66577
0;
#X obj 66 199 r \$0-iiwu;
#X msg 66 233 help;
#X msg 146 217 init /usr/lib/awe/sfbank/2gmgsmt.sf2;
#X obj 66 269 fluid~;
#X text 145 185 init [soundfont] can (re)initialize fluid~ for example
to adapt to new samplerates.;
#X msg 741 432 cc \$3 \$2 \$1;
#X obj 203 617 cnv 15 302 110 empty empty empty 20 12 1 14 -1 -66577
0;
#X obj 204 618 cnv 15 300 108 empty Notes generators 20 12 1 14 -228992
-66577 0;
#X msg 231 682 gen 1 \$2 \$1;
#X obj 231 704 s \$0-iiwu;
#X floatatom 289 642 5 0 60 0 - - -, f 5;
#X floatatom 231 642 5 0 0 0 - - -, f 5;
#X obj 231 662 pack 0 17;
#X text 78 607 gen 17 is "pan".;
#X text 78 594 Setting generators like for example:;
#X obj 695 266 del 1000;
#X symbolatom 343 684 20 0 0 0 - - -, f 20;
#X obj 343 656 fluid.gen2sym;
#X text 345 700 a little helper;
#N canvas 402 274 605 444 dust 0;
#X obj 23 65 cnv 15 300 108 empty Notes generators 20 12 1 14 #dce4fc
#404040 0;
#X msg 50 129 gen 1 \$2 \$1;
#X floatatom 108 89 5 0 60 0 - - -, f 5;
#X floatatom 50 89 5 0 0 0 - - -, f 5;
#X obj 50 109 pack 0 17;
#X text 23 32 gen 17 is "pan".;
#X text 23 19 Setting generators like for example:;
#X symbolatom 162 131 20 0 0 0 - - -, f 20;
#X obj 162 103 fluid.gen2sym;
#X text 164 147 a little helper;
#X obj 50 151 s \$0-fluid;
#X connect 2 0 11 0;
#X connect 3 0 5 1;
#X connect 3 0 9 0;
#X connect 4 0 5 0;
#X connect 5 0 2 0;
#X connect 9 0 8 0;
#X restore 435 214 pd generators;
#X text 435 239 A composition:;
#N canvas 400 273 610 524 dust 0;
#X obj 119 135 del 10;
#X obj 119 41 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 119 41 tgl 15 0 empty empty empty 0 -6 0 8 #fcfcfc #000000 #000000
0 1;
#X floatatom 386 66 5 0 0 1 dustiness - -, f 5;
#X floatatom 386 164 5 0 0 1 note_range - -, f 5;
#X floatatom 387 198 5 0 0 1 note_center - -, f 5;
#X obj 237 417 s \$0-iiwu;
#X obj 387 242 / 2;
#X floatatom 387 223 5 0 0 1 pan_mod - -, f 5;
#X msg 237 281 gen 1 17 \$1;
......@@ -112,7 +144,6 @@ to adapt to new samplerates.;
#X obj 119 273 pack 0 0;
#X obj 119 63 metro;
#X obj 126 339 pack 0 0;
#X msg 126 371 note 1 \$1 \$2;
#X obj 119 251 makenote 100 2;
#X obj 119 212 + 60;
#X obj 119 178 random 24;
......@@ -121,80 +152,61 @@ to adapt to new samplerates.;
#X obj 198 108 t f f;
#X text 98 11 Inspired by Hans-Christoph Steiner and Derek Holzer;
#X text 15 11 __Dust__;
#X connect 0 0 9 0;
#X connect 0 0 17 0;
#X connect 1 0 12 0;
#X connect 2 0 18 1;
#X connect 3 0 17 1;
#X connect 4 0 16 1;
#X connect 6 0 10 1;
#X connect 7 0 6 0;
#X connect 7 0 9 1;
#X connect 8 0 5 0;
#X connect 9 0 10 0;
#X connect 10 0 8 0;
#X connect 11 0 19 0;
#X connect 12 0 0 0;
#X connect 12 0 18 0;
#X connect 13 0 14 0;
#X connect 14 0 5 0;
#X connect 15 0 11 0;
#X connect 15 1 11 1;
#X connect 16 0 15 0;
#X connect 17 0 16 0;
#X connect 18 0 20 0;
#X connect 19 1 13 0;
#X connect 19 2 13 1;
#X connect 20 0 0 1;
#X restore 709 715 pd dust;
#X text 601 716 A composition:;
#X msg 705 87 load /home/ico/Downloads/Soundfonts/jRhodes3.sf2;
#X obj 66 320 output~;
#X connect 9 0 13 0;
#X connect 10 0 13 0;
#X connect 11 0 10 0;
#X connect 12 0 11 0;
#X connect 17 0 18 0;
#X connect 17 1 18 1;
#X connect 17 2 18 2;
#X connect 18 0 22 0;
#X connect 19 0 20 0;
#X connect 21 0 70 0;
#X connect 22 0 23 0;
#X connect 28 0 30 0;
#X connect 29 0 27 0;
#X connect 30 0 27 0;
#X obj 237 417 s \$0-fluid;
#X msg 126 371 1 \$1 \$2;
#X connect 0 0 8 0;
#X connect 0 0 15 0;
#X connect 1 0 11 0;
#X connect 2 0 16 1;
#X connect 3 0 15 1;
#X connect 4 0 14 1;
#X connect 5 0 9 1;
#X connect 6 0 5 0;
#X connect 6 0 8 1;
#X connect 7 0 21 0;
#X connect 8 0 9 0;
#X connect 9 0 7 0;
#X connect 10 0 17 0;
#X connect 11 0 0 0;
#X connect 11 0 16 0;
#X connect 12 0 22 0;
#X connect 13 0 10 0;
#X connect 13 1 10 1;
#X connect 14 0 13 0;
#X connect 15 0 14 0;
#X connect 16 0 18 0;
#X connect 17 1 12 0;
#X connect 17 2 12 1;
#X connect 18 0 0 1;
#X connect 22 0 21 0;
#X restore 435 259 pd dust;
#X obj 182 169 pddp/pddplink https://bitbucket.org/agraef/pd-smmf;
#X text 86 390 load sf-file;
#X text 86 415 init [-smmf] sf-file;
#X obj 164 78 pddp/pddplink http://sourceforge.net/p/mscore/code/HEAD/tree/trunk/mscore/share/sound/TimGM6mb.sf2?format=raw
-text TimGM6mb.sf2 (sf.net);
#X connect 15 0 14 0;
#X connect 15 1 14 1;
#X connect 18 0 15 0;
#X connect 19 0 15 0;
#X connect 29 0 30 0;
#X connect 29 1 30 1;
#X connect 29 2 30 2;
#X connect 30 0 31 0;
#X connect 31 0 45 0;
#X connect 33 0 37 0;
#X connect 34 0 33 0;
#X connect 35 0 33 0;
#X connect 36 0 34 0;
#X connect 37 0 40 0;
#X connect 38 0 35 0;
#X connect 39 0 29 0;
#X connect 40 0 20 0;
#X connect 40 0 21 0;
#X connect 41 0 42 0;
#X connect 41 1 42 1;
#X connect 41 2 42 2;
#X connect 42 0 60 0;
#X connect 43 0 44 0;
#X connect 43 1 44 1;
#X connect 44 0 46 0;
#X connect 46 0 45 0;
#X connect 48 0 33 0;
#X connect 49 0 48 0;
#X connect 51 0 52 0;
#X connect 52 0 37 0;
#X connect 55 0 58 0;
#X connect 56 0 58 0;
#X connect 57 0 58 0;
#X connect 58 0 77 0;
#X connect 58 1 77 1;
#X connect 60 0 27 0;
#X connect 63 0 64 0;
#X connect 65 0 67 1;
#X connect 65 0 72 0;
#X connect 66 0 67 0;
#X connect 67 0 63 0;
#X connect 70 0 19 0;
#X connect 72 0 71 0;
#X connect 76 0 13 0;
#X connect 34 1 33 1;
#X connect 34 2 33 2;
#X connect 35 0 36 0;
#X connect 35 1 36 1;
#X connect 36 0 44 0;
#X connect 37 0 45 0;
#X connect 38 0 39 0;
#X connect 39 0 53 0;
#X connect 40 0 41 0;
#X connect 41 0 53 0;
#X connect 44 0 45 0;
#X connect 46 0 48 0;
#X connect 47 0 46 0;
#X connect 49 0 50 0;
// Original version by Frank Barknecht (fbar@footils.org) 2003
// Ported from Flext/C++ to plain C/pdlibbuilder by Jonathan Wilkes 2016
// SMMF mode and various other little improvements by Albert Gräf 2020
// Distributed under the GPLv2+, please check the LICENSE file for details.
#include <fluidsynth.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
// needed to get S_IRUSR etc. in msys2
#include <sys/stat.h>
#include "m_pd.h"
......@@ -10,8 +21,10 @@ typedef struct _fluid_tilde {
fluid_settings_t *x_settings;
t_outlet *x_out_left;
t_outlet *x_out_right;
t_canvas *x_canvas;
int smmf_mode;
} t_fluid_tilde;
t_int *fluid_tilde_perform(t_int *w)
{
t_fluid_tilde *x = (t_fluid_tilde *)(w[1]);
......@@ -33,18 +46,23 @@ static void fluid_tilde_dsp(t_fluid_tilde *x, t_signal **sp)
static void fluid_tilde_free(t_fluid_tilde *x)
{
outlet_free(x->x_out_left);
outlet_free(x->x_out_right);
if (x->x_synth) delete_fluid_synth(x->x_synth);
if (x->x_settings) delete_fluid_settings(x->x_settings);
}
static void fluid_help(void)
{
const char * helptext =
"_ __fluid~_ _ a soundfont external for Pd and Max/MSP \n"
"_ argument: \"/path/to/soundfont.sf\" to load on object creation\n"
"_ messages: \n"
"load /path/to/soundfont.sf2 --- Loads a Soundfont \n"
"note 0 0 0 --- Play note. Arguments: \n"
"fluid~: a soundfont external for Pd and Max/MSP\n"
"options:\n"
"-smmf: enable SMMF mode (https://bitbucket.org/agraef/pd-smmf)\n"
"-g 1: set the synth.gain value (0-10, default is 1)\n"
"-v: verbose mode (post startup messages to Pd console)\n"
"any other symbol: soundfont file to load on object creation\n"
"messages:\n"
"load /path/to/soundfont.sf2 --- Loads a Soundfont\n"
"gain 1 --- Change the gain value (0-10)\n"
"note 0 0 0 --- Play note, arguments:\n"
" channel-# note-# veloc-#\n"
"n 0 0 0 --- Play note, same as above\n"
"0 0 0 --- Play note, same as above\n"
......@@ -57,7 +75,7 @@ static void fluid_help(void)
post("%s", helptext);
}
static void fluid_note(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
static void fluid_legacy_note(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (x->x_synth == NULL) return;
if (argc == 3)
......@@ -70,7 +88,7 @@ static void fluid_note(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
}
}
static void fluid_program_change(t_fluid_tilde *x, t_symbol *s, int argc,
static void fluid_legacy_program_change(t_fluid_tilde *x, t_symbol *s, int argc,
t_atom *argv)
{
if (x->x_synth == NULL) return;
......@@ -79,11 +97,11 @@ static void fluid_program_change(t_fluid_tilde *x, t_symbol *s, int argc,
int chan, prog;
chan = atom_getintarg(0, argc, argv);
prog = atom_getintarg(1, argc, argv);
fluid_synth_program_change(x->x_synth, chan - 1, prog);
fluid_synth_program_change(x->x_synth, chan - 1, prog - 1);
}
}
static void fluid_control_change(t_fluid_tilde *x, t_symbol *s, int argc,
static void fluid_legacy_control_change(t_fluid_tilde *x, t_symbol *s, int argc,
t_atom *argv)
{
if (x->x_synth == NULL) return;
......@@ -97,7 +115,7 @@ static void fluid_control_change(t_fluid_tilde *x, t_symbol *s, int argc,
}
}
static void fluid_pitch_bend(t_fluid_tilde *x, t_symbol *s, int argc,
static void fluid_legacy_pitch_bend(t_fluid_tilde *x, t_symbol *s, int argc,
t_atom *argv)
{
if (x->x_synth == NULL) return;
......@@ -110,7 +128,7 @@ static void fluid_pitch_bend(t_fluid_tilde *x, t_symbol *s, int argc,
}
}
static void fluid_bank(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
static void fluid_legacy_bank(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (x->x_synth == NULL) return;
if (argc == 2)
......@@ -122,7 +140,7 @@ static void fluid_bank(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
}
}
static void fluid_gen(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
static void fluid_legacy_gen(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (x->x_synth == NULL) return;
if (argc == 3)
......@@ -136,47 +154,254 @@ static void fluid_gen(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
}
}
// Note that in all the SMMF methods we allow the channel to be omitted, in
// which case it defaults to 1. Also note that the channel argument *always*
// comes last, and that the argument order, being in 1-1 correspondence with
// the Pd MIDI objects, is a bit different from the legacy message format
// above which follows the MIDI standard instead.
// The system realtime messages start, stop, and cont are in SMMF, but not
// recognized by fluidsynth, so we don't support them here either. (MTS) sysex
// messages (which fluidsynth recognizes) are supported, however.
// Please check https://bitbucket.org/agraef/pd-smmf for details.
static void fluid_note(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (!x->smmf_mode)
{
fluid_legacy_note(x, s, argc, argv); return;
}
if (x->x_synth == NULL) return;
if (argc == 2 || argc == 3)
{
int key = atom_getintarg(0, argc, argv);
int vel = atom_getintarg(1, argc, argv);
int chan = argc>2 ? atom_getintarg(2, argc, argv) : 1;
fluid_synth_noteon(x->x_synth, chan - 1, key, vel);
}
}
static void fluid_ctl(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (!x->smmf_mode || x->x_synth == NULL) return;
if (argc == 2 || argc == 3)
{
int val = atom_getintarg(0, argc, argv);
int ctrl = atom_getintarg(1, argc, argv);
int chan = argc>2 ? atom_getintarg(2, argc, argv) : 1;
fluid_synth_cc(x->x_synth, chan - 1, ctrl, val);
}
}
static void fluid_pgm(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (!x->smmf_mode || x->x_synth == NULL) return;
if (argc == 1 || argc == 2)
{
int prog = atom_getintarg(0, argc, argv);
int chan = argc>1 ? atom_getintarg(1, argc, argv) : 1;
fluid_synth_program_change(x->x_synth, chan - 1, prog - 1);
}
}
static void fluid_polytouch(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (!x->smmf_mode || x->x_synth == NULL) return;
if (argc == 2 || argc == 3)
{
int val = atom_getintarg(0, argc, argv);
int key = atom_getintarg(1, argc, argv);
int chan = argc>2 ? atom_getintarg(2, argc, argv) : 1;
fluid_synth_key_pressure(x->x_synth, chan - 1, key, val);
}
}
static void fluid_touch(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (!x->smmf_mode || x->x_synth == NULL) return;
if (argc == 1 || argc == 2)
{
int val = atom_getintarg(0, argc, argv);
int chan = argc>1 ? atom_getintarg(1, argc, argv) : 1;
fluid_synth_channel_pressure(x->x_synth, chan - 1, val);
}
}
static void fluid_bend(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (!x->smmf_mode)
{
fluid_legacy_pitch_bend(x, s, argc, argv); return;
}
if (x->x_synth == NULL) return;
if (argc == 1 || argc == 2)
{
int val = atom_getintarg(0, argc, argv);
int chan = argc>1 ? atom_getintarg(1, argc, argv) : 1;
fluid_synth_pitch_bend(x->x_synth, chan - 1, val);
}
}
// Maximum size of sysex data (excluding the f0 and f7 bytes) that we can
// handle. The size below should be plenty to handle any kind of MTS message,
// which at the time of this writing is the only kind of sysex message
// recognized by fluidsynth.
#define MAXSYSEXSIZE 1024
static void fluid_sysex(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (!x->smmf_mode || x->x_synth == NULL) return;
if (argc > 0)
{
char buf[MAXSYSEXSIZE];
int len = 0;
while (len < MAXSYSEXSIZE && len < argc) {
buf[len] = atom_getintarg(len, argc, argv);
len++;
}
// TODO: In order to handle bulk dump requests in the future, we will
// have to pick up fluidsynth's response here and output that to a
// control outlet (which doesn't exist at present).
fluid_synth_sysex(x->x_synth, buf, len, NULL, NULL, NULL, 0);
}
}
static void fluid_gain(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
t_float gain = atom_getfloatarg(0, argc, argv);
// clamp the value to fluidsynths 0-10 range
if (gain < 0.0) gain = 0.0;
if (gain > 10.0) gain = 10.0;
fluid_settings_setnum(x->x_settings, "synth.gain", gain);
}
static void fluid_load(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (x->x_synth == NULL)
{
post("No fluidsynth");
pd_error(x, "fluid~: no fluidsynth");
return;
}
if (argc >= 1 && argv->a_type == A_SYMBOL)
{
const char* filename = atom_getsymbolarg(0, argc, argv)->s_name;
if (fluid_synth_sfload(x->x_synth, filename, 0) >= 0)
const char* ext = strrchr(filename, '.');
if (ext && !strchr(ext, '/'))
// extension already supplied, no default extension
ext = "";
else
ext = ".sf2";
char realdir[MAXPDSTRING], *realname = NULL;
int fd = canvas_open(x->x_canvas, filename, ext, realdir,
&realname, MAXPDSTRING, 0);
if (fd < 0) {
pd_error(x, "fluid~: can't find soundfont %s", filename);
return;
}
// Save the current working directory.
char buf[MAXPDSTRING], *cwd = getcwd(buf, MAXPDSTRING);
sys_close(fd);
if (chdir(realdir)) {}
if (fluid_synth_sfload(x->x_synth, realname, 0) >= 0)
{
post("Loaded Soundfont: %s", filename);
post("fluid~: loaded soundfont %s", realname);
fluid_synth_program_reset(x->x_synth);
}
// Restore the working directory.
cwd && chdir(cwd);
}
}
// Where to put the temporary log file (see below). The only place we can
// safely assume to be writable is the user's configuration directory, so
// that's where it goes.
#ifdef _WIN32
#define USER_CONFIG_DIR "AppData/Roaming/Purr-Data"
#else
#define USER_CONFIG_DIR ".purr-data"
#endif
#define maxline 1024
static void fluid_init(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
{
if (x->x_synth) delete_fluid_synth(x->x_synth);
if (x->x_settings) delete_fluid_settings(x->x_settings);
float sr = sys_getsr();
// Gain value. Fluidsynth's default gain is absurdly low, so we use a
// larger but still moderate value (range is 0-10). I find 1.0 to be a
// good default, YMMV. (Original fluid~ had 0.6 here, but I found that too
// low with most soundfonts.) This value can be changed by the user with
// the -g option, see below.
float gain = 1.0;
// check the options
int vflag = 0;
while (argc > 0) {
const char* arg = atom_getsymbolarg(0, argc, argv)->s_name;
if (strcmp(arg, "-smmf") == 0) {
// SMMF mode
x->smmf_mode = 1; argc--; argv++;
} else if (strcmp(arg, "-v") == 0) {
// verbose mode (capture stderr, see below)
vflag = 1; argc--; argv++;
} else if (strcmp(arg, "-g") == 0) {
// default gain value ("synth.gain")
argc--; argv++;
if (argc > 0) {
gain = atom_getfloatarg(0, argc, argv);
// clamp the value to fluidsynths 0-10 range
if (gain < 0.0) gain = 0.0;
if (gain > 10.0) gain = 10.0;
argc--; argv++;
}
} else {
break;
}
}
// Some drivers (e.g. ALSA) are very chatty and will print a lot of log
// messages to stderr while fluidsynth is being initialized. We can
// capture stderr and redirect it to the Pd console, or just get rid of
// it, depending on the user's choice. To these ends we temporarily
// redirect stderr while running the intialization.
char logfile[FILENAME_MAX], *homedir = getenv("HOME");
snprintf(logfile, FILENAME_MAX,
"%s/" USER_CONFIG_DIR "/fluidtmp.log", homedir);
int saved_stderr = dup(STDERR_FILENO);
int fd;
if (!vflag) {
fd = open("/dev/null", O_RDWR);
} else {
fd = open(logfile, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
}
dup2(fd, STDERR_FILENO);
x->x_settings = new_fluid_settings();
if (x->x_settings == NULL)
{
post("fluid~: couldn't create synth settings\n");
pd_error(x, "fluid~: couldn't create synth settings\n");
}
else
{
// fluid_settings_setstr(settings, "audio.driver", "float");
// settings:
fluid_settings_setnum(x->x_settings, "synth.midi-channels", 16);
fluid_settings_setnum(x->x_settings, "synth.polyphony", 256);
fluid_settings_setnum(x->x_settings, "synth.gain", 0.600000);
fluid_settings_setnum(x->x_settings, "synth.sample-rate", 44100.000000);
fluid_settings_setstr(x->x_settings, "synth.chorus.active", "no");
fluid_settings_setstr(x->x_settings, "synth.reverb.active", "no");
fluid_settings_setstr(x->x_settings, "synth.ladspa.active", "no");
// ag: fluidsynth defaults are: 0.2, 16, 256, 44100.0, 1, 1, 0.
fluid_settings_setnum(x->x_settings, "synth.gain", gain);
#if 0
// Crufty old defaults which we don't use any more. Except for the
// gain, we really want to keep things as close to the defaults as
// possible, so that fluid~ sounds *exactly* like the stand-alone
// program.
fluid_settings_setint(x->x_settings, "synth.midi-channels", 16);
fluid_settings_setint(x->x_settings, "synth.polyphony", 256);
fluid_settings_setnum(x->x_settings, "synth.sample-rate", 44100.0);
fluid_settings_setint(x->x_settings, "synth.chorus.active", 0);
fluid_settings_setint(x->x_settings, "synth.reverb.active", 0);
fluid_settings_setint(x->x_settings, "synth.ladspa.active", 0);
#endif
if (sr != 0)
{
......@@ -186,63 +411,121 @@ static void fluid_init(t_fluid_tilde *x, t_symbol *s, int argc, t_atom *argv)
x->x_synth = new_fluid_synth(x->x_settings);
if (x->x_synth == NULL )
{
post("fluid~: couldn't create synth\n");
pd_error(x, "fluid~: couldn't create synth");
}
// try to load argument as soundfont
fluid_load(x, gensym("load"), argc, argv);
//if (settings != NULL )
// delete_fluid_settings(settings);
// We're done constructing:
if (x->x_synth)
post("-- fluid~ for Pd ---");
post("-- fluid~ for Pd%s --", x->smmf_mode?" (SMMF mode)":"");
}
// Restore stderr.
if (!vflag) {
dup2(saved_stderr, STDERR_FILENO);
close(fd);
} else {
lseek(fd, 0, SEEK_SET);
// read stuff, post it (it's more convenient to do this with a FILE*)
FILE *fp = fdopen(fd, "r+");
char buf[maxline];
if (fp) {
while (fgets(buf, maxline, fp)) {
int n = strlen(buf);
if (n > 0 && buf[n-1] == '\n') buf[n-1] = '\0';
if (*buf) post("%s", buf);
}
}
fclose(fp);
dup2(saved_stderr, STDERR_FILENO);
unlink(logfile);
}
}
static void *fluid_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
t_fluid_tilde *x = (t_fluid_tilde *)pd_new(fluid_tilde_class);
x->x_synth = NULL; x->x_settings = NULL;
x->x_out_left = outlet_new(&x->x_obj, &s_signal);
x->x_out_right = outlet_new(&x->x_obj, &s_signal);
x->smmf_mode = 0;
x->x_canvas = canvas_getcurrent();
fluid_init(x, gensym("init"), argc, argv);
return (void *)x;
}
static void fluid_log_cb(int level, const char *message, void *data)
{
post("fluid~ [%d]: %s", level, message);
}
void fluid_tilde_setup(void)
{
fluid_tilde_class = class_new(gensym("fluid~"),
(t_newmethod)fluid_tilde_new, 0, sizeof(t_fluid_tilde),
(t_newmethod)fluid_tilde_new, (t_method)fluid_tilde_free,
sizeof(t_fluid_tilde),
CLASS_DEFAULT, A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_init, gensym("init"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_load, gensym("load"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_note, gensym("note"),
// "legacy" methods. These are 100% backwards-compatible, and are all
// enabled by default. NOTE: When in SMMF mode (-smmf), the "note" and
// "bend" messages actually invoke the corresponding SMMF methods below,
// while all other legacy methods still work (in particular, the "note"
// and "bend" shortcuts are still available).
#if 0
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_note, gensym("note"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_program_change,
#endif
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_program_change,
gensym("prog"), A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_control_change,
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_control_change,
gensym("control"), A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_pitch_bend,
#if 0
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_pitch_bend,
gensym("bend"), A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_bank, gensym("bank"),
#endif
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_bank, gensym("bank"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_gen, gensym("gen"),
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_gen, gensym("gen"),
A_GIMME, 0);
// list input calls fluid_note(...)
class_addlist(fluid_tilde_class, (t_method)fluid_note);
// list input calls fluid_legacy_note(...)
class_addlist(fluid_tilde_class, (t_method)fluid_legacy_note);
// some alias shortcuts:
class_addmethod(fluid_tilde_class, (t_method)fluid_note, gensym("n"),
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_note, gensym("n"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_program_change,
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_program_change,
gensym("p"), A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_control_change,
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_control_change,
gensym("c"), A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_control_change,
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_control_change,
gensym("cc"), A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_pitch_bend, gensym("b"),
class_addmethod(fluid_tilde_class, (t_method)fluid_legacy_pitch_bend, gensym("b"),
A_GIMME, 0);
// SMMF methods (new interface methods for MIDI, enabled with -smmf)
// NOTE: When in the default legacy mode, fluid_note and fluid_bend
// actually invoke the corresponding legacy methods above.
class_addmethod(fluid_tilde_class, (t_method)fluid_note, gensym("note"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_ctl, gensym("ctl"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_pgm, gensym("pgm"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_polytouch, gensym("polytouch"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_touch, gensym("touch"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_bend, gensym("bend"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_sysex, gensym("sysex"),
A_GIMME, 0);
class_addmethod(fluid_tilde_class, (t_method)fluid_gain, gensym("gain"),
A_GIMME, 0);
// Simulate Flext's help message
......@@ -251,4 +534,12 @@ void fluid_tilde_setup(void)
class_addmethod(fluid_tilde_class,
(t_method)fluid_tilde_dsp, gensym("dsp"), A_CANT, 0);
// Set up logging. We don't want to have too much noise here, and we also
// want to see the important stuff in the Pd console rather than the
// terminal.
fluid_set_log_function(FLUID_PANIC, fluid_log_cb, NULL);
fluid_set_log_function(FLUID_ERR, fluid_log_cb, NULL);
fluid_set_log_function(FLUID_WARN, fluid_log_cb, NULL);
fluid_set_log_function(FLUID_DBG, NULL, NULL);
}
......@@ -6,6 +6,6 @@ class.sources = fluid~.c
ldlibs = -lfluidsynth
datafiles = fluid~-help.pd fluid.gen2sym.pd simple_onthego_synth.pd fluid.gen.txt LICENSE README
datafiles = fluid~-help.pd fluid.gen2sym.pd midi-input.pd mts-tuning.pd simple_onthego_synth.pd fluid.gen.txt LICENSE README
include Makefile.pdlibbuilder.revised
#N canvas 542 308 583 345 10;
#X obj 24 50 ctlin;
#X obj 24 71 pack f f f;
#X msg 24 92 ctl \$1 \$2 \$3;
#X obj 126 70 pack f f f;
#X obj 223 70 pack f f f;
#X obj 126 49 notein;
#X msg 126 91 note \$1 \$2 \$3;
#X obj 223 49 polytouchin;
#X msg 223 91 polytouch \$1 \$2 \$3;
#X obj 22 121 pgmin;
#X obj 22 142 pack f f;
#X msg 22 163 pgm \$1 \$2;
#X obj 126 142 pack f f;
#X obj 223 142 pack f f;
#X obj 126 121 bendin 0 1;
#X msg 126 163 bend \$1 \$2;
#X obj 223 121 touchin;
#X msg 223 163 touch \$1 \$2;
#X obj 21 193 midiin;
#X obj 21 214 sel 250 251 252;
#X msg 21 235 start;
#X msg 50 257 cont;
#X msg 79 237 stop;
#X obj 222 259 outlet;
#X obj 410 21 sysexin;
#X obj 410 51 sel 240;
#X msg 410 75 1;
#X obj 410 172 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 449 76 spigot;
#X obj 449 103 moses 128;
#X msg 500 156 0;
#X obj 449 216 list prepend;
#X obj 410 194 swap 1;
#X obj 410 216 -;
#X obj 410 241 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 300 254 spigot;
#X obj 500 128 t b b b;
#X obj 300 281 list prepend sysex;
#X obj 300 302 list trim;
#X text 320 316 sysex input - this is a bit tricky;
#X obj 536 241 t l;
#X text 20 7 This is a little helper patch which encodes MIDI messages
in a symbolic format used by some pd-pure plugins.;
#X connect 0 0 1 0;
#X connect 0 1 1 1;
#X connect 0 2 1 2;
#X connect 1 0 2 0;
#X connect 2 0 23 0;
#X connect 3 0 6 0;
#X connect 4 0 8 0;
#X connect 5 0 3 0;
#X connect 5 1 3 1;
#X connect 5 2 3 2;
#X connect 6 0 23 0;
#X connect 7 0 4 0;
#X connect 7 1 4 1;
#X connect 7 2 4 2;
#X connect 8 0 23 0;
#X connect 9 0 10 0;
#X connect 9 1 10 1;
#X connect 10 0 11 0;
#X connect 11 0 23 0;
#X connect 12 0 15 0;
#X connect 13 0 17 0;
#X connect 14 0 12 0;
#X connect 14 1 12 1;
#X connect 15 0 23 0;
#X connect 16 0 13 0;
#X connect 16 1 13 1;
#X connect 17 0 23 0;
#X connect 18 0 19 0;
#X connect 19 0 20 0;
#X connect 19 1 21 0;
#X connect 19 2 22 0;
#X connect 20 0 23 0;
#X connect 21 0 23 0;
#X connect 22 0 23 0;
#X connect 24 0 25 0;
#X connect 25 0 26 0;
#X connect 25 1 28 0;
#X connect 26 0 27 0;
#X connect 27 0 28 1;
#X connect 27 0 32 0;
#X connect 28 0 29 0;
#X connect 29 0 31 0;
#X connect 29 1 36 0;
#X connect 30 0 27 0;
#X connect 31 0 35 0;
#X connect 31 0 40 0;
#X connect 32 0 33 0;
#X connect 32 1 33 1;
#X connect 33 0 34 0;
#X connect 34 0 35 1;
#X connect 35 0 37 0;
#X connect 36 0 31 1;
#X connect 36 1 31 0;
#X connect 36 2 30 0;
#X connect 37 0 38 0;
#X connect 38 0 23 0;
#X connect 40 0 31 1;
#N canvas 513 180 490 406 12;
#X obj 90 183 midi-input;
#X obj 33 262 output~;
#X obj 33 233 fluid~ -smmf TimGM6mb;
#X text 20 327 Download Tim Brechbill's small (~6MB) GM soundfont here:
;
#X obj 19 375 pddp/pddplink https://musescore.org/en/handbook/soundfonts-and-sfz-files#list
-text More soundfonts here (musescore.org);
#X obj 19 351 pddp/pddplink http://sourceforge.net/p/mscore/code/HEAD/tree/trunk/mscore/share/sound/TimGM6mb.sf2?format=raw
-text TimGM6mb.sf2 (sf.net);
#X msg 219 184 pgm 20 1 \, pgm 20 2 \, pgm 20 3;
#X msg 33 41 sysex 127 127 8 8 3 127 127 64 64 64 64 64 64 64 64 64
64 64 64, f 33;
#X msg 33 91 sysex 127 127 8 8 3 127 127 74 50 67 85 61 78 54 71 47 64 81 57, f 33;
#X text 218 157 church organ on channels 1-3;
#X text 288 48 12-tet (default tuning);
#X text 286 91 quarter-comma meantone (has wolf fifth at Ab - Eb),
f 27;
#X connect 0 0 2 0;
#X connect 2 0 1 0;
#X connect 2 1 1 1;
#X connect 6 0 2 0;
#X connect 7 0 2 0;
#X connect 8 0 2 0;
#N canvas 480 117 389 508 10;
#X declare -lib maxlib;
#N canvas 480 116 390 511 10;
#X obj 25 197 notein;
#X obj 25 222 + 0;
#X obj 25 20 key;
......@@ -7,16 +6,20 @@
#X msg 25 64 -12;
#X msg 50 85 12;
#X obj 25 117 +;
#X obj 109 134 nbx 3 88 -60 60 0 0 empty empty empty 0 -8 0 70 -262144
-1 -1 0 256 1;
#X obj 109 134 nbx 3 88 -60 60 0 0 empty empty empty 0 -8 0 70 #fcfcfc
#000000 #000000 0 256 1;
#X obj 25 253 pack 0 0 0;
#X msg 25 275 \$3 \$1 \$2;
#X obj 25 296 fluid~ /home/l2orkist/Downloads/Soundfonts/jRhodes3.sf2
#X obj 139 295 loadbang;
#X obj 25 296 fluid~ TimGM6mb;
#X obj 25 357 output~;
#X msg 139 320 1;
#X text 24 431 Download Tim Brechbill's small (~6MB) GM soundfont here:
;
#X obj 26 377 l2ork_output~;
#X obj 105 334 loadbang;
#X obj 36 350 freeverb~;
#X obj 105 355 t 50 1;
#X obj 23 479 pddp/pddplink https://musescore.org/en/handbook/soundfonts-and-sfz-files#list
-text More soundfonts here (musescore.org);
#X obj 23 455 pddp/pddplink http://sourceforge.net/p/mscore/code/HEAD/tree/trunk/mscore/share/sound/TimGM6mb.sf2?format=raw
-text TimGM6mb.sf2 (sf.net);
#X connect 0 0 1 0;
#X connect 0 1 8 1;
#X connect 0 2 8 2;
......@@ -30,10 +33,8 @@
#X connect 7 0 6 1;
#X connect 7 0 1 1;
#X connect 8 0 9 0;
#X connect 9 0 10 0;
#X connect 9 0 11 0;
#X connect 10 0 13 0;
#X connect 10 0 11 0;
#X connect 12 0 14 0;
#X connect 13 0 11 0;
#X connect 14 0 11 6;
#X connect 14 1 11 7;
#X connect 11 0 12 0;
#X connect 11 1 12 1;
#X connect 13 0 12 2;
......@@ -523,7 +523,7 @@ ifeq ($(system), Darwin)
/Applications/Pd-extended*.app/Contents/Resources/include/pdextended \
/Applications/Pd*.app/Contents/Resources/src))
extension = pd_darwin
cpp.flags := -DUNIX -DMACOSX -I /sw/include
cpp.flags := -DUNIX -DMACOSX
c.flags :=
c.ldflags := -undefined suppress -flat_namespace -bundle
c.ldlibs := -lc
......
......@@ -27,8 +27,12 @@
#include "g_canvas.h"
#include "g_all_guis.h"
/* This really should be part of g_all_guis.h... */
EXTERN int gfxstub_haveproperties(void *key);
#include <math.h>
#ifdef WIN32
#include <io.h>
#else
......@@ -297,15 +301,15 @@ static void knob_getrect(t_gobj *z, t_glist *glist,
static void knob_save(t_gobj *z, t_binbuf *b)
{
t_knob *x = (t_knob *)z;
int bflcol[3];
t_symbol *bflcol[3];
t_symbol *srl[3];
iemgui_save(&x->x_gui, srl, bflcol);
binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"),
binbuf_addv(b, "ssiisiiffiisssiiiisssii;", gensym("#X"),gensym("obj"),
(t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
atom_getsymbol(binbuf_getvec(x->x_gui.x_obj.te_binbuf)),
x->x_gui.x_h, x->x_gui.x_h,
(float)x->x_min, (float)x->x_max,
(t_float)x->x_min, (t_float)x->x_max,
x->x_lin0_log1, iem_symargstoint(&x->x_gui),
srl[0], srl[1], srl[2],
x->x_gui.x_ldx, x->x_gui.x_ldy,
......
......@@ -71,7 +71,7 @@ ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION)
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
CPU := $(shell uname -p)
ifeq ($(CPU),arm) # iPhone/iPod Touch
ifeq ($(CPU),arm-iphone) # iPhone/iPod Touch
SOURCES += $(SOURCES_iphoneos)
EXTENSION = pd_darwin
OS = iphoneos
......@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
SOURCES += $(SOURCES_iphoneos)
endif
CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
CFLAGS += $(FAT_FLAGS) -fPIC
LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
# if the 'pd' binary exists, check the linking against it to aid with stripping
LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
LIBS += -lc
......
......@@ -104,14 +104,9 @@ case "$host" in
*-darwin* | *-macos10*)
EXTENSION=pd_darwin
LDFLAGS="$LDFLAGS -bundle -undefined dynamic_lookup"
# Check for DarwinPorts and/or Fink on Mac OS X/Darwin
if test -d /sw ; then
# Fink
PATH="/sw/bin:/sw/sbin:$PATH"
INCLUDES="$INCLUDES -I/sw/include"
LIBS="$LIBS -L/sw/lib"
elif test -d /opt/local ; then
# DarwinPorts
# Check for MacPorts on Mac OS X/Darwin
if test -d /opt/local ; then
# MacPorts
PATH="/opt/local/bin:/opt/local/sbin:$PATH"
INCLUDES="$INCLUDES -I/opt/local/include"
LIBS="$LIBS -L/opt/local/lib"
......
......@@ -74,7 +74,7 @@ ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION)
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
CPU := $(shell uname -p)
ifeq ($(CPU),arm) # iPhone/iPod Touch
ifeq ($(CPU),arm-iphone) # iPhone/iPod Touch
SOURCES += $(SOURCES_iphoneos)
EXTENSION = pd_darwin
OS = iphoneos
......@@ -104,8 +104,8 @@ ifeq ($(UNAME),Darwin)
FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
SOURCES += $(SOURCES_iphoneos)
endif
CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
CFLAGS += $(FAT_FLAGS) -fPIC
LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
# if the 'pd' binary exists, check the linking against it to aid with stripping
LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
LIBS += -lc
......
......@@ -44,13 +44,13 @@ static void draw_inlets(t_button *x, t_glist *glist, int firsttime, int nin, int
{
int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus;
if (firsttime)
sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags { %lxo%d %lxS }\n",
sys_vgui(".x%zx.c create rectangle %d %d %d %d -tags { %zxo%d %zxS }\n",
glist_getcanvas(glist),
onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2,
onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1,
x, i, x);
else
sys_vgui(".x%lx.c coords %lxo%d %d %d %d %d\n",
sys_vgui(".x%zx.c coords %zxo%d %d %d %d %d\n",
glist_getcanvas(glist), x, i,
onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2,
onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1);
......@@ -61,13 +61,13 @@ static void draw_inlets(t_button *x, t_glist *glist, int firsttime, int nin, int
{
int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus;
if (firsttime)
sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags { %lxi%d %lxS }\n",
sys_vgui(".x%zx.c create rectangle %d %d %d %d -tags { %zxi%d %zxS }\n",
glist_getcanvas(glist),
onset, text_ypix(&x->x_obj, glist),
onset + IOWIDTH, text_ypix(&x->x_obj, glist)+5,
x, i, x);
else
sys_vgui(".x%lx.c coords %lxi%d %d %d %d %d\n",
sys_vgui(".x%zx.c coords %zxi%d %d %d %d %d\n",
glist_getcanvas(glist), x, i,
onset, text_ypix(&x->x_obj, glist),
onset + IOWIDTH, text_ypix(&x->x_obj, glist)+5);
......@@ -81,13 +81,13 @@ static void draw_handle(t_button *x, t_glist *glist, int firsttime) {
int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH+2);
if (firsttime)
sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags { %lxhandle %lxS }\n",
sys_vgui(".x%zx.c create rectangle %d %d %d %d -tags { %zxhandle %zxS }\n",
glist_getcanvas(glist),
onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12,
onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4,
x, x);
else
sys_vgui(".x%lx.c coords %lxhandle %d %d %d %d\n",
sys_vgui(".x%zx.c coords %zxhandle %d %d %d %d\n",
glist_getcanvas(glist), x,
onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12,
onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4);
......@@ -107,8 +107,8 @@ static void create_widget(t_button *x, t_glist *glist)
if (text[i] == '_')
text[i] = ' ';
}
sys_vgui("destroy .x%lx.c.s%lx\n",glist_getcanvas(glist),x);
sys_vgui("button .x%lx.c.s%lx -height %d -text \"%s\" -command button_cb%lx\n",canvas,x,
sys_vgui("destroy .x%zx.c.s%zx\n",glist_getcanvas(glist),x);
sys_vgui("button .x%zx.c.s%zx -height %d -text \"%s\" -command button_cb%zx\n",canvas,x,
x->x_height,text,
x);
}
......@@ -122,17 +122,17 @@ static void button_drawme(t_button *x, t_glist *glist, int firsttime)
t_canvas *canvas=glist_getcanvas(glist);
DEBUG(post("drawme %d",firsttime);)
if (firsttime) {
DEBUG(post("glist %lx canvas %lx",x->x_glist,canvas);)
DEBUG(post("glist %zx canvas %zx",x->x_glist,canvas);)
// if (x->x_glist != canvas) {
create_widget(x,glist);
x->x_glist = canvas;
// }
sys_vgui(".x%lx.c create window %d %d -anchor nw -window .x%lx.c.s%lx -tags %lxS\n",
sys_vgui(".x%zx.c create window %d %d -anchor nw -window .x%zx.c.s%zx -tags %zxS\n",
canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),x->x_glist,x,x);
}
else {
sys_vgui(".x%lx.c coords %lxS \
sys_vgui(".x%zx.c coords %zxS \
%d %d\n",
canvas, x,
text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist));
......@@ -148,15 +148,15 @@ static void button_erase(t_button* x,t_glist* glist)
int n;
DEBUG(post("erase");)
sys_vgui("destroy .x%lx.c.s%lx\n",glist_getcanvas(glist),x);
sys_vgui("destroy .x%zx.c.s%zx\n",glist_getcanvas(glist),x);
sys_vgui(".x%lx.c delete %lxS\n",glist_getcanvas(glist), x);
sys_vgui(".x%zx.c delete %zxS\n",glist_getcanvas(glist), x);
/* inlets and outlets */
sys_vgui(".x%lx.c delete %lxi%d\n",glist_getcanvas(glist),x,0);
sys_vgui(".x%lx.c delete %lxo%d\n",glist_getcanvas(glist),x,0);
sys_vgui(".x%lx.c delete %lxhandle\n",glist_getcanvas(glist),x,0);
sys_vgui(".x%zx.c delete %zxi%d\n",glist_getcanvas(glist),x,0);
sys_vgui(".x%zx.c delete %zxo%d\n",glist_getcanvas(glist),x,0);
sys_vgui(".x%zx.c delete %zxhandle\n",glist_getcanvas(glist),x,0);
}
......@@ -187,7 +187,7 @@ static void button_displace(t_gobj *z, t_glist *glist,
x->x_obj.te_ypix += dy;
if (glist_isvisible(glist))
{
sys_vgui(".x%lx.c coords %lxSEL %d %d %d %d\n",
sys_vgui(".x%zx.c coords %zxSEL %d %d %d %d\n",
glist_getcanvas(glist), x,
text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1,
text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height-2);
......@@ -202,18 +202,18 @@ static void button_select(t_gobj *z, t_glist *glist, int state)
{
t_button *x = (t_button *)z;
if (state) {
sys_vgui(".x%lx.c create rectangle \
%d %d %d %d -tags { %lxSEL %lxS } -outline $select_color\n",
sys_vgui(".x%zx.c create rectangle \
%d %d %d %d -tags { %zxSEL %zxS } -outline $select_color\n",
glist_getcanvas(glist),
text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1,
text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height-2,
x, x);
sys_vgui(".x%x.c addtag selected withtag %lxS\n", glist_getcanvas(glist), x);
sys_vgui(".x%x.c addtag selected withtag %zxS\n", glist_getcanvas(glist), x);
}
else {
sys_vgui(".x%lx.c delete %lxSEL\n",
sys_vgui(".x%zx.c delete %zxSEL\n",
glist_getcanvas(glist), x);
sys_vgui(".x%lx.c dtag %lxS selected\n", glist_getcanvas(glist), x);
sys_vgui(".x%zx.c dtag %zxS selected\n", glist_getcanvas(glist), x);
}
......@@ -268,7 +268,7 @@ void button_color(t_button* x,t_symbol* col)
static void button_bang(t_button* x)
{
sys_vgui(".x%lx.c.s%lx flash\n",x->x_glist,x);
sys_vgui(".x%zx.c.s%zx flash\n",x->x_glist,x);
outlet_bang(x->x_obj.ob_outlet);
}
......@@ -313,13 +313,13 @@ static void *button_new(t_symbol* text)
/* TODO .. ask the button for its width */
x->x_width += strlen(x->x_text->s_name)*5.2;
sprintf(buf,"button%lx", (long unsigned int)x);
sprintf(buf,"button%zx", (t_uint)x);
x->x_sym = gensym(buf);
pd_bind(&x->x_obj.ob_pd, x->x_sym);
/* pipe startup code to tk */
sys_vgui("proc button_cb%lx {} {pd [concat %s b \\;]}\n", x, buf);
sys_vgui("proc button_cb%zx {} {pd [concat %s b \\;]}\n", x, buf);
outlet_new(&x->x_obj, &s_float);
return (x);
......
......@@ -259,7 +259,7 @@ static void *envgen_new(t_symbol *s,int argc,t_atom* argv)
x->args = STATES;
x->finalvalues = getbytes( x->args*sizeof(t_float));
x->duration = getbytes( x->args*sizeof(t_float));
DEBUG(post("finalvalues %lx",x->finalvalues););
DEBUG(post("finalvalues %zx",x->finalvalues););
/* widget */
......
......@@ -23,11 +23,13 @@ typedef struct _image
int x_img_height;
int x_gop_spill;
int x_click;
//t_float x_clicked;
t_symbol* x_fname;
t_symbol* x_receive;
//int x_selected;
//t_symbol* send;
#if 0 // TODO?
t_float x_clicked;
int x_selected;
t_symbol* send;
#endif
} t_image;
/* widget helper functions */
......@@ -56,11 +58,24 @@ t_symbol *image_trytoopen(t_image* x)
}
}
// defined in s_main.c and used to offset object at creation time
// in case it is being autopatched
extern int glob_autopatch_connectme;
static void image_drawme(t_image *x, t_glist *glist, int firstime)
{
if (firstime)
{
t_symbol *fname = image_trytoopen(x);
// check if we are autopatching and offset for the default
// image only. Since we need to wait for the callback from
// the GUI to determine the custom image size, we can only
// compensate for the default image
if (glob_autopatch_connectme)
{
x->x_obj.te_xpix += 12;
x->x_obj.te_ypix += 12;
}
// make a new gobj, border, etc.
gui_vmess("gui_gobj_new", "xxsiii",
glist_getcanvas(glist),
......@@ -84,33 +99,29 @@ static void image_drawme(t_image *x, t_glist *glist, int firstime)
x,
x,
"center");
//sys_vgui("catch {.x%lx.c delete %xS}\n", glist_getcanvas(glist), x);
//sys_vgui(".x%x.c create image %d %d -tags %xS\n",
// glist_getcanvas(glist),text_xpix(&x->x_obj, glist),
// text_ypix(&x->x_obj, glist), x);
gui_vmess("gui_image_size_callback", "xxs",
glist_getcanvas(glist), x, x->x_receive->s_name);
}
else
{
// move the gobj
//sys_vgui(".x%x.c coords %xS %d %d\n",
// glist_getcanvas(glist), x,
// text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist));
gui_vmess("gui_image_coords", "xxii",
glist_getcanvas(glist),
x,
text_xpix(&x->x_obj, glist),
text_ypix(&x->x_obj, glist));
if (glist_isselected(x->x_glist, (t_gobj *)x) && glist_getcanvas(x->x_glist) == x->x_glist)
{
image_select((t_gobj *)x, glist_getcanvas(x->x_glist), 0);
image_select((t_gobj *)x, glist_getcanvas(x->x_glist), 1);
}
canvas_fixlinesfor(x->x_glist, (t_text*)x);
}
}
static void image_erase(t_image* x,t_glist* glist)
{
gui_vmess("gui_gobj_erase", "xx", glist_getcanvas(glist), x);
//sys_vgui("catch {.x%x.c delete %xS}\n",glist_getcanvas(glist), x);
//sys_vgui("catch {image delete $img%x}\n", x);
//sys_vgui("catch {.x%x.c delete %xSEL}\n",glist_getcanvas(glist), x);
}
static t_symbol *get_filename(t_int argc, t_atom *argv)
......@@ -169,14 +180,15 @@ static void image_getrect(t_gobj *z, t_glist *glist,
if ((glist_getcanvas(glist) != glist && !x->x_click) || (!glist->gl_edit && !x->x_click))
{
*xp2 = *xp1;
// only if we have an image loaded and we are placed within a GOP obliterate the height
//if (glist_getcanvas(glist) != glist && (x->x_img_width + x->x_img_height) >= 2)
//{
//printf("blah\n");
//*yp2 = *yp1;
//}
// only if we have an image loaded and we are placed within a GOP
// obliterate the height
#if 0
if (glist_getcanvas(glist) != glist && (x->x_img_width + x->x_img_height) >= 2)
{
*yp2 = *yp1;
}
#endif
}
//fprintf(stderr,"image_getrect %d %d %d %d\n", *xp1, *yp1, *xp2, *yp2);
}
static void image_displace(t_gobj *z, t_glist *glist,
......@@ -186,31 +198,6 @@ static void image_displace(t_gobj *z, t_glist *glist,
t_image *x = (t_image *)z;
x->x_obj.te_xpix += dx;
x->x_obj.te_ypix += dy;
if (!x->x_gop_spill && (x->x_img_width + x->x_img_height) >= 2)
{
sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n",
glist_getcanvas(glist), x,
text_xpix(&x->x_obj, glist) - x->x_img_width/2,
text_ypix(&x->x_obj, glist) - x->x_img_height/2,
text_xpix(&x->x_obj, glist) + x->x_img_width/2,
text_ypix(&x->x_obj, glist) + x->x_img_height/2);
}
else
{
sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n",
glist_getcanvas(glist), x,
text_xpix(&x->x_obj, glist) - x->x_width/2,
text_ypix(&x->x_obj, glist) - x->x_height/2,
text_xpix(&x->x_obj, glist) + x->x_width/2,
text_ypix(&x->x_obj, glist) + x->x_height/2);
/*if (x->x_img_width + x->x_img_height == 0)
sys_vgui(".x%x.c coords %xMT %d %d %d %d\n",
glist_getcanvas(glist), x,
text_xpix(&x->x_obj, glist) - x->x_width/2,
text_ypix(&x->x_obj, glist) - x->x_height/2,
text_xpix(&x->x_obj, glist) + x->x_width/2,
text_ypix(&x->x_obj, glist) + x->x_height/2);*/
}
image_drawme(x, glist, 0);
canvas_fixlinesfor(glist,(t_text*) x);
}
......@@ -222,12 +209,6 @@ static void image_displace_wtag(t_gobj *z, t_glist *glist,
t_image *x = (t_image *)z;
x->x_obj.te_xpix += dx;
x->x_obj.te_ypix += dy;
/*sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n",
glist_getcanvas(glist), x,
text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height);
image_drawme(x, glist, 0);*/
canvas_fixlinesfor(glist,(t_text*) x);
}
......@@ -240,42 +221,13 @@ static void image_select(t_gobj *z, t_glist *glist, int state)
if (x->x_glist == glist_getcanvas(glist))
{
//x->x_selected = state;
if (!x->x_gop_spill && (x->x_img_width + x->x_img_height) >= 2)
{
sys_vgui(".x%x.c create prect %d %d %d %d \
-tags %xSEL -strokewidth 1 -stroke $pd_colors(selection)\n",
glist_getcanvas(glist),
text_xpix(&x->x_obj, glist) - x->x_img_width/2,
text_ypix(&x->x_obj, glist) - x->x_img_height/2,
text_xpix(&x->x_obj, glist) + x->x_img_width/2,
text_ypix(&x->x_obj, glist) + x->x_img_height/2, x);
}
else
{
sys_vgui(".x%x.c create prect %d %d %d %d \
-tags %xSEL -strokewidth 1 -stroke $pd_colors(selection)\n",
glist_getcanvas(glist),
text_xpix(&x->x_obj, glist) - x->x_width/2,
text_ypix(&x->x_obj, glist) - x->x_height/2,
text_xpix(&x->x_obj, glist) + x->x_width/2,
text_ypix(&x->x_obj, glist) + x->x_height/2, x);
}
gui_vmess("gui_image_toggle_border", "xxi", glist_getcanvas(glist),
x, 1);
}
gui_vmess("gui_gobj_select", "xx", glist_getcanvas(glist), x);
//if (glist->gl_owner && !glist_istoplevel(glist))
//sys_vgui(".x%x.c addtag selected withtag %xS\n", glist_getcanvas(glist), x);
//sys_vgui(".x%x.c addtag selected withtag %xMT\n", glist_getcanvas(glist), x);
//sys_vgui(".x%x.c addtag selected withtag %xSEL\n", glist_getcanvas(glist), x);
}
else
{
//sys_vgui("catch {.x%x.c delete %xSEL}\n",
//glist_getcanvas(glist), x);
//if (glist->gl_owner && !glist_istoplevel(glist))
//sys_vgui(".x%lx.c dtag %xS selected\n", glist_getcanvas(glist), x);
//sys_vgui(".x%lx.c dtag %xMT selected\n", glist_getcanvas(glist), x);
gui_vmess("gui_image_toggle_border", "xxi", glist_getcanvas(glist),
x, 0);
gui_vmess("gui_gobj_deselect", "xx", glist_getcanvas(glist), x);
......@@ -284,12 +236,14 @@ static void image_select(t_gobj *z, t_glist *glist, int state)
static void image_activate(t_gobj *z, t_glist *glist, int state)
{
/*fprintf(stderr,"activate...\n");
#if 0 // TODO?
fprintf(stderr,"activate...\n");
t_text *x = (t_text *)z;
t_rtext *y = glist_findrtext(glist, x);
rtext_activate(y, state);
t_image *i = (t_image *)z;
canvas_redraw(i->x_glist);*/
canvas_redraw(i->x_glist);
#endif
}
static void image_delete(t_gobj *z, t_glist *glist)
......@@ -313,27 +267,37 @@ static void image_vis(t_gobj *z, t_glist *glist, int vis)
static void image_save(t_gobj *z, t_binbuf *b)
{
t_image *x = (t_image *)z;
binbuf_addv(b, "ssiissi", gensym("#X"), gensym("obj"),
x->x_obj.te_xpix, x->x_obj.te_ypix,
atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)),
x->x_fname, x->x_gop_spill);
// ag: unless we need it, avoid adding the gop-spill argument which isn't
// compatible with vanilla ggee
if (x->x_gop_spill)
binbuf_addv(b, "ssiissi", gensym("#X"), gensym("obj"),
x->x_obj.te_xpix, x->x_obj.te_ypix,
atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)),
x->x_fname, x->x_gop_spill);
else
binbuf_addv(b, "ssiiss", gensym("#X"), gensym("obj"),
x->x_obj.te_xpix, x->x_obj.te_ypix,
atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)),
x->x_fname);
binbuf_addv(b, ";");
}
static t_widgetbehavior image_widgetbehavior;
/*void image_size(t_image* x,t_floatarg w,t_floatarg h) {
#if 0 // TODO?
static void image_size(t_image* x,t_floatarg w,t_floatarg h) {
x->x_width = w;
x->x_height = h;
image_displace((t_gobj*)x, x->x_glist, 0.0, 0.0);
}*/
}
/*void image_color(t_image* x,t_symbol* col)
static void image_color(t_image* x,t_symbol* col)
{
//outlet_bang(x->x_obj.ob_outlet); only bang if there was a bang ..
//so color black does the same as bang, but doesn't forward the bang
}*/
}
#endif
static int image_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
{
......@@ -343,15 +307,6 @@ static int image_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, i
outlet_bang(x->x_obj.ob_outlet);
// LATER: figure out how to do click on and click off
// and provide a toggle button behavior instead
/*{
x->x_clicked = 1;
outlet_float(x->x_obj.ob_outlet, x->x_clicked);
}
else if (x->x_clicked)
{
x->x_clicked = 0;
outlet_float(x->x_obj.ob_outlet, x->x_clicked);
}*/
return(1);
}
......@@ -432,9 +387,11 @@ static void image_imagesize_callback(t_image *x, t_float w, t_float h) {
}
else
{
//sys_vgui("catch {.x%x.c delete %xMT}\n", glist_getcanvas(x->x_glist), x);
// reselect if we are on a toplevel canvas to adjust the selection rectangle, if necessary
#if 0
/* ico@vt.edu: this does not work for the spill mode, so we will have to
draw the select box on demand */
gui_vmess("gui_image_draw_border", "xxiiii",
glist_getcanvas(x->x_glist),
x,
......@@ -442,6 +399,7 @@ static void image_imagesize_callback(t_image *x, t_float w, t_float h) {
0 - x->x_img_height/2,
x->x_img_width,
x->x_img_height);
#endif
if (glist_isselected(x->x_glist, (t_gobj *)x) && glist_getcanvas(x->x_glist) == x->x_glist)
{
......@@ -466,14 +424,11 @@ static void image_setwidget(void)
static void image_free(t_image *x)
{
//sys_vgui("image delete img%x\n", x);
gui_vmess("gui_image_free", "x", x);
if (x->x_receive)
{
pd_unbind(&x->x_obj.ob_pd,x->x_receive);
}
//sys_vgui(".x%x.c delete %xSEL\n", x);
//sys_vgui(".x%x.c delete %xS\n", x);
}
static void *image_new(t_symbol *s, t_int argc, t_atom *argv)
......@@ -505,7 +460,7 @@ static void *image_new(t_symbol *s, t_int argc, t_atom *argv)
}
// Create default receiver
char buf[MAXPDSTRING];
sprintf(buf, "#%lx", (long)x);
sprintf(buf, "#%zx", (t_uint)x);
x->x_receive = gensym(buf);
pd_bind(&x->x_obj.ob_pd, x->x_receive);
outlet_new(&x->x_obj, &s_bang);
......@@ -518,12 +473,12 @@ void image_setup(void)
image_class = class_new(gensym("image"),
(t_newmethod)image_new, (t_method)image_free,
sizeof(t_image),0, A_GIMME,0);
/*
#if 0 // TODO?
class_addmethod(image_class, (t_method)image_size, gensym("size"),
A_FLOAT, A_FLOAT, 0);
class_addmethod(image_class, (t_method)image_color, gensym("color"),
A_SYMBOL, 0);
*/
#endif
class_addmethod(image_class, (t_method)image_click, gensym("click"),
A_DEFFLOAT, 0);
class_addmethod(image_class, (t_method)image_open, gensym("open"),
......
......@@ -529,9 +529,10 @@ void envgen_key(t_envgen *x, t_floatarg f)
}
}
static int envgen_newclick(t_envgen *x, struct _glist *glist,
static int envgen_newclick(t_gobj *z, struct _glist *glist,
int xpos, int ypos, int shift, int alt, int dbl, int doit)
{
t_envgen *x = (t_envgen *)z;
/* check if user wants to resize */
float wxpos = text_xpix(&x->x_obj, glist);
float wypos = (int) (text_ypix(&x->x_obj,glist) + x->w.height);
......
......@@ -49,7 +49,7 @@
extern int close(int);
#endif
extern void sys_rmpollfn(int fd);
extern sys_addpollfn(int fd, void* fn, void *ptr);
extern int sys_addpollfn(int fd, void* fn, void *ptr);
static void sys_sockerror(char *s)
{
......
File mode changed from 100755 to 100644