summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
commit526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch)
tree22b1af92348785daad16714ee5e2b633017e0e48 /apps
parent4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff)
downloadrockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.tar.gz
rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.zip
Cut the files in half and it might work better (note to self: check your tree is really clean before patching)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21070 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/pdbox/PDa/CHANGELOG.PDa59
-rw-r--r--apps/plugins/pdbox/PDa/LICENSE.txt29
-rw-r--r--apps/plugins/pdbox/PDa/README.PDa54
-rw-r--r--apps/plugins/pdbox/PDa/README.txt43
-rw-r--r--apps/plugins/pdbox/PDa/extra/OSC-client.h187
-rw-r--r--apps/plugins/pdbox/PDa/extra/OSC.pd14
-rw-r--r--apps/plugins/pdbox/PDa/extra/OSCroute.c604
-rw-r--r--apps/plugins/pdbox/PDa/extra/README11
-rw-r--r--apps/plugins/pdbox/PDa/extra/bandpass-help.pd18
-rw-r--r--apps/plugins/pdbox/PDa/extra/bandpass.c87
-rw-r--r--apps/plugins/pdbox/PDa/extra/dumpOSC.c1000
-rw-r--r--apps/plugins/pdbox/PDa/extra/equalizer.c94
-rw-r--r--apps/plugins/pdbox/PDa/extra/fatom.h484
-rw-r--r--apps/plugins/pdbox/PDa/extra/filters.h75
-rw-r--r--apps/plugins/pdbox/PDa/extra/g_canvas.h601
-rw-r--r--apps/plugins/pdbox/PDa/extra/gcanvas-help.pd9
-rw-r--r--apps/plugins/pdbox/PDa/extra/gcanvas.c381
-rw-r--r--apps/plugins/pdbox/PDa/extra/highpass.c91
-rw-r--r--apps/plugins/pdbox/PDa/extra/highshelf.c92
-rw-r--r--apps/plugins/pdbox/PDa/extra/hlshelf.c228
-rw-r--r--apps/plugins/pdbox/PDa/extra/image.c217
-rw-r--r--apps/plugins/pdbox/PDa/extra/lowpass.c93
-rw-r--r--apps/plugins/pdbox/PDa/extra/lowshelf.c93
-rw-r--r--apps/plugins/pdbox/PDa/extra/m_pd.h649
-rw-r--r--apps/plugins/pdbox/PDa/extra/makefile32
-rw-r--r--apps/plugins/pdbox/PDa/extra/moog~.c184
-rw-r--r--apps/plugins/pdbox/PDa/extra/notch.c95
-rw-r--r--apps/plugins/pdbox/PDa/extra/s_stuff.h214
-rw-r--r--apps/plugins/pdbox/PDa/extra/sendOSC.c1463
-rw-r--r--apps/plugins/pdbox/PDa/extra/sformat.h54
-rw-r--r--apps/plugins/pdbox/PDa/extra/shell.c314
-rw-r--r--apps/plugins/pdbox/PDa/extra/slider.c52
-rw-r--r--apps/plugins/pdbox/PDa/extra/sliderh.c62
-rw-r--r--apps/plugins/pdbox/PDa/extra/test-clip.pd14
-rw-r--r--apps/plugins/pdbox/PDa/extra/test-vcf.pd19
-rw-r--r--apps/plugins/pdbox/PDa/extra/zerox~.c56
-rw-r--r--apps/plugins/pdbox/PDa/intern/biquad~.c125
-rw-r--r--apps/plugins/pdbox/PDa/intern/bp~.c138
-rw-r--r--apps/plugins/pdbox/PDa/intern/clip~.c57
-rw-r--r--apps/plugins/pdbox/PDa/intern/cos_table.h3
-rw-r--r--apps/plugins/pdbox/PDa/intern/cos~.c60
-rw-r--r--apps/plugins/pdbox/PDa/intern/dbtopow~.c51
-rw-r--r--apps/plugins/pdbox/PDa/intern/dbtorms~.c52
-rw-r--r--apps/plugins/pdbox/PDa/intern/delay.h41
-rw-r--r--apps/plugins/pdbox/PDa/intern/delread~.c99
-rw-r--r--apps/plugins/pdbox/PDa/intern/delwrite~.c83
-rw-r--r--apps/plugins/pdbox/PDa/intern/env~.c128
-rw-r--r--apps/plugins/pdbox/PDa/intern/ftom~.c43
-rw-r--r--apps/plugins/pdbox/PDa/intern/hip~.c91
-rw-r--r--apps/plugins/pdbox/PDa/intern/intern_setup.c46
-rw-r--r--apps/plugins/pdbox/PDa/intern/line~.c102
-rw-r--r--apps/plugins/pdbox/PDa/intern/lop~.c89
-rw-r--r--apps/plugins/pdbox/PDa/intern/makefile23
-rw-r--r--apps/plugins/pdbox/PDa/intern/mtof~.c48
-rw-r--r--apps/plugins/pdbox/PDa/intern/noise~.c56
-rw-r--r--apps/plugins/pdbox/PDa/intern/osc~.c88
-rw-r--r--apps/plugins/pdbox/PDa/intern/phasor~.c69
-rw-r--r--apps/plugins/pdbox/PDa/intern/powtodb~.c53
-rw-r--r--apps/plugins/pdbox/PDa/intern/print~.c77
-rw-r--r--apps/plugins/pdbox/PDa/intern/rmstodb~.c51
-rw-r--r--apps/plugins/pdbox/PDa/intern/rsqrt~.c105
-rw-r--r--apps/plugins/pdbox/PDa/intern/samphold~.c74
-rw-r--r--apps/plugins/pdbox/PDa/intern/sformat.h54
-rw-r--r--apps/plugins/pdbox/PDa/intern/sfread~.c288
-rw-r--r--apps/plugins/pdbox/PDa/intern/sfwrite~.c239
-rw-r--r--apps/plugins/pdbox/PDa/intern/sig~.c66
-rw-r--r--apps/plugins/pdbox/PDa/intern/snapshot~.c56
-rw-r--r--apps/plugins/pdbox/PDa/intern/sqrt~.c77
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabosc4~.c131
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabplay~.c131
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabread.c51
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabread4~.c104
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabread~.c96
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabreceive~.c61
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabsend~.c97
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabwrite.c83
-rw-r--r--apps/plugins/pdbox/PDa/intern/tabwrite~.c131
-rw-r--r--apps/plugins/pdbox/PDa/intern/threshold~.c134
-rw-r--r--apps/plugins/pdbox/PDa/intern/vcf~.c119
-rw-r--r--apps/plugins/pdbox/PDa/intern/vd~.c91
-rw-r--r--apps/plugins/pdbox/PDa/intern/vline~.c183
-rw-r--r--apps/plugins/pdbox/PDa/intern/vsnapshot~.c88
-rw-r--r--apps/plugins/pdbox/PDa/intern/wrap~.c51
-rw-r--r--apps/plugins/pdbox/PDa/src/build.ipod4
-rw-r--r--apps/plugins/pdbox/PDa/src/d_arithmetic.c842
-rw-r--r--apps/plugins/pdbox/PDa/src/d_array.c1074
-rw-r--r--apps/plugins/pdbox/PDa/src/d_ctl.c783
-rw-r--r--apps/plugins/pdbox/PDa/src/d_dac.c184
-rw-r--r--apps/plugins/pdbox/PDa/src/d_delay.c319
-rw-r--r--apps/plugins/pdbox/PDa/src/d_fft.c343
-rw-r--r--apps/plugins/pdbox/PDa/src/d_fftroutine.c1000
-rw-r--r--apps/plugins/pdbox/PDa/src/d_filter.c546
-rw-r--r--apps/plugins/pdbox/PDa/src/d_global.c308
-rw-r--r--apps/plugins/pdbox/PDa/src/d_imayer_fft.c515
-rw-r--r--apps/plugins/pdbox/PDa/src/d_imayer_tables.h49
-rw-r--r--apps/plugins/pdbox/PDa/src/d_math.c573
-rw-r--r--apps/plugins/pdbox/PDa/src/d_mayer_fft.c418
-rw-r--r--apps/plugins/pdbox/PDa/src/d_misc.c265
-rw-r--r--apps/plugins/pdbox/PDa/src/d_osc.c535
-rw-r--r--apps/plugins/pdbox/PDa/src/d_resample.c224
-rw-r--r--apps/plugins/pdbox/PDa/src/d_soundfile.c2367
-rw-r--r--apps/plugins/pdbox/PDa/src/d_ugen.c1126
-rw-r--r--apps/plugins/pdbox/PDa/src/delme.pd9
-rw-r--r--apps/plugins/pdbox/PDa/src/g_all_guis.c661
-rw-r--r--apps/plugins/pdbox/PDa/src/g_all_guis.h328
-rw-r--r--apps/plugins/pdbox/PDa/src/g_array.c1368
-rw-r--r--apps/plugins/pdbox/PDa/src/g_bang.c553
-rw-r--r--apps/plugins/pdbox/PDa/src/g_canvas.c1475
-rw-r--r--apps/plugins/pdbox/PDa/src/g_canvas.h601
-rw-r--r--apps/plugins/pdbox/PDa/src/g_editor.c2273
-rw-r--r--apps/plugins/pdbox/PDa/src/g_graph.c1111
-rw-r--r--apps/plugins/pdbox/PDa/src/g_guiconnect.c93
-rw-r--r--apps/plugins/pdbox/PDa/src/g_hdial.c734
-rw-r--r--apps/plugins/pdbox/PDa/src/g_hslider.c653
-rw-r--r--apps/plugins/pdbox/PDa/src/g_io.c611
-rw-r--r--apps/plugins/pdbox/PDa/src/g_mycanvas.c384
-rw-r--r--apps/plugins/pdbox/PDa/src/g_numbox.c906
-rw-r--r--apps/plugins/pdbox/PDa/src/g_readwrite.c722
-rw-r--r--apps/plugins/pdbox/PDa/src/g_rtext.c485
-rw-r--r--apps/plugins/pdbox/PDa/src/g_scalar.c400
-rw-r--r--apps/plugins/pdbox/PDa/src/g_template.c1678
-rw-r--r--apps/plugins/pdbox/PDa/src/g_text.c1317
-rw-r--r--apps/plugins/pdbox/PDa/src/g_toggle.c473
-rw-r--r--apps/plugins/pdbox/PDa/src/g_traversal.c1083
-rw-r--r--apps/plugins/pdbox/PDa/src/g_vdial.c715
-rw-r--r--apps/plugins/pdbox/PDa/src/g_vslider.c626
-rw-r--r--apps/plugins/pdbox/PDa/src/g_vumeter.c712
-rw-r--r--apps/plugins/pdbox/PDa/src/m_atom.c128
-rw-r--r--apps/plugins/pdbox/PDa/src/m_binbuf.c1218
-rw-r--r--apps/plugins/pdbox/PDa/src/m_class.c823
-rw-r--r--apps/plugins/pdbox/PDa/src/m_conf.c101
-rw-r--r--apps/plugins/pdbox/PDa/src/m_fixed.c127
-rw-r--r--apps/plugins/pdbox/PDa/src/m_fixed.h56
-rw-r--r--apps/plugins/pdbox/PDa/src/m_glob.c104
-rw-r--r--apps/plugins/pdbox/PDa/src/m_imp.h77
-rw-r--r--apps/plugins/pdbox/PDa/src/m_memory.c88
-rw-r--r--apps/plugins/pdbox/PDa/src/m_obj.c697
-rw-r--r--apps/plugins/pdbox/PDa/src/m_pd.c306
-rw-r--r--apps/plugins/pdbox/PDa/src/m_pd.h649
-rw-r--r--apps/plugins/pdbox/PDa/src/m_sched.c580
-rw-r--r--apps/plugins/pdbox/PDa/src/makecostab.c26
-rw-r--r--apps/plugins/pdbox/PDa/src/makefile178
-rw-r--r--apps/plugins/pdbox/PDa/src/s_audio.c872
-rw-r--r--apps/plugins/pdbox/PDa/src/s_audio_alsa.c944
-rw-r--r--apps/plugins/pdbox/PDa/src/s_audio_mmio.c793
-rw-r--r--apps/plugins/pdbox/PDa/src/s_audio_oss.c843
-rw-r--r--apps/plugins/pdbox/PDa/src/s_audio_pa.c291
-rw-r--r--apps/plugins/pdbox/PDa/src/s_entry.c50
-rw-r--r--apps/plugins/pdbox/PDa/src/s_file.c55
-rw-r--r--apps/plugins/pdbox/PDa/src/s_inter.c1000
-rw-r--r--apps/plugins/pdbox/PDa/src/s_loader.c175
-rw-r--r--apps/plugins/pdbox/PDa/src/s_main.c837
-rw-r--r--apps/plugins/pdbox/PDa/src/s_midi.c640
-rw-r--r--apps/plugins/pdbox/PDa/src/s_midi_oss.c358
-rw-r--r--apps/plugins/pdbox/PDa/src/s_midi_pm.c165
-rw-r--r--apps/plugins/pdbox/PDa/src/s_midi_sgi.c187
-rw-r--r--apps/plugins/pdbox/PDa/src/s_path.c411
-rw-r--r--apps/plugins/pdbox/PDa/src/s_print.c149
-rw-r--r--apps/plugins/pdbox/PDa/src/s_stuff.h214
-rw-r--r--apps/plugins/pdbox/PDa/src/s_watchdog.c46
-rw-r--r--apps/plugins/pdbox/PDa/src/t_main.c119
-rw-r--r--apps/plugins/pdbox/PDa/src/t_tk.h9
-rw-r--r--apps/plugins/pdbox/PDa/src/t_tkcmd.c398
-rw-r--r--apps/plugins/pdbox/PDa/src/u_main.tk3366
-rw-r--r--apps/plugins/pdbox/PDa/src/u_pdreceive.c324
-rw-r--r--apps/plugins/pdbox/PDa/src/u_pdsend.c156
-rw-r--r--apps/plugins/pdbox/PDa/src/x_acoustics.c193
-rw-r--r--apps/plugins/pdbox/PDa/src/x_arithmetic.c897
-rw-r--r--apps/plugins/pdbox/PDa/src/x_connective.c1451
-rw-r--r--apps/plugins/pdbox/PDa/src/x_gui.c376
-rw-r--r--apps/plugins/pdbox/PDa/src/x_interface.c77
-rw-r--r--apps/plugins/pdbox/PDa/src/x_midi.c1312
-rw-r--r--apps/plugins/pdbox/PDa/src/x_misc.c320
-rw-r--r--apps/plugins/pdbox/PDa/src/x_net.c362
-rw-r--r--apps/plugins/pdbox/PDa/src/x_qlist.c345
-rw-r--r--apps/plugins/pdbox/PDa/src/x_time.c519
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/CHANGES12
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/FILES15
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/Makefile38
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/Malloc.c202
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/README23
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/bmalloc.c371
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/bmalloc.h7
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/bysize.c424
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/bysize.h4
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/dmalloc.c690
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/dmalloc.h9
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/dmytest.c138
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/malloc.man95
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/mytest.c71
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/thoughts170
-rw-r--r--apps/plugins/pdbox/pdbox.h71
192 files changed, 20 insertions, 69133 deletions
diff --git a/apps/plugins/pdbox/PDa/CHANGELOG.PDa b/apps/plugins/pdbox/PDa/CHANGELOG.PDa
index f8afc2bd89..9eee2c4e5a 100644
--- a/apps/plugins/pdbox/PDa/CHANGELOG.PDa
+++ b/apps/plugins/pdbox/PDa/CHANGELOG.PDa
@@ -56,63 +56,4 @@
double t_time
s_inter: check !!!
s_main: check !!!
-
-0.6:
- - added compilation for blackfin architecture (blackfin.uclinux.org)
- - added third outlet for mouseup to gcanvas.
- - debian package support (for maemo)
- - don't ask quit question
-
-0.5:
- - fixed a crasher bug in sfread~.c
-
-0.4:
- - added ipod gui communication in m_pd.c (pd_bind) and m_fixed.c
- - moved the pd internal objects in a folder called interns
- - restructuring of the makefile, you can build a static binary
- now with "make static", needed for the iPod part mainly.
- - the oscillator tables are precalculated now (faster startup).
- see src/makecostable.c for that
- - the scheduler is simplified (added an additional scheduler called
- m_scheduler_pda(), this is a lot faster now
- - changed the "look" of PDa
- - The menubar in the patcher window is now optional, its off by default.
- - stdin interface added. It is now possible to communicate with pd via the
- keyboard even in -nogui mode
- - fixed loading and saving of arrays (g_array.c)
- - corrected rounding when calculation phase update osc~ and phasor~
- (there are better methods to do this, but they are slower)
- - fixed tabosc4~
- - enabled array drawing
- - fixed array saving in subpatch
-
-0.3test2:
- - added the O_CREAT flag to sfwrite
- - removed the OSC stuff (now in PDa-externals)
-
-0.3test1:
- - moved all objects into the extra dir
-
-
- d_arithmetic: t_float -> t_sample .. exchanged * with mult / with divide
- d_fft: t_float -> t_sample
- d_global: t_float -> t_sample
- d_misc: put print~ into extra folder
- d_resample: t_float -> t_sample
- g_array: disable editing
- fixtof()
- t_float -> t_sample (check out the savefn thingy)
-
- g_graph: 1 t_float -> t_sample
- g_io: t_float -> t_sample
- m_conf: remove calls to setup routines
- m_obj.c ftofix
- m_pd.h definition of t_sample
- double -> t_time
- ... and more
- m_sched.c
- double t_time
- s_inter: check !!!
- s_main: check !!!
-
diff --git a/apps/plugins/pdbox/PDa/LICENSE.txt b/apps/plugins/pdbox/PDa/LICENSE.txt
index 3e104c77a2..cfefb942d7 100644
--- a/apps/plugins/pdbox/PDa/LICENSE.txt
+++ b/apps/plugins/pdbox/PDa/LICENSE.txt
@@ -28,33 +28,4 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
-This software is copyrighted by Miller Puckette and others. The following
-terms (the "Standard Improved BSD License") apply to all files associated with
-the software unless explicitly disclaimed in individual files:
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-3. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior
- written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/apps/plugins/pdbox/PDa/README.PDa b/apps/plugins/pdbox/PDa/README.PDa
index 7c567d70c2..566daea9d8 100644
--- a/apps/plugins/pdbox/PDa/README.PDa
+++ b/apps/plugins/pdbox/PDa/README.PDa
@@ -50,57 +50,3 @@ Pd from the podzilla console or with this GUI for PDa on iPod:
http://ipodlinux.org/Pdpod
-
-PDa - Pure Data for Personal Digital Assistants
-===============================================
-
-Based on pd-0.37-4.
-
-This version of Pure Data is based on the original sources by
-Miller Puckette, but several part have been changed in order
-to run on embedded systems. Most of the changed objects are in
-the folder "intern".
-
-This means, that all the signal processing is done with fixed-point
-math. The control processing is still in floating point, therefor this
-might be a bit slow.
-
-The package is compilable under Linux. I would be glad if someone would
-make a version for windows or OSX, but I unfortunately don't have the
-time or resource to do so.
-
-In order to compile:
-cd src/
-make
-
-The default compilation flags are very conservative, you can add
-optimization flags through the CFLAGS variable.
-e.g
-
-make CFLAGS="-O6"
-
-Will turn on maximum optimization (almost).
-
-If you have tcl/tk installed in the right place this should work out,
-if you have problems with that, either adapt the makefile or ask me.
-On Debian you just have to install tk8.4-dev to get it going.
-
-Have fun !
-
-Guenter
-
-
-Additional information:
----------------------------
-
-Instructions for compiling for iPods, using arm-elf-tools-20030314:
-
-cd src
-./build.ipod
-
-The tcl/tk interface will not be built for iPods, you can interface with
-Pd from the podzilla console or with this GUI for PDa on iPod:
-
-http://ipodlinux.org/Pdpod
-
-
diff --git a/apps/plugins/pdbox/PDa/README.txt b/apps/plugins/pdbox/PDa/README.txt
index 856ccaad62..cab1e3605c 100644
--- a/apps/plugins/pdbox/PDa/README.txt
+++ b/apps/plugins/pdbox/PDa/README.txt
@@ -42,47 +42,4 @@ Winfried Ritsch, Vibeke Sorensen, Rand Steiger, Shahrokh Yadegari, David
Zicarelli, Iohannes Zmoelnig, and probably many others for contributions of
code, documentation, ideas, and expertise. This work has received generous
support from the Intel Research Council.
-This is the README file for Pd, a free real-time computer music software
-package resembling Max. You can get Pd for Linux, Windows, Mac OSX, or IRIX
-from http://www.crca.ucsd.edu/~msp/software.html or ftp://felix.ucsd.edu.
-Installation instructions are in the HTML DOCUMENTATION at:
-
- http://www.crca.ucsd.edu/~msp/Pd_documentation/index.htm
-
-If you download and unpack Pd, you will also find the html documentation
-locally in the file, .../pd-whatever/doc/1.manual/index.htm. To unpack Pd:
-
-LINUX (or freeBSD). Download Pd, which will be a ".tar.gz" file; to unpack it,
-type "zcat [name].tar.gz | tar xf -" to a shell. This creates a directory with
-a name like "pd-0.35". There are also RPMs available.
-
-Microsoft Windows. Pd is distributed as a "zip" file. Unzip this,
-creating a directory such as \pd.
-
-IRIX. Download Pd, which will be a "tar.Z" file. You can unpack this by
-typing "zcat [name].tar.Z | tar xf -" to a shell.
-
-Macintosh. The web browser will automatically unpack the distributions
-into a folder such as "pd-0.35" on your desktop.
-If you have qustions about Pd, or if you wish to be notified of releases,
-check the Pd mailing list: http://iem.mhsg.ac.at/mailinglists/pd-list/
-
-Many extensions to Pd are available, notably for handling video and 3D
-graphics; see the html documentation for pointers.
-
-COPYRIGHT. Except as otherwise noted, all files in the Pd distribution are
-
- Copyright (c) 1997-2001 Miller Puckette and others.
-
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "LICENSE.txt," included in the Pd distribution.
-(Note that tcl/tk, expr, and some other files are copyrighted separately).
-
-ACKNOWLEDGEMENTS. Thanks to Harry Castle, Krzysztof Czaja, Mark Danks,
-Christian Feldbauer, Guenter Geiger, Kerry Hagan, Trevor Johnson, Fernando
-Lopez-Lezcano, Adam Lindsay, Karl MacMillan, Thomas Musil, Toshinori Ohkouchi,
-Winfried Ritsch, Vibeke Sorensen, Rand Steiger, Shahrokh Yadegari, David
-Zicarelli, Iohannes Zmoelnig, and probably many others for contributions of
-code, documentation, ideas, and expertise. This work has received generous
-support from the Intel Research Council.
diff --git a/apps/plugins/pdbox/PDa/extra/OSC-client.h b/apps/plugins/pdbox/PDa/extra/OSC-client.h
index 196143f8e7..fe2c37b5cb 100644
--- a/apps/plugins/pdbox/PDa/extra/OSC-client.h
+++ b/apps/plugins/pdbox/PDa/extra/OSC-client.h
@@ -186,191 +186,4 @@ extern char *OSC_errorMessage;
string? The length of the string, plus the null char, plus any padding
needed for 4-byte alignment. */
int OSC_effectiveStringLength(char *string);
-/*
-Written by Matt Wright, The Center for New Music and Audio Technologies,
-University of California, Berkeley. Copyright (c) 1996,97,98,99,2000,01,02,03
-The Regents of the University of California (Regents).
-
-Permission to use, copy, modify, distribute, and distribute modified versions
-of this software and its documentation without fee and without a signed
-licensing agreement, is hereby granted, provided that the above copyright
-notice, this paragraph and the following two paragraphs appear in all copies,
-modifications, and distributions.
-
-IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
-OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
-BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
-HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
-MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-*/
-
-/*
-
- OSC-client.h: library for constructing OpenSoundControl messages.
- Derived from SynthControl.h
- Author: Matt Wright
- Version 0.1: 6/13/97
- Version 0.2: 7/21/2000: Support for type-tagged messages
-
-
- General notes:
-
- This library abstracts away the data format for the OpenSoundControl
- protocol. Users of this library can construct OpenSoundControl packets
- with a function call interface instead of knowing how to lay out the bits.
-
- All issues of memory allocation are deferred to the user of this library.
- There are two data structures that the user must allocate. The first
- is the actual buffer that the message will be written into. This buffer
- can be any size, but if it's too small there's a possibility that it
- will become overfull. The other data structure is called an OSCbuf,
- and it holds all the state used by the library as it's constructing
- a buffer.
-
- All procedures that have the possibility of an error condition return int,
- with 0 indicating no error and nonzero indicating an error. The variable
- OSC_errorMessage will be set to point to a string containing an error
- message explaining what the problem is.
-
-*/
-
-
-
-/* The int4byte type has to be a 4-byte integer. You may have to
- change this to long or something else on your system. */
-#ifdef __MWERKS__
- /* In Metrowerks you can set ints to be 2 or 4 bytes on 68K, but long is
- always 4 bytes */
- typedef long int4byte;
-#else
- typedef int int4byte;
-#endif
-
-/* OSC_timetag.h */
-
- typedef struct {
- int seconds;
- int fraction;
- } OSCTimeTag;
-OSCTimeTag OSCTT_Immediately(void);
-OSCTimeTag OSCTT_PlusSeconds(OSCTimeTag original, float secondsOffset);
-OSCTimeTag OSCTT_CurrentTime(void);
-
-
-
-/* The maximum depth of bundles within bundles within bundles within...
- This is the size of a static array. If you exceed this limit you'll
- get an error message. */
-#define MAX_BUNDLE_NESTING 32
-
-
-/* Don't ever manipulate the data in the OSCbuf struct directly. (It's
- declared here in the header file only so your program will be able to
- declare variables of type OSCbuf and have the right amount of memory
- be allocated.) */
-
-typedef struct OSCbuf_struct {
- char *buffer; /* The buffer to hold the OSC packet */
- int size; /* Size of the buffer */
- char *bufptr; /* Current position as we fill the buffer */
- int state; /* State of partially-constructed message */
- int4byte *thisMsgSize; /* Pointer to count field before
- currently-being-written message */
- int4byte *prevCounts[MAX_BUNDLE_NESTING];
- /* Pointers to count field before each currently
- open bundle */
- int bundleDepth; /* How many sub-sub-bundles are we in now? */
- char *typeStringPtr; /* This pointer advances through the type
- tag string as you add arguments. */
- int gettingFirstUntypedArg; /* nonzero if this message doesn't have
- a type tag and we're waiting for the 1st arg */
-} OSCbuf;
-
-
-
-/* Initialize the given OSCbuf. The user of this module must pass in the
- block of memory that this OSCbuf will use for a buffer, and the number of
- bytes in that block. (It's the user's job to allocate the memory because
- you do it differently in different systems.) */
-void OSC_initBuffer(OSCbuf *buf, int size, char *byteArray);
-
-
-/* Reset the given OSCbuf. Do this after you send out the contents of
- the buffer and want to start writing new data into it. */
-void OSC_resetBuffer(OSCbuf *buf);
-
-
-/* Is the buffer empty? (I.e., would it be stupid to send the buffer
- contents to the synth?) */
-int OSC_isBufferEmpty(OSCbuf *buf);
-
-
-/* How much space is left in the buffer? */
-int OSC_freeSpaceInBuffer(OSCbuf *buf);
-
-/* Does the buffer contain a valid OSC packet? (Returns nonzero if yes.) */
-int OSC_isBufferDone(OSCbuf *buf);
-
-/* When you're ready to send out the buffer (i.e., when OSC_isBufferDone()
- returns true), call these two procedures to get the OSC packet that's been
- assembled and its size in bytes. (And then call OSC_resetBuffer() if you
- want to re-use this OSCbuf for the next packet.) */
-char *OSC_getPacket(OSCbuf *buf);
-int OSC_packetSize(OSCbuf *buf);
-
-
-
-/* Here's the basic model for building up OSC messages in an OSCbuf:
-
- - Make sure the OSCbuf has been initialized with OSC_initBuffer().
-
- - To open a bundle, call OSC_openBundle(). You can then write
- messages or open new bundles within the bundle you opened.
- Call OSC_closeBundle() to close the bundle. Note that a packet
- does not have to have a bundle; it can instead consist of just a
- single message.
-
-
- - For each message you want to send:
-
- - Call OSC_writeAddress() with the name of your message. (In
- addition to writing your message name into the buffer, this
- procedure will also leave space for the size count of this message.)
-
- - Alternately, call OSC_writeAddressAndTypes() with the name of
- your message and with a type string listing the types of all the
- arguments you will be putting in this message.
-
- - Now write each of the arguments into the buffer, by calling one of:
- OSC_writeFloatArg()
- OSC_writeFloatArgs()
- OSC_writeIntArg()
- OSC_writeStringArg()
-
- - Now your message is complete; you can send out the buffer or you can
- add another message to it.
-*/
-
-int OSC_openBundle(OSCbuf *buf, OSCTimeTag tt);
-int OSC_closeBundle(OSCbuf *buf);
-int OSC_closeAllBundles(OSCbuf *buf);
-
-int OSC_writeAddress(OSCbuf *buf, char *name);
-int OSC_writeAddressAndTypes(OSCbuf *buf, char *name, char *types);
-int OSC_writeFloatArg(OSCbuf *buf, float arg);
-int OSC_writeFloatArgs(OSCbuf *buf, int numFloats, float *args);
-int OSC_writeIntArg(OSCbuf *buf, int4byte arg);
-int OSC_writeStringArg(OSCbuf *buf, char *arg);
-
-extern char *OSC_errorMessage;
-
-/* How many bytes will be needed in the OSC format to hold the given
- string? The length of the string, plus the null char, plus any padding
- needed for 4-byte alignment. */
-int OSC_effectiveStringLength(char *string);
diff --git a/apps/plugins/pdbox/PDa/extra/OSC.pd b/apps/plugins/pdbox/PDa/extra/OSC.pd
index 8873f308da..37841ef17a 100644
--- a/apps/plugins/pdbox/PDa/extra/OSC.pd
+++ b/apps/plugins/pdbox/PDa/extra/OSC.pd
@@ -11,16 +11,4 @@
#X connect 1 1 3 0;
#X connect 5 0 4 0;
#X connect 6 0 4 0;
-#N canvas 0 0 240 300 10;
-#X obj 32 185 dumpOSC 5550;
-#X obj 32 217 OSCroute /hello;
-#X obj 32 239 print;
-#X obj 133 238 print;
-#X obj 26 87 sendOSC;
-#X msg 50 43 connect localhost 5550;
-#X msg 21 13 send /hello PDa;
-#X connect 0 0 1 0;
-#X connect 1 0 2 0;
-#X connect 1 1 3 0;
-#X connect 5 0 4 0;
-#X connect 6 0 4 0;
+
diff --git a/apps/plugins/pdbox/PDa/extra/OSCroute.c b/apps/plugins/pdbox/PDa/extra/OSCroute.c
index 437d34dc68..24860d0b79 100644
--- a/apps/plugins/pdbox/PDa/extra/OSCroute.c
+++ b/apps/plugins/pdbox/PDa/extra/OSCroute.c
@@ -598,607 +598,3 @@ static Boolean MatchList (const char *pattern, const char *test) {
}
-
-
-/*
-Written by Adrian Freed, The Center for New Music and Audio Technologies,
-University of California, Berkeley. Copyright (c) 1992,93,94,95,96,97,98,99,2000,01,02,03,04
-The Regents of the University of California (Regents).
-
-Permission to use, copy, modify, distribute, and distribute modified versions
-of this software and its documentation without fee and without a signed
-licensing agreement, is hereby granted, provided that the above copyright
-notice, this paragraph and the following two paragraphs appear in all copies,
-modifications, and distributions.
-
-IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
-OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
-BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
-HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
-MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-
-The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl
-*/
-
- /* OSC-route.c
- Max object for OSC-style dispatching
-
- To-do:
-
- Match a pattern against a pattern?
- Declare outlet types / distinguish leaf nodes from other children
- More sophisticated (2-pass?) allmessages scheme
- set message?
-
-
- pd
- -------------
- -- tweaks for Win32 www.zeggz.com/raf 13-April-2002
-
-
- */
-
-#ifdef WIN32
- #include <stdlib.h>
- #include <string.h>
-#endif
-#ifdef __APPLE__
- #include <stdio.h>
-#endif
-#ifdef UNIX
- #include <stdio.h>
-#endif
-
-/* structure definition of your object */
-
-#define MAX_NUM 20
-#define OSC_ROUTE_VERSION "1.05"
-#define OSCWarning(x...) post(x)
-
-/* the required include files */
-#include "m_pd.h"
-
-
-#ifndef TRUE
-typedef int Boolean;
-#define TRUE 1
-#define FALSE 0
-#endif
-
-
-/* Fixed byte width types */
-typedef int int4; /* 4 byte int */
-
-Boolean PatternMatch (const char *pattern, const char *test);
-
-
-
-/* Version 1.04: Allows #1 thru #9 as typed-in arguments
- Version 1.05: Allows "list" messages as well as "message" messages.
-*/
-
-static t_class *OSCroute_class;
-
-typedef struct _OSCroute
-{
- t_object x_obj; // required header
- t_int x_num; // Number of address prefixes we store
- t_int x_complainmode; // Do we print a message if no match?
- t_int x_sendmode; // use pd internal sends instead of outlets
- char *x_prefixes[MAX_NUM];
- void *x_outlets[MAX_NUM+1];
-} t_OSCroute;
-
-t_symbol *ps_list, *ps_complain, *ps_emptySymbol;
-
-/* prototypes */
-
-void OSCroute_doanything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv);
-void OSCroute_anything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv);
-void OSCroute_list(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv);
-/* //void *OSCroute_new(t_symbol *s, int argc, atom *argv); */
-void *OSCroute_new(t_symbol *s, int argc, t_atom *argv);
-void OSCroute_version (t_OSCroute *x);
-/* void OSCroute_assist (OSCroute *x, void *box, long msg, long arg, */
-/* char *dstString); */
-void OSCroute_allmessages(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv);
-
-static char *NextSlashOrNull(char *p);
-static void StrCopyUntilSlash(char *target, const char *source);
-
-
-// free
-static void OSCroute_free(t_OSCroute *x)
-{
- // freebytes(x->x_vec, x->x_nelement * sizeof(*x->x_vec));
-}
-
-/* initialization routine */
-
-// setup
-#ifdef WIN32
- OSC_API void OSCroute_setup(void) {
-#else
-void OSCroute_setup(void) {
-#endif
- OSCroute_class = class_new(gensym("OSCroute"), (t_newmethod)OSCroute_new,
- (t_method)OSCroute_free,sizeof(t_OSCroute), 0, A_GIMME, 0);
- class_addlist(OSCroute_class, OSCroute_list);
- class_addanything(OSCroute_class, OSCroute_anything);
- class_addmethod(OSCroute_class, (t_method)OSCroute_version, gensym("version"), A_NULL, 0, 0);
- class_sethelpsymbol(OSCroute_class, gensym("OSCroute-help.pd"));
-
- /*
- class_addmethod(OSCroute_class, (t_method)OSCroute_connect,
- gensym("connect"), A_SYMBOL, A_FLOAT, 0);
- class_addmethod(OSCroute_class, (t_method)OSCroute_disconnect,
- gensym("disconnect"), 0);
- class_addmethod(OSCroute_class, (t_method)OSCroute_send, gensym("send"),
- A_GIMME, 0);
- */
-/* ps_list = gensym("list"); */
-/* ps_complain = gensym("complain"); */
- ps_emptySymbol = gensym("");
-
- post("OSCroute object version " OSC_ROUTE_VERSION " by Matt Wright. pd: jdl Win32 raf.");
- post("OSCroute Copyright © 1999 Regents of the University of California. All Rights Reserved.");
-}
-
-
-
-/* instance creation routine */
-
-void *OSCroute_new(t_symbol *s, int argc, t_atom *argv)
-{
-
- t_OSCroute *x = (t_OSCroute *)pd_new(OSCroute_class); // get memory for a new object & initialize
-
- int i; //{{raf}} n not used
-
- // EnterCallback();
-
- if (argc > MAX_NUM) {
- post("* OSC-route: too many arguments: %ld (max %ld)", argc, MAX_NUM);
- // ExitCallback();
- return 0;
- }
-
- x->x_complainmode = 0;
- x->x_num = 0;
- for (i = 0; i < argc; ++i) {
- if (argv[i].a_type == A_SYMBOL) {
- if (argv[i].a_w.w_symbol->s_name[0] == '/') {
- /* Now that's a nice prefix */
- x->x_prefixes[i] = argv[i].a_w.w_symbol->s_name;
- ++(x->x_num);
- } else if (argv[i].a_w.w_symbol->s_name[0] == '#' &&
- argv[i].a_w.w_symbol->s_name[1] >= '1' &&
- argv[i].a_w.w_symbol->s_name[1] <= '9') {
- /* The Max programmer is trying to make a patch that will be
- a subpatch with arguments. We have to make an outlet for this
- argument. */
- x->x_prefixes[i] = "dummy";
- ++(x->x_num);
- } else {
- /* Maybe this is an option we support */
-
-/* if (argv[i].a_w.w_sym == ps_complain) { */
-/* x->x_complainmode = 1; */
-/* } else { */
-/* post("* OSC-route: Unrecognized argument %s", argv[i].a_w.w_sym->s_name); */
-/* } */
-
- }
-
- // no LONG
-
-/* } else if (argv[i].a_type == A_FLOAD) { */
-/* // Convert to a numeral. Max ints are -2147483648 to 2147483647 */
-/* char *string = getbytes(12); */
-/* // I can't be bothered to plug this 12 byte memory leak */
-/* if (string == 0) { */
-/* post("* OSC-route: out of memory!"); */
-/* // ExitCallback(); */
-/* return 0; */
-/* } */
-/* sprintf(string, "%d", argv[i].a_w.w_long); */
-/* x->x_prefixes[i] = string; */
-/* ++(x->x_num); */
-
- } else if (argv[i].a_type == A_FLOAT) {
- post("* OSC-route: float arguments are not OK.");
- // ExitCallback();
- return 0;
- } else {
- post("* OSC-route: unrecognized argument type!");
- // ExitCallback();
- return 0;
- }
- }
-
-
- /* Have to create the outlets in reverse order */
- /* well, not in pd ? */
- // for (i = x->x_num-1; i >= 0; --i) {
- // for (i = 0; i <= x->x_num-1; i++) {
- for (i = 0; i <= x->x_num; i++) {
- // x->x_outlets[i] = listout(x);
- x->x_outlets[i] = outlet_new(&x->x_obj, &s_list);
- }
-
- // ExitCallback();
- return (x);
-}
-
-
-void OSCroute_version (t_OSCroute *x) {
- // EnterCallback();
- post("OSCroute Version " OSC_ROUTE_VERSION
- ", by Matt Wright. pd jdl, win32: raf.\nOSCroute Compiled " __TIME__ " " __DATE__);
- // ExitCallback();
-}
-
-/* I don't know why these aren't defined in some Max #include file. */
-#define ASSIST_INLET 1
-#define ASSIST_OUTLET 2
-
-void OSCroute_assist (t_OSCroute *x, void *box, long msg, long arg,
- char *dstString) {
- // EnterCallback();
-
- if (msg==ASSIST_INLET) {
- sprintf(dstString, "Incoming OSC messages");
- } else if (msg==ASSIST_OUTLET) {
- if (arg < 0 || arg >= x->x_num) {
- post("* OSCroute_assist: No outlet corresponds to arg %ld!", arg);
- } else {
- sprintf(dstString, "subaddress + args for prefix %s", x->x_prefixes[arg]);
- }
- } else {
- post("* OSCroute_assist: unrecognized message %ld", msg);
- }
-
- // ExitCallback();
-}
-
-void OSCroute_list(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) {
- // EnterCallback();
- if (argc > 0 && argv[0].a_type == A_SYMBOL) {
- /* Ignore the fact that this is a "list" */
- OSCroute_doanything(x, argv[0].a_w.w_symbol, argc-1, argv+1);
- } else {
- // post("* OSC-route: invalid list beginning with a number");
- // output on unmatched outlet jdl 20020908
- if (argv[0].a_type == A_FLOAT) {
- outlet_float(x->x_outlets[x->x_num], argv[0].a_w.w_float);
- } else {
- post("* OSC-route: unrecognized atom type!");
- }
- }
- // ExitCallback();
-}
-
-
-void OSCroute_anything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) {
- // EnterCallback();
- OSCroute_doanything(x, s, argc, argv);
- // ExitCallback();
-}
-
-
-
-
-void OSCroute_doanything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) {
- char *pattern, *nextSlash;
- int i;
- int matchedAnything;
- // post("*** OSCroute_anything(s %s, argc %ld)", s->s_name, (long) argc);
-
- pattern = s->s_name;
- if (pattern[0] != '/') {
- post("* OSC-route: invalid message pattern %s does not begin with /", s->s_name);
- outlet_anything(x->x_outlets[x->x_num], s, argc, argv);
- return;
- }
-
- matchedAnything = 0;
-
- nextSlash = NextSlashOrNull(pattern+1);
- if (*nextSlash == '\0') {
- /* last level of the address, so we'll output the argument list */
-
-
-#ifdef NULL_IS_DIFFERENT_FROM_BANG
- if (argc==0) {
- post("* OSC-route: why are you matching one level pattern %s with no args?",
- pattern);
- return;
- }
-#endif
-
- for (i = 0; i < x->x_num; ++i) {
- if (PatternMatch(pattern+1, x->x_prefixes[i]+1)) {
- ++matchedAnything;
-
- // I hate stupid Max lists with a special first element
- if (argc == 0) {
- outlet_bang(x->x_outlets[i]);
- } else if (argv[0].a_type == A_SYMBOL) {
- // Promote the symbol that was argv[0] to the special symbol
- outlet_anything(x->x_outlets[i], argv[0].a_w.w_symbol, argc-1, argv+1);
- } else if (argc > 1) {
- // Multiple arguments starting with a number, so naturally we have
- // to use a special function to output this "list", since it's what
- // Max originally meant by "list".
- outlet_list(x->x_outlets[i], 0L, argc, argv);
- } else {
- // There was only one argument, and it was a number, so we output it
- // not as a list
-/* if (argv[0].a_type == A_LONG) { */
-
-/* outlet_int(x->x_outlets[i], argv[0].a_w.w_long); */
- // } else
- if (argv[0].a_type == A_FLOAT) {
-
- outlet_float(x->x_outlets[i], argv[0].a_w.w_float);
- } else {
- post("* OSC-route: unrecognized atom type!");
- }
- }
- }
- }
- } else {
- /* There's more address after this part, so our output list will begin with
- the next slash. */
- t_symbol *restOfPattern = 0; /* avoid the gensym unless we have to output */
- char patternBegin[1000];
-
-
- /* Get the first level of the incoming pattern to match against all our prefixes */
- StrCopyUntilSlash(patternBegin, pattern+1);
-
- for (i = 0; i < x->x_num; ++i) {
- if (PatternMatch(patternBegin, x->x_prefixes[i]+1)) {
- ++matchedAnything;
- if (restOfPattern == 0) {
- restOfPattern = gensym(nextSlash);
- }
- outlet_anything(x->x_outlets[i], restOfPattern, argc, argv);
- }
- }
- }
-
- if (x->x_complainmode) {
- if (!matchedAnything) {
- post("* OSC-route: pattern %s did not match any prefixes", pattern);
- }
- }
-
- // output unmatched data on rightmost outlet a la normal 'route' object, jdl 20020908
- if (!matchedAnything) {
- outlet_anything(x->x_outlets[x->x_num], s, argc, argv);
- }
-
-
-}
-
-static char *NextSlashOrNull(char *p) {
- while (*p != '/' && *p != '\0') {
- p++;
- }
- return p;
-}
-
-static void StrCopyUntilSlash(char *target, const char *source) {
- while (*source != '/' && *source != '\0') {
- *target = *source;
- ++target;
- ++source;
- }
- *target = 0;
-}
-
-static int MyStrCopy(char *target, const char *source) {
- int i = 0;
- while (*source != '\0') {
- *target = *source;
- ++target;
- ++source;
- ++i;
- }
- *target = 0;
- return i;
-}
-
-
-
-void OSCroute_allmessages(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) {
- int i;
- t_symbol *prefixSymbol = 0;
- char prefixBuf[1000];
- char *endOfPrefix;
- t_atom a[1];
-
- if (argc >= 1 && argv[0].a_type == A_SYMBOL) {
- prefixSymbol = argv[0].a_w.w_symbol;
- endOfPrefix = prefixBuf + MyStrCopy(prefixBuf,
- prefixSymbol->s_name);
- } else {
- prefixSymbol = ps_emptySymbol;
- prefixBuf[0] = '\0';
- endOfPrefix = prefixBuf;
- }
-
-
- for (i = 0; i < x->x_num; ++i) {
- post("OSC: %s%s", prefixSymbol->s_name, x->x_prefixes[i]);
- MyStrCopy(endOfPrefix, x->x_prefixes[i]);
- SETSYMBOL(a, gensym(prefixBuf));
- outlet_anything(x->x_outlets[i], s, 1, a);
- }
-}
-
-
-/* --------------------------------------------------- */
-
-
-
-static const char *theWholePattern; /* Just for warning messages */
-
-static Boolean MatchBrackets (const char *pattern, const char *test);
-static Boolean MatchList (const char *pattern, const char *test);
-
-Boolean PatternMatch (const char * pattern, const char * test) {
- theWholePattern = pattern;
-
- if (pattern == 0 || pattern[0] == 0) {
- return test[0] == 0;
- }
-
- if (test[0] == 0) {
- if (pattern[0] == '*')
- return PatternMatch (pattern+1,test);
- else
- return FALSE;
- }
-
- switch (pattern[0]) {
- case 0 : return test[0] == 0;
- case '?' : return PatternMatch (pattern + 1, test + 1);
- case '*' :
- if (PatternMatch (pattern+1, test)) {
- return TRUE;
- } else {
- return PatternMatch (pattern, test+1);
- }
- case ']' :
- case '}' :
- OSCWarning("Spurious %c in pattern \".../%s/...\"",pattern[0], theWholePattern);
- return FALSE;
- case '[' :
- return MatchBrackets (pattern,test);
- case '{' :
- return MatchList (pattern,test);
- case '\\' :
- if (pattern[1] == 0) {
- return test[0] == 0;
- } else if (pattern[1] == test[0]) {
- return PatternMatch (pattern+2,test+1);
- } else {
- return FALSE;
- }
- default :
- if (pattern[0] == test[0]) {
- return PatternMatch (pattern+1,test+1);
- } else {
- return FALSE;
- }
- }
-}
-
-
-/* we know that pattern[0] == '[' and test[0] != 0 */
-
-static Boolean MatchBrackets (const char *pattern, const char *test) {
- Boolean result;
- Boolean negated = FALSE;
- const char *p = pattern;
-
- if (pattern[1] == 0) {
- OSCWarning("Unterminated [ in pattern \".../%s/...\"", theWholePattern);
- return FALSE;
- }
-
- if (pattern[1] == '!') {
- negated = TRUE;
- p++;
- }
-
- while (*p != ']') {
- if (*p == 0) {
- OSCWarning("Unterminated [ in pattern \".../%s/...\"", theWholePattern);
- return FALSE;
- }
- if (p[1] == '-' && p[2] != 0) {
- if (test[0] >= p[0] && test[0] <= p[2]) {
- result = !negated;
- goto advance;
- }
- }
- if (p[0] == test[0]) {
- result = !negated;
- goto advance;
- }
- p++;
- }
-
- result = negated;
-
-advance:
-
- if (!result)
- return FALSE;
-
- while (*p != ']') {
- if (*p == 0) {
- OSCWarning("Unterminated [ in pattern \".../%s/...\"", theWholePattern);
- return FALSE;
- }
- p++;
- }
-
- return PatternMatch (p+1,test+1);
-}
-
-static Boolean MatchList (const char *pattern, const char *test) {
-
- const char *restOfPattern, *tp = test;
-
-
- for(restOfPattern = pattern; *restOfPattern != '}'; restOfPattern++) {
- if (*restOfPattern == 0) {
- OSCWarning("Unterminated { in pattern \".../%s/...\"", theWholePattern);
- return FALSE;
- }
- }
-
- restOfPattern++; /* skip close curly brace */
-
-
- pattern++; /* skip open curly brace */
-
- while (1) {
-
- if (*pattern == ',') {
- if (PatternMatch (restOfPattern, tp)) {
- return TRUE;
- } else {
- tp = test;
- ++pattern;
- }
- } else if (*pattern == '}') {
- return PatternMatch (restOfPattern, tp);
- } else if (*pattern == *tp) {
- ++pattern;
- ++tp;
- } else {
- tp = test;
- while (*pattern != ',' && *pattern != '}') {
- pattern++;
- }
- if (*pattern == ',') {
- pattern++;
- }
- }
- }
-
-}
-
-
-
diff --git a/apps/plugins/pdbox/PDa/extra/README b/apps/plugins/pdbox/PDa/extra/README
index 6e0b4a1e67..3c83e39862 100644
--- a/apps/plugins/pdbox/PDa/extra/README
+++ b/apps/plugins/pdbox/PDa/extra/README
@@ -10,15 +10,4 @@ fault. Send feedback and wishes to
geiger <AT> xdv dot org
-PDa - externals
-===============
-
-This is a collection of selected externals for PDa. The externals are
-all copyright by their authors, check out the copyright notice in
-each of the files.
-
-I have changed some of the files a bit, so the bugs are most likely my
-fault. Send feedback and wishes to
-
-geiger <AT> xdv dot org
diff --git a/apps/plugins/pdbox/PDa/extra/bandpass-help.pd b/apps/plugins/pdbox/PDa/extra/bandpass-help.pd
index 65d41eafad..52feeb16c2 100644
--- a/apps/plugins/pdbox/PDa/extra/bandpass-help.pd
+++ b/apps/plugins/pdbox/PDa/extra/bandpass-help.pd
@@ -15,20 +15,4 @@
#X connect 3 0 5 0;
#X connect 4 0 5 1;
#X connect 5 0 2 0;
-#N canvas 428 285 240 300 8;
-#X obj 24 78 noise~;
-#X obj 15 215 dac~;
-#X obj 24 167 biquad~;
-#X floatatom 67 76 5 0 0 0 - - -;
-#X floatatom 83 111 5 0 0 0 - - -;
-#X obj 67 138 bandpass 600 10;
-#X text 77 97 bandwidth: 100 = 1 octave;
-#X text 67 58 frequency;
-#X text 8 11 Calculation of biquad coefficients;
-#X text 7 21 ==================================;
-#X connect 0 0 2 0;
-#X connect 2 0 1 0;
-#X connect 2 0 1 1;
-#X connect 3 0 5 0;
-#X connect 4 0 5 1;
-#X connect 5 0 2 0;
+
diff --git a/apps/plugins/pdbox/PDa/extra/bandpass.c b/apps/plugins/pdbox/PDa/extra/bandpass.c
index 6de56d6174..127a1eee06 100644
--- a/apps/plugins/pdbox/PDa/extra/bandpass.c
+++ b/apps/plugins/pdbox/PDa/extra/bandpass.c
@@ -84,89 +84,4 @@ void bandpass_setup(void)
-
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-/*
-
- These filter coefficients computations are taken from
- http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
-
- written by Robert Bristow-Johnson
-
-*/
-
-#include "m_pd.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-#include <math.h>
-#include "filters.h"
-
-/* ------------------- bandpass ----------------------------*/
-
-static t_class *bandpass_class;
-
-void bandpass_bang(t_rbjfilter *x)
-{
- t_atom at[5];
- t_float omega = e_omega(x->x_freq,x->x_rate);
- t_float alpha = e_alpha(x->x_bw* 0.01,omega);
- t_float b1 = 0.;
- t_float b0 = alpha;
- t_float b2 = -alpha;
- t_float a0 = 1 + alpha;
- t_float a1 = -2.*cos(omega);
- t_float a2 = 1 - alpha;
-
-/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
-
- if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
- post("bandpass: filter unstable -> resetting");
- a0=1.;a1=0.;a2=0.;
- b0=1.;b1=0.;b2=0.;
- }
-
- SETFLOAT(at,-a1/a0);
- SETFLOAT(at+1,-a2/a0);
- SETFLOAT(at+2,b0/a0);
- SETFLOAT(at+3,b1/a0);
- SETFLOAT(at+4,b2/a0);
-
- outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
-}
-
-
-void bandpass_float(t_rbjfilter *x,t_floatarg f)
-{
- x->x_freq = f;
- bandpass_bang(x);
-}
-
-
-static void *bandpass_new(t_floatarg f,t_floatarg bw)
-{
- t_rbjfilter *x = (t_rbjfilter *)pd_new(bandpass_class);
-
- x->x_rate = 44100.0;
- outlet_new(&x->x_obj,&s_float);
-/* floatinlet_new(&x->x_obj, &x->x_gain); */
- floatinlet_new(&x->x_obj, &x->x_bw);
- if (f > 0.) x->x_freq = f;
- if (bw > 0.) x->x_bw = bw;
- return (x);
-}
-
-
-void bandpass_setup(void)
-{
- bandpass_class = class_new(gensym("bandpass"), (t_newmethod)bandpass_new, 0,
- sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
- class_addbang(bandpass_class,bandpass_bang);
- class_addfloat(bandpass_class,bandpass_float);
-}
-
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/dumpOSC.c b/apps/plugins/pdbox/PDa/extra/dumpOSC.c
index 37767c2b03..28b0d8223e 100644
--- a/apps/plugins/pdbox/PDa/extra/dumpOSC.c
+++ b/apps/plugins/pdbox/PDa/extra/dumpOSC.c
@@ -997,1002 +997,4 @@ void complain(char *s, ...) {
}
#endif /* __sgi or LINUX or WIN32 */
-/*
-Written by Matt Wright and Adrian Freed, The Center for New Music and
-Audio Technologies, University of California, Berkeley. Copyright (c)
-1992,93,94,95,96,97,98,99,2000,01,02,03,04 The Regents of the University of
-California (Regents).
-
-Permission to use, copy, modify, distribute, and distribute modified versions
-of this software and its documentation without fee and without a signed
-licensing agreement, is hereby granted, provided that the above copyright
-notice, this paragraph and the following two paragraphs appear in all copies,
-modifications, and distributions.
-
-IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
-OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
-BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
-HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
-MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-
-The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl
-*/
-
-
- /*
-
- dumpOSC.c
- server that displays OpenSoundControl messages sent to it
- for debugging client udp and UNIX protocol
-
- by Matt Wright, 6/3/97
- modified from dumpSC.c, by Matt Wright and Adrian Freed
-
- version 0.2: Added "-silent" option a.k.a. "-quiet"
-
- version 0.3: Incorporated patches from Nicola Bernardini to make
- things Linux-friendly. Also added ntohl() in the right places
- to support little-endian architectures.
-
-
-
- compile:
- cc -o dumpOSC dumpOSC.c
-
- to-do:
-
- More robustness in saying exactly what's wrong with ill-formed
- messages. (If they don't make sense, show exactly what was
- received.)
-
- Time-based features: print time-received for each packet
-
- Clean up to separate OSC parsing code from socket/select stuff
-
- pd: branched from http://www.cnmat.berkeley.edu/OpenSoundControl/src/dumpOSC/dumpOSC.c
- -------------
- -- added pd functions
- -- socket is made differently than original via pd mechanisms
- -- tweaks for Win32 www.zeggz.com/raf 13-April-2002
- -- the OSX changes from cnmat didnt make it here yet but this compiles
- on OSX anyway.
-
-*/
-
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "m_pd.h"
-//#include "m_imp.h"
-#include "s_stuff.h"
-
-/* declarations */
-
-// typedef void (*t_fdpollfn)(void *ptr, int fd);
-void sys_addpollfn(int fd, t_fdpollfn fn, void *ptr);
-
-
-#if defined(__sgi) || defined(__linux) || defined(WIN32) || defined(__APPLE__)
-
-#ifdef WIN32
- #include "OSC-common.h"
- #include <winsock2.h>
- #include <string.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <ctype.h>
- #include <signal.h>
-#else
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <netinet/in.h>
- #include <rpc/rpc.h>
- #include <sys/socket.h>
- #include <sys/un.h>
- #include <sys/times.h>
- #include <sys/param.h>
- #include <sys/time.h>
- #include <sys/ioctl.h>
- #include <ctype.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <pwd.h>
- #include <signal.h>
- #include <grp.h>
- #include <sys/file.h>
- //#include <sys/prctl.h>
-
- #ifdef NEED_SCHEDCTL_AND_LOCK
- #include <sys/schedctl.h>
- #include <sys/lock.h>
- #endif
-#endif
-
-
-char *htm_error_string;
-typedef int Boolean;
-typedef void *OBJ;
-
-typedef struct ClientAddressStruct {
- struct sockaddr_in cl_addr;
- int clilen;
- int sockfd;
-} *ClientAddr;
-
-typedef unsigned long long osc_time_t;
-
-Boolean ShowBytes = FALSE;
-Boolean Silent = FALSE;
-
-/* Declarations */
-#ifndef WIN32
-static int unixinitudp(int chan);
-#endif
-
-static int initudp(int chan);
-static void closeudp(int sockfd);
-Boolean ClientReply(int packetsize, void *packet, int socketfd,
- void *clientaddresspointer, int clientaddressbufferlength);
-void sgi_CleanExit(void);
-Boolean sgi_HaveToQuit(void);
-int RegisterPollingDevice(int fd, void (*callbackfunction)(int , void *), void *dummy);
-static void catch_sigint();
-static int Synthmessage(char *m, int n, void *clientdesc, int clientdesclength, int fd) ;
-char *DataAfterAlignedString(char *string, char *boundary) ;
-Boolean IsNiceString(char *string, char *boundary) ;
-void complain(char *s, ...);
-
-#define MAXMESG 32768
-static char mbuf[MAXMESG];
-
-/* ----------------------------- dumpOSC ------------------------- */
-
-#define MAXOUTAT 50
-
-static t_class *dumpOSC_class;
-
-typedef struct _dumpOSC
-{
- t_object x_obj;
- t_outlet *x_msgout;
- t_outlet *x_connectout;
- t_atom x_outat[MAXOUTAT];
- int x_outatc;
- t_binbuf *x_b;
- int x_connectsocket;
- int x_nconnections;
- int x_udp;
- struct sockaddr_in x_server;
- int x_clilen;
-} t_dumpOSC;
-
-void dumpOSC_ParsePacket(t_dumpOSC *x, char *buf, int n, ClientAddr returnAddr);
-Boolean dumpOSC_SendReply(char *buf, int n, void *clientDesc, int clientDescLenght, int fd);
-static void dumpOSC_Smessage(t_dumpOSC *x, char *address, void *v, int n, ClientAddr returnAddr);
-static void dumpOSC_PrintTypeTaggedArgs(t_dumpOSC *x, void *v, int n);
-static void dumpOSC_PrintHeuristicallyTypeGuessedArgs(t_dumpOSC *x, void *v, int n, int skipComma);
-
-static void dumpOSC_read(t_dumpOSC *x, int sockfd) {
- int clilen = x->x_clilen;
- int n;
- struct ClientAddressStruct ras;
- ClientAddr ra = &ras;
-
- //catchupflag= FALSE;
-
-/* if (ShowBytes) { */
-/* int i; */
-/* printf("%d byte message:\n", n); */
-/* for (i = 0; i < n; ++i) { */
-/* printf(" %x (%c)\t", m[i], m[i]); */
-/* if (i%4 == 3) printf("\n"); */
-/* } */
-/* printf("\n"); */
-/* } */
-
- // return catchupflag;
- //struct sockaddr_in x->x_server;
- //while( (n = recvfrom(sockfd, mbuf, MAXMESG, 0, &cl_addr, &clilen)) >0)
- // while((
-
- #ifdef WIN32
- if ((n = recvfrom(sockfd, mbuf, MAXMESG, 0, (SOCKADDR*)&x->x_server, &clilen)) >0)
- #else
- if ((n = recvfrom(sockfd, mbuf, MAXMESG, 0, (struct sockaddr *)&x->x_server, &clilen)) >0)
- #endif
- {
- //int r;
- ras.cl_addr = *((struct sockaddr_in *) &x->x_server);
- ras.clilen = x->x_clilen;
- ras.sockfd = x->x_connectsocket;
-
- #ifdef DEBUG
- printf("dumpOSC_read: received UDP packet of length %d\n", n);
- #endif
-
- if(!dumpOSC_SendReply(mbuf, n, &x->x_server, clilen, sockfd))
- {
- dumpOSC_ParsePacket(x, mbuf, n, ra);
- }
- //r = Synthmessage(mbuf, n, &x->x_server, clilen, sockfd);
- //post ("%d", r);
- //outlet_anything(x->x_msgout, at[msg].a_w.w_symbol,
- // emsg-msg-1, at + msg + 1);
- // outlet_list(x->x_msgout, 0, n, mbuf);
- //if( sgi_HaveToQuit()) goto out;
- //if(r>0) goto back;
- //clilen = maxclilen;
- }
-}
-
-static void *dumpOSC_new(t_symbol *compatflag,
- t_floatarg fportno) {
- t_dumpOSC *x;
- struct sockaddr_in server;
- int clilen=sizeof(server);
- int sockfd;
- int portno=fportno;
- int udp = 1;
-
- //x->x_b = binbuf_new();
- //x->x_outat = binbuf_getvec(x->x_b);
-
- //{{raf}} pointer not valid yet...moving this down
- //x->x_outatc = 0; {{raf}}
-
- /* create a socket */
- if ((sockfd = socket(AF_INET, (udp ? SOCK_DGRAM : SOCK_STREAM), 0)) == -1)
- {
- sys_sockerror("socket");
- return (0);
- }
-
- server.sin_family = AF_INET;
- server.sin_addr.s_addr = INADDR_ANY;
- /* assign server port number */
- server.sin_port = htons((u_short)portno);
- /* name the socket */
- if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
- {
- sys_sockerror("bind");
- sys_closesocket(sockfd);
- return (0);
- }
-
- x = (t_dumpOSC *)pd_new(dumpOSC_class);
- x->x_outatc = 0; // {{raf}} now pointer is valid (less invalid)
-
- x->x_msgout = outlet_new(&x->x_obj, &s_anything);
-
- // if (udp) /* datagram protocol */
- {
-
- sys_addpollfn(sockfd, (t_fdpollfn)dumpOSC_read, x);
- x->x_connectout = 0;
- }
- // else /* streaming protocol */
- /* { */
- /* if (listen(sockfd, 5) < 0) */
- /* { */
- /* sys_sockerror("listen"); */
- /* sys_closesocket(sockfd); */
- /* sockfd = -1; */
- /* } */
- /* else */
- /* { */
- /* sys_addpollfn(sockfd, (t_fdpollfn)dumpOSC_connectpoll, x); */
- /* x->x_connectout = outlet_new(&x->x_obj, &s_float); */
- /* } */
- /* } */
-
- x->x_connectsocket = sockfd;
- x->x_server = server;
- x->x_clilen = clilen;
- x->x_nconnections = 0;
- x->x_udp = udp;
-
- return (x);
-}
-
-static void dumpOSC_free(t_dumpOSC *x)
-{
- /* LATER make me clean up open connections */
- if (x->x_connectsocket >= 0)
- {
- sys_rmpollfn(x->x_connectsocket);
- sys_closesocket(x->x_connectsocket);
- }
-}
-
-#ifdef WIN32
-OSC_API void dumpOSC_setup(void)
-#else
-void dumpOSC_setup(void)
-#endif
-{
- dumpOSC_class = class_new(gensym("dumpOSC"),
- (t_newmethod)dumpOSC_new, (t_method)dumpOSC_free,
- sizeof(t_dumpOSC), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT,
- A_DEFSYM, 0);
- class_sethelpsymbol(dumpOSC_class, gensym("dumpOSC-help.pd"));
-}
-
-
-#ifndef WIN32
- #define UNIXDG_PATH "/tmp/htm"
- #define UNIXDG_TMP "/tmp/htm.XXXXXX"
- static int unixinitudp(int chan)
- {
- struct sockaddr_un serv_addr;
- int sockfd;
-
- if((sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
- return sockfd;
-
- bzero((char *)&serv_addr, sizeof(serv_addr));
- serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, UNIXDG_PATH);
- sprintf(serv_addr.sun_path+strlen(serv_addr.sun_path), "%d", chan);
- unlink(serv_addr.sun_path);
- if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr.sun_family)+strlen(serv_addr.sun_path)) < 0)
- {
- perror("unable to bind\n");
- return -1;
- }
-
- fcntl(sockfd, F_SETFL, FNDELAY);
- return sockfd;
- }
-#endif // #ifndef WIN32
-
-
-
-static int initudp(int chan)
-{
-
-#ifdef WIN32
- struct sockaddr_in serv_addr;
- unsigned int sockfd;
- ULONG nonBlocking = (ULONG) TRUE;
-
- if( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET ) {
- ZeroMemory((char *)&serv_addr, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- serv_addr.sin_port = htons(chan);
- if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) >= 0) {
- // set for non-blocking mode
- if(ioctlsocket(sockfd, FIONBIO, &nonBlocking) == SOCKET_ERROR) {
- perror("unable to set non-blocking\n");
- return -1;
- }
- }
- else { perror("unable to bind\n"); return -1; }
- }
- return (sockfd == INVALID_SOCKET ? -1 : (int)sockfd);
-#else
- struct sockaddr_in serv_addr;
- int sockfd;
-
- if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- return sockfd;
-
- bzero((char *)&serv_addr, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- serv_addr.sin_port = htons(chan);
-
- if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
- {
- perror("unable to bind\n");
- return -1;
- }
-
- fcntl(sockfd, F_SETFL, FNDELAY);
- return sockfd;
-#endif
-}
-
-
-
-
-
-
-
-
-static void closeudp(int sockfd) {
- #ifdef WIN32
- closesocket(sockfd);
- #else
- close(sockfd);
- #endif
-}
-
-static Boolean catchupflag=FALSE;
-Boolean ClientReply(int packetsize, void *packet, int socketfd,
- void *clientaddresspointer, int clientaddressbufferlength)
-{
- if(!clientaddresspointer) return FALSE;
- catchupflag= TRUE;
- return packetsize==sendto(socketfd, packet, packetsize, 0, clientaddresspointer, clientaddressbufferlength);
-}
-
-static Boolean exitflag= FALSE;
-void sgi_CleanExit(void) {
- exitflag = TRUE;
-}
-
-Boolean sgi_HaveToQuit(void) {
- return exitflag;
-}
-
-
-/* file descriptor poll table */
-static int npolldevs =0;
-typedef struct polldev
-{
- int fd;
- void (*callbackfunction)(int , void *);
- void *dummy;
-} polldev;
-#define TABMAX 8
-static polldev polldevs[TABMAX];
-
-
-/* Register a device (referred to by a file descriptor that the caller
- should have already successfully obtained from a system call) to be
- polled as real-time constraints allowed.
-
- When a select(2) call indicates activity on the file descriptor, the
- callback function is called with the file descripter as first
- argument and the given dummy argument (presumably a pointer to the
- instance variables associated with the device).
-*/
-int RegisterPollingDevice(int fd, void (*callbackfunction)(int , void *), void *dummy)
-{
- if(npolldevs<TABMAX)
- {
- polldevs[npolldevs].fd = fd;
- polldevs[npolldevs].callbackfunction = callbackfunction;
- polldevs[npolldevs].dummy = dummy;
- }
- else return -1;
- return npolldevs++;
-}
-
-static int caught_sigint;
-
-static void catch_sigint() {
- caught_sigint = 1;
-}
-static int sockfd, usockfd;
-
-
-void PrintClientAddr(ClientAddr CA) {
- unsigned long addr = CA->cl_addr.sin_addr.s_addr;
- printf("Client address %p:\n", CA);
- printf(" clilen %d, sockfd %d\n", CA->clilen, CA->sockfd);
- printf(" sin_family %d, sin_port %d\n", CA->cl_addr.sin_family,
- CA->cl_addr.sin_port);
- printf(" address: (%x) %s\n", addr, inet_ntoa(CA->cl_addr.sin_addr));
-
- printf(" sin_zero = \"%c%c%c%c%c%c%c%c\"\n",
- CA->cl_addr.sin_zero[0],
- CA->cl_addr.sin_zero[1],
- CA->cl_addr.sin_zero[2],
- CA->cl_addr.sin_zero[3],
- CA->cl_addr.sin_zero[4],
- CA->cl_addr.sin_zero[5],
- CA->cl_addr.sin_zero[6],
- CA->cl_addr.sin_zero[7]);
-
- printf("\n");
-}
-
-//*******************
-
-void WriteTime(char* dst, osc_time_t osctime)
-{
- *(int32_t*)dst = htonl((int32_t)(osctime >> 32));
- *(int32_t*)(dst+4) = htonl((int32_t)osctime);
-}
-
-void WriteMode(char* dst)
-{
- *(int32_t*)dst = htonl(0);
-}
-
-osc_time_t ReadTime(const char* src)
-{
- osc_time_t osctime = ntohl(*(int32_t*)src);
- return (osctime << 32) + ntohl(*(int32_t*)(src+4));
-}
-
-double TimeToSeconds(osc_time_t osctime)
-{
- return (double)osctime * 2.3283064365386962890625e-10 /* 1/2^32 */;
-}
-
-int timeRound(double x)
-{
- return x >= 0.0 ? x+0.5 : x-0.5;
-}
-/*
-void WriteLogicalTime(char* dst)
-{
- static double startTime = -1.0;
- double sTime;
-
- // Initialisierung der Startzeit.
- // Knnte effizienter (ohne 'if') auch irgendwo vorher passieren.
- // Knnte wahrscheinlich auch 0.0 sein.
- if (startTime < 0.0) {
- startTime = clock_getlogicaltime();
- }
-
- sTime = clock_gettimesince(startTime) * 0.001;
- *(int32_t*)dst = hton'K l((int32_t)sTime);
- *(int32_t*)(dst+4) = htonl((int32_t)(4294967296.0 * sTime));
-}
-*/
-
-void WriteLogicalTime(char* dst)
-{
- double sTime = clock_gettimesince(19230720) / 1000.0;
- double tau = sTime - timeRound(sTime);
-
- //fprintf(stderr, "sSec = %f tau = %f\n", sTime, tau);
-
- *(int32_t*)dst = htonl((int32_t)(sTime));
- *(int32_t*)(dst+4) = htonl((int32_t)(4294967296 * tau));
-}
-
-Boolean dumpOSC_SendReply(char *buf, int n, void *clientDesc, int clientDescLenght, int fd)
-{
- if((n == 24) && (strcmp(buf, "#time") == 0))
- {
- osc_time_t t0, t1, t2;
- double dt0, dt1, dt2;
-
- WriteMode(buf+6);
-
- t0 = ReadTime(buf+8);
-
- WriteLogicalTime(buf+16);
- t1 = ReadTime(buf+16); // reverse
- dt0 = TimeToSeconds(t0); // client time
- dt1 = TimeToSeconds(t1); // server time
-
- // fprintf(stderr, "%f\t%f\t%f\n", dt0, dt1, dt0 - dt1);
-
- sendto(fd, buf, n, 0, (struct sockaddr *)clientDesc, clientDescLenght);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-
-//**********************
-
-void dumpOSC_ParsePacket(t_dumpOSC *x, char *buf, int n, ClientAddr returnAddr) {
- // t_dumpOSC *x;
- int size, messageLen, i;
- char *messageName;
- char *args;
-
- //#ifdef PRINTADDRS
- #ifdef DEBUG
- //PrintClientAddr(returnAddr);
- #endif
-
-
- if ((n%4) != 0) {
- complain("SynthControl packet size (%d) not a multiple of 4 bytes: dropping", n);
- return;
- }
-
- if ((n >= 8) && (strncmp(buf, "#bundle", 8) == 0)) {
- /* This is a bundle message. */
- #ifdef DEBUG
- printf("dumpOSC_ParsePacket: bundle msg: bundles not yet supported\n");
- #endif
-
- if (n < 16) {
- complain("Bundle message too small (%d bytes) for time tag", n);
- return;
- }
-
- /* Print the time tag */
- #ifdef DEBUG
- printf("[ %lx%08lx\n", ntohl(*((unsigned long *)(buf+8))), ntohl(*((unsigned long *)(buf+12))));
- #endif
-
- /* Note: if we wanted to actually use the time tag as a little-endian
- 64-bit int, we'd have to word-swap the two 32-bit halves of it */
-
- i = 16; /* Skip "#group\0" and time tag */
-
- while(i<n) {
- size = ntohl(*((int *) (buf + i)));
- if ((size % 4) != 0) {
- complain("Bad size count %d in bundle (not a multiple of 4)", size);
- return;
- }
- if ((size + i + 4) > n) {
- complain("Bad size count %d in bundle (only %d bytes left in entire bundle)",
- size, n-i-4);
- return;
- }
-
- /* Recursively handle element of bundle */
- dumpOSC_ParsePacket(x, buf+i+4, size, returnAddr);
- i += 4 + size;
- }
-
- if (i != n) {
- complain("This can't happen");
- }
- #ifdef DEBUG
- printf("]\n");
- #endif
-
- }
- else if ((n == 24) && (strcmp(buf, "#time") == 0))
- {
- complain("Time message: %s\n :).\n", htm_error_string);
- return;
-
- }
- else
- {
- /* This is not a bundle message */
-
- messageName = buf;
- args = DataAfterAlignedString(messageName, buf+n);
- if (args == 0) {
- complain("Bad message name string: %s\nDropping entire message.\n",
- htm_error_string);
- return;
- }
- messageLen = args-messageName;
- dumpOSC_Smessage(x, messageName, (void *)args, n-messageLen, returnAddr);
- }
-}
-
-#define SMALLEST_POSITIVE_FLOAT 0.000001f
-
-static void dumpOSC_Smessage(t_dumpOSC *x, char *address, void *v, int n, ClientAddr returnAddr) {
- char *chars = v;
- t_atom at;
- //t_atom myargv[50];
-
- int myargc = x->x_outatc;
- t_atom* mya = x->x_outat;
- int myi;
-
-#ifdef DEBUG
- printf("%s ", address);
-#endif
-
- // ztoln+cvt from envgen.c, ggee-0.18 ..
- // outlet_anything's 'symbol' gets set to address
- // so we dont need to append address to the atomlist
- /*
- SETSYMBOL(mya,gensym(address));myargc++;
- x->x_outatc = myargc;
- */
-
- if (n != 0) {
- if (chars[0] == ',') {
- if (chars[1] != ',') {
- /* This message begins with a type-tag string */
- dumpOSC_PrintTypeTaggedArgs(x, v, n);
- } else {
- /* Double comma means an escaped real comma, not a type string */
- dumpOSC_PrintHeuristicallyTypeGuessedArgs(x, v, n, 1);
- }
- } else {
- dumpOSC_PrintHeuristicallyTypeGuessedArgs(x, v, n, 0);
- }
- }
-
- outlet_anything(x->x_msgout,gensym(address),x->x_outatc,(t_atom*)&x->x_outat);
- x->x_outatc = 0;
-#ifdef DEBUG
- printf("\n");
-#endif
- fflush(stdout); /* Added for Sami 5/21/98 */
-}
-
-static void dumpOSC_PrintTypeTaggedArgs(t_dumpOSC *x, void *v, int n) {
- char *typeTags, *thisType;
- char *p;
-
- int myargc = x->x_outatc;
- t_atom* mya = x->x_outat;
- int myi;
-
- typeTags = v;
-
- if (!IsNiceString(typeTags, typeTags+n)) {
- /* No null-termination, so maybe it wasn't a type tag
- string after all */
- dumpOSC_PrintHeuristicallyTypeGuessedArgs(x, v, n, 0);
- return;
- }
-
- p = DataAfterAlignedString(typeTags, typeTags+n);
-
-
- for (thisType = typeTags + 1; *thisType != 0; ++thisType) {
- switch (*thisType) {
- case 'i': case 'r': case 'm': case 'c':
-#ifdef DEBUG
- //post("integer: %d", ntohl(*((int *) p)));
-#endif
- /* Martin Peach fix for negative floats:
- * was: SETFLOAT(mya+myargc,ntohl(*((int *) p)));
- * now is:
- */
- SETFLOAT(mya+myargc,(signed)ntohl(*((int *) p)));
- myargc++;
-
- p += 4;
- break;
-
- case 'f': {
- int i = ntohl(*((int *) p));
- float *floatp = ((float *) (&i));
-#ifdef DEBUG
- post("float: %f", *floatp);
-#endif
- SETFLOAT(mya+myargc,*floatp);
- myargc++;
-
- p += 4;
- }
- break;
-
- case 'h': case 't':
-#ifdef DEBUG
- printf("[A 64-bit int] ");
-#endif
- post("[A 64-bit int] not implemented");
-
- p += 8;
- break;
-
- case 'd':
-#ifdef DEBUG
- printf("[A 64-bit float] ");
-#endif
- post("[A 64-bit float] not implemented");
-
- p += 8;
- break;
-
- case 's': case 'S':
- if (!IsNiceString(p, typeTags+n)) {
- post("Type tag said this arg is a string but it's not!\n");
- return;
- } else {
-#ifdef DEBUG
- post("string: \"%s\"", p);
-#endif
- SETSYMBOL(mya+myargc,gensym(p));
- myargc++;
- //outlet_list(x->x_msgout, 0,sizeof(p), p);
- //outlet_anything(x->x_msgout, 0, sizeof(p), p);
- p = DataAfterAlignedString(p, typeTags+n);
- // append to output vector ..
- }
- break;
-
- case 'T':
-#ifdef DEBUG
- printf("[True] ");
-#endif
- SETFLOAT(mya+myargc,1.);
- myargc++;
- break;
- case 'F':
-#ifdef DEBUG
- printf("[False] ");
-#endif
- SETFLOAT(mya+myargc,0.);
- myargc++;
- break;
- case 'N':
-#ifdef DEBUG
- printf("[Nil]");
-#endif
- post("sendOSC: [Nil] not implemented");
- break;
- case 'I':
-#ifdef DEBUG
- printf("[Infinitum]");
-#endif
- post("sendOSC: [Infinitum] not implemented");
- break;
-
- default:
- post("sendOSC: [Unrecognized type tag %c]", *thisType);
- // return;
- }
- }
- x->x_outatc = myargc;
-}
-
-static void dumpOSC_PrintHeuristicallyTypeGuessedArgs(t_dumpOSC *x, void *v, int n, int skipComma) {
- int i, thisi;
- float thisf;
- int *ints;
- char *chars;
- char *string, *nextString;
-
- int myargc= x->x_outatc;
- t_atom* mya = x->x_outat;
- int myi;
-
-
- /* Go through the arguments 32 bits at a time */
- ints = v;
- chars = v;
-
- for (i = 0; i<n/4; ) {
- string = &chars[i*4];
- thisi = ntohl(ints[i]);
- /* Reinterpret the (potentially byte-reversed) thisi as a float */
- thisf = *(((float *) (&thisi)));
-
- if (thisi >= -1000 && thisi <= 1000000) {
-#ifdef DEBUG
- printf("%d ", thisi);
-#endif
- // append to output vector ..
- SETFLOAT(mya+myargc,(t_float) (thisi));
- myargc++;
- // outlet_float(x->x_msgout, thisi);
- i++;
- } else if (thisf >= -1000.f && thisf <= 1000000.f &&
- (thisf <=0.0f || thisf >= SMALLEST_POSITIVE_FLOAT)) {
-#ifdef DEBUG
- printf("%f ", thisf);
-#endif
- // append to output vector ..
- SETFLOAT(mya+myargc,thisf);
- myargc++;
- //outlet_float(x->x_msgout, thisf);
- i++;
- } else if (IsNiceString(string, chars+n)) {
- nextString = DataAfterAlignedString(string, chars+n);
-#ifdef DEBUG
- printf("\"%s\" ", (i == 0 && skipComma) ? string +1 : string);
-#endif
- // append to output vector ..
- SETSYMBOL(mya+myargc,gensym(string));
- myargc++;
- //outlet_symbol(x->x_msgout, gensym((i == 0 && skipComma) ? string +1 : string));
- i += (nextString-string) / 4;
- } else {
- // unhandled .. ;)
-#ifdef DEBUG
- printf("0x%x xx", ints[i]);
-#endif
- i++;
- }
- x->x_outatc = myargc;
- }
-}
-
-
-#define STRING_ALIGN_PAD 4
-
-char *DataAfterAlignedString(char *string, char *boundary)
-{
- /* The argument is a block of data beginning with a string. The
- string has (presumably) been padded with extra null characters
- so that the overall length is a multiple of STRING_ALIGN_PAD
- bytes. Return a pointer to the next byte after the null
- byte(s). The boundary argument points to the character after
- the last valid character in the buffer---if the string hasn't
- ended by there, something's wrong.
-
- If the data looks wrong, return 0, and set htm_error_string */
-
- int i;
-
- if ((boundary - string) %4 != 0) {
- fprintf(stderr, "Internal error: DataAfterAlignedString: bad boundary\n");
- return 0;
- }
-
- for (i = 0; string[i] != '\0'; i++) {
- if (string + i >= boundary) {
- htm_error_string = "DataAfterAlignedString: Unreasonably long string";
- return 0;
- }
- }
-
- /* Now string[i] is the first null character */
- i++;
-
- for (; (i % STRING_ALIGN_PAD) != 0; i++) {
- if (string + i >= boundary) {
- htm_error_string = "DataAfterAlignedString: Unreasonably long string";
- return 0;
- }
- if (string[i] != '\0') {
- htm_error_string = "DataAfterAlignedString: Incorrectly padded string.";
- return 0;
- }
- }
-
- return string+i;
-}
-
-Boolean IsNiceString(char *string, char *boundary)
-{
- /* Arguments same as DataAfterAlignedString(). Is the given "string"
- really a string? I.e., is it a sequence of isprint() characters
- terminated with 1-4 null characters to align on a 4-byte boundary? */
-
- int i;
-
- if ((boundary - string) %4 != 0) {
- fprintf(stderr, "Internal error: IsNiceString: bad boundary\n");
- return 0;
- }
-
- for (i = 0; string[i] != '\0'; i++) {
- if (!isprint(string[i])) return FALSE;
- if (string + i >= boundary) return FALSE;
- }
-
- /* If we made it this far, it's a null-terminated sequence of printing characters
- in the given boundary. Now we just make sure it's null padded... */
-
- /* Now string[i] is the first null character */
- i++;
- for (; (i % STRING_ALIGN_PAD) != 0; i++) {
- if (string[i] != '\0') return FALSE;
- }
-
- return TRUE;
-}
-
-
-
-
-
-
-
-
-
-#include <stdarg.h>
-void complain(char *s, ...) {
- va_list ap;
- va_start(ap, s);
- fprintf(stderr, "*** ERROR: ");
- vfprintf(stderr, s, ap);
- fprintf(stderr, "\n");
- va_end(ap);
-}
-
-#endif /* __sgi or LINUX or WIN32 */
+
diff --git a/apps/plugins/pdbox/PDa/extra/equalizer.c b/apps/plugins/pdbox/PDa/extra/equalizer.c
index 1d21c4087c..743832302b 100644
--- a/apps/plugins/pdbox/PDa/extra/equalizer.c
+++ b/apps/plugins/pdbox/PDa/extra/equalizer.c
@@ -83,96 +83,4 @@ void equalizer_setup(void)
class_addfloat(equ_class,equ_float);
}
-
-
-
-
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-/*
-
- These filter coefficients computations are taken from
- http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
-
- written by Robert Bristow-Johnson
-
-*/
-
-#include "m_pd.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-#include <math.h>
-#include "filters.h"
-
-
-
-/* ------------------- equ ----------------------------*/
-static t_class *equ_class;
-
-void equ_bang(t_rbjfilter *x)
-{
- t_atom at[5];
- t_float omega = e_omega(x->x_freq,x->x_rate);
- t_float alpha = e_alpha(x->x_bw*0.01,omega);
- t_float b0 = 1 + alpha*e_A(x->x_gain);
- t_float b1 = -2.*cos(omega);
- t_float b2 = 1 - alpha*e_A(x->x_gain);
- t_float a0 = 1 + alpha/e_A(x->x_gain);
- t_float a1 = -2.*cos(omega);
- t_float a2 = 1 - alpha/e_A(x->x_gain);
-
-/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw);*/
-
- if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
- post("equ: filter unstable -> resetting");
- a0=1.;a1=0.;a2=0.;
- b0=1.;b1=0.;b2=0.;
- }
-
- SETFLOAT(at,-a1/a0);
- SETFLOAT(at+1,-a2/a0);
- SETFLOAT(at+2,b0/a0);
- SETFLOAT(at+3,b1/a0);
- SETFLOAT(at+4,b2/a0);
-
- outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
-}
-
-
-void equ_float(t_rbjfilter *x,t_floatarg f)
-{
- x->x_freq = f;
- equ_bang(x);
-}
-
-
-static void *equ_new(t_floatarg f,t_floatarg g,t_floatarg bw)
-{
- t_rbjfilter *x = (t_rbjfilter *)pd_new(equ_class);
-
- x->x_rate = 44100.0;
- outlet_new(&x->x_obj,&s_float);
- floatinlet_new(&x->x_obj, &x->x_gain);
- floatinlet_new(&x->x_obj, &x->x_bw);
- if (f > 0.) x->x_freq = f;
- if (bw > 0.) x->x_bw = bw;
- if (g != 0.) x->x_gain = g;
- return (x);
-}
-
-
-void equalizer_setup(void)
-{
- equ_class = class_new(gensym("equalizer"), (t_newmethod)equ_new, 0,
- sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
- class_addbang(equ_class,equ_bang);
- class_addfloat(equ_class,equ_float);
-}
-
-
-
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/fatom.h b/apps/plugins/pdbox/PDa/extra/fatom.h
index abaf9b91c1..a7a153fad3 100644
--- a/apps/plugins/pdbox/PDa/extra/fatom.h
+++ b/apps/plugins/pdbox/PDa/extra/fatom.h
@@ -483,488 +483,4 @@ static void fatom_setup_common(t_class* class)
class_setsavefn(class,&fatom_save);
#endif
}
-/* ------------------------ fatom ----------------------------- */
-
-#define x_val a_pos.a_w.w_float
-#define DEBUG(x)
-
-#include <string.h>
-#include <stdio.h>
-
-typedef struct _fatom
-{
- t_object x_obj;
- t_atom a_pos; /* the value of the fatom */
-
- t_symbol* x_send;
- t_symbol* x_receive;
- t_glist * x_glist; /* value of the current canvas, intialized in _new */
- int x_rect_width; /* width of the widget */
- int x_rect_height; /* height of the widget */
- t_symbol* x_sym; /* symbol for receiving callbacks from GUI */
- t_symbol* x_type; /* type of fatom (vslider, hslider, checkbutton) */
-
- t_symbol* x_text; /* associated widget text */
- int x_max; /* maximum value of a_pos (x_val) */
- int x_min; /* minimum value of a_pos (x_val) */
- int x_width; /* width of widget (e.g x_rect_height + 15 for hslider, x_rect_width + 15 for slider) */
- t_symbol* x_color;
- t_symbol* x_bgcolor;
-} t_fatom;
-
-/* widget helper functions */
-
-
-
-
-static void draw_inlets(t_fatom *x, t_glist *glist, int firsttime, int nin, int nout)
-{
- int n = nin;
- int nplus, i;
- nplus = (n == 1 ? 1 : n-1);
- DEBUG(post("draw inlet");)
- for (i = 0; i < n; i++)
- {
- int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n",
- glist_getcanvas(glist),
- onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 1,
- onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height,
- x, i);
- else
- sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
- glist_getcanvas(glist), x, i,
- onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 1,
- onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height);
- }
- n = nout;
- nplus = (n == 1 ? 1 : n-1);
- for (i = 0; i < n; i++)
- {
- int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n",
- glist_getcanvas(glist),
- onset, text_ypix(&x->x_obj, glist),
- onset + IOWIDTH, text_ypix(&x->x_obj, glist) + 1,
- x, i);
- else
- sys_vgui(".x%x.c coords %xi%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) + 1);
-
- }
- DEBUG(post("draw inlet end");)
-}
-
-
-static void draw_handle(t_fatom *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%x.c create rectangle %d %d %d %d -tags %xhandle\n",
- glist_getcanvas(glist),
- onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12,
- onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-4,
- x);
- else
- sys_vgui(".x%x.c coords %xhandle %d %d %d %d\n",
- glist_getcanvas(glist), x,
- onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12,
- onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-4);
-}
-
-static void create_widget(t_fatom *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- if (!strcmp(x->x_type->s_name,"vslider")) {
- x->x_rect_width = x->x_width+15;
- x->x_rect_height = x->x_max-x->x_min+26;
-
- sys_vgui("scale .x%x.c.s%x \
- -sliderlength 10 \
- -showvalue 0 \
- -length %d \
- -resolution 0.01 \
- -repeatinterval 20 \
- -from %d -to %d \
- -width %d \
- -bg %s \
- -activebackground %s \
- -troughcolor %s \
- -command fatom_cb%x\n",canvas,x,
- x->x_max-x->x_min+14,
- x->x_max,
- x->x_min,
- x->x_width,
- x->x_color->s_name,
- x->x_color->s_name,
- x->x_bgcolor->s_name,
- x);
- } else if (!strcmp(x->x_type->s_name,"hslider")) {
- x->x_rect_width = x->x_max-x->x_min + 24;
- x->x_rect_height = x->x_width + 15;
- sys_vgui("scale .x%x.c.s%x \
- -sliderlength 10 \
- -showvalue 0 \
- -length %d \
- -resolution 0.01 \
- -orient horizontal \
- -repeatinterval 20 \
- -from %d -to %d \
- -width %d \
- -bg %s \
- -activebackground %s \
- -troughcolor %s \
- -command fatom_cb%x\n",canvas,x,
- x->x_max-x->x_min+14,
- x->x_min,
- x->x_max,
- x->x_width,
- x->x_color->s_name,
- x->x_color->s_name,
- x->x_bgcolor->s_name,
- x);
- } else if (!strcmp(x->x_type->s_name,"checkbutton")) {
- x->x_rect_width = 32;
- x->x_rect_height = 28;
- sys_vgui("checkbutton .x%x.c.s%x \
- -command { fatom_cb%x $fatom_val%x} -variable fatom_val%x -text \"%s\" \
- -bg %s \
- -activebackground %s \
- \n",canvas,x,x,x,x,
- x->x_text->s_name,
- x->x_color->s_name,
- x->x_bgcolor->s_name);
- } else if (!strcmp(x->x_type->s_name,"hradio")) {
- int i;
- x->x_rect_width = 8*20;
- x->x_rect_height = 25;
- for (i=0;i<8;i++) {
- sys_vgui("radiobutton .x%x.c.s%x%d \
- -command { fatom_cb%x $fatom_val%x} -variable fatom_val%x -value %d\n",canvas,x,i,x,x,x,i);
- }
- /* TODO pack them */
- } else if (!strcmp(x->x_type->s_name,"vradio")) {
- int i;
- x->x_rect_width = 30;
- x->x_rect_height = 20*8+5;
- for (i=0;i<8;i++) {
- sys_vgui("radiobutton .x%x.c.s%x%d \
- -command { fatom_cb%x $fatom_val%x} -variable fatom_val%x -value %d\n",canvas,x,i,x,x,x,i);
- }
- /* TODO pack them */
- } else {
- x->x_rect_width = 32;
- x->x_rect_height = 140;
- sys_vgui("scale .x%x.c.s%x \
- -sliderlength 10 \
- -showvalue 0 \
- -length 131 \
- -from 127 -to 0 \
- -command fatom_cb%x\n",canvas,x,x);
- }
-
- /* set the start value */
- if (!strcmp(x->x_type->s_name,"checkbutton")) {
- if (x->x_val)
- sys_vgui(".x%x.c.s%x select\n",canvas,x,x->x_val);
- else
- sys_vgui(".x%x.c.s%x deselect\n",canvas,x,x->x_val);
- } else
- sys_vgui(".x%x.c.s%x set %f\n",canvas,x,x->x_val);
-
-}
-
-
-
-
-
-static void fatom_drawme(t_fatom *x, t_glist *glist, int firsttime)
-{
- t_canvas *canvas=glist_getcanvas(glist);// x->x_glist;//glist_getcanvas(glist);
- DEBUG(post("drawme %d",firsttime);)
- if (firsttime) {
- DEBUG(post("glist %x canvas %x",x->x_glist,canvas));
- create_widget(x,glist);
- x->x_glist = canvas;
- sys_vgui(".x%x.c create window %d %d -anchor nw -window .x%x.c.s%x -tags %xS\n",
- canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)+2,x->x_glist,x,x);
-
- }
- else {
- sys_vgui(".x%x.c coords %xS \
-%d %d\n",
- canvas, x,
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)+2);
- }
- draw_inlets(x, glist, firsttime, 1,1);
- // draw_handle(x, glist, firsttime);
-
-}
-
-
-static void fatom_erase(t_fatom* x,t_glist* glist)
-{
- int n;
-
- DEBUG(post("erase");)
- sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
-
- sys_vgui(".x%x.c delete %xS\n",glist_getcanvas(glist), x);
-
- /* inlets and outlets */
-
- sys_vgui(".x%x.c delete %xi%d\n",glist_getcanvas(glist),x,0);
- sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist),x,0);
- sys_vgui(".x%x.c delete %xhandle\n",glist_getcanvas(glist),x,0);
-}
-
-
-
-/* ------------------------ fatom widgetbehaviour----------------------------- */
-
-
-static void fatom_getrect(t_gobj *z, t_glist *owner,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- int width, height;
- t_fatom* s = (t_fatom*)z;
-
- width = s->x_rect_width;
- height = s->x_rect_height;
- *xp1 = text_xpix(&s->x_obj, owner);
- *yp1 = text_ypix(&s->x_obj, owner);
- *xp2 = text_xpix(&s->x_obj, owner) + width;
- *yp2 = text_ypix(&s->x_obj, owner) + height;
-}
-
-static void fatom_displace(t_gobj *z, t_glist *glist,
- int dx, int dy)
-{
- t_fatom *x = (t_fatom *)z;
- DEBUG(post("displace");)
- x->x_obj.te_xpix += dx;
- x->x_obj.te_ypix += dy;
- if (glist_isvisible(glist))
- {
- 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_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height);
-
- fatom_drawme(x, glist, 0);
- canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
- }
- DEBUG(post("displace end");)
-}
-
-static void fatom_select(t_gobj *z, t_glist *glist, int state)
-{
- t_fatom *x = (t_fatom *)z;
- if (state) {
- sys_vgui(".x%x.c create rectangle \
-%d %d %d %d -tags %xSEL -outline blue\n",
- glist_getcanvas(glist),
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
- text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height,
- x);
- }
- else {
- sys_vgui(".x%x.c delete %xSEL\n",
- glist_getcanvas(glist), x);
- }
-
-
-
-}
-
-
-static void fatom_activate(t_gobj *z, t_glist *glist, int state)
-{
-/* t_text *x = (t_text *)z;
- t_rtext *y = glist_findrtext(glist, x);
- if (z->g_pd != gatom_class) rtext_activate(y, state);*/
-}
-
-static void fatom_delete(t_gobj *z, t_glist *glist)
-{
- t_text *x = (t_text *)z;
- canvas_deletelinesfor(glist_getcanvas(glist), x);
-}
-
-
-static void fatom_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_fatom* s = (t_fatom*)z;
- t_rtext *y;
- DEBUG(post("vis: %d",vis);)
- if (vis) {
-#ifdef PD_MINOR_VERSION
- y = (t_rtext *) rtext_new(glist, (t_text *)z);
-#else
- y = (t_rtext *) rtext_new(glist, (t_text *)z,0,0);
-#endif
- fatom_drawme(s, glist, 1);
- }
- else {
- y = glist_findrtext(glist, (t_text *)z);
- fatom_erase(s,glist);
- rtext_free(y);
- }
-}
-
-static void fatom_save(t_gobj *z, t_binbuf *b);
-
-t_widgetbehavior fatom_widgetbehavior;
-
-
-
-
-static void fatom_size(t_fatom* x,t_floatarg w,t_floatarg h) {
- x->x_rect_width = w;
- x->x_rect_height = h;
-}
-
-static void fatom_color(t_fatom* x,t_symbol* col)
-{
-
-}
-
-
-static void fatom_f(t_fatom* x,t_floatarg f)
-{
- x->x_val = f;
- if (x->x_send == &s_)
- outlet_float(x->x_obj.ob_outlet,f);
- else
- if (x->x_send->s_thing) pd_float(x->x_send->s_thing,f);
-}
-
-
-static void fatom_float(t_fatom* x,t_floatarg f)
-{
- if (glist_isvisible(x->x_glist)) {
- if (!strcmp(x->x_type->s_name,"checkbutton")) {
- if (x->x_val)
- sys_vgui(".x%x.c.s%x select\n",x->x_glist,x,f);
- else
- sys_vgui(".x%x.c.s%x deselect\n",x->x_glist,x,f);
- } else
- sys_vgui(".x%x.c.s%x set %f\n",x->x_glist,x,f);
- }
- fatom_f(x,f);
-}
-
-static void fatom_bang(t_fatom* x,t_floatarg f)
-{
- outlet_float(x->x_obj.ob_outlet,x->x_val);
-}
-
-
-static void fatom_properties(t_gobj *z, t_glist *owner)
-{
- post("N/I");
-}
-
-
-static void fatom_save(t_gobj *z, t_binbuf *b)
-{
-
- t_fatom *x = (t_fatom *)z;
-
- binbuf_addv(b, "ssiiss", gensym("#X"),gensym("obj"),
- x->x_obj.te_xpix, x->x_obj.te_ypix ,
- gensym("fatom"),x->x_type);
- binbuf_addv(b, ";");
-}
-
-
-static void *fatom_new(t_fatom* x,int argc,t_atom* argv)
-{
- char buf[256];
- int n = 0;
- x->x_glist = canvas_getcurrent();
-
- x->x_text = gensym("");
- x->x_max = 127;
- x->x_min = 0;
- x->x_width = 15;
- x->x_color = gensym("grey");
- x->x_bgcolor = gensym("grey");
- x->x_send = &s_;
-
- while (argc) {
- if (argv->a_type == A_FLOAT) {
- if (n==0) x->x_max = atom_getfloat(argv);
- if (n==1) x->x_min = atom_getfloat(argv);
- if (n==2) x->x_width = atom_getfloat(argv);
- }
-
- if (argv->a_type == A_SYMBOL) {
- post("%d: symbol value %s",n,atom_getsymbol(argv)->s_name);
- if (n==3) x->x_send = atom_getsymbol(argv);
- if (n==4) x->x_color = atom_getsymbol(argv);
- if (n==5) x->x_bgcolor = atom_getsymbol(argv);
- }
- argv++;
- argc--;
- n++;
- }
-
- /* bind to a symbol for slider callback (later make this based on the
- filepath ??) */
-
- sprintf(buf,"fatom%x",(t_int)x);
- x->x_sym = gensym(buf);
- pd_bind(&x->x_obj.ob_pd, x->x_sym);
-
- /* pipe startup code to tk */
-
- sys_vgui("proc fatom_cb%x {v} {\n pd [concat fatom%x f $v \\;]\n }\n",x,x);
-
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-static void fatom_setup_common(t_class* class)
-{
-
- fatom_widgetbehavior.w_getrectfn = fatom_getrect;
- fatom_widgetbehavior.w_displacefn = fatom_displace;
- fatom_widgetbehavior.w_selectfn = fatom_select;
- fatom_widgetbehavior.w_activatefn = fatom_activate;
- fatom_widgetbehavior.w_deletefn = fatom_delete;
- fatom_widgetbehavior.w_visfn = fatom_vis;
-#if PD_MINOR_VERSION < 37
- fatom_widgetbehavior.w_savefn = fatom_save;
- fatom_widgetbehavior.w_propertiesfn = NULL;
-#endif
- fatom_widgetbehavior.w_clickfn = NULL;
-
- class_addfloat(class, (t_method)fatom_float);
- class_addbang(class, (t_method)fatom_bang);
- class_addmethod(class, (t_method)fatom_f, gensym("f"),
- A_FLOAT, 0);
-
-/*
- class_addmethod(class, (t_method)fatom_size, gensym("size"),
- A_FLOAT, A_FLOAT, 0);
-
- class_addmethod(class, (t_method)fatom_color, gensym("color"),
- A_SYMBOL, 0);
-*/
-/*
- class_addmethod(class, (t_method)fatom_open, gensym("open"),
- A_SYMBOL, 0);
-*/
-
- class_setwidget(class,&fatom_widgetbehavior);
-#if PD_MINOR_VERSION >= 37
- class_setsavefn(class,&fatom_save);
-#endif
-}
diff --git a/apps/plugins/pdbox/PDa/extra/filters.h b/apps/plugins/pdbox/PDa/extra/filters.h
index 72d997e425..8a91f75073 100644
--- a/apps/plugins/pdbox/PDa/extra/filters.h
+++ b/apps/plugins/pdbox/PDa/extra/filters.h
@@ -72,77 +72,4 @@ stable:
#endif
-/*
-
- These filter coefficients computations are taken from
- http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
-
- written by Robert Bristow-Johnson
-
-*/
-
-
-#ifndef __GGEE_FILTERS_H__
-#define __GGEE_FILTERS_H__
-
-
-
-#ifndef M_PI
-#define M_PI 3.141593f
-#endif
-
-
-#include <math.h>
-#define LN2 0.69314718
-#define e_A(g) (pow(10,(g/40.)))
-#define e_omega(f,r) (2.0*M_PI*f/r)
-#define e_alpha(bw,omega) (sin(omega)*sinh(LN2/2. * bw * omega/sin(omega)))
-#define e_beta(a,S) (sqrt((a*a + 1)/(S) - (a-1)*(a-1)))
-
-
-
-
-typedef struct _rbjfilter
-{
- t_object x_obj;
- t_float x_rate;
- t_float x_freq;
- t_float x_gain;
- t_float x_bw;
-} t_rbjfilter;
-
-
-static int check_stability(t_float fb1,
- t_float fb2,
- t_float ff1,
- t_float ff2,
- t_float ff3)
-{
- float discriminant = fb1 * fb1 + 4 * fb2;
-
- if (discriminant < 0) /* imaginary roots -- resonant filter */
- {
- /* they're conjugates so we just check that the product
- is less than one */
- if (fb2 >= -1.0f) goto stable;
- }
- else /* real roots */
- {
- /* check that the parabola 1 - fb1 x - fb2 x^2 has a
- vertex between -1 and 1, and that it's nonnegative
- at both ends, which implies both roots are in [1-,1]. */
- if (fb1 <= 2.0f && fb1 >= -2.0f &&
- 1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0)
- goto stable;
- }
- return 0;
-stable:
- return 1;
-}
-
-
-
-
-
-
-#endif
+
diff --git a/apps/plugins/pdbox/PDa/extra/g_canvas.h b/apps/plugins/pdbox/PDa/extra/g_canvas.h
index 54ab985feb..9fc580da08 100644
--- a/apps/plugins/pdbox/PDa/extra/g_canvas.h
+++ b/apps/plugins/pdbox/PDa/extra/g_canvas.h
@@ -600,605 +600,4 @@ EXTERN t_symbol *iemgui_dollar2raute(t_symbol *s);
#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
}
#endif
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* this file defines the structure for "glists" and related structures and
-functions. "Glists" and "canvases" and "graphs" used to be different
-structures until being unified in version 0.35.
-
-A glist occupies its own window if the "gl_havewindow" flag is set. Its
-appearance on its "parent" or "owner" (if it has one) is as a graph if
-"gl_isgraph" is set, and otherwise as a text box.
-
-A glist is "root" if it has no owner, i.e., a document window. In this
-case "gl_havewindow" is always set.
-
-We maintain a list of root windows, so that we can traverse the whole
-collection of everything in a Pd process.
-
-If a glist has a window it may still not be "mapped." Miniaturized
-windows aren't mapped, for example, but a window is also not mapped
-immediately upon creation. In either case gl_havewindow is true but
-gl_mapped is false.
-
-Closing a non-root window makes it invisible; closing a root destroys it.
-
-A glist that's just a text object on its parent is always "toplevel." An
-embedded glist can switch back and forth to appear as a toplevel by double-
-clicking on it. Single-clicking a text box makes the toplevel become visible
-and raises the window it's in.
-
-If a glist shows up as a graph on its parent, the graph is blanked while the
-glist has its own window, even if miniaturized.
-
-*/
-
-/* NOTE: this file describes Pd implementation details which may change
-in future releases. The public (stable) API is in m_pd.h. */
-
-#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
-extern "C" {
-#endif
-
-/* --------------------- geometry ---------------------------- */
-#define IOWIDTH 7 /* width of an inlet/outlet in pixels */
-#define IOMIDDLE ((IOWIDTH-1)/2)
-#define GLIST_DEFGRAPHWIDTH 200
-#define GLIST_DEFGRAPHHEIGHT 140
-/* ----------------------- data ------------------------------- */
-
-typedef struct _updateheader
-{
- struct _updateheader *upd_next;
- unsigned int upd_array:1; /* true if array, false if glist */
- unsigned int upd_queued:1; /* true if we're queued */
-} t_updateheader;
-
- /* types to support glists grabbing mouse motion or keys from parent */
-typedef void (*t_glistmotionfn)(void *z, t_floatarg dx, t_floatarg dy);
-typedef void (*t_glistkeyfn)(void *z, t_floatarg key);
-
-EXTERN_STRUCT _rtext;
-#define t_rtext struct _rtext
-EXTERN_STRUCT _gtemplate;
-#define t_gtemplate struct _gtemplate
-
-EXTERN_STRUCT _guiconnect;
-#define t_guiconnect struct _guiconnect
-
-EXTERN_STRUCT _tscalar;
-#define t_tscalar struct _tscalar
-
-EXTERN_STRUCT _canvasenvironment;
-#define t_canvasenvironment struct _canvasenvironment
-
-typedef struct _selection
-{
- t_gobj *sel_what;
- struct _selection *sel_next;
-} t_selection;
-
- /* this structure is instantiated whenever a glist becomes visible. */
-typedef struct _editor
-{
- t_updateheader e_upd; /* update header structure */
- t_selection *e_updlist; /* list of objects to update */
- t_rtext *e_rtext; /* text responder linked list */
- t_selection *e_selection; /* head of the selection list */
- t_rtext *e_textedfor; /* the rtext if any that we are editing */
- t_gobj *e_grab; /* object being "dragged" */
- t_glistmotionfn e_motionfn; /* ... motion callback */
- t_glistkeyfn e_keyfn; /* ... keypress callback */
- t_binbuf *e_connectbuf; /* connections to deleted objects */
- t_binbuf *e_deleted; /* last stuff we deleted */
- t_guiconnect *e_guiconnect; /* GUI connection for filtering messages */
- struct _glist *e_glist; /* glist which owns this */
- int e_xwas; /* xpos on last mousedown or motion event */
- int e_ywas; /* ypos, similarly */
- int e_selectline_index1; /* indices for the selected line if any */
- int e_selectline_outno; /* (only valid if e_selectedline is set) */
- int e_selectline_index2;
- int e_selectline_inno;
- t_outconnect *e_selectline_tag;
- unsigned int e_onmotion: 3; /* action to take on motion */
- unsigned int e_lastmoved: 1; /* one if mouse has moved since click */
- unsigned int e_textdirty: 1; /* one if e_textedfor has changed */
- unsigned int e_selectedline: 1; /* one if a line is selected */
-} t_editor;
-
-#define MA_NONE 0 /* e_onmotion: do nothing on mouse motion */
-#define MA_MOVE 1 /* drag the selection around */
-#define MA_CONNECT 2 /* make a connection */
-#define MA_REGION 3 /* selection region */
-#define MA_PASSOUT 4 /* send on to e_grab */
-#define MA_DRAGTEXT 5 /* drag in text editor to alter selection */
-
-/* editor structure for "garrays". We don't bother to delete and regenerate
-this structure when the "garray" becomes invisible or visible, although we
-could do so if the structure gets big (like the "editor" above.) */
-
-typedef struct _arrayvis
-{
- t_updateheader av_upd; /* update header structure */
- t_garray *av_garray; /* owning structure */
-} t_arrayvis;
-
-/* the t_tick structure describes where to draw x and y "ticks" for a glist */
-
-typedef struct _tick /* where to put ticks on x or y axes */
-{
- float k_point; /* one point to draw a big tick at */
- float k_inc; /* x or y increment per little tick */
- int k_lperb; /* little ticks per big; 0 if no ticks to draw */
-} t_tick;
-
-/* the t_glist structure, which describes a list of elements that live on an
-area of a window.
-
-*/
-
-struct _glist
-{
- t_object gl_obj; /* header in case we're a glist */
- t_gobj *gl_list; /* the actual data */
- struct _gstub *gl_stub; /* safe pointer handler */
- int gl_valid; /* incremented when pointers might be stale */
- struct _glist *gl_owner; /* parent glist, supercanvas, or 0 if none */
- int gl_pixwidth; /* width in pixels (on parent, if a graph) */
- int gl_pixheight;
- float gl_x1; /* bounding rectangle in our own coordinates */
- float gl_y1;
- float gl_x2;
- float gl_y2;
- int gl_screenx1; /* screen coordinates when toplevel */
- int gl_screeny1;
- int gl_screenx2;
- int gl_screeny2;
- t_tick gl_xtick; /* ticks marking X values */
- int gl_nxlabels; /* number of X coordinate labels */
- t_symbol **gl_xlabel; /* ... an array to hold them */
- float gl_xlabely; /* ... and their Y coordinates */
- t_tick gl_ytick; /* same as above for Y ticks and labels */
- int gl_nylabels;
- t_symbol **gl_ylabel;
- float gl_ylabelx;
- t_editor *gl_editor; /* editor structure when visible */
- t_symbol *gl_name; /* symbol bound here */
- int gl_font; /* nominal font size in points, e.g., 10 */
- struct _glist *gl_next; /* link in list of toplevels */
- t_canvasenvironment *gl_env; /* root canvases and abstractions only */
- unsigned int gl_havewindow:1; /* true if we own a window */
- unsigned int gl_mapped:1; /* true if, moreover, it's "mapped" */
- unsigned int gl_dirty:1; /* (root canvas only:) patch has changed */
- unsigned int gl_loading:1; /* am now loading from file */
- unsigned int gl_willvis:1; /* make me visible after loading */
- unsigned int gl_edit:1; /* edit mode */
- unsigned int gl_isdeleting:1; /* we're inside glist_delete -- hack! */
- unsigned int gl_stretch:1; /* stretch contents on resize */
- unsigned int gl_isgraph:1; /* show as graph on parent */
-};
-
-#define gl_gobj gl_obj.te_g
-#define gl_pd gl_gobj.g_pd
-
-/* a data structure to describe a field in a pure datum */
-
-#define DT_FLOAT 0
-#define DT_SYMBOL 1
-#define DT_LIST 2
-#define DT_ARRAY 3
-
-typedef struct _dataslot
-{
- int ds_type;
- t_symbol *ds_name;
- t_symbol *ds_arraytemplate; /* filled in for arrays only */
-} t_dataslot;
-
-
-/* T.Grill - changed t_pd member to t_pdobj to avoid name clashed */
-typedef struct _template
-{
- t_pd t_pdobj; /* header */
- struct _gtemplate *t_list; /* list of "struct"/gtemplate objects */
- t_symbol *t_sym; /* name */
- int t_n; /* number of dataslots (fields) */
- t_dataslot *t_vec; /* array of dataslots */
-} t_template;
-
-struct _array
-{
- int a_n; /* number of elements */
- int a_elemsize; /* size in bytes; LATER get this from template */
- char *a_vec; /* array of elements */
- t_symbol *a_templatesym; /* template for elements */
- int a_valid; /* protection against stale pointers into array */
- t_gpointer a_gp; /* pointer to scalar or array element we're in */
- t_gstub *a_stub;
-};
-
- /* structure for traversing all the connections in a glist */
-typedef struct _linetraverser
-{
- t_canvas *tr_x;
- t_object *tr_ob;
- int tr_nout;
- int tr_outno;
- t_object *tr_ob2;
- t_outlet *tr_outlet;
- t_inlet *tr_inlet;
- int tr_nin;
- int tr_inno;
- int tr_x11, tr_y11, tr_x12, tr_y12;
- int tr_x21, tr_y21, tr_x22, tr_y22;
- int tr_lx1, tr_ly1, tr_lx2, tr_ly2;
- t_outconnect *tr_nextoc;
- int tr_nextoutno;
-} t_linetraverser;
-
-/* function types used to define graphical behavior for gobjs, a bit like X
-widgets. We don't use Pd methods because Pd's typechecking can't specify the
-types of pointer arguments. Also it's more convenient this way, since
-every "patchable" object can just get the "text" behaviors. */
-
- /* Call this to get a gobj's bounding rectangle in pixels */
-typedef void (*t_getrectfn)(t_gobj *x, struct _glist *glist,
- int *x1, int *y1, int *x2, int *y2);
- /* and this to displace a gobj: */
-typedef void (*t_displacefn)(t_gobj *x, struct _glist *glist, int dx, int dy);
- /* change color to show selection: */
-typedef void (*t_selectfn)(t_gobj *x, struct _glist *glist, int state);
- /* change appearance to show activation/deactivation: */
-typedef void (*t_activatefn)(t_gobj *x, struct _glist *glist, int state);
- /* warn a gobj it's about to be deleted */
-typedef void (*t_deletefn)(t_gobj *x, struct _glist *glist);
- /* making visible or invisible */
-typedef void (*t_visfn)(t_gobj *x, struct _glist *glist, int flag);
- /* field a mouse click (when not in "edit" mode) */
-typedef int (*t_clickfn)(t_gobj *x, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit);
- /* ... and later, resizing; getting/setting font or color... */
-
-struct _widgetbehavior
-{
- t_getrectfn w_getrectfn;
- t_displacefn w_displacefn;
- t_selectfn w_selectfn;
- t_activatefn w_activatefn;
- t_deletefn w_deletefn;
- t_visfn w_visfn;
- t_clickfn w_clickfn;
-};
-
-/* -------- behaviors for scalars defined by objects in template --------- */
-/* these are set by "drawing commands" in g_template.c which add appearance to
-scalars, which live in some other window. If the scalar is just included
-in a canvas the "parent" is a misnomer. There is also a text scalar object
-which really does draw the scalar on the parent window; see g_scalar.c. */
-
-/* note how the click function wants the whole scalar, not the "data", so
-doesn't work on array elements... LATER reconsider this */
-
- /* bounding rectangle: */
-typedef void (*t_parentgetrectfn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int *x1, int *y1, int *x2, int *y2);
- /* displace it */
-typedef void (*t_parentdisplacefn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int dx, int dy);
- /* change color to show selection */
-typedef void (*t_parentselectfn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int state);
- /* change appearance to show activation/deactivation: */
-typedef void (*t_parentactivatefn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int state);
- /* making visible or invisible */
-typedef void (*t_parentvisfn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int flag);
- /* field a mouse click */
-typedef int (*t_parentclickfn)(t_gobj *x, struct _glist *glist,
- t_scalar *sc, t_template *tmpl, float basex, float basey,
- int xpix, int ypix, int shift, int alt, int dbl, int doit);
-
-struct _parentwidgetbehavior
-{
- t_parentgetrectfn w_parentgetrectfn;
- t_parentdisplacefn w_parentdisplacefn;
- t_parentselectfn w_parentselectfn;
- t_parentactivatefn w_parentactivatefn;
- t_parentvisfn w_parentvisfn;
- t_parentclickfn w_parentclickfn;
-};
-
- /* cursor definitions; used as return value for t_parentclickfn */
-#define CURSOR_RUNMODE_NOTHING 0
-#define CURSOR_RUNMODE_CLICKME 1
-#define CURSOR_RUNMODE_THICKEN 2
-#define CURSOR_RUNMODE_ADDPOINT 3
-#define CURSOR_EDITMODE_NOTHING 4
-#define CURSOR_EDITMODE_CONNECT 5
-#define CURSOR_EDITMODE_DISCONNECT 6
-EXTERN void canvas_setcursor(t_glist *x, unsigned int cursornum);
-
-extern t_canvas *canvas_editing; /* last canvas to start text edting */
-extern t_canvas *canvas_whichfind; /* last canvas we did a find in */
-extern t_canvas *canvas_list; /* list of all root canvases */
-extern t_class *vinlet_class, *voutlet_class;
-extern int glist_valid; /* incremented when pointers might be stale */
-
-/* ------------------- functions on any gobj ----------------------------- */
-EXTERN void gobj_getrect(t_gobj *x, t_glist *owner, int *x1, int *y1,
- int *x2, int *y2);
-EXTERN void gobj_displace(t_gobj *x, t_glist *owner, int dx, int dy);
-EXTERN void gobj_select(t_gobj *x, t_glist *owner, int state);
-EXTERN void gobj_activate(t_gobj *x, t_glist *owner, int state);
-EXTERN void gobj_delete(t_gobj *x, t_glist *owner);
-EXTERN void gobj_vis(t_gobj *x, t_glist *glist, int flag);
-EXTERN int gobj_click(t_gobj *x, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit);
-EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
-EXTERN void gobj_properties(t_gobj *x, struct _glist *glist);
-EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
-
-/* -------------------- functions on glists --------------------- */
-EXTERN t_glist *glist_new( void);
-EXTERN void glist_init(t_glist *x);
-EXTERN void glist_add(t_glist *x, t_gobj *g);
-EXTERN void glist_cleanup(t_glist *x);
-EXTERN void glist_free(t_glist *x);
-
-EXTERN void glist_clear(t_glist *x);
-EXTERN t_canvas *glist_getcanvas(t_glist *x);
-EXTERN int glist_isselected(t_glist *x, t_gobj *y);
-EXTERN void glist_select(t_glist *x, t_gobj *y);
-EXTERN void glist_deselect(t_glist *x, t_gobj *y);
-EXTERN void glist_noselect(t_glist *x);
-EXTERN void glist_selectall(t_glist *x);
-EXTERN void glist_delete(t_glist *x, t_gobj *y);
-EXTERN void glist_retext(t_glist *x, t_text *y);
-EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
- t_glistkeyfn keyfn, int xpos, int ypos);
-EXTERN int glist_isvisible(t_glist *x);
-EXTERN int glist_istoplevel(t_glist *x);
-EXTERN t_glist *glist_findgraph(t_glist *x);
-EXTERN int glist_getfont(t_glist *x);
-EXTERN void glist_sort(t_glist *canvas);
-EXTERN void glist_read(t_glist *x, t_symbol *filename, t_symbol *format);
-EXTERN void glist_mergefile(t_glist *x, t_symbol *filename, t_symbol *format);
-
-EXTERN float glist_pixelstox(t_glist *x, float xpix);
-EXTERN float glist_pixelstoy(t_glist *x, float ypix);
-EXTERN float glist_xtopixels(t_glist *x, float xval);
-EXTERN float glist_ytopixels(t_glist *x, float yval);
-EXTERN float glist_dpixtodx(t_glist *x, float dxpix);
-EXTERN float glist_dpixtody(t_glist *x, float dypix);
-
-EXTERN void glist_redrawitem(t_glist *owner, t_gobj *gobj);
-EXTERN void glist_getnextxy(t_glist *gl, int *xval, int *yval);
-EXTERN void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv);
-EXTERN t_glist *glist_addglist(t_glist *g, t_symbol *sym,
- float x1, float y1, float x2, float y2,
- float px1, float py1, float px2, float py2);
-EXTERN void glist_arraydialog(t_glist *parent, t_symbol *name,
- t_floatarg size, t_floatarg saveit, t_floatarg newgraph);
-EXTERN t_binbuf *glist_writetobinbuf(t_glist *x, int wholething);
-EXTERN int glist_isgraph(t_glist *x);
-EXTERN void glist_redraw(t_glist *x);
-EXTERN void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
- char *tag, int x1, int y1, int x2, int y2);
-EXTERN void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag);
-EXTERN void canvas_create_editor(t_glist *x, int createit);
-void canvas_deletelinesforio(t_canvas *x, t_text *text,
- t_inlet *inp, t_outlet *outp);
-
-
-/* -------------------- functions on texts ------------------------- */
-EXTERN void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize);
-EXTERN void text_drawborder(t_text *x, t_glist *glist, char *tag,
- int width, int height, int firsttime);
-EXTERN void text_eraseborder(t_text *x, t_glist *glist, char *tag);
-EXTERN int text_xcoord(t_text *x, t_glist *glist);
-EXTERN int text_ycoord(t_text *x, t_glist *glist);
-EXTERN int text_xpix(t_text *x, t_glist *glist);
-EXTERN int text_ypix(t_text *x, t_glist *glist);
-EXTERN int text_shouldvis(t_text *x, t_glist *glist);
-
-/* -------------------- functions on rtexts ------------------------- */
-#define RTEXT_DOWN 1
-#define RTEXT_DRAG 2
-#define RTEXT_DBL 3
-#define RTEXT_SHIFT 4
-
-EXTERN t_rtext *rtext_new(t_glist *glist, t_text *who);
-EXTERN t_rtext *glist_findrtext(t_glist *gl, t_text *who);
-EXTERN void rtext_draw(t_rtext *x);
-EXTERN void rtext_erase(t_rtext *x);
-EXTERN t_rtext *rtext_remove(t_rtext *first, t_rtext *x);
-EXTERN int rtext_height(t_rtext *x);
-EXTERN void rtext_displace(t_rtext *x, int dx, int dy);
-EXTERN void rtext_select(t_rtext *x, int state);
-EXTERN void rtext_activate(t_rtext *x, int state);
-EXTERN void rtext_free(t_rtext *x);
-EXTERN void rtext_key(t_rtext *x, int n, t_symbol *s);
-EXTERN void rtext_mouse(t_rtext *x, int xval, int yval, int flag);
-EXTERN void rtext_retext(t_rtext *x);
-EXTERN int rtext_width(t_rtext *x);
-EXTERN int rtext_height(t_rtext *x);
-EXTERN char *rtext_gettag(t_rtext *x);
-EXTERN void rtext_gettext(t_rtext *x, char **buf, int *bufsize);
-
-/* -------------------- functions on canvases ------------------------ */
-EXTERN t_class *canvas_class;
-
-EXTERN t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv);
-EXTERN t_symbol *canvas_makebindsym(t_symbol *s);
-EXTERN void canvas_vistext(t_canvas *x, t_text *y);
-EXTERN void canvas_fixlinesfor(t_canvas *x, t_text *text);
-EXTERN void canvas_deletelinesfor(t_canvas *x, t_text *text);
-EXTERN void canvas_stowconnections(t_canvas *x);
-EXTERN void canvas_restoreconnections(t_canvas *x);
-EXTERN void canvas_redraw(t_canvas *x);
-
-EXTERN t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *sym);
-EXTERN void canvas_rminlet(t_canvas *x, t_inlet *ip);
-EXTERN t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *sym);
-EXTERN void canvas_rmoutlet(t_canvas *x, t_outlet *op);
-EXTERN void canvas_redrawallfortemplate(t_canvas *tmpl);
-EXTERN void canvas_zapallfortemplate(t_canvas *tmpl);
-EXTERN void canvas_setusedastemplate(t_canvas *x);
-EXTERN t_canvas *canvas_getcurrent(void);
-EXTERN void canvas_setcurrent(t_canvas *x);
-EXTERN void canvas_unsetcurrent(t_canvas *x);
-EXTERN t_symbol *canvas_realizedollar(t_canvas *x, t_symbol *s);
-EXTERN t_canvas *canvas_getrootfor(t_canvas *x);
-EXTERN void canvas_dirty(t_canvas *x, t_int n);
-EXTERN int canvas_getfont(t_canvas *x);
-typedef int (*t_canvasapply)(t_canvas *x, t_int x1, t_int x2, t_int x3);
-
-EXTERN t_int *canvas_recurapply(t_canvas *x, t_canvasapply *fn,
- t_int x1, t_int x2, t_int x3);
-
-EXTERN void canvas_resortinlets(t_canvas *x);
-EXTERN void canvas_resortoutlets(t_canvas *x);
-EXTERN void canvas_free(t_canvas *x);
-EXTERN void canvas_updatewindowlist( void);
-EXTERN void canvas_editmode(t_canvas *x, t_floatarg yesplease);
-EXTERN int canvas_isabstraction(t_canvas *x);
-EXTERN int canvas_istable(t_canvas *x);
-EXTERN int canvas_showtext(t_canvas *x);
-EXTERN void canvas_vis(t_canvas *x, t_floatarg f);
-EXTERN t_canvasenvironment *canvas_getenv(t_canvas *x);
-EXTERN void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir);
-EXTERN void canvas_loadbang(t_canvas *x);
-EXTERN int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos,
- int *x1p, int *y1p, int *x2p, int *y2p);
-EXTERN int canvas_setdeleting(t_canvas *x, int flag);
-
-typedef void (*t_undofn)(t_canvas *canvas, void *buf,
- int action); /* a function that does UNDO/REDO */
-#define UNDO_FREE 0 /* free current undo/redo buffer */
-#define UNDO_UNDO 1 /* undo */
-#define UNDO_REDO 2 /* redo */
-EXTERN void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
- const char *name);
-EXTERN void canvas_noundo(t_canvas *x);
-EXTERN int canvas_getindex(t_canvas *x, t_gobj *y);
-
-/* T.Grill - made public for dynamic object creation */
-/* in g_editor.c */
-EXTERN void canvas_connect(t_canvas *x,
- t_floatarg fwhoout, t_floatarg foutno,t_floatarg fwhoin, t_floatarg finno);
-EXTERN void canvas_disconnect(t_canvas *x,
- float index1, float outno, float index2, float inno);
-EXTERN int canvas_isconnected (t_canvas *x,
- t_text *ob1, int n1, t_text *ob2, int n2);
-EXTERN void canvas_selectinrect(t_canvas *x, int lox, int loy, int hix, int hiy);
-
-
-/* ---- functions on canvasses as objects --------------------- */
-
-EXTERN void canvas_fattenforscalars(t_canvas *x,
- int *x1, int *y1, int *x2, int *y2);
-EXTERN void canvas_visforscalars(t_canvas *x, t_glist *glist, int vis);
-EXTERN int canvas_clicksub(t_canvas *x, int xpix, int ypix, int shift,
- int alt, int dbl, int doit);
-EXTERN t_glist *canvas_getglistonsuper(void);
-
-EXTERN void linetraverser_start(t_linetraverser *t, t_canvas *x);
-EXTERN t_outconnect *linetraverser_next(t_linetraverser *t);
-EXTERN void linetraverser_skipobject(t_linetraverser *t);
-
-/* --------------------- functions on tscalars --------------------- */
-
-EXTERN void tscalar_getrect(t_tscalar *x, t_glist *owner,
- int *xp1, int *yp1, int *xp2, int *yp2);
-EXTERN void tscalar_vis(t_tscalar *x, t_glist *owner, int flag);
-EXTERN int tscalar_click(t_tscalar *x, int xpix, int ypix, int shift,
- int alt, int dbl, int doit);
-
-/* --------- functions on garrays (graphical arrays) -------------------- */
-
-EXTERN t_template *garray_template(t_garray *x);
-
-/* -------------------- arrays --------------------- */
-EXTERN t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *tmpl,
- t_floatarg f, t_floatarg saveit);
-EXTERN t_array *array_new(t_symbol *templatesym, t_gpointer *parent);
-EXTERN void array_resize(t_array *x, t_template *tmpl, int n);
-EXTERN void array_free(t_array *x);
-
-/* --------------------- gpointers and stubs ---------------- */
-EXTERN t_gstub *gstub_new(t_glist *gl, t_array *a);
-EXTERN void gstub_cutoff(t_gstub *gs);
-EXTERN void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x);
-
-/* --------------------- scalars ------------------------- */
-EXTERN void word_init(t_word *wp, t_template *tmpl, t_gpointer *gp);
-EXTERN void word_restore(t_word *wp, t_template *tmpl,
- int argc, t_atom *argv);
-EXTERN t_scalar *scalar_new(t_glist *owner,
- t_symbol *templatesym);
-EXTERN void scalar_getbasexy(t_scalar *x, float *basex, float *basey);
-
-/* ------helper routines for "garrays" and "plots" -------------- */
-EXTERN int array_doclick(t_array *array, t_glist *glist, t_gobj *gobj,
- t_symbol *elemtemplatesym,
- float linewidth, float xloc, float xinc, float yloc,
- int xpix, int ypix, int shift, int alt, int dbl, int doit);
-
-EXTERN void array_getcoordinate(t_glist *glist,
- char *elem, int xonset, int yonset, int wonset, int indx,
- float basex, float basey, float xinc,
- float *xp, float *yp, float *wp);
-
-EXTERN int array_getfields(t_symbol *elemtemplatesym,
- t_canvas **elemtemplatecanvasp,
- t_template **elemtemplatep, int *elemsizep,
- int *xonsetp, int *yonsetp, int *wonsetp);
-
-/* --------------------- templates ------------------------- */
-EXTERN t_template *template_new(t_symbol *sym, int argc, t_atom *argv);
-EXTERN void template_free(t_template *x);
-EXTERN int template_match(t_template *x1, t_template *x2);
-EXTERN int template_find_field(t_template *x, t_symbol *name, int *p_onset,
- int *p_type, t_symbol **p_arraytype);
-EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname, t_word *wp,
- int loud);
-EXTERN void template_setfloat(t_template *x, t_symbol *fieldname, t_word *wp,
- t_float f, int loud);
-EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
- t_word *wp, int loud);
-EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
- t_word *wp, t_symbol *s, int loud);
-
-EXTERN t_template *gtemplate_get(t_gtemplate *x);
-EXTERN t_template *template_findbyname(t_symbol *s);
-EXTERN t_canvas *template_findcanvas(t_template *tmpl);
-
-EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname,
- t_word *wp, int loud);
-EXTERN void template_setfloat(t_template *x, t_symbol *fieldname,
- t_word *wp, t_float f, int loud);
-EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
- t_word *wp, int loud);
-EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
- t_word *wp, t_symbol *s, int loud);
-
-/* ----------------------- guiconnects, g_guiconnect.c --------- */
-EXTERN t_guiconnect *guiconnect_new(t_pd *who, t_symbol *sym);
-EXTERN void guiconnect_notarget(t_guiconnect *x, double timedelay);
-
-/* ------------- IEMGUI routines used in other g_ files ---------------- */
-EXTERN t_symbol *iemgui_raute2dollar(t_symbol *s);
-EXTERN t_symbol *iemgui_dollar2raute(t_symbol *s);
-
-#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
-}
-#endif
diff --git a/apps/plugins/pdbox/PDa/extra/gcanvas-help.pd b/apps/plugins/pdbox/PDa/extra/gcanvas-help.pd
index e0e3fd6f4d..2844911261 100644
--- a/apps/plugins/pdbox/PDa/extra/gcanvas-help.pd
+++ b/apps/plugins/pdbox/PDa/extra/gcanvas-help.pd
@@ -6,11 +6,4 @@
#X floatatom 94 147 5 0 0 0 - - -;
#X connect 0 0 3 0;
#X connect 0 1 4 0;
-#N canvas 0 0 240 300 8;
-#X obj 21 61 gcanvas 80 80;
-#X text 14 9 gcanvas .. mouse coordinate enabled canvas;
-#X text 13 22 ==========================================;
-#X floatatom 21 148 5 0 0 0 - - -;
-#X floatatom 94 147 5 0 0 0 - - -;
-#X connect 0 0 3 0;
-#X connect 0 1 4 0;
+
diff --git a/apps/plugins/pdbox/PDa/extra/gcanvas.c b/apps/plugins/pdbox/PDa/extra/gcanvas.c
index aed5c96cec..9e3f934299 100644
--- a/apps/plugins/pdbox/PDa/extra/gcanvas.c
+++ b/apps/plugins/pdbox/PDa/extra/gcanvas.c
@@ -376,383 +376,4 @@ void gcanvas_setup(void)
class_setwidget(gcanvas_class,&gcanvas_widgetbehavior);
}
-
-/* (C) Guenter Geiger <geiger@xdv.org> */
-
-
-#include "m_pd.h"
-#include "g_canvas.h"
-
-/* ------------------------ gcanvas ----------------------------- */
-
-
-#define BACKGROUNDCOLOR "grey"
-
-#define DEFAULTSIZE 80
-
-static t_class *gcanvas_class;
-
-typedef struct _gcanvas
-{
- t_object x_obj;
- t_glist * x_glist;
- t_outlet* out2;
- t_outlet* out3;
- int x_width;
- int x_height;
- int x;
- int y;
- int x_xgrid;
- int x_ygrid;
-} t_gcanvas;
-
-
-static void rectangle(void* cv,void* o,char c,int x, int y,int w,int h,char* color) {
- sys_vgui(".x%x.c create rectangle \
- %d %d %d %d -tags %x%c -fill %s\n",cv,x,y,x+w,y+h,o,c,color);
-}
-
-static void move_object(void* cv,void* o,char c,int x, int y,int w,int h) {
- sys_vgui(".x%x.c coords %x%c %d %d %d %d\n",
- cv,o,c,x,y,x+w,y+h);
-
-}
-
-static void color_object(void* cv,void* o,char c,char* color) {
- sys_vgui(".x%x.c itemconfigure %x%c -fill %s\n", cv,
- o, c,color);
-}
-
-static void delete_object(void* cv,void* o,char c) {
- sys_vgui(".x%x.c delete %x%c\n",
- cv, o,c);
-}
-
-static void line(void* cv,void* o,char c,int x,int y,int w,int h,char* color) {
- sys_vgui(".x%x.c create line \
- %d %d %d %d -tags %x%c -fill %s\n",cv,x,y,x+w,y+h,o,c,color);
-}
-
-
-/* widget helper functions */
-
-void gcanvas_drawme(t_gcanvas *x, t_glist *glist, int firsttime)
-{
- int i;
- if (firsttime) {
- rectangle(glist_getcanvas(glist),x,'a',
- x->x_obj.te_xpix, x->x_obj.te_ypix,
- x->x_width, x->x_height,BACKGROUNDCOLOR);
- for (i=1;i<x->x_xgrid;i++)
- line(glist_getcanvas(glist),x,'b'+ i,
- x->x_obj.te_xpix + x->x_width*i/x->x_xgrid,
- x->x_obj.te_ypix,
- 0, x->x_height,"red");
- for (i=1;i<x->x_ygrid;i++)
- line(glist_getcanvas(glist),x,'B'+ i,
- x->x_obj.te_xpix,
- x->x_obj.te_ypix + x->x_height*i/x->x_ygrid,
- x->x_width, 0,"blue");
- }
- else {
- move_object(
- glist_getcanvas(glist),x,'a',
- x->x_obj.te_xpix, x->x_obj.te_ypix,
- x->x_width, x->x_height);
- for (i=1;i<x->x_xgrid;i++)
- move_object(glist_getcanvas(glist),x,'b'+ i,
- x->x_obj.te_xpix + x->x_width*i/x->x_xgrid,
- x->x_obj.te_ypix,
- 0, x->x_height);
- for (i=1;i<x->x_ygrid;i++)
- move_object(glist_getcanvas(glist),x,'B'+ i,
- x->x_obj.te_xpix,
- x->x_obj.te_ypix + x->x_height*i/x->x_ygrid,
- x->x_width, 0);
- }
-
- {
- /* outlets */
- int n = 3;
- int nplus, i;
- nplus = (n == 1 ? 1 : n-1);
- for (i = 0; i < n; i++)
- {
- int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n",
- glist_getcanvas(glist),
- onset, x->x_obj.te_ypix + x->x_height - 1,
- onset + IOWIDTH, x->x_obj.te_ypix + x->x_height,
- x, i);
- else
- sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
- glist_getcanvas(glist), x, i,
- onset, x->x_obj.te_ypix + x->x_height - 1,
- onset + IOWIDTH, x->x_obj.te_ypix + x->x_height);
- }
- /* inlets */
- n = 0;
- nplus = (n == 1 ? 1 : n-1);
- for (i = 0; i < n; i++)
- {
- int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n",
- glist_getcanvas(glist),
- onset, x->x_obj.te_ypix,
- onset + IOWIDTH, x->x_obj.te_ypix + 1,
- x, i);
- else
- sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n",
- glist_getcanvas(glist), x, i,
- onset, x->x_obj.te_ypix,
- onset + IOWIDTH, x->x_obj.te_ypix + 1);
-
- }
- }
-
-}
-
-
-
-
-void gcanvas_erase(t_gcanvas* x,t_glist* glist)
-{
- int n,i;
- delete_object(glist_getcanvas(glist),x,'a');
- for (i=1;i<x->x_xgrid;i++)
- delete_object(glist_getcanvas(glist),x,'b'+ i);
- for (i=1;i<x->x_ygrid;i++)
- delete_object(glist_getcanvas(glist),x,'B'+ i);
-
- n = 2;
- while (n--) {
- sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist),x,n);
- }
-}
-
-
-
-/* ------------------------ gcanvas widgetbehaviour----------------------------- */
-
-
-static void gcanvas_getrect(t_gobj *z, t_glist *owner,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- int width, height;
- t_gcanvas* s = (t_gcanvas*)z;
-
-
- width = s->x_width;
- height = s->x_height;
- *xp1 = s->x_obj.te_xpix;
- *yp1 = s->x_obj.te_ypix;
- *xp2 = s->x_obj.te_xpix + width;
- *yp2 = s->x_obj.te_ypix + height;
-}
-
-static void gcanvas_displace(t_gobj *z, t_glist *glist,
- int dx, int dy)
-{
- t_gcanvas *x = (t_gcanvas *)z;
- x->x_obj.te_xpix += dx;
- x->x_obj.te_ypix += dy;
- gcanvas_drawme(x, glist, 0);
- canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
-}
-
-static void gcanvas_select(t_gobj *z, t_glist *glist, int state)
-{
- t_gcanvas *x = (t_gcanvas *)z;
- color_object(glist,x,'a',state ? "blue" : BACKGROUNDCOLOR);
-}
-
-
-static void gcanvas_activate(t_gobj *z, t_glist *glist, int state)
-{
-/* t_text *x = (t_text *)z;
- t_rtext *y = glist_findrtext(glist, x);
- if (z->g_pd != gatom_class) rtext_activate(y, state);*/
-}
-
-static void gcanvas_delete(t_gobj *z, t_glist *glist)
-{
- t_text *x = (t_text *)z;
- canvas_deletelinesfor(glist_getcanvas(glist), x);
-}
-
-
-static void gcanvas_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_gcanvas* s = (t_gcanvas*)z;
- if (vis)
- gcanvas_drawme(s, glist, 1);
- else
- gcanvas_erase(s,glist);
-}
-
-/* can we use the normal text save function ?? */
-
-static void gcanvas_save(t_gobj *z, t_binbuf *b)
-{
- t_gcanvas *x = (t_gcanvas *)z;
- binbuf_addv(b, "ssiisiiii", gensym("#X"),gensym("obj"),
- (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix,
- gensym("gcanvas"),x->x_width,x->x_height,
- x->x_xgrid,
- x->x_ygrid);
- binbuf_addv(b, ";");
-}
-
-
-t_widgetbehavior gcanvas_widgetbehavior;
-
-static void gcanvas_motion(t_gcanvas *x, t_floatarg dx, t_floatarg dy)
-{
- x->x += dx;
- x->y += dy;
- outlet_float(x->out2,x->y);
- outlet_float(x->x_obj.ob_outlet,x->x);
-}
-
-void gcanvas_key(t_gcanvas *x, t_floatarg f)
-{
- post("key");
-}
-
-
-static void gcanvas_click(t_gcanvas *x,
- t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
- t_floatarg doit,int up)
-{
- glist_grab(x->x_glist, &x->x_obj.te_g, (t_glistmotionfn) gcanvas_motion,
- (t_glistkeyfn) NULL, xpos, ypos);
-
- x->x = xpos - x->x_obj.te_xpix;
- x->y = ypos - x->x_obj.te_ypix;
- outlet_float(x->out2,x->y);
- outlet_float(x->x_obj.ob_outlet,x->x);
- outlet_float(x->out3,0);
-}
-
-static int gcanvas_newclick(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- if (doit)
- gcanvas_click((t_gcanvas *)z, (t_floatarg)xpix, (t_floatarg)ypix,
- (t_floatarg)shift, 0, (t_floatarg)alt,dbl);
-
- if (dbl) outlet_float(((t_gcanvas*)z)->out3,1);
- return (1);
-}
-
-void gcanvas_size(t_gcanvas* x,t_floatarg w,t_floatarg h) {
- x->x_width = w;
- x->x_height = h;
- gcanvas_drawme(x, x->x_glist, 0);
-}
-
-static void gcanvas_setwidget(void)
-{
- gcanvas_widgetbehavior.w_getrectfn = gcanvas_getrect;
- gcanvas_widgetbehavior.w_displacefn = gcanvas_displace;
- gcanvas_widgetbehavior.w_selectfn = gcanvas_select;
- gcanvas_widgetbehavior.w_activatefn = gcanvas_activate;
- gcanvas_widgetbehavior.w_deletefn = gcanvas_delete;
- gcanvas_widgetbehavior.w_visfn = gcanvas_vis;
- gcanvas_widgetbehavior.w_clickfn = gcanvas_newclick;
- class_setsavefn(gcanvas_class,gcanvas_save);
-}
-
-
-static void *gcanvas_new(t_symbol* s,t_int ac,t_atom* at)
-{
- t_gcanvas *x = (t_gcanvas *)pd_new(gcanvas_class);
-
- x->x_glist = (t_glist*) canvas_getcurrent();
-
-
- /* Fetch the width */
-
- x->x_width = DEFAULTSIZE;
- if (ac-- > 0) {
- if (at->a_type != A_FLOAT)
- error("gcanvas: wrong argument type");
- else
- x->x_width = atom_getfloat(at++);
-
- if (x->x_width < 0 || x->x_width > 2000) {
- error("gcanvas: unallowed width %f",x->x_width);
- x->x_width = DEFAULTSIZE;
- }
- }
-
- /* Fetch the height */
-
- x->x_height = DEFAULTSIZE;
- if (ac-- > 0) {
- if (at->a_type != A_FLOAT)
- error("gcanvas: wrong argument type");
- else
- x->x_height = atom_getfloat(at++);
-
- if (x->x_height < 0 || x->x_height > 2000) {
- error("gcanvas: unallowed height %f",x->x_height);
- x->x_width = DEFAULTSIZE;
- }
- }
-
- /* Fetch the xgrid */
-
- x->x_xgrid = 0;
- if (ac-- > 0) {
- if (at->a_type != A_FLOAT)
- error("gcanvas: wrong argument type");
- else
- x->x_xgrid = atom_getfloat(at++);
-
- if (x->x_xgrid < 0 || x->x_xgrid > x->x_width/2) {
- error("gcanvas: unallowed xgrid %f",x->x_xgrid);
- x->x_xgrid = 0;
- }
- }
-
- /* Fetch the ygrid */
-
- x->x_ygrid = 0;
- if (ac-- > 0) {
- if (at->a_type != A_FLOAT)
- error("gcanvas: wrong argument type");
- else
- x->x_ygrid = atom_getfloat(at++);
-
- if (x->x_ygrid < 0 || x->x_ygrid > x->x_height/2) {
- error("gcanvas: unallowed xgrid %f",x->x_ygrid);
- x->x_ygrid = 0;
- }
- }
-
- outlet_new(&x->x_obj, &s_float);
- x->out2 = outlet_new(&x->x_obj, &s_float);
- x->out3 = outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-
-
-void gcanvas_setup(void)
-{
- gcanvas_class = class_new(gensym("gcanvas"), (t_newmethod)gcanvas_new, 0,
- sizeof(t_gcanvas),0, A_GIMME,0);
-
- class_addmethod(gcanvas_class, (t_method)gcanvas_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(gcanvas_class, (t_method)gcanvas_size, gensym("size"),
- A_FLOAT, A_FLOAT, 0);
-
- gcanvas_setwidget();
- class_setwidget(gcanvas_class,&gcanvas_widgetbehavior);
-}
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/highpass.c b/apps/plugins/pdbox/PDa/extra/highpass.c
index 88ba4564e6..f97ca233f3 100644
--- a/apps/plugins/pdbox/PDa/extra/highpass.c
+++ b/apps/plugins/pdbox/PDa/extra/highpass.c
@@ -82,93 +82,4 @@ void highpass_setup(void)
class_addfloat(highpass_class,highpass_float);
}
-
-
-
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-/*
-
- These filter coefficients computations are taken from
- http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
-
- written by Robert Bristow-Johnson
-
-*/
-
-#include "m_pd.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-#include <math.h>
-#include "filters.h"
-
-
-/* ------------------- highpass ----------------------------*/
-
-static t_class *highpass_class;
-
-void highpass_bang(t_rbjfilter *x)
-{
- t_atom at[5];
- t_float omega = e_omega(x->x_freq,x->x_rate);
- t_float alpha = e_alpha(x->x_bw* 0.01,omega);
- t_float b1 = -(1 + cos(omega));
- t_float b0 = -b1/2.;
- t_float b2 = b0;
- t_float a0 = 1 + alpha;
- t_float a1 = -2.*cos(omega);
- t_float a2 = 1 - alpha;
-
-/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
-
- if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
- post("highpass: filter unstable -> resetting");
- a0=1.;a1=0.;a2=0.;
- b0=1.;b1=0.;b2=0.;
- }
-
- SETFLOAT(at,-a1/a0);
- SETFLOAT(at+1,-a2/a0);
- SETFLOAT(at+2,b0/a0);
- SETFLOAT(at+3,b1/a0);
- SETFLOAT(at+4,b2/a0);
-
- outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
-}
-
-
-void highpass_float(t_rbjfilter *x,t_floatarg f)
-{
- x->x_freq = f;
- highpass_bang(x);
-}
-
-
-static void *highpass_new(t_floatarg f,t_floatarg bw)
-{
- t_rbjfilter *x = (t_rbjfilter *)pd_new(highpass_class);
-
- x->x_rate = 44100.0;
- outlet_new(&x->x_obj,&s_float);
-/* floatinlet_new(&x->x_obj, &x->x_gain); */
- floatinlet_new(&x->x_obj, &x->x_bw);
- if (f > 0.) x->x_freq = f;
- if (bw > 0.) x->x_bw = bw;
- return (x);
-}
-
-
-void highpass_setup(void)
-{
- highpass_class = class_new(gensym("highpass"), (t_newmethod)highpass_new, 0,
- sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
- class_addbang(highpass_class,highpass_bang);
- class_addfloat(highpass_class,highpass_float);
-}
-
-
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/highshelf.c b/apps/plugins/pdbox/PDa/extra/highshelf.c
index 0060d896c2..74db29178a 100644
--- a/apps/plugins/pdbox/PDa/extra/highshelf.c
+++ b/apps/plugins/pdbox/PDa/extra/highshelf.c
@@ -87,94 +87,4 @@ void highshelf_setup(void)
class_addfloat(highshelf_class,highshelf_float);
}
-
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-/*
-
- These filter coefficients computations are taken from
- http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
-
- written by Robert Bristow-Johnson
-
-*/
-
-#include "m_pd.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-#include <math.h>
-#include "filters.h"
-
-
-/* ------------------- highshelf ----------------------------*/
-
-static t_class *highshelf_class;
-
-void highshelf_bang(t_rbjfilter *x)
-{
- t_atom at[5];
- t_float omega = e_omega(x->x_freq,x->x_rate);
- t_float A = e_A(x->x_gain);
- t_float cs = cos(omega);
- t_float sn = sin(omega);
- t_float beta = e_beta(A,x->x_bw* 0.01);
-
- t_float b0 = A*((A+1) + (A-1)*cs + beta*sn);
- t_float b1 =-2.*A*((A-1) + (A+1)*cs);
- t_float b2 = A*((A+1) + (A-1)*cs - beta*sn);
- t_float a0 = ((A+1) - (A-1)*cs + beta*sn);
- t_float a1 = 2.*((A-1) - (A+1)*cs);
- t_float a2 = ((A+1) - (A-1)*cs - beta*sn);
-
-/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw);*/
-
- if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
- post("highshelf: filter unstable -> resetting");
- a0=1.;a1=0.;a2=0.;
- b0=1.;b1=0.;b2=0.;
- }
-
- SETFLOAT(at,-a1/a0);
- SETFLOAT(at+1,-a2/a0);
- SETFLOAT(at+2,b0/a0);
- SETFLOAT(at+3,b1/a0);
- SETFLOAT(at+4,b2/a0);
-
- outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
-}
-
-
-void highshelf_float(t_rbjfilter *x,t_floatarg f)
-{
- x->x_freq = f;
- highshelf_bang(x);
-}
-
-
-static void *highshelf_new(t_floatarg f,t_floatarg g,t_floatarg bw)
-{
- t_rbjfilter *x = (t_rbjfilter *)pd_new(highshelf_class);
-
- x->x_rate = 44100.0;
- outlet_new(&x->x_obj,&s_float);
- floatinlet_new(&x->x_obj, &x->x_gain);
- floatinlet_new(&x->x_obj, &x->x_bw);
- if (f > 0.) x->x_freq = f;
- if (bw > 0.) x->x_bw = bw;
- if (g != 0.) x->x_gain = g;
- return (x);
-}
-
-
-void highshelf_setup(void)
-{
- highshelf_class = class_new(gensym("highshelf"), (t_newmethod)highshelf_new, 0,
- sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
- class_addbang(highshelf_class,highshelf_bang);
- class_addfloat(highshelf_class,highshelf_float);
-}
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/hlshelf.c b/apps/plugins/pdbox/PDa/extra/hlshelf.c
index 46190c9b7c..242a2e625f 100644
--- a/apps/plugins/pdbox/PDa/extra/hlshelf.c
+++ b/apps/plugins/pdbox/PDa/extra/hlshelf.c
@@ -223,230 +223,4 @@ void hlshelf_setup(void)
class_addfloat(hlshelf_class,hlshelf_float);
}
-
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-#include <m_pd.h>
-#include <math.h>
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-/* ------------------------ hlshelf ----------------------------- */
-
-
-#ifndef M_PI
-#define M_PI 3.141593f
-#endif
-
-#define SRATE 44100.0
-#define MAX_GAIN 120.0f
-
-static t_class *hlshelf_class;
-
-
-typedef struct _hlshelf
-{
- t_object x_obj;
- float s_rate;
- float s_gain0;
- float s_gain1;
- float s_gain2;
- float s_ltransfq;
- float s_htransfq;
- float s_lradians;
- float s_hradians;
-} t_hlshelf;
-
-
-int hlshelf_check_stability(t_float fb1,
- t_float fb2,
- t_float ff1,
- t_float ff2,
- t_float ff3)
-{
- float discriminant = fb1 * fb1 + 4 * fb2;
-
- if (discriminant < 0) /* imaginary roots -- resonant filter */
- {
- /* they're conjugates so we just check that the product
- is less than one */
- if (fb2 >= -1.0f) goto stable;
- }
- else /* real roots */
- {
- /* check that the parabola 1 - fb1 x - fb2 x^2 has a
- vertex between -1 and 1, and that it's nonnegative
- at both ends, which implies both roots are in [1-,1]. */
- if (fb1 <= 2.0f && fb1 >= -2.0f &&
- 1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0)
- goto stable;
- }
- return 0;
-stable:
- return 1;
-}
-
-
-void hlshelf_check(t_hlshelf *x)
-{
-
- if(x->s_gain0 - x->s_gain1 > MAX_GAIN) {
- x->s_gain0 = x->s_gain1 + MAX_GAIN;
- post("setting gain0 to %f",x->s_gain0);
- }
-
-
- if(x->s_gain1 > MAX_GAIN) {
- x->s_gain1 = MAX_GAIN;
- post("setting gain1 to %f",x->s_gain1);
- }
-
- if(x->s_gain2 - x->s_gain1 > MAX_GAIN) {
- x->s_gain2 = x->s_gain1 + MAX_GAIN;
- post("setting gain2 to %f",x->s_gain2);
- }
-
- /* constrain: 0 <= x->s_ltransfq < x->s_htransfq. */
- x->s_ltransfq = (x->s_ltransfq < x->s_htransfq) ? x->s_ltransfq : x->s_htransfq - 0.5f;
-
- if (x->s_ltransfq < 0) x->s_ltransfq = 0.0f;
-
- x->s_lradians = M_PI * x->s_ltransfq / x->s_rate;
- x->s_hradians= M_PI * (0.5f - (x->s_htransfq / x->s_rate));
-
-}
-
-
-void hlshelf_bang(t_hlshelf *x)
-{
- t_atom at[6];
- float c0, c1, c2, d0, d1, d2; /* output coefs */
- float a1, a2, b1, b2, g1, g2; /* temp coefs */
- double xf;
-
- hlshelf_check(x);
-
- /* low shelf */
- xf = 0.5 * 0.115129255 * (double)(x->s_gain0 - x->s_gain1); /* ln(10) / 20 = 0.115129255 */
- if(xf < -200.) /* exp(x) -> 0 */
- {
- a1 = 1.0f;
- b1 = -1.0f;
- g1 = 0.0f;
- }
- else
- {
- double t = tan(x->s_lradians);
- double e = exp(xf);
- double r = t / e;
- double kr = t * e;
-
- a1 = (r - 1) / (r + 1);
- b1 = (kr - 1) / (kr + 1);
- g1 = (kr + 1) / (r + 1);
- }
-
- /* high shelf */
- xf = 0.5 * 0.115129255 * (double)(x->s_gain2 - x->s_gain1); /* ln(10) / 20 = 0.115129255 */
- if(xf < -200.) /* exp(x) -> 0 */
- {
- a2 = -1.0f;
- b2 = 1.0f;
- g2 = 0.0f;
- }
- else
- {
- double t = tan(x->s_hradians);
- double e = exp(xf);
- double r = t / e;
- double kr = t * e;
-
- a2 = (1 - r) / (1 + r);
- b2 = (1 - kr) / (1 + kr);
- g2 = (1 + kr) / (1 + r);
- }
-
- /* form product */
- c0 = g1 * g2 * (float)(exp((double)(x->s_gain1) * 0.05f * 2.302585093f)); ;
- c1 = a1 + a2;
- c2 = a1 * a2;
- d0 = 1.0f;
- d1 = b1 + b2;
- d2 = b1 * b2;
-
- if (!hlshelf_check_stability(-c1/d0,-c2/d0,d0/d0,d1/d0,d2/d0)) {
- post("hlshelf: filter unstable -> resetting");
- c0=1.;c1=0.;c2=0.;
- d0=1.;d1=0.;d2=0.;
- }
-
- SETFLOAT(at,-c1/d0);
- SETFLOAT(at+1,-c2/d0);
- SETFLOAT(at+2,d0/d0);
- SETFLOAT(at+3,d1/d0);
- SETFLOAT(at+4,d2/d0);
-
- outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
-}
-
-void hlshelf_float(t_hlshelf *x,t_floatarg f)
-{
- x->s_gain0 = f;
- hlshelf_bang(x);
-}
-
-
-static void *hlshelf_new(t_symbol* s,t_int argc, t_atom* at)
-{
- t_hlshelf *x = (t_hlshelf *)pd_new(hlshelf_class);
- t_float k0 = atom_getfloat(at);
- t_float k1 = atom_getfloat(at+1);
- t_float k2 = atom_getfloat(at+2);
- t_float f1 = atom_getfloat(at+3);
- t_float f2 = atom_getfloat(at+4);
-
-
- f1 = atom_getfloat(at);
- f2 = atom_getfloat(at);
-
- if ((f1 == 0.0f && f2 == 0.0f) || f1 > f2){ /* all gains = 0db */
- f1 = 150.0f;
- f2 = 5000.0f;
- }
-
- if (f1 < 0) f1 = 0.0f;
- if (f2 > SRATE) f2 = .5f*SRATE;
-
- x->s_rate = SRATE; /* srate default */
- x->s_gain0 = k0;
- x->s_gain1 = k1;
- x->s_gain2 = k2;
-
- x->s_ltransfq = 0.0f;
- x->s_htransfq = SRATE/2;
-
- x->s_lradians = M_PI * x->s_ltransfq / x->s_rate;
- x->s_hradians= M_PI * (0.5f - (x->s_htransfq / x->s_rate));
-
- floatinlet_new(&x->x_obj, &x->s_gain1);
- floatinlet_new(&x->x_obj, &x->s_gain2);
- floatinlet_new(&x->x_obj, &x->s_ltransfq);
- floatinlet_new(&x->x_obj, &x->s_htransfq);
- outlet_new(&x->x_obj, &s_list);
-
- return (x);
-}
-
-void hlshelf_setup(void)
-{
- hlshelf_class = class_new(gensym("hlshelf"), (t_newmethod)hlshelf_new, 0,
- sizeof(t_hlshelf), 0, A_GIMME, 0);
- class_addbang(hlshelf_class,hlshelf_bang);
- class_addfloat(hlshelf_class,hlshelf_float);
-}
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/image.c b/apps/plugins/pdbox/PDa/extra/image.c
index 6de48ef8fb..946a363986 100644
--- a/apps/plugins/pdbox/PDa/extra/image.c
+++ b/apps/plugins/pdbox/PDa/extra/image.c
@@ -215,220 +215,3 @@ void image_setup(void)
}
-#include "m_pd.h"
-#include "g_canvas.h"
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-/* ------------------------ image ----------------------------- */
-
-static t_class *image_class;
-
-typedef struct _image
-{
- t_object x_obj;
- t_glist * x_glist;
- int x_width;
- int x_height;
- t_symbol* x_fname;
-} t_image;
-
-/* widget helper functions */
-
-void image_drawme(t_image *x, t_glist *glist, int firsttime)
-{
- if (firsttime) {
- char fname[MAXPDSTRING];
- canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name,
- fname, MAXPDSTRING);
-
- sys_vgui("image create photo img%x -file %s\n",x,fname);
- sys_vgui(".x%x.c create image %d %d -image img%x -tags %xS\n",
- glist_getcanvas(glist),text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),x,x);
-
- /* TODO callback from gui
- sys_vgui("image_size logo");
- */
- }
- else {
- 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));
- }
-
-}
-
-
-void image_erase(t_image* x,t_glist* glist)
-{
- int n;
- sys_vgui(".x%x.c delete %xS\n",
- glist_getcanvas(glist), x);
-
-}
-
-
-
-/* ------------------------ image widgetbehaviour----------------------------- */
-
-
-static void image_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- int width, height;
- t_image* x = (t_image*)z;
-
-
- width = x->x_width;
- height = x->x_height;
- *xp1 = text_xpix(&x->x_obj, glist);
- *yp1 = text_ypix(&x->x_obj, glist);
- *xp2 = text_xpix(&x->x_obj, glist) + width;
- *yp2 = text_ypix(&x->x_obj, glist) + height;
-}
-
-static void image_displace(t_gobj *z, t_glist *glist,
- int dx, int dy)
-{
- 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_getcanvas(glist),(t_text*) x);
-}
-
-static void image_select(t_gobj *z, t_glist *glist, int state)
-{
- t_image *x = (t_image *)z;
- if (state) {
- sys_vgui(".x%x.c create rectangle \
-%d %d %d %d -tags %xSEL -outline blue\n",
- glist_getcanvas(glist),
- 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,
- x);
- }
- else {
- sys_vgui(".x%x.c delete %xSEL\n",
- glist_getcanvas(glist), x);
- }
-
-
-
-}
-
-
-static void image_activate(t_gobj *z, t_glist *glist, int state)
-{
-/* t_text *x = (t_text *)z;
- t_rtext *y = glist_findrtext(glist, x);
- if (z->g_pd != gatom_class) rtext_activate(y, state);*/
-}
-
-static void image_delete(t_gobj *z, t_glist *glist)
-{
- t_text *x = (t_text *)z;
- canvas_deletelinesfor(glist_getcanvas(glist), x);
-}
-
-
-static void image_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_image* s = (t_image*)z;
- if (vis)
- image_drawme(s, glist, 1);
- else
- image_erase(s,glist);
-}
-
-/* can we use the normal text save function ?? */
-
-static void image_save(t_gobj *z, t_binbuf *b)
-{
- t_image *x = (t_image *)z;
- binbuf_addv(b, "ssiiss", gensym("#X"),gensym("obj"),
- x->x_obj.te_xpix, x->x_obj.te_ypix,
- gensym("image"),x->x_fname);
- binbuf_addv(b, ";");
-}
-
-
-t_widgetbehavior image_widgetbehavior;
-
-void image_size(t_image* x,t_floatarg w,t_floatarg h) {
- x->x_width = w;
- x->x_height = h;
-}
-
-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
-*/
-}
-
-static void image_setwidget(void)
-{
- image_widgetbehavior.w_getrectfn = image_getrect;
- image_widgetbehavior.w_displacefn = image_displace;
- image_widgetbehavior.w_selectfn = image_select;
- image_widgetbehavior.w_activatefn = image_activate;
- image_widgetbehavior.w_deletefn = image_delete;
- image_widgetbehavior.w_visfn = image_vis;
-#if (PD_VERSION_MINOR > 31)
- image_widgetbehavior.w_clickfn = NULL;
- image_widgetbehavior.w_propertiesfn = NULL;
-#endif
-#if PD_MINOR_VERSION < 37
- image_widgetbehavior.w_savefn = image_save;
-#endif
-}
-
-
-static void *image_new(t_symbol* fname)
-{
- t_image *x = (t_image *)pd_new(image_class);
-
- x->x_glist = (t_glist*) canvas_getcurrent();
-
- x->x_width = 15;
- x->x_height = 15;
-
- x->x_fname = fname;
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-void image_setup(void)
-{
- image_class = class_new(gensym("image"), (t_newmethod)image_new, 0,
- sizeof(t_image),0, A_DEFSYM,0);
-
-/*
- 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);
-*/
-/*
- class_addmethod(image_class, (t_method)image_open, gensym("open"),
- A_SYMBOL, 0);
-*/
- image_setwidget();
- class_setwidget(image_class,&image_widgetbehavior);
-#if PD_MINOR_VERSION >= 37
- class_setsavefn(image_class,&image_save);
-#endif
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/extra/lowpass.c b/apps/plugins/pdbox/PDa/extra/lowpass.c
index c242aff0a8..251b7175f3 100644
--- a/apps/plugins/pdbox/PDa/extra/lowpass.c
+++ b/apps/plugins/pdbox/PDa/extra/lowpass.c
@@ -84,95 +84,4 @@ void lowpass_setup(void)
class_addfloat(lowpass_class,lowpass_float);
}
-
-
-
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-/*
-
- These filter coefficients computations are taken from
- http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
-
- written by Robert Bristow-Johnson
-
-*/
-
-#include "m_pd.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-#include <math.h>
-#include "filters.h"
-
-
-
-/* ------------------- lowpass ----------------------------*/
-
-static t_class *lowpass_class;
-
-void lowpass_bang(t_rbjfilter *x)
-{
- t_atom at[5];
- t_float omega = e_omega(x->x_freq,x->x_rate);
- t_float alpha = e_alpha(x->x_bw*0.01,omega);
- t_float b1 = 1 - cos(omega);
- t_float b0 = b1/2.;
- t_float b2 = b0;
- t_float a0 = 1 + alpha;
- t_float a1 = -2.*cos(omega);
- t_float a2 = 1 - alpha;
-
-/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
-
- if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
- post("lowpass: filter unstable -> resetting");
- a0=1.;a1=0.;a2=0.;
- b0=1.;b1=0.;b2=0.;
- }
-
- SETFLOAT(at,-a1/a0);
- SETFLOAT(at+1,-a2/a0);
- SETFLOAT(at+2,b0/a0);
- SETFLOAT(at+3,b1/a0);
- SETFLOAT(at+4,b2/a0);
-
- outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
-}
-
-
-void lowpass_float(t_rbjfilter *x,t_floatarg f)
-{
- x->x_freq = f;
- lowpass_bang(x);
-}
-
-
-static void *lowpass_new(t_floatarg f,t_floatarg bw)
-{
- t_rbjfilter *x = (t_rbjfilter *)pd_new(lowpass_class);
-
- x->x_rate = 44100.0;
- outlet_new(&x->x_obj,&s_float);
-/* floatinlet_new(&x->x_obj, &x->x_gain); */
- floatinlet_new(&x->x_obj, &x->x_bw);
-
- if (f > 0.) x->x_freq = f;
- if (bw > 0.) x->x_bw = bw;
- return (x);
-}
-
-
-void lowpass_setup(void)
-{
- lowpass_class = class_new(gensym("lowpass"), (t_newmethod)lowpass_new, 0,
- sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
- class_addbang(lowpass_class,lowpass_bang);
- class_addfloat(lowpass_class,lowpass_float);
-}
-
-
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/lowshelf.c b/apps/plugins/pdbox/PDa/extra/lowshelf.c
index 52c30d839d..ba32b6dba8 100644
--- a/apps/plugins/pdbox/PDa/extra/lowshelf.c
+++ b/apps/plugins/pdbox/PDa/extra/lowshelf.c
@@ -88,95 +88,4 @@ void lowshelf_setup(void)
class_addfloat(lowshelf_class,lowshelf_float);
}
-
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-/*
-
- These filter coefficients computations are taken from
- http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
-
- written by Robert Bristow-Johnson
-
-*/
-
-#include "m_pd.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-#include <math.h>
-#include "filters.h"
-
-
-
-/* ------------------- lowshelf ----------------------------*/
-
-static t_class *lowshelf_class;
-
-void lowshelf_bang(t_rbjfilter *x)
-{
- t_atom at[5];
- t_float omega = e_omega(x->x_freq,x->x_rate);
- t_float A = e_A(x->x_gain);
- t_float cs = cos(omega);
- t_float sn = sin(omega);
- t_float beta = e_beta(A,x->x_bw*0.01);
-
- t_float b0 = A*((A+1) - (A-1)*cs + beta*sn);
- t_float b1 = 2.*A*((A-1) - (A+1)*cs);
- t_float b2 = A*((A+1) - (A-1)*cs - beta*sn);
- t_float a0 = ((A+1) + (A-1)*cs + beta*sn);
- t_float a1 = -2.*((A-1) + (A+1)*cs);
- t_float a2 = ((A+1) + (A-1)*cs - beta*sn);
-
-/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
-
- if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
- post("lowshelf: filter unstable -> resetting");
- a0=1.;a1=0.;a2=0.;
- b0=1.;b1=0.;b2=0.;
- }
-
- SETFLOAT(at,-a1/a0);
- SETFLOAT(at+1,-a2/a0);
- SETFLOAT(at+2,b0/a0);
- SETFLOAT(at+3,b1/a0);
- SETFLOAT(at+4,b2/a0);
-
- outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
-}
-
-
-void lowshelf_float(t_rbjfilter *x,t_floatarg f)
-{
- x->x_freq = f;
- lowshelf_bang(x);
-}
-
-
-static void *lowshelf_new(t_floatarg f,t_floatarg g,t_floatarg bw)
-{
- t_rbjfilter *x = (t_rbjfilter *)pd_new(lowshelf_class);
-
- x->x_rate = 44100.0;
- outlet_new(&x->x_obj,&s_float);
- floatinlet_new(&x->x_obj, &x->x_gain);
- floatinlet_new(&x->x_obj, &x->x_bw);
- if (f > 0.) x->x_freq = f;
- if (bw > 0.) x->x_bw = bw;
- if (g != 0.) x->x_gain = g;
- return (x);
-}
-
-
-void lowshelf_setup(void)
-{
- lowshelf_class = class_new(gensym("lowshelf"), (t_newmethod)lowshelf_new, 0,
- sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
- class_addbang(lowshelf_class,lowshelf_bang);
- class_addfloat(lowshelf_class,lowshelf_float);
-}
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/m_pd.h b/apps/plugins/pdbox/PDa/extra/m_pd.h
index 403c5b382b..f08fdccf93 100644
--- a/apps/plugins/pdbox/PDa/extra/m_pd.h
+++ b/apps/plugins/pdbox/PDa/extra/m_pd.h
@@ -648,653 +648,4 @@ defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */
#define __m_pd_h_
#endif /* __m_pd_h_ */
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#ifndef __m_pd_h_
-
-#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
-extern "C" {
-#endif
-
-#define PD_VERSION 0.37 /* oops, don't use this... */ */
-#define PD_MAJOR_VERSION 0 /* ... use these two instead. */
-#define PD_MINOR_VERSION 37
-
-/* old name for "MSW" flag -- we have to take it for the sake of many old
-"nmakefiles" for externs, which will define NT and not MSW */
-#if defined(NT) && !defined(MSW)
-#define MSW
-#endif
-
-#ifdef MSW
-// #pragma warning( disable : 4091 )
-#pragma warning( disable : 4305 ) /* uncast const double to float */
-#pragma warning( disable : 4244 ) /* uncast float/int conversion etc. */
-#pragma warning( disable : 4101 ) /* unused automatic variables */
-#endif /* MSW */
-
- /* the external storage class is "extern" in UNIX; in MSW it's ugly. */
-#ifdef MSW
-#ifdef PD_INTERNAL
-#define EXTERN __declspec(dllexport) extern
-#else
-#define EXTERN __declspec(dllimport) extern
-#endif /* PD_INTERNAL */
-#else
-#define EXTERN extern
-#endif /* MSW */
-
- /* and depending on the compiler, hidden data structures are
- declared differently: */
-#if defined( __GNUC__) || defined( __BORLANDC__ ) || defined( __MWERKS__ )
-#define EXTERN_STRUCT struct
-#else
-#define EXTERN_STRUCT extern struct
-#endif
-
-
-#if !defined(_SIZE_T) && !defined(_SIZE_T_)
-#include <stddef.h> /* just for size_t -- how lame! */
-#endif
-
-#define MAXPDSTRING 1000 /* use this for anything you want */
-#define MAXPDARG 5 /* max number of args we can typecheck today */
-
- /* signed and unsigned integer types the size of a pointer: */
-#ifdef __alpha__
-typedef long t_int;
-#else
-typedef int t_int;
-#endif
-
-typedef float t_float; /* a floating-point number at most the same size */
-typedef float t_floatarg; /* floating-point type for function calls */
-
-typedef struct _symbol
-{
- char *s_name;
- struct _class **s_thing;
- struct _symbol *s_next;
-} t_symbol;
-
-EXTERN_STRUCT _array;
-#define t_array struct _array /* g_canvas.h */
-
-/* pointers to glist and array elements go through a "stub" which sticks
-around after the glist or array is freed. The stub itself is deleted when
-both the glist/array is gone and the refcount is zero, ensuring that no
-gpointers are pointing here. */
-
-#define GP_NONE 0 /* the stub points nowhere (has been cut off) */
-#define GP_GLIST 1 /* the stub points to a glist element */
-#define GP_ARRAY 2 /* ... or array */
-typedef struct _gstub
-{
- union
- {
- struct _glist *gs_glist; /* glist we're in */
- struct _array *gs_array; /* array we're in */
- } gs_un;
- int gs_which; /* GP_GLIST/GP_ARRAY */
- int gs_refcount; /* number of gpointers pointing here */
-} t_gstub;
-
-typedef struct _gpointer /* pointer to a gobj in a glist */
-{
- union
- {
- struct _scalar *gp_scalar; /* scalar we're in (if glist) */
- union word *gp_w; /* raw data (if array) */
- } gp_un;
- int gp_valid; /* number which must match gpointee */
- t_gstub *gp_stub; /* stub which points to glist/array */
-} t_gpointer;
-
-typedef union word
-{
- t_float w_float;
- t_symbol *w_symbol;
- t_gpointer *w_gpointer;
- t_array *w_array;
- struct _glist *w_list;
- int w_index;
-} t_word;
-
-typedef enum
-{
- A_NULL,
- A_FLOAT,
- A_SYMBOL,
- A_POINTER,
- A_SEMI,
- A_COMMA,
- A_DEFFLOAT,
- A_DEFSYM,
- A_DOLLAR,
- A_DOLLSYM,
- A_GIMME,
- A_CANT
-} t_atomtype;
-
-#define A_DEFSYMBOL A_DEFSYM /* better name for this */
-
-typedef struct _atom
-{
- t_atomtype a_type;
- union word a_w;
-} t_atom;
-
-EXTERN_STRUCT _class;
-#define t_class struct _class
-
-EXTERN_STRUCT _outlet;
-#define t_outlet struct _outlet
-
-EXTERN_STRUCT _inlet;
-#define t_inlet struct _inlet
-
-EXTERN_STRUCT _binbuf;
-#define t_binbuf struct _binbuf
-
-EXTERN_STRUCT _clock;
-#define t_clock struct _clock
-
-EXTERN_STRUCT _outconnect;
-#define t_outconnect struct _outconnect
-
-EXTERN_STRUCT _glist;
-#define t_glist struct _glist
-#define t_canvas struct _glist /* LATER lose this */
-
-typedef t_class *t_pd; /* pure datum: nothing but a class pointer */
-
-typedef struct _gobj /* a graphical object */
-{
- t_pd g_pd; /* pure datum header (class) */
- struct _gobj *g_next; /* next in list */
-} t_gobj;
-
-typedef struct _scalar /* a graphical object holding data */
-{
- t_gobj sc_gobj; /* header for graphical object */
- t_symbol *sc_template; /* template name (LATER replace with pointer) */
- t_word sc_vec[1]; /* indeterminate-length array of words */
-} t_scalar;
-
-typedef struct _text /* patchable object - graphical, with text */
-{
- t_gobj te_g; /* header for graphical object */
- t_binbuf *te_binbuf; /* holder for the text */
- t_outlet *te_outlet; /* linked list of outlets */
- t_inlet *te_inlet; /* linked list of inlets */
- short te_xpix; /* x&y location (within the toplevel) */
- short te_ypix;
- short te_width; /* requested width in chars, 0 if auto */
- unsigned int te_type:2; /* from defs below */
-} t_text;
-
-#define T_TEXT 0 /* just a textual comment */
-#define T_OBJECT 1 /* a MAX style patchable object */
-#define T_MESSAGE 2 /* a MAX stype message */
-#define T_ATOM 3 /* a cell to display a number or symbol */
-
-#define te_pd te_g.g_pd
-
- /* t_object is synonym for t_text (LATER unify them) */
-
-typedef struct _text t_object;
-
-#define ob_outlet te_outlet
-#define ob_inlet te_inlet
-#define ob_binbuf te_binbuf
-#define ob_pd te_g.g_pd
-#define ob_g te_g
-
-typedef void (*t_method)(void);
-typedef void *(*t_newmethod)( void);
-typedef void (*t_gotfn)(void *x, ...);
-
-/* ---------------- pre-defined objects and symbols --------------*/
-EXTERN t_pd pd_objectmaker; /* factory for creating "object" boxes */
-EXTERN t_pd pd_canvasmaker; /* factory for creating canvases */
-EXTERN t_symbol s_pointer;
-EXTERN t_symbol s_float;
-EXTERN t_symbol s_symbol;
-EXTERN t_symbol s_bang;
-EXTERN t_symbol s_list;
-EXTERN t_symbol s_anything;
-EXTERN t_symbol s_signal;
-EXTERN t_symbol s__N;
-EXTERN t_symbol s__X;
-EXTERN t_symbol s_x;
-EXTERN t_symbol s_y;
-EXTERN t_symbol s_;
-
-/* --------- prototypes from the central message system ----------- */
-EXTERN void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN void pd_forwardmess(t_pd *x, int argc, t_atom *argv);
-EXTERN t_symbol *gensym(char *s);
-EXTERN t_gotfn getfn(t_pd *x, t_symbol *s);
-EXTERN t_gotfn zgetfn(t_pd *x, t_symbol *s);
-EXTERN void nullfn(void);
-EXTERN void pd_vmess(t_pd *x, t_symbol *s, char *fmt, ...);
-#define mess0(x, s) ((*getfn((x), (s)))((x)))
-#define mess1(x, s, a) ((*getfn((x), (s)))((x), (a)))
-#define mess2(x, s, a,b) ((*getfn((x), (s)))((x), (a),(b)))
-#define mess3(x, s, a,b,c) ((*getfn((x), (s)))((x), (a),(b),(c)))
-#define mess4(x, s, a,b,c,d) ((*getfn((x), (s)))((x), (a),(b),(c),(d)))
-#define mess5(x, s, a,b,c,d,e) ((*getfn((x), (s)))((x), (a),(b),(c),(d),(e)))
-EXTERN void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN t_pd *pd_newest(void);
-
-/* --------------- memory management -------------------- */
-EXTERN void *getbytes(size_t nbytes);
-EXTERN void *getzbytes(size_t nbytes);
-EXTERN void *copybytes(void *src, size_t nbytes);
-EXTERN void freebytes(void *x, size_t nbytes);
-EXTERN void *resizebytes(void *x, size_t oldsize, size_t newsize);
-
-/* -------------------- atoms ----------------------------- */
-
-#define SETSEMI(atom) ((atom)->a_type = A_SEMI, (atom)->a_w.w_index = 0)
-#define SETCOMMA(atom) ((atom)->a_type = A_COMMA, (atom)->a_w.w_index = 0)
-#define SETPOINTER(atom, gp) ((atom)->a_type = A_POINTER, \
- (atom)->a_w.w_gpointer = (gp))
-#define SETFLOAT(atom, f) ((atom)->a_type = A_FLOAT, (atom)->a_w.w_float = (f))
-#define SETSYMBOL(atom, s) ((atom)->a_type = A_SYMBOL, \
- (atom)->a_w.w_symbol = (s))
-#define SETDOLLAR(atom, n) ((atom)->a_type = A_DOLLAR, \
- (atom)->a_w.w_index = (n))
-#define SETDOLLSYM(atom, s) ((atom)->a_type = A_DOLLSYM, \
- (atom)->a_w.w_symbol= (s))
-
-EXTERN t_float atom_getfloat(t_atom *a);
-EXTERN t_int atom_getint(t_atom *a);
-EXTERN t_symbol *atom_getsymbol(t_atom *a);
-EXTERN t_symbol *atom_gensym(t_atom *a);
-EXTERN t_float atom_getfloatarg(int which, int argc, t_atom *argv);
-EXTERN t_int atom_getintarg(int which, int argc, t_atom *argv);
-EXTERN t_symbol *atom_getsymbolarg(int which, int argc, t_atom *argv);
-
-EXTERN void atom_string(t_atom *a, char *buf, unsigned int bufsize);
-
-/* ------------------ binbufs --------------- */
-
-EXTERN t_binbuf *binbuf_new(void);
-EXTERN void binbuf_free(t_binbuf *x);
-EXTERN t_binbuf *binbuf_duplicate(t_binbuf *y);
-
-EXTERN void binbuf_text(t_binbuf *x, char *text, size_t size);
-EXTERN void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp);
-EXTERN void binbuf_clear(t_binbuf *x);
-EXTERN void binbuf_add(t_binbuf *x, int argc, t_atom *argv);
-EXTERN void binbuf_addv(t_binbuf *x, char *fmt, ...);
-EXTERN void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y);
-EXTERN void binbuf_addsemi(t_binbuf *x);
-EXTERN void binbuf_restore(t_binbuf *x, int argc, t_atom *argv);
-EXTERN void binbuf_print(t_binbuf *x);
-EXTERN int binbuf_getnatom(t_binbuf *x);
-EXTERN t_atom *binbuf_getvec(t_binbuf *x);
-EXTERN void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv);
-EXTERN int binbuf_read(t_binbuf *b, char *filename, char *dirname,
- int crflag);
-EXTERN int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname,
- int crflag);
-EXTERN int binbuf_write(t_binbuf *x, char *filename, char *dir,
- int crflag);
-EXTERN void binbuf_evalfile(t_symbol *name, t_symbol *dir);
-EXTERN t_symbol *binbuf_realizedollsym(t_symbol *s, int ac, t_atom *av,
- int tonew);
-
-/* ------------------ clocks --------------- */
-
-typedef long long t_time;
-EXTERN t_clock *clock_new(void *owner, t_method fn);
-EXTERN void clock_set(t_clock *x, t_time systime);
-EXTERN void clock_delay(t_clock *x, t_time delaytime);
-EXTERN void clock_unset(t_clock *x);
-EXTERN t_time clock_getlogicaltime(void);
-EXTERN t_time clock_getsystime(void); /* OBSOLETE; use clock_getlogicaltime() */
-EXTERN t_time clock_gettimesince(t_time prevsystime);
-EXTERN t_time clock_getsystimeafter(t_time delaytime);
-EXTERN void clock_free(t_clock *x);
-
-/* ----------------- pure data ---------------- */
-EXTERN t_pd *pd_new(t_class *cls);
-EXTERN void pd_free(t_pd *x);
-EXTERN void pd_bind(t_pd *x, t_symbol *s);
-EXTERN void pd_unbind(t_pd *x, t_symbol *s);
-EXTERN t_pd *pd_findbyclass(t_symbol *s, t_class *c);
-EXTERN void pd_pushsym(t_pd *x);
-EXTERN void pd_popsym(t_pd *x);
-EXTERN t_symbol *pd_getfilename(void);
-EXTERN t_symbol *pd_getdirname(void);
-EXTERN void pd_bang(t_pd *x);
-EXTERN void pd_pointer(t_pd *x, t_gpointer *gp);
-EXTERN void pd_float(t_pd *x, t_float f);
-EXTERN void pd_symbol(t_pd *x, t_symbol *s);
-EXTERN void pd_list(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN void pd_anything(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-#define pd_class(x) (*(x))
-
-/* ----------------- pointers ---------------- */
-EXTERN void gpointer_init(t_gpointer *gp);
-EXTERN void gpointer_copy(const t_gpointer *gpfrom, t_gpointer *gpto);
-EXTERN void gpointer_unset(t_gpointer *gp);
-EXTERN int gpointer_check(const t_gpointer *gp, int headok);
-
-/* ----------------- patchable "objects" -------------- */
-EXTERN_STRUCT _inlet;
-#define t_inlet struct _inlet
-EXTERN_STRUCT _outlet;
-#define t_outlet struct _outlet
-
-EXTERN t_inlet *inlet_new(t_object *owner, t_pd *dest, t_symbol *s1,
- t_symbol *s2);
-EXTERN t_inlet *pointerinlet_new(t_object *owner, t_gpointer *gp);
-EXTERN t_inlet *floatinlet_new(t_object *owner, t_float *fp);
-EXTERN t_inlet *symbolinlet_new(t_object *owner, t_symbol **sp);
-EXTERN void inlet_free(t_inlet *x);
-
-EXTERN t_outlet *outlet_new(t_object *owner, t_symbol *s);
-EXTERN void outlet_bang(t_outlet *x);
-EXTERN void outlet_pointer(t_outlet *x, t_gpointer *gp);
-EXTERN void outlet_float(t_outlet *x, t_float f);
-EXTERN void outlet_symbol(t_outlet *x, t_symbol *s);
-EXTERN void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN t_symbol *outlet_getsymbol(t_outlet *x);
-EXTERN void outlet_free(t_outlet *x);
-EXTERN t_object *pd_checkobject(t_pd *x);
-
-
-/* -------------------- canvases -------------- */
-
-EXTERN void glob_setfilename(void *dummy, t_symbol *name, t_symbol *dir);
-
-EXTERN void canvas_setargs(int argc, t_atom *argv);
-EXTERN void canvas_getargs(int *argcp, t_atom **argvp);
-EXTERN t_symbol *canvas_getcurrentdir(void);
-EXTERN t_glist *canvas_getcurrent(void);
-EXTERN void canvas_makefilename(t_glist *c, char *file,
- char *result,int resultsize);
-EXTERN t_symbol *canvas_getdir(t_glist *x);
-EXTERN int sys_fontwidth(int fontsize);
-EXTERN int sys_fontheight(int fontsize);
-EXTERN void canvas_dataproperties(t_glist *x, t_scalar *sc, t_binbuf *b);
-
-/* ---------------- widget behaviors ---------------------- */
-
-EXTERN_STRUCT _widgetbehavior;
-#define t_widgetbehavior struct _widgetbehavior
-
-EXTERN_STRUCT _parentwidgetbehavior;
-#define t_parentwidgetbehavior struct _parentwidgetbehavior
-EXTERN t_parentwidgetbehavior *pd_getparentwidget(t_pd *x);
-
-/* -------------------- classes -------------- */
-
-#define CLASS_DEFAULT 0 /* flags for new classes below */
-#define CLASS_PD 1
-#define CLASS_GOBJ 2
-#define CLASS_PATCHABLE 3
-#define CLASS_NOINLET 8
-
-#define CLASS_TYPEMASK 3
-
-
-EXTERN t_class *class_new(t_symbol *name, t_newmethod newmethod,
- t_method freemethod, size_t size, int flags, t_atomtype arg1, ...);
-EXTERN void class_addcreator(t_newmethod newmethod, t_symbol *s,
- t_atomtype type1, ...);
-EXTERN void class_addmethod(t_class *c, t_method fn, t_symbol *sel,
- t_atomtype arg1, ...);
-EXTERN void class_addbang(t_class *c, t_method fn);
-EXTERN void class_addpointer(t_class *c, t_method fn);
-EXTERN void class_doaddfloat(t_class *c, t_method fn);
-EXTERN void class_addsymbol(t_class *c, t_method fn);
-EXTERN void class_addlist(t_class *c, t_method fn);
-EXTERN void class_addanything(t_class *c, t_method fn);
-EXTERN void class_sethelpsymbol(t_class *c, t_symbol *s);
-EXTERN void class_setwidget(t_class *c, t_widgetbehavior *w);
-EXTERN void class_setparentwidget(t_class *c, t_parentwidgetbehavior *w);
-EXTERN t_parentwidgetbehavior *class_parentwidget(t_class *c);
-EXTERN char *class_getname(t_class *c);
-EXTERN char *class_gethelpname(t_class *c);
-EXTERN void class_setdrawcommand(t_class *c);
-EXTERN int class_isdrawcommand(t_class *c);
-EXTERN void class_domainsignalin(t_class *c, int onset);
-#define CLASS_MAINSIGNALIN(c, type, field) \
- class_domainsignalin(c, (char *)(&((type *)0)->field) - (char *)0)
-
- /* prototype for functions to save Pd's to a binbuf */
-typedef void (*t_savefn)(t_gobj *x, t_binbuf *b);
-EXTERN void class_setsavefn(t_class *c, t_savefn f);
-EXTERN t_savefn class_getsavefn(t_class *c);
- /* prototype for functions to open properties dialogs */
-typedef void (*t_propertiesfn)(t_gobj *x, struct _glist *glist);
-EXTERN void class_setpropertiesfn(t_class *c, t_propertiesfn f);
-EXTERN t_propertiesfn class_getpropertiesfn(t_class *c);
-
-#ifndef PD_CLASS_DEF
-#define class_addbang(x, y) class_addbang((x), (t_method)(y))
-#define class_addpointer(x, y) class_addpointer((x), (t_method)(y))
-#define class_addfloat(x, y) class_doaddfloat((x), (t_method)(y))
-#define class_addsymbol(x, y) class_addsymbol((x), (t_method)(y))
-#define class_addlist(x, y) class_addlist((x), (t_method)(y))
-#define class_addanything(x, y) class_addanything((x), (t_method)(y))
-#endif
-
-/* ------------ printing --------------------------------- */
-EXTERN void post(char *fmt, ...);
-EXTERN void startpost(char *fmt, ...);
-EXTERN void poststring(char *s);
-EXTERN void postfloat(float f);
-EXTERN void postatom(int argc, t_atom *argv);
-EXTERN void endpost(void);
-EXTERN void error(char *fmt, ...);
-EXTERN void bug(char *fmt, ...);
-EXTERN void pd_error(void *object, char *fmt, ...);
-EXTERN void sys_logerror(char *object, char *s);
-EXTERN void sys_unixerror(char *object);
-EXTERN void sys_ouch(void);
-
-#ifdef __linux__
-EXTERN char* sys_get_path( void);
-#endif
-EXTERN void sys_addpath(const char* p);
-
-
-/* ------------ system interface routines ------------------- */
-EXTERN int sys_isreadablefile(const char *name);
-EXTERN void sys_bashfilename(const char *from, char *to);
-EXTERN void sys_unbashfilename(const char *from, char *to);
-EXTERN int open_via_path(const char *name, const char *ext, const char *dir,
- char *dirresult, char **nameresult, unsigned int size, int bin);
-EXTERN int sched_geteventno(void);
-EXTERN double sys_getrealtime(void);
-
-
-/* ------------ threading ------------------- */
-/* T.Grill - see m_sched.c */
-
-EXTERN void sys_lock(void);
-EXTERN void sys_unlock(void);
-EXTERN int sys_trylock(void);
-
-
-/* --------------- signals ----------------------------------- */
-
-#define MAXLOGSIG 32
-#define MAXSIGSIZE (1 << MAXLOGSIG)
-#ifndef FIXEDPOINT
-typedef float t_sample;
-#else
-#include "m_fixed.h"
-#endif
-
-
-typedef struct _signal
-{
- int s_n; /* number of points in the array */
- t_sample *s_vec; /* the array */
- float s_sr; /* sample rate */
- int s_refcount; /* number of times used */
- int s_isborrowed; /* whether we're going to borrow our array */
- struct _signal *s_borrowedfrom; /* signal to borrow it from */
- struct _signal *s_nextfree; /* next in freelist */
- struct _signal *s_nextused; /* next in used list */
-} t_signal;
-
-
-typedef t_int *(*t_perfroutine)(t_int *args);
-
-EXTERN t_int *plus_perform(t_int *args);
-EXTERN t_int *zero_perform(t_int *args);
-EXTERN t_int *copy_perform(t_int *args);
-
-EXTERN void dsp_add_plus(t_sample *in1, t_sample *in2, t_sample *out, int n);
-EXTERN void dsp_add_copy(t_sample *in, t_sample *out, int n);
-EXTERN void dsp_add_scalarcopy(t_sample *in, t_sample *out, int n);
-EXTERN void dsp_add_zero(t_sample *out, int n);
-
-EXTERN int sys_getblksize(void);
-EXTERN float sys_getsr(void);
-EXTERN int sys_get_inchannels(void);
-EXTERN int sys_get_outchannels(void);
-
-EXTERN void dsp_add(t_perfroutine f, int n, ...);
-EXTERN void dsp_addv(t_perfroutine f, int n, t_int *vec);
-EXTERN void pd_fft(float *buf, int npoints, int inverse);
-EXTERN int ilog2(int n);
-
-EXTERN void mayer_fht(t_sample *fz, int n);
-EXTERN void mayer_fft(int n, t_sample *real, t_sample *imag);
-EXTERN void mayer_ifft(int n, t_sample *real, t_sample *imag);
-EXTERN void mayer_realfft(int n, t_sample *real);
-EXTERN void mayer_realifft(int n, t_sample *real);
-
-EXTERN t_sample *cos_table;
-
-#define LOGCOSTABSIZE 9
-#define COSTABSIZE (1<<LOGCOSTABSIZE)
-
-EXTERN int canvas_suspend_dsp(void);
-EXTERN void canvas_resume_dsp(int oldstate);
-EXTERN void canvas_update_dsp(void);
-
-/* IOhannes { (up/downsampling) */
-typedef struct _resample
-{
- int method; /* up/downsampling method ID */
-
- t_int downsample; /* downsampling factor */
- t_int upsample; /* upsampling factor */
-
- t_sample *s_vec; /* here we hold the resampled data */
- int s_n;
-
- t_sample *coeffs; /* coefficients for filtering... */
- int coefsize;
-
- t_sample *buffer; /* buffer for filtering */
- int bufsize;
-} t_resample;
-
-EXTERN void resample_init(t_resample *x);
-EXTERN void resample_free(t_resample *x);
-
-EXTERN void resample_dsp(t_resample *x, t_sample *in, int insize, t_sample *out, int outsize, int method);
-EXTERN void resamplefrom_dsp(t_resample *x, t_sample *in, int insize, int outsize, int method);
-EXTERN void resampleto_dsp(t_resample *x, t_sample *out, int insize, int outsize, int method);
-/* } IOhannes */
-
-/* ----------------------- utility functions for signals -------------- */
-EXTERN float mtof(float);
-EXTERN float ftom(float);
-EXTERN float rmstodb(float);
-EXTERN float powtodb(float);
-EXTERN float dbtorms(float);
-EXTERN float dbtopow(float);
-
-EXTERN float q8_sqrt(float);
-EXTERN float q8_rsqrt(float);
-#ifndef N32
-EXTERN float qsqrt(float); /* old names kept for extern compatibility */
-EXTERN float qrsqrt(float);
-#endif
-/* --------------------- data --------------------------------- */
-
- /* graphical arrays */
-EXTERN_STRUCT _garray;
-#define t_garray struct _garray
-
-EXTERN t_class *garray_class;
-EXTERN int garray_getfloatarray(t_garray *x, int *size, t_sample **vec);
-EXTERN float garray_get(t_garray *x, t_symbol *s, t_int indx);
-EXTERN void garray_redraw(t_garray *x);
-EXTERN int garray_npoints(t_garray *x);
-EXTERN char *garray_vec(t_garray *x);
-EXTERN void garray_resize(t_garray *x, t_floatarg f);
-EXTERN void garray_usedindsp(t_garray *x);
-EXTERN void garray_setsaveit(t_garray *x, int saveit);
-EXTERN t_class *scalar_class;
-
-EXTERN t_float *value_get(t_symbol *s);
-EXTERN void value_release(t_symbol *s);
-EXTERN int value_getfloat(t_symbol *s, t_float *f);
-EXTERN int value_setfloat(t_symbol *s, t_float f);
-
-/* ------- GUI interface - functions to send strings to TK --------- */
-EXTERN void sys_vgui(char *fmt, ...);
-EXTERN void sys_gui(char *s);
-
- /* dialog window creation and destruction */
-EXTERN void gfxstub_new(t_pd *owner, void *key, const char *cmd);
-EXTERN void gfxstub_deleteforkey(void *key);
-
-extern t_class *glob_pdobject; /* object to send "pd" messages */
-
-/*------------- Max 0.26 compatibility --------------------*/
-
-/* the following reflects the new way classes are laid out, with the class
- pointing to the messlist and not vice versa. Externs shouldn't feel it. */
-typedef t_class *t_externclass;
-
-EXTERN void c_extern(t_externclass *cls, t_newmethod newroutine,
- t_method freeroutine, t_symbol *name, size_t size, int tiny, \
- t_atomtype arg1, ...);
-EXTERN void c_addmess(t_method fn, t_symbol *sel, t_atomtype arg1, ...);
-
-#define t_getbytes getbytes
-#define t_freebytes freebytes
-#define t_resizebytes resizebytes
-#define typedmess pd_typedmess
-#define vmess pd_vmess
-
-/* A definition to help gui objects straddle 0.34-0.35 changes. If this is
-defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */
-
-#define PD_USE_TE_XPIX
-
-#if 0
-/* a test for NANs and denormals. Should only be necessary on i386. */
-#define PD_BADFLOAT(f) ((((*(unsigned int*)&(f))&0x7f800000)==0) || \
- (((*(unsigned int*)&(f))&0x7f800000)==0x7f800000))
-/* more stringent test: anything not between 1e-19 and 1e19 in absolute val */
-#define PD_BIGORSMALL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \
- (((*(unsigned int*)&(f))&0x60000000)==0x60000000))
-#else
-#define PD_BADFLOAT(f) 0
-#define PD_BIGORSMALL(f) 0
-#endif
-
-#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
-}
-#endif
-
-#define __m_pd_h_
-#endif /* __m_pd_h_ */
diff --git a/apps/plugins/pdbox/PDa/extra/makefile b/apps/plugins/pdbox/PDa/extra/makefile
index 270491de63..4bd6ed0960 100644
--- a/apps/plugins/pdbox/PDa/extra/makefile
+++ b/apps/plugins/pdbox/PDa/extra/makefile
@@ -32,35 +32,3 @@ install:
%.o : %.c
$(CC) -c $(AFLAGS) $(CFLAGS) $+
-VERSION = 0.2
-SOURCE = $(shell ls *.c)
-TARGETS = $(SOURCE:.c=.pd_linux)
-
-EXT= pd_linux
-
-AFLAGS = -g -O2 -I./ -DFIXEDPOINT
-EFLAGS = -shared -Wl,-export-dynamic
-PREFIX = /usr
-
-
-all: $(TARGETS)
-
-clean:
- -rm $(TARGETS)
- -rm *.o *~
-
-tar: clean
- cd ..;tar czvf PDa-externals-$(VERSION).tgz PDa-externals
-
-upload: tar
- scp ../PDa-externals-$(VERSION).tgz gige@xdv.org:~/www/pda/release
-
-install:
- install -d $(DESTDIR)/$(PREFIX)/lib/pd/extra
- cp $(TARGETS) $(DESTDIR)/$(PREFIX)/lib/pd/extra
-
-%.$(EXT) : %.o
- $(CC) -o $@ $(EFLAGS) $+
-
-%.o : %.c
- $(CC) -c $(AFLAGS) $(CFLAGS) $+ \ No newline at end of file
diff --git a/apps/plugins/pdbox/PDa/extra/moog~.c b/apps/plugins/pdbox/PDa/extra/moog~.c
index ee7acc99aa..48d4dfe932 100644
--- a/apps/plugins/pdbox/PDa/extra/moog~.c
+++ b/apps/plugins/pdbox/PDa/extra/moog~.c
@@ -181,186 +181,4 @@ void moog_tilde_setup(void)
class_addmethod(moog_class, (t_method)moog_reset, gensym("reset"), 0);
class_addmethod(moog_class, (t_method)moog_dsp, gensym("dsp"), A_NULL);
}
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-#include "math.h"
-#include <m_pd.h>
-
-/* ----------------------------- moog ----------------------------- */
-static t_class *moog_class;
-
-
-typedef struct _moog
-{
- t_object x_obj;
- t_pd in2;
- t_sample x_1,x_2,x_3,x_4;
- t_sample y_1,y_2,y_3,y_4;
-} t_moog;
-
-static void moog_reset(t_moog *x)
-{
- x->x_1 = x->x_2 = x->x_3 = x->x_4 = 0;
- x->y_1 = x->y_2 = x->y_3 = x->y_4 = 0;
-
-}
-
-
-
-static void *moog_new(t_symbol *s, int argc, t_atom *argv)
-{
- if (argc > 1) post("moog~: extra arguments ignored");
- {
- t_moog *x = (t_moog *)pd_new(moog_class);
- outlet_new(&x->x_obj, &s_signal);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- inlet_new(&x->x_obj, &x->in2, &s_signal, &s_signal);
- moog_reset(x);
- return (x);
- }
-
-
-}
-
-
-
-static t_sample calc_k(t_sample f,t_sample k) {
- if (k>itofix(4)) k = itofix(4);
- if (k < 0) k = 0;
- if (f <= itofix(3800)) return k;
- k = k - mult(0.5,(f-idiv(itofix(3800),itofix(4300))));
- return k;
-}
-
-t_int *moog_perform(t_int *w)
-{
- t_moog* x = (t_moog*) (w[1]);
- t_sample *in1 = (t_sample *)(w[2]);
- t_sample *p = (t_sample *)(w[3]);
- t_sample *k = (t_sample *)(w[4]);
-
- t_sample *out = (t_sample *)(w[5]);
- int n = (int)(w[6]);
- t_sample in;
- t_sample pt,pt1;
-
- t_sample x1 = x->x_1;
- t_sample x2 = x->x_2;
- t_sample x3 = x->x_3;
- t_sample x4 = x->x_4;
- t_sample ys1 = x->y_1;
- t_sample ys2 = x->y_2;
- t_sample ys3 = x->y_3;
- t_sample ys4 = x->y_4;
-
-
- while (n--) {
- if (*p > itofix(8140)) *p = itofix(8140);
- *k = calc_k(*p,*k);
- pt =*p;
- pt1=mult((pt+1),ftofix(0.76923077));
- in = *in1++ - mult(*k,ys4);
- ys1 = mult(pt1,in) + mult(0.3,x1) - mult(pt,ys1);
- x1 = in;
- ys2 = mult(pt1,ys1) + mult(0.3,x2) - mult(pt,ys2);
- x2 = ys1;
- ys3 = mult(pt1,ys2) + mult(0.3,x3) - mult(pt,ys3);
- x3 = ys2;
- ys4 = mult(pt1,ys3) + mult(0.3,x4) - mult(pt,ys4);
- x4 = ys3;
- *out++ = ys4;
- }
-
-
- x->y_1 = ys1;
- x->y_2 = ys2;
- x->y_3 = ys3;
- x->y_4 = ys4;
- x->x_1 = x1;
- x->x_2 = x2;
- x->x_3 = x3;
- x->x_4 = x4;
-
- return (w+7);
-}
-
-
-#define CLIP(x) x = ((x) > 1.0 ? (1.0) : (x))
-
-t_int *moog_perf8(t_int *w)
-{
- t_moog* x = (t_moog*) (w[1]);
- t_sample *in1 = (t_sample *)(w[2]);
- t_sample *p = (t_sample *)(w[3]);
- t_sample *k = (t_sample *)(w[4]);
- t_sample *out = (t_sample *)(w[5]);
- int n = (int)(w[6]);
-
- t_sample x1 = x->x_1;
- t_sample x2 = x->x_2;
- t_sample x3 = x->x_3;
- t_sample x4 = x->x_4;
- t_sample ys1 = x->y_1;
- t_sample ys2 = x->y_2;
- t_sample ys3 = x->y_3;
- t_sample ys4 = x->y_4;
-
- t_sample temp,temp2;
- t_sample pt,pt1;
- t_sample in;
-
- while (n--) {
- if (*p > itofix(8140)) *p = itofix(8140);
- *k = calc_k(*p,*k);
-
- pt =mult(*p, ftofix(0.01*0.0140845)) - ftofix(0.9999999f);
- pt1=mult((pt+itofix(1)),ftofix(0.76923077));
- in = *in1++ - mult(*k,ys4);
- ys1 = mult(pt1,(in + mult(ftofix(0.3),x1))) - mult(pt,ys1);
- x1 = in;
- ys2 = mult(pt1,(ys1 + mult(0.3,x2))) - mult(pt,ys2);
- x2 = ys1;
- ys3 = mult(pt1,(ys2 + mult(0.3,x3))) - mult(pt,ys3);
- x3 = ys2;
- ys4 = mult(pt1,(ys3 + mult(0.3,x4))) - mult(pt,ys4);
- x4 = ys3;
- *out++ = ys4;
-
- p++;k++;
- }
-
- x->y_1 = ys1;
- x->y_2 = ys2;
- x->y_3 = ys3;
- x->y_4 = ys4;
- x->x_1 = x1;
- x->x_2 = x2;
- x->x_3 = x3;
- x->x_4 = x4;
-
- return (w+7);
-}
-
-void dsp_add_moog(t_moog *x, t_sample *in1, t_sample *in2, t_sample *in3, t_sample *out, int n)
-{
- if (n&7)
- dsp_add(moog_perform, 6,(t_int)x, in1,in2,in3, out, n);
- else
- dsp_add(moog_perf8, 6,(t_int) x, in1, in2, in3, out, n);
-}
-
-static void moog_dsp(t_moog *x, t_signal **sp)
-{
- dsp_add_moog(x,sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec,sp[0]->s_n);
-}
-
-
-void moog_tilde_setup(void)
-{
- moog_class = class_new(gensym("moog~"), (t_newmethod)moog_new, 0,
- sizeof(t_moog), 0, A_GIMME, 0);
- class_addmethod(moog_class, nullfn, gensym("signal"), 0);
- class_addmethod(moog_class, (t_method)moog_reset, gensym("reset"), 0);
- class_addmethod(moog_class, (t_method)moog_dsp, gensym("dsp"), A_NULL);
-}
+
diff --git a/apps/plugins/pdbox/PDa/extra/notch.c b/apps/plugins/pdbox/PDa/extra/notch.c
index 49be753ff2..0ab4332166 100644
--- a/apps/plugins/pdbox/PDa/extra/notch.c
+++ b/apps/plugins/pdbox/PDa/extra/notch.c
@@ -82,97 +82,4 @@ void notch_setup(void)
class_addbang(notch_class,notch_bang);
class_addfloat(notch_class,notch_float);
}
-
-
-
-
-
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-/*
-
- These filter coefficients computations are taken from
- http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
-
- written by Robert Bristow-Johnson
-
-*/
-
-#include "m_pd.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-#include <math.h>
-#include "filters.h"
-
-
-
-/* ------------------- notch ----------------------------*/
-
-static t_class *notch_class;
-
-void notch_bang(t_rbjfilter *x)
-{
- t_atom at[5];
- t_float omega = e_omega(x->x_freq,x->x_rate);
- t_float alpha = e_alpha(x->x_bw* 0.01,omega);
- t_float b1 = -2.*cos(omega);
- t_float b0 = 1;
- t_float b2 = b0;
- t_float a0 = 1 + alpha;
- t_float a1 = -2.*cos(omega);
- t_float a2 = 1 - alpha;
-
-/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
-
- if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
- post("notch: filter unstable -> resetting");
- a0=1.;a1=0.;a2=0.;
- b0=1.;b1=0.;b2=0.;
- }
-
- SETFLOAT(at,-a1/a0);
- SETFLOAT(at+1,-a2/a0);
- SETFLOAT(at+2,b0/a0);
- SETFLOAT(at+3,b1/a0);
- SETFLOAT(at+4,b2/a0);
-
- outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
-}
-
-
-void notch_float(t_rbjfilter *x,t_floatarg f)
-{
- x->x_freq = f;
- notch_bang(x);
-}
-
-
-static void *notch_new(t_floatarg f,t_floatarg bw)
-{
- t_rbjfilter *x = (t_rbjfilter *)pd_new(notch_class);
-
- x->x_rate = 44100.0;
- outlet_new(&x->x_obj,&s_float);
-/* floatinlet_new(&x->x_obj, &x->x_gain); */
- floatinlet_new(&x->x_obj, &x->x_bw);
- if (f > 0.) x->x_freq = f;
- if (bw > 0.) x->x_bw = bw;
- return (x);
-}
-
-
-void notch_setup(void)
-{
- notch_class = class_new(gensym("notch"), (t_newmethod)notch_new, 0,
- sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
- class_addbang(notch_class,notch_bang);
- class_addfloat(notch_class,notch_float);
-}
-
-
-
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/s_stuff.h b/apps/plugins/pdbox/PDa/extra/s_stuff.h
index 6dc9a88c4b..2c7ae8b209 100644
--- a/apps/plugins/pdbox/PDa/extra/s_stuff.h
+++ b/apps/plugins/pdbox/PDa/extra/s_stuff.h
@@ -213,218 +213,4 @@ void sys_set_audio_state(int onoff);
/* API dependent audio flags and settings */
void oss_set32bit( void);
void linux_alsa_devname(char *devname);
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* Audio and MIDI I/O, and other scheduling and system stuff. */
-
-/* NOTE: this file describes Pd implementation details which may change
-in future releases. The public (stable) API is in m_pd.h. */
-
-/* in s_file.c */
-typedef struct _namelist
-{
- struct _namelist *nl_next;
- char *nl_string;
-} t_namelist;
-
-t_namelist *namelist_append(t_namelist *listwas, const char *s);
-void namelist_free(t_namelist *listwas);
-
-/* s_main.c */
-extern int sys_debuglevel;
-extern int sys_verbose;
-extern int sys_noloadbang;
-extern int sys_nogui;
-extern char *sys_guicmd;
-
-EXTERN int sys_nearestfontsize(int fontsize);
-EXTERN int sys_hostfontsize(int fontsize);
-
-extern int sys_defaultfont;
-extern t_symbol *sys_libdir; /* library directory for auxilliary files */
-
-/* s_loader.c */
-int sys_load_lib(char *dirname, char *filename);
-
-/* s_audio.c */
-
-#define SENDDACS_NO 0 /* return values for sys_send_dacs() */
-#define SENDDACS_YES 1
-#define SENDDACS_SLEPT 2
-
-#define DEFDACBLKSIZE 64
-extern int sys_schedblocksize; /* audio block size for scheduler */
-extern int sys_hipriority; /* real-time flag, true if priority boosted */
-extern t_sample *sys_soundout;
-extern t_sample *sys_soundin;
-extern int sys_inchannels;
-extern int sys_outchannels;
-extern int sys_advance_samples; /* scheduler advance in samples */
-extern int sys_blocksize; /* audio I/O block size in sample frames */
-extern float sys_dacsr;
-extern int sys_schedadvance;
-extern int sys_sleepgrain;
-void sys_open_audio(int naudioindev, int *audioindev,
- int nchindev, int *chindev,
- int naudiooutdev, int *audiooutdev, int nchoutdev, int *choutdev,
- int srate, int advance, int enable);
-void sys_close_audio(void);
-
- /* s_midi.c */
-void sys_open_midi(int nmidiin, int *midiinvec, int nmidiout, int *midioutvec);
-
- /* implemented in the system dependent MIDI code (s_midi_pm.c, etc. ) */
-void sys_do_open_midi(int nmidiin, int *midiinvec,
- int nmidiout, int *midioutvec);
-void sys_close_midi(void);
-void midi_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int maxndev, int devdescsize);
-
-int sys_send_dacs(void);
-void sys_reportidle(void);
-void sys_set_priority(int higher);
-void sys_audiobuf(int nbufs);
-void sys_getmeters(float *inmax, float *outmax);
-void sys_listdevs(void);
-void sys_setblocksize(int n);
-
-/* s_midi.c */
-#define MAXMIDIINDEV 16 /* max. number of input ports */
-#define MAXMIDIOUTDEV 16 /* max. number of output ports */
-extern int sys_nmidiin;
-extern int sys_nmidiout;
-extern int sys_midiindevlist[];
-extern int sys_midioutdevlist[];
-
-EXTERN void sys_putmidimess(int portno, int a, int b, int c);
-EXTERN void sys_putmidibyte(int portno, int a);
-EXTERN void sys_poll_midi(void);
-EXTERN void sys_setmiditimediff(double inbuftime, double outbuftime);
-EXTERN void sys_midibytein(int portno, int byte);
-
-/* m_sched.c */
-EXTERN void sys_log_error(int type);
-#define ERR_NOTHING 0
-#define ERR_ADCSLEPT 1
-#define ERR_DACSLEPT 2
-#define ERR_RESYNC 3
-#define ERR_DATALATE 4
-void sched_set_using_dacs(int flag);
-
-/* s_inter.c */
-
-EXTERN void sys_microsleep(int microsec);
-
-EXTERN void sys_bail(int exitcode);
-EXTERN int sys_pollgui(void);
-
-EXTERN_STRUCT _socketreceiver;
-#define t_socketreceiver struct _socketreceiver
-
-typedef void (*t_socketnotifier)(void *x);
-typedef void (*t_socketreceivefn)(void *x, t_binbuf *b);
-
-EXTERN t_socketreceiver *socketreceiver_new(void *owner,
- t_socketnotifier notifier, t_socketreceivefn socketreceivefn, int udp);
-EXTERN void socketreceiver_read(t_socketreceiver *x, int fd);
-EXTERN void sys_sockerror(char *s);
-EXTERN void sys_closesocket(int fd);
-
-typedef void (*t_fdpollfn)(void *ptr, int fd);
-EXTERN void sys_addpollfn(int fd, t_fdpollfn fn, void *ptr);
-EXTERN void sys_rmpollfn(int fd);
-#ifdef UNIX
-void sys_setalarm(int microsec);
-void sys_setvirtualalarm( void);
-#endif
-
-#define API_ALSA 1
-#define API_OSS 2
-#define API_MMIO 3
-#define API_PORTAUDIO 4
-#define API_JACK 5
-
-#ifdef __linux__
-#define API_DEFAULT API_OSS
-#define API_DEFSTRING "OSS"
-#endif
-#ifdef MSW
-#define API_DEFAULT API_MMIO
-#define API_DEFSTRING "MMIO"
-#endif
-#ifdef MACOSX
-#define API_DEFAULT API_PORTAUDIO
-#define API_DEFSTRING "portaudio"
-#endif
-#define DEFAULTAUDIODEV 0
-#define MAXAUDIOINDEV 4
-#define MAXAUDIOOUTDEV 4
-
-#define DEFMIDIDEV 0
-
-#define DEFAULTSRATE 44100
-#ifdef MSW
-#define DEFAULTADVANCE 70
-#else
-#define DEFAULTADVANCE 50
-#endif
-
-int pa_open_audio(int inchans, int outchans, int rate, t_sample *soundin,
- t_sample *soundout, int framesperbuf, int nbuffers,
- int indeviceno, int outdeviceno);
-void pa_close_audio(void);
-int pa_send_dacs(void);
-void sys_reportidle(void);
-void pa_listdevs(void);
-void pa_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize);
-
-int oss_open_audio(int naudioindev, int *audioindev, int nchindev,
- int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
- int *choutdev, int rate); /* IOhannes */
-void oss_close_audio(void);
-int oss_send_dacs(void);
-void oss_reportidle(void);
-void oss_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize);
-
-int alsa_open_audio(int naudioindev, int *audioindev, int nchindev,
- int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
- int *choutdev, int rate);
-void alsa_close_audio(void);
-int alsa_send_dacs(void);
-void alsa_reportidle(void);
-void alsa_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize);
-
-int jack_open_audio(int wantinchans, int wantoutchans, int srate);
-void jack_close_audio(void);
-int jack_send_dacs(void);
-void jack_reportidle(void);
-void jack_listdevs(void);
-
-void mmio_open_audio(int naudioindev, int *audioindev,
- int nchindev, int *chindev, int naudiooutdev, int *audiooutdev,
- int nchoutdev, int *choutdev, int rate);
-void mmio_close_audio( void);
-void mmio_reportidle(void);
-int mmio_send_dacs(void);
-void mmio_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize);
-
-void sys_listmididevs(void);
-void sys_set_audio_api(int whichapi);
-void sys_get_audio_apis(char *buf);
-extern int sys_audioapi;
-void sys_set_audio_state(int onoff);
-
-/* API dependent audio flags and settings */
-void oss_set32bit( void);
-void linux_alsa_devname(char *devname);
diff --git a/apps/plugins/pdbox/PDa/extra/sendOSC.c b/apps/plugins/pdbox/PDa/extra/sendOSC.c
index c00f693280..bc983cc31e 100644
--- a/apps/plugins/pdbox/PDa/extra/sendOSC.c
+++ b/apps/plugins/pdbox/PDa/extra/sendOSC.c
@@ -1458,1465 +1458,4 @@ static int OSC_WritePadding(char *dest, int i) {
return i;
}
-
-/*
-Written by Matt Wright, The Center for New Music and Audio Technologies,
-University of California, Berkeley. Copyright (c) 1996,97,98,99,2000,01,02,03
-The Regents of the University of California (Regents).
-
-Permission to use, copy, modify, distribute, and distribute modified versions
-of this software and its documentation without fee and without a signed
-licensing agreement, is hereby granted, provided that the above copyright
-notice, this paragraph and the following two paragraphs appear in all copies,
-modifications, and distributions.
-
-IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
-OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
-BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
-HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
-MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-
-The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl
-*/
-
-
-/* sendOSC.c
-
- Matt Wright, 6/3/97
- based on sendOSC.c, which was based on a version by Adrian Freed
-
- Text-based OpenSoundControl client. User can enter messages via command
- line arguments or standard input.
-
- Version 0.1: "play" feature
- Version 0.2: Message type tags.
-
- pd version branched from http://www.cnmat.berkeley.edu/OpenSoundControl/src/sendOSC/sendOSC.c
- -------------
- -- added bundle stuff to send. jdl 20020416
- -- tweaks for Win32 www.zeggz.com/raf 13-April-2002
- -- ost_at_test.at + i22_at_test.at, 2000-2002
- modified to compile as pd externel
-*/
-
-#define MAX_ARGS 2000
-#define SC_BUFFER_SIZE 64000
-
-#include "m_pd.h"
-#include "OSC-client.h"
-
-#include <string.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#ifdef WIN32
-#include <winsock2.h>
-#include <io.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <winsock2.h>
-#include <ctype.h>
-#include <signal.h>
-#else
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <rpc/rpc.h>
-#include <sys/times.h>
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <netdb.h>
-#endif
-
-#ifdef __APPLE__
- #include <string.h>
-#endif
-
-#define UNIXDG_PATH "/tmp/htm"
-#define UNIXDG_TMP "/tmp/htm.XXXXXX"
-
-
-
-OSCTimeTag OSCTT_Immediately(void) {
- OSCTimeTag result;
- result.seconds = 0;
- result.fraction = 1;
- return result;
-}
-
-
-OSCTimeTag OSCTT_CurrentTime(void) {
- OSCTimeTag result;
- result.seconds = 0;
- result.fraction = 1;
- return result;
-}
-
-OSCTimeTag OSCTT_PlusSeconds(OSCTimeTag original, float secondsOffset) {
- OSCTimeTag result;
- result.seconds = 0;
- result.fraction = 1;
- return result;
-}
-
-
-typedef int bool;
-
-typedef struct
-{
- float srate;
-
- struct sockaddr_in serv_addr; /* udp socket */
- #ifndef WIN32
- struct sockaddr_un userv_addr; /* UNIX socket */
- #endif
- int sockfd; /* socket file descriptor */
- int index, len,uservlen;
- void *addr;
- int id;
-} desc;
-
-
-/* open a socket for HTM communication to given host on given portnumber */
-/* if host is 0 then UNIX protocol is used (i.e. local communication */
-void *OpenHTMSocket(char *host, int portnumber)
-{
- struct sockaddr_in cl_addr;
- #ifndef WIN32
- int sockfd;
- struct sockaddr_un ucl_addr;
- #else
- unsigned int sockfd;
- #endif
-
- desc *o;
- int oval = 1;
- o = malloc(sizeof(*o));
- if(!o) return 0;
-
- #ifndef WIN32
-
- if(!host)
- {
- char *mktemp(char *);
- int clilen;
- o->len = sizeof(ucl_addr);
- /*
- * Fill in the structure "userv_addr" with the address of the
- * server that we want to send to.
- */
-
- bzero((char *) &o->userv_addr, sizeof(o->userv_addr));
- o->userv_addr.sun_family = AF_UNIX;
- strcpy(o->userv_addr.sun_path, UNIXDG_PATH);
- sprintf(o->userv_addr.sun_path+strlen(o->userv_addr.sun_path), "%d", portnumber);
- o->uservlen = sizeof(o->userv_addr.sun_family) + strlen(o->userv_addr.sun_path);
- o->addr = &(o->userv_addr);
- /*
- * Open a socket (a UNIX domain datagram socket).
- */
-
- if ( (sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) >= 0)
- {
- /*
- * Bind a local address for us.
- * In the UNIX domain we have to choose our own name (that
- * should be unique). We'll use mktemp() to create a unique
- * pathname, based on our process id.
- */
-
- bzero((char *) &ucl_addr, sizeof(ucl_addr)); /* zero out */
- ucl_addr.sun_family = AF_UNIX;
- strcpy(ucl_addr.sun_path, UNIXDG_TMP);
-
- mktemp(ucl_addr.sun_path);
- clilen = sizeof(ucl_addr.sun_family) + strlen(ucl_addr.sun_path);
-
- if (bind(sockfd, (struct sockaddr *) &ucl_addr, clilen) < 0)
- {
- perror("client: can't bind local address");
- close(sockfd);
- sockfd = -1;
- }
- }
- else
- perror("unable to make socket\n");
-
- }else
-
- #endif
-
- {
- /*
- * Fill in the structure "serv_addr" with the address of the
- * server that we want to send to.
- */
- o->len = sizeof(cl_addr);
-
- #ifdef WIN32
- ZeroMemory((char *)&o->serv_addr, sizeof(o->serv_addr));
- #else
- bzero((char *)&o->serv_addr, sizeof(o->serv_addr));
- #endif
-
- o->serv_addr.sin_family = AF_INET;
-
- /* MW 6/6/96: Call gethostbyname() instead of inet_addr(),
- so that host can be either an Internet host name (e.g.,
- "les") or an Internet address in standard dot notation
- (e.g., "128.32.122.13") */
- {
- struct hostent *hostsEntry;
- unsigned long address;
-
- hostsEntry = gethostbyname(host);
- if (hostsEntry == NULL) {
- fprintf(stderr, "Couldn't decipher host name \"%s\"\n", host);
- #ifndef WIN32
- herror(NULL);
- #endif
- return 0;
- }
- address = *((unsigned long *) hostsEntry->h_addr_list[0]);
- o->serv_addr.sin_addr.s_addr = address;
- }
-
- /* was: o->serv_addr.sin_addr.s_addr = inet_addr(host); */
-
- /* End MW changes */
-
- /*
- * Open a socket (a UDP domain datagram socket).
- */
-
-
- #ifdef WIN32
- o->serv_addr.sin_port = htons((USHORT)portnumber);
- o->addr = &(o->serv_addr);
- if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET) {
- ZeroMemory((char *)&cl_addr, sizeof(cl_addr));
- cl_addr.sin_family = AF_INET;
- cl_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- cl_addr.sin_port = htons(0);
-
- // enable broadcast: jdl ~2003
- if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &oval, sizeof(int)) == -1) {
- perror("setsockopt");
- }
-
- if(bind(sockfd, (struct sockaddr *) &cl_addr, sizeof(cl_addr)) < 0) {
- perror("could not bind\n");
- closesocket(sockfd);
- sockfd = -1;
- }
- }
- else { perror("unable to make socket\n");}
- #else
- o->serv_addr.sin_port = htons(portnumber);
- o->addr = &(o->serv_addr);
- if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
- bzero((char *)&cl_addr, sizeof(cl_addr));
- cl_addr.sin_family = AF_INET;
- cl_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- cl_addr.sin_port = htons(0);
-
- // enable broadcast: jdl ~2003
- if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &oval, sizeof(int)) == -1) {
- perror("setsockopt");
- }
-
- if(bind(sockfd, (struct sockaddr *) &cl_addr, sizeof(cl_addr)) < 0) {
- perror("could not bind\n");
- close(sockfd);
- sockfd = -1;
- }
- }
- else { perror("unable to make socket\n");}
- #endif
- }
- #ifdef WIN32
- if(sockfd == INVALID_SOCKET) {
- #else
- if(sockfd < 0) {
- #endif
- free(o);
- o = 0;
- }
- else
- o->sockfd = sockfd;
- return o;
-}
-
-static bool sendudp(const struct sockaddr *sp, int sockfd,int length, int count, void *b)
-{
- int rcount;
- if((rcount=sendto(sockfd, b, count, 0, sp, length)) != count)
- {
- printf("sockfd %d count %d rcount %dlength %d\n", sockfd,count,rcount,length);
- return FALSE;
- }
- return TRUE;
-}
-
-bool SendHTMSocket(void *htmsendhandle, int length_in_bytes, void *buffer)
-{
- desc *o = (desc *)htmsendhandle;
- return sendudp(o->addr, o->sockfd, o->len, length_in_bytes, buffer);
-}
-void CloseHTMSocket(void *htmsendhandle)
-{
- desc *o = (desc *)htmsendhandle;
- #ifdef WIN32
- if(SOCKET_ERROR == closesocket(o->sockfd)) {
- perror("CloseHTMSocket::closesocket failed\n");
- return;
- }
- #else
- if(close(o->sockfd) == -1)
- {
- perror("CloseHTMSocket::closesocket failed");
- return;
- }
- #endif
-
- free(o);
-}
-
-
-///////////////////////
-// from sendOSC
-
-typedef struct {
- //enum {INT, FLOAT, STRING} type;
- enum {INT_osc, FLOAT_osc, STRING_osc} type;
- union {
- int i;
- float f;
- char *s;
- } datum;
-} typedArg;
-
-void CommandLineMode(int argc, char *argv[], void *htmsocket);
-OSCTimeTag ParseTimeTag(char *s);
-void ParseInteractiveLine(OSCbuf *buf, char *mesg);
-typedArg ParseToken(char *token);
-int WriteMessage(OSCbuf *buf, char *messageName, int numArgs, typedArg *args);
-void SendBuffer(void *htmsocket, OSCbuf *buf);
-void SendData(void *htmsocket, int size, char *data);
-/* defined in OSC-system-dependent.c now */
-
-//static void *htmsocket;
-static int exitStatus = 0;
-static int useTypeTags = 0;
-
-static char bufferForOSCbuf[SC_BUFFER_SIZE];
-
-
-/////////
-// end from sendOSC
-
-static t_class *sendOSC_class;
-
-typedef struct _sendOSC
-{
- t_object x_obj;
- int x_protocol; // UDP/TCP (udp only atm)
- t_int x_typetags; // typetag flag
- void *x_htmsocket; // sending socket
- int x_bundle; // bundle open flag
- OSCbuf x_oscbuf[1]; // OSCbuffer
- t_outlet *x_bdpthout;// bundle-depth floatoutlet
-} t_sendOSC;
-
-static void *sendOSC_new(t_floatarg udpflag)
-{
- t_sendOSC *x = (t_sendOSC *)pd_new(sendOSC_class);
- outlet_new(&x->x_obj, &s_float);
- x->x_htmsocket = 0; // {{raf}}
- // set udp
- x->x_protocol = SOCK_STREAM;
- // set typetags to 1 by default
- x->x_typetags = 1;
- // bunlde is closed
- x->x_bundle = 0;
- OSC_initBuffer(x->x_oscbuf, SC_BUFFER_SIZE, bufferForOSCbuf);
- x->x_bdpthout = outlet_new(&x->x_obj, 0); // outlet_float();
- //x->x_oscbuf =
- return (x);
-}
-
-
-void sendOSC_openbundle(t_sendOSC *x)
-{
- if (x->x_oscbuf->bundleDepth + 1 >= MAX_BUNDLE_NESTING ||
- OSC_openBundle(x->x_oscbuf, OSCTT_Immediately()))
- {
- post("Problem opening bundle: %s\n", OSC_errorMessage);
- return;
- }
- x->x_bundle = 1;
- outlet_float(x->x_bdpthout, (float)x->x_oscbuf->bundleDepth);
-}
-
-static void sendOSC_closebundle(t_sendOSC *x)
-{
- if (OSC_closeBundle(x->x_oscbuf)) {
- post("Problem closing bundle: %s\n", OSC_errorMessage);
- return;
- }
- outlet_float(x->x_bdpthout, (float)x->x_oscbuf->bundleDepth);
- // in bundle mode we send when bundle is closed?
- if(!OSC_isBufferEmpty(x->x_oscbuf) > 0 && OSC_isBufferDone(x->x_oscbuf)) {
- // post("x_oscbuf: something inside me?");
- if (x->x_htmsocket) {
- SendBuffer(x->x_htmsocket, x->x_oscbuf);
- } else {
- post("sendOSC: not connected");
- }
- OSC_initBuffer(x->x_oscbuf, SC_BUFFER_SIZE, bufferForOSCbuf);
- x->x_bundle = 0;
- return;
- }
- // post("x_oscbuf: something went wrong");
-}
-
-static void sendOSC_settypetags(t_sendOSC *x, t_float *f)
- {
- x->x_typetags = (int)f;
- post("sendOSC.c: setting typetags %d",x->x_typetags);
- }
-
-
-static void sendOSC_connect(t_sendOSC *x, t_symbol *hostname,
- t_floatarg fportno)
-{
- int portno = fportno;
- /* create a socket */
-
- // make sure handle is available
- if(x->x_htmsocket == 0) {
- //
- x->x_htmsocket = OpenHTMSocket(hostname->s_name, portno);
- if (!x->x_htmsocket)
- post("Couldn't open socket: ");
- else {
- post("connected to port %s:%d (hSock=%d)", hostname->s_name, portno, x->x_htmsocket);
- outlet_float(x->x_obj.ob_outlet, 1);
- }
- }
- else
- perror("call to sendOSC_connect() against UNavailable socket handle");
-}
-
-void sendOSC_disconnect(t_sendOSC *x)
-{
- if (x->x_htmsocket)
- {
- post("disconnecting htmsock (hSock=%d)...", x->x_htmsocket);
- CloseHTMSocket(x->x_htmsocket);
- x->x_htmsocket = 0; // {{raf}} semi-quasi-semaphorize this
- outlet_float(x->x_obj.ob_outlet, 0);
- }
- else {
- perror("call to sendOSC_disconnect() against unused socket handle");
- }
-}
-
-void sendOSC_senduntyped(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv)
-{
- char* targv[MAXPDARG];
- char tmparg[MAXPDSTRING];
- char* tmp = tmparg;
- //char testarg[MAXPDSTRING];
- int c;
-
- post("sendOSC: use typetags 0/1 message and plain send method so send untypetagged...");
- return;
-
- //atom_string(argv,testarg, MAXPDSTRING);
- for (c=0;c<argc;c++) {
- atom_string(argv+c,tmp, 80);
- targv[c] = tmp;
- tmp += strlen(tmp)+1;
- }
-
- // this sock needs to be larger than 0, not >= ..
- if (x->x_htmsocket)
- {
- CommandLineMode(argc, targv, x->x_htmsocket);
- // post("test %d", c);
- }
- else {
- post("sendOSC: not connected");
- }
-}
-
-//////////////////////////////////////////////////////////////////////
-// this is the real and only sending routine now, for both typed and
-// undtyped mode.
-
-static void sendOSC_sendtyped(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv)
-{
- char* targv[MAX_ARGS];
- char tmparg[MAXPDSTRING];
- char* tmp = tmparg;
- int c;
-
- char *messageName;
- char *token;
- typedArg args[MAX_ARGS];
- int i,j;
- int numArgs = 0;
-
- messageName = "";
-#ifdef DEBUG
- post ("sendOSC: messageName: %s", messageName);
-#endif
-
-
-
- for (c=0;c<argc;c++) {
- atom_string(argv+c,tmp, 80);
-
-#ifdef DEBUG
- // post ("sendOSC: %d, %s",c, tmp);
-#endif
-
- targv[c] = tmp;
- tmp += strlen(tmp)+1;
-
-#ifdef DEBUG
- // post ("sendOSC: %d, %s",c, targv[c]);
-#endif
- }
-
- // this sock needs to be larger than 0, not >= ..
- if (x->x_htmsocket > 0)
- {
-#ifdef DEBUG
- post ("sendOSC: type tags? %d", useTypeTags);
-#endif
-
- messageName = strtok(targv[0], ",");
- j = 1;
- for (i = j; i < argc; i++) {
- token = strtok(targv[i],",");
- args[i-j] = ParseToken(token);
-#ifdef DEBUG
- printf("cell-cont: %s\n", targv[i]);
- printf(" type-id: %d\n", args[i-j]);
-#endif
- numArgs = i;
- }
-
-
- if(WriteMessage(x->x_oscbuf, messageName, numArgs, args)) {
- post("sendOSC: usage error, write-msg failed: %s", OSC_errorMessage);
- return;
- }
-
- if(!x->x_bundle) {
- SendBuffer(x->x_htmsocket, x->x_oscbuf);
- OSC_initBuffer(x->x_oscbuf, SC_BUFFER_SIZE, bufferForOSCbuf);
- }
-
- //CommandLineMode(argc, targv, x->x_htmsocket);
- //useTypeTags = 0;
- }
- else {
- post("sendOSC: not connected");
- }
-}
-
-void sendOSC_send(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv)
-{
- if(!argc) {
- post("not sending empty message.");
- return;
- }
- if(x->x_typetags) {
- useTypeTags = 1;
- sendOSC_sendtyped(x,s,argc,argv);
- useTypeTags = 0;
- } else {
- sendOSC_sendtyped(x,s,argc,argv);
- }
-}
-
-static void sendOSC_free(t_sendOSC *x)
-{
- sendOSC_disconnect(x);
-}
-
-#ifdef WIN32
- OSC_API void sendOSC_setup(void) {
-#else
- void sendOSC_setup(void) {
-#endif
- sendOSC_class = class_new(gensym("sendOSC"), (t_newmethod)sendOSC_new,
- (t_method)sendOSC_free,
- sizeof(t_sendOSC), 0, A_DEFFLOAT, 0);
- class_addmethod(sendOSC_class, (t_method)sendOSC_connect,
- gensym("connect"), A_SYMBOL, A_FLOAT, 0);
- class_addmethod(sendOSC_class, (t_method)sendOSC_disconnect,
- gensym("disconnect"), 0);
- class_addmethod(sendOSC_class, (t_method)sendOSC_settypetags,
- gensym("typetags"),
- A_FLOAT, 0);
- class_addmethod(sendOSC_class, (t_method)sendOSC_send,
- gensym("send"),
- A_GIMME, 0);
- class_addmethod(sendOSC_class, (t_method)sendOSC_send,
- gensym("senduntyped"),
- A_GIMME, 0);
- class_addmethod(sendOSC_class, (t_method)sendOSC_send,
- gensym("sendtyped"),
- A_GIMME, 0);
- class_addmethod(sendOSC_class, (t_method)sendOSC_openbundle,
- gensym("["),
- 0, 0);
- class_addmethod(sendOSC_class, (t_method)sendOSC_closebundle,
- gensym("]"),
- 0, 0);
- class_sethelpsymbol(sendOSC_class, gensym("sendOSC-help.pd"));
-}
-
-
-
-
-
-/* Exit status codes:
- 0: successful
- 2: Message(s) dropped because of buffer overflow
- 3: Socket error
- 4: Usage error
- 5: Internal error
-*/
-
-void CommandLineMode(int argc, char *argv[], void *htmsocket) {
- char *messageName;
- char *token;
- typedArg args[MAX_ARGS];
- int i,j, numArgs;
- OSCbuf buf[1];
-
- OSC_initBuffer(buf, SC_BUFFER_SIZE, bufferForOSCbuf);
-
- if (argc > 1) {
- post("argc (%d) > 1", argc);
- }
-
- // ParseInteractiveLine(buf, argv);
- messageName = strtok(argv[0], ",");
-
- j = 1;
- for (i = j; i < argc; i++) {
- token = strtok(argv[i],",");
- args[i-j] = ParseToken(token);
-#ifdef DEBUG
- printf("cell-cont: %s\n", argv[i]);
- printf(" type-id: %d\n", args[i-j]);
-#endif
- numArgs = i;
- }
-
- if(WriteMessage(buf, messageName, numArgs, args)) {
- post("sendOSC: usage error. write-msg failed: %s", OSC_errorMessage);
- return;
- }
-
- SendBuffer(htmsocket, buf);
-}
-
-#define MAXMESG 2048
-
-void InteractiveMode(void *htmsocket) {
- char mesg[MAXMESG];
- OSCbuf buf[1];
- int bundleDepth = 0; /* At first, we haven't seen "[". */
-
- OSC_initBuffer(buf, SC_BUFFER_SIZE, bufferForOSCbuf);
-
- while (fgets(mesg, MAXMESG, stdin) != NULL) {
- if (mesg[0] == '\n') {
- if (bundleDepth > 0) {
- /* Ignore blank lines inside a group. */
- } else {
- /* blank line => repeat previous send */
- SendBuffer(htmsocket, buf);
- }
- continue;
- }
-
- if (bundleDepth == 0) {
- OSC_resetBuffer(buf);
- }
-
- if (mesg[0] == '[') {
- OSCTimeTag tt = ParseTimeTag(mesg+1);
- if (OSC_openBundle(buf, tt)) {
- post("Problem opening bundle: %s\n", OSC_errorMessage);
- OSC_resetBuffer(buf);
- bundleDepth = 0;
- continue;
- }
- bundleDepth++;
- } else if (mesg[0] == ']' && mesg[1] == '\n' && mesg[2] == '\0') {
- if (bundleDepth == 0) {
- post("Unexpected ']': not currently in a bundle.\n");
- } else {
- if (OSC_closeBundle(buf)) {
- post("Problem closing bundle: %s\n", OSC_errorMessage);
- OSC_resetBuffer(buf);
- bundleDepth = 0;
- continue;
- }
-
- bundleDepth--;
- if (bundleDepth == 0) {
- SendBuffer(htmsocket, buf);
- }
- }
- } else {
- ParseInteractiveLine(buf, mesg);
- if (bundleDepth != 0) {
- /* Don't send anything until we close all bundles */
- } else {
- SendBuffer(htmsocket, buf);
- }
- }
- }
-}
-
-OSCTimeTag ParseTimeTag(char *s) {
- char *p, *newline;
- typedArg arg;
-
- p = s;
- while (isspace(*p)) p++;
- if (*p == '\0') return OSCTT_Immediately();
-
- if (*p == '+') {
- /* Time tag is for some time in the future. It should be a
- number of seconds as an int or float */
-
- newline = strchr(s, '\n');
- if (newline != NULL) *newline = '\0';
-
- p++; /* Skip '+' */
- while (isspace(*p)) p++;
-
- arg = ParseToken(p);
- if (arg.type == STRING_osc) {
- post("warning: inscrutable time tag request: %s\n", s);
- return OSCTT_Immediately();
- } else if (arg.type == INT_osc) {
- return OSCTT_PlusSeconds(OSCTT_CurrentTime(),
- (float) arg.datum.i);
- } else if (arg.type == FLOAT_osc) {
- return OSCTT_PlusSeconds(OSCTT_CurrentTime(), arg.datum.f);
- } else {
- error("This can't happen!");
- }
- }
-
- if (isdigit(*p) || (*p >= 'a' && *p <='f') || (*p >= 'A' && *p <='F')) {
- /* They specified the 8-byte tag in hex */
- OSCTimeTag tt;
- if (sscanf(p, "%llx", &tt) != 1) {
- post("warning: couldn't parse time tag %s\n", s);
- return OSCTT_Immediately();
- }
-#ifndef HAS8BYTEINT
- if (ntohl(1) != 1) {
- /* tt is a struct of seconds and fractional part,
- and this machine is little-endian, so sscanf
- wrote each half of the time tag in the wrong half
- of the struct. */
- int temp;
- temp = tt.seconds;
- tt.seconds = tt.fraction ;
- tt.fraction = temp;
- }
-#endif
- return tt;
- }
-
- post("warning: invalid time tag: %s\n", s);
- return OSCTT_Immediately();
-}
-
-
-void ParseInteractiveLine(OSCbuf *buf, char *mesg) {
- char *messageName, *token, *p;
- typedArg args[MAX_ARGS];
- int thisArg;
-
- p = mesg;
- while (isspace(*p)) p++;
- if (*p == '\0') return;
-
- messageName = p;
-
- if (strcmp(messageName, "play\n") == 0) {
- /* Special kludge feature to save typing */
- typedArg arg;
-
- if (OSC_openBundle(buf, OSCTT_Immediately())) {
- post("Problem opening bundle: %s\n", OSC_errorMessage);
- return;
- }
-
- arg.type = INT_osc;
- arg.datum.i = 0;
- WriteMessage(buf, "/voices/0/tp/timbre_index", 1, &arg);
-
- arg.type = FLOAT_osc;
- arg.datum.i = 0.0f;
- WriteMessage(buf, "/voices/0/tm/goto", 1, &arg);
-
- if (OSC_closeBundle(buf)) {
- post("Problem closing bundle: %s\n", OSC_errorMessage);
- }
-
- return;
- }
-
- while (!isspace(*p) && *p != '\0') p++;
- if (isspace(*p)) {
- *p = '\0';
- p++;
- }
-
- thisArg = 0;
- while (*p != '\0') {
- /* flush leading whitespace */
- while (isspace(*p)) p++;
- if (*p == '\0') break;
-
- if (*p == '"') {
- /* A string argument: scan for close quotes */
- p++;
- args[thisArg].type = STRING_osc;
- args[thisArg].datum.s = p;
-
- while (*p != '"') {
- if (*p == '\0') {
- post("Unterminated quote mark: ignoring line\n");
- return;
- }
- p++;
- }
- *p = '\0';
- p++;
- } else {
- token = p;
- while (!isspace(*p) && (*p != '\0')) p++;
- if (isspace(*p)) {
- *p = '\0';
- p++;
- }
- args[thisArg] = ParseToken(token);
- }
- thisArg++;
- if (thisArg >= MAX_ARGS) {
- post("Sorry, your message has more than MAX_ARGS (%d) arguments; ignoring the rest.\n",
- MAX_ARGS);
- break;
- }
- }
-
- if (WriteMessage(buf, messageName, thisArg, args) != 0) {
- post("Problem sending message: %s\n", OSC_errorMessage);
- }
-}
-
-typedArg ParseToken(char *token) {
- char *p = token;
- typedArg returnVal;
-
- /* It might be an int, a float, or a string */
-
- if (*p == '-') p++;
-
- if (isdigit(*p) || *p == '.') {
- while (isdigit(*p)) p++;
- if (*p == '\0') {
- returnVal.type = INT_osc;
- returnVal.datum.i = atoi(token);
- return returnVal;
- }
- if (*p == '.') {
- p++;
- while (isdigit(*p)) p++;
- if (*p == '\0') {
- returnVal.type = FLOAT_osc;
- returnVal.datum.f = atof(token);
- return returnVal;
- }
- }
- }
-
- returnVal.type = STRING_osc;
- returnVal.datum.s = token;
- return returnVal;
-}
-
-int WriteMessage(OSCbuf *buf, char *messageName, int numArgs, typedArg *args) {
- int j, returnVal;
- const int wmERROR = -1;
-
- returnVal = 0;
-
-#ifdef DEBUG
- printf("WriteMessage: %s ", messageName);
-
- for (j = 0; j < numArgs; j++) {
- switch (args[j].type) {
- case INT_osc:
- printf("%d ", args[j].datum.i);
- break;
-
- case FLOAT_osc:
- printf("%f ", args[j].datum.f);
- break;
-
- case STRING_osc:
- printf("%s ", args[j].datum.s);
- break;
-
- default:
- error("Unrecognized arg type, (not exiting)");
- return(wmERROR);
- }
- }
- printf("\n");
-#endif
-
- if (!useTypeTags) {
- returnVal = OSC_writeAddress(buf, messageName);
- if (returnVal) {
- post("Problem writing address: %s\n", OSC_errorMessage);
- }
- } else {
- /* First figure out the type tags */
- char typeTags[MAX_ARGS+2];
- int i;
-
- typeTags[0] = ',';
-
- for (i = 0; i < numArgs; ++i) {
- switch (args[i].type) {
- case INT_osc:
- typeTags[i+1] = 'i';
- break;
-
- case FLOAT_osc:
- typeTags[i+1] = 'f';
- break;
-
- case STRING_osc:
- typeTags[i+1] = 's';
- break;
-
- default:
- error("Unrecognized arg type (not exiting)");
- return(wmERROR);
- }
- }
- typeTags[i+1] = '\0';
-
- returnVal = OSC_writeAddressAndTypes(buf, messageName, typeTags);
- if (returnVal) {
- post("Problem writing address: %s\n", OSC_errorMessage);
- }
- }
-
- for (j = 0; j < numArgs; j++) {
- switch (args[j].type) {
- case INT_osc:
- if ((returnVal = OSC_writeIntArg(buf, args[j].datum.i)) != 0) {
- return returnVal;
- }
- break;
-
- case FLOAT_osc:
- if ((returnVal = OSC_writeFloatArg(buf, args[j].datum.f)) != 0) {
- return returnVal;
- }
- break;
-
- case STRING_osc:
- if ((returnVal = OSC_writeStringArg(buf, args[j].datum.s)) != 0) {
- return returnVal;
- }
- break;
-
- default:
- error("Unrecognized arg type (not exiting)");
- returnVal = wmERROR;
- }
- }
- return returnVal;
-}
-
-void SendBuffer(void *htmsocket, OSCbuf *buf) {
-#ifdef DEBUG
- printf("Sending buffer...\n");
-#endif
- if (OSC_isBufferEmpty(buf)) {
- post("SendBuffer() called but buffer empty");
- return;
- }
- if (!OSC_isBufferDone(buf)) {
- error("SendBuffer() called but buffer not ready!, not exiting");
- return; //{{raf}}
- }
- SendData(htmsocket, OSC_packetSize(buf), OSC_getPacket(buf));
-}
-
-void SendData(void *htmsocket, int size, char *data) {
- if (!SendHTMSocket(htmsocket, size, data)) {
- post("SendData::SendHTMSocket()failure -- not connected");
- CloseHTMSocket(htmsocket);
- }
-}
-
-
-
-/* ----------------------
- OSC-client code
-
- */
-
-/* Here are the possible values of the state field: */
-
-#define EMPTY 0 /* Nothing written to packet yet */
-#define ONE_MSG_ARGS 1 /* Packet has a single message; gathering arguments */
-#define NEED_COUNT 2 /* Just opened a bundle; must write message name or
- open another bundle */
-#define GET_ARGS 3 /* Getting arguments to a message. If we see a message
- name or a bundle open/close then the current message
- will end. */
-#define DONE 4 /* All open bundles have been closed, so can't write
- anything else */
-
-#ifdef WIN32
- #include <winsock2.h>
- #include <io.h>
- #include <stdio.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
-#endif
-
-#ifdef __APPLE__
- #include <sys/types.h>
-#endif
-
-#ifdef unix
- #include <netinet/in.h>
- #include <stdio.h>
-#endif
-
-
-char *OSC_errorMessage;
-
-static int OSC_padString(char *dest, char *str);
-static int OSC_padStringWithAnExtraStupidComma(char *dest, char *str);
-static int OSC_WritePadding(char *dest, int i);
-static int CheckTypeTag(OSCbuf *buf, char expectedType);
-
-void OSC_initBuffer(OSCbuf *buf, int size, char *byteArray) {
- buf->buffer = byteArray;
- buf->size = size;
- OSC_resetBuffer(buf);
-}
-
-void OSC_resetBuffer(OSCbuf *buf) {
- buf->bufptr = buf->buffer;
- buf->state = EMPTY;
- buf->bundleDepth = 0;
- buf->prevCounts[0] = 0;
- buf->gettingFirstUntypedArg = 0;
- buf->typeStringPtr = 0;
-}
-
-int OSC_isBufferEmpty(OSCbuf *buf) {
- return buf->bufptr == buf->buffer;
-}
-
-int OSC_freeSpaceInBuffer(OSCbuf *buf) {
- return buf->size - (buf->bufptr - buf->buffer);
-}
-
-int OSC_isBufferDone(OSCbuf *buf) {
- return (buf->state == DONE || buf->state == ONE_MSG_ARGS);
-}
-
-char *OSC_getPacket(OSCbuf *buf) {
-#ifdef ERROR_CHECK_GETPACKET
- if (buf->state == DONE || buf->state == ONE_MSG_ARGS) {
- return buf->buffer;
- } else {
- OSC_errorMessage = "Packet has unterminated bundles";
- return 0;
- }
-#else
- return buf->buffer;
-#endif
-}
-
-int OSC_packetSize(OSCbuf *buf) {
-#ifdef ERROR_CHECK_PACKETSIZE
- if (buf->state == DONE || buf->state == ONE_MSG_ARGS) {
- return (buf->bufptr - buf->buffer);
- } else {
- OSC_errorMessage = "Packet has unterminated bundles";
- return 0;
- }
-#else
- return (buf->bufptr - buf->buffer);
-#endif
-}
-
-#define CheckOverflow(buf, bytesNeeded) { if ((bytesNeeded) > OSC_freeSpaceInBuffer(buf)) {OSC_errorMessage = "buffer overflow"; return 1;}}
-
-static void PatchMessageSize(OSCbuf *buf) {
- int4byte size;
- size = buf->bufptr - ((char *) buf->thisMsgSize) - 4;
- *(buf->thisMsgSize) = htonl(size);
-}
-
-int OSC_openBundle(OSCbuf *buf, OSCTimeTag tt) {
- if (buf->state == ONE_MSG_ARGS) {
- OSC_errorMessage = "Can't open a bundle in a one-message packet";
- return 3;
- }
-
- if (buf->state == DONE) {
- OSC_errorMessage = "This packet is finished; can't open a new bundle";
- return 4;
- }
-
- if (++(buf->bundleDepth) >= MAX_BUNDLE_NESTING) {
- OSC_errorMessage = "Bundles nested too deeply; change MAX_BUNDLE_NESTING in OpenSoundControl.h";
- return 2;
- }
-
- if (CheckTypeTag(buf, '\0')) return 9;
-
- if (buf->state == GET_ARGS) {
- PatchMessageSize(buf);
- }
-
- if (buf->state == EMPTY) {
- /* Need 16 bytes for "#bundle" and time tag */
- CheckOverflow(buf, 16);
- } else {
- /* This bundle is inside another bundle, so we need to leave
- a blank size count for the size of this current bundle. */
- CheckOverflow(buf, 20);
- *((int4byte *)buf->bufptr) = 0xaaaaaaaa;
- buf->prevCounts[buf->bundleDepth] = (int4byte *)buf->bufptr;
-
- buf->bufptr += 4;
- }
-
- buf->bufptr += OSC_padString(buf->bufptr, "#bundle");
-
-
- *((OSCTimeTag *) buf->bufptr) = tt;
-
- if (htonl(1) != 1) {
- /* Byte swap the 8-byte integer time tag */
- int4byte *intp = (int4byte *)buf->bufptr;
- intp[0] = htonl(intp[0]);
- intp[1] = htonl(intp[1]);
-
-#ifdef HAS8BYTEINT
- { /* tt is a 64-bit int so we have to swap the two 32-bit words.
- (Otherwise tt is a struct of two 32-bit words, and even though
- each word was wrong-endian, they were in the right order
- in the struct.) */
- int4byte temp = intp[0];
- intp[0] = intp[1];
- intp[1] = temp;
- }
-#endif
- }
-
- buf->bufptr += sizeof(OSCTimeTag);
-
- buf->state = NEED_COUNT;
-
- buf->gettingFirstUntypedArg = 0;
- buf->typeStringPtr = 0;
- return 0;
-}
-
-
-int OSC_closeBundle(OSCbuf *buf) {
- if (buf->bundleDepth == 0) {
- /* This handles EMPTY, ONE_MSG, ARGS, and DONE */
- OSC_errorMessage = "Can't close bundle; no bundle is open!";
- return 5;
- }
-
- if (CheckTypeTag(buf, '\0')) return 9;
-
- if (buf->state == GET_ARGS) {
- PatchMessageSize(buf);
- }
-
- if (buf->bundleDepth == 1) {
- /* Closing the last bundle: No bundle size to patch */
- buf->state = DONE;
- } else {
- /* Closing a sub-bundle: patch bundle size */
- int size = buf->bufptr - ((char *) buf->prevCounts[buf->bundleDepth]) - 4;
- *(buf->prevCounts[buf->bundleDepth]) = htonl(size);
- buf->state = NEED_COUNT;
- }
-
- --buf->bundleDepth;
- buf->gettingFirstUntypedArg = 0;
- buf->typeStringPtr = 0;
- return 0;
-}
-
-
-int OSC_closeAllBundles(OSCbuf *buf) {
- if (buf->bundleDepth == 0) {
- /* This handles EMPTY, ONE_MSG, ARGS, and DONE */
- OSC_errorMessage = "Can't close all bundles; no bundle is open!";
- return 6;
- }
-
- if (CheckTypeTag(buf, '\0')) return 9;
-
- while (buf->bundleDepth > 0) {
- OSC_closeBundle(buf);
- }
- buf->typeStringPtr = 0;
- return 0;
-}
-
-int OSC_writeAddress(OSCbuf *buf, char *name) {
- int4byte paddedLength;
-
- if (buf->state == ONE_MSG_ARGS) {
- OSC_errorMessage = "This packet is not a bundle, so you can't write another address";
- return 7;
- }
-
- if (buf->state == DONE) {
- OSC_errorMessage = "This packet is finished; can't write another address";
- return 8;
- }
-
- if (CheckTypeTag(buf, '\0')) return 9;
-
- paddedLength = OSC_effectiveStringLength(name);
-
- if (buf->state == EMPTY) {
- /* This will be a one-message packet, so no sizes to worry about */
- CheckOverflow(buf, paddedLength);
- buf->state = ONE_MSG_ARGS;
- } else {
- /* GET_ARGS or NEED_COUNT */
- CheckOverflow(buf, 4+paddedLength);
- if (buf->state == GET_ARGS) {
- /* Close the old message */
- PatchMessageSize(buf);
- }
- buf->thisMsgSize = (int4byte *)buf->bufptr;
- *(buf->thisMsgSize) = 0xbbbbbbbb;
- buf->bufptr += 4;
- buf->state = GET_ARGS;
- }
-
- /* Now write the name */
- buf->bufptr += OSC_padString(buf->bufptr, name);
- buf->typeStringPtr = 0;
- buf->gettingFirstUntypedArg = 1;
-
- return 0;
-}
-
-int OSC_writeAddressAndTypes(OSCbuf *buf, char *name, char *types) {
- int result;
- int4byte paddedLength;
-
- if (CheckTypeTag(buf, '\0')) return 9;
-
- result = OSC_writeAddress(buf, name);
-
- if (result) return result;
-
- paddedLength = OSC_effectiveStringLength(types);
-
- CheckOverflow(buf, paddedLength);
-
- buf->typeStringPtr = buf->bufptr + 1; /* skip comma */
- buf->bufptr += OSC_padString(buf->bufptr, types);
-
- buf->gettingFirstUntypedArg = 0;
- return 0;
-}
-
-static int CheckTypeTag(OSCbuf *buf, char expectedType) {
- if (buf->typeStringPtr) {
- if (*(buf->typeStringPtr) != expectedType) {
- if (expectedType == '\0') {
- OSC_errorMessage =
- "According to the type tag I expected more arguments.";
- } else if (*(buf->typeStringPtr) == '\0') {
- OSC_errorMessage =
- "According to the type tag I didn't expect any more arguments.";
- } else {
- OSC_errorMessage =
- "According to the type tag I expected an argument of a different type.";
- printf("* Expected %c, string now %s\n", expectedType, buf->typeStringPtr);
- }
- return 9;
- }
- ++(buf->typeStringPtr);
- }
- return 0;
-}
-
-
-int OSC_writeFloatArg(OSCbuf *buf, float arg) {
- int4byte *intp;
- //int result;
-
- CheckOverflow(buf, 4);
-
- if (CheckTypeTag(buf, 'f')) return 9;
-
- /* Pretend arg is a long int so we can use htonl() */
- intp = ((int4byte *) &arg);
- *((int4byte *) buf->bufptr) = htonl(*intp);
-
- buf->bufptr += 4;
-
- buf->gettingFirstUntypedArg = 0;
- return 0;
-}
-
-
-
-int OSC_writeFloatArgs(OSCbuf *buf, int numFloats, float *args) {
- int i;
- int4byte *intp;
-
- CheckOverflow(buf, 4 * numFloats);
-
- /* Pretend args are long ints so we can use htonl() */
- intp = ((int4byte *) args);
-
- for (i = 0; i < numFloats; i++) {
- if (CheckTypeTag(buf, 'f')) return 9;
- *((int4byte *) buf->bufptr) = htonl(intp[i]);
- buf->bufptr += 4;
- }
-
- buf->gettingFirstUntypedArg = 0;
- return 0;
-}
-
-int OSC_writeIntArg(OSCbuf *buf, int4byte arg) {
- CheckOverflow(buf, 4);
- if (CheckTypeTag(buf, 'i')) return 9;
-
- *((int4byte *) buf->bufptr) = htonl(arg);
- buf->bufptr += 4;
-
- buf->gettingFirstUntypedArg = 0;
- return 0;
-}
-
-int OSC_writeStringArg(OSCbuf *buf, char *arg) {
- int len;
-
- if (CheckTypeTag(buf, 's')) return 9;
-
- len = OSC_effectiveStringLength(arg);
-
- if (buf->gettingFirstUntypedArg && arg[0] == ',') {
- /* This un-type-tagged message starts with a string
- that starts with a comma, so we have to escape it
- (with a double comma) so it won't look like a type
- tag string. */
-
- CheckOverflow(buf, len+4); /* Too conservative */
- buf->bufptr +=
- OSC_padStringWithAnExtraStupidComma(buf->bufptr, arg);
-
- } else {
- CheckOverflow(buf, len);
- buf->bufptr += OSC_padString(buf->bufptr, arg);
- }
-
- buf->gettingFirstUntypedArg = 0;
- return 0;
-
-}
-
-/* String utilities */
-
-#define STRING_ALIGN_PAD 4
-int OSC_effectiveStringLength(char *string) {
- int len = strlen(string) + 1; /* We need space for the null char. */
-
- /* Round up len to next multiple of STRING_ALIGN_PAD to account for alignment padding */
- if ((len % STRING_ALIGN_PAD) != 0) {
- len += STRING_ALIGN_PAD - (len % STRING_ALIGN_PAD);
- }
- return len;
-}
-
-static int OSC_padString(char *dest, char *str) {
- int i;
-
- for (i = 0; str[i] != '\0'; i++) {
- dest[i] = str[i];
- }
-
- return OSC_WritePadding(dest, i);
-}
-
-static int OSC_padStringWithAnExtraStupidComma(char *dest, char *str) {
- int i;
-
- dest[0] = ',';
- for (i = 0; str[i] != '\0'; i++) {
- dest[i+1] = str[i];
- }
-
- return OSC_WritePadding(dest, i+1);
-}
-
-static int OSC_WritePadding(char *dest, int i) {
- dest[i] = '\0';
- i++;
-
- for (; (i % STRING_ALIGN_PAD) != 0; i++) {
- dest[i] = '\0';
- }
-
- return i;
-}
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/sformat.h b/apps/plugins/pdbox/PDa/extra/sformat.h
index b75ef98c9a..93d353785b 100644
--- a/apps/plugins/pdbox/PDa/extra/sformat.h
+++ b/apps/plugins/pdbox/PDa/extra/sformat.h
@@ -54,57 +54,3 @@ typedef struct _wave
#endif
-#ifndef SFORMAT_H__
-#define SFORMAT_H__
-
-typedef unsigned short uint16;
-typedef unsigned long uint32;
-
-#define FORMAT_WAVE 0
-#define FORMAT_AIFF 1
-#define FORMAT_NEXT 2
-
-/* the NeXTStep sound header structure; can be big or little endian */
-
-typedef struct _nextstep
-{
- char ns_fileid[4]; /* magic number '.snd' if file is big-endian */
- uint32 ns_onset; /* byte offset of first sample */
- uint32 ns_length; /* length of sound in bytes */
- uint32 ns_format; /* format; see below */
- uint32 ns_sr; /* sample rate */
- uint32 ns_nchans; /* number of channels */
- char ns_info[4]; /* comment */
-} t_nextstep;
-
-#define NS_FORMAT_LINEAR_16 3
-#define NS_FORMAT_LINEAR_24 4
-#define NS_FORMAT_FLOAT 6
-#define SCALE (1./(1024. * 1024. * 1024. * 2.))
-
-/* the WAVE header. All Wave files are little endian. We assume
- the "fmt" chunk comes first which is usually the case but perhaps not
- always; same for AIFF and the "COMM" chunk. */
-
-typedef unsigned word;
-typedef unsigned long dword;
-
-typedef struct _wave
-{
- char w_fileid[4]; /* chunk id 'RIFF' */
- uint32 w_chunksize; /* chunk size */
- char w_waveid[4]; /* wave chunk id 'WAVE' */
- char w_fmtid[4]; /* format chunk id 'fmt ' */
- uint32 w_fmtchunksize; /* format chunk size */
- uint16 w_fmttag; /* format tag, 1 for PCM */
- uint16 w_nchannels; /* number of channels */
- uint32 w_samplespersec; /* sample rate in hz */
- uint32 w_navgbytespersec; /* average bytes per second */
- uint16 w_nblockalign; /* number of bytes per sample */
- uint16 w_nbitspersample; /* number of bits in a sample */
- char w_datachunkid[4]; /* data chunk id 'data' */
- uint32 w_datachunksize; /* length of data chunk */
-} t_wave;
-
-
-#endif
diff --git a/apps/plugins/pdbox/PDa/extra/shell.c b/apps/plugins/pdbox/PDa/extra/shell.c
index a0b6cef5b5..dd6b0e239d 100644
--- a/apps/plugins/pdbox/PDa/extra/shell.c
+++ b/apps/plugins/pdbox/PDa/extra/shell.c
@@ -309,316 +309,4 @@ void shell_setup(void)
class_addanything(shell_class, shell_anything);
}
-
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-#include "m_pd.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <sched.h>
-
-void sys_rmpollfn(int fd);
-void sys_addpollfn(int fd, void* fn, void *ptr);
-
-/* ------------------------ shell ----------------------------- */
-
-#define INBUFSIZE 1024
-
-static t_class *shell_class;
-
-
-static void drop_priority(void)
-{
-#ifdef _POSIX_PRIORITY_SCHEDULING
- struct sched_param par;
- int p1 ,p2, p3;
- par.sched_priority = 0;
- sched_setscheduler(0,SCHED_OTHER,&par);
-#endif
-}
-
-
-typedef struct _shell
-{
- t_object x_obj;
- int x_echo;
- char *sr_inbuf;
- int sr_inhead;
- int sr_intail;
- void* x_binbuf;
- int fdpipe[2];
- int fdinpipe[2];
- int pid;
- int x_del;
- t_outlet* x_done;
- t_clock* x_clock;
-} t_shell;
-
-static int shell_pid;
-
-
-void shell_cleanup(t_shell* x)
-{
- sys_rmpollfn(x->fdpipe[0]);
-
- if (x->fdpipe[0]>0) close(x->fdpipe[0]);
- if (x->fdpipe[1]>0) close(x->fdpipe[1]);
- if (x->fdinpipe[0]>0) close(x->fdinpipe[0]);
- if (x->fdinpipe[1]>0) close(x->fdinpipe[1]);
-
- x->fdpipe[0] = -1;
- x->fdpipe[1] = -1;
- x->fdinpipe[0] = -1;
- x->fdinpipe[1] = -1;
- clock_unset(x->x_clock);
-}
-
-void shell_check(t_shell* x)
-{
- int ret;
- int status;
- ret = waitpid(x->pid,&status,WNOHANG);
- if (ret == x->pid) {
- shell_cleanup(x);
- if (WIFEXITED(status)) {
- outlet_float(x->x_done,WEXITSTATUS(status));
- }
- else outlet_float(x->x_done,0);
- }
- else {
- if (x->x_del < 100) x->x_del+=2; /* increment poll times */
- clock_delay(x->x_clock,x->x_del);
- }
-}
-
-
-void shell_bang(t_shell *x)
-{
- post("bang");
-}
-
-/* snippet from pd's code */
-static void shell_doit(void *z, t_binbuf *b)
-{
- t_shell *x = (t_shell *)z;
- int msg, natom = binbuf_getnatom(b);
- t_atom *at = binbuf_getvec(b);
-
- for (msg = 0; msg < natom;)
- {
- int emsg;
- for (emsg = msg; emsg < natom && at[emsg].a_type != A_COMMA
- && at[emsg].a_type != A_SEMI; emsg++)
- ;
- if (emsg > msg)
- {
- int i;
- for (i = msg; i < emsg; i++)
- if (at[i].a_type == A_DOLLAR || at[i].a_type == A_DOLLSYM)
- {
- pd_error(x, "netreceive: got dollar sign in message");
- goto nodice;
- }
- if (at[msg].a_type == A_FLOAT)
- {
- if (emsg > msg + 1)
- outlet_list(x->x_obj.ob_outlet, 0, emsg-msg, at + msg);
- else outlet_float(x->x_obj.ob_outlet, at[msg].a_w.w_float);
- }
- else if (at[msg].a_type == A_SYMBOL)
- outlet_anything(x->x_obj.ob_outlet, at[msg].a_w.w_symbol,
- emsg-msg-1, at + msg + 1);
- }
- nodice:
- msg = emsg + 1;
- }
-}
-
-
-void shell_read(t_shell *x, int fd)
-{
- char buf[INBUFSIZE];
- t_binbuf* bbuf = binbuf_new();
- int i;
- int readto =
- (x->sr_inhead >= x->sr_intail ? INBUFSIZE : x->sr_intail-1);
- int ret;
-
- ret = read(fd, buf,INBUFSIZE-1);
- buf[ret] = '\0';
-
- for (i=0;i<ret;i++)
- if (buf[i] == '\n') buf[i] = ';';
- if (ret < 0)
- {
- error("shell: pipe read error");
- sys_rmpollfn(fd);
- x->fdpipe[0] = -1;
- close(fd);
- return;
- }
- else if (ret == 0)
- {
- post("EOF on socket %d\n", fd);
- sys_rmpollfn(fd);
- x->fdpipe[0] = -1;
- close(fd);
- return;
- }
- else
- {
- int natom;
- t_atom *at;
- binbuf_text(bbuf, buf, strlen(buf));
-
- natom = binbuf_getnatom(bbuf);
- at = binbuf_getvec(bbuf);
- shell_doit(x,bbuf);
- }
- binbuf_free(bbuf);
-}
-
-
-static void shell_send(t_shell *x, t_symbol *s,int ac, t_atom *at)
-{
- int i;
- char tmp[MAXPDSTRING];
- int size = 0;
-
- if (x->fdinpipe[0] == -1) return; /* nothing to send to */
-
- for (i=0;i<ac;i++) {
- atom_string(at,tmp+size,MAXPDSTRING - size);
- at++;
- size=strlen(tmp);
- tmp[size++] = ' ';
- }
- tmp[size-1] = '\0';
- post("sending %s",tmp);
- write(x->fdinpipe[0],tmp,strlen(tmp));
-}
-
-static void shell_anything(t_shell *x, t_symbol *s, int ac, t_atom *at)
-{
- int i;
- char* argv[20];
- t_symbol* sym;
-
- if (!strcmp(s->s_name,"send")) {
- post("send");
- shell_send(x,s,ac,at);
- return;
- }
-
- argv[0] = s->s_name;
-
- if (x->fdpipe[0] != -1) {
- post("shell: old process still running");
- kill(x->pid,SIGKILL);
- shell_cleanup(x);
- }
-
-
- if (pipe(x->fdpipe) < 0) {
- error("unable to create pipe");
- return;
- }
-
- if (pipe(x->fdinpipe) < 0) {
- error("unable to create input pipe");
- return;
- }
-
-
- sys_addpollfn(x->fdpipe[0],shell_read,x);
-
- if (!(x->pid = fork())) {
- int status;
- char* cmd = getbytes(1024);
- char* tcmd = getbytes(1024);
- strcpy(cmd,s->s_name);
-
-#if 0
- for (i=1;i<=ac;i++) {
- argv[i] = getbytes(255);
- atom_string(at,argv[i],255);
-/* post("argument %s",argv[i]); */
- at++;
- }
- argv[i] = 0;
-#endif
- for (i=1;i<=ac;i++) {
- atom_string(at,tcmd,255);
- strcat(cmd," ");
- strcat(cmd,tcmd);
- at++;
- }
-
-
- /* reassign stdout */
- dup2(x->fdpipe[1],1);
- dup2(x->fdinpipe[1],0);
-
- /* drop privileges */
- drop_priority();
- seteuid(getuid()); /* lose setuid priveliges */
-
- post("executing %s",cmd);
- system(cmd);
-// execvp(s->s_name,argv);
- exit(0);
- }
- x->x_del = 4;
- clock_delay(x->x_clock,x->x_del);
-
- if (x->x_echo)
- outlet_anything(x->x_obj.ob_outlet, s, ac, at);
-}
-
-
-
-void shell_free(t_shell* x)
-{
- binbuf_free(x->x_binbuf);
-}
-
-static void *shell_new(void)
-{
- t_shell *x = (t_shell *)pd_new(shell_class);
-
- x->x_echo = 0;
- x->fdpipe[0] = -1;
- x->fdpipe[1] = -1;
- x->fdinpipe[0] = -1;
- x->fdinpipe[1] = -1;
-
- x->sr_inhead = x->sr_intail = 0;
- if (!(x->sr_inbuf = (char*) malloc(INBUFSIZE))) bug("t_shell");;
-
- x->x_binbuf = binbuf_new();
-
- outlet_new(&x->x_obj, &s_list);
- x->x_done = outlet_new(&x->x_obj, &s_bang);
- x->x_clock = clock_new(x, (t_method) shell_check);
- return (x);
-}
-
-void shell_setup(void)
-{
- shell_class = class_new(gensym("shell"), (t_newmethod)shell_new,
- (t_method)shell_free,sizeof(t_shell), 0,0);
- class_addbang(shell_class,shell_bang);
- class_addanything(shell_class, shell_anything);
-}
-
-
+
diff --git a/apps/plugins/pdbox/PDa/extra/slider.c b/apps/plugins/pdbox/PDa/extra/slider.c
index 4650050006..bea94d6f5a 100644
--- a/apps/plugins/pdbox/PDa/extra/slider.c
+++ b/apps/plugins/pdbox/PDa/extra/slider.c
@@ -51,56 +51,4 @@ void slider_setup(void) {
#endif
}
-#include <stdio.h>
-#include "m_pd.h"
-#include "g_canvas.h" /* for widgetbehaviour */
-#include "fatom.h"
-
-static t_class *slider_class;
-
-static void slider_save(t_gobj *z, t_binbuf *b)
-{
- t_fatom *x = (t_fatom *)z;
-
- binbuf_addv(b, "ssiisiiisss", gensym("#X"),gensym("obj"),
- x->x_obj.te_xpix, x->x_obj.te_ypix ,
- gensym("slider"),x->x_max,x->x_min,x->x_width,x->x_send,x->x_color,x->x_bgcolor);
- binbuf_addv(b, ";");
-}
-
-
-static void *slider_new(t_symbol* s,t_int argc, t_atom* argv)
-{
- t_fatom *x = (t_fatom *)pd_new(slider_class);
- x->x_type = gensym("vslider");
- return fatom_new(x,argc,argv);
-}
-
-
-t_widgetbehavior slider_widgetbehavior;
-
-
-void slider_setup(void) {
- slider_class = class_new(gensym("slider"), (t_newmethod)slider_new, 0,
- sizeof(t_fatom),0,A_GIMME,0);
-
- slider_widgetbehavior.w_getrectfn = fatom_getrect;
- slider_widgetbehavior.w_displacefn = fatom_displace;
- slider_widgetbehavior.w_selectfn = fatom_select;
- slider_widgetbehavior.w_activatefn = fatom_activate;
- slider_widgetbehavior.w_deletefn = fatom_delete;
- slider_widgetbehavior.w_visfn= fatom_vis;
- slider_widgetbehavior.w_clickfn = NULL;
-
- fatom_setup_common(slider_class);
- class_setwidget(slider_class,&slider_widgetbehavior);
-
-#if PD_MINOR_VERSION < 37
- slider_widgetbehavior.w_savefn = slider_save;
- slider_widgetbehavior.w_propertiesfn = NULL;
-#else
- class_setsavefn(slider_class,&slider_save);
- class_setpropertiesfn(slider_class,&fatom_properties);
-#endif
-}
diff --git a/apps/plugins/pdbox/PDa/extra/sliderh.c b/apps/plugins/pdbox/PDa/extra/sliderh.c
index 23a6d256e0..cfeb961a72 100644
--- a/apps/plugins/pdbox/PDa/extra/sliderh.c
+++ b/apps/plugins/pdbox/PDa/extra/sliderh.c
@@ -61,66 +61,4 @@ void sliderh_setup(void) {
class_setsavefn(sliderh_class,&sliderh_save);
#endif
}
-#include "m_pd.h"
-#include "g_canvas.h"
-
-
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#include "fatom.h"
-
-/* can we use the normal text save function ?? */
-
-static t_class *sliderh_class;
-
-static void sliderh_save(t_gobj *z, t_binbuf *b)
-{
-
- t_fatom *x = (t_fatom *)z;
-
- binbuf_addv(b, "ssiisiiisss", gensym("#X"),gensym("obj"),
- x->x_obj.te_xpix, x->x_obj.te_ypix ,
- gensym("sliderh"),x->x_max,x->x_min,x->x_width,x->x_send,x->x_color,x->x_bgcolor);
- binbuf_addv(b, ";");
-}
-
-
-static void *sliderh_new(t_symbol* s, int argc, t_atom* argv)
-{
- t_fatom *x = (t_fatom *)pd_new(sliderh_class);
- x->x_type = gensym("hslider");
- return fatom_new(x,argc,argv);
-}
-
-
-t_widgetbehavior sliderh_widgetbehavior;
-
-
-
-void sliderh_setup(void) {
- sliderh_class = class_new(gensym("sliderh"), (t_newmethod)sliderh_new, 0,
- sizeof(t_fatom),0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
-
- fatom_setup_common(sliderh_class);
-
- sliderh_widgetbehavior.w_getrectfn = fatom_getrect;
- sliderh_widgetbehavior.w_displacefn= fatom_displace;
- sliderh_widgetbehavior.w_selectfn= fatom_select;
- sliderh_widgetbehavior.w_activatefn=fatom_activate;
- sliderh_widgetbehavior.w_deletefn= fatom_delete;
- sliderh_widgetbehavior.w_visfn= fatom_vis;
-#if PD_MINOR_VERSION < 37
- sliderh_widgetbehavior.w_savefn= sliderh_save;
- sliderh_widgetbehavior.w_propertiesfn= NULL;
-#endif
- sliderh_widgetbehavior.w_clickfn= NULL;
-
- class_setwidget(sliderh_class,&sliderh_widgetbehavior);
-#if PD_MINOR_VERSION >= 37
- class_setsavefn(sliderh_class,&sliderh_save);
-#endif
-}
diff --git a/apps/plugins/pdbox/PDa/extra/test-clip.pd b/apps/plugins/pdbox/PDa/extra/test-clip.pd
index c682e31845..ed6c0c8396 100644
--- a/apps/plugins/pdbox/PDa/extra/test-clip.pd
+++ b/apps/plugins/pdbox/PDa/extra/test-clip.pd
@@ -11,16 +11,4 @@
#X connect 3 0 5 0;
#X connect 5 0 1 0;
#X connect 5 1 2 0;
-#N canvas 0 0 240 300 10;
-#X obj 57 84 clip~ -0.1 0.1;
-#X obj 58 61 sig~;
-#X obj 57 111 snapshot~;
-#X floatatom 58 19 5 0 0 0 - - -;
-#X floatatom 57 144 5 0 0 0 - - -;
-#X obj 58 37 t f b;
-#X connect 0 0 2 0;
-#X connect 1 0 0 0;
-#X connect 2 0 4 0;
-#X connect 3 0 5 0;
-#X connect 5 0 1 0;
-#X connect 5 1 2 0;
+
diff --git a/apps/plugins/pdbox/PDa/extra/test-vcf.pd b/apps/plugins/pdbox/PDa/extra/test-vcf.pd
index 099d3d7958..5f1b29381a 100644
--- a/apps/plugins/pdbox/PDa/extra/test-vcf.pd
+++ b/apps/plugins/pdbox/PDa/extra/test-vcf.pd
@@ -16,21 +16,4 @@
#X connect 6 0 5 0;
#X connect 7 0 1 1;
#X connect 8 0 7 0;
-#N canvas 0 0 240 300 10;
-#X obj 38 93 noise~;
-#X obj 44 161 vcf~;
-#X obj 48 191 dac~;
-#X floatatom 138 33 5 0 0 0 - - -;
-#X obj 44 18 osc~ 1;
-#X obj 46 75 *~ 800;
-#X obj 48 48 +~ 2;
-#X obj 106 125 sig~;
-#X floatatom 132 77 5 0 0 0 - - -;
-#X connect 0 0 1 0;
-#X connect 1 0 2 0;
-#X connect 1 0 2 1;
-#X connect 3 0 1 2;
-#X connect 4 0 6 0;
-#X connect 6 0 5 0;
-#X connect 7 0 1 1;
-#X connect 8 0 7 0;
+
diff --git a/apps/plugins/pdbox/PDa/extra/zerox~.c b/apps/plugins/pdbox/PDa/extra/zerox~.c
index f97f412308..5476583501 100644
--- a/apps/plugins/pdbox/PDa/extra/zerox~.c
+++ b/apps/plugins/pdbox/PDa/extra/zerox~.c
@@ -55,60 +55,4 @@ void zerox_tilde_setup(void)
class_addmethod(zerox_class, (t_method)zerox_dsp, gensym("dsp"), 0);
class_addbang(zerox_class, (t_method)zerox_bang);
}
-#include "m_pd.h"
-
-static t_class *zerox_class;
-
-typedef struct _zerox
-{
- t_object x_obj;
- t_sample x_f;
- t_int x_zeros;
-} t_zerox;
-
-
-static t_int *zerox_perform(t_int *w)
-{
- t_zerox* x = (t_zerox*)w[1];
- t_sample *in = (t_sample *)(w[2]);
- int n = (int)(w[3]) ;
-
- if (*in * x->x_f < 0) x->x_zeros++;
- n--;
- while (n--)
- {
- float f = *(in++);
- x->x_zeros += f * *in < 0;
- }
- return (w+4);
-}
-
-static void zerox_dsp(t_zerox *x, t_signal **sp)
-{
- dsp_add(zerox_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
-}
-
-
-static void zerox_bang(t_zerox* x)
-{
- outlet_float(x->x_obj.ob_outlet,x->x_zeros);
- x->x_zeros=0;
-}
-
-static void *zerox_new(void)
-{
- t_zerox *x = (t_zerox *)pd_new(zerox_class);
- outlet_new(&x->x_obj, gensym("float"));
- x->x_f = 0;
- x->x_zeros=0;
- return (x);
-}
-void zerox_tilde_setup(void)
-{
- zerox_class = class_new(gensym("zerox~"), (t_newmethod)zerox_new, 0,
- sizeof(t_zerox), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(zerox_class, t_zerox, x_f);
- class_addmethod(zerox_class, (t_method)zerox_dsp, gensym("dsp"), 0);
- class_addbang(zerox_class, (t_method)zerox_bang);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/biquad~.c b/apps/plugins/pdbox/PDa/intern/biquad~.c
index c37182a911..2dc6d72071 100644
--- a/apps/plugins/pdbox/PDa/intern/biquad~.c
+++ b/apps/plugins/pdbox/PDa/intern/biquad~.c
@@ -124,129 +124,4 @@ void biquad_tilde_setup(void)
class_addmethod(sigbiquad_class, (t_method)sigbiquad_set, gensym("clear"),
A_GIMME, 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-typedef struct biquadctl
-{
- t_sample c_x1;
- t_sample c_x2;
- t_sample c_fb1;
- t_sample c_fb2;
- t_sample c_ff1;
- t_sample c_ff2;
- t_sample c_ff3;
-} t_biquadctl;
-
-typedef struct sigbiquad
-{
- t_object x_obj;
- float x_f;
- t_biquadctl x_cspace;
- t_biquadctl *x_ctl;
-} t_sigbiquad;
-
-t_class *sigbiquad_class;
-
-static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv);
-static void *sigbiquad_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_sigbiquad *x = (t_sigbiquad *)pd_new(sigbiquad_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_x1 = x->x_cspace.c_x2 = 0;
- sigbiquad_list(x, s, argc, argv);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigbiquad_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- t_biquadctl *c = (t_biquadctl *)(w[3]);
- int n = (t_int)(w[4]);
- int i;
- t_sample last = c->c_x1;
- t_sample prev = c->c_x2;
- t_sample fb1 = c->c_fb1;
- t_sample fb2 = c->c_fb2;
- t_sample ff1 = c->c_ff1;
- t_sample ff2 = c->c_ff2;
- t_sample ff3 = c->c_ff3;
- for (i = 0; i < n; i++)
- {
- t_sample output = *in++ + mult(fb1,last) + mult(fb2,prev);
- if (PD_BADFLOAT(output))
- output = 0;
- *out++ = mult(ff1,output) + mult(ff2,last) + mult(ff3,prev);
- prev = last;
- last = output;
- }
- c->c_x1 = last;
- c->c_x2 = prev;
- return (w+5);
-}
-
-static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv)
-{
- float fb1 = atom_getfloatarg(0, argc, argv);
- float fb2 = atom_getfloatarg(1, argc, argv);
- float ff1 = atom_getfloatarg(2, argc, argv);
- float ff2 = atom_getfloatarg(3, argc, argv);
- float ff3 = atom_getfloatarg(4, argc, argv);
- float discriminant = fb1 * fb1 + 4 * fb2;
- t_biquadctl *c = x->x_ctl;
- if (discriminant < 0) /* imaginary roots -- resonant filter */
- {
- /* they're conjugates so we just check that the product
- is less than one */
- if (fb2 >= -1.0f) goto stable;
- }
- else /* real roots */
- {
- /* check that the parabola 1 - fb1 x - fb2 x^2 has a
- vertex between -1 and 1, and that it's nonnegative
- at both ends, which implies both roots are in [1-,1]. */
- if (fb1 <= 2.0f && fb1 >= -2.0f &&
- 1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0)
- goto stable;
- }
- /* if unstable, just bash to zero */
- fb1 = fb2 = ff1 = ff2 = ff3 = 0;
-stable:
- c->c_fb1 = ftofix(fb1);
- c->c_fb2 = ftofix(fb2);
- c->c_ff1 = ftofix(ff1);
- c->c_ff2 = ftofix(ff2);
- c->c_ff3 = ftofix(ff3);
-}
-
-static void sigbiquad_set(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_biquadctl *c = x->x_ctl;
- c->c_x1 = atom_getfloatarg(0, argc, argv);
- c->c_x2 = atom_getfloatarg(1, argc, argv);
-}
-
-static void sigbiquad_dsp(t_sigbiquad *x, t_signal **sp)
-{
- dsp_add(sigbiquad_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-void biquad_tilde_setup(void)
-{
- sigbiquad_class = class_new(gensym("biquad~"), (t_newmethod)sigbiquad_new,
- 0, sizeof(t_sigbiquad), 0, A_GIMME, 0);
- CLASS_MAINSIGNALIN(sigbiquad_class, t_sigbiquad, x_f);
- class_addmethod(sigbiquad_class, (t_method)sigbiquad_dsp, gensym("dsp"), 0);
- class_addlist(sigbiquad_class, sigbiquad_list);
- class_addmethod(sigbiquad_class, (t_method)sigbiquad_set, gensym("set"),
- A_GIMME, 0);
- class_addmethod(sigbiquad_class, (t_method)sigbiquad_set, gensym("clear"),
- A_GIMME, 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/bp~.c b/apps/plugins/pdbox/PDa/intern/bp~.c
index f247c1d66b..2c44536e8a 100644
--- a/apps/plugins/pdbox/PDa/intern/bp~.c
+++ b/apps/plugins/pdbox/PDa/intern/bp~.c
@@ -136,141 +136,3 @@ void bp_tilde_setup(void)
class_sethelpsymbol(sigbp_class, gensym("lop~-help.pd"));
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-typedef struct bpctl
-{
- t_sample c_x1;
- t_sample c_x2;
- t_sample c_coef1;
- t_sample c_coef2;
- t_sample c_gain;
-} t_bpctl;
-
-typedef struct sigbp
-{
- t_object x_obj;
- float x_sr;
- float x_freq;
- float x_q;
- t_bpctl x_cspace;
- t_bpctl *x_ctl;
- float x_f;
-} t_sigbp;
-
-t_class *sigbp_class;
-
-static void sigbp_docoef(t_sigbp *x, t_floatarg f, t_floatarg q);
-
-static void *sigbp_new(t_floatarg f, t_floatarg q)
-{
- t_sigbp *x = (t_sigbp *)pd_new(sigbp_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft2"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_sr = 44100;
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_x1 = 0;
- x->x_cspace.c_x2 = 0;
- sigbp_docoef(x, f, q);
- x->x_f = 0;
- return (x);
-}
-
-static float sigbp_qcos(float f)
-{
- if (f >= -(0.5f*3.14159f) && f <= 0.5f*3.14159f)
- {
- float g = f*f;
- return (((g*g*g * (-1.0f/720.0f) + g*g*(1.0f/24.0f)) - g*0.5) + 1);
- }
- else return (0);
-}
-
-static void sigbp_docoef(t_sigbp *x, t_floatarg f, t_floatarg q)
-{
- float r, oneminusr, omega;
- if (f < 0.001) f = 10;
- if (q < 0) q = 0;
- x->x_freq = f;
- x->x_q = q;
- omega = f * (2.0f * 3.14159f) / x->x_sr;
- if (q < 0.001) oneminusr = 1.0f;
- else oneminusr = omega/q;
- if (oneminusr > 1.0f) oneminusr = 1.0f;
- r = 1.0f - oneminusr;
- x->x_ctl->c_coef1 = ftofix(2.0f * sigbp_qcos(omega) * r);
- x->x_ctl->c_coef2 = ftofix(- r * r);
- x->x_ctl->c_gain = ftofix(2 * oneminusr * (oneminusr + r * omega));
- /* post("r %f, omega %f, coef1 %f, coef2 %f",
- r, omega, x->x_ctl->c_coef1, x->x_ctl->c_coef2); */
-}
-
-static void sigbp_ft1(t_sigbp *x, t_floatarg f)
-{
- sigbp_docoef(x, f, x->x_q);
-}
-
-static void sigbp_ft2(t_sigbp *x, t_floatarg q)
-{
- sigbp_docoef(x, x->x_freq, q);
-}
-
-static void sigbp_clear(t_sigbp *x, t_floatarg q)
-{
- x->x_ctl->c_x1 = x->x_ctl->c_x2 = 0;
-}
-
-static t_int *sigbp_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- t_bpctl *c = (t_bpctl *)(w[3]);
- int n = (t_int)(w[4]);
- int i;
- t_sample last = c->c_x1;
- t_sample prev = c->c_x2;
- t_sample coef1 = c->c_coef1;
- t_sample coef2 = c->c_coef2;
- t_sample gain = c->c_gain;
- for (i = 0; i < n; i++)
- {
- t_sample output = *in++ + mult(coef1,last) + mult(coef2,prev);
- *out++ = mult(gain,output);
- prev = last;
- last = output;
- }
- if (PD_BADFLOAT(last))
- last = 0;
- if (PD_BADFLOAT(prev))
- prev = 0;
- c->c_x1 = last;
- c->c_x2 = prev;
- return (w+5);
-}
-
-static void sigbp_dsp(t_sigbp *x, t_signal **sp)
-{
- x->x_sr = sp[0]->s_sr;
- sigbp_docoef(x, x->x_freq, x->x_q);
- dsp_add(sigbp_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-void bp_tilde_setup(void)
-{
- sigbp_class = class_new(gensym("bp~"), (t_newmethod)sigbp_new, 0,
- sizeof(t_sigbp), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(sigbp_class, t_sigbp, x_f);
- class_addmethod(sigbp_class, (t_method)sigbp_dsp, gensym("dsp"), 0);
- class_addmethod(sigbp_class, (t_method)sigbp_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addmethod(sigbp_class, (t_method)sigbp_ft2,
- gensym("ft2"), A_FLOAT, 0);
- class_addmethod(sigbp_class, (t_method)sigbp_clear, gensym("clear"), 0);
- class_sethelpsymbol(sigbp_class, gensym("lop~-help.pd"));
-}
-
diff --git a/apps/plugins/pdbox/PDa/intern/clip~.c b/apps/plugins/pdbox/PDa/intern/clip~.c
index e2c697d1d8..83bcc80c53 100644
--- a/apps/plugins/pdbox/PDa/intern/clip~.c
+++ b/apps/plugins/pdbox/PDa/intern/clip~.c
@@ -56,61 +56,4 @@ void clip_tilde_setup(void)
CLASS_MAINSIGNALIN(clip_class, t_clip, x_f);
class_addmethod(clip_class, (t_method)clip_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *clip_class;
-typedef struct _clip
-{
- t_object x_obj;
- float x_f;
- t_float x_lo;
- t_float x_hi;
-} t_clip;
-
-static void *clip_new(t_floatarg lo, t_floatarg hi)
-{
- t_clip *x = (t_clip *)pd_new(clip_class);
- x->x_lo = lo;
- x->x_hi = hi;
- outlet_new(&x->x_obj, gensym("signal"));
- floatinlet_new(&x->x_obj, &x->x_lo);
- floatinlet_new(&x->x_obj, &x->x_hi);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *clip_perform(t_int *w)
-{
- t_clip *x = (t_clip *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- t_sample lo;
- t_sample hi;
- lo = ftofix(x->x_lo);
- hi = ftofix(x->x_hi);
-
- while (n--)
- {
- t_sample f = *in++;
- if (f < lo) f = lo;
- if (f > hi) f = hi;
- *out++ = f;
- }
- return (w+5);
-}
-
-static void clip_dsp(t_clip *x, t_signal **sp)
-{
- dsp_add(clip_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void clip_tilde_setup(void)
-{
- clip_class = class_new(gensym("clip~"), (t_newmethod)clip_new, 0,
- sizeof(t_clip), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(clip_class, t_clip, x_f);
- class_addmethod(clip_class, (t_method)clip_dsp, gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/cos_table.h b/apps/plugins/pdbox/PDa/intern/cos_table.h
index b30bb4245b..e8be7f5c8c 100644
--- a/apps/plugins/pdbox/PDa/intern/cos_table.h
+++ b/apps/plugins/pdbox/PDa/intern/cos_table.h
@@ -1,6 +1,3 @@
#define ILOGCOSTABSIZE 15
#define ICOSTABSIZE (1<<ILOGCOSTABSIZE)
static t_sample cos_table[] = {262144,262144,262144,262144,262144,262144,262144,262144,262144,262144,262144,262143,262143,262143,262143,262143,262143,262143,262142,262142,262142,262142,262142,262141,262141,262141,262141,262140,262140,262140,262140,262139,262139,262139,262138,262138,262138,262137,262137,262137,262136,262136,262135,262135,262135,262134,262134,262133,262133,262132,262132,262131,262131,262130,262130,262129,262129,262128,262128,262127,262127,262126,262125,262125,262124,262124,262123,262122,262122,262121,262120,262120,262119,262118,262118,262117,262116,262115,262115,262114,262113,262112,262112,262111,262110,262109,262108,262108,262107,262106,262105,262104,262103,262102,262101,262101,262100,262099,262098,262097,262096,262095,262094,262093,262092,262091,262090,262089,262088,262087,262086,262085,262084,262082,262081,262080,262079,262078,262077,262076,262075,262073,262072,262071,262070,262069,262067,262066,262065,262064,262063,262061,262060,262059,262057,262056,262055,262054,262052,262051,262050,262048,262047,262045,262044,262043,262041,262040,262038,262037,262036,262034,262033,262031,262030,262028,262027,262025,262024,262022,262021,262019,262018,262016,262014,262013,262011,262010,262008,262006,262005,262003,262001,262000,261998,261996,261995,261993,261991,261990,261988,261986,261984,261983,261981,261979,261977,261975,261974,261972,261970,261968,261966,261965,261963,261961,261959,261957,261955,261953,261951,261949,261947,261945,261943,261942,261940,261938,261936,261934,261932,261929,261927,261925,261923,261921,261919,261917,261915,261913,261911,261909,261907,261904,261902,261900,261898,261896,261894,261891,261889,261887,261885,261882,261880,261878,261876,261873,261871,261869,261866,261864,261862,261859,261857,261855,261852,261850,261848,261845,261843,261840,261838,261836,261833,261831,261828,261826,261823,261821,261818,261816,261813,261811,261808,261806,261803,261801,261798,261795,261793,261790,261788,261785,261782,261780,261777,261774,261772,261769,261766,261764,261761,261758,261755,261753,261750,261747,261744,261742,261739,261736,261733,261730,261728,261725,261722,261719,261716,261713,261710,261708,261705,261702,261699,261696,261693,261690,261687,261684,261681,261678,261675,261672,261669,261666,261663,261660,261657,261654,261651,261648,261644,261641,261638,261635,261632,261629,261626,261623,261619,261616,261613,261610,261607,261603,261600,261597,261594,261590,261587,261584,261581,261577,261574,261571,261567,261564,261561,261557,261554,261551,261547,261544,261540,261537,261533,261530,261527,261523,261520,261516,261513,261509,261506,261502,261499,261495,261492,261488,261485,261481,261477,261474,261470,261467,261463,261459,261456,261452,261448,261445,261441,261437,261434,261430,261426,261423,261419,261415,261411,261408,261404,261400,261396,261392,261389,261385,261381,261377,261373,261369,261366,261362,261358,261354,261350,261346,261342,261338,261334,261330,261326,261322,261318,261314,261310,261306,261302,261298,261294,261290,261286,261282,261278,261274,261270,261266,261262,261258,261253,261249,261245,261241,261237,261233,261228,261224,261220,261216,261212,261207,261203,261199,261195,261190,261186,261182,261177,261173,261169,261164,261160,261156,261151,261147,261143,261138,261134,261129,261125,261120,261116,261112,261107,261103,261098,261094,261089,261085,261080,261076,261071,261067,261062,261057,261053,261048,261044,261039,261034,261030,261025,261021,261016,261011,261007,261002,260997,260992,260988,260983,260978,260974,260969,260964,260959,260955,260950,260945,260940,260935,260930,260926,260921,260916,260911,260906,260901,260896,260892,260887,260882,260877,260872,260867,260862,260857,260852,260847,260842,260837,260832,260827,260822,260817,260812,260807,260802,260797,260791,260786,260781,260776,260771,260766,260761,260756,260750,260745,260740,260735,260730,260724,260719,260714,260709,260703,260698,260693,260688,260682,260677,260672,260666,260661,260656,260650,260645,260640,260634,260629,260623,260618,260613,260607,260602,260596,260591,260585,260580,260574,260569,260563,260558,260552,260547,260541,260536,260530,260525,260519,260513,260508,260502,260496,260491,260485,260480,260474,260468,260463,260457,260451,260445,260440,260434,260428,260423,260417,260411,260405,260399,260394,260388,260382,260376,260370,260365,260359,260353,260347,260341,260335,260329,260323,260317,260312,260306,260300,260294,260288,260282,260276,260270,260264,260258,260252,260246,260240,260234,260228,260221,260215,260209,260203,260197,260191,260185,260179,260173,260166,260160,260154,260148,260142,260135,260129,260123,260117,260111,260104,260098,260092,260085,260079,260073,260067,260060,260054,260048,260041,260035,260029,260022,260016,260009,260003,259997,259990,259984,259977,259971,259964,259958,259951,259945,259938,259932,259925,259919,259912,259906,259899,259893,259886,259879,259873,259866,259860,259853,259846,259840,259833,259826,259820,259813,259806,259800,259793,259786,259779,259773,259766,259759,259752,259746,259739,259732,259725,259718,259712,259705,259698,259691,259684,259677,259670,259664,259657,259650,259643,259636,259629,259622,259615,259608,259601,259594,259587,259580,259573,259566,259559,259552,259545,259538,259531,259524,259517,259509,259502,259495,259488,259481,259474,259467,259459,259452,259445,259438,259431,259423,259416,259409,259402,259395,259387,259380,259373,259365,259358,259351,259343,259336,259329,259321,259314,259307,259299,259292,259285,259277,259270,259262,259255,259247,259240,259232,259225,259217,259210,259202,259195,259187,259180,259172,259165,259157,259150,259142,259135,259127,259119,259112,259104,259096,259089,259081,259073,259066,259058,259050,259043,259035,259027,259020,259012,259004,258996,258989,258981,258973,258965,258957,258950,258942,258934,258926,258918,258910,258902,258895,258887,258879,258871,258863,258855,258847,258839,258831,258823,258815,258807,258799,258791,258783,258775,258767,258759,258751,258743,258735,258727,258719,258711,258702,258694,258686,258678,258670,258662,258654,258645,258637,258629,258621,258613,258604,258596,258588,258580,258571,258563,258555,258546,258538,258530,258522,258513,258505,258496,258488,258480,258471,258463,258455,258446,258438,258429,258421,258412,258404,258396,258387,258379,258370,258362,258353,258345,258336,258327,258319,258310,258302,258293,258285,258276,258267,258259,258250,258242,258233,258224,258216,258207,258198,258190,258181,258172,258163,258155,258146,258137,258128,258120,258111,258102,258093,258084,258076,258067,258058,258049,258040,258031,258023,258014,258005,257996,257987,257978,257969,257960,257951,257942,257933,257924,257915,257906,257897,257888,257879,257870,257861,257852,257843,257834,257825,257816,257807,257798,257789,257779,257770,257761,257752,257743,257734,257724,257715,257706,257697,257688,257678,257669,257660,257651,257641,257632,257623,257613,257604,257595,257585,257576,257567,257557,257548,257539,257529,257520,257510,257501,257492,257482,257473,257463,257454,257444,257435,257425,257416,257406,257397,257387,257378,257368,257359,257349,257340,257330,257320,257311,257301,257292,257282,257272,257263,257253,257243,257234,257224,257214,257205,257195,257185,257175,257166,257156,257146,257136,257127,257117,257107,257097,257087,257078,257068,257058,257048,257038,257028,257018,257008,256999,256989,256979,256969,256959,256949,256939,256929,256919,256909,256899,256889,256879,256869,256859,256849,256839,256829,256819,256809,256798,256788,256778,256768,256758,256748,256738,256728,256717,256707,256697,256687,256677,256666,256656,256646,256636,256625,256615,256605,256595,256584,256574,256564,256553,256543,256533,256522,256512,256502,256491,256481,256470,256460,256450,256439,256429,256418,256408,256397,256387,256376,256366,256355,256345,256334,256324,256313,256303,256292,256282,256271,256261,256250,256239,256229,256218,256207,256197,256186,256176,256165,256154,256143,256133,256122,256111,256101,256090,256079,256068,256058,256047,256036,256025,256014,256004,255993,255982,255971,255960,255949,255939,255928,255917,255906,255895,255884,255873,255862,255851,255840,255829,255818,255807,255796,255785,255774,255763,255752,255741,255730,255719,255708,255697,255686,255675,255664,255653,255642,255630,255619,255608,255597,255586,255575,255564,255552,255541,255530,255519,255507,255496,255485,255474,255462,255451,255440,255429,255417,255406,255395,255383,255372,255361,255349,255338,255326,255315,255304,255292,255281,255269,255258,255246,255235,255224,255212,255201,255189,255178,255166,255155,255143,255131,255120,255108,255097,255085,255074,255062,255050,255039,255027,255015,255004,254992,254981,254969,254957,254945,254934,254922,254910,254899,254887,254875,254863,254852,254840,254828,254816,254804,254793,254781,254769,254757,254745,254733,254721,254710,254698,254686,254674,254662,254650,254638,254626,254614,254602,254590,254578,254566,254554,254542,254530,254518,254506,254494,254482,254470,254458,254446,254434,254422,254410,254397,254385,254373,254361,254349,254337,254324,254312,254300,254288,254276,254263,254251,254239,254227,254214,254202,254190,254178,254165,254153,254141,254128,254116,254104,254091,254079,254067,254054,254042,254029,254017,254004,253992,253980,253967,253955,253942,253930,253917,253905,253892,253880,253867,253855,253842,253830,253817,253804,253792,253779,253767,253754,253741,253729,253716,253704,253691,253678,253666,253653,253640,253627,253615,253602,253589,253577,253564,253551,253538,253525,253513,253500,253487,253474,253461,253449,253436,253423,253410,253397,253384,253371,253359,253346,253333,253320,253307,253294,253281,253268,253255,253242,253229,253216,253203,253190,253177,253164,253151,253138,253125,253112,253099,253085,253072,253059,253046,253033,253020,253007,252994,252980,252967,252954,252941,252928,252914,252901,252888,252875,252861,252848,252835,252822,252808,252795,252782,252768,252755,252742,252728,252715,252702,252688,252675,252662,252648,252635,252621,252608,252594,252581,252568,252554,252541,252527,252514,252500,252487,252473,252460,252446,252432,252419,252405,252392,252378,252365,252351,252337,252324,252310,252296,252283,252269,252255,252242,252228,252214,252201,252187,252173,252159,252146,252132,252118,252104,252091,252077,252063,252049,252035,252022,252008,251994,251980,251966,251952,251938,251925,251911,251897,251883,251869,251855,251841,251827,251813,251799,251785,251771,251757,251743,251729,251715,251701,251687,251673,251659,251645,251631,251617,251602,251588,251574,251560,251546,251532,251518,251503,251489,251475,251461,251447,251432,251418,251404,251390,251375,251361,251347,251333,251318,251304,251290,251275,251261,251247,251232,251218,251204,251189,251175,251161,251146,251132,251117,251103,251088,251074,251060,251045,251031,251016,251002,250987,250973,250958,250944,250929,250914,250900,250885,250871,250856,250842,250827,250812,250798,250783,250768,250754,250739,250724,250710,250695,250680,250666,250651,250636,250622,250607,250592,250577,250562,250548,250533,250518,250503,250489,250474,250459,250444,250429,250414,250399,250385,250370,250355,250340,250325,250310,250295,250280,250265,250250,250235,250220,250205,250190,250175,250160,250145,250130,250115,250100,250085,250070,250055,250040,250025,250009,249994,249979,249964,249949,249934,249919,249903,249888,249873,249858,249843,249827,249812,249797,249782,249766,249751,249736,249721,249705,249690,249675,249659,249644,249629,249613,249598,249583,249567,249552,249536,249521,249506,249490,249475,249459,249444,249428,249413,249398,249382,249367,249351,249335,249320,249304,249289,249273,249258,249242,249227,249211,249195,249180,249164,249149,249133,249117,249102,249086,249070,249055,249039,249023,249008,248992,248976,248960,248945,248929,248913,248897,248882,248866,248850,248834,248818,248803,248787,248771,248755,248739,248723,248707,248691,248676,248660,248644,248628,248612,248596,248580,248564,248548,248532,248516,248500,248484,248468,248452,248436,248420,248404,248388,248372,248356,248340,248323,248307,248291,248275,248259,248243,248227,248211,248194,248178,248162,248146,248130,248113,248097,248081,248065,248048,248032,248016,248000,247983,247967,247951,247934,247918,247902,247885,247869,247853,247836,247820,247803,247787,247771,247754,247738,247721,247705,247688,247672,247655,247639,247622,247606,247589,247573,247556,247540,247523,247507,247490,247474,247457,247440,247424,247407,247391,247374,247357,247341,247324,247307,247291,247274,247257,247241,247224,247207,247190,247174,247157,247140,247123,247107,247090,247073,247056,247040,247023,247006,246989,246972,246955,246938,246922,246905,246888,246871,246854,246837,246820,246803,246786,246769,246752,246735,246718,246701,246684,246667,246650,246633,246616,246599,246582,246565,246548,246531,246514,246497,246480,246463,246445,246428,246411,246394,246377,246360,246342,246325,246308,246291,246274,246256,246239,246222,246205,246187,246170,246153,246136,246118,246101,246084,246066,246049,246032,246014,245997,245979,245962,245945,245927,245910,245892,245875,245858,245840,245823,245805,245788,245770,245753,245735,245718,245700,245683,245665,245648,245630,245613,245595,245577,245560,245542,245525,245507,245489,245472,245454,245436,245419,245401,245383,245366,245348,245330,245313,245295,245277,245259,245242,245224,245206,245188,245171,245153,245135,245117,245099,245081,245064,245046,245028,245010,244992,244974,244956,244938,244921,244903,244885,244867,244849,244831,244813,244795,244777,244759,244741,244723,244705,244687,244669,244651,244633,244615,244597,244578,244560,244542,244524,244506,244488,244470,244452,244433,244415,244397,244379,244361,244343,244324,244306,244288,244270,244251,244233,244215,244197,244178,244160,244142,244123,244105,244087,244068,244050,244032,244013,243995,243977,243958,243940,243921,243903,243885,243866,243848,243829,243811,243792,243774,243755,243737,243718,243700,243681,243663,243644,243626,243607,243588,243570,243551,243533,243514,243496,243477,243458,243440,243421,243402,243384,243365,243346,243328,243309,243290,243271,243253,243234,243215,243196,243178,243159,243140,243121,243103,243084,243065,243046,243027,243008,242990,242971,242952,242933,242914,242895,242876,242857,242838,242819,242800,242782,242763,242744,242725,242706,242687,242668,242649,242630,242611,242591,242572,242553,242534,242515,242496,242477,242458,242439,242420,242401,242381,242362,242343,242324,242305,242286,242266,242247,242228,242209,242189,242170,242151,242132,242112,242093,242074,242055,242035,242016,241997,241977,241958,241939,241919,241900,241881,241861,241842,241822,241803,241784,241764,241745,241725,241706,241686,241667,241647,241628,241608,241589,241569,241550,241530,241511,241491,241472,241452,241433,241413,241393,241374,241354,241334,241315,241295,241276,241256,241236,241217,241197,241177,241157,241138,241118,241098,241079,241059,241039,241019,241000,240980,240960,240940,240920,240901,240881,240861,240841,240821,240801,240781,240762,240742,240722,240702,240682,240662,240642,240622,240602,240582,240562,240542,240522,240502,240482,240462,240442,240422,240402,240382,240362,240342,240322,240302,240282,240262,240242,240221,240201,240181,240161,240141,240121,240101,240080,240060,240040,240020,240000,239979,239959,239939,239919,239898,239878,239858,239838,239817,239797,239777,239756,239736,239716,239695,239675,239655,239634,239614,239593,239573,239553,239532,239512,239491,239471,239450,239430,239410,239389,239369,239348,239328,239307,239287,239266,239245,239225,239204,239184,239163,239143,239122,239101,239081,239060,239040,239019,238998,238978,238957,238936,238916,238895,238874,238853,238833,238812,238791,238771,238750,238729,238708,238688,238667,238646,238625,238604,238583,238563,238542,238521,238500,238479,238458,238437,238417,238396,238375,238354,238333,238312,238291,238270,238249,238228,238207,238186,238165,238144,238123,238102,238081,238060,238039,238018,237997,237976,237955,237934,237913,237891,237870,237849,237828,237807,237786,237765,237743,237722,237701,237680,237659,237637,237616,237595,237574,237552,237531,237510,237489,237467,237446,237425,237403,237382,237361,237339,237318,237297,237275,237254,237233,237211,237190,237168,237147,237126,237104,237083,237061,237040,237018,236997,236975,236954,236932,236911,236889,236868,236846,236825,236803,236782,236760,236738,236717,236695,236674,236652,236630,236609,236587,236565,236544,236522,236500,236479,236457,236435,236414,236392,236370,236348,236327,236305,236283,236261,236240,236218,236196,236174,236152,236131,236109,236087,236065,236043,236021,235999,235978,235956,235934,235912,235890,235868,235846,235824,235802,235780,235758,235736,235714,235692,235670,235648,235626,235604,235582,235560,235538,235516,235494,235472,235450,235428,235405,235383,235361,235339,235317,235295,235273,235250,235228,235206,235184,235162,235139,235117,235095,235073,235050,235028,235006,234984,234961,234939,234917,234894,234872,234850,234828,234805,234783,234760,234738,234716,234693,234671,234649,234626,234604,234581,234559,234536,234514,234491,234469,234446,234424,234401,234379,234356,234334,234311,234289,234266,234244,234221,234199,234176,234153,234131,234108,234086,234063,234040,234018,233995,233972,233950,233927,233904,233882,233859,233836,233813,233791,233768,233745,233722,233700,233677,233654,233631,233609,233586,233563,233540,233517,233494,233472,233449,233426,233403,233380,233357,233334,233311,233288,233265,233243,233220,233197,233174,233151,233128,233105,233082,233059,233036,233013,232990,232967,232944,232920,232897,232874,232851,232828,232805,232782,232759,232736,232713,232689,232666,232643,232620,232597,232574,232550,232527,232504,232481,232457,232434,232411,232388,232364,232341,232318,232295,232271,232248,232225,232201,232178,232155,232131,232108,232085,232061,232038,232014,231991,231968,231944,231921,231897,231874,231850,231827,231804,231780,231757,231733,231710,231686,231663,231639,231615,231592,231568,231545,231521,231498,231474,231450,231427,231403,231380,231356,231332,231309,231285,231261,231238,231214,231190,231167,231143,231119,231096,231072,231048,231024,231001,230977,230953,230929,230905,230882,230858,230834,230810,230786,230762,230739,230715,230691,230667,230643,230619,230595,230571,230548,230524,230500,230476,230452,230428,230404,230380,230356,230332,230308,230284,230260,230236,230212,230188,230164,230140,230116,230091,230067,230043,230019,229995,229971,229947,229923,229898,229874,229850,229826,229802,229778,229753,229729,229705,229681,229657,229632,229608,229584,229560,229535,229511,229487,229462,229438,229414,229389,229365,229341,229316,229292,229268,229243,229219,229194,229170,229146,229121,229097,229072,229048,229024,228999,228975,228950,228926,228901,228877,228852,228828,228803,228779,228754,228729,228705,228680,228656,228631,228607,228582,228557,228533,228508,228483,228459,228434,228409,228385,228360,228335,228311,228286,228261,228237,228212,228187,228162,228138,228113,228088,228063,228039,228014,227989,227964,227939,227914,227890,227865,227840,227815,227790,227765,227740,227716,227691,227666,227641,227616,227591,227566,227541,227516,227491,227466,227441,227416,227391,227366,227341,227316,227291,227266,227241,227216,227191,227166,227141,227115,227090,227065,227040,227015,226990,226965,226940,226914,226889,226864,226839,226814,226788,226763,226738,226713,226688,226662,226637,226612,226586,226561,226536,226511,226485,226460,226435,226409,226384,226359,226333,226308,226283,226257,226232,226206,226181,226156,226130,226105,226079,226054,226028,226003,225977,225952,225926,225901,225875,225850,225824,225799,225773,225748,225722,225697,225671,225646,225620,225594,225569,225543,225517,225492,225466,225441,225415,225389,225364,225338,225312,225287,225261,225235,225209,225184,225158,225132,225106,225081,225055,225029,225003,224978,224952,224926,224900,224874,224848,224823,224797,224771,224745,224719,224693,224667,224641,224615,224590,224564,224538,224512,224486,224460,224434,224408,224382,224356,224330,224304,224278,224252,224226,224200,224174,224148,224122,224096,224069,224043,224017,223991,223965,223939,223913,223887,223860,223834,223808,223782,223756,223730,223703,223677,223651,223625,223599,223572,223546,223520,223493,223467,223441,223415,223388,223362,223336,223309,223283,223257,223230,223204,223178,223151,223125,223099,223072,223046,223019,222993,222966,222940,222914,222887,222861,222834,222808,222781,222755,222728,222702,222675,222649,222622,222596,222569,222542,222516,222489,222463,222436,222410,222383,222356,222330,222303,222276,222250,222223,222196,222170,222143,222116,222090,222063,222036,222010,221983,221956,221929,221903,221876,221849,221822,221795,221769,221742,221715,221688,221661,221634,221608,221581,221554,221527,221500,221473,221446,221419,221393,221366,221339,221312,221285,221258,221231,221204,221177,221150,221123,221096,221069,221042,221015,220988,220961,220934,220907,220880,220853,220826,220798,220771,220744,220717,220690,220663,220636,220609,220581,220554,220527,220500,220473,220446,220418,220391,220364,220337,220309,220282,220255,220228,220200,220173,220146,220119,220091,220064,220037,220009,219982,219955,219927,219900,219873,219845,219818,219790,219763,219736,219708,219681,219653,219626,219598,219571,219544,219516,219489,219461,219434,219406,219379,219351,219324,219296,219268,219241,219213,219186,219158,219131,219103,219075,219048,219020,218993,218965,218937,218910,218882,218854,218827,218799,218771,218744,218716,218688,218660,218633,218605,218577,218549,218522,218494,218466,218438,218411,218383,218355,218327,218299,218271,218244,218216,218188,218160,218132,218104,218076,218049,218021,217993,217965,217937,217909,217881,217853,217825,217797,217769,217741,217713,217685,217657,217629,217601,217573,217545,217517,217489,217461,217433,217405,217377,217348,217320,217292,217264,217236,217208,217180,217152,217123,217095,217067,217039,217011,216982,216954,216926,216898,216870,216841,216813,216785,216757,216728,216700,216672,216643,216615,216587,216558,216530,216502,216473,216445,216417,216388,216360,216332,216303,216275,216246,216218,216190,216161,216133,216104,216076,216047,216019,215990,215962,215933,215905,215876,215848,215819,215791,215762,215734,215705,215677,215648,215619,215591,215562,215534,215505,215476,215448,215419,215390,215362,215333,215304,215276,215247,215218,215190,215161,215132,215104,215075,215046,215017,214989,214960,214931,214902,214873,214845,214816,214787,214758,214729,214701,214672,214643,214614,214585,214556,214527,214498,214470,214441,214412,214383,214354,214325,214296,214267,214238,214209,214180,214151,214122,214093,214064,214035,214006,213977,213948,213919,213890,213861,213832,213803,213774,213745,213715,213686,213657,213628,213599,213570,213541,213511,213482,213453,213424,213395,213366,213336,213307,213278,213249,213219,213190,213161,213132,213102,213073,213044,213015,212985,212956,212927,212897,212868,212839,212809,212780,212751,212721,212692,212662,212633,212604,212574,212545,212515,212486,212456,212427,212398,212368,212339,212309,212280,212250,212221,212191,212162,212132,212103,212073,212043,212014,211984,211955,211925,211896,211866,211836,211807,211777,211748,211718,211688,211659,211629,211599,211570,211540,211510,211481,211451,211421,211391,211362,211332,211302,211272,211243,211213,211183,211153,211124,211094,211064,211034,211004,210974,210945,210915,210885,210855,210825,210795,210765,210736,210706,210676,210646,210616,210586,210556,210526,210496,210466,210436,210406,210376,210346,210316,210286,210256,210226,210196,210166,210136,210106,210076,210046,210016,209986,209956,209926,209895,209865,209835,209805,209775,209745,209715,209684,209654,209624,209594,209564,209534,209503,209473,209443,209413,209382,209352,209322,209292,209261,209231,209201,209170,209140,209110,209080,209049,209019,208989,208958,208928,208897,208867,208837,208806,208776,208746,208715,208685,208654,208624,208593,208563,208533,208502,208472,208441,208411,208380,208350,208319,208289,208258,208228,208197,208166,208136,208105,208075,208044,208014,207983,207952,207922,207891,207861,207830,207799,207769,207738,207707,207677,207646,207615,207585,207554,207523,207492,207462,207431,207400,207370,207339,207308,207277,207246,207216,207185,207154,207123,207092,207062,207031,207000,206969,206938,206907,206877,206846,206815,206784,206753,206722,206691,206660,206629,206598,206567,206537,206506,206475,206444,206413,206382,206351,206320,206289,206258,206227,206196,206165,206133,206102,206071,206040,206009,205978,205947,205916,205885,205854,205823,205791,205760,205729,205698,205667,205636,205604,205573,205542,205511,205480,205448,205417,205386,205355,205324,205292,205261,205230,205198,205167,205136,205105,205073,205042,205011,204979,204948,204917,204885,204854,204823,204791,204760,204728,204697,204666,204634,204603,204571,204540,204508,204477,204446,204414,204383,204351,204320,204288,204257,204225,204194,204162,204131,204099,204067,204036,204004,203973,203941,203910,203878,203846,203815,203783,203752,203720,203688,203657,203625,203593,203562,203530,203498,203467,203435,203403,203372,203340,203308,203276,203245,203213,203181,203149,203118,203086,203054,203022,202990,202959,202927,202895,202863,202831,202799,202768,202736,202704,202672,202640,202608,202576,202544,202512,202481,202449,202417,202385,202353,202321,202289,202257,202225,202193,202161,202129,202097,202065,202033,202001,201969,201937,201905,201873,201841,201808,201776,201744,201712,201680,201648,201616,201584,201552,201519,201487,201455,201423,201391,201359,201326,201294,201262,201230,201198,201165,201133,201101,201069,201036,201004,200972,200940,200907,200875,200843,200810,200778,200746,200713,200681,200649,200616,200584,200552,200519,200487,200454,200422,200390,200357,200325,200292,200260,200228,200195,200163,200130,200098,200065,200033,200000,199968,199935,199903,199870,199838,199805,199773,199740,199708,199675,199642,199610,199577,199545,199512,199479,199447,199414,199382,199349,199316,199284,199251,199218,199186,199153,199120,199088,199055,199022,198989,198957,198924,198891,198858,198826,198793,198760,198727,198695,198662,198629,198596,198563,198531,198498,198465,198432,198399,198366,198334,198301,198268,198235,198202,198169,198136,198103,198070,198037,198004,197972,197939,197906,197873,197840,197807,197774,197741,197708,197675,197642,197609,197576,197543,197510,197476,197443,197410,197377,197344,197311,197278,197245,197212,197179,197146,197112,197079,197046,197013,196980,196947,196913,196880,196847,196814,196781,196747,196714,196681,196648,196615,196581,196548,196515,196481,196448,196415,196382,196348,196315,196282,196248,196215,196182,196148,196115,196082,196048,196015,195982,195948,195915,195881,195848,195815,195781,195748,195714,195681,195647,195614,195580,195547,195513,195480,195446,195413,195379,195346,195312,195279,195245,195212,195178,195145,195111,195078,195044,195010,194977,194943,194910,194876,194842,194809,194775,194741,194708,194674,194640,194607,194573,194539,194506,194472,194438,194405,194371,194337,194303,194270,194236,194202,194168,194135,194101,194067,194033,193999,193966,193932,193898,193864,193830,193796,193763,193729,193695,193661,193627,193593,193559,193525,193492,193458,193424,193390,193356,193322,193288,193254,193220,193186,193152,193118,193084,193050,193016,192982,192948,192914,192880,192846,192812,192778,192744,192710,192676,192641,192607,192573,192539,192505,192471,192437,192403,192369,192334,192300,192266,192232,192198,192164,192129,192095,192061,192027,191992,191958,191924,191890,191856,191821,191787,191753,191718,191684,191650,191616,191581,191547,191513,191478,191444,191410,191375,191341,191307,191272,191238,191203,191169,191135,191100,191066,191031,190997,190963,190928,190894,190859,190825,190790,190756,190721,190687,190652,190618,190583,190549,190514,190480,190445,190411,190376,190342,190307,190272,190238,190203,190169,190134,190099,190065,190030,189996,189961,189926,189892,189857,189822,189788,189753,189718,189684,189649,189614,189580,189545,189510,189475,189441,189406,189371,189336,189302,189267,189232,189197,189162,189128,189093,189058,189023,188988,188954,188919,188884,188849,188814,188779,188744,188709,188675,188640,188605,188570,188535,188500,188465,188430,188395,188360,188325,188290,188255,188220,188185,188150,188115,188080,188045,188010,187975,187940,187905,187870,187835,187800,187765,187730,187695,187660,187625,187589,187554,187519,187484,187449,187414,187379,187343,187308,187273,187238,187203,187168,187132,187097,187062,187027,186992,186956,186921,186886,186851,186815,186780,186745,186710,186674,186639,186604,186568,186533,186498,186462,186427,186392,186356,186321,186286,186250,186215,186179,186144,186109,186073,186038,186002,185967,185932,185896,185861,185825,185790,185754,185719,185683,185648,185612,185577,185541,185506,185470,185435,185399,185364,185328,185293,185257,185222,185186,185150,185115,185079,185044,185008,184972,184937,184901,184866,184830,184794,184759,184723,184687,184652,184616,184580,184545,184509,184473,184437,184402,184366,184330,184294,184259,184223,184187,184151,184116,184080,184044,184008,183972,183937,183901,183865,183829,183793,183757,183722,183686,183650,183614,183578,183542,183506,183470,183435,183399,183363,183327,183291,183255,183219,183183,183147,183111,183075,183039,183003,182967,182931,182895,182859,182823,182787,182751,182715,182679,182643,182607,182571,182535,182499,182463,182426,182390,182354,182318,182282,182246,182210,182174,182137,182101,182065,182029,181993,181957,181920,181884,181848,181812,181776,181739,181703,181667,181631,181594,181558,181522,181486,181449,181413,181377,181341,181304,181268,181232,181195,181159,181123,181086,181050,181014,180977,180941,180904,180868,180832,180795,180759,180723,180686,180650,180613,180577,180540,180504,180467,180431,180395,180358,180322,180285,180249,180212,180176,180139,180103,180066,180029,179993,179956,179920,179883,179847,179810,179774,179737,179700,179664,179627,179591,179554,179517,179481,179444,179407,179371,179334,179297,179261,179224,179187,179151,179114,179077,179041,179004,178967,178930,178894,178857,178820,178783,178747,178710,178673,178636,178600,178563,178526,178489,178452,178415,178379,178342,178305,178268,178231,178194,178158,178121,178084,178047,178010,177973,177936,177899,177862,177825,177788,177752,177715,177678,177641,177604,177567,177530,177493,177456,177419,177382,177345,177308,177271,177234,177197,177160,177123,177085,177048,177011,176974,176937,176900,176863,176826,176789,176752,176714,176677,176640,176603,176566,176529,176492,176454,176417,176380,176343,176306,176268,176231,176194,176157,176120,176082,176045,176008,175971,175933,175896,175859,175822,175784,175747,175710,175672,175635,175598,175560,175523,175486,175448,175411,175374,175336,175299,175262,175224,175187,175149,175112,175075,175037,175000,174962,174925,174887,174850,174813,174775,174738,174700,174663,174625,174588,174550,174513,174475,174438,174400,174363,174325,174288,174250,174212,174175,174137,174100,174062,174025,173987,173949,173912,173874,173837,173799,173761,173724,173686,173648,173611,173573,173535,173498,173460,173422,173385,173347,173309,173271,173234,173196,173158,173121,173083,173045,173007,172969,172932,172894,172856,172818,172781,172743,172705,172667,172629,172591,172554,172516,172478,172440,172402,172364,172326,172289,172251,172213,172175,172137,172099,172061,172023,171985,171947,171909,171871,171834,171796,171758,171720,171682,171644,171606,171568,171530,171492,171454,171416,171378,171339,171301,171263,171225,171187,171149,171111,171073,171035,170997,170959,170921,170883,170844,170806,170768,170730,170692,170654,170616,170577,170539,170501,170463,170425,170386,170348,170310,170272,170234,170195,170157,170119,170081,170042,170004,169966,169928,169889,169851,169813,169774,169736,169698,169660,169621,169583,169545,169506,169468,169430,169391,169353,169314,169276,169238,169199,169161,169122,169084,169046,169007,168969,168930,168892,168853,168815,168777,168738,168700,168661,168623,168584,168546,168507,168469,168430,168392,168353,168315,168276,168238,168199,168160,168122,168083,168045,168006,167968,167929,167890,167852,167813,167774,167736,167697,167659,167620,167581,167543,167504,167465,167427,167388,167349,167311,167272,167233,167194,167156,167117,167078,167040,167001,166962,166923,166885,166846,166807,166768,166729,166691,166652,166613,166574,166535,166497,166458,166419,166380,166341,166302,166264,166225,166186,166147,166108,166069,166030,165991,165952,165914,165875,165836,165797,165758,165719,165680,165641,165602,165563,165524,165485,165446,165407,165368,165329,165290,165251,165212,165173,165134,165095,165056,165017,164978,164939,164900,164861,164821,164782,164743,164704,164665,164626,164587,164548,164509,164469,164430,164391,164352,164313,164274,164234,164195,164156,164117,164078,164039,163999,163960,163921,163882,163842,163803,163764,163725,163685,163646,163607,163568,163528,163489,163450,163410,163371,163332,163292,163253,163214,163174,163135,163096,163056,163017,162978,162938,162899,162860,162820,162781,162741,162702,162663,162623,162584,162544,162505,162465,162426,162386,162347,162308,162268,162229,162189,162150,162110,162071,162031,161992,161952,161913,161873,161833,161794,161754,161715,161675,161636,161596,161557,161517,161477,161438,161398,161359,161319,161279,161240,161200,161160,161121,161081,161041,161002,160962,160922,160883,160843,160803,160764,160724,160684,160644,160605,160565,160525,160486,160446,160406,160366,160327,160287,160247,160207,160167,160128,160088,160048,160008,159968,159929,159889,159849,159809,159769,159729,159689,159650,159610,159570,159530,159490,159450,159410,159370,159330,159291,159251,159211,159171,159131,159091,159051,159011,158971,158931,158891,158851,158811,158771,158731,158691,158651,158611,158571,158531,158491,158451,158411,158371,158331,158291,158251,158211,158170,158130,158090,158050,158010,157970,157930,157890,157850,157809,157769,157729,157689,157649,157609,157569,157528,157488,157448,157408,157368,157327,157287,157247,157207,157167,157126,157086,157046,157006,156965,156925,156885,156845,156804,156764,156724,156683,156643,156603,156562,156522,156482,156441,156401,156361,156320,156280,156240,156199,156159,156119,156078,156038,155997,155957,155917,155876,155836,155795,155755,155715,155674,155634,155593,155553,155512,155472,155431,155391,155350,155310,155269,155229,155188,155148,155107,155067,155026,154986,154945,154905,154864,154824,154783,154742,154702,154661,154621,154580,154539,154499,154458,154418,154377,154336,154296,154255,154214,154174,154133,154093,154052,154011,153970,153930,153889,153848,153808,153767,153726,153686,153645,153604,153563,153523,153482,153441,153400,153360,153319,153278,153237,153197,153156,153115,153074,153033,152993,152952,152911,152870,152829,152788,152748,152707,152666,152625,152584,152543,152502,152461,152421,152380,152339,152298,152257,152216,152175,152134,152093,152052,152011,151970,151929,151888,151847,151806,151765,151724,151683,151642,151601,151560,151519,151478,151437,151396,151355,151314,151273,151232,151191,151150,151109,151068,151027,150986,150945,150904,150862,150821,150780,150739,150698,150657,150616,150575,150533,150492,150451,150410,150369,150328,150286,150245,150204,150163,150122,150080,150039,149998,149957,149916,149874,149833,149792,149751,149709,149668,149627,149585,149544,149503,149462,149420,149379,149338,149296,149255,149214,149172,149131,149090,149048,149007,148966,148924,148883,148842,148800,148759,148717,148676,148635,148593,148552,148510,148469,148428,148386,148345,148303,148262,148220,148179,148137,148096,148054,148013,147971,147930,147888,147847,147805,147764,147722,147681,147639,147598,147556,147515,147473,147432,147390,147348,147307,147265,147224,147182,147141,147099,147057,147016,146974,146932,146891,146849,146808,146766,146724,146683,146641,146599,146558,146516,146474,146433,146391,146349,146307,146266,146224,146182,146141,146099,146057,146015,145974,145932,145890,145848,145807,145765,145723,145681,145639,145598,145556,145514,145472,145430,145389,145347,145305,145263,145221,145179,145137,145096,145054,145012,144970,144928,144886,144844,144802,144761,144719,144677,144635,144593,144551,144509,144467,144425,144383,144341,144299,144257,144215,144173,144131,144089,144047,144005,143963,143921,143879,143837,143795,143753,143711,143669,143627,143585,143543,143501,143459,143417,143375,143333,143291,143248,143206,143164,143122,143080,143038,142996,142954,142912,142869,142827,142785,142743,142701,142659,142616,142574,142532,142490,142448,142405,142363,142321,142279,142237,142194,142152,142110,142068,142025,141983,141941,141899,141856,141814,141772,141730,141687,141645,141603,141560,141518,141476,141433,141391,141349,141306,141264,141222,141179,141137,141095,141052,141010,140968,140925,140883,140840,140798,140756,140713,140671,140628,140586,140544,140501,140459,140416,140374,140331,140289,140246,140204,140161,140119,140077,140034,139992,139949,139907,139864,139821,139779,139736,139694,139651,139609,139566,139524,139481,139439,139396,139353,139311,139268,139226,139183,139141,139098,139055,139013,138970,138927,138885,138842,138800,138757,138714,138672,138629,138586,138544,138501,138458,138416,138373,138330,138288,138245,138202,138159,138117,138074,138031,137988,137946,137903,137860,137817,137775,137732,137689,137646,137604,137561,137518,137475,137432,137390,137347,137304,137261,137218,137176,137133,137090,137047,137004,136961,136918,136876,136833,136790,136747,136704,136661,136618,136575,136532,136490,136447,136404,136361,136318,136275,136232,136189,136146,136103,136060,136017,135974,135931,135888,135845,135802,135759,135716,135673,135630,135587,135544,135501,135458,135415,135372,135329,135286,135243,135200,135157,135114,135071,135028,134984,134941,134898,134855,134812,134769,134726,134683,134640,134596,134553,134510,134467,134424,134381,134338,134294,134251,134208,134165,134122,134078,134035,133992,133949,133906,133862,133819,133776,133733,133690,133646,133603,133560,133517,133473,133430,133387,133343,133300,133257,133214,133170,133127,133084,133040,132997,132954,132910,132867,132824,132780,132737,132694,132650,132607,132564,132520,132477,132434,132390,132347,132303,132260,132217,132173,132130,132086,132043,132000,131956,131913,131869,131826,131782,131739,131695,131652,131609,131565,131522,131478,131435,131391,131348,131304,131261,131217,131174,131130,131087,131043,130999,130956,130912,130869,130825,130782,130738,130695,130651,130607,130564,130520,130477,130433,130389,130346,130302,130259,130215,130171,130128,130084,130040,129997,129953,129909,129866,129822,129778,129735,129691,129647,129604,129560,129516,129473,129429,129385,129341,129298,129254,129210,129167,129123,129079,129035,128992,128948,128904,128860,128816,128773,128729,128685,128641,128598,128554,128510,128466,128422,128378,128335,128291,128247,128203,128159,128115,128072,128028,127984,127940,127896,127852,127808,127764,127721,127677,127633,127589,127545,127501,127457,127413,127369,127325,127281,127237,127193,127150,127106,127062,127018,126974,126930,126886,126842,126798,126754,126710,126666,126622,126578,126534,126490,126446,126402,126358,126314,126269,126225,126181,126137,126093,126049,126005,125961,125917,125873,125829,125785,125741,125696,125652,125608,125564,125520,125476,125432,125388,125343,125299,125255,125211,125167,125123,125078,125034,124990,124946,124902,124857,124813,124769,124725,124681,124636,124592,124548,124504,124460,124415,124371,124327,124283,124238,124194,124150,124105,124061,124017,123973,123928,123884,123840,123795,123751,123707,123662,123618,123574,123529,123485,123441,123396,123352,123308,123263,123219,123175,123130,123086,123042,122997,122953,122908,122864,122820,122775,122731,122686,122642,122597,122553,122509,122464,122420,122375,122331,122286,122242,122197,122153,122108,122064,122019,121975,121931,121886,121842,121797,121752,121708,121663,121619,121574,121530,121485,121441,121396,121352,121307,121263,121218,121173,121129,121084,121040,120995,120950,120906,120861,120817,120772,120727,120683,120638,120594,120549,120504,120460,120415,120370,120326,120281,120236,120192,120147,120102,120058,120013,119968,119924,119879,119834,119790,119745,119700,119655,119611,119566,119521,119476,119432,119387,119342,119297,119253,119208,119163,119118,119074,119029,118984,118939,118894,118850,118805,118760,118715,118670,118626,118581,118536,118491,118446,118401,118357,118312,118267,118222,118177,118132,118087,118042,117998,117953,117908,117863,117818,117773,117728,117683,117638,117593,117549,117504,117459,117414,117369,117324,117279,117234,117189,117144,117099,117054,117009,116964,116919,116874,116829,116784,116739,116694,116649,116604,116559,116514,116469,116424,116379,116334,116289,116244,116199,116154,116109,116064,116018,115973,115928,115883,115838,115793,115748,115703,115658,115613,115567,115522,115477,115432,115387,115342,115297,115252,115206,115161,115116,115071,115026,114981,114935,114890,114845,114800,114755,114710,114664,114619,114574,114529,114483,114438,114393,114348,114303,114257,114212,114167,114122,114076,114031,113986,113941,113895,113850,113805,113759,113714,113669,113624,113578,113533,113488,113442,113397,113352,113306,113261,113216,113170,113125,113080,113034,112989,112944,112898,112853,112808,112762,112717,112671,112626,112581,112535,112490,112444,112399,112354,112308,112263,112217,112172,112126,112081,112036,111990,111945,111899,111854,111808,111763,111717,111672,111626,111581,111535,111490,111444,111399,111353,111308,111262,111217,111171,111126,111080,111035,110989,110944,110898,110853,110807,110762,110716,110670,110625,110579,110534,110488,110443,110397,110351,110306,110260,110215,110169,110123,110078,110032,109986,109941,109895,109850,109804,109758,109713,109667,109621,109576,109530,109484,109439,109393,109347,109302,109256,109210,109165,109119,109073,109027,108982,108936,108890,108845,108799,108753,108707,108662,108616,108570,108524,108479,108433,108387,108341,108295,108250,108204,108158,108112,108067,108021,107975,107929,107883,107838,107792,107746,107700,107654,107608,107563,107517,107471,107425,107379,107333,107287,107242,107196,107150,107104,107058,107012,106966,106920,106875,106829,106783,106737,106691,106645,106599,106553,106507,106461,106415,106369,106323,106278,106232,106186,106140,106094,106048,106002,105956,105910,105864,105818,105772,105726,105680,105634,105588,105542,105496,105450,105404,105358,105312,105266,105220,105174,105128,105082,105035,104989,104943,104897,104851,104805,104759,104713,104667,104621,104575,104529,104483,104436,104390,104344,104298,104252,104206,104160,104114,104067,104021,103975,103929,103883,103837,103791,103744,103698,103652,103606,103560,103514,103467,103421,103375,103329,103283,103236,103190,103144,103098,103052,103005,102959,102913,102867,102820,102774,102728,102682,102635,102589,102543,102497,102450,102404,102358,102312,102265,102219,102173,102126,102080,102034,101988,101941,101895,101849,101802,101756,101710,101663,101617,101571,101524,101478,101432,101385,101339,101293,101246,101200,101153,101107,101061,101014,100968,100922,100875,100829,100782,100736,100690,100643,100597,100550,100504,100457,100411,100365,100318,100272,100225,100179,100132,100086,100039,99993,99947,99900,99854,99807,99761,99714,99668,99621,99575,99528,99482,99435,99389,99342,99296,99249,99203,99156,99110,99063,99016,98970,98923,98877,98830,98784,98737,98691,98644,98597,98551,98504,98458,98411,98364,98318,98271,98225,98178,98131,98085,98038,97992,97945,97898,97852,97805,97758,97712,97665,97619,97572,97525,97479,97432,97385,97339,97292,97245,97199,97152,97105,97058,97012,96965,96918,96872,96825,96778,96732,96685,96638,96591,96545,96498,96451,96404,96358,96311,96264,96217,96171,96124,96077,96030,95984,95937,95890,95843,95796,95750,95703,95656,95609,95562,95516,95469,95422,95375,95328,95282,95235,95188,95141,95094,95047,95001,94954,94907,94860,94813,94766,94719,94673,94626,94579,94532,94485,94438,94391,94344,94297,94251,94204,94157,94110,94063,94016,93969,93922,93875,93828,93781,93734,93687,93640,93594,93547,93500,93453,93406,93359,93312,93265,93218,93171,93124,93077,93030,92983,92936,92889,92842,92795,92748,92701,92654,92607,92560,92513,92466,92419,92372,92325,92278,92230,92183,92136,92089,92042,91995,91948,91901,91854,91807,91760,91713,91666,91619,91571,91524,91477,91430,91383,91336,91289,91242,91195,91147,91100,91053,91006,90959,90912,90865,90817,90770,90723,90676,90629,90582,90534,90487,90440,90393,90346,90299,90251,90204,90157,90110,90063,90015,89968,89921,89874,89826,89779,89732,89685,89638,89590,89543,89496,89449,89401,89354,89307,89260,89212,89165,89118,89070,89023,88976,88929,88881,88834,88787,88739,88692,88645,88598,88550,88503,88456,88408,88361,88314,88266,88219,88172,88124,88077,88030,87982,87935,87888,87840,87793,87745,87698,87651,87603,87556,87509,87461,87414,87366,87319,87272,87224,87177,87129,87082,87035,86987,86940,86892,86845,86798,86750,86703,86655,86608,86560,86513,86465,86418,86371,86323,86276,86228,86181,86133,86086,86038,85991,85943,85896,85848,85801,85753,85706,85658,85611,85563,85516,85468,85421,85373,85326,85278,85231,85183,85136,85088,85040,84993,84945,84898,84850,84803,84755,84708,84660,84612,84565,84517,84470,84422,84374,84327,84279,84232,84184,84136,84089,84041,83994,83946,83898,83851,83803,83756,83708,83660,83613,83565,83517,83470,83422,83374,83327,83279,83231,83184,83136,83088,83041,82993,82945,82898,82850,82802,82755,82707,82659,82612,82564,82516,82468,82421,82373,82325,82278,82230,82182,82134,82087,82039,81991,81943,81896,81848,81800,81752,81705,81657,81609,81561,81514,81466,81418,81370,81322,81275,81227,81179,81131,81083,81036,80988,80940,80892,80844,80797,80749,80701,80653,80605,80557,80510,80462,80414,80366,80318,80270,80223,80175,80127,80079,80031,79983,79935,79887,79840,79792,79744,79696,79648,79600,79552,79504,79457,79409,79361,79313,79265,79217,79169,79121,79073,79025,78977,78929,78881,78834,78786,78738,78690,78642,78594,78546,78498,78450,78402,78354,78306,78258,78210,78162,78114,78066,78018,77970,77922,77874,77826,77778,77730,77682,77634,77586,77538,77490,77442,77394,77346,77298,77250,77202,77154,77106,77058,77010,76962,76914,76866,76818,76770,76721,76673,76625,76577,76529,76481,76433,76385,76337,76289,76241,76193,76144,76096,76048,76000,75952,75904,75856,75808,75760,75711,75663,75615,75567,75519,75471,75423,75375,75326,75278,75230,75182,75134,75086,75037,74989,74941,74893,74845,74797,74748,74700,74652,74604,74556,74508,74459,74411,74363,74315,74267,74218,74170,74122,74074,74025,73977,73929,73881,73833,73784,73736,73688,73640,73591,73543,73495,73447,73398,73350,73302,73254,73205,73157,73109,73061,73012,72964,72916,72867,72819,72771,72723,72674,72626,72578,72529,72481,72433,72384,72336,72288,72239,72191,72143,72095,72046,71998,71950,71901,71853,71805,71756,71708,71659,71611,71563,71514,71466,71418,71369,71321,71273,71224,71176,71127,71079,71031,70982,70934,70886,70837,70789,70740,70692,70644,70595,70547,70498,70450,70401,70353,70305,70256,70208,70159,70111,70062,70014,69966,69917,69869,69820,69772,69723,69675,69626,69578,69530,69481,69433,69384,69336,69287,69239,69190,69142,69093,69045,68996,68948,68899,68851,68802,68754,68705,68657,68608,68560,68511,68463,68414,68366,68317,68269,68220,68171,68123,68074,68026,67977,67929,67880,67832,67783,67735,67686,67637,67589,67540,67492,67443,67395,67346,67297,67249,67200,67152,67103,67055,67006,66957,66909,66860,66812,66763,66714,66666,66617,66568,66520,66471,66423,66374,66325,66277,66228,66179,66131,66082,66034,65985,65936,65888,65839,65790,65742,65693,65644,65596,65547,65498,65450,65401,65352,65304,65255,65206,65158,65109,65060,65011,64963,64914,64865,64817,64768,64719,64671,64622,64573,64524,64476,64427,64378,64329,64281,64232,64183,64135,64086,64037,63988,63940,63891,63842,63793,63745,63696,63647,63598,63550,63501,63452,63403,63354,63306,63257,63208,63159,63111,63062,63013,62964,62915,62867,62818,62769,62720,62671,62623,62574,62525,62476,62427,62378,62330,62281,62232,62183,62134,62085,62037,61988,61939,61890,61841,61792,61744,61695,61646,61597,61548,61499,61450,61402,61353,61304,61255,61206,61157,61108,61059,61011,60962,60913,60864,60815,60766,60717,60668,60619,60570,60522,60473,60424,60375,60326,60277,60228,60179,60130,60081,60032,59983,59935,59886,59837,59788,59739,59690,59641,59592,59543,59494,59445,59396,59347,59298,59249,59200,59151,59102,59053,59004,58955,58906,58857,58808,58759,58711,58662,58613,58564,58515,58466,58417,58368,58319,58270,58221,58171,58122,58073,58024,57975,57926,57877,57828,57779,57730,57681,57632,57583,57534,57485,57436,57387,57338,57289,57240,57191,57142,57093,57044,56995,56946,56896,56847,56798,56749,56700,56651,56602,56553,56504,56455,56406,56357,56308,56258,56209,56160,56111,56062,56013,55964,55915,55866,55816,55767,55718,55669,55620,55571,55522,55473,55424,55374,55325,55276,55227,55178,55129,55080,55030,54981,54932,54883,54834,54785,54736,54686,54637,54588,54539,54490,54441,54391,54342,54293,54244,54195,54145,54096,54047,53998,53949,53900,53850,53801,53752,53703,53654,53604,53555,53506,53457,53408,53358,53309,53260,53211,53161,53112,53063,53014,52965,52915,52866,52817,52768,52718,52669,52620,52571,52521,52472,52423,52374,52324,52275,52226,52177,52127,52078,52029,51980,51930,51881,51832,51782,51733,51684,51635,51585,51536,51487,51438,51388,51339,51290,51240,51191,51142,51092,51043,50994,50945,50895,50846,50797,50747,50698,50649,50599,50550,50501,50451,50402,50353,50303,50254,50205,50155,50106,50057,50007,49958,49909,49859,49810,49761,49711,49662,49613,49563,49514,49464,49415,49366,49316,49267,49218,49168,49119,49070,49020,48971,48921,48872,48823,48773,48724,48674,48625,48576,48526,48477,48427,48378,48329,48279,48230,48180,48131,48082,48032,47983,47933,47884,47835,47785,47736,47686,47637,47587,47538,47489,47439,47390,47340,47291,47241,47192,47142,47093,47044,46994,46945,46895,46846,46796,46747,46697,46648,46598,46549,46500,46450,46401,46351,46302,46252,46203,46153,46104,46054,46005,45955,45906,45856,45807,45757,45708,45658,45609,45559,45510,45460,45411,45361,45312,45262,45213,45163,45114,45064,45015,44965,44916,44866,44817,44767,44718,44668,44619,44569,44519,44470,44420,44371,44321,44272,44222,44173,44123,44074,44024,43974,43925,43875,43826,43776,43727,43677,43628,43578,43528,43479,43429,43380,43330,43281,43231,43181,43132,43082,43033,42983,42933,42884,42834,42785,42735,42686,42636,42586,42537,42487,42438,42388,42338,42289,42239,42190,42140,42090,42041,41991,41941,41892,41842,41793,41743,41693,41644,41594,41544,41495,41445,41396,41346,41296,41247,41197,41147,41098,41048,40998,40949,40899,40849,40800,40750,40701,40651,40601,40552,40502,40452,40403,40353,40303,40254,40204,40154,40105,40055,40005,39956,39906,39856,39806,39757,39707,39657,39608,39558,39508,39459,39409,39359,39310,39260,39210,39160,39111,39061,39011,38962,38912,38862,38813,38763,38713,38663,38614,38564,38514,38465,38415,38365,38315,38266,38216,38166,38116,38067,38017,37967,37917,37868,37818,37768,37719,37669,37619,37569,37520,37470,37420,37370,37321,37271,37221,37171,37122,37072,37022,36972,36922,36873,36823,36773,36723,36674,36624,36574,36524,36475,36425,36375,36325,36275,36226,36176,36126,36076,36027,35977,35927,35877,35827,35778,35728,35678,35628,35578,35529,35479,35429,35379,35329,35280,35230,35180,35130,35080,35030,34981,34931,34881,34831,34781,34732,34682,34632,34582,34532,34482,34433,34383,34333,34283,34233,34183,34134,34084,34034,33984,33934,33884,33835,33785,33735,33685,33635,33585,33535,33486,33436,33386,33336,33286,33236,33186,33137,33087,33037,32987,32937,32887,32837,32788,32738,32688,32638,32588,32538,32488,32438,32389,32339,32289,32239,32189,32139,32089,32039,31989,31940,31890,31840,31790,31740,31690,31640,31590,31540,31490,31441,31391,31341,31291,31241,31191,31141,31091,31041,30991,30942,30892,30842,30792,30742,30692,30642,30592,30542,30492,30442,30392,30342,30293,30243,30193,30143,30093,30043,29993,29943,29893,29843,29793,29743,29693,29643,29593,29543,29494,29444,29394,29344,29294,29244,29194,29144,29094,29044,28994,28944,28894,28844,28794,28744,28694,28644,28594,28544,28494,28444,28394,28344,28295,28245,28195,28145,28095,28045,27995,27945,27895,27845,27795,27745,27695,27645,27595,27545,27495,27445,27395,27345,27295,27245,27195,27145,27095,27045,26995,26945,26895,26845,26795,26745,26695,26645,26595,26545,26495,26445,26395,26345,26295,26245,26195,26145,26095,26045,25995,25945,25895,25845,25795,25745,25695,25645,25595,25545,25495,25444,25394,25344,25294,25244,25194,25144,25094,25044,24994,24944,24894,24844,24794,24744,24694,24644,24594,24544,24494,24444,24394,24344,24294,24244,24193,24143,24093,24043,23993,23943,23893,23843,23793,23743,23693,23643,23593,23543,23493,23443,23393,23342,23292,23242,23192,23142,23092,23042,22992,22942,22892,22842,22792,22742,22692,22641,22591,22541,22491,22441,22391,22341,22291,22241,22191,22141,22091,22040,21990,21940,21890,21840,21790,21740,21690,21640,21590,21540,21489,21439,21389,21339,21289,21239,21189,21139,21089,21039,20988,20938,20888,20838,20788,20738,20688,20638,20588,20538,20487,20437,20387,20337,20287,20237,20187,20137,20086,20036,19986,19936,19886,19836,19786,19736,19686,19635,19585,19535,19485,19435,19385,19335,19285,19234,19184,19134,19084,19034,18984,18934,18883,18833,18783,18733,18683,18633,18583,18532,18482,18432,18382,18332,18282,18232,18181,18131,18081,18031,17981,17931,17881,17830,17780,17730,17680,17630,17580,17530,17479,17429,17379,17329,17279,17229,17178,17128,17078,17028,16978,16928,16878,16827,16777,16727,16677,16627,16577,16526,16476,16426,16376,16326,16276,16225,16175,16125,16075,16025,15975,15924,15874,15824,15774,15724,15673,15623,15573,15523,15473,15423,15372,15322,15272,15222,15172,15122,15071,15021,14971,14921,14871,14820,14770,14720,14670,14620,14569,14519,14469,14419,14369,14319,14268,14218,14168,14118,14068,14017,13967,13917,13867,13817,13766,13716,13666,13616,13566,13515,13465,13415,13365,13315,13264,13214,13164,13114,13064,13013,12963,12913,12863,12813,12762,12712,12662,12612,12562,12511,12461,12411,12361,12311,12260,12210,12160,12110,12059,12009,11959,11909,11859,11808,11758,11708,11658,11608,11557,11507,11457,11407,11356,11306,11256,11206,11156,11105,11055,11005,10955,10904,10854,10804,10754,10704,10653,10603,10553,10503,10452,10402,10352,10302,10252,10201,10151,10101,10051,10000,9950,9900,9850,9799,9749,9699,9649,9599,9548,9498,9448,9398,9347,9297,9247,9197,9146,9096,9046,8996,8946,8895,8845,8795,8745,8694,8644,8594,8544,8493,8443,8393,8343,8292,8242,8192,8142,8091,8041,7991,7941,7890,7840,7790,7740,7690,7639,7589,7539,7489,7438,7388,7338,7288,7237,7187,7137,7087,7036,6986,6936,6886,6835,6785,6735,6685,6634,6584,6534,6484,6433,6383,6333,6283,6232,6182,6132,6082,6031,5981,5931,5881,5830,5780,5730,5680,5629,5579,5529,5479,5428,5378,5328,5278,5227,5177,5127,5076,5026,4976,4926,4875,4825,4775,4725,4674,4624,4574,4524,4473,4423,4373,4323,4272,4222,4172,4122,4071,4021,3971,3921,3870,3820,3770,3720,3669,3619,3569,3518,3468,3418,3368,3317,3267,3217,3167,3116,3066,3016,2966,2915,2865,2815,2765,2714,2664,2614,2563,2513,2463,2413,2362,2312,2262,2212,2161,2111,2061,2011,1960,1910,1860,1810,1759,1709,1659,1608,1558,1508,1458,1407,1357,1307,1257,1206,1156,1106,1056,1005,955,905,855,804,754,704,653,603,553,503,452,402,352,302,251,201,151,101,50,0,-49,-100,-150,-200,-250,-301,-351,-401,-451,-502,-552,-602,-652,-703,-753,-803,-854,-904,-954,-1004,-1055,-1105,-1155,-1205,-1256,-1306,-1356,-1406,-1457,-1507,-1557,-1607,-1658,-1708,-1758,-1809,-1859,-1909,-1959,-2010,-2060,-2110,-2160,-2211,-2261,-2311,-2361,-2412,-2462,-2512,-2562,-2613,-2663,-2713,-2764,-2814,-2864,-2914,-2965,-3015,-3065,-3115,-3166,-3216,-3266,-3316,-3367,-3417,-3467,-3517,-3568,-3618,-3668,-3719,-3769,-3819,-3869,-3920,-3970,-4020,-4070,-4121,-4171,-4221,-4271,-4322,-4372,-4422,-4472,-4523,-4573,-4623,-4673,-4724,-4774,-4824,-4874,-4925,-4975,-5025,-5075,-5126,-5176,-5226,-5277,-5327,-5377,-5427,-5478,-5528,-5578,-5628,-5679,-5729,-5779,-5829,-5880,-5930,-5980,-6030,-6081,-6131,-6181,-6231,-6282,-6332,-6382,-6432,-6483,-6533,-6583,-6633,-6684,-6734,-6784,-6834,-6885,-6935,-6985,-7035,-7086,-7136,-7186,-7236,-7287,-7337,-7387,-7437,-7488,-7538,-7588,-7638,-7689,-7739,-7789,-7839,-7889,-7940,-7990,-8040,-8090,-8141,-8191,-8241,-8291,-8342,-8392,-8442,-8492,-8543,-8593,-8643,-8693,-8744,-8794,-8844,-8894,-8945,-8995,-9045,-9095,-9145,-9196,-9246,-9296,-9346,-9397,-9447,-9497,-9547,-9598,-9648,-9698,-9748,-9798,-9849,-9899,-9949,-9999,-10050,-10100,-10150,-10200,-10251,-10301,-10351,-10401,-10451,-10502,-10552,-10602,-10652,-10703,-10753,-10803,-10853,-10903,-10954,-11004,-11054,-11104,-11155,-11205,-11255,-11305,-11355,-11406,-11456,-11506,-11556,-11607,-11657,-11707,-11757,-11807,-11858,-11908,-11958,-12008,-12058,-12109,-12159,-12209,-12259,-12310,-12360,-12410,-12460,-12510,-12561,-12611,-12661,-12711,-12761,-12812,-12862,-12912,-12962,-13012,-13063,-13113,-13163,-13213,-13263,-13314,-13364,-13414,-13464,-13514,-13565,-13615,-13665,-13715,-13765,-13816,-13866,-13916,-13966,-14016,-14067,-14117,-14167,-14217,-14267,-14318,-14368,-14418,-14468,-14518,-14568,-14619,-14669,-14719,-14769,-14819,-14870,-14920,-14970,-15020,-15070,-15121,-15171,-15221,-15271,-15321,-15371,-15422,-15472,-15522,-15572,-15622,-15672,-15723,-15773,-15823,-15873,-15923,-15974,-16024,-16074,-16124,-16174,-16224,-16275,-16325,-16375,-16425,-16475,-16525,-16576,-16626,-16676,-16726,-16776,-16826,-16877,-16927,-16977,-17027,-17077,-17127,-17177,-17228,-17278,-17328,-17378,-17428,-17478,-17529,-17579,-17629,-17679,-17729,-17779,-17829,-17880,-17930,-17980,-18030,-18080,-18130,-18180,-18231,-18281,-18331,-18381,-18431,-18481,-18531,-18582,-18632,-18682,-18732,-18782,-18832,-18882,-18933,-18983,-19033,-19083,-19133,-19183,-19233,-19284,-19334,-19384,-19434,-19484,-19534,-19584,-19634,-19685,-19735,-19785,-19835,-19885,-19935,-19985,-20035,-20085,-20136,-20186,-20236,-20286,-20336,-20386,-20436,-20486,-20537,-20587,-20637,-20687,-20737,-20787,-20837,-20887,-20937,-20987,-21038,-21088,-21138,-21188,-21238,-21288,-21338,-21388,-21438,-21488,-21539,-21589,-21639,-21689,-21739,-21789,-21839,-21889,-21939,-21989,-22039,-22090,-22140,-22190,-22240,-22290,-22340,-22390,-22440,-22490,-22540,-22590,-22640,-22691,-22741,-22791,-22841,-22891,-22941,-22991,-23041,-23091,-23141,-23191,-23241,-23291,-23341,-23392,-23442,-23492,-23542,-23592,-23642,-23692,-23742,-23792,-23842,-23892,-23942,-23992,-24042,-24092,-24142,-24192,-24243,-24293,-24343,-24393,-24443,-24493,-24543,-24593,-24643,-24693,-24743,-24793,-24843,-24893,-24943,-24993,-25043,-25093,-25143,-25193,-25243,-25293,-25343,-25393,-25443,-25494,-25544,-25594,-25644,-25694,-25744,-25794,-25844,-25894,-25944,-25994,-26044,-26094,-26144,-26194,-26244,-26294,-26344,-26394,-26444,-26494,-26544,-26594,-26644,-26694,-26744,-26794,-26844,-26894,-26944,-26994,-27044,-27094,-27144,-27194,-27244,-27294,-27344,-27394,-27444,-27494,-27544,-27594,-27644,-27694,-27744,-27794,-27844,-27894,-27944,-27994,-28044,-28094,-28144,-28194,-28244,-28294,-28343,-28393,-28443,-28493,-28543,-28593,-28643,-28693,-28743,-28793,-28843,-28893,-28943,-28993,-29043,-29093,-29143,-29193,-29243,-29293,-29343,-29393,-29443,-29493,-29542,-29592,-29642,-29692,-29742,-29792,-29842,-29892,-29942,-29992,-30042,-30092,-30142,-30192,-30242,-30292,-30341,-30391,-30441,-30491,-30541,-30591,-30641,-30691,-30741,-30791,-30841,-30891,-30941,-30990,-31040,-31090,-31140,-31190,-31240,-31290,-31340,-31390,-31440,-31489,-31539,-31589,-31639,-31689,-31739,-31789,-31839,-31889,-31939,-31988,-32038,-32088,-32138,-32188,-32238,-32288,-32338,-32388,-32437,-32487,-32537,-32587,-32637,-32687,-32737,-32787,-32836,-32886,-32936,-32986,-33036,-33086,-33136,-33185,-33235,-33285,-33335,-33385,-33435,-33485,-33534,-33584,-33634,-33684,-33734,-33784,-33834,-33883,-33933,-33983,-34033,-34083,-34133,-34182,-34232,-34282,-34332,-34382,-34432,-34481,-34531,-34581,-34631,-34681,-34731,-34780,-34830,-34880,-34930,-34980,-35029,-35079,-35129,-35179,-35229,-35279,-35328,-35378,-35428,-35478,-35528,-35577,-35627,-35677,-35727,-35777,-35826,-35876,-35926,-35976,-36026,-36075,-36125,-36175,-36225,-36274,-36324,-36374,-36424,-36474,-36523,-36573,-36623,-36673,-36722,-36772,-36822,-36872,-36921,-36971,-37021,-37071,-37121,-37170,-37220,-37270,-37320,-37369,-37419,-37469,-37519,-37568,-37618,-37668,-37718,-37767,-37817,-37867,-37916,-37966,-38016,-38066,-38115,-38165,-38215,-38265,-38314,-38364,-38414,-38464,-38513,-38563,-38613,-38662,-38712,-38762,-38812,-38861,-38911,-38961,-39010,-39060,-39110,-39159,-39209,-39259,-39309,-39358,-39408,-39458,-39507,-39557,-39607,-39656,-39706,-39756,-39805,-39855,-39905,-39955,-40004,-40054,-40104,-40153,-40203,-40253,-40302,-40352,-40402,-40451,-40501,-40551,-40600,-40650,-40700,-40749,-40799,-40848,-40898,-40948,-40997,-41047,-41097,-41146,-41196,-41246,-41295,-41345,-41395,-41444,-41494,-41543,-41593,-41643,-41692,-41742,-41792,-41841,-41891,-41940,-41990,-42040,-42089,-42139,-42189,-42238,-42288,-42337,-42387,-42437,-42486,-42536,-42585,-42635,-42685,-42734,-42784,-42833,-42883,-42932,-42982,-43032,-43081,-43131,-43180,-43230,-43280,-43329,-43379,-43428,-43478,-43527,-43577,-43627,-43676,-43726,-43775,-43825,-43874,-43924,-43973,-44023,-44073,-44122,-44172,-44221,-44271,-44320,-44370,-44419,-44469,-44518,-44568,-44618,-44667,-44717,-44766,-44816,-44865,-44915,-44964,-45014,-45063,-45113,-45162,-45212,-45261,-45311,-45360,-45410,-45459,-45509,-45558,-45608,-45657,-45707,-45756,-45806,-45855,-45905,-45954,-46004,-46053,-46103,-46152,-46202,-46251,-46301,-46350,-46400,-46449,-46499,-46548,-46597,-46647,-46696,-46746,-46795,-46845,-46894,-46944,-46993,-47043,-47092,-47141,-47191,-47240,-47290,-47339,-47389,-47438,-47488,-47537,-47586,-47636,-47685,-47735,-47784,-47834,-47883,-47932,-47982,-48031,-48081,-48130,-48179,-48229,-48278,-48328,-48377,-48426,-48476,-48525,-48575,-48624,-48673,-48723,-48772,-48822,-48871,-48920,-48970,-49019,-49069,-49118,-49167,-49217,-49266,-49315,-49365,-49414,-49463,-49513,-49562,-49612,-49661,-49710,-49760,-49809,-49858,-49908,-49957,-50006,-50056,-50105,-50154,-50204,-50253,-50302,-50352,-50401,-50450,-50500,-50549,-50598,-50648,-50697,-50746,-50796,-50845,-50894,-50944,-50993,-51042,-51091,-51141,-51190,-51239,-51289,-51338,-51387,-51437,-51486,-51535,-51584,-51634,-51683,-51732,-51781,-51831,-51880,-51929,-51979,-52028,-52077,-52126,-52176,-52225,-52274,-52323,-52373,-52422,-52471,-52520,-52570,-52619,-52668,-52717,-52767,-52816,-52865,-52914,-52964,-53013,-53062,-53111,-53160,-53210,-53259,-53308,-53357,-53407,-53456,-53505,-53554,-53603,-53653,-53702,-53751,-53800,-53849,-53899,-53948,-53997,-54046,-54095,-54144,-54194,-54243,-54292,-54341,-54390,-54440,-54489,-54538,-54587,-54636,-54685,-54735,-54784,-54833,-54882,-54931,-54980,-55029,-55079,-55128,-55177,-55226,-55275,-55324,-55373,-55423,-55472,-55521,-55570,-55619,-55668,-55717,-55766,-55815,-55865,-55914,-55963,-56012,-56061,-56110,-56159,-56208,-56257,-56307,-56356,-56405,-56454,-56503,-56552,-56601,-56650,-56699,-56748,-56797,-56846,-56895,-56945,-56994,-57043,-57092,-57141,-57190,-57239,-57288,-57337,-57386,-57435,-57484,-57533,-57582,-57631,-57680,-57729,-57778,-57827,-57876,-57925,-57974,-58023,-58072,-58121,-58170,-58220,-58269,-58318,-58367,-58416,-58465,-58514,-58563,-58612,-58661,-58710,-58758,-58807,-58856,-58905,-58954,-59003,-59052,-59101,-59150,-59199,-59248,-59297,-59346,-59395,-59444,-59493,-59542,-59591,-59640,-59689,-59738,-59787,-59836,-59885,-59934,-59982,-60031,-60080,-60129,-60178,-60227,-60276,-60325,-60374,-60423,-60472,-60521,-60569,-60618,-60667,-60716,-60765,-60814,-60863,-60912,-60961,-61010,-61058,-61107,-61156,-61205,-61254,-61303,-61352,-61401,-61449,-61498,-61547,-61596,-61645,-61694,-61743,-61791,-61840,-61889,-61938,-61987,-62036,-62084,-62133,-62182,-62231,-62280,-62329,-62377,-62426,-62475,-62524,-62573,-62622,-62670,-62719,-62768,-62817,-62866,-62914,-62963,-63012,-63061,-63110,-63158,-63207,-63256,-63305,-63353,-63402,-63451,-63500,-63549,-63597,-63646,-63695,-63744,-63792,-63841,-63890,-63939,-63987,-64036,-64085,-64134,-64182,-64231,-64280,-64328,-64377,-64426,-64475,-64523,-64572,-64621,-64670,-64718,-64767,-64816,-64864,-64913,-64962,-65010,-65059,-65108,-65157,-65205,-65254,-65303,-65351,-65400,-65449,-65497,-65546,-65595,-65643,-65692,-65741,-65789,-65838,-65887,-65935,-65984,-66033,-66081,-66130,-66178,-66227,-66276,-66324,-66373,-66422,-66470,-66519,-66567,-66616,-66665,-66713,-66762,-66811,-66859,-66908,-66956,-67005,-67054,-67102,-67151,-67199,-67248,-67296,-67345,-67394,-67442,-67491,-67539,-67588,-67636,-67685,-67734,-67782,-67831,-67879,-67928,-67976,-68025,-68073,-68122,-68170,-68219,-68268,-68316,-68365,-68413,-68462,-68510,-68559,-68607,-68656,-68704,-68753,-68801,-68850,-68898,-68947,-68995,-69044,-69092,-69141,-69189,-69238,-69286,-69335,-69383,-69432,-69480,-69529,-69577,-69625,-69674,-69722,-69771,-69819,-69868,-69916,-69965,-70013,-70061,-70110,-70158,-70207,-70255,-70304,-70352,-70400,-70449,-70497,-70546,-70594,-70643,-70691,-70739,-70788,-70836,-70885,-70933,-70981,-71030,-71078,-71126,-71175,-71223,-71272,-71320,-71368,-71417,-71465,-71513,-71562,-71610,-71658,-71707,-71755,-71804,-71852,-71900,-71949,-71997,-72045,-72094,-72142,-72190,-72238,-72287,-72335,-72383,-72432,-72480,-72528,-72577,-72625,-72673,-72722,-72770,-72818,-72866,-72915,-72963,-73011,-73060,-73108,-73156,-73204,-73253,-73301,-73349,-73397,-73446,-73494,-73542,-73590,-73639,-73687,-73735,-73783,-73832,-73880,-73928,-73976,-74024,-74073,-74121,-74169,-74217,-74266,-74314,-74362,-74410,-74458,-74507,-74555,-74603,-74651,-74699,-74747,-74796,-74844,-74892,-74940,-74988,-75036,-75085,-75133,-75181,-75229,-75277,-75325,-75374,-75422,-75470,-75518,-75566,-75614,-75662,-75710,-75759,-75807,-75855,-75903,-75951,-75999,-76047,-76095,-76143,-76192,-76240,-76288,-76336,-76384,-76432,-76480,-76528,-76576,-76624,-76672,-76720,-76769,-76817,-76865,-76913,-76961,-77009,-77057,-77105,-77153,-77201,-77249,-77297,-77345,-77393,-77441,-77489,-77537,-77585,-77633,-77681,-77729,-77777,-77825,-77873,-77921,-77969,-78017,-78065,-78113,-78161,-78209,-78257,-78305,-78353,-78401,-78449,-78497,-78545,-78593,-78641,-78689,-78737,-78785,-78833,-78880,-78928,-78976,-79024,-79072,-79120,-79168,-79216,-79264,-79312,-79360,-79408,-79456,-79503,-79551,-79599,-79647,-79695,-79743,-79791,-79839,-79886,-79934,-79982,-80030,-80078,-80126,-80174,-80222,-80269,-80317,-80365,-80413,-80461,-80509,-80556,-80604,-80652,-80700,-80748,-80796,-80843,-80891,-80939,-80987,-81035,-81082,-81130,-81178,-81226,-81274,-81321,-81369,-81417,-81465,-81513,-81560,-81608,-81656,-81704,-81751,-81799,-81847,-81895,-81942,-81990,-82038,-82086,-82133,-82181,-82229,-82277,-82324,-82372,-82420,-82467,-82515,-82563,-82611,-82658,-82706,-82754,-82801,-82849,-82897,-82944,-82992,-83040,-83087,-83135,-83183,-83230,-83278,-83326,-83373,-83421,-83469,-83516,-83564,-83612,-83659,-83707,-83755,-83802,-83850,-83897,-83945,-83993,-84040,-84088,-84135,-84183,-84231,-84278,-84326,-84373,-84421,-84469,-84516,-84564,-84611,-84659,-84707,-84754,-84802,-84849,-84897,-84944,-84992,-85039,-85087,-85135,-85182,-85230,-85277,-85325,-85372,-85420,-85467,-85515,-85562,-85610,-85657,-85705,-85752,-85800,-85847,-85895,-85942,-85990,-86037,-86085,-86132,-86180,-86227,-86275,-86322,-86370,-86417,-86464,-86512,-86559,-86607,-86654,-86702,-86749,-86797,-86844,-86891,-86939,-86986,-87034,-87081,-87128,-87176,-87223,-87271,-87318,-87365,-87413,-87460,-87508,-87555,-87602,-87650,-87697,-87744,-87792,-87839,-87887,-87934,-87981,-88029,-88076,-88123,-88171,-88218,-88265,-88313,-88360,-88407,-88455,-88502,-88549,-88597,-88644,-88691,-88738,-88786,-88833,-88880,-88928,-88975,-89022,-89069,-89117,-89164,-89211,-89259,-89306,-89353,-89400,-89448,-89495,-89542,-89589,-89637,-89684,-89731,-89778,-89825,-89873,-89920,-89967,-90014,-90062,-90109,-90156,-90203,-90250,-90298,-90345,-90392,-90439,-90486,-90533,-90581,-90628,-90675,-90722,-90769,-90816,-90864,-90911,-90958,-91005,-91052,-91099,-91146,-91194,-91241,-91288,-91335,-91382,-91429,-91476,-91523,-91570,-91618,-91665,-91712,-91759,-91806,-91853,-91900,-91947,-91994,-92041,-92088,-92135,-92182,-92229,-92277,-92324,-92371,-92418,-92465,-92512,-92559,-92606,-92653,-92700,-92747,-92794,-92841,-92888,-92935,-92982,-93029,-93076,-93123,-93170,-93217,-93264,-93311,-93358,-93405,-93452,-93499,-93546,-93593,-93639,-93686,-93733,-93780,-93827,-93874,-93921,-93968,-94015,-94062,-94109,-94156,-94203,-94250,-94296,-94343,-94390,-94437,-94484,-94531,-94578,-94625,-94672,-94718,-94765,-94812,-94859,-94906,-94953,-95000,-95046,-95093,-95140,-95187,-95234,-95281,-95327,-95374,-95421,-95468,-95515,-95561,-95608,-95655,-95702,-95749,-95795,-95842,-95889,-95936,-95983,-96029,-96076,-96123,-96170,-96216,-96263,-96310,-96357,-96403,-96450,-96497,-96544,-96590,-96637,-96684,-96731,-96777,-96824,-96871,-96917,-96964,-97011,-97057,-97104,-97151,-97198,-97244,-97291,-97338,-97384,-97431,-97478,-97524,-97571,-97618,-97664,-97711,-97757,-97804,-97851,-97897,-97944,-97991,-98037,-98084,-98130,-98177,-98224,-98270,-98317,-98363,-98410,-98457,-98503,-98550,-98596,-98643,-98690,-98736,-98783,-98829,-98876,-98922,-98969,-99015,-99062,-99109,-99155,-99202,-99248,-99295,-99341,-99388,-99434,-99481,-99527,-99574,-99620,-99667,-99713,-99760,-99806,-99853,-99899,-99946,-99992,-100038,-100085,-100131,-100178,-100224,-100271,-100317,-100364,-100410,-100456,-100503,-100549,-100596,-100642,-100689,-100735,-100781,-100828,-100874,-100921,-100967,-101013,-101060,-101106,-101152,-101199,-101245,-101292,-101338,-101384,-101431,-101477,-101523,-101570,-101616,-101662,-101709,-101755,-101801,-101848,-101894,-101940,-101987,-102033,-102079,-102125,-102172,-102218,-102264,-102311,-102357,-102403,-102449,-102496,-102542,-102588,-102634,-102681,-102727,-102773,-102819,-102866,-102912,-102958,-103004,-103051,-103097,-103143,-103189,-103235,-103282,-103328,-103374,-103420,-103466,-103513,-103559,-103605,-103651,-103697,-103743,-103790,-103836,-103882,-103928,-103974,-104020,-104066,-104113,-104159,-104205,-104251,-104297,-104343,-104389,-104435,-104482,-104528,-104574,-104620,-104666,-104712,-104758,-104804,-104850,-104896,-104942,-104988,-105034,-105081,-105127,-105173,-105219,-105265,-105311,-105357,-105403,-105449,-105495,-105541,-105587,-105633,-105679,-105725,-105771,-105817,-105863,-105909,-105955,-106001,-106047,-106093,-106139,-106185,-106231,-106277,-106322,-106368,-106414,-106460,-106506,-106552,-106598,-106644,-106690,-106736,-106782,-106828,-106874,-106919,-106965,-107011,-107057,-107103,-107149,-107195,-107241,-107286,-107332,-107378,-107424,-107470,-107516,-107562,-107607,-107653,-107699,-107745,-107791,-107837,-107882,-107928,-107974,-108020,-108066,-108111,-108157,-108203,-108249,-108294,-108340,-108386,-108432,-108478,-108523,-108569,-108615,-108661,-108706,-108752,-108798,-108844,-108889,-108935,-108981,-109026,-109072,-109118,-109164,-109209,-109255,-109301,-109346,-109392,-109438,-109483,-109529,-109575,-109620,-109666,-109712,-109757,-109803,-109849,-109894,-109940,-109985,-110031,-110077,-110122,-110168,-110214,-110259,-110305,-110350,-110396,-110442,-110487,-110533,-110578,-110624,-110669,-110715,-110761,-110806,-110852,-110897,-110943,-110988,-111034,-111079,-111125,-111170,-111216,-111261,-111307,-111352,-111398,-111443,-111489,-111534,-111580,-111625,-111671,-111716,-111762,-111807,-111853,-111898,-111944,-111989,-112035,-112080,-112125,-112171,-112216,-112262,-112307,-112353,-112398,-112443,-112489,-112534,-112580,-112625,-112670,-112716,-112761,-112807,-112852,-112897,-112943,-112988,-113033,-113079,-113124,-113169,-113215,-113260,-113305,-113351,-113396,-113441,-113487,-113532,-113577,-113623,-113668,-113713,-113758,-113804,-113849,-113894,-113940,-113985,-114030,-114075,-114121,-114166,-114211,-114256,-114302,-114347,-114392,-114437,-114482,-114528,-114573,-114618,-114663,-114709,-114754,-114799,-114844,-114889,-114934,-114980,-115025,-115070,-115115,-115160,-115205,-115251,-115296,-115341,-115386,-115431,-115476,-115521,-115566,-115612,-115657,-115702,-115747,-115792,-115837,-115882,-115927,-115972,-116017,-116063,-116108,-116153,-116198,-116243,-116288,-116333,-116378,-116423,-116468,-116513,-116558,-116603,-116648,-116693,-116738,-116783,-116828,-116873,-116918,-116963,-117008,-117053,-117098,-117143,-117188,-117233,-117278,-117323,-117368,-117413,-117458,-117503,-117548,-117592,-117637,-117682,-117727,-117772,-117817,-117862,-117907,-117952,-117997,-118041,-118086,-118131,-118176,-118221,-118266,-118311,-118356,-118400,-118445,-118490,-118535,-118580,-118625,-118669,-118714,-118759,-118804,-118849,-118893,-118938,-118983,-119028,-119073,-119117,-119162,-119207,-119252,-119296,-119341,-119386,-119431,-119475,-119520,-119565,-119610,-119654,-119699,-119744,-119789,-119833,-119878,-119923,-119967,-120012,-120057,-120101,-120146,-120191,-120235,-120280,-120325,-120369,-120414,-120459,-120503,-120548,-120593,-120637,-120682,-120726,-120771,-120816,-120860,-120905,-120949,-120994,-121039,-121083,-121128,-121172,-121217,-121262,-121306,-121351,-121395,-121440,-121484,-121529,-121573,-121618,-121662,-121707,-121751,-121796,-121841,-121885,-121930,-121974,-122018,-122063,-122107,-122152,-122196,-122241,-122285,-122330,-122374,-122419,-122463,-122508,-122552,-122596,-122641,-122685,-122730,-122774,-122819,-122863,-122907,-122952,-122996,-123041,-123085,-123129,-123174,-123218,-123262,-123307,-123351,-123395,-123440,-123484,-123528,-123573,-123617,-123661,-123706,-123750,-123794,-123839,-123883,-123927,-123972,-124016,-124060,-124104,-124149,-124193,-124237,-124282,-124326,-124370,-124414,-124459,-124503,-124547,-124591,-124635,-124680,-124724,-124768,-124812,-124856,-124901,-124945,-124989,-125033,-125077,-125122,-125166,-125210,-125254,-125298,-125342,-125387,-125431,-125475,-125519,-125563,-125607,-125651,-125695,-125740,-125784,-125828,-125872,-125916,-125960,-126004,-126048,-126092,-126136,-126180,-126224,-126268,-126313,-126357,-126401,-126445,-126489,-126533,-126577,-126621,-126665,-126709,-126753,-126797,-126841,-126885,-126929,-126973,-127017,-127061,-127105,-127149,-127192,-127236,-127280,-127324,-127368,-127412,-127456,-127500,-127544,-127588,-127632,-127676,-127720,-127763,-127807,-127851,-127895,-127939,-127983,-128027,-128071,-128114,-128158,-128202,-128246,-128290,-128334,-128377,-128421,-128465,-128509,-128553,-128597,-128640,-128684,-128728,-128772,-128815,-128859,-128903,-128947,-128991,-129034,-129078,-129122,-129166,-129209,-129253,-129297,-129340,-129384,-129428,-129472,-129515,-129559,-129603,-129646,-129690,-129734,-129777,-129821,-129865,-129908,-129952,-129996,-130039,-130083,-130127,-130170,-130214,-130258,-130301,-130345,-130388,-130432,-130476,-130519,-130563,-130606,-130650,-130694,-130737,-130781,-130824,-130868,-130911,-130955,-130998,-131042,-131086,-131129,-131173,-131216,-131260,-131303,-131347,-131390,-131434,-131477,-131521,-131564,-131608,-131651,-131694,-131738,-131781,-131825,-131868,-131912,-131955,-131999,-132042,-132085,-132129,-132172,-132216,-132259,-132302,-132346,-132389,-132433,-132476,-132519,-132563,-132606,-132649,-132693,-132736,-132779,-132823,-132866,-132909,-132953,-132996,-133039,-133083,-133126,-133169,-133213,-133256,-133299,-133342,-133386,-133429,-133472,-133516,-133559,-133602,-133645,-133689,-133732,-133775,-133818,-133861,-133905,-133948,-133991,-134034,-134077,-134121,-134164,-134207,-134250,-134293,-134337,-134380,-134423,-134466,-134509,-134552,-134595,-134639,-134682,-134725,-134768,-134811,-134854,-134897,-134940,-134983,-135027,-135070,-135113,-135156,-135199,-135242,-135285,-135328,-135371,-135414,-135457,-135500,-135543,-135586,-135629,-135672,-135715,-135758,-135801,-135844,-135887,-135930,-135973,-136016,-136059,-136102,-136145,-136188,-136231,-136274,-136317,-136360,-136403,-136446,-136489,-136531,-136574,-136617,-136660,-136703,-136746,-136789,-136832,-136875,-136917,-136960,-137003,-137046,-137089,-137132,-137175,-137217,-137260,-137303,-137346,-137389,-137431,-137474,-137517,-137560,-137603,-137645,-137688,-137731,-137774,-137816,-137859,-137902,-137945,-137987,-138030,-138073,-138116,-138158,-138201,-138244,-138287,-138329,-138372,-138415,-138457,-138500,-138543,-138585,-138628,-138671,-138713,-138756,-138799,-138841,-138884,-138926,-138969,-139012,-139054,-139097,-139140,-139182,-139225,-139267,-139310,-139352,-139395,-139438,-139480,-139523,-139565,-139608,-139650,-139693,-139735,-139778,-139820,-139863,-139906,-139948,-139991,-140033,-140076,-140118,-140160,-140203,-140245,-140288,-140330,-140373,-140415,-140458,-140500,-140543,-140585,-140627,-140670,-140712,-140755,-140797,-140839,-140882,-140924,-140967,-141009,-141051,-141094,-141136,-141178,-141221,-141263,-141305,-141348,-141390,-141432,-141475,-141517,-141559,-141602,-141644,-141686,-141729,-141771,-141813,-141855,-141898,-141940,-141982,-142024,-142067,-142109,-142151,-142193,-142236,-142278,-142320,-142362,-142404,-142447,-142489,-142531,-142573,-142615,-142658,-142700,-142742,-142784,-142826,-142868,-142911,-142953,-142995,-143037,-143079,-143121,-143163,-143205,-143247,-143290,-143332,-143374,-143416,-143458,-143500,-143542,-143584,-143626,-143668,-143710,-143752,-143794,-143836,-143878,-143920,-143962,-144004,-144046,-144088,-144130,-144172,-144214,-144256,-144298,-144340,-144382,-144424,-144466,-144508,-144550,-144592,-144634,-144676,-144718,-144760,-144801,-144843,-144885,-144927,-144969,-145011,-145053,-145095,-145136,-145178,-145220,-145262,-145304,-145346,-145388,-145429,-145471,-145513,-145555,-145597,-145638,-145680,-145722,-145764,-145806,-145847,-145889,-145931,-145973,-146014,-146056,-146098,-146140,-146181,-146223,-146265,-146306,-146348,-146390,-146432,-146473,-146515,-146557,-146598,-146640,-146682,-146723,-146765,-146807,-146848,-146890,-146931,-146973,-147015,-147056,-147098,-147140,-147181,-147223,-147264,-147306,-147347,-147389,-147431,-147472,-147514,-147555,-147597,-147638,-147680,-147721,-147763,-147804,-147846,-147887,-147929,-147970,-148012,-148053,-148095,-148136,-148178,-148219,-148261,-148302,-148344,-148385,-148427,-148468,-148509,-148551,-148592,-148634,-148675,-148716,-148758,-148799,-148841,-148882,-148923,-148965,-149006,-149047,-149089,-149130,-149171,-149213,-149254,-149295,-149337,-149378,-149419,-149461,-149502,-149543,-149584,-149626,-149667,-149708,-149750,-149791,-149832,-149873,-149915,-149956,-149997,-150038,-150079,-150121,-150162,-150203,-150244,-150285,-150327,-150368,-150409,-150450,-150491,-150532,-150574,-150615,-150656,-150697,-150738,-150779,-150820,-150861,-150903,-150944,-150985,-151026,-151067,-151108,-151149,-151190,-151231,-151272,-151313,-151354,-151395,-151436,-151477,-151518,-151559,-151600,-151641,-151682,-151723,-151764,-151805,-151846,-151887,-151928,-151969,-152010,-152051,-152092,-152133,-152174,-152215,-152256,-152297,-152338,-152379,-152420,-152460,-152501,-152542,-152583,-152624,-152665,-152706,-152747,-152787,-152828,-152869,-152910,-152951,-152992,-153032,-153073,-153114,-153155,-153196,-153236,-153277,-153318,-153359,-153399,-153440,-153481,-153522,-153562,-153603,-153644,-153685,-153725,-153766,-153807,-153847,-153888,-153929,-153969,-154010,-154051,-154092,-154132,-154173,-154213,-154254,-154295,-154335,-154376,-154417,-154457,-154498,-154538,-154579,-154620,-154660,-154701,-154741,-154782,-154823,-154863,-154904,-154944,-154985,-155025,-155066,-155106,-155147,-155187,-155228,-155268,-155309,-155349,-155390,-155430,-155471,-155511,-155552,-155592,-155633,-155673,-155714,-155754,-155794,-155835,-155875,-155916,-155956,-155996,-156037,-156077,-156118,-156158,-156198,-156239,-156279,-156319,-156360,-156400,-156440,-156481,-156521,-156561,-156602,-156642,-156682,-156723,-156763,-156803,-156844,-156884,-156924,-156964,-157005,-157045,-157085,-157125,-157166,-157206,-157246,-157286,-157326,-157367,-157407,-157447,-157487,-157527,-157568,-157608,-157648,-157688,-157728,-157768,-157808,-157849,-157889,-157929,-157969,-158009,-158049,-158089,-158129,-158169,-158210,-158250,-158290,-158330,-158370,-158410,-158450,-158490,-158530,-158570,-158610,-158650,-158690,-158730,-158770,-158810,-158850,-158890,-158930,-158970,-159010,-159050,-159090,-159130,-159170,-159210,-159250,-159290,-159329,-159369,-159409,-159449,-159489,-159529,-159569,-159609,-159649,-159688,-159728,-159768,-159808,-159848,-159888,-159928,-159967,-160007,-160047,-160087,-160127,-160166,-160206,-160246,-160286,-160326,-160365,-160405,-160445,-160485,-160524,-160564,-160604,-160643,-160683,-160723,-160763,-160802,-160842,-160882,-160921,-160961,-161001,-161040,-161080,-161120,-161159,-161199,-161239,-161278,-161318,-161358,-161397,-161437,-161476,-161516,-161556,-161595,-161635,-161674,-161714,-161753,-161793,-161832,-161872,-161912,-161951,-161991,-162030,-162070,-162109,-162149,-162188,-162228,-162267,-162307,-162346,-162385,-162425,-162464,-162504,-162543,-162583,-162622,-162662,-162701,-162740,-162780,-162819,-162859,-162898,-162937,-162977,-163016,-163055,-163095,-163134,-163173,-163213,-163252,-163291,-163331,-163370,-163409,-163449,-163488,-163527,-163567,-163606,-163645,-163684,-163724,-163763,-163802,-163841,-163881,-163920,-163959,-163998,-164038,-164077,-164116,-164155,-164194,-164233,-164273,-164312,-164351,-164390,-164429,-164468,-164508,-164547,-164586,-164625,-164664,-164703,-164742,-164781,-164820,-164860,-164899,-164938,-164977,-165016,-165055,-165094,-165133,-165172,-165211,-165250,-165289,-165328,-165367,-165406,-165445,-165484,-165523,-165562,-165601,-165640,-165679,-165718,-165757,-165796,-165835,-165874,-165913,-165951,-165990,-166029,-166068,-166107,-166146,-166185,-166224,-166263,-166301,-166340,-166379,-166418,-166457,-166496,-166534,-166573,-166612,-166651,-166690,-166728,-166767,-166806,-166845,-166884,-166922,-166961,-167000,-167039,-167077,-167116,-167155,-167193,-167232,-167271,-167310,-167348,-167387,-167426,-167464,-167503,-167542,-167580,-167619,-167658,-167696,-167735,-167773,-167812,-167851,-167889,-167928,-167967,-168005,-168044,-168082,-168121,-168159,-168198,-168237,-168275,-168314,-168352,-168391,-168429,-168468,-168506,-168545,-168583,-168622,-168660,-168699,-168737,-168776,-168814,-168852,-168891,-168929,-168968,-169006,-169045,-169083,-169121,-169160,-169198,-169237,-169275,-169313,-169352,-169390,-169429,-169467,-169505,-169544,-169582,-169620,-169659,-169697,-169735,-169773,-169812,-169850,-169888,-169927,-169965,-170003,-170041,-170080,-170118,-170156,-170194,-170233,-170271,-170309,-170347,-170385,-170424,-170462,-170500,-170538,-170576,-170615,-170653,-170691,-170729,-170767,-170805,-170843,-170882,-170920,-170958,-170996,-171034,-171072,-171110,-171148,-171186,-171224,-171262,-171300,-171338,-171377,-171415,-171453,-171491,-171529,-171567,-171605,-171643,-171681,-171719,-171757,-171795,-171833,-171870,-171908,-171946,-171984,-172022,-172060,-172098,-172136,-172174,-172212,-172250,-172288,-172325,-172363,-172401,-172439,-172477,-172515,-172553,-172590,-172628,-172666,-172704,-172742,-172780,-172817,-172855,-172893,-172931,-172968,-173006,-173044,-173082,-173120,-173157,-173195,-173233,-173270,-173308,-173346,-173384,-173421,-173459,-173497,-173534,-173572,-173610,-173647,-173685,-173723,-173760,-173798,-173836,-173873,-173911,-173948,-173986,-174024,-174061,-174099,-174136,-174174,-174211,-174249,-174287,-174324,-174362,-174399,-174437,-174474,-174512,-174549,-174587,-174624,-174662,-174699,-174737,-174774,-174812,-174849,-174886,-174924,-174961,-174999,-175036,-175074,-175111,-175148,-175186,-175223,-175261,-175298,-175335,-175373,-175410,-175447,-175485,-175522,-175559,-175597,-175634,-175671,-175709,-175746,-175783,-175821,-175858,-175895,-175932,-175970,-176007,-176044,-176081,-176119,-176156,-176193,-176230,-176267,-176305,-176342,-176379,-176416,-176453,-176491,-176528,-176565,-176602,-176639,-176676,-176713,-176751,-176788,-176825,-176862,-176899,-176936,-176973,-177010,-177047,-177084,-177122,-177159,-177196,-177233,-177270,-177307,-177344,-177381,-177418,-177455,-177492,-177529,-177566,-177603,-177640,-177677,-177714,-177751,-177787,-177824,-177861,-177898,-177935,-177972,-178009,-178046,-178083,-178120,-178157,-178193,-178230,-178267,-178304,-178341,-178378,-178414,-178451,-178488,-178525,-178562,-178599,-178635,-178672,-178709,-178746,-178782,-178819,-178856,-178893,-178929,-178966,-179003,-179040,-179076,-179113,-179150,-179186,-179223,-179260,-179296,-179333,-179370,-179406,-179443,-179480,-179516,-179553,-179590,-179626,-179663,-179699,-179736,-179773,-179809,-179846,-179882,-179919,-179955,-179992,-180028,-180065,-180102,-180138,-180175,-180211,-180248,-180284,-180321,-180357,-180394,-180430,-180466,-180503,-180539,-180576,-180612,-180649,-180685,-180722,-180758,-180794,-180831,-180867,-180903,-180940,-180976,-181013,-181049,-181085,-181122,-181158,-181194,-181231,-181267,-181303,-181340,-181376,-181412,-181448,-181485,-181521,-181557,-181593,-181630,-181666,-181702,-181738,-181775,-181811,-181847,-181883,-181919,-181956,-181992,-182028,-182064,-182100,-182136,-182173,-182209,-182245,-182281,-182317,-182353,-182389,-182425,-182462,-182498,-182534,-182570,-182606,-182642,-182678,-182714,-182750,-182786,-182822,-182858,-182894,-182930,-182966,-183002,-183038,-183074,-183110,-183146,-183182,-183218,-183254,-183290,-183326,-183362,-183398,-183434,-183469,-183505,-183541,-183577,-183613,-183649,-183685,-183721,-183756,-183792,-183828,-183864,-183900,-183936,-183971,-184007,-184043,-184079,-184115,-184150,-184186,-184222,-184258,-184293,-184329,-184365,-184401,-184436,-184472,-184508,-184544,-184579,-184615,-184651,-184686,-184722,-184758,-184793,-184829,-184865,-184900,-184936,-184971,-185007,-185043,-185078,-185114,-185149,-185185,-185221,-185256,-185292,-185327,-185363,-185398,-185434,-185469,-185505,-185540,-185576,-185611,-185647,-185682,-185718,-185753,-185789,-185824,-185860,-185895,-185931,-185966,-186001,-186037,-186072,-186108,-186143,-186178,-186214,-186249,-186285,-186320,-186355,-186391,-186426,-186461,-186497,-186532,-186567,-186603,-186638,-186673,-186709,-186744,-186779,-186814,-186850,-186885,-186920,-186955,-186991,-187026,-187061,-187096,-187131,-187167,-187202,-187237,-187272,-187307,-187342,-187378,-187413,-187448,-187483,-187518,-187553,-187588,-187624,-187659,-187694,-187729,-187764,-187799,-187834,-187869,-187904,-187939,-187974,-188009,-188044,-188079,-188114,-188149,-188184,-188219,-188254,-188289,-188324,-188359,-188394,-188429,-188464,-188499,-188534,-188569,-188604,-188639,-188674,-188708,-188743,-188778,-188813,-188848,-188883,-188918,-188953,-188987,-189022,-189057,-189092,-189127,-189161,-189196,-189231,-189266,-189301,-189335,-189370,-189405,-189440,-189474,-189509,-189544,-189579,-189613,-189648,-189683,-189717,-189752,-189787,-189821,-189856,-189891,-189925,-189960,-189995,-190029,-190064,-190098,-190133,-190168,-190202,-190237,-190271,-190306,-190341,-190375,-190410,-190444,-190479,-190513,-190548,-190582,-190617,-190651,-190686,-190720,-190755,-190789,-190824,-190858,-190893,-190927,-190962,-190996,-191030,-191065,-191099,-191134,-191168,-191202,-191237,-191271,-191306,-191340,-191374,-191409,-191443,-191477,-191512,-191546,-191580,-191615,-191649,-191683,-191717,-191752,-191786,-191820,-191855,-191889,-191923,-191957,-191991,-192026,-192060,-192094,-192128,-192163,-192197,-192231,-192265,-192299,-192333,-192368,-192402,-192436,-192470,-192504,-192538,-192572,-192606,-192640,-192675,-192709,-192743,-192777,-192811,-192845,-192879,-192913,-192947,-192981,-193015,-193049,-193083,-193117,-193151,-193185,-193219,-193253,-193287,-193321,-193355,-193389,-193423,-193457,-193491,-193524,-193558,-193592,-193626,-193660,-193694,-193728,-193762,-193795,-193829,-193863,-193897,-193931,-193965,-193998,-194032,-194066,-194100,-194134,-194167,-194201,-194235,-194269,-194302,-194336,-194370,-194404,-194437,-194471,-194505,-194538,-194572,-194606,-194639,-194673,-194707,-194740,-194774,-194808,-194841,-194875,-194909,-194942,-194976,-195009,-195043,-195077,-195110,-195144,-195177,-195211,-195244,-195278,-195311,-195345,-195378,-195412,-195445,-195479,-195512,-195546,-195579,-195613,-195646,-195680,-195713,-195747,-195780,-195814,-195847,-195880,-195914,-195947,-195981,-196014,-196047,-196081,-196114,-196147,-196181,-196214,-196247,-196281,-196314,-196347,-196381,-196414,-196447,-196480,-196514,-196547,-196580,-196614,-196647,-196680,-196713,-196746,-196780,-196813,-196846,-196879,-196912,-196946,-196979,-197012,-197045,-197078,-197111,-197145,-197178,-197211,-197244,-197277,-197310,-197343,-197376,-197409,-197442,-197475,-197509,-197542,-197575,-197608,-197641,-197674,-197707,-197740,-197773,-197806,-197839,-197872,-197905,-197938,-197971,-198003,-198036,-198069,-198102,-198135,-198168,-198201,-198234,-198267,-198300,-198333,-198365,-198398,-198431,-198464,-198497,-198530,-198562,-198595,-198628,-198661,-198694,-198726,-198759,-198792,-198825,-198857,-198890,-198923,-198956,-198988,-199021,-199054,-199087,-199119,-199152,-199185,-199217,-199250,-199283,-199315,-199348,-199381,-199413,-199446,-199478,-199511,-199544,-199576,-199609,-199641,-199674,-199707,-199739,-199772,-199804,-199837,-199869,-199902,-199934,-199967,-199999,-200032,-200064,-200097,-200129,-200162,-200194,-200227,-200259,-200291,-200324,-200356,-200389,-200421,-200453,-200486,-200518,-200551,-200583,-200615,-200648,-200680,-200712,-200745,-200777,-200809,-200842,-200874,-200906,-200939,-200971,-201003,-201035,-201068,-201100,-201132,-201164,-201197,-201229,-201261,-201293,-201325,-201358,-201390,-201422,-201454,-201486,-201518,-201551,-201583,-201615,-201647,-201679,-201711,-201743,-201775,-201807,-201840,-201872,-201904,-201936,-201968,-202000,-202032,-202064,-202096,-202128,-202160,-202192,-202224,-202256,-202288,-202320,-202352,-202384,-202416,-202448,-202480,-202511,-202543,-202575,-202607,-202639,-202671,-202703,-202735,-202767,-202798,-202830,-202862,-202894,-202926,-202958,-202989,-203021,-203053,-203085,-203117,-203148,-203180,-203212,-203244,-203275,-203307,-203339,-203371,-203402,-203434,-203466,-203497,-203529,-203561,-203592,-203624,-203656,-203687,-203719,-203751,-203782,-203814,-203845,-203877,-203909,-203940,-203972,-204003,-204035,-204066,-204098,-204130,-204161,-204193,-204224,-204256,-204287,-204319,-204350,-204382,-204413,-204445,-204476,-204507,-204539,-204570,-204602,-204633,-204665,-204696,-204727,-204759,-204790,-204822,-204853,-204884,-204916,-204947,-204978,-205010,-205041,-205072,-205104,-205135,-205166,-205197,-205229,-205260,-205291,-205323,-205354,-205385,-205416,-205447,-205479,-205510,-205541,-205572,-205603,-205635,-205666,-205697,-205728,-205759,-205790,-205822,-205853,-205884,-205915,-205946,-205977,-206008,-206039,-206070,-206101,-206132,-206164,-206195,-206226,-206257,-206288,-206319,-206350,-206381,-206412,-206443,-206474,-206505,-206536,-206566,-206597,-206628,-206659,-206690,-206721,-206752,-206783,-206814,-206845,-206876,-206906,-206937,-206968,-206999,-207030,-207061,-207091,-207122,-207153,-207184,-207215,-207245,-207276,-207307,-207338,-207369,-207399,-207430,-207461,-207491,-207522,-207553,-207584,-207614,-207645,-207676,-207706,-207737,-207768,-207798,-207829,-207860,-207890,-207921,-207951,-207982,-208013,-208043,-208074,-208104,-208135,-208165,-208196,-208227,-208257,-208288,-208318,-208349,-208379,-208410,-208440,-208471,-208501,-208532,-208562,-208592,-208623,-208653,-208684,-208714,-208745,-208775,-208805,-208836,-208866,-208896,-208927,-208957,-208988,-209018,-209048,-209079,-209109,-209139,-209169,-209200,-209230,-209260,-209291,-209321,-209351,-209381,-209412,-209442,-209472,-209502,-209533,-209563,-209593,-209623,-209653,-209683,-209714,-209744,-209774,-209804,-209834,-209864,-209894,-209925,-209955,-209985,-210015,-210045,-210075,-210105,-210135,-210165,-210195,-210225,-210255,-210285,-210315,-210345,-210375,-210405,-210435,-210465,-210495,-210525,-210555,-210585,-210615,-210645,-210675,-210705,-210735,-210764,-210794,-210824,-210854,-210884,-210914,-210944,-210973,-211003,-211033,-211063,-211093,-211123,-211152,-211182,-211212,-211242,-211271,-211301,-211331,-211361,-211390,-211420,-211450,-211480,-211509,-211539,-211569,-211598,-211628,-211658,-211687,-211717,-211747,-211776,-211806,-211835,-211865,-211895,-211924,-211954,-211983,-212013,-212042,-212072,-212102,-212131,-212161,-212190,-212220,-212249,-212279,-212308,-212338,-212367,-212397,-212426,-212455,-212485,-212514,-212544,-212573,-212603,-212632,-212661,-212691,-212720,-212750,-212779,-212808,-212838,-212867,-212896,-212926,-212955,-212984,-213014,-213043,-213072,-213101,-213131,-213160,-213189,-213218,-213248,-213277,-213306,-213335,-213365,-213394,-213423,-213452,-213481,-213510,-213540,-213569,-213598,-213627,-213656,-213685,-213714,-213744,-213773,-213802,-213831,-213860,-213889,-213918,-213947,-213976,-214005,-214034,-214063,-214092,-214121,-214150,-214179,-214208,-214237,-214266,-214295,-214324,-214353,-214382,-214411,-214440,-214469,-214497,-214526,-214555,-214584,-214613,-214642,-214671,-214700,-214728,-214757,-214786,-214815,-214844,-214872,-214901,-214930,-214959,-214988,-215016,-215045,-215074,-215103,-215131,-215160,-215189,-215217,-215246,-215275,-215303,-215332,-215361,-215389,-215418,-215447,-215475,-215504,-215533,-215561,-215590,-215618,-215647,-215676,-215704,-215733,-215761,-215790,-215818,-215847,-215875,-215904,-215932,-215961,-215989,-216018,-216046,-216075,-216103,-216132,-216160,-216189,-216217,-216245,-216274,-216302,-216331,-216359,-216387,-216416,-216444,-216472,-216501,-216529,-216557,-216586,-216614,-216642,-216671,-216699,-216727,-216756,-216784,-216812,-216840,-216869,-216897,-216925,-216953,-216981,-217010,-217038,-217066,-217094,-217122,-217151,-217179,-217207,-217235,-217263,-217291,-217319,-217347,-217376,-217404,-217432,-217460,-217488,-217516,-217544,-217572,-217600,-217628,-217656,-217684,-217712,-217740,-217768,-217796,-217824,-217852,-217880,-217908,-217936,-217964,-217992,-218020,-218048,-218075,-218103,-218131,-218159,-218187,-218215,-218243,-218270,-218298,-218326,-218354,-218382,-218410,-218437,-218465,-218493,-218521,-218548,-218576,-218604,-218632,-218659,-218687,-218715,-218743,-218770,-218798,-218826,-218853,-218881,-218909,-218936,-218964,-218992,-219019,-219047,-219074,-219102,-219130,-219157,-219185,-219212,-219240,-219267,-219295,-219323,-219350,-219378,-219405,-219433,-219460,-219488,-219515,-219543,-219570,-219597,-219625,-219652,-219680,-219707,-219735,-219762,-219789,-219817,-219844,-219872,-219899,-219926,-219954,-219981,-220008,-220036,-220063,-220090,-220118,-220145,-220172,-220199,-220227,-220254,-220281,-220308,-220336,-220363,-220390,-220417,-220445,-220472,-220499,-220526,-220553,-220580,-220608,-220635,-220662,-220689,-220716,-220743,-220770,-220797,-220825,-220852,-220879,-220906,-220933,-220960,-220987,-221014,-221041,-221068,-221095,-221122,-221149,-221176,-221203,-221230,-221257,-221284,-221311,-221338,-221365,-221392,-221418,-221445,-221472,-221499,-221526,-221553,-221580,-221607,-221633,-221660,-221687,-221714,-221741,-221768,-221794,-221821,-221848,-221875,-221902,-221928,-221955,-221982,-222009,-222035,-222062,-222089,-222115,-222142,-222169,-222195,-222222,-222249,-222275,-222302,-222329,-222355,-222382,-222409,-222435,-222462,-222488,-222515,-222541,-222568,-222595,-222621,-222648,-222674,-222701,-222727,-222754,-222780,-222807,-222833,-222860,-222886,-222913,-222939,-222965,-222992,-223018,-223045,-223071,-223098,-223124,-223150,-223177,-223203,-223229,-223256,-223282,-223308,-223335,-223361,-223387,-223414,-223440,-223466,-223492,-223519,-223545,-223571,-223598,-223624,-223650,-223676,-223702,-223729,-223755,-223781,-223807,-223833,-223859,-223886,-223912,-223938,-223964,-223990,-224016,-224042,-224068,-224095,-224121,-224147,-224173,-224199,-224225,-224251,-224277,-224303,-224329,-224355,-224381,-224407,-224433,-224459,-224485,-224511,-224537,-224563,-224589,-224614,-224640,-224666,-224692,-224718,-224744,-224770,-224796,-224822,-224847,-224873,-224899,-224925,-224951,-224977,-225002,-225028,-225054,-225080,-225105,-225131,-225157,-225183,-225208,-225234,-225260,-225286,-225311,-225337,-225363,-225388,-225414,-225440,-225465,-225491,-225516,-225542,-225568,-225593,-225619,-225645,-225670,-225696,-225721,-225747,-225772,-225798,-225823,-225849,-225874,-225900,-225925,-225951,-225976,-226002,-226027,-226053,-226078,-226104,-226129,-226155,-226180,-226205,-226231,-226256,-226282,-226307,-226332,-226358,-226383,-226408,-226434,-226459,-226484,-226510,-226535,-226560,-226585,-226611,-226636,-226661,-226687,-226712,-226737,-226762,-226787,-226813,-226838,-226863,-226888,-226913,-226939,-226964,-226989,-227014,-227039,-227064,-227089,-227114,-227140,-227165,-227190,-227215,-227240,-227265,-227290,-227315,-227340,-227365,-227390,-227415,-227440,-227465,-227490,-227515,-227540,-227565,-227590,-227615,-227640,-227665,-227690,-227715,-227739,-227764,-227789,-227814,-227839,-227864,-227889,-227913,-227938,-227963,-227988,-228013,-228038,-228062,-228087,-228112,-228137,-228161,-228186,-228211,-228236,-228260,-228285,-228310,-228334,-228359,-228384,-228408,-228433,-228458,-228482,-228507,-228532,-228556,-228581,-228606,-228630,-228655,-228679,-228704,-228728,-228753,-228778,-228802,-228827,-228851,-228876,-228900,-228925,-228949,-228974,-228998,-229023,-229047,-229071,-229096,-229120,-229145,-229169,-229193,-229218,-229242,-229267,-229291,-229315,-229340,-229364,-229388,-229413,-229437,-229461,-229486,-229510,-229534,-229559,-229583,-229607,-229631,-229656,-229680,-229704,-229728,-229752,-229777,-229801,-229825,-229849,-229873,-229897,-229922,-229946,-229970,-229994,-230018,-230042,-230066,-230090,-230115,-230139,-230163,-230187,-230211,-230235,-230259,-230283,-230307,-230331,-230355,-230379,-230403,-230427,-230451,-230475,-230499,-230523,-230547,-230570,-230594,-230618,-230642,-230666,-230690,-230714,-230738,-230761,-230785,-230809,-230833,-230857,-230881,-230904,-230928,-230952,-230976,-231000,-231023,-231047,-231071,-231095,-231118,-231142,-231166,-231189,-231213,-231237,-231260,-231284,-231308,-231331,-231355,-231379,-231402,-231426,-231449,-231473,-231497,-231520,-231544,-231567,-231591,-231614,-231638,-231662,-231685,-231709,-231732,-231756,-231779,-231803,-231826,-231849,-231873,-231896,-231920,-231943,-231967,-231990,-232013,-232037,-232060,-232084,-232107,-232130,-232154,-232177,-232200,-232224,-232247,-232270,-232294,-232317,-232340,-232363,-232387,-232410,-232433,-232456,-232480,-232503,-232526,-232549,-232573,-232596,-232619,-232642,-232665,-232688,-232712,-232735,-232758,-232781,-232804,-232827,-232850,-232873,-232896,-232919,-232943,-232966,-232989,-233012,-233035,-233058,-233081,-233104,-233127,-233150,-233173,-233196,-233219,-233242,-233264,-233287,-233310,-233333,-233356,-233379,-233402,-233425,-233448,-233471,-233493,-233516,-233539,-233562,-233585,-233608,-233630,-233653,-233676,-233699,-233721,-233744,-233767,-233790,-233812,-233835,-233858,-233881,-233903,-233926,-233949,-233971,-233994,-234017,-234039,-234062,-234085,-234107,-234130,-234152,-234175,-234198,-234220,-234243,-234265,-234288,-234310,-234333,-234355,-234378,-234400,-234423,-234445,-234468,-234490,-234513,-234535,-234558,-234580,-234603,-234625,-234648,-234670,-234692,-234715,-234737,-234759,-234782,-234804,-234827,-234849,-234871,-234893,-234916,-234938,-234960,-234983,-235005,-235027,-235049,-235072,-235094,-235116,-235138,-235161,-235183,-235205,-235227,-235249,-235272,-235294,-235316,-235338,-235360,-235382,-235404,-235427,-235449,-235471,-235493,-235515,-235537,-235559,-235581,-235603,-235625,-235647,-235669,-235691,-235713,-235735,-235757,-235779,-235801,-235823,-235845,-235867,-235889,-235911,-235933,-235955,-235977,-235998,-236020,-236042,-236064,-236086,-236108,-236130,-236151,-236173,-236195,-236217,-236239,-236260,-236282,-236304,-236326,-236347,-236369,-236391,-236413,-236434,-236456,-236478,-236499,-236521,-236543,-236564,-236586,-236608,-236629,-236651,-236673,-236694,-236716,-236737,-236759,-236781,-236802,-236824,-236845,-236867,-236888,-236910,-236931,-236953,-236974,-236996,-237017,-237039,-237060,-237082,-237103,-237125,-237146,-237167,-237189,-237210,-237232,-237253,-237274,-237296,-237317,-237338,-237360,-237381,-237402,-237424,-237445,-237466,-237488,-237509,-237530,-237551,-237573,-237594,-237615,-237636,-237658,-237679,-237700,-237721,-237742,-237764,-237785,-237806,-237827,-237848,-237869,-237890,-237912,-237933,-237954,-237975,-237996,-238017,-238038,-238059,-238080,-238101,-238122,-238143,-238164,-238185,-238206,-238227,-238248,-238269,-238290,-238311,-238332,-238353,-238374,-238395,-238416,-238436,-238457,-238478,-238499,-238520,-238541,-238562,-238582,-238603,-238624,-238645,-238666,-238687,-238707,-238728,-238749,-238770,-238790,-238811,-238832,-238852,-238873,-238894,-238915,-238935,-238956,-238977,-238997,-239018,-239039,-239059,-239080,-239100,-239121,-239142,-239162,-239183,-239203,-239224,-239244,-239265,-239286,-239306,-239327,-239347,-239368,-239388,-239409,-239429,-239449,-239470,-239490,-239511,-239531,-239552,-239572,-239592,-239613,-239633,-239654,-239674,-239694,-239715,-239735,-239755,-239776,-239796,-239816,-239837,-239857,-239877,-239897,-239918,-239938,-239958,-239978,-239999,-240019,-240039,-240059,-240079,-240100,-240120,-240140,-240160,-240180,-240200,-240220,-240241,-240261,-240281,-240301,-240321,-240341,-240361,-240381,-240401,-240421,-240441,-240461,-240481,-240501,-240521,-240541,-240561,-240581,-240601,-240621,-240641,-240661,-240681,-240701,-240721,-240741,-240761,-240780,-240800,-240820,-240840,-240860,-240880,-240900,-240919,-240939,-240959,-240979,-240999,-241018,-241038,-241058,-241078,-241097,-241117,-241137,-241156,-241176,-241196,-241216,-241235,-241255,-241275,-241294,-241314,-241333,-241353,-241373,-241392,-241412,-241432,-241451,-241471,-241490,-241510,-241529,-241549,-241568,-241588,-241607,-241627,-241646,-241666,-241685,-241705,-241724,-241744,-241763,-241783,-241802,-241821,-241841,-241860,-241880,-241899,-241918,-241938,-241957,-241976,-241996,-242015,-242034,-242054,-242073,-242092,-242111,-242131,-242150,-242169,-242188,-242208,-242227,-242246,-242265,-242285,-242304,-242323,-242342,-242361,-242380,-242400,-242419,-242438,-242457,-242476,-242495,-242514,-242533,-242552,-242571,-242590,-242610,-242629,-242648,-242667,-242686,-242705,-242724,-242743,-242762,-242781,-242799,-242818,-242837,-242856,-242875,-242894,-242913,-242932,-242951,-242970,-242989,-243007,-243026,-243045,-243064,-243083,-243102,-243120,-243139,-243158,-243177,-243195,-243214,-243233,-243252,-243270,-243289,-243308,-243327,-243345,-243364,-243383,-243401,-243420,-243439,-243457,-243476,-243495,-243513,-243532,-243550,-243569,-243587,-243606,-243625,-243643,-243662,-243680,-243699,-243717,-243736,-243754,-243773,-243791,-243810,-243828,-243847,-243865,-243884,-243902,-243920,-243939,-243957,-243976,-243994,-244012,-244031,-244049,-244067,-244086,-244104,-244122,-244141,-244159,-244177,-244196,-244214,-244232,-244250,-244269,-244287,-244305,-244323,-244342,-244360,-244378,-244396,-244414,-244432,-244451,-244469,-244487,-244505,-244523,-244541,-244559,-244577,-244596,-244614,-244632,-244650,-244668,-244686,-244704,-244722,-244740,-244758,-244776,-244794,-244812,-244830,-244848,-244866,-244884,-244902,-244920,-244937,-244955,-244973,-244991,-245009,-245027,-245045,-245063,-245080,-245098,-245116,-245134,-245152,-245170,-245187,-245205,-245223,-245241,-245258,-245276,-245294,-245312,-245329,-245347,-245365,-245382,-245400,-245418,-245435,-245453,-245471,-245488,-245506,-245524,-245541,-245559,-245576,-245594,-245612,-245629,-245647,-245664,-245682,-245699,-245717,-245734,-245752,-245769,-245787,-245804,-245822,-245839,-245857,-245874,-245891,-245909,-245926,-245944,-245961,-245978,-245996,-246013,-246031,-246048,-246065,-246083,-246100,-246117,-246135,-246152,-246169,-246186,-246204,-246221,-246238,-246255,-246273,-246290,-246307,-246324,-246341,-246359,-246376,-246393,-246410,-246427,-246444,-246462,-246479,-246496,-246513,-246530,-246547,-246564,-246581,-246598,-246615,-246632,-246649,-246666,-246683,-246700,-246717,-246734,-246751,-246768,-246785,-246802,-246819,-246836,-246853,-246870,-246887,-246904,-246921,-246937,-246954,-246971,-246988,-247005,-247022,-247039,-247055,-247072,-247089,-247106,-247122,-247139,-247156,-247173,-247189,-247206,-247223,-247240,-247256,-247273,-247290,-247306,-247323,-247340,-247356,-247373,-247390,-247406,-247423,-247439,-247456,-247473,-247489,-247506,-247522,-247539,-247555,-247572,-247588,-247605,-247621,-247638,-247654,-247671,-247687,-247704,-247720,-247737,-247753,-247770,-247786,-247802,-247819,-247835,-247852,-247868,-247884,-247901,-247917,-247933,-247950,-247966,-247982,-247999,-248015,-248031,-248047,-248064,-248080,-248096,-248112,-248129,-248145,-248161,-248177,-248193,-248210,-248226,-248242,-248258,-248274,-248290,-248306,-248322,-248339,-248355,-248371,-248387,-248403,-248419,-248435,-248451,-248467,-248483,-248499,-248515,-248531,-248547,-248563,-248579,-248595,-248611,-248627,-248643,-248659,-248675,-248690,-248706,-248722,-248738,-248754,-248770,-248786,-248802,-248817,-248833,-248849,-248865,-248881,-248896,-248912,-248928,-248944,-248959,-248975,-248991,-249007,-249022,-249038,-249054,-249069,-249085,-249101,-249116,-249132,-249148,-249163,-249179,-249194,-249210,-249226,-249241,-249257,-249272,-249288,-249303,-249319,-249334,-249350,-249366,-249381,-249397,-249412,-249427,-249443,-249458,-249474,-249489,-249505,-249520,-249535,-249551,-249566,-249582,-249597,-249612,-249628,-249643,-249658,-249674,-249689,-249704,-249720,-249735,-249750,-249765,-249781,-249796,-249811,-249826,-249842,-249857,-249872,-249887,-249902,-249918,-249933,-249948,-249963,-249978,-249993,-250008,-250024,-250039,-250054,-250069,-250084,-250099,-250114,-250129,-250144,-250159,-250174,-250189,-250204,-250219,-250234,-250249,-250264,-250279,-250294,-250309,-250324,-250339,-250354,-250369,-250384,-250398,-250413,-250428,-250443,-250458,-250473,-250488,-250502,-250517,-250532,-250547,-250561,-250576,-250591,-250606,-250621,-250635,-250650,-250665,-250679,-250694,-250709,-250723,-250738,-250753,-250767,-250782,-250797,-250811,-250826,-250841,-250855,-250870,-250884,-250899,-250913,-250928,-250943,-250957,-250972,-250986,-251001,-251015,-251030,-251044,-251059,-251073,-251087,-251102,-251116,-251131,-251145,-251160,-251174,-251188,-251203,-251217,-251231,-251246,-251260,-251274,-251289,-251303,-251317,-251332,-251346,-251360,-251374,-251389,-251403,-251417,-251431,-251446,-251460,-251474,-251488,-251502,-251517,-251531,-251545,-251559,-251573,-251587,-251601,-251616,-251630,-251644,-251658,-251672,-251686,-251700,-251714,-251728,-251742,-251756,-251770,-251784,-251798,-251812,-251826,-251840,-251854,-251868,-251882,-251896,-251910,-251924,-251937,-251951,-251965,-251979,-251993,-252007,-252021,-252034,-252048,-252062,-252076,-252090,-252103,-252117,-252131,-252145,-252158,-252172,-252186,-252200,-252213,-252227,-252241,-252254,-252268,-252282,-252295,-252309,-252323,-252336,-252350,-252364,-252377,-252391,-252404,-252418,-252431,-252445,-252459,-252472,-252486,-252499,-252513,-252526,-252540,-252553,-252567,-252580,-252593,-252607,-252620,-252634,-252647,-252661,-252674,-252687,-252701,-252714,-252727,-252741,-252754,-252767,-252781,-252794,-252807,-252821,-252834,-252847,-252860,-252874,-252887,-252900,-252913,-252927,-252940,-252953,-252966,-252979,-252993,-253006,-253019,-253032,-253045,-253058,-253071,-253084,-253098,-253111,-253124,-253137,-253150,-253163,-253176,-253189,-253202,-253215,-253228,-253241,-253254,-253267,-253280,-253293,-253306,-253319,-253332,-253345,-253358,-253370,-253383,-253396,-253409,-253422,-253435,-253448,-253460,-253473,-253486,-253499,-253512,-253524,-253537,-253550,-253563,-253576,-253588,-253601,-253614,-253626,-253639,-253652,-253665,-253677,-253690,-253703,-253715,-253728,-253740,-253753,-253766,-253778,-253791,-253803,-253816,-253829,-253841,-253854,-253866,-253879,-253891,-253904,-253916,-253929,-253941,-253954,-253966,-253979,-253991,-254003,-254016,-254028,-254041,-254053,-254066,-254078,-254090,-254103,-254115,-254127,-254140,-254152,-254164,-254177,-254189,-254201,-254213,-254226,-254238,-254250,-254262,-254275,-254287,-254299,-254311,-254323,-254336,-254348,-254360,-254372,-254384,-254396,-254409,-254421,-254433,-254445,-254457,-254469,-254481,-254493,-254505,-254517,-254529,-254541,-254553,-254565,-254577,-254589,-254601,-254613,-254625,-254637,-254649,-254661,-254673,-254685,-254697,-254709,-254720,-254732,-254744,-254756,-254768,-254780,-254792,-254803,-254815,-254827,-254839,-254851,-254862,-254874,-254886,-254898,-254909,-254921,-254933,-254944,-254956,-254968,-254980,-254991,-255003,-255014,-255026,-255038,-255049,-255061,-255073,-255084,-255096,-255107,-255119,-255130,-255142,-255154,-255165,-255177,-255188,-255200,-255211,-255223,-255234,-255245,-255257,-255268,-255280,-255291,-255303,-255314,-255325,-255337,-255348,-255360,-255371,-255382,-255394,-255405,-255416,-255428,-255439,-255450,-255461,-255473,-255484,-255495,-255506,-255518,-255529,-255540,-255551,-255563,-255574,-255585,-255596,-255607,-255618,-255629,-255641,-255652,-255663,-255674,-255685,-255696,-255707,-255718,-255729,-255740,-255751,-255762,-255773,-255784,-255795,-255806,-255817,-255828,-255839,-255850,-255861,-255872,-255883,-255894,-255905,-255916,-255927,-255938,-255948,-255959,-255970,-255981,-255992,-256003,-256013,-256024,-256035,-256046,-256057,-256067,-256078,-256089,-256100,-256110,-256121,-256132,-256142,-256153,-256164,-256175,-256185,-256196,-256206,-256217,-256228,-256238,-256249,-256260,-256270,-256281,-256291,-256302,-256312,-256323,-256333,-256344,-256354,-256365,-256375,-256386,-256396,-256407,-256417,-256428,-256438,-256449,-256459,-256469,-256480,-256490,-256501,-256511,-256521,-256532,-256542,-256552,-256563,-256573,-256583,-256594,-256604,-256614,-256624,-256635,-256645,-256655,-256665,-256676,-256686,-256696,-256706,-256716,-256727,-256737,-256747,-256757,-256767,-256777,-256787,-256797,-256808,-256818,-256828,-256838,-256848,-256858,-256868,-256878,-256888,-256898,-256908,-256918,-256928,-256938,-256948,-256958,-256968,-256978,-256988,-256998,-257007,-257017,-257027,-257037,-257047,-257057,-257067,-257077,-257086,-257096,-257106,-257116,-257126,-257135,-257145,-257155,-257165,-257174,-257184,-257194,-257204,-257213,-257223,-257233,-257242,-257252,-257262,-257271,-257281,-257291,-257300,-257310,-257319,-257329,-257339,-257348,-257358,-257367,-257377,-257386,-257396,-257405,-257415,-257424,-257434,-257443,-257453,-257462,-257472,-257481,-257491,-257500,-257509,-257519,-257528,-257538,-257547,-257556,-257566,-257575,-257584,-257594,-257603,-257612,-257622,-257631,-257640,-257650,-257659,-257668,-257677,-257687,-257696,-257705,-257714,-257723,-257733,-257742,-257751,-257760,-257769,-257778,-257788,-257797,-257806,-257815,-257824,-257833,-257842,-257851,-257860,-257869,-257878,-257887,-257896,-257905,-257914,-257923,-257932,-257941,-257950,-257959,-257968,-257977,-257986,-257995,-258004,-258013,-258022,-258030,-258039,-258048,-258057,-258066,-258075,-258083,-258092,-258101,-258110,-258119,-258127,-258136,-258145,-258154,-258162,-258171,-258180,-258189,-258197,-258206,-258215,-258223,-258232,-258241,-258249,-258258,-258266,-258275,-258284,-258292,-258301,-258309,-258318,-258326,-258335,-258344,-258352,-258361,-258369,-258378,-258386,-258395,-258403,-258411,-258420,-258428,-258437,-258445,-258454,-258462,-258470,-258479,-258487,-258495,-258504,-258512,-258521,-258529,-258537,-258545,-258554,-258562,-258570,-258579,-258587,-258595,-258603,-258612,-258620,-258628,-258636,-258644,-258653,-258661,-258669,-258677,-258685,-258693,-258701,-258710,-258718,-258726,-258734,-258742,-258750,-258758,-258766,-258774,-258782,-258790,-258798,-258806,-258814,-258822,-258830,-258838,-258846,-258854,-258862,-258870,-258878,-258886,-258894,-258901,-258909,-258917,-258925,-258933,-258941,-258949,-258956,-258964,-258972,-258980,-258988,-258995,-259003,-259011,-259019,-259026,-259034,-259042,-259049,-259057,-259065,-259072,-259080,-259088,-259095,-259103,-259111,-259118,-259126,-259134,-259141,-259149,-259156,-259164,-259171,-259179,-259186,-259194,-259201,-259209,-259216,-259224,-259231,-259239,-259246,-259254,-259261,-259269,-259276,-259284,-259291,-259298,-259306,-259313,-259320,-259328,-259335,-259342,-259350,-259357,-259364,-259372,-259379,-259386,-259394,-259401,-259408,-259415,-259422,-259430,-259437,-259444,-259451,-259458,-259466,-259473,-259480,-259487,-259494,-259501,-259508,-259516,-259523,-259530,-259537,-259544,-259551,-259558,-259565,-259572,-259579,-259586,-259593,-259600,-259607,-259614,-259621,-259628,-259635,-259642,-259649,-259656,-259663,-259669,-259676,-259683,-259690,-259697,-259704,-259711,-259717,-259724,-259731,-259738,-259745,-259751,-259758,-259765,-259772,-259778,-259785,-259792,-259799,-259805,-259812,-259819,-259825,-259832,-259839,-259845,-259852,-259859,-259865,-259872,-259878,-259885,-259892,-259898,-259905,-259911,-259918,-259924,-259931,-259937,-259944,-259950,-259957,-259963,-259970,-259976,-259983,-259989,-259996,-260002,-260008,-260015,-260021,-260028,-260034,-260040,-260047,-260053,-260059,-260066,-260072,-260078,-260084,-260091,-260097,-260103,-260110,-260116,-260122,-260128,-260134,-260141,-260147,-260153,-260159,-260165,-260172,-260178,-260184,-260190,-260196,-260202,-260208,-260214,-260220,-260227,-260233,-260239,-260245,-260251,-260257,-260263,-260269,-260275,-260281,-260287,-260293,-260299,-260305,-260311,-260316,-260322,-260328,-260334,-260340,-260346,-260352,-260358,-260364,-260369,-260375,-260381,-260387,-260393,-260398,-260404,-260410,-260416,-260422,-260427,-260433,-260439,-260444,-260450,-260456,-260462,-260467,-260473,-260479,-260484,-260490,-260495,-260501,-260507,-260512,-260518,-260524,-260529,-260535,-260540,-260546,-260551,-260557,-260562,-260568,-260573,-260579,-260584,-260590,-260595,-260601,-260606,-260612,-260617,-260622,-260628,-260633,-260639,-260644,-260649,-260655,-260660,-260665,-260671,-260676,-260681,-260687,-260692,-260697,-260702,-260708,-260713,-260718,-260723,-260729,-260734,-260739,-260744,-260749,-260755,-260760,-260765,-260770,-260775,-260780,-260785,-260790,-260796,-260801,-260806,-260811,-260816,-260821,-260826,-260831,-260836,-260841,-260846,-260851,-260856,-260861,-260866,-260871,-260876,-260881,-260886,-260891,-260895,-260900,-260905,-260910,-260915,-260920,-260925,-260929,-260934,-260939,-260944,-260949,-260954,-260958,-260963,-260968,-260973,-260977,-260982,-260987,-260991,-260996,-261001,-261006,-261010,-261015,-261020,-261024,-261029,-261033,-261038,-261043,-261047,-261052,-261056,-261061,-261066,-261070,-261075,-261079,-261084,-261088,-261093,-261097,-261102,-261106,-261111,-261115,-261119,-261124,-261128,-261133,-261137,-261142,-261146,-261150,-261155,-261159,-261163,-261168,-261172,-261176,-261181,-261185,-261189,-261194,-261198,-261202,-261206,-261211,-261215,-261219,-261223,-261227,-261232,-261236,-261240,-261244,-261248,-261252,-261257,-261261,-261265,-261269,-261273,-261277,-261281,-261285,-261289,-261293,-261297,-261301,-261305,-261309,-261313,-261317,-261321,-261325,-261329,-261333,-261337,-261341,-261345,-261349,-261353,-261357,-261361,-261365,-261368,-261372,-261376,-261380,-261384,-261388,-261391,-261395,-261399,-261403,-261407,-261410,-261414,-261418,-261422,-261425,-261429,-261433,-261436,-261440,-261444,-261447,-261451,-261455,-261458,-261462,-261466,-261469,-261473,-261476,-261480,-261484,-261487,-261491,-261494,-261498,-261501,-261505,-261508,-261512,-261515,-261519,-261522,-261526,-261529,-261532,-261536,-261539,-261543,-261546,-261550,-261553,-261556,-261560,-261563,-261566,-261570,-261573,-261576,-261580,-261583,-261586,-261589,-261593,-261596,-261599,-261602,-261606,-261609,-261612,-261615,-261618,-261622,-261625,-261628,-261631,-261634,-261637,-261640,-261643,-261647,-261650,-261653,-261656,-261659,-261662,-261665,-261668,-261671,-261674,-261677,-261680,-261683,-261686,-261689,-261692,-261695,-261698,-261701,-261704,-261707,-261709,-261712,-261715,-261718,-261721,-261724,-261727,-261729,-261732,-261735,-261738,-261741,-261743,-261746,-261749,-261752,-261754,-261757,-261760,-261763,-261765,-261768,-261771,-261773,-261776,-261779,-261781,-261784,-261787,-261789,-261792,-261794,-261797,-261800,-261802,-261805,-261807,-261810,-261812,-261815,-261817,-261820,-261822,-261825,-261827,-261830,-261832,-261835,-261837,-261839,-261842,-261844,-261847,-261849,-261851,-261854,-261856,-261858,-261861,-261863,-261865,-261868,-261870,-261872,-261875,-261877,-261879,-261881,-261884,-261886,-261888,-261890,-261893,-261895,-261897,-261899,-261901,-261903,-261906,-261908,-261910,-261912,-261914,-261916,-261918,-261920,-261922,-261924,-261926,-261928,-261931,-261933,-261935,-261937,-261939,-261941,-261942,-261944,-261946,-261948,-261950,-261952,-261954,-261956,-261958,-261960,-261962,-261964,-261965,-261967,-261969,-261971,-261973,-261974,-261976,-261978,-261980,-261982,-261983,-261985,-261987,-261989,-261990,-261992,-261994,-261995,-261997,-261999,-262000,-262002,-262004,-262005,-262007,-262009,-262010,-262012,-262013,-262015,-262017,-262018,-262020,-262021,-262023,-262024,-262026,-262027,-262029,-262030,-262032,-262033,-262035,-262036,-262037,-262039,-262040,-262042,-262043,-262044,-262046,-262047,-262049,-262050,-262051,-262053,-262054,-262055,-262056,-262058,-262059,-262060,-262062,-262063,-262064,-262065,-262066,-262068,-262069,-262070,-262071,-262072,-262074,-262075,-262076,-262077,-262078,-262079,-262080,-262081,-262083,-262084,-262085,-262086,-262087,-262088,-262089,-262090,-262091,-262092,-262093,-262094,-262095,-262096,-262097,-262098,-262099,-262100,-262100,-262101,-262102,-262103,-262104,-262105,-262106,-262107,-262107,-262108,-262109,-262110,-262111,-262111,-262112,-262113,-262114,-262114,-262115,-262116,-262117,-262117,-262118,-262119,-262119,-262120,-262121,-262121,-262122,-262123,-262123,-262124,-262124,-262125,-262126,-262126,-262127,-262127,-262128,-262128,-262129,-262129,-262130,-262130,-262131,-262131,-262132,-262132,-262133,-262133,-262134,-262134,-262134,-262135,-262135,-262136,-262136,-262136,-262137,-262137,-262137,-262138,-262138,-262138,-262139,-262139,-262139,-262139,-262140,-262140,-262140,-262140,-262141,-262141,-262141,-262141,-262141,-262142,-262142,-262142,-262142,-262142,-262142,-262142,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262142,-262142,-262142,-262142,-262142,-262142,-262142,-262141,-262141,-262141,-262141,-262141,-262140,-262140,-262140,-262140,-262139,-262139,-262139,-262139,-262138,-262138,-262138,-262137,-262137,-262137,-262136,-262136,-262136,-262135,-262135,-262134,-262134,-262134,-262133,-262133,-262132,-262132,-262131,-262131,-262130,-262130,-262129,-262129,-262128,-262128,-262127,-262127,-262126,-262126,-262125,-262124,-262124,-262123,-262123,-262122,-262121,-262121,-262120,-262119,-262119,-262118,-262117,-262117,-262116,-262115,-262114,-262114,-262113,-262112,-262111,-262111,-262110,-262109,-262108,-262107,-262107,-262106,-262105,-262104,-262103,-262102,-262101,-262100,-262100,-262099,-262098,-262097,-262096,-262095,-262094,-262093,-262092,-262091,-262090,-262089,-262088,-262087,-262086,-262085,-262084,-262083,-262081,-262080,-262079,-262078,-262077,-262076,-262075,-262074,-262072,-262071,-262070,-262069,-262068,-262066,-262065,-262064,-262063,-262062,-262060,-262059,-262058,-262056,-262055,-262054,-262053,-262051,-262050,-262049,-262047,-262046,-262044,-262043,-262042,-262040,-262039,-262037,-262036,-262035,-262033,-262032,-262030,-262029,-262027,-262026,-262024,-262023,-262021,-262020,-262018,-262017,-262015,-262013,-262012,-262010,-262009,-262007,-262005,-262004,-262002,-262000,-261999,-261997,-261995,-261994,-261992,-261990,-261989,-261987,-261985,-261983,-261982,-261980,-261978,-261976,-261974,-261973,-261971,-261969,-261967,-261965,-261964,-261962,-261960,-261958,-261956,-261954,-261952,-261950,-261948,-261946,-261944,-261942,-261941,-261939,-261937,-261935,-261933,-261931,-261928,-261926,-261924,-261922,-261920,-261918,-261916,-261914,-261912,-261910,-261908,-261906,-261903,-261901,-261899,-261897,-261895,-261893,-261890,-261888,-261886,-261884,-261881,-261879,-261877,-261875,-261872,-261870,-261868,-261865,-261863,-261861,-261858,-261856,-261854,-261851,-261849,-261847,-261844,-261842,-261839,-261837,-261835,-261832,-261830,-261827,-261825,-261822,-261820,-261817,-261815,-261812,-261810,-261807,-261805,-261802,-261800,-261797,-261794,-261792,-261789,-261787,-261784,-261781,-261779,-261776,-261773,-261771,-261768,-261765,-261763,-261760,-261757,-261754,-261752,-261749,-261746,-261743,-261741,-261738,-261735,-261732,-261729,-261727,-261724,-261721,-261718,-261715,-261712,-261709,-261707,-261704,-261701,-261698,-261695,-261692,-261689,-261686,-261683,-261680,-261677,-261674,-261671,-261668,-261665,-261662,-261659,-261656,-261653,-261650,-261647,-261643,-261640,-261637,-261634,-261631,-261628,-261625,-261622,-261618,-261615,-261612,-261609,-261606,-261602,-261599,-261596,-261593,-261589,-261586,-261583,-261580,-261576,-261573,-261570,-261566,-261563,-261560,-261556,-261553,-261550,-261546,-261543,-261539,-261536,-261532,-261529,-261526,-261522,-261519,-261515,-261512,-261508,-261505,-261501,-261498,-261494,-261491,-261487,-261484,-261480,-261476,-261473,-261469,-261466,-261462,-261458,-261455,-261451,-261447,-261444,-261440,-261436,-261433,-261429,-261425,-261422,-261418,-261414,-261410,-261407,-261403,-261399,-261395,-261391,-261388,-261384,-261380,-261376,-261372,-261368,-261365,-261361,-261357,-261353,-261349,-261345,-261341,-261337,-261333,-261329,-261325,-261321,-261317,-261313,-261309,-261305,-261301,-261297,-261293,-261289,-261285,-261281,-261277,-261273,-261269,-261265,-261261,-261257,-261252,-261248,-261244,-261240,-261236,-261232,-261227,-261223,-261219,-261215,-261211,-261206,-261202,-261198,-261194,-261189,-261185,-261181,-261176,-261172,-261168,-261163,-261159,-261155,-261150,-261146,-261142,-261137,-261133,-261128,-261124,-261119,-261115,-261111,-261106,-261102,-261097,-261093,-261088,-261084,-261079,-261075,-261070,-261066,-261061,-261056,-261052,-261047,-261043,-261038,-261033,-261029,-261024,-261020,-261015,-261010,-261006,-261001,-260996,-260991,-260987,-260982,-260977,-260973,-260968,-260963,-260958,-260954,-260949,-260944,-260939,-260934,-260929,-260925,-260920,-260915,-260910,-260905,-260900,-260895,-260891,-260886,-260881,-260876,-260871,-260866,-260861,-260856,-260851,-260846,-260841,-260836,-260831,-260826,-260821,-260816,-260811,-260806,-260801,-260796,-260790,-260785,-260780,-260775,-260770,-260765,-260760,-260755,-260749,-260744,-260739,-260734,-260729,-260723,-260718,-260713,-260708,-260702,-260697,-260692,-260687,-260681,-260676,-260671,-260665,-260660,-260655,-260649,-260644,-260639,-260633,-260628,-260622,-260617,-260612,-260606,-260601,-260595,-260590,-260584,-260579,-260573,-260568,-260562,-260557,-260551,-260546,-260540,-260535,-260529,-260524,-260518,-260512,-260507,-260501,-260495,-260490,-260484,-260479,-260473,-260467,-260462,-260456,-260450,-260444,-260439,-260433,-260427,-260422,-260416,-260410,-260404,-260398,-260393,-260387,-260381,-260375,-260369,-260364,-260358,-260352,-260346,-260340,-260334,-260328,-260322,-260316,-260311,-260305,-260299,-260293,-260287,-260281,-260275,-260269,-260263,-260257,-260251,-260245,-260239,-260233,-260227,-260220,-260214,-260208,-260202,-260196,-260190,-260184,-260178,-260172,-260165,-260159,-260153,-260147,-260141,-260134,-260128,-260122,-260116,-260110,-260103,-260097,-260091,-260084,-260078,-260072,-260066,-260059,-260053,-260047,-260040,-260034,-260028,-260021,-260015,-260008,-260002,-259996,-259989,-259983,-259976,-259970,-259963,-259957,-259950,-259944,-259937,-259931,-259924,-259918,-259911,-259905,-259898,-259892,-259885,-259878,-259872,-259865,-259859,-259852,-259845,-259839,-259832,-259825,-259819,-259812,-259805,-259799,-259792,-259785,-259778,-259772,-259765,-259758,-259751,-259745,-259738,-259731,-259724,-259717,-259711,-259704,-259697,-259690,-259683,-259676,-259669,-259663,-259656,-259649,-259642,-259635,-259628,-259621,-259614,-259607,-259600,-259593,-259586,-259579,-259572,-259565,-259558,-259551,-259544,-259537,-259530,-259523,-259516,-259508,-259501,-259494,-259487,-259480,-259473,-259466,-259458,-259451,-259444,-259437,-259430,-259422,-259415,-259408,-259401,-259394,-259386,-259379,-259372,-259364,-259357,-259350,-259342,-259335,-259328,-259320,-259313,-259306,-259298,-259291,-259284,-259276,-259269,-259261,-259254,-259246,-259239,-259231,-259224,-259216,-259209,-259201,-259194,-259186,-259179,-259171,-259164,-259156,-259149,-259141,-259134,-259126,-259118,-259111,-259103,-259095,-259088,-259080,-259072,-259065,-259057,-259049,-259042,-259034,-259026,-259019,-259011,-259003,-258995,-258988,-258980,-258972,-258964,-258956,-258949,-258941,-258933,-258925,-258917,-258909,-258901,-258894,-258886,-258878,-258870,-258862,-258854,-258846,-258838,-258830,-258822,-258814,-258806,-258798,-258790,-258782,-258774,-258766,-258758,-258750,-258742,-258734,-258726,-258718,-258710,-258701,-258693,-258685,-258677,-258669,-258661,-258653,-258644,-258636,-258628,-258620,-258612,-258603,-258595,-258587,-258579,-258570,-258562,-258554,-258545,-258537,-258529,-258521,-258512,-258504,-258495,-258487,-258479,-258470,-258462,-258454,-258445,-258437,-258428,-258420,-258411,-258403,-258395,-258386,-258378,-258369,-258361,-258352,-258344,-258335,-258326,-258318,-258309,-258301,-258292,-258284,-258275,-258266,-258258,-258249,-258241,-258232,-258223,-258215,-258206,-258197,-258189,-258180,-258171,-258162,-258154,-258145,-258136,-258127,-258119,-258110,-258101,-258092,-258083,-258075,-258066,-258057,-258048,-258039,-258030,-258022,-258013,-258004,-257995,-257986,-257977,-257968,-257959,-257950,-257941,-257932,-257923,-257914,-257905,-257896,-257887,-257878,-257869,-257860,-257851,-257842,-257833,-257824,-257815,-257806,-257797,-257788,-257778,-257769,-257760,-257751,-257742,-257733,-257723,-257714,-257705,-257696,-257687,-257677,-257668,-257659,-257650,-257640,-257631,-257622,-257612,-257603,-257594,-257584,-257575,-257566,-257556,-257547,-257538,-257528,-257519,-257509,-257500,-257491,-257481,-257472,-257462,-257453,-257443,-257434,-257424,-257415,-257405,-257396,-257386,-257377,-257367,-257358,-257348,-257339,-257329,-257319,-257310,-257300,-257291,-257281,-257271,-257262,-257252,-257242,-257233,-257223,-257213,-257204,-257194,-257184,-257174,-257165,-257155,-257145,-257135,-257126,-257116,-257106,-257096,-257086,-257077,-257067,-257057,-257047,-257037,-257027,-257017,-257007,-256998,-256988,-256978,-256968,-256958,-256948,-256938,-256928,-256918,-256908,-256898,-256888,-256878,-256868,-256858,-256848,-256838,-256828,-256818,-256808,-256797,-256787,-256777,-256767,-256757,-256747,-256737,-256727,-256716,-256706,-256696,-256686,-256676,-256665,-256655,-256645,-256635,-256624,-256614,-256604,-256594,-256583,-256573,-256563,-256552,-256542,-256532,-256521,-256511,-256501,-256490,-256480,-256469,-256459,-256449,-256438,-256428,-256417,-256407,-256396,-256386,-256375,-256365,-256354,-256344,-256333,-256323,-256312,-256302,-256291,-256281,-256270,-256260,-256249,-256238,-256228,-256217,-256206,-256196,-256185,-256175,-256164,-256153,-256142,-256132,-256121,-256110,-256100,-256089,-256078,-256067,-256057,-256046,-256035,-256024,-256013,-256003,-255992,-255981,-255970,-255959,-255948,-255938,-255927,-255916,-255905,-255894,-255883,-255872,-255861,-255850,-255839,-255828,-255817,-255806,-255795,-255784,-255773,-255762,-255751,-255740,-255729,-255718,-255707,-255696,-255685,-255674,-255663,-255652,-255641,-255629,-255618,-255607,-255596,-255585,-255574,-255563,-255551,-255540,-255529,-255518,-255506,-255495,-255484,-255473,-255461,-255450,-255439,-255428,-255416,-255405,-255394,-255382,-255371,-255360,-255348,-255337,-255325,-255314,-255303,-255291,-255280,-255268,-255257,-255245,-255234,-255223,-255211,-255200,-255188,-255177,-255165,-255154,-255142,-255130,-255119,-255107,-255096,-255084,-255073,-255061,-255049,-255038,-255026,-255014,-255003,-254991,-254980,-254968,-254956,-254944,-254933,-254921,-254909,-254898,-254886,-254874,-254862,-254851,-254839,-254827,-254815,-254803,-254792,-254780,-254768,-254756,-254744,-254732,-254720,-254709,-254697,-254685,-254673,-254661,-254649,-254637,-254625,-254613,-254601,-254589,-254577,-254565,-254553,-254541,-254529,-254517,-254505,-254493,-254481,-254469,-254457,-254445,-254433,-254421,-254409,-254396,-254384,-254372,-254360,-254348,-254336,-254323,-254311,-254299,-254287,-254275,-254262,-254250,-254238,-254226,-254213,-254201,-254189,-254177,-254164,-254152,-254140,-254127,-254115,-254103,-254090,-254078,-254066,-254053,-254041,-254028,-254016,-254003,-253991,-253979,-253966,-253954,-253941,-253929,-253916,-253904,-253891,-253879,-253866,-253854,-253841,-253829,-253816,-253803,-253791,-253778,-253766,-253753,-253740,-253728,-253715,-253703,-253690,-253677,-253665,-253652,-253639,-253626,-253614,-253601,-253588,-253576,-253563,-253550,-253537,-253524,-253512,-253499,-253486,-253473,-253460,-253448,-253435,-253422,-253409,-253396,-253383,-253370,-253358,-253345,-253332,-253319,-253306,-253293,-253280,-253267,-253254,-253241,-253228,-253215,-253202,-253189,-253176,-253163,-253150,-253137,-253124,-253111,-253098,-253084,-253071,-253058,-253045,-253032,-253019,-253006,-252993,-252979,-252966,-252953,-252940,-252927,-252913,-252900,-252887,-252874,-252860,-252847,-252834,-252821,-252807,-252794,-252781,-252767,-252754,-252741,-252727,-252714,-252701,-252687,-252674,-252661,-252647,-252634,-252620,-252607,-252593,-252580,-252567,-252553,-252540,-252526,-252513,-252499,-252486,-252472,-252459,-252445,-252431,-252418,-252404,-252391,-252377,-252364,-252350,-252336,-252323,-252309,-252295,-252282,-252268,-252254,-252241,-252227,-252213,-252200,-252186,-252172,-252158,-252145,-252131,-252117,-252103,-252090,-252076,-252062,-252048,-252034,-252021,-252007,-251993,-251979,-251965,-251951,-251937,-251924,-251910,-251896,-251882,-251868,-251854,-251840,-251826,-251812,-251798,-251784,-251770,-251756,-251742,-251728,-251714,-251700,-251686,-251672,-251658,-251644,-251630,-251616,-251601,-251587,-251573,-251559,-251545,-251531,-251517,-251502,-251488,-251474,-251460,-251446,-251431,-251417,-251403,-251389,-251374,-251360,-251346,-251332,-251317,-251303,-251289,-251274,-251260,-251246,-251231,-251217,-251203,-251188,-251174,-251160,-251145,-251131,-251116,-251102,-251087,-251073,-251059,-251044,-251030,-251015,-251001,-250986,-250972,-250957,-250943,-250928,-250913,-250899,-250884,-250870,-250855,-250841,-250826,-250811,-250797,-250782,-250767,-250753,-250738,-250723,-250709,-250694,-250679,-250665,-250650,-250635,-250621,-250606,-250591,-250576,-250561,-250547,-250532,-250517,-250502,-250488,-250473,-250458,-250443,-250428,-250413,-250398,-250384,-250369,-250354,-250339,-250324,-250309,-250294,-250279,-250264,-250249,-250234,-250219,-250204,-250189,-250174,-250159,-250144,-250129,-250114,-250099,-250084,-250069,-250054,-250039,-250024,-250008,-249993,-249978,-249963,-249948,-249933,-249918,-249902,-249887,-249872,-249857,-249842,-249826,-249811,-249796,-249781,-249765,-249750,-249735,-249720,-249704,-249689,-249674,-249658,-249643,-249628,-249612,-249597,-249582,-249566,-249551,-249535,-249520,-249505,-249489,-249474,-249458,-249443,-249427,-249412,-249397,-249381,-249366,-249350,-249334,-249319,-249303,-249288,-249272,-249257,-249241,-249226,-249210,-249194,-249179,-249163,-249148,-249132,-249116,-249101,-249085,-249069,-249054,-249038,-249022,-249007,-248991,-248975,-248959,-248944,-248928,-248912,-248896,-248881,-248865,-248849,-248833,-248817,-248802,-248786,-248770,-248754,-248738,-248722,-248706,-248690,-248675,-248659,-248643,-248627,-248611,-248595,-248579,-248563,-248547,-248531,-248515,-248499,-248483,-248467,-248451,-248435,-248419,-248403,-248387,-248371,-248355,-248339,-248322,-248306,-248290,-248274,-248258,-248242,-248226,-248210,-248193,-248177,-248161,-248145,-248129,-248112,-248096,-248080,-248064,-248047,-248031,-248015,-247999,-247982,-247966,-247950,-247933,-247917,-247901,-247884,-247868,-247852,-247835,-247819,-247802,-247786,-247770,-247753,-247737,-247720,-247704,-247687,-247671,-247654,-247638,-247621,-247605,-247588,-247572,-247555,-247539,-247522,-247506,-247489,-247473,-247456,-247439,-247423,-247406,-247390,-247373,-247356,-247340,-247323,-247306,-247290,-247273,-247256,-247240,-247223,-247206,-247189,-247173,-247156,-247139,-247122,-247106,-247089,-247072,-247055,-247039,-247022,-247005,-246988,-246971,-246954,-246937,-246921,-246904,-246887,-246870,-246853,-246836,-246819,-246802,-246785,-246768,-246751,-246734,-246717,-246700,-246683,-246666,-246649,-246632,-246615,-246598,-246581,-246564,-246547,-246530,-246513,-246496,-246479,-246462,-246444,-246427,-246410,-246393,-246376,-246359,-246341,-246324,-246307,-246290,-246273,-246255,-246238,-246221,-246204,-246186,-246169,-246152,-246135,-246117,-246100,-246083,-246065,-246048,-246031,-246013,-245996,-245978,-245961,-245944,-245926,-245909,-245891,-245874,-245857,-245839,-245822,-245804,-245787,-245769,-245752,-245734,-245717,-245699,-245682,-245664,-245647,-245629,-245612,-245594,-245576,-245559,-245541,-245524,-245506,-245488,-245471,-245453,-245435,-245418,-245400,-245382,-245365,-245347,-245329,-245312,-245294,-245276,-245258,-245241,-245223,-245205,-245187,-245170,-245152,-245134,-245116,-245098,-245080,-245063,-245045,-245027,-245009,-244991,-244973,-244955,-244937,-244920,-244902,-244884,-244866,-244848,-244830,-244812,-244794,-244776,-244758,-244740,-244722,-244704,-244686,-244668,-244650,-244632,-244614,-244596,-244577,-244559,-244541,-244523,-244505,-244487,-244469,-244451,-244432,-244414,-244396,-244378,-244360,-244342,-244323,-244305,-244287,-244269,-244250,-244232,-244214,-244196,-244177,-244159,-244141,-244122,-244104,-244086,-244067,-244049,-244031,-244012,-243994,-243976,-243957,-243939,-243920,-243902,-243884,-243865,-243847,-243828,-243810,-243791,-243773,-243754,-243736,-243717,-243699,-243680,-243662,-243643,-243625,-243606,-243587,-243569,-243550,-243532,-243513,-243495,-243476,-243457,-243439,-243420,-243401,-243383,-243364,-243345,-243327,-243308,-243289,-243270,-243252,-243233,-243214,-243195,-243177,-243158,-243139,-243120,-243102,-243083,-243064,-243045,-243026,-243007,-242989,-242970,-242951,-242932,-242913,-242894,-242875,-242856,-242837,-242818,-242799,-242781,-242762,-242743,-242724,-242705,-242686,-242667,-242648,-242629,-242610,-242590,-242571,-242552,-242533,-242514,-242495,-242476,-242457,-242438,-242419,-242400,-242380,-242361,-242342,-242323,-242304,-242285,-242265,-242246,-242227,-242208,-242188,-242169,-242150,-242131,-242111,-242092,-242073,-242054,-242034,-242015,-241996,-241976,-241957,-241938,-241918,-241899,-241880,-241860,-241841,-241821,-241802,-241783,-241763,-241744,-241724,-241705,-241685,-241666,-241646,-241627,-241607,-241588,-241568,-241549,-241529,-241510,-241490,-241471,-241451,-241432,-241412,-241392,-241373,-241353,-241333,-241314,-241294,-241275,-241255,-241235,-241216,-241196,-241176,-241156,-241137,-241117,-241097,-241078,-241058,-241038,-241018,-240999,-240979,-240959,-240939,-240919,-240900,-240880,-240860,-240840,-240820,-240800,-240780,-240761,-240741,-240721,-240701,-240681,-240661,-240641,-240621,-240601,-240581,-240561,-240541,-240521,-240501,-240481,-240461,-240441,-240421,-240401,-240381,-240361,-240341,-240321,-240301,-240281,-240261,-240241,-240220,-240200,-240180,-240160,-240140,-240120,-240100,-240079,-240059,-240039,-240019,-239999,-239978,-239958,-239938,-239918,-239897,-239877,-239857,-239837,-239816,-239796,-239776,-239755,-239735,-239715,-239694,-239674,-239654,-239633,-239613,-239592,-239572,-239552,-239531,-239511,-239490,-239470,-239449,-239429,-239409,-239388,-239368,-239347,-239327,-239306,-239286,-239265,-239244,-239224,-239203,-239183,-239162,-239142,-239121,-239100,-239080,-239059,-239039,-239018,-238997,-238977,-238956,-238935,-238915,-238894,-238873,-238852,-238832,-238811,-238790,-238770,-238749,-238728,-238707,-238687,-238666,-238645,-238624,-238603,-238582,-238562,-238541,-238520,-238499,-238478,-238457,-238436,-238416,-238395,-238374,-238353,-238332,-238311,-238290,-238269,-238248,-238227,-238206,-238185,-238164,-238143,-238122,-238101,-238080,-238059,-238038,-238017,-237996,-237975,-237954,-237933,-237912,-237890,-237869,-237848,-237827,-237806,-237785,-237764,-237742,-237721,-237700,-237679,-237658,-237636,-237615,-237594,-237573,-237551,-237530,-237509,-237488,-237466,-237445,-237424,-237402,-237381,-237360,-237338,-237317,-237296,-237274,-237253,-237232,-237210,-237189,-237167,-237146,-237125,-237103,-237082,-237060,-237039,-237017,-236996,-236974,-236953,-236931,-236910,-236888,-236867,-236845,-236824,-236802,-236781,-236759,-236737,-236716,-236694,-236673,-236651,-236629,-236608,-236586,-236564,-236543,-236521,-236499,-236478,-236456,-236434,-236413,-236391,-236369,-236347,-236326,-236304,-236282,-236260,-236239,-236217,-236195,-236173,-236151,-236130,-236108,-236086,-236064,-236042,-236020,-235998,-235977,-235955,-235933,-235911,-235889,-235867,-235845,-235823,-235801,-235779,-235757,-235735,-235713,-235691,-235669,-235647,-235625,-235603,-235581,-235559,-235537,-235515,-235493,-235471,-235449,-235427,-235404,-235382,-235360,-235338,-235316,-235294,-235272,-235249,-235227,-235205,-235183,-235161,-235138,-235116,-235094,-235072,-235049,-235027,-235005,-234983,-234960,-234938,-234916,-234893,-234871,-234849,-234827,-234804,-234782,-234759,-234737,-234715,-234692,-234670,-234648,-234625,-234603,-234580,-234558,-234535,-234513,-234490,-234468,-234445,-234423,-234400,-234378,-234355,-234333,-234310,-234288,-234265,-234243,-234220,-234198,-234175,-234152,-234130,-234107,-234085,-234062,-234039,-234017,-233994,-233971,-233949,-233926,-233903,-233881,-233858,-233835,-233812,-233790,-233767,-233744,-233721,-233699,-233676,-233653,-233630,-233608,-233585,-233562,-233539,-233516,-233493,-233471,-233448,-233425,-233402,-233379,-233356,-233333,-233310,-233287,-233264,-233242,-233219,-233196,-233173,-233150,-233127,-233104,-233081,-233058,-233035,-233012,-232989,-232966,-232943,-232919,-232896,-232873,-232850,-232827,-232804,-232781,-232758,-232735,-232712,-232688,-232665,-232642,-232619,-232596,-232573,-232549,-232526,-232503,-232480,-232456,-232433,-232410,-232387,-232363,-232340,-232317,-232294,-232270,-232247,-232224,-232200,-232177,-232154,-232130,-232107,-232084,-232060,-232037,-232013,-231990,-231967,-231943,-231920,-231896,-231873,-231849,-231826,-231803,-231779,-231756,-231732,-231709,-231685,-231662,-231638,-231614,-231591,-231567,-231544,-231520,-231497,-231473,-231449,-231426,-231402,-231379,-231355,-231331,-231308,-231284,-231260,-231237,-231213,-231189,-231166,-231142,-231118,-231095,-231071,-231047,-231023,-231000,-230976,-230952,-230928,-230904,-230881,-230857,-230833,-230809,-230785,-230761,-230738,-230714,-230690,-230666,-230642,-230618,-230594,-230570,-230547,-230523,-230499,-230475,-230451,-230427,-230403,-230379,-230355,-230331,-230307,-230283,-230259,-230235,-230211,-230187,-230163,-230139,-230115,-230090,-230066,-230042,-230018,-229994,-229970,-229946,-229922,-229897,-229873,-229849,-229825,-229801,-229777,-229752,-229728,-229704,-229680,-229656,-229631,-229607,-229583,-229559,-229534,-229510,-229486,-229461,-229437,-229413,-229388,-229364,-229340,-229315,-229291,-229267,-229242,-229218,-229193,-229169,-229145,-229120,-229096,-229071,-229047,-229023,-228998,-228974,-228949,-228925,-228900,-228876,-228851,-228827,-228802,-228778,-228753,-228728,-228704,-228679,-228655,-228630,-228606,-228581,-228556,-228532,-228507,-228482,-228458,-228433,-228408,-228384,-228359,-228334,-228310,-228285,-228260,-228236,-228211,-228186,-228161,-228137,-228112,-228087,-228062,-228038,-228013,-227988,-227963,-227938,-227913,-227889,-227864,-227839,-227814,-227789,-227764,-227739,-227715,-227690,-227665,-227640,-227615,-227590,-227565,-227540,-227515,-227490,-227465,-227440,-227415,-227390,-227365,-227340,-227315,-227290,-227265,-227240,-227215,-227190,-227165,-227140,-227114,-227089,-227064,-227039,-227014,-226989,-226964,-226939,-226913,-226888,-226863,-226838,-226813,-226787,-226762,-226737,-226712,-226687,-226661,-226636,-226611,-226585,-226560,-226535,-226510,-226484,-226459,-226434,-226408,-226383,-226358,-226332,-226307,-226282,-226256,-226231,-226205,-226180,-226155,-226129,-226104,-226078,-226053,-226027,-226002,-225976,-225951,-225925,-225900,-225874,-225849,-225823,-225798,-225772,-225747,-225721,-225696,-225670,-225645,-225619,-225593,-225568,-225542,-225516,-225491,-225465,-225440,-225414,-225388,-225363,-225337,-225311,-225286,-225260,-225234,-225208,-225183,-225157,-225131,-225105,-225080,-225054,-225028,-225002,-224977,-224951,-224925,-224899,-224873,-224847,-224822,-224796,-224770,-224744,-224718,-224692,-224666,-224640,-224614,-224589,-224563,-224537,-224511,-224485,-224459,-224433,-224407,-224381,-224355,-224329,-224303,-224277,-224251,-224225,-224199,-224173,-224147,-224121,-224095,-224068,-224042,-224016,-223990,-223964,-223938,-223912,-223886,-223859,-223833,-223807,-223781,-223755,-223729,-223702,-223676,-223650,-223624,-223598,-223571,-223545,-223519,-223492,-223466,-223440,-223414,-223387,-223361,-223335,-223308,-223282,-223256,-223229,-223203,-223177,-223150,-223124,-223098,-223071,-223045,-223018,-222992,-222965,-222939,-222913,-222886,-222860,-222833,-222807,-222780,-222754,-222727,-222701,-222674,-222648,-222621,-222595,-222568,-222541,-222515,-222488,-222462,-222435,-222409,-222382,-222355,-222329,-222302,-222275,-222249,-222222,-222195,-222169,-222142,-222115,-222089,-222062,-222035,-222009,-221982,-221955,-221928,-221902,-221875,-221848,-221821,-221794,-221768,-221741,-221714,-221687,-221660,-221633,-221607,-221580,-221553,-221526,-221499,-221472,-221445,-221418,-221392,-221365,-221338,-221311,-221284,-221257,-221230,-221203,-221176,-221149,-221122,-221095,-221068,-221041,-221014,-220987,-220960,-220933,-220906,-220879,-220852,-220825,-220797,-220770,-220743,-220716,-220689,-220662,-220635,-220608,-220580,-220553,-220526,-220499,-220472,-220445,-220417,-220390,-220363,-220336,-220308,-220281,-220254,-220227,-220199,-220172,-220145,-220118,-220090,-220063,-220036,-220008,-219981,-219954,-219926,-219899,-219872,-219844,-219817,-219789,-219762,-219735,-219707,-219680,-219652,-219625,-219597,-219570,-219543,-219515,-219488,-219460,-219433,-219405,-219378,-219350,-219323,-219295,-219267,-219240,-219212,-219185,-219157,-219130,-219102,-219074,-219047,-219019,-218992,-218964,-218936,-218909,-218881,-218853,-218826,-218798,-218770,-218743,-218715,-218687,-218659,-218632,-218604,-218576,-218548,-218521,-218493,-218465,-218437,-218410,-218382,-218354,-218326,-218298,-218270,-218243,-218215,-218187,-218159,-218131,-218103,-218075,-218048,-218020,-217992,-217964,-217936,-217908,-217880,-217852,-217824,-217796,-217768,-217740,-217712,-217684,-217656,-217628,-217600,-217572,-217544,-217516,-217488,-217460,-217432,-217404,-217376,-217347,-217319,-217291,-217263,-217235,-217207,-217179,-217151,-217122,-217094,-217066,-217038,-217010,-216981,-216953,-216925,-216897,-216869,-216840,-216812,-216784,-216756,-216727,-216699,-216671,-216642,-216614,-216586,-216557,-216529,-216501,-216472,-216444,-216416,-216387,-216359,-216331,-216302,-216274,-216245,-216217,-216189,-216160,-216132,-216103,-216075,-216046,-216018,-215989,-215961,-215932,-215904,-215875,-215847,-215818,-215790,-215761,-215733,-215704,-215676,-215647,-215618,-215590,-215561,-215533,-215504,-215475,-215447,-215418,-215389,-215361,-215332,-215303,-215275,-215246,-215217,-215189,-215160,-215131,-215103,-215074,-215045,-215016,-214988,-214959,-214930,-214901,-214872,-214844,-214815,-214786,-214757,-214728,-214700,-214671,-214642,-214613,-214584,-214555,-214526,-214497,-214469,-214440,-214411,-214382,-214353,-214324,-214295,-214266,-214237,-214208,-214179,-214150,-214121,-214092,-214063,-214034,-214005,-213976,-213947,-213918,-213889,-213860,-213831,-213802,-213773,-213744,-213714,-213685,-213656,-213627,-213598,-213569,-213540,-213510,-213481,-213452,-213423,-213394,-213365,-213335,-213306,-213277,-213248,-213218,-213189,-213160,-213131,-213101,-213072,-213043,-213014,-212984,-212955,-212926,-212896,-212867,-212838,-212808,-212779,-212750,-212720,-212691,-212661,-212632,-212603,-212573,-212544,-212514,-212485,-212455,-212426,-212397,-212367,-212338,-212308,-212279,-212249,-212220,-212190,-212161,-212131,-212102,-212072,-212042,-212013,-211983,-211954,-211924,-211895,-211865,-211835,-211806,-211776,-211747,-211717,-211687,-211658,-211628,-211598,-211569,-211539,-211509,-211480,-211450,-211420,-211390,-211361,-211331,-211301,-211271,-211242,-211212,-211182,-211152,-211123,-211093,-211063,-211033,-211003,-210973,-210944,-210914,-210884,-210854,-210824,-210794,-210764,-210735,-210705,-210675,-210645,-210615,-210585,-210555,-210525,-210495,-210465,-210435,-210405,-210375,-210345,-210315,-210285,-210255,-210225,-210195,-210165,-210135,-210105,-210075,-210045,-210015,-209985,-209955,-209925,-209894,-209864,-209834,-209804,-209774,-209744,-209714,-209683,-209653,-209623,-209593,-209563,-209533,-209502,-209472,-209442,-209412,-209381,-209351,-209321,-209291,-209260,-209230,-209200,-209169,-209139,-209109,-209079,-209048,-209018,-208988,-208957,-208927,-208896,-208866,-208836,-208805,-208775,-208745,-208714,-208684,-208653,-208623,-208592,-208562,-208532,-208501,-208471,-208440,-208410,-208379,-208349,-208318,-208288,-208257,-208227,-208196,-208165,-208135,-208104,-208074,-208043,-208013,-207982,-207951,-207921,-207890,-207860,-207829,-207798,-207768,-207737,-207706,-207676,-207645,-207614,-207584,-207553,-207522,-207491,-207461,-207430,-207399,-207369,-207338,-207307,-207276,-207245,-207215,-207184,-207153,-207122,-207091,-207061,-207030,-206999,-206968,-206937,-206906,-206876,-206845,-206814,-206783,-206752,-206721,-206690,-206659,-206628,-206597,-206566,-206536,-206505,-206474,-206443,-206412,-206381,-206350,-206319,-206288,-206257,-206226,-206195,-206164,-206132,-206101,-206070,-206039,-206008,-205977,-205946,-205915,-205884,-205853,-205822,-205790,-205759,-205728,-205697,-205666,-205635,-205603,-205572,-205541,-205510,-205479,-205447,-205416,-205385,-205354,-205323,-205291,-205260,-205229,-205197,-205166,-205135,-205104,-205072,-205041,-205010,-204978,-204947,-204916,-204884,-204853,-204822,-204790,-204759,-204727,-204696,-204665,-204633,-204602,-204570,-204539,-204507,-204476,-204445,-204413,-204382,-204350,-204319,-204287,-204256,-204224,-204193,-204161,-204130,-204098,-204066,-204035,-204003,-203972,-203940,-203909,-203877,-203845,-203814,-203782,-203751,-203719,-203687,-203656,-203624,-203592,-203561,-203529,-203497,-203466,-203434,-203402,-203371,-203339,-203307,-203275,-203244,-203212,-203180,-203148,-203117,-203085,-203053,-203021,-202989,-202958,-202926,-202894,-202862,-202830,-202798,-202767,-202735,-202703,-202671,-202639,-202607,-202575,-202543,-202511,-202480,-202448,-202416,-202384,-202352,-202320,-202288,-202256,-202224,-202192,-202160,-202128,-202096,-202064,-202032,-202000,-201968,-201936,-201904,-201872,-201840,-201807,-201775,-201743,-201711,-201679,-201647,-201615,-201583,-201551,-201518,-201486,-201454,-201422,-201390,-201358,-201325,-201293,-201261,-201229,-201197,-201164,-201132,-201100,-201068,-201035,-201003,-200971,-200939,-200906,-200874,-200842,-200809,-200777,-200745,-200712,-200680,-200648,-200615,-200583,-200551,-200518,-200486,-200453,-200421,-200389,-200356,-200324,-200291,-200259,-200227,-200194,-200162,-200129,-200097,-200064,-200032,-199999,-199967,-199934,-199902,-199869,-199837,-199804,-199772,-199739,-199707,-199674,-199641,-199609,-199576,-199544,-199511,-199478,-199446,-199413,-199381,-199348,-199315,-199283,-199250,-199217,-199185,-199152,-199119,-199087,-199054,-199021,-198988,-198956,-198923,-198890,-198857,-198825,-198792,-198759,-198726,-198694,-198661,-198628,-198595,-198562,-198530,-198497,-198464,-198431,-198398,-198365,-198333,-198300,-198267,-198234,-198201,-198168,-198135,-198102,-198069,-198036,-198003,-197971,-197938,-197905,-197872,-197839,-197806,-197773,-197740,-197707,-197674,-197641,-197608,-197575,-197542,-197509,-197475,-197442,-197409,-197376,-197343,-197310,-197277,-197244,-197211,-197178,-197145,-197111,-197078,-197045,-197012,-196979,-196946,-196912,-196879,-196846,-196813,-196780,-196746,-196713,-196680,-196647,-196614,-196580,-196547,-196514,-196480,-196447,-196414,-196381,-196347,-196314,-196281,-196247,-196214,-196181,-196147,-196114,-196081,-196047,-196014,-195981,-195947,-195914,-195880,-195847,-195814,-195780,-195747,-195713,-195680,-195646,-195613,-195579,-195546,-195512,-195479,-195445,-195412,-195378,-195345,-195311,-195278,-195244,-195211,-195177,-195144,-195110,-195077,-195043,-195009,-194976,-194942,-194909,-194875,-194841,-194808,-194774,-194740,-194707,-194673,-194639,-194606,-194572,-194538,-194505,-194471,-194437,-194404,-194370,-194336,-194302,-194269,-194235,-194201,-194167,-194134,-194100,-194066,-194032,-193998,-193965,-193931,-193897,-193863,-193829,-193795,-193762,-193728,-193694,-193660,-193626,-193592,-193558,-193524,-193491,-193457,-193423,-193389,-193355,-193321,-193287,-193253,-193219,-193185,-193151,-193117,-193083,-193049,-193015,-192981,-192947,-192913,-192879,-192845,-192811,-192777,-192743,-192709,-192675,-192640,-192606,-192572,-192538,-192504,-192470,-192436,-192402,-192368,-192333,-192299,-192265,-192231,-192197,-192163,-192128,-192094,-192060,-192026,-191991,-191957,-191923,-191889,-191855,-191820,-191786,-191752,-191717,-191683,-191649,-191615,-191580,-191546,-191512,-191477,-191443,-191409,-191374,-191340,-191306,-191271,-191237,-191202,-191168,-191134,-191099,-191065,-191030,-190996,-190962,-190927,-190893,-190858,-190824,-190789,-190755,-190720,-190686,-190651,-190617,-190582,-190548,-190513,-190479,-190444,-190410,-190375,-190341,-190306,-190271,-190237,-190202,-190168,-190133,-190098,-190064,-190029,-189995,-189960,-189925,-189891,-189856,-189821,-189787,-189752,-189717,-189683,-189648,-189613,-189579,-189544,-189509,-189474,-189440,-189405,-189370,-189335,-189301,-189266,-189231,-189196,-189161,-189127,-189092,-189057,-189022,-188987,-188953,-188918,-188883,-188848,-188813,-188778,-188743,-188708,-188674,-188639,-188604,-188569,-188534,-188499,-188464,-188429,-188394,-188359,-188324,-188289,-188254,-188219,-188184,-188149,-188114,-188079,-188044,-188009,-187974,-187939,-187904,-187869,-187834,-187799,-187764,-187729,-187694,-187659,-187624,-187588,-187553,-187518,-187483,-187448,-187413,-187378,-187342,-187307,-187272,-187237,-187202,-187167,-187131,-187096,-187061,-187026,-186991,-186955,-186920,-186885,-186850,-186814,-186779,-186744,-186709,-186673,-186638,-186603,-186567,-186532,-186497,-186461,-186426,-186391,-186355,-186320,-186285,-186249,-186214,-186178,-186143,-186108,-186072,-186037,-186001,-185966,-185931,-185895,-185860,-185824,-185789,-185753,-185718,-185682,-185647,-185611,-185576,-185540,-185505,-185469,-185434,-185398,-185363,-185327,-185292,-185256,-185221,-185185,-185149,-185114,-185078,-185043,-185007,-184971,-184936,-184900,-184865,-184829,-184793,-184758,-184722,-184686,-184651,-184615,-184579,-184544,-184508,-184472,-184436,-184401,-184365,-184329,-184293,-184258,-184222,-184186,-184150,-184115,-184079,-184043,-184007,-183971,-183936,-183900,-183864,-183828,-183792,-183756,-183721,-183685,-183649,-183613,-183577,-183541,-183505,-183469,-183434,-183398,-183362,-183326,-183290,-183254,-183218,-183182,-183146,-183110,-183074,-183038,-183002,-182966,-182930,-182894,-182858,-182822,-182786,-182750,-182714,-182678,-182642,-182606,-182570,-182534,-182498,-182462,-182425,-182389,-182353,-182317,-182281,-182245,-182209,-182173,-182136,-182100,-182064,-182028,-181992,-181956,-181919,-181883,-181847,-181811,-181775,-181738,-181702,-181666,-181630,-181593,-181557,-181521,-181485,-181448,-181412,-181376,-181340,-181303,-181267,-181231,-181194,-181158,-181122,-181085,-181049,-181013,-180976,-180940,-180903,-180867,-180831,-180794,-180758,-180722,-180685,-180649,-180612,-180576,-180539,-180503,-180466,-180430,-180394,-180357,-180321,-180284,-180248,-180211,-180175,-180138,-180102,-180065,-180028,-179992,-179955,-179919,-179882,-179846,-179809,-179773,-179736,-179699,-179663,-179626,-179590,-179553,-179516,-179480,-179443,-179406,-179370,-179333,-179296,-179260,-179223,-179186,-179150,-179113,-179076,-179040,-179003,-178966,-178929,-178893,-178856,-178819,-178782,-178746,-178709,-178672,-178635,-178599,-178562,-178525,-178488,-178451,-178414,-178378,-178341,-178304,-178267,-178230,-178193,-178157,-178120,-178083,-178046,-178009,-177972,-177935,-177898,-177861,-177824,-177787,-177751,-177714,-177677,-177640,-177603,-177566,-177529,-177492,-177455,-177418,-177381,-177344,-177307,-177270,-177233,-177196,-177159,-177122,-177084,-177047,-177010,-176973,-176936,-176899,-176862,-176825,-176788,-176751,-176713,-176676,-176639,-176602,-176565,-176528,-176491,-176453,-176416,-176379,-176342,-176305,-176267,-176230,-176193,-176156,-176119,-176081,-176044,-176007,-175970,-175932,-175895,-175858,-175821,-175783,-175746,-175709,-175671,-175634,-175597,-175559,-175522,-175485,-175447,-175410,-175373,-175335,-175298,-175261,-175223,-175186,-175148,-175111,-175074,-175036,-174999,-174961,-174924,-174886,-174849,-174812,-174774,-174737,-174699,-174662,-174624,-174587,-174549,-174512,-174474,-174437,-174399,-174362,-174324,-174287,-174249,-174211,-174174,-174136,-174099,-174061,-174024,-173986,-173948,-173911,-173873,-173836,-173798,-173760,-173723,-173685,-173647,-173610,-173572,-173534,-173497,-173459,-173421,-173384,-173346,-173308,-173270,-173233,-173195,-173157,-173120,-173082,-173044,-173006,-172968,-172931,-172893,-172855,-172817,-172780,-172742,-172704,-172666,-172628,-172590,-172553,-172515,-172477,-172439,-172401,-172363,-172325,-172288,-172250,-172212,-172174,-172136,-172098,-172060,-172022,-171984,-171946,-171908,-171870,-171833,-171795,-171757,-171719,-171681,-171643,-171605,-171567,-171529,-171491,-171453,-171415,-171377,-171338,-171300,-171262,-171224,-171186,-171148,-171110,-171072,-171034,-170996,-170958,-170920,-170882,-170843,-170805,-170767,-170729,-170691,-170653,-170615,-170576,-170538,-170500,-170462,-170424,-170385,-170347,-170309,-170271,-170233,-170194,-170156,-170118,-170080,-170041,-170003,-169965,-169927,-169888,-169850,-169812,-169773,-169735,-169697,-169659,-169620,-169582,-169544,-169505,-169467,-169429,-169390,-169352,-169313,-169275,-169237,-169198,-169160,-169121,-169083,-169045,-169006,-168968,-168929,-168891,-168852,-168814,-168776,-168737,-168699,-168660,-168622,-168583,-168545,-168506,-168468,-168429,-168391,-168352,-168314,-168275,-168237,-168198,-168159,-168121,-168082,-168044,-168005,-167967,-167928,-167889,-167851,-167812,-167773,-167735,-167696,-167658,-167619,-167580,-167542,-167503,-167464,-167426,-167387,-167348,-167310,-167271,-167232,-167193,-167155,-167116,-167077,-167039,-167000,-166961,-166922,-166884,-166845,-166806,-166767,-166728,-166690,-166651,-166612,-166573,-166534,-166496,-166457,-166418,-166379,-166340,-166301,-166263,-166224,-166185,-166146,-166107,-166068,-166029,-165990,-165951,-165913,-165874,-165835,-165796,-165757,-165718,-165679,-165640,-165601,-165562,-165523,-165484,-165445,-165406,-165367,-165328,-165289,-165250,-165211,-165172,-165133,-165094,-165055,-165016,-164977,-164938,-164899,-164860,-164820,-164781,-164742,-164703,-164664,-164625,-164586,-164547,-164508,-164468,-164429,-164390,-164351,-164312,-164273,-164233,-164194,-164155,-164116,-164077,-164038,-163998,-163959,-163920,-163881,-163841,-163802,-163763,-163724,-163684,-163645,-163606,-163567,-163527,-163488,-163449,-163409,-163370,-163331,-163291,-163252,-163213,-163173,-163134,-163095,-163055,-163016,-162977,-162937,-162898,-162859,-162819,-162780,-162740,-162701,-162662,-162622,-162583,-162543,-162504,-162464,-162425,-162385,-162346,-162307,-162267,-162228,-162188,-162149,-162109,-162070,-162030,-161991,-161951,-161912,-161872,-161832,-161793,-161753,-161714,-161674,-161635,-161595,-161556,-161516,-161476,-161437,-161397,-161358,-161318,-161278,-161239,-161199,-161159,-161120,-161080,-161040,-161001,-160961,-160921,-160882,-160842,-160802,-160763,-160723,-160683,-160643,-160604,-160564,-160524,-160485,-160445,-160405,-160365,-160326,-160286,-160246,-160206,-160166,-160127,-160087,-160047,-160007,-159967,-159928,-159888,-159848,-159808,-159768,-159728,-159688,-159649,-159609,-159569,-159529,-159489,-159449,-159409,-159369,-159329,-159290,-159250,-159210,-159170,-159130,-159090,-159050,-159010,-158970,-158930,-158890,-158850,-158810,-158770,-158730,-158690,-158650,-158610,-158570,-158530,-158490,-158450,-158410,-158370,-158330,-158290,-158250,-158210,-158169,-158129,-158089,-158049,-158009,-157969,-157929,-157889,-157849,-157808,-157768,-157728,-157688,-157648,-157608,-157568,-157527,-157487,-157447,-157407,-157367,-157326,-157286,-157246,-157206,-157166,-157125,-157085,-157045,-157005,-156964,-156924,-156884,-156844,-156803,-156763,-156723,-156682,-156642,-156602,-156561,-156521,-156481,-156440,-156400,-156360,-156319,-156279,-156239,-156198,-156158,-156118,-156077,-156037,-155996,-155956,-155916,-155875,-155835,-155794,-155754,-155714,-155673,-155633,-155592,-155552,-155511,-155471,-155430,-155390,-155349,-155309,-155268,-155228,-155187,-155147,-155106,-155066,-155025,-154985,-154944,-154904,-154863,-154823,-154782,-154741,-154701,-154660,-154620,-154579,-154538,-154498,-154457,-154417,-154376,-154335,-154295,-154254,-154213,-154173,-154132,-154092,-154051,-154010,-153969,-153929,-153888,-153847,-153807,-153766,-153725,-153685,-153644,-153603,-153562,-153522,-153481,-153440,-153399,-153359,-153318,-153277,-153236,-153196,-153155,-153114,-153073,-153032,-152992,-152951,-152910,-152869,-152828,-152787,-152747,-152706,-152665,-152624,-152583,-152542,-152501,-152460,-152420,-152379,-152338,-152297,-152256,-152215,-152174,-152133,-152092,-152051,-152010,-151969,-151928,-151887,-151846,-151805,-151764,-151723,-151682,-151641,-151600,-151559,-151518,-151477,-151436,-151395,-151354,-151313,-151272,-151231,-151190,-151149,-151108,-151067,-151026,-150985,-150944,-150903,-150861,-150820,-150779,-150738,-150697,-150656,-150615,-150574,-150532,-150491,-150450,-150409,-150368,-150327,-150285,-150244,-150203,-150162,-150121,-150079,-150038,-149997,-149956,-149915,-149873,-149832,-149791,-149750,-149708,-149667,-149626,-149584,-149543,-149502,-149461,-149419,-149378,-149337,-149295,-149254,-149213,-149171,-149130,-149089,-149047,-149006,-148965,-148923,-148882,-148841,-148799,-148758,-148716,-148675,-148634,-148592,-148551,-148509,-148468,-148427,-148385,-148344,-148302,-148261,-148219,-148178,-148136,-148095,-148053,-148012,-147970,-147929,-147887,-147846,-147804,-147763,-147721,-147680,-147638,-147597,-147555,-147514,-147472,-147431,-147389,-147347,-147306,-147264,-147223,-147181,-147140,-147098,-147056,-147015,-146973,-146931,-146890,-146848,-146807,-146765,-146723,-146682,-146640,-146598,-146557,-146515,-146473,-146432,-146390,-146348,-146306,-146265,-146223,-146181,-146140,-146098,-146056,-146014,-145973,-145931,-145889,-145847,-145806,-145764,-145722,-145680,-145638,-145597,-145555,-145513,-145471,-145429,-145388,-145346,-145304,-145262,-145220,-145178,-145136,-145095,-145053,-145011,-144969,-144927,-144885,-144843,-144801,-144760,-144718,-144676,-144634,-144592,-144550,-144508,-144466,-144424,-144382,-144340,-144298,-144256,-144214,-144172,-144130,-144088,-144046,-144004,-143962,-143920,-143878,-143836,-143794,-143752,-143710,-143668,-143626,-143584,-143542,-143500,-143458,-143416,-143374,-143332,-143290,-143247,-143205,-143163,-143121,-143079,-143037,-142995,-142953,-142911,-142868,-142826,-142784,-142742,-142700,-142658,-142615,-142573,-142531,-142489,-142447,-142404,-142362,-142320,-142278,-142236,-142193,-142151,-142109,-142067,-142024,-141982,-141940,-141898,-141855,-141813,-141771,-141729,-141686,-141644,-141602,-141559,-141517,-141475,-141432,-141390,-141348,-141305,-141263,-141221,-141178,-141136,-141094,-141051,-141009,-140967,-140924,-140882,-140839,-140797,-140755,-140712,-140670,-140627,-140585,-140543,-140500,-140458,-140415,-140373,-140330,-140288,-140245,-140203,-140160,-140118,-140076,-140033,-139991,-139948,-139906,-139863,-139820,-139778,-139735,-139693,-139650,-139608,-139565,-139523,-139480,-139438,-139395,-139352,-139310,-139267,-139225,-139182,-139140,-139097,-139054,-139012,-138969,-138926,-138884,-138841,-138799,-138756,-138713,-138671,-138628,-138585,-138543,-138500,-138457,-138415,-138372,-138329,-138287,-138244,-138201,-138158,-138116,-138073,-138030,-137987,-137945,-137902,-137859,-137816,-137774,-137731,-137688,-137645,-137603,-137560,-137517,-137474,-137431,-137389,-137346,-137303,-137260,-137217,-137175,-137132,-137089,-137046,-137003,-136960,-136917,-136875,-136832,-136789,-136746,-136703,-136660,-136617,-136574,-136531,-136489,-136446,-136403,-136360,-136317,-136274,-136231,-136188,-136145,-136102,-136059,-136016,-135973,-135930,-135887,-135844,-135801,-135758,-135715,-135672,-135629,-135586,-135543,-135500,-135457,-135414,-135371,-135328,-135285,-135242,-135199,-135156,-135113,-135070,-135027,-134983,-134940,-134897,-134854,-134811,-134768,-134725,-134682,-134639,-134595,-134552,-134509,-134466,-134423,-134380,-134337,-134293,-134250,-134207,-134164,-134121,-134077,-134034,-133991,-133948,-133905,-133861,-133818,-133775,-133732,-133689,-133645,-133602,-133559,-133516,-133472,-133429,-133386,-133342,-133299,-133256,-133213,-133169,-133126,-133083,-133039,-132996,-132953,-132909,-132866,-132823,-132779,-132736,-132693,-132649,-132606,-132563,-132519,-132476,-132433,-132389,-132346,-132302,-132259,-132216,-132172,-132129,-132085,-132042,-131999,-131955,-131912,-131868,-131825,-131781,-131738,-131694,-131651,-131608,-131564,-131521,-131477,-131434,-131390,-131347,-131303,-131260,-131216,-131173,-131129,-131086,-131042,-130998,-130955,-130911,-130868,-130824,-130781,-130737,-130694,-130650,-130606,-130563,-130519,-130476,-130432,-130388,-130345,-130301,-130258,-130214,-130170,-130127,-130083,-130039,-129996,-129952,-129908,-129865,-129821,-129777,-129734,-129690,-129646,-129603,-129559,-129515,-129472,-129428,-129384,-129340,-129297,-129253,-129209,-129166,-129122,-129078,-129034,-128991,-128947,-128903,-128859,-128815,-128772,-128728,-128684,-128640,-128597,-128553,-128509,-128465,-128421,-128377,-128334,-128290,-128246,-128202,-128158,-128114,-128071,-128027,-127983,-127939,-127895,-127851,-127807,-127763,-127720,-127676,-127632,-127588,-127544,-127500,-127456,-127412,-127368,-127324,-127280,-127236,-127192,-127149,-127105,-127061,-127017,-126973,-126929,-126885,-126841,-126797,-126753,-126709,-126665,-126621,-126577,-126533,-126489,-126445,-126401,-126357,-126313,-126268,-126224,-126180,-126136,-126092,-126048,-126004,-125960,-125916,-125872,-125828,-125784,-125740,-125695,-125651,-125607,-125563,-125519,-125475,-125431,-125387,-125342,-125298,-125254,-125210,-125166,-125122,-125077,-125033,-124989,-124945,-124901,-124856,-124812,-124768,-124724,-124680,-124635,-124591,-124547,-124503,-124459,-124414,-124370,-124326,-124282,-124237,-124193,-124149,-124104,-124060,-124016,-123972,-123927,-123883,-123839,-123794,-123750,-123706,-123661,-123617,-123573,-123528,-123484,-123440,-123395,-123351,-123307,-123262,-123218,-123174,-123129,-123085,-123041,-122996,-122952,-122907,-122863,-122819,-122774,-122730,-122685,-122641,-122596,-122552,-122508,-122463,-122419,-122374,-122330,-122285,-122241,-122196,-122152,-122107,-122063,-122018,-121974,-121930,-121885,-121841,-121796,-121751,-121707,-121662,-121618,-121573,-121529,-121484,-121440,-121395,-121351,-121306,-121262,-121217,-121172,-121128,-121083,-121039,-120994,-120949,-120905,-120860,-120816,-120771,-120726,-120682,-120637,-120593,-120548,-120503,-120459,-120414,-120369,-120325,-120280,-120235,-120191,-120146,-120101,-120057,-120012,-119967,-119923,-119878,-119833,-119789,-119744,-119699,-119654,-119610,-119565,-119520,-119475,-119431,-119386,-119341,-119296,-119252,-119207,-119162,-119117,-119073,-119028,-118983,-118938,-118893,-118849,-118804,-118759,-118714,-118669,-118625,-118580,-118535,-118490,-118445,-118400,-118356,-118311,-118266,-118221,-118176,-118131,-118086,-118041,-117997,-117952,-117907,-117862,-117817,-117772,-117727,-117682,-117637,-117592,-117548,-117503,-117458,-117413,-117368,-117323,-117278,-117233,-117188,-117143,-117098,-117053,-117008,-116963,-116918,-116873,-116828,-116783,-116738,-116693,-116648,-116603,-116558,-116513,-116468,-116423,-116378,-116333,-116288,-116243,-116198,-116153,-116108,-116063,-116017,-115972,-115927,-115882,-115837,-115792,-115747,-115702,-115657,-115612,-115566,-115521,-115476,-115431,-115386,-115341,-115296,-115251,-115205,-115160,-115115,-115070,-115025,-114980,-114934,-114889,-114844,-114799,-114754,-114709,-114663,-114618,-114573,-114528,-114482,-114437,-114392,-114347,-114302,-114256,-114211,-114166,-114121,-114075,-114030,-113985,-113940,-113894,-113849,-113804,-113758,-113713,-113668,-113623,-113577,-113532,-113487,-113441,-113396,-113351,-113305,-113260,-113215,-113169,-113124,-113079,-113033,-112988,-112943,-112897,-112852,-112807,-112761,-112716,-112670,-112625,-112580,-112534,-112489,-112443,-112398,-112353,-112307,-112262,-112216,-112171,-112125,-112080,-112035,-111989,-111944,-111898,-111853,-111807,-111762,-111716,-111671,-111625,-111580,-111534,-111489,-111443,-111398,-111352,-111307,-111261,-111216,-111170,-111125,-111079,-111034,-110988,-110943,-110897,-110852,-110806,-110761,-110715,-110669,-110624,-110578,-110533,-110487,-110442,-110396,-110350,-110305,-110259,-110214,-110168,-110122,-110077,-110031,-109985,-109940,-109894,-109849,-109803,-109757,-109712,-109666,-109620,-109575,-109529,-109483,-109438,-109392,-109346,-109301,-109255,-109209,-109164,-109118,-109072,-109026,-108981,-108935,-108889,-108844,-108798,-108752,-108706,-108661,-108615,-108569,-108523,-108478,-108432,-108386,-108340,-108294,-108249,-108203,-108157,-108111,-108066,-108020,-107974,-107928,-107882,-107837,-107791,-107745,-107699,-107653,-107607,-107562,-107516,-107470,-107424,-107378,-107332,-107286,-107241,-107195,-107149,-107103,-107057,-107011,-106965,-106919,-106874,-106828,-106782,-106736,-106690,-106644,-106598,-106552,-106506,-106460,-106414,-106368,-106322,-106277,-106231,-106185,-106139,-106093,-106047,-106001,-105955,-105909,-105863,-105817,-105771,-105725,-105679,-105633,-105587,-105541,-105495,-105449,-105403,-105357,-105311,-105265,-105219,-105173,-105127,-105081,-105034,-104988,-104942,-104896,-104850,-104804,-104758,-104712,-104666,-104620,-104574,-104528,-104482,-104435,-104389,-104343,-104297,-104251,-104205,-104159,-104113,-104066,-104020,-103974,-103928,-103882,-103836,-103790,-103743,-103697,-103651,-103605,-103559,-103513,-103466,-103420,-103374,-103328,-103282,-103235,-103189,-103143,-103097,-103051,-103004,-102958,-102912,-102866,-102819,-102773,-102727,-102681,-102634,-102588,-102542,-102496,-102449,-102403,-102357,-102311,-102264,-102218,-102172,-102125,-102079,-102033,-101987,-101940,-101894,-101848,-101801,-101755,-101709,-101662,-101616,-101570,-101523,-101477,-101431,-101384,-101338,-101292,-101245,-101199,-101152,-101106,-101060,-101013,-100967,-100921,-100874,-100828,-100781,-100735,-100689,-100642,-100596,-100549,-100503,-100456,-100410,-100364,-100317,-100271,-100224,-100178,-100131,-100085,-100038,-99992,-99946,-99899,-99853,-99806,-99760,-99713,-99667,-99620,-99574,-99527,-99481,-99434,-99388,-99341,-99295,-99248,-99202,-99155,-99109,-99062,-99015,-98969,-98922,-98876,-98829,-98783,-98736,-98690,-98643,-98596,-98550,-98503,-98457,-98410,-98363,-98317,-98270,-98224,-98177,-98130,-98084,-98037,-97991,-97944,-97897,-97851,-97804,-97757,-97711,-97664,-97618,-97571,-97524,-97478,-97431,-97384,-97338,-97291,-97244,-97198,-97151,-97104,-97057,-97011,-96964,-96917,-96871,-96824,-96777,-96731,-96684,-96637,-96590,-96544,-96497,-96450,-96403,-96357,-96310,-96263,-96216,-96170,-96123,-96076,-96029,-95983,-95936,-95889,-95842,-95795,-95749,-95702,-95655,-95608,-95561,-95515,-95468,-95421,-95374,-95327,-95281,-95234,-95187,-95140,-95093,-95046,-95000,-94953,-94906,-94859,-94812,-94765,-94718,-94672,-94625,-94578,-94531,-94484,-94437,-94390,-94343,-94296,-94250,-94203,-94156,-94109,-94062,-94015,-93968,-93921,-93874,-93827,-93780,-93733,-93686,-93639,-93593,-93546,-93499,-93452,-93405,-93358,-93311,-93264,-93217,-93170,-93123,-93076,-93029,-92982,-92935,-92888,-92841,-92794,-92747,-92700,-92653,-92606,-92559,-92512,-92465,-92418,-92371,-92324,-92277,-92229,-92182,-92135,-92088,-92041,-91994,-91947,-91900,-91853,-91806,-91759,-91712,-91665,-91618,-91570,-91523,-91476,-91429,-91382,-91335,-91288,-91241,-91194,-91146,-91099,-91052,-91005,-90958,-90911,-90864,-90816,-90769,-90722,-90675,-90628,-90581,-90533,-90486,-90439,-90392,-90345,-90298,-90250,-90203,-90156,-90109,-90062,-90014,-89967,-89920,-89873,-89825,-89778,-89731,-89684,-89637,-89589,-89542,-89495,-89448,-89400,-89353,-89306,-89259,-89211,-89164,-89117,-89069,-89022,-88975,-88928,-88880,-88833,-88786,-88738,-88691,-88644,-88597,-88549,-88502,-88455,-88407,-88360,-88313,-88265,-88218,-88171,-88123,-88076,-88029,-87981,-87934,-87887,-87839,-87792,-87744,-87697,-87650,-87602,-87555,-87508,-87460,-87413,-87365,-87318,-87271,-87223,-87176,-87128,-87081,-87034,-86986,-86939,-86891,-86844,-86797,-86749,-86702,-86654,-86607,-86559,-86512,-86464,-86417,-86370,-86322,-86275,-86227,-86180,-86132,-86085,-86037,-85990,-85942,-85895,-85847,-85800,-85752,-85705,-85657,-85610,-85562,-85515,-85467,-85420,-85372,-85325,-85277,-85230,-85182,-85135,-85087,-85039,-84992,-84944,-84897,-84849,-84802,-84754,-84707,-84659,-84611,-84564,-84516,-84469,-84421,-84373,-84326,-84278,-84231,-84183,-84135,-84088,-84040,-83993,-83945,-83897,-83850,-83802,-83755,-83707,-83659,-83612,-83564,-83516,-83469,-83421,-83373,-83326,-83278,-83230,-83183,-83135,-83087,-83040,-82992,-82944,-82897,-82849,-82801,-82754,-82706,-82658,-82611,-82563,-82515,-82467,-82420,-82372,-82324,-82277,-82229,-82181,-82133,-82086,-82038,-81990,-81942,-81895,-81847,-81799,-81751,-81704,-81656,-81608,-81560,-81513,-81465,-81417,-81369,-81321,-81274,-81226,-81178,-81130,-81082,-81035,-80987,-80939,-80891,-80843,-80796,-80748,-80700,-80652,-80604,-80556,-80509,-80461,-80413,-80365,-80317,-80269,-80222,-80174,-80126,-80078,-80030,-79982,-79934,-79886,-79839,-79791,-79743,-79695,-79647,-79599,-79551,-79503,-79456,-79408,-79360,-79312,-79264,-79216,-79168,-79120,-79072,-79024,-78976,-78928,-78880,-78833,-78785,-78737,-78689,-78641,-78593,-78545,-78497,-78449,-78401,-78353,-78305,-78257,-78209,-78161,-78113,-78065,-78017,-77969,-77921,-77873,-77825,-77777,-77729,-77681,-77633,-77585,-77537,-77489,-77441,-77393,-77345,-77297,-77249,-77201,-77153,-77105,-77057,-77009,-76961,-76913,-76865,-76817,-76769,-76720,-76672,-76624,-76576,-76528,-76480,-76432,-76384,-76336,-76288,-76240,-76192,-76143,-76095,-76047,-75999,-75951,-75903,-75855,-75807,-75759,-75710,-75662,-75614,-75566,-75518,-75470,-75422,-75374,-75325,-75277,-75229,-75181,-75133,-75085,-75036,-74988,-74940,-74892,-74844,-74796,-74747,-74699,-74651,-74603,-74555,-74507,-74458,-74410,-74362,-74314,-74266,-74217,-74169,-74121,-74073,-74024,-73976,-73928,-73880,-73832,-73783,-73735,-73687,-73639,-73590,-73542,-73494,-73446,-73397,-73349,-73301,-73253,-73204,-73156,-73108,-73060,-73011,-72963,-72915,-72866,-72818,-72770,-72722,-72673,-72625,-72577,-72528,-72480,-72432,-72383,-72335,-72287,-72238,-72190,-72142,-72094,-72045,-71997,-71949,-71900,-71852,-71804,-71755,-71707,-71658,-71610,-71562,-71513,-71465,-71417,-71368,-71320,-71272,-71223,-71175,-71126,-71078,-71030,-70981,-70933,-70885,-70836,-70788,-70739,-70691,-70643,-70594,-70546,-70497,-70449,-70400,-70352,-70304,-70255,-70207,-70158,-70110,-70061,-70013,-69965,-69916,-69868,-69819,-69771,-69722,-69674,-69625,-69577,-69529,-69480,-69432,-69383,-69335,-69286,-69238,-69189,-69141,-69092,-69044,-68995,-68947,-68898,-68850,-68801,-68753,-68704,-68656,-68607,-68559,-68510,-68462,-68413,-68365,-68316,-68268,-68219,-68170,-68122,-68073,-68025,-67976,-67928,-67879,-67831,-67782,-67734,-67685,-67636,-67588,-67539,-67491,-67442,-67394,-67345,-67296,-67248,-67199,-67151,-67102,-67054,-67005,-66956,-66908,-66859,-66811,-66762,-66713,-66665,-66616,-66567,-66519,-66470,-66422,-66373,-66324,-66276,-66227,-66178,-66130,-66081,-66033,-65984,-65935,-65887,-65838,-65789,-65741,-65692,-65643,-65595,-65546,-65497,-65449,-65400,-65351,-65303,-65254,-65205,-65157,-65108,-65059,-65010,-64962,-64913,-64864,-64816,-64767,-64718,-64670,-64621,-64572,-64523,-64475,-64426,-64377,-64328,-64280,-64231,-64182,-64134,-64085,-64036,-63987,-63939,-63890,-63841,-63792,-63744,-63695,-63646,-63597,-63549,-63500,-63451,-63402,-63353,-63305,-63256,-63207,-63158,-63110,-63061,-63012,-62963,-62914,-62866,-62817,-62768,-62719,-62670,-62622,-62573,-62524,-62475,-62426,-62377,-62329,-62280,-62231,-62182,-62133,-62084,-62036,-61987,-61938,-61889,-61840,-61791,-61743,-61694,-61645,-61596,-61547,-61498,-61449,-61401,-61352,-61303,-61254,-61205,-61156,-61107,-61058,-61010,-60961,-60912,-60863,-60814,-60765,-60716,-60667,-60618,-60569,-60521,-60472,-60423,-60374,-60325,-60276,-60227,-60178,-60129,-60080,-60031,-59982,-59934,-59885,-59836,-59787,-59738,-59689,-59640,-59591,-59542,-59493,-59444,-59395,-59346,-59297,-59248,-59199,-59150,-59101,-59052,-59003,-58954,-58905,-58856,-58807,-58758,-58710,-58661,-58612,-58563,-58514,-58465,-58416,-58367,-58318,-58269,-58220,-58170,-58121,-58072,-58023,-57974,-57925,-57876,-57827,-57778,-57729,-57680,-57631,-57582,-57533,-57484,-57435,-57386,-57337,-57288,-57239,-57190,-57141,-57092,-57043,-56994,-56945,-56895,-56846,-56797,-56748,-56699,-56650,-56601,-56552,-56503,-56454,-56405,-56356,-56307,-56257,-56208,-56159,-56110,-56061,-56012,-55963,-55914,-55865,-55815,-55766,-55717,-55668,-55619,-55570,-55521,-55472,-55423,-55373,-55324,-55275,-55226,-55177,-55128,-55079,-55029,-54980,-54931,-54882,-54833,-54784,-54735,-54685,-54636,-54587,-54538,-54489,-54440,-54390,-54341,-54292,-54243,-54194,-54144,-54095,-54046,-53997,-53948,-53899,-53849,-53800,-53751,-53702,-53653,-53603,-53554,-53505,-53456,-53407,-53357,-53308,-53259,-53210,-53160,-53111,-53062,-53013,-52964,-52914,-52865,-52816,-52767,-52717,-52668,-52619,-52570,-52520,-52471,-52422,-52373,-52323,-52274,-52225,-52176,-52126,-52077,-52028,-51979,-51929,-51880,-51831,-51781,-51732,-51683,-51634,-51584,-51535,-51486,-51437,-51387,-51338,-51289,-51239,-51190,-51141,-51091,-51042,-50993,-50944,-50894,-50845,-50796,-50746,-50697,-50648,-50598,-50549,-50500,-50450,-50401,-50352,-50302,-50253,-50204,-50154,-50105,-50056,-50006,-49957,-49908,-49858,-49809,-49760,-49710,-49661,-49612,-49562,-49513,-49463,-49414,-49365,-49315,-49266,-49217,-49167,-49118,-49069,-49019,-48970,-48920,-48871,-48822,-48772,-48723,-48673,-48624,-48575,-48525,-48476,-48426,-48377,-48328,-48278,-48229,-48179,-48130,-48081,-48031,-47982,-47932,-47883,-47834,-47784,-47735,-47685,-47636,-47586,-47537,-47488,-47438,-47389,-47339,-47290,-47240,-47191,-47141,-47092,-47043,-46993,-46944,-46894,-46845,-46795,-46746,-46696,-46647,-46597,-46548,-46499,-46449,-46400,-46350,-46301,-46251,-46202,-46152,-46103,-46053,-46004,-45954,-45905,-45855,-45806,-45756,-45707,-45657,-45608,-45558,-45509,-45459,-45410,-45360,-45311,-45261,-45212,-45162,-45113,-45063,-45014,-44964,-44915,-44865,-44816,-44766,-44717,-44667,-44618,-44568,-44518,-44469,-44419,-44370,-44320,-44271,-44221,-44172,-44122,-44073,-44023,-43973,-43924,-43874,-43825,-43775,-43726,-43676,-43627,-43577,-43527,-43478,-43428,-43379,-43329,-43280,-43230,-43180,-43131,-43081,-43032,-42982,-42932,-42883,-42833,-42784,-42734,-42685,-42635,-42585,-42536,-42486,-42437,-42387,-42337,-42288,-42238,-42189,-42139,-42089,-42040,-41990,-41940,-41891,-41841,-41792,-41742,-41692,-41643,-41593,-41543,-41494,-41444,-41395,-41345,-41295,-41246,-41196,-41146,-41097,-41047,-40997,-40948,-40898,-40848,-40799,-40749,-40700,-40650,-40600,-40551,-40501,-40451,-40402,-40352,-40302,-40253,-40203,-40153,-40104,-40054,-40004,-39955,-39905,-39855,-39805,-39756,-39706,-39656,-39607,-39557,-39507,-39458,-39408,-39358,-39309,-39259,-39209,-39159,-39110,-39060,-39010,-38961,-38911,-38861,-38812,-38762,-38712,-38662,-38613,-38563,-38513,-38464,-38414,-38364,-38314,-38265,-38215,-38165,-38115,-38066,-38016,-37966,-37916,-37867,-37817,-37767,-37718,-37668,-37618,-37568,-37519,-37469,-37419,-37369,-37320,-37270,-37220,-37170,-37121,-37071,-37021,-36971,-36921,-36872,-36822,-36772,-36722,-36673,-36623,-36573,-36523,-36474,-36424,-36374,-36324,-36274,-36225,-36175,-36125,-36075,-36026,-35976,-35926,-35876,-35826,-35777,-35727,-35677,-35627,-35577,-35528,-35478,-35428,-35378,-35328,-35279,-35229,-35179,-35129,-35079,-35029,-34980,-34930,-34880,-34830,-34780,-34731,-34681,-34631,-34581,-34531,-34481,-34432,-34382,-34332,-34282,-34232,-34182,-34133,-34083,-34033,-33983,-33933,-33883,-33834,-33784,-33734,-33684,-33634,-33584,-33534,-33485,-33435,-33385,-33335,-33285,-33235,-33185,-33136,-33086,-33036,-32986,-32936,-32886,-32836,-32787,-32737,-32687,-32637,-32587,-32537,-32487,-32437,-32388,-32338,-32288,-32238,-32188,-32138,-32088,-32038,-31988,-31939,-31889,-31839,-31789,-31739,-31689,-31639,-31589,-31539,-31489,-31440,-31390,-31340,-31290,-31240,-31190,-31140,-31090,-31040,-30990,-30941,-30891,-30841,-30791,-30741,-30691,-30641,-30591,-30541,-30491,-30441,-30391,-30341,-30292,-30242,-30192,-30142,-30092,-30042,-29992,-29942,-29892,-29842,-29792,-29742,-29692,-29642,-29592,-29542,-29493,-29443,-29393,-29343,-29293,-29243,-29193,-29143,-29093,-29043,-28993,-28943,-28893,-28843,-28793,-28743,-28693,-28643,-28593,-28543,-28493,-28443,-28393,-28343,-28294,-28244,-28194,-28144,-28094,-28044,-27994,-27944,-27894,-27844,-27794,-27744,-27694,-27644,-27594,-27544,-27494,-27444,-27394,-27344,-27294,-27244,-27194,-27144,-27094,-27044,-26994,-26944,-26894,-26844,-26794,-26744,-26694,-26644,-26594,-26544,-26494,-26444,-26394,-26344,-26294,-26244,-26194,-26144,-26094,-26044,-25994,-25944,-25894,-25844,-25794,-25744,-25694,-25644,-25594,-25544,-25494,-25443,-25393,-25343,-25293,-25243,-25193,-25143,-25093,-25043,-24993,-24943,-24893,-24843,-24793,-24743,-24693,-24643,-24593,-24543,-24493,-24443,-24393,-24343,-24293,-24243,-24192,-24142,-24092,-24042,-23992,-23942,-23892,-23842,-23792,-23742,-23692,-23642,-23592,-23542,-23492,-23442,-23392,-23341,-23291,-23241,-23191,-23141,-23091,-23041,-22991,-22941,-22891,-22841,-22791,-22741,-22691,-22640,-22590,-22540,-22490,-22440,-22390,-22340,-22290,-22240,-22190,-22140,-22090,-22039,-21989,-21939,-21889,-21839,-21789,-21739,-21689,-21639,-21589,-21539,-21488,-21438,-21388,-21338,-21288,-21238,-21188,-21138,-21088,-21038,-20987,-20937,-20887,-20837,-20787,-20737,-20687,-20637,-20587,-20537,-20486,-20436,-20386,-20336,-20286,-20236,-20186,-20136,-20085,-20035,-19985,-19935,-19885,-19835,-19785,-19735,-19685,-19634,-19584,-19534,-19484,-19434,-19384,-19334,-19284,-19233,-19183,-19133,-19083,-19033,-18983,-18933,-18882,-18832,-18782,-18732,-18682,-18632,-18582,-18531,-18481,-18431,-18381,-18331,-18281,-18231,-18180,-18130,-18080,-18030,-17980,-17930,-17880,-17829,-17779,-17729,-17679,-17629,-17579,-17529,-17478,-17428,-17378,-17328,-17278,-17228,-17177,-17127,-17077,-17027,-16977,-16927,-16877,-16826,-16776,-16726,-16676,-16626,-16576,-16525,-16475,-16425,-16375,-16325,-16275,-16224,-16174,-16124,-16074,-16024,-15974,-15923,-15873,-15823,-15773,-15723,-15672,-15622,-15572,-15522,-15472,-15422,-15371,-15321,-15271,-15221,-15171,-15121,-15070,-15020,-14970,-14920,-14870,-14819,-14769,-14719,-14669,-14619,-14568,-14518,-14468,-14418,-14368,-14318,-14267,-14217,-14167,-14117,-14067,-14016,-13966,-13916,-13866,-13816,-13765,-13715,-13665,-13615,-13565,-13514,-13464,-13414,-13364,-13314,-13263,-13213,-13163,-13113,-13063,-13012,-12962,-12912,-12862,-12812,-12761,-12711,-12661,-12611,-12561,-12510,-12460,-12410,-12360,-12310,-12259,-12209,-12159,-12109,-12058,-12008,-11958,-11908,-11858,-11807,-11757,-11707,-11657,-11607,-11556,-11506,-11456,-11406,-11355,-11305,-11255,-11205,-11155,-11104,-11054,-11004,-10954,-10903,-10853,-10803,-10753,-10703,-10652,-10602,-10552,-10502,-10451,-10401,-10351,-10301,-10251,-10200,-10150,-10100,-10050,-9999,-9949,-9899,-9849,-9798,-9748,-9698,-9648,-9598,-9547,-9497,-9447,-9397,-9346,-9296,-9246,-9196,-9145,-9095,-9045,-8995,-8945,-8894,-8844,-8794,-8744,-8693,-8643,-8593,-8543,-8492,-8442,-8392,-8342,-8291,-8241,-8191,-8141,-8090,-8040,-7990,-7940,-7889,-7839,-7789,-7739,-7689,-7638,-7588,-7538,-7488,-7437,-7387,-7337,-7287,-7236,-7186,-7136,-7086,-7035,-6985,-6935,-6885,-6834,-6784,-6734,-6684,-6633,-6583,-6533,-6483,-6432,-6382,-6332,-6282,-6231,-6181,-6131,-6081,-6030,-5980,-5930,-5880,-5829,-5779,-5729,-5679,-5628,-5578,-5528,-5478,-5427,-5377,-5327,-5277,-5226,-5176,-5126,-5075,-5025,-4975,-4925,-4874,-4824,-4774,-4724,-4673,-4623,-4573,-4523,-4472,-4422,-4372,-4322,-4271,-4221,-4171,-4121,-4070,-4020,-3970,-3920,-3869,-3819,-3769,-3719,-3668,-3618,-3568,-3517,-3467,-3417,-3367,-3316,-3266,-3216,-3166,-3115,-3065,-3015,-2965,-2914,-2864,-2814,-2764,-2713,-2663,-2613,-2562,-2512,-2462,-2412,-2361,-2311,-2261,-2211,-2160,-2110,-2060,-2010,-1959,-1909,-1859,-1809,-1758,-1708,-1658,-1607,-1557,-1507,-1457,-1406,-1356,-1306,-1256,-1205,-1155,-1105,-1055,-1004,-954,-904,-854,-803,-753,-703,-652,-602,-552,-502,-451,-401,-351,-301,-250,-200,-150,-100,-49,0,50,101,151,201,251,302,352,402,452,503,553,603,653,704,754,804,855,905,955,1005,1056,1106,1156,1206,1257,1307,1357,1407,1458,1508,1558,1608,1659,1709,1759,1810,1860,1910,1960,2011,2061,2111,2161,2212,2262,2312,2362,2413,2463,2513,2563,2614,2664,2714,2765,2815,2865,2915,2966,3016,3066,3116,3167,3217,3267,3317,3368,3418,3468,3518,3569,3619,3669,3720,3770,3820,3870,3921,3971,4021,4071,4122,4172,4222,4272,4323,4373,4423,4473,4524,4574,4624,4674,4725,4775,4825,4875,4926,4976,5026,5076,5127,5177,5227,5278,5328,5378,5428,5479,5529,5579,5629,5680,5730,5780,5830,5881,5931,5981,6031,6082,6132,6182,6232,6283,6333,6383,6433,6484,6534,6584,6634,6685,6735,6785,6835,6886,6936,6986,7036,7087,7137,7187,7237,7288,7338,7388,7438,7489,7539,7589,7639,7690,7740,7790,7840,7890,7941,7991,8041,8091,8142,8192,8242,8292,8343,8393,8443,8493,8544,8594,8644,8694,8745,8795,8845,8895,8946,8996,9046,9096,9146,9197,9247,9297,9347,9398,9448,9498,9548,9599,9649,9699,9749,9799,9850,9900,9950,10000,10051,10101,10151,10201,10252,10302,10352,10402,10452,10503,10553,10603,10653,10704,10754,10804,10854,10904,10955,11005,11055,11105,11156,11206,11256,11306,11356,11407,11457,11507,11557,11608,11658,11708,11758,11808,11859,11909,11959,12009,12059,12110,12160,12210,12260,12311,12361,12411,12461,12511,12562,12612,12662,12712,12762,12813,12863,12913,12963,13013,13064,13114,13164,13214,13264,13315,13365,13415,13465,13515,13566,13616,13666,13716,13766,13817,13867,13917,13967,14017,14068,14118,14168,14218,14268,14319,14369,14419,14469,14519,14569,14620,14670,14720,14770,14820,14871,14921,14971,15021,15071,15122,15172,15222,15272,15322,15372,15423,15473,15523,15573,15623,15673,15724,15774,15824,15874,15924,15975,16025,16075,16125,16175,16225,16276,16326,16376,16426,16476,16526,16577,16627,16677,16727,16777,16827,16878,16928,16978,17028,17078,17128,17178,17229,17279,17329,17379,17429,17479,17530,17580,17630,17680,17730,17780,17830,17881,17931,17981,18031,18081,18131,18181,18232,18282,18332,18382,18432,18482,18532,18583,18633,18683,18733,18783,18833,18883,18934,18984,19034,19084,19134,19184,19234,19285,19335,19385,19435,19485,19535,19585,19635,19686,19736,19786,19836,19886,19936,19986,20036,20086,20137,20187,20237,20287,20337,20387,20437,20487,20538,20588,20638,20688,20738,20788,20838,20888,20938,20988,21039,21089,21139,21189,21239,21289,21339,21389,21439,21489,21540,21590,21640,21690,21740,21790,21840,21890,21940,21990,22040,22091,22141,22191,22241,22291,22341,22391,22441,22491,22541,22591,22641,22692,22742,22792,22842,22892,22942,22992,23042,23092,23142,23192,23242,23292,23342,23393,23443,23493,23543,23593,23643,23693,23743,23793,23843,23893,23943,23993,24043,24093,24143,24193,24244,24294,24344,24394,24444,24494,24544,24594,24644,24694,24744,24794,24844,24894,24944,24994,25044,25094,25144,25194,25244,25294,25344,25394,25444,25495,25545,25595,25645,25695,25745,25795,25845,25895,25945,25995,26045,26095,26145,26195,26245,26295,26345,26395,26445,26495,26545,26595,26645,26695,26745,26795,26845,26895,26945,26995,27045,27095,27145,27195,27245,27295,27345,27395,27445,27495,27545,27595,27645,27695,27745,27795,27845,27895,27945,27995,28045,28095,28145,28195,28245,28295,28344,28394,28444,28494,28544,28594,28644,28694,28744,28794,28844,28894,28944,28994,29044,29094,29144,29194,29244,29294,29344,29394,29444,29494,29543,29593,29643,29693,29743,29793,29843,29893,29943,29993,30043,30093,30143,30193,30243,30293,30342,30392,30442,30492,30542,30592,30642,30692,30742,30792,30842,30892,30942,30991,31041,31091,31141,31191,31241,31291,31341,31391,31441,31490,31540,31590,31640,31690,31740,31790,31840,31890,31940,31989,32039,32089,32139,32189,32239,32289,32339,32389,32438,32488,32538,32588,32638,32688,32738,32788,32837,32887,32937,32987,33037,33087,33137,33186,33236,33286,33336,33386,33436,33486,33535,33585,33635,33685,33735,33785,33835,33884,33934,33984,34034,34084,34134,34183,34233,34283,34333,34383,34433,34482,34532,34582,34632,34682,34732,34781,34831,34881,34931,34981,35030,35080,35130,35180,35230,35280,35329,35379,35429,35479,35529,35578,35628,35678,35728,35778,35827,35877,35927,35977,36027,36076,36126,36176,36226,36275,36325,36375,36425,36475,36524,36574,36624,36674,36723,36773,36823,36873,36922,36972,37022,37072,37122,37171,37221,37271,37321,37370,37420,37470,37520,37569,37619,37669,37719,37768,37818,37868,37917,37967,38017,38067,38116,38166,38216,38266,38315,38365,38415,38465,38514,38564,38614,38663,38713,38763,38813,38862,38912,38962,39011,39061,39111,39160,39210,39260,39310,39359,39409,39459,39508,39558,39608,39657,39707,39757,39806,39856,39906,39956,40005,40055,40105,40154,40204,40254,40303,40353,40403,40452,40502,40552,40601,40651,40701,40750,40800,40849,40899,40949,40998,41048,41098,41147,41197,41247,41296,41346,41396,41445,41495,41544,41594,41644,41693,41743,41793,41842,41892,41941,41991,42041,42090,42140,42190,42239,42289,42338,42388,42438,42487,42537,42586,42636,42686,42735,42785,42834,42884,42933,42983,43033,43082,43132,43181,43231,43281,43330,43380,43429,43479,43528,43578,43628,43677,43727,43776,43826,43875,43925,43974,44024,44074,44123,44173,44222,44272,44321,44371,44420,44470,44519,44569,44619,44668,44718,44767,44817,44866,44916,44965,45015,45064,45114,45163,45213,45262,45312,45361,45411,45460,45510,45559,45609,45658,45708,45757,45807,45856,45906,45955,46005,46054,46104,46153,46203,46252,46302,46351,46401,46450,46500,46549,46598,46648,46697,46747,46796,46846,46895,46945,46994,47044,47093,47142,47192,47241,47291,47340,47390,47439,47489,47538,47587,47637,47686,47736,47785,47835,47884,47933,47983,48032,48082,48131,48180,48230,48279,48329,48378,48427,48477,48526,48576,48625,48674,48724,48773,48823,48872,48921,48971,49020,49070,49119,49168,49218,49267,49316,49366,49415,49464,49514,49563,49613,49662,49711,49761,49810,49859,49909,49958,50007,50057,50106,50155,50205,50254,50303,50353,50402,50451,50501,50550,50599,50649,50698,50747,50797,50846,50895,50945,50994,51043,51092,51142,51191,51240,51290,51339,51388,51438,51487,51536,51585,51635,51684,51733,51782,51832,51881,51930,51980,52029,52078,52127,52177,52226,52275,52324,52374,52423,52472,52521,52571,52620,52669,52718,52768,52817,52866,52915,52965,53014,53063,53112,53161,53211,53260,53309,53358,53408,53457,53506,53555,53604,53654,53703,53752,53801,53850,53900,53949,53998,54047,54096,54145,54195,54244,54293,54342,54391,54441,54490,54539,54588,54637,54686,54736,54785,54834,54883,54932,54981,55030,55080,55129,55178,55227,55276,55325,55374,55424,55473,55522,55571,55620,55669,55718,55767,55816,55866,55915,55964,56013,56062,56111,56160,56209,56258,56308,56357,56406,56455,56504,56553,56602,56651,56700,56749,56798,56847,56896,56946,56995,57044,57093,57142,57191,57240,57289,57338,57387,57436,57485,57534,57583,57632,57681,57730,57779,57828,57877,57926,57975,58024,58073,58122,58171,58221,58270,58319,58368,58417,58466,58515,58564,58613,58662,58711,58759,58808,58857,58906,58955,59004,59053,59102,59151,59200,59249,59298,59347,59396,59445,59494,59543,59592,59641,59690,59739,59788,59837,59886,59935,59983,60032,60081,60130,60179,60228,60277,60326,60375,60424,60473,60522,60570,60619,60668,60717,60766,60815,60864,60913,60962,61011,61059,61108,61157,61206,61255,61304,61353,61402,61450,61499,61548,61597,61646,61695,61744,61792,61841,61890,61939,61988,62037,62085,62134,62183,62232,62281,62330,62378,62427,62476,62525,62574,62623,62671,62720,62769,62818,62867,62915,62964,63013,63062,63111,63159,63208,63257,63306,63354,63403,63452,63501,63550,63598,63647,63696,63745,63793,63842,63891,63940,63988,64037,64086,64135,64183,64232,64281,64329,64378,64427,64476,64524,64573,64622,64671,64719,64768,64817,64865,64914,64963,65011,65060,65109,65158,65206,65255,65304,65352,65401,65450,65498,65547,65596,65644,65693,65742,65790,65839,65888,65936,65985,66034,66082,66131,66179,66228,66277,66325,66374,66423,66471,66520,66568,66617,66666,66714,66763,66812,66860,66909,66957,67006,67055,67103,67152,67200,67249,67297,67346,67395,67443,67492,67540,67589,67637,67686,67735,67783,67832,67880,67929,67977,68026,68074,68123,68171,68220,68269,68317,68366,68414,68463,68511,68560,68608,68657,68705,68754,68802,68851,68899,68948,68996,69045,69093,69142,69190,69239,69287,69336,69384,69433,69481,69530,69578,69626,69675,69723,69772,69820,69869,69917,69966,70014,70062,70111,70159,70208,70256,70305,70353,70401,70450,70498,70547,70595,70644,70692,70740,70789,70837,70886,70934,70982,71031,71079,71127,71176,71224,71273,71321,71369,71418,71466,71514,71563,71611,71659,71708,71756,71805,71853,71901,71950,71998,72046,72095,72143,72191,72239,72288,72336,72384,72433,72481,72529,72578,72626,72674,72723,72771,72819,72867,72916,72964,73012,73061,73109,73157,73205,73254,73302,73350,73398,73447,73495,73543,73591,73640,73688,73736,73784,73833,73881,73929,73977,74025,74074,74122,74170,74218,74267,74315,74363,74411,74459,74508,74556,74604,74652,74700,74748,74797,74845,74893,74941,74989,75037,75086,75134,75182,75230,75278,75326,75375,75423,75471,75519,75567,75615,75663,75711,75760,75808,75856,75904,75952,76000,76048,76096,76144,76193,76241,76289,76337,76385,76433,76481,76529,76577,76625,76673,76721,76770,76818,76866,76914,76962,77010,77058,77106,77154,77202,77250,77298,77346,77394,77442,77490,77538,77586,77634,77682,77730,77778,77826,77874,77922,77970,78018,78066,78114,78162,78210,78258,78306,78354,78402,78450,78498,78546,78594,78642,78690,78738,78786,78834,78881,78929,78977,79025,79073,79121,79169,79217,79265,79313,79361,79409,79457,79504,79552,79600,79648,79696,79744,79792,79840,79887,79935,79983,80031,80079,80127,80175,80223,80270,80318,80366,80414,80462,80510,80557,80605,80653,80701,80749,80797,80844,80892,80940,80988,81036,81083,81131,81179,81227,81275,81322,81370,81418,81466,81514,81561,81609,81657,81705,81752,81800,81848,81896,81943,81991,82039,82087,82134,82182,82230,82278,82325,82373,82421,82468,82516,82564,82612,82659,82707,82755,82802,82850,82898,82945,82993,83041,83088,83136,83184,83231,83279,83327,83374,83422,83470,83517,83565,83613,83660,83708,83756,83803,83851,83898,83946,83994,84041,84089,84136,84184,84232,84279,84327,84374,84422,84470,84517,84565,84612,84660,84708,84755,84803,84850,84898,84945,84993,85040,85088,85136,85183,85231,85278,85326,85373,85421,85468,85516,85563,85611,85658,85706,85753,85801,85848,85896,85943,85991,86038,86086,86133,86181,86228,86276,86323,86371,86418,86465,86513,86560,86608,86655,86703,86750,86798,86845,86892,86940,86987,87035,87082,87129,87177,87224,87272,87319,87366,87414,87461,87509,87556,87603,87651,87698,87745,87793,87840,87888,87935,87982,88030,88077,88124,88172,88219,88266,88314,88361,88408,88456,88503,88550,88598,88645,88692,88739,88787,88834,88881,88929,88976,89023,89070,89118,89165,89212,89260,89307,89354,89401,89449,89496,89543,89590,89638,89685,89732,89779,89826,89874,89921,89968,90015,90063,90110,90157,90204,90251,90299,90346,90393,90440,90487,90534,90582,90629,90676,90723,90770,90817,90865,90912,90959,91006,91053,91100,91147,91195,91242,91289,91336,91383,91430,91477,91524,91571,91619,91666,91713,91760,91807,91854,91901,91948,91995,92042,92089,92136,92183,92230,92278,92325,92372,92419,92466,92513,92560,92607,92654,92701,92748,92795,92842,92889,92936,92983,93030,93077,93124,93171,93218,93265,93312,93359,93406,93453,93500,93547,93594,93640,93687,93734,93781,93828,93875,93922,93969,94016,94063,94110,94157,94204,94251,94297,94344,94391,94438,94485,94532,94579,94626,94673,94719,94766,94813,94860,94907,94954,95001,95047,95094,95141,95188,95235,95282,95328,95375,95422,95469,95516,95562,95609,95656,95703,95750,95796,95843,95890,95937,95984,96030,96077,96124,96171,96217,96264,96311,96358,96404,96451,96498,96545,96591,96638,96685,96732,96778,96825,96872,96918,96965,97012,97058,97105,97152,97199,97245,97292,97339,97385,97432,97479,97525,97572,97619,97665,97712,97758,97805,97852,97898,97945,97992,98038,98085,98131,98178,98225,98271,98318,98364,98411,98458,98504,98551,98597,98644,98691,98737,98784,98830,98877,98923,98970,99016,99063,99110,99156,99203,99249,99296,99342,99389,99435,99482,99528,99575,99621,99668,99714,99761,99807,99854,99900,99947,99993,100039,100086,100132,100179,100225,100272,100318,100365,100411,100457,100504,100550,100597,100643,100690,100736,100782,100829,100875,100922,100968,101014,101061,101107,101153,101200,101246,101293,101339,101385,101432,101478,101524,101571,101617,101663,101710,101756,101802,101849,101895,101941,101988,102034,102080,102126,102173,102219,102265,102312,102358,102404,102450,102497,102543,102589,102635,102682,102728,102774,102820,102867,102913,102959,103005,103052,103098,103144,103190,103236,103283,103329,103375,103421,103467,103514,103560,103606,103652,103698,103744,103791,103837,103883,103929,103975,104021,104067,104114,104160,104206,104252,104298,104344,104390,104436,104483,104529,104575,104621,104667,104713,104759,104805,104851,104897,104943,104989,105035,105082,105128,105174,105220,105266,105312,105358,105404,105450,105496,105542,105588,105634,105680,105726,105772,105818,105864,105910,105956,106002,106048,106094,106140,106186,106232,106278,106323,106369,106415,106461,106507,106553,106599,106645,106691,106737,106783,106829,106875,106920,106966,107012,107058,107104,107150,107196,107242,107287,107333,107379,107425,107471,107517,107563,107608,107654,107700,107746,107792,107838,107883,107929,107975,108021,108067,108112,108158,108204,108250,108295,108341,108387,108433,108479,108524,108570,108616,108662,108707,108753,108799,108845,108890,108936,108982,109027,109073,109119,109165,109210,109256,109302,109347,109393,109439,109484,109530,109576,109621,109667,109713,109758,109804,109850,109895,109941,109986,110032,110078,110123,110169,110215,110260,110306,110351,110397,110443,110488,110534,110579,110625,110670,110716,110762,110807,110853,110898,110944,110989,111035,111080,111126,111171,111217,111262,111308,111353,111399,111444,111490,111535,111581,111626,111672,111717,111763,111808,111854,111899,111945,111990,112036,112081,112126,112172,112217,112263,112308,112354,112399,112444,112490,112535,112581,112626,112671,112717,112762,112808,112853,112898,112944,112989,113034,113080,113125,113170,113216,113261,113306,113352,113397,113442,113488,113533,113578,113624,113669,113714,113759,113805,113850,113895,113941,113986,114031,114076,114122,114167,114212,114257,114303,114348,114393,114438,114483,114529,114574,114619,114664,114710,114755,114800,114845,114890,114935,114981,115026,115071,115116,115161,115206,115252,115297,115342,115387,115432,115477,115522,115567,115613,115658,115703,115748,115793,115838,115883,115928,115973,116018,116064,116109,116154,116199,116244,116289,116334,116379,116424,116469,116514,116559,116604,116649,116694,116739,116784,116829,116874,116919,116964,117009,117054,117099,117144,117189,117234,117279,117324,117369,117414,117459,117504,117549,117593,117638,117683,117728,117773,117818,117863,117908,117953,117998,118042,118087,118132,118177,118222,118267,118312,118357,118401,118446,118491,118536,118581,118626,118670,118715,118760,118805,118850,118894,118939,118984,119029,119074,119118,119163,119208,119253,119297,119342,119387,119432,119476,119521,119566,119611,119655,119700,119745,119790,119834,119879,119924,119968,120013,120058,120102,120147,120192,120236,120281,120326,120370,120415,120460,120504,120549,120594,120638,120683,120727,120772,120817,120861,120906,120950,120995,121040,121084,121129,121173,121218,121263,121307,121352,121396,121441,121485,121530,121574,121619,121663,121708,121752,121797,121842,121886,121931,121975,122019,122064,122108,122153,122197,122242,122286,122331,122375,122420,122464,122509,122553,122597,122642,122686,122731,122775,122820,122864,122908,122953,122997,123042,123086,123130,123175,123219,123263,123308,123352,123396,123441,123485,123529,123574,123618,123662,123707,123751,123795,123840,123884,123928,123973,124017,124061,124105,124150,124194,124238,124283,124327,124371,124415,124460,124504,124548,124592,124636,124681,124725,124769,124813,124857,124902,124946,124990,125034,125078,125123,125167,125211,125255,125299,125343,125388,125432,125476,125520,125564,125608,125652,125696,125741,125785,125829,125873,125917,125961,126005,126049,126093,126137,126181,126225,126269,126314,126358,126402,126446,126490,126534,126578,126622,126666,126710,126754,126798,126842,126886,126930,126974,127018,127062,127106,127150,127193,127237,127281,127325,127369,127413,127457,127501,127545,127589,127633,127677,127721,127764,127808,127852,127896,127940,127984,128028,128072,128115,128159,128203,128247,128291,128335,128378,128422,128466,128510,128554,128598,128641,128685,128729,128773,128816,128860,128904,128948,128992,129035,129079,129123,129167,129210,129254,129298,129341,129385,129429,129473,129516,129560,129604,129647,129691,129735,129778,129822,129866,129909,129953,129997,130040,130084,130128,130171,130215,130259,130302,130346,130389,130433,130477,130520,130564,130607,130651,130695,130738,130782,130825,130869,130912,130956,130999,131043,131087,131130,131174,131217,131261,131304,131348,131391,131435,131478,131522,131565,131609,131652,131695,131739,131782,131826,131869,131913,131956,132000,132043,132086,132130,132173,132217,132260,132303,132347,132390,132434,132477,132520,132564,132607,132650,132694,132737,132780,132824,132867,132910,132954,132997,133040,133084,133127,133170,133214,133257,133300,133343,133387,133430,133473,133517,133560,133603,133646,133690,133733,133776,133819,133862,133906,133949,133992,134035,134078,134122,134165,134208,134251,134294,134338,134381,134424,134467,134510,134553,134596,134640,134683,134726,134769,134812,134855,134898,134941,134984,135028,135071,135114,135157,135200,135243,135286,135329,135372,135415,135458,135501,135544,135587,135630,135673,135716,135759,135802,135845,135888,135931,135974,136017,136060,136103,136146,136189,136232,136275,136318,136361,136404,136447,136490,136532,136575,136618,136661,136704,136747,136790,136833,136876,136918,136961,137004,137047,137090,137133,137176,137218,137261,137304,137347,137390,137432,137475,137518,137561,137604,137646,137689,137732,137775,137817,137860,137903,137946,137988,138031,138074,138117,138159,138202,138245,138288,138330,138373,138416,138458,138501,138544,138586,138629,138672,138714,138757,138800,138842,138885,138927,138970,139013,139055,139098,139141,139183,139226,139268,139311,139353,139396,139439,139481,139524,139566,139609,139651,139694,139736,139779,139821,139864,139907,139949,139992,140034,140077,140119,140161,140204,140246,140289,140331,140374,140416,140459,140501,140544,140586,140628,140671,140713,140756,140798,140840,140883,140925,140968,141010,141052,141095,141137,141179,141222,141264,141306,141349,141391,141433,141476,141518,141560,141603,141645,141687,141730,141772,141814,141856,141899,141941,141983,142025,142068,142110,142152,142194,142237,142279,142321,142363,142405,142448,142490,142532,142574,142616,142659,142701,142743,142785,142827,142869,142912,142954,142996,143038,143080,143122,143164,143206,143248,143291,143333,143375,143417,143459,143501,143543,143585,143627,143669,143711,143753,143795,143837,143879,143921,143963,144005,144047,144089,144131,144173,144215,144257,144299,144341,144383,144425,144467,144509,144551,144593,144635,144677,144719,144761,144802,144844,144886,144928,144970,145012,145054,145096,145137,145179,145221,145263,145305,145347,145389,145430,145472,145514,145556,145598,145639,145681,145723,145765,145807,145848,145890,145932,145974,146015,146057,146099,146141,146182,146224,146266,146307,146349,146391,146433,146474,146516,146558,146599,146641,146683,146724,146766,146808,146849,146891,146932,146974,147016,147057,147099,147141,147182,147224,147265,147307,147348,147390,147432,147473,147515,147556,147598,147639,147681,147722,147764,147805,147847,147888,147930,147971,148013,148054,148096,148137,148179,148220,148262,148303,148345,148386,148428,148469,148510,148552,148593,148635,148676,148717,148759,148800,148842,148883,148924,148966,149007,149048,149090,149131,149172,149214,149255,149296,149338,149379,149420,149462,149503,149544,149585,149627,149668,149709,149751,149792,149833,149874,149916,149957,149998,150039,150080,150122,150163,150204,150245,150286,150328,150369,150410,150451,150492,150533,150575,150616,150657,150698,150739,150780,150821,150862,150904,150945,150986,151027,151068,151109,151150,151191,151232,151273,151314,151355,151396,151437,151478,151519,151560,151601,151642,151683,151724,151765,151806,151847,151888,151929,151970,152011,152052,152093,152134,152175,152216,152257,152298,152339,152380,152421,152461,152502,152543,152584,152625,152666,152707,152748,152788,152829,152870,152911,152952,152993,153033,153074,153115,153156,153197,153237,153278,153319,153360,153400,153441,153482,153523,153563,153604,153645,153686,153726,153767,153808,153848,153889,153930,153970,154011,154052,154093,154133,154174,154214,154255,154296,154336,154377,154418,154458,154499,154539,154580,154621,154661,154702,154742,154783,154824,154864,154905,154945,154986,155026,155067,155107,155148,155188,155229,155269,155310,155350,155391,155431,155472,155512,155553,155593,155634,155674,155715,155755,155795,155836,155876,155917,155957,155997,156038,156078,156119,156159,156199,156240,156280,156320,156361,156401,156441,156482,156522,156562,156603,156643,156683,156724,156764,156804,156845,156885,156925,156965,157006,157046,157086,157126,157167,157207,157247,157287,157327,157368,157408,157448,157488,157528,157569,157609,157649,157689,157729,157769,157809,157850,157890,157930,157970,158010,158050,158090,158130,158170,158211,158251,158291,158331,158371,158411,158451,158491,158531,158571,158611,158651,158691,158731,158771,158811,158851,158891,158931,158971,159011,159051,159091,159131,159171,159211,159251,159291,159330,159370,159410,159450,159490,159530,159570,159610,159650,159689,159729,159769,159809,159849,159889,159929,159968,160008,160048,160088,160128,160167,160207,160247,160287,160327,160366,160406,160446,160486,160525,160565,160605,160644,160684,160724,160764,160803,160843,160883,160922,160962,161002,161041,161081,161121,161160,161200,161240,161279,161319,161359,161398,161438,161477,161517,161557,161596,161636,161675,161715,161754,161794,161833,161873,161913,161952,161992,162031,162071,162110,162150,162189,162229,162268,162308,162347,162386,162426,162465,162505,162544,162584,162623,162663,162702,162741,162781,162820,162860,162899,162938,162978,163017,163056,163096,163135,163174,163214,163253,163292,163332,163371,163410,163450,163489,163528,163568,163607,163646,163685,163725,163764,163803,163842,163882,163921,163960,163999,164039,164078,164117,164156,164195,164234,164274,164313,164352,164391,164430,164469,164509,164548,164587,164626,164665,164704,164743,164782,164821,164861,164900,164939,164978,165017,165056,165095,165134,165173,165212,165251,165290,165329,165368,165407,165446,165485,165524,165563,165602,165641,165680,165719,165758,165797,165836,165875,165914,165952,165991,166030,166069,166108,166147,166186,166225,166264,166302,166341,166380,166419,166458,166497,166535,166574,166613,166652,166691,166729,166768,166807,166846,166885,166923,166962,167001,167040,167078,167117,167156,167194,167233,167272,167311,167349,167388,167427,167465,167504,167543,167581,167620,167659,167697,167736,167774,167813,167852,167890,167929,167968,168006,168045,168083,168122,168160,168199,168238,168276,168315,168353,168392,168430,168469,168507,168546,168584,168623,168661,168700,168738,168777,168815,168853,168892,168930,168969,169007,169046,169084,169122,169161,169199,169238,169276,169314,169353,169391,169430,169468,169506,169545,169583,169621,169660,169698,169736,169774,169813,169851,169889,169928,169966,170004,170042,170081,170119,170157,170195,170234,170272,170310,170348,170386,170425,170463,170501,170539,170577,170616,170654,170692,170730,170768,170806,170844,170883,170921,170959,170997,171035,171073,171111,171149,171187,171225,171263,171301,171339,171378,171416,171454,171492,171530,171568,171606,171644,171682,171720,171758,171796,171834,171871,171909,171947,171985,172023,172061,172099,172137,172175,172213,172251,172289,172326,172364,172402,172440,172478,172516,172554,172591,172629,172667,172705,172743,172781,172818,172856,172894,172932,172969,173007,173045,173083,173121,173158,173196,173234,173271,173309,173347,173385,173422,173460,173498,173535,173573,173611,173648,173686,173724,173761,173799,173837,173874,173912,173949,173987,174025,174062,174100,174137,174175,174212,174250,174288,174325,174363,174400,174438,174475,174513,174550,174588,174625,174663,174700,174738,174775,174813,174850,174887,174925,174962,175000,175037,175075,175112,175149,175187,175224,175262,175299,175336,175374,175411,175448,175486,175523,175560,175598,175635,175672,175710,175747,175784,175822,175859,175896,175933,175971,176008,176045,176082,176120,176157,176194,176231,176268,176306,176343,176380,176417,176454,176492,176529,176566,176603,176640,176677,176714,176752,176789,176826,176863,176900,176937,176974,177011,177048,177085,177123,177160,177197,177234,177271,177308,177345,177382,177419,177456,177493,177530,177567,177604,177641,177678,177715,177752,177788,177825,177862,177899,177936,177973,178010,178047,178084,178121,178158,178194,178231,178268,178305,178342,178379,178415,178452,178489,178526,178563,178600,178636,178673,178710,178747,178783,178820,178857,178894,178930,178967,179004,179041,179077,179114,179151,179187,179224,179261,179297,179334,179371,179407,179444,179481,179517,179554,179591,179627,179664,179700,179737,179774,179810,179847,179883,179920,179956,179993,180029,180066,180103,180139,180176,180212,180249,180285,180322,180358,180395,180431,180467,180504,180540,180577,180613,180650,180686,180723,180759,180795,180832,180868,180904,180941,180977,181014,181050,181086,181123,181159,181195,181232,181268,181304,181341,181377,181413,181449,181486,181522,181558,181594,181631,181667,181703,181739,181776,181812,181848,181884,181920,181957,181993,182029,182065,182101,182137,182174,182210,182246,182282,182318,182354,182390,182426,182463,182499,182535,182571,182607,182643,182679,182715,182751,182787,182823,182859,182895,182931,182967,183003,183039,183075,183111,183147,183183,183219,183255,183291,183327,183363,183399,183435,183470,183506,183542,183578,183614,183650,183686,183722,183757,183793,183829,183865,183901,183937,183972,184008,184044,184080,184116,184151,184187,184223,184259,184294,184330,184366,184402,184437,184473,184509,184545,184580,184616,184652,184687,184723,184759,184794,184830,184866,184901,184937,184972,185008,185044,185079,185115,185150,185186,185222,185257,185293,185328,185364,185399,185435,185470,185506,185541,185577,185612,185648,185683,185719,185754,185790,185825,185861,185896,185932,185967,186002,186038,186073,186109,186144,186179,186215,186250,186286,186321,186356,186392,186427,186462,186498,186533,186568,186604,186639,186674,186710,186745,186780,186815,186851,186886,186921,186956,186992,187027,187062,187097,187132,187168,187203,187238,187273,187308,187343,187379,187414,187449,187484,187519,187554,187589,187625,187660,187695,187730,187765,187800,187835,187870,187905,187940,187975,188010,188045,188080,188115,188150,188185,188220,188255,188290,188325,188360,188395,188430,188465,188500,188535,188570,188605,188640,188675,188709,188744,188779,188814,188849,188884,188919,188954,188988,189023,189058,189093,189128,189162,189197,189232,189267,189302,189336,189371,189406,189441,189475,189510,189545,189580,189614,189649,189684,189718,189753,189788,189822,189857,189892,189926,189961,189996,190030,190065,190099,190134,190169,190203,190238,190272,190307,190342,190376,190411,190445,190480,190514,190549,190583,190618,190652,190687,190721,190756,190790,190825,190859,190894,190928,190963,190997,191031,191066,191100,191135,191169,191203,191238,191272,191307,191341,191375,191410,191444,191478,191513,191547,191581,191616,191650,191684,191718,191753,191787,191821,191856,191890,191924,191958,191992,192027,192061,192095,192129,192164,192198,192232,192266,192300,192334,192369,192403,192437,192471,192505,192539,192573,192607,192641,192676,192710,192744,192778,192812,192846,192880,192914,192948,192982,193016,193050,193084,193118,193152,193186,193220,193254,193288,193322,193356,193390,193424,193458,193492,193525,193559,193593,193627,193661,193695,193729,193763,193796,193830,193864,193898,193932,193966,193999,194033,194067,194101,194135,194168,194202,194236,194270,194303,194337,194371,194405,194438,194472,194506,194539,194573,194607,194640,194674,194708,194741,194775,194809,194842,194876,194910,194943,194977,195010,195044,195078,195111,195145,195178,195212,195245,195279,195312,195346,195379,195413,195446,195480,195513,195547,195580,195614,195647,195681,195714,195748,195781,195815,195848,195881,195915,195948,195982,196015,196048,196082,196115,196148,196182,196215,196248,196282,196315,196348,196382,196415,196448,196481,196515,196548,196581,196615,196648,196681,196714,196747,196781,196814,196847,196880,196913,196947,196980,197013,197046,197079,197112,197146,197179,197212,197245,197278,197311,197344,197377,197410,197443,197476,197510,197543,197576,197609,197642,197675,197708,197741,197774,197807,197840,197873,197906,197939,197972,198004,198037,198070,198103,198136,198169,198202,198235,198268,198301,198334,198366,198399,198432,198465,198498,198531,198563,198596,198629,198662,198695,198727,198760,198793,198826,198858,198891,198924,198957,198989,199022,199055,199088,199120,199153,199186,199218,199251,199284,199316,199349,199382,199414,199447,199479,199512,199545,199577,199610,199642,199675,199708,199740,199773,199805,199838,199870,199903,199935,199968,200000,200033,200065,200098,200130,200163,200195,200228,200260,200292,200325,200357,200390,200422,200454,200487,200519,200552,200584,200616,200649,200681,200713,200746,200778,200810,200843,200875,200907,200940,200972,201004,201036,201069,201101,201133,201165,201198,201230,201262,201294,201326,201359,201391,201423,201455,201487,201519,201552,201584,201616,201648,201680,201712,201744,201776,201808,201841,201873,201905,201937,201969,202001,202033,202065,202097,202129,202161,202193,202225,202257,202289,202321,202353,202385,202417,202449,202481,202512,202544,202576,202608,202640,202672,202704,202736,202768,202799,202831,202863,202895,202927,202959,202990,203022,203054,203086,203118,203149,203181,203213,203245,203276,203308,203340,203372,203403,203435,203467,203498,203530,203562,203593,203625,203657,203688,203720,203752,203783,203815,203846,203878,203910,203941,203973,204004,204036,204067,204099,204131,204162,204194,204225,204257,204288,204320,204351,204383,204414,204446,204477,204508,204540,204571,204603,204634,204666,204697,204728,204760,204791,204823,204854,204885,204917,204948,204979,205011,205042,205073,205105,205136,205167,205198,205230,205261,205292,205324,205355,205386,205417,205448,205480,205511,205542,205573,205604,205636,205667,205698,205729,205760,205791,205823,205854,205885,205916,205947,205978,206009,206040,206071,206102,206133,206165,206196,206227,206258,206289,206320,206351,206382,206413,206444,206475,206506,206537,206567,206598,206629,206660,206691,206722,206753,206784,206815,206846,206877,206907,206938,206969,207000,207031,207062,207092,207123,207154,207185,207216,207246,207277,207308,207339,207370,207400,207431,207462,207492,207523,207554,207585,207615,207646,207677,207707,207738,207769,207799,207830,207861,207891,207922,207952,207983,208014,208044,208075,208105,208136,208166,208197,208228,208258,208289,208319,208350,208380,208411,208441,208472,208502,208533,208563,208593,208624,208654,208685,208715,208746,208776,208806,208837,208867,208897,208928,208958,208989,209019,209049,209080,209110,209140,209170,209201,209231,209261,209292,209322,209352,209382,209413,209443,209473,209503,209534,209564,209594,209624,209654,209684,209715,209745,209775,209805,209835,209865,209895,209926,209956,209986,210016,210046,210076,210106,210136,210166,210196,210226,210256,210286,210316,210346,210376,210406,210436,210466,210496,210526,210556,210586,210616,210646,210676,210706,210736,210765,210795,210825,210855,210885,210915,210945,210974,211004,211034,211064,211094,211124,211153,211183,211213,211243,211272,211302,211332,211362,211391,211421,211451,211481,211510,211540,211570,211599,211629,211659,211688,211718,211748,211777,211807,211836,211866,211896,211925,211955,211984,212014,212043,212073,212103,212132,212162,212191,212221,212250,212280,212309,212339,212368,212398,212427,212456,212486,212515,212545,212574,212604,212633,212662,212692,212721,212751,212780,212809,212839,212868,212897,212927,212956,212985,213015,213044,213073,213102,213132,213161,213190,213219,213249,213278,213307,213336,213366,213395,213424,213453,213482,213511,213541,213570,213599,213628,213657,213686,213715,213745,213774,213803,213832,213861,213890,213919,213948,213977,214006,214035,214064,214093,214122,214151,214180,214209,214238,214267,214296,214325,214354,214383,214412,214441,214470,214498,214527,214556,214585,214614,214643,214672,214701,214729,214758,214787,214816,214845,214873,214902,214931,214960,214989,215017,215046,215075,215104,215132,215161,215190,215218,215247,215276,215304,215333,215362,215390,215419,215448,215476,215505,215534,215562,215591,215619,215648,215677,215705,215734,215762,215791,215819,215848,215876,215905,215933,215962,215990,216019,216047,216076,216104,216133,216161,216190,216218,216246,216275,216303,216332,216360,216388,216417,216445,216473,216502,216530,216558,216587,216615,216643,216672,216700,216728,216757,216785,216813,216841,216870,216898,216926,216954,216982,217011,217039,217067,217095,217123,217152,217180,217208,217236,217264,217292,217320,217348,217377,217405,217433,217461,217489,217517,217545,217573,217601,217629,217657,217685,217713,217741,217769,217797,217825,217853,217881,217909,217937,217965,217993,218021,218049,218076,218104,218132,218160,218188,218216,218244,218271,218299,218327,218355,218383,218411,218438,218466,218494,218522,218549,218577,218605,218633,218660,218688,218716,218744,218771,218799,218827,218854,218882,218910,218937,218965,218993,219020,219048,219075,219103,219131,219158,219186,219213,219241,219268,219296,219324,219351,219379,219406,219434,219461,219489,219516,219544,219571,219598,219626,219653,219681,219708,219736,219763,219790,219818,219845,219873,219900,219927,219955,219982,220009,220037,220064,220091,220119,220146,220173,220200,220228,220255,220282,220309,220337,220364,220391,220418,220446,220473,220500,220527,220554,220581,220609,220636,220663,220690,220717,220744,220771,220798,220826,220853,220880,220907,220934,220961,220988,221015,221042,221069,221096,221123,221150,221177,221204,221231,221258,221285,221312,221339,221366,221393,221419,221446,221473,221500,221527,221554,221581,221608,221634,221661,221688,221715,221742,221769,221795,221822,221849,221876,221903,221929,221956,221983,222010,222036,222063,222090,222116,222143,222170,222196,222223,222250,222276,222303,222330,222356,222383,222410,222436,222463,222489,222516,222542,222569,222596,222622,222649,222675,222702,222728,222755,222781,222808,222834,222861,222887,222914,222940,222966,222993,223019,223046,223072,223099,223125,223151,223178,223204,223230,223257,223283,223309,223336,223362,223388,223415,223441,223467,223493,223520,223546,223572,223599,223625,223651,223677,223703,223730,223756,223782,223808,223834,223860,223887,223913,223939,223965,223991,224017,224043,224069,224096,224122,224148,224174,224200,224226,224252,224278,224304,224330,224356,224382,224408,224434,224460,224486,224512,224538,224564,224590,224615,224641,224667,224693,224719,224745,224771,224797,224823,224848,224874,224900,224926,224952,224978,225003,225029,225055,225081,225106,225132,225158,225184,225209,225235,225261,225287,225312,225338,225364,225389,225415,225441,225466,225492,225517,225543,225569,225594,225620,225646,225671,225697,225722,225748,225773,225799,225824,225850,225875,225901,225926,225952,225977,226003,226028,226054,226079,226105,226130,226156,226181,226206,226232,226257,226283,226308,226333,226359,226384,226409,226435,226460,226485,226511,226536,226561,226586,226612,226637,226662,226688,226713,226738,226763,226788,226814,226839,226864,226889,226914,226940,226965,226990,227015,227040,227065,227090,227115,227141,227166,227191,227216,227241,227266,227291,227316,227341,227366,227391,227416,227441,227466,227491,227516,227541,227566,227591,227616,227641,227666,227691,227716,227740,227765,227790,227815,227840,227865,227890,227914,227939,227964,227989,228014,228039,228063,228088,228113,228138,228162,228187,228212,228237,228261,228286,228311,228335,228360,228385,228409,228434,228459,228483,228508,228533,228557,228582,228607,228631,228656,228680,228705,228729,228754,228779,228803,228828,228852,228877,228901,228926,228950,228975,228999,229024,229048,229072,229097,229121,229146,229170,229194,229219,229243,229268,229292,229316,229341,229365,229389,229414,229438,229462,229487,229511,229535,229560,229584,229608,229632,229657,229681,229705,229729,229753,229778,229802,229826,229850,229874,229898,229923,229947,229971,229995,230019,230043,230067,230091,230116,230140,230164,230188,230212,230236,230260,230284,230308,230332,230356,230380,230404,230428,230452,230476,230500,230524,230548,230571,230595,230619,230643,230667,230691,230715,230739,230762,230786,230810,230834,230858,230882,230905,230929,230953,230977,231001,231024,231048,231072,231096,231119,231143,231167,231190,231214,231238,231261,231285,231309,231332,231356,231380,231403,231427,231450,231474,231498,231521,231545,231568,231592,231615,231639,231663,231686,231710,231733,231757,231780,231804,231827,231850,231874,231897,231921,231944,231968,231991,232014,232038,232061,232085,232108,232131,232155,232178,232201,232225,232248,232271,232295,232318,232341,232364,232388,232411,232434,232457,232481,232504,232527,232550,232574,232597,232620,232643,232666,232689,232713,232736,232759,232782,232805,232828,232851,232874,232897,232920,232944,232967,232990,233013,233036,233059,233082,233105,233128,233151,233174,233197,233220,233243,233265,233288,233311,233334,233357,233380,233403,233426,233449,233472,233494,233517,233540,233563,233586,233609,233631,233654,233677,233700,233722,233745,233768,233791,233813,233836,233859,233882,233904,233927,233950,233972,233995,234018,234040,234063,234086,234108,234131,234153,234176,234199,234221,234244,234266,234289,234311,234334,234356,234379,234401,234424,234446,234469,234491,234514,234536,234559,234581,234604,234626,234649,234671,234693,234716,234738,234760,234783,234805,234828,234850,234872,234894,234917,234939,234961,234984,235006,235028,235050,235073,235095,235117,235139,235162,235184,235206,235228,235250,235273,235295,235317,235339,235361,235383,235405,235428,235450,235472,235494,235516,235538,235560,235582,235604,235626,235648,235670,235692,235714,235736,235758,235780,235802,235824,235846,235868,235890,235912,235934,235956,235978,235999,236021,236043,236065,236087,236109,236131,236152,236174,236196,236218,236240,236261,236283,236305,236327,236348,236370,236392,236414,236435,236457,236479,236500,236522,236544,236565,236587,236609,236630,236652,236674,236695,236717,236738,236760,236782,236803,236825,236846,236868,236889,236911,236932,236954,236975,236997,237018,237040,237061,237083,237104,237126,237147,237168,237190,237211,237233,237254,237275,237297,237318,237339,237361,237382,237403,237425,237446,237467,237489,237510,237531,237552,237574,237595,237616,237637,237659,237680,237701,237722,237743,237765,237786,237807,237828,237849,237870,237891,237913,237934,237955,237976,237997,238018,238039,238060,238081,238102,238123,238144,238165,238186,238207,238228,238249,238270,238291,238312,238333,238354,238375,238396,238417,238437,238458,238479,238500,238521,238542,238563,238583,238604,238625,238646,238667,238688,238708,238729,238750,238771,238791,238812,238833,238853,238874,238895,238916,238936,238957,238978,238998,239019,239040,239060,239081,239101,239122,239143,239163,239184,239204,239225,239245,239266,239287,239307,239328,239348,239369,239389,239410,239430,239450,239471,239491,239512,239532,239553,239573,239593,239614,239634,239655,239675,239695,239716,239736,239756,239777,239797,239817,239838,239858,239878,239898,239919,239939,239959,239979,240000,240020,240040,240060,240080,240101,240121,240141,240161,240181,240201,240221,240242,240262,240282,240302,240322,240342,240362,240382,240402,240422,240442,240462,240482,240502,240522,240542,240562,240582,240602,240622,240642,240662,240682,240702,240722,240742,240762,240781,240801,240821,240841,240861,240881,240901,240920,240940,240960,240980,241000,241019,241039,241059,241079,241098,241118,241138,241157,241177,241197,241217,241236,241256,241276,241295,241315,241334,241354,241374,241393,241413,241433,241452,241472,241491,241511,241530,241550,241569,241589,241608,241628,241647,241667,241686,241706,241725,241745,241764,241784,241803,241822,241842,241861,241881,241900,241919,241939,241958,241977,241997,242016,242035,242055,242074,242093,242112,242132,242151,242170,242189,242209,242228,242247,242266,242286,242305,242324,242343,242362,242381,242401,242420,242439,242458,242477,242496,242515,242534,242553,242572,242591,242611,242630,242649,242668,242687,242706,242725,242744,242763,242782,242800,242819,242838,242857,242876,242895,242914,242933,242952,242971,242990,243008,243027,243046,243065,243084,243103,243121,243140,243159,243178,243196,243215,243234,243253,243271,243290,243309,243328,243346,243365,243384,243402,243421,243440,243458,243477,243496,243514,243533,243551,243570,243588,243607,243626,243644,243663,243681,243700,243718,243737,243755,243774,243792,243811,243829,243848,243866,243885,243903,243921,243940,243958,243977,243995,244013,244032,244050,244068,244087,244105,244123,244142,244160,244178,244197,244215,244233,244251,244270,244288,244306,244324,244343,244361,244379,244397,244415,244433,244452,244470,244488,244506,244524,244542,244560,244578,244597,244615,244633,244651,244669,244687,244705,244723,244741,244759,244777,244795,244813,244831,244849,244867,244885,244903,244921,244938,244956,244974,244992,245010,245028,245046,245064,245081,245099,245117,245135,245153,245171,245188,245206,245224,245242,245259,245277,245295,245313,245330,245348,245366,245383,245401,245419,245436,245454,245472,245489,245507,245525,245542,245560,245577,245595,245613,245630,245648,245665,245683,245700,245718,245735,245753,245770,245788,245805,245823,245840,245858,245875,245892,245910,245927,245945,245962,245979,245997,246014,246032,246049,246066,246084,246101,246118,246136,246153,246170,246187,246205,246222,246239,246256,246274,246291,246308,246325,246342,246360,246377,246394,246411,246428,246445,246463,246480,246497,246514,246531,246548,246565,246582,246599,246616,246633,246650,246667,246684,246701,246718,246735,246752,246769,246786,246803,246820,246837,246854,246871,246888,246905,246922,246938,246955,246972,246989,247006,247023,247040,247056,247073,247090,247107,247123,247140,247157,247174,247190,247207,247224,247241,247257,247274,247291,247307,247324,247341,247357,247374,247391,247407,247424,247440,247457,247474,247490,247507,247523,247540,247556,247573,247589,247606,247622,247639,247655,247672,247688,247705,247721,247738,247754,247771,247787,247803,247820,247836,247853,247869,247885,247902,247918,247934,247951,247967,247983,248000,248016,248032,248048,248065,248081,248097,248113,248130,248146,248162,248178,248194,248211,248227,248243,248259,248275,248291,248307,248323,248340,248356,248372,248388,248404,248420,248436,248452,248468,248484,248500,248516,248532,248548,248564,248580,248596,248612,248628,248644,248660,248676,248691,248707,248723,248739,248755,248771,248787,248803,248818,248834,248850,248866,248882,248897,248913,248929,248945,248960,248976,248992,249008,249023,249039,249055,249070,249086,249102,249117,249133,249149,249164,249180,249195,249211,249227,249242,249258,249273,249289,249304,249320,249335,249351,249367,249382,249398,249413,249428,249444,249459,249475,249490,249506,249521,249536,249552,249567,249583,249598,249613,249629,249644,249659,249675,249690,249705,249721,249736,249751,249766,249782,249797,249812,249827,249843,249858,249873,249888,249903,249919,249934,249949,249964,249979,249994,250009,250025,250040,250055,250070,250085,250100,250115,250130,250145,250160,250175,250190,250205,250220,250235,250250,250265,250280,250295,250310,250325,250340,250355,250370,250385,250399,250414,250429,250444,250459,250474,250489,250503,250518,250533,250548,250562,250577,250592,250607,250622,250636,250651,250666,250680,250695,250710,250724,250739,250754,250768,250783,250798,250812,250827,250842,250856,250871,250885,250900,250914,250929,250944,250958,250973,250987,251002,251016,251031,251045,251060,251074,251088,251103,251117,251132,251146,251161,251175,251189,251204,251218,251232,251247,251261,251275,251290,251304,251318,251333,251347,251361,251375,251390,251404,251418,251432,251447,251461,251475,251489,251503,251518,251532,251546,251560,251574,251588,251602,251617,251631,251645,251659,251673,251687,251701,251715,251729,251743,251757,251771,251785,251799,251813,251827,251841,251855,251869,251883,251897,251911,251925,251938,251952,251966,251980,251994,252008,252022,252035,252049,252063,252077,252091,252104,252118,252132,252146,252159,252173,252187,252201,252214,252228,252242,252255,252269,252283,252296,252310,252324,252337,252351,252365,252378,252392,252405,252419,252432,252446,252460,252473,252487,252500,252514,252527,252541,252554,252568,252581,252594,252608,252621,252635,252648,252662,252675,252688,252702,252715,252728,252742,252755,252768,252782,252795,252808,252822,252835,252848,252861,252875,252888,252901,252914,252928,252941,252954,252967,252980,252994,253007,253020,253033,253046,253059,253072,253085,253099,253112,253125,253138,253151,253164,253177,253190,253203,253216,253229,253242,253255,253268,253281,253294,253307,253320,253333,253346,253359,253371,253384,253397,253410,253423,253436,253449,253461,253474,253487,253500,253513,253525,253538,253551,253564,253577,253589,253602,253615,253627,253640,253653,253666,253678,253691,253704,253716,253729,253741,253754,253767,253779,253792,253804,253817,253830,253842,253855,253867,253880,253892,253905,253917,253930,253942,253955,253967,253980,253992,254004,254017,254029,254042,254054,254067,254079,254091,254104,254116,254128,254141,254153,254165,254178,254190,254202,254214,254227,254239,254251,254263,254276,254288,254300,254312,254324,254337,254349,254361,254373,254385,254397,254410,254422,254434,254446,254458,254470,254482,254494,254506,254518,254530,254542,254554,254566,254578,254590,254602,254614,254626,254638,254650,254662,254674,254686,254698,254710,254721,254733,254745,254757,254769,254781,254793,254804,254816,254828,254840,254852,254863,254875,254887,254899,254910,254922,254934,254945,254957,254969,254981,254992,255004,255015,255027,255039,255050,255062,255074,255085,255097,255108,255120,255131,255143,255155,255166,255178,255189,255201,255212,255224,255235,255246,255258,255269,255281,255292,255304,255315,255326,255338,255349,255361,255372,255383,255395,255406,255417,255429,255440,255451,255462,255474,255485,255496,255507,255519,255530,255541,255552,255564,255575,255586,255597,255608,255619,255630,255642,255653,255664,255675,255686,255697,255708,255719,255730,255741,255752,255763,255774,255785,255796,255807,255818,255829,255840,255851,255862,255873,255884,255895,255906,255917,255928,255939,255949,255960,255971,255982,255993,256004,256014,256025,256036,256047,256058,256068,256079,256090,256101,256111,256122,256133,256143,256154,256165,256176,256186,256197,256207,256218,256229,256239,256250,256261,256271,256282,256292,256303,256313,256324,256334,256345,256355,256366,256376,256387,256397,256408,256418,256429,256439,256450,256460,256470,256481,256491,256502,256512,256522,256533,256543,256553,256564,256574,256584,256595,256605,256615,256625,256636,256646,256656,256666,256677,256687,256697,256707,256717,256728,256738,256748,256758,256768,256778,256788,256798,256809,256819,256829,256839,256849,256859,256869,256879,256889,256899,256909,256919,256929,256939,256949,256959,256969,256979,256989,256999,257008,257018,257028,257038,257048,257058,257068,257078,257087,257097,257107,257117,257127,257136,257146,257156,257166,257175,257185,257195,257205,257214,257224,257234,257243,257253,257263,257272,257282,257292,257301,257311,257320,257330,257340,257349,257359,257368,257378,257387,257397,257406,257416,257425,257435,257444,257454,257463,257473,257482,257492,257501,257510,257520,257529,257539,257548,257557,257567,257576,257585,257595,257604,257613,257623,257632,257641,257651,257660,257669,257678,257688,257697,257706,257715,257724,257734,257743,257752,257761,257770,257779,257789,257798,257807,257816,257825,257834,257843,257852,257861,257870,257879,257888,257897,257906,257915,257924,257933,257942,257951,257960,257969,257978,257987,257996,258005,258014,258023,258031,258040,258049,258058,258067,258076,258084,258093,258102,258111,258120,258128,258137,258146,258155,258163,258172,258181,258190,258198,258207,258216,258224,258233,258242,258250,258259,258267,258276,258285,258293,258302,258310,258319,258327,258336,258345,258353,258362,258370,258379,258387,258396,258404,258412,258421,258429,258438,258446,258455,258463,258471,258480,258488,258496,258505,258513,258522,258530,258538,258546,258555,258563,258571,258580,258588,258596,258604,258613,258621,258629,258637,258645,258654,258662,258670,258678,258686,258694,258702,258711,258719,258727,258735,258743,258751,258759,258767,258775,258783,258791,258799,258807,258815,258823,258831,258839,258847,258855,258863,258871,258879,258887,258895,258902,258910,258918,258926,258934,258942,258950,258957,258965,258973,258981,258989,258996,259004,259012,259020,259027,259035,259043,259050,259058,259066,259073,259081,259089,259096,259104,259112,259119,259127,259135,259142,259150,259157,259165,259172,259180,259187,259195,259202,259210,259217,259225,259232,259240,259247,259255,259262,259270,259277,259285,259292,259299,259307,259314,259321,259329,259336,259343,259351,259358,259365,259373,259380,259387,259395,259402,259409,259416,259423,259431,259438,259445,259452,259459,259467,259474,259481,259488,259495,259502,259509,259517,259524,259531,259538,259545,259552,259559,259566,259573,259580,259587,259594,259601,259608,259615,259622,259629,259636,259643,259650,259657,259664,259670,259677,259684,259691,259698,259705,259712,259718,259725,259732,259739,259746,259752,259759,259766,259773,259779,259786,259793,259800,259806,259813,259820,259826,259833,259840,259846,259853,259860,259866,259873,259879,259886,259893,259899,259906,259912,259919,259925,259932,259938,259945,259951,259958,259964,259971,259977,259984,259990,259997,260003,260009,260016,260022,260029,260035,260041,260048,260054,260060,260067,260073,260079,260085,260092,260098,260104,260111,260117,260123,260129,260135,260142,260148,260154,260160,260166,260173,260179,260185,260191,260197,260203,260209,260215,260221,260228,260234,260240,260246,260252,260258,260264,260270,260276,260282,260288,260294,260300,260306,260312,260317,260323,260329,260335,260341,260347,260353,260359,260365,260370,260376,260382,260388,260394,260399,260405,260411,260417,260423,260428,260434,260440,260445,260451,260457,260463,260468,260474,260480,260485,260491,260496,260502,260508,260513,260519,260525,260530,260536,260541,260547,260552,260558,260563,260569,260574,260580,260585,260591,260596,260602,260607,260613,260618,260623,260629,260634,260640,260645,260650,260656,260661,260666,260672,260677,260682,260688,260693,260698,260703,260709,260714,260719,260724,260730,260735,260740,260745,260750,260756,260761,260766,260771,260776,260781,260786,260791,260797,260802,260807,260812,260817,260822,260827,260832,260837,260842,260847,260852,260857,260862,260867,260872,260877,260882,260887,260892,260896,260901,260906,260911,260916,260921,260926,260930,260935,260940,260945,260950,260955,260959,260964,260969,260974,260978,260983,260988,260992,260997,261002,261007,261011,261016,261021,261025,261030,261034,261039,261044,261048,261053,261057,261062,261067,261071,261076,261080,261085,261089,261094,261098,261103,261107,261112,261116,261120,261125,261129,261134,261138,261143,261147,261151,261156,261160,261164,261169,261173,261177,261182,261186,261190,261195,261199,261203,261207,261212,261216,261220,261224,261228,261233,261237,261241,261245,261249,261253,261258,261262,261266,261270,261274,261278,261282,261286,261290,261294,261298,261302,261306,261310,261314,261318,261322,261326,261330,261334,261338,261342,261346,261350,261354,261358,261362,261366,261369,261373,261377,261381,261385,261389,261392,261396,261400,261404,261408,261411,261415,261419,261423,261426,261430,261434,261437,261441,261445,261448,261452,261456,261459,261463,261467,261470,261474,261477,261481,261485,261488,261492,261495,261499,261502,261506,261509,261513,261516,261520,261523,261527,261530,261533,261537,261540,261544,261547,261551,261554,261557,261561,261564,261567,261571,261574,261577,261581,261584,261587,261590,261594,261597,261600,261603,261607,261610,261613,261616,261619,261623,261626,261629,261632,261635,261638,261641,261644,261648,261651,261654,261657,261660,261663,261666,261669,261672,261675,261678,261681,261684,261687,261690,261693,261696,261699,261702,261705,261708,261710,261713,261716,261719,261722,261725,261728,261730,261733,261736,261739,261742,261744,261747,261750,261753,261755,261758,261761,261764,261766,261769,261772,261774,261777,261780,261782,261785,261788,261790,261793,261795,261798,261801,261803,261806,261808,261811,261813,261816,261818,261821,261823,261826,261828,261831,261833,261836,261838,261840,261843,261845,261848,261850,261852,261855,261857,261859,261862,261864,261866,261869,261871,261873,261876,261878,261880,261882,261885,261887,261889,261891,261894,261896,261898,261900,261902,261904,261907,261909,261911,261913,261915,261917,261919,261921,261923,261925,261927,261929,261932,261934,261936,261938,261940,261942,261943,261945,261947,261949,261951,261953,261955,261957,261959,261961,261963,261965,261966,261968,261970,261972,261974,261975,261977,261979,261981,261983,261984,261986,261988,261990,261991,261993,261995,261996,261998,262000,262001,262003,262005,262006,262008,262010,262011,262013,262014,262016,262018,262019,262021,262022,262024,262025,262027,262028,262030,262031,262033,262034,262036,262037,262038,262040,262041,262043,262044,262045,262047,262048,262050,262051,262052,262054,262055,262056,262057,262059,262060,262061,262063,262064,262065,262066,262067,262069,262070,262071,262072,262073,262075,262076,262077,262078,262079,262080,262081,262082,262084,262085,262086,262087,262088,262089,262090,262091,262092,262093,262094,262095,262096,262097,262098,262099,262100,262101,262101,262102,262103,262104,262105,262106,262107,262108,262108,262109,262110,262111,262112,262112,262113,262114,262115,262115,262116,262117,262118,262118,262119,262120,262120,262121,262122,262122,262123,262124,262124,262125,262125,262126,262127,262127,262128,262128,262129,262129,262130,262130,262131,262131,262132,262132,262133,262133,262134,262134,262135,262135,262135,262136,262136,262137,262137,262137,262138,262138,262138,262139,262139,262139,262140,262140,262140,262140,262141,262141,262141,262141,262142,262142,262142,262142,262142,262143,262143,262143,262143,262143,262143,262143,262144,262144,262144,262144,262144,262144,262144,262144,262144,262144,262144,0};
-#define ILOGCOSTABSIZE 15
-#define ICOSTABSIZE (1<<ILOGCOSTABSIZE)
-static t_sample cos_table[] = {262144,262144,262144,262144,262144,262144,262144,262144,262144,262144,262144,262143,262143,262143,262143,262143,262143,262143,262142,262142,262142,262142,262142,262141,262141,262141,262141,262140,262140,262140,262140,262139,262139,262139,262138,262138,262138,262137,262137,262137,262136,262136,262135,262135,262135,262134,262134,262133,262133,262132,262132,262131,262131,262130,262130,262129,262129,262128,262128,262127,262127,262126,262125,262125,262124,262124,262123,262122,262122,262121,262120,262120,262119,262118,262118,262117,262116,262115,262115,262114,262113,262112,262112,262111,262110,262109,262108,262108,262107,262106,262105,262104,262103,262102,262101,262101,262100,262099,262098,262097,262096,262095,262094,262093,262092,262091,262090,262089,262088,262087,262086,262085,262084,262082,262081,262080,262079,262078,262077,262076,262075,262073,262072,262071,262070,262069,262067,262066,262065,262064,262063,262061,262060,262059,262057,262056,262055,262054,262052,262051,262050,262048,262047,262045,262044,262043,262041,262040,262038,262037,262036,262034,262033,262031,262030,262028,262027,262025,262024,262022,262021,262019,262018,262016,262014,262013,262011,262010,262008,262006,262005,262003,262001,262000,261998,261996,261995,261993,261991,261990,261988,261986,261984,261983,261981,261979,261977,261975,261974,261972,261970,261968,261966,261965,261963,261961,261959,261957,261955,261953,261951,261949,261947,261945,261943,261942,261940,261938,261936,261934,261932,261929,261927,261925,261923,261921,261919,261917,261915,261913,261911,261909,261907,261904,261902,261900,261898,261896,261894,261891,261889,261887,261885,261882,261880,261878,261876,261873,261871,261869,261866,261864,261862,261859,261857,261855,261852,261850,261848,261845,261843,261840,261838,261836,261833,261831,261828,261826,261823,261821,261818,261816,261813,261811,261808,261806,261803,261801,261798,261795,261793,261790,261788,261785,261782,261780,261777,261774,261772,261769,261766,261764,261761,261758,261755,261753,261750,261747,261744,261742,261739,261736,261733,261730,261728,261725,261722,261719,261716,261713,261710,261708,261705,261702,261699,261696,261693,261690,261687,261684,261681,261678,261675,261672,261669,261666,261663,261660,261657,261654,261651,261648,261644,261641,261638,261635,261632,261629,261626,261623,261619,261616,261613,261610,261607,261603,261600,261597,261594,261590,261587,261584,261581,261577,261574,261571,261567,261564,261561,261557,261554,261551,261547,261544,261540,261537,261533,261530,261527,261523,261520,261516,261513,261509,261506,261502,261499,261495,261492,261488,261485,261481,261477,261474,261470,261467,261463,261459,261456,261452,261448,261445,261441,261437,261434,261430,261426,261423,261419,261415,261411,261408,261404,261400,261396,261392,261389,261385,261381,261377,261373,261369,261366,261362,261358,261354,261350,261346,261342,261338,261334,261330,261326,261322,261318,261314,261310,261306,261302,261298,261294,261290,261286,261282,261278,261274,261270,261266,261262,261258,261253,261249,261245,261241,261237,261233,261228,261224,261220,261216,261212,261207,261203,261199,261195,261190,261186,261182,261177,261173,261169,261164,261160,261156,261151,261147,261143,261138,261134,261129,261125,261120,261116,261112,261107,261103,261098,261094,261089,261085,261080,261076,261071,261067,261062,261057,261053,261048,261044,261039,261034,261030,261025,261021,261016,261011,261007,261002,260997,260992,260988,260983,260978,260974,260969,260964,260959,260955,260950,260945,260940,260935,260930,260926,260921,260916,260911,260906,260901,260896,260892,260887,260882,260877,260872,260867,260862,260857,260852,260847,260842,260837,260832,260827,260822,260817,260812,260807,260802,260797,260791,260786,260781,260776,260771,260766,260761,260756,260750,260745,260740,260735,260730,260724,260719,260714,260709,260703,260698,260693,260688,260682,260677,260672,260666,260661,260656,260650,260645,260640,260634,260629,260623,260618,260613,260607,260602,260596,260591,260585,260580,260574,260569,260563,260558,260552,260547,260541,260536,260530,260525,260519,260513,260508,260502,260496,260491,260485,260480,260474,260468,260463,260457,260451,260445,260440,260434,260428,260423,260417,260411,260405,260399,260394,260388,260382,260376,260370,260365,260359,260353,260347,260341,260335,260329,260323,260317,260312,260306,260300,260294,260288,260282,260276,260270,260264,260258,260252,260246,260240,260234,260228,260221,260215,260209,260203,260197,260191,260185,260179,260173,260166,260160,260154,260148,260142,260135,260129,260123,260117,260111,260104,260098,260092,260085,260079,260073,260067,260060,260054,260048,260041,260035,260029,260022,260016,260009,260003,259997,259990,259984,259977,259971,259964,259958,259951,259945,259938,259932,259925,259919,259912,259906,259899,259893,259886,259879,259873,259866,259860,259853,259846,259840,259833,259826,259820,259813,259806,259800,259793,259786,259779,259773,259766,259759,259752,259746,259739,259732,259725,259718,259712,259705,259698,259691,259684,259677,259670,259664,259657,259650,259643,259636,259629,259622,259615,259608,259601,259594,259587,259580,259573,259566,259559,259552,259545,259538,259531,259524,259517,259509,259502,259495,259488,259481,259474,259467,259459,259452,259445,259438,259431,259423,259416,259409,259402,259395,259387,259380,259373,259365,259358,259351,259343,259336,259329,259321,259314,259307,259299,259292,259285,259277,259270,259262,259255,259247,259240,259232,259225,259217,259210,259202,259195,259187,259180,259172,259165,259157,259150,259142,259135,259127,259119,259112,259104,259096,259089,259081,259073,259066,259058,259050,259043,259035,259027,259020,259012,259004,258996,258989,258981,258973,258965,258957,258950,258942,258934,258926,258918,258910,258902,258895,258887,258879,258871,258863,258855,258847,258839,258831,258823,258815,258807,258799,258791,258783,258775,258767,258759,258751,258743,258735,258727,258719,258711,258702,258694,258686,258678,258670,258662,258654,258645,258637,258629,258621,258613,258604,258596,258588,258580,258571,258563,258555,258546,258538,258530,258522,258513,258505,258496,258488,258480,258471,258463,258455,258446,258438,258429,258421,258412,258404,258396,258387,258379,258370,258362,258353,258345,258336,258327,258319,258310,258302,258293,258285,258276,258267,258259,258250,258242,258233,258224,258216,258207,258198,258190,258181,258172,258163,258155,258146,258137,258128,258120,258111,258102,258093,258084,258076,258067,258058,258049,258040,258031,258023,258014,258005,257996,257987,257978,257969,257960,257951,257942,257933,257924,257915,257906,257897,257888,257879,257870,257861,257852,257843,257834,257825,257816,257807,257798,257789,257779,257770,257761,257752,257743,257734,257724,257715,257706,257697,257688,257678,257669,257660,257651,257641,257632,257623,257613,257604,257595,257585,257576,257567,257557,257548,257539,257529,257520,257510,257501,257492,257482,257473,257463,257454,257444,257435,257425,257416,257406,257397,257387,257378,257368,257359,257349,257340,257330,257320,257311,257301,257292,257282,257272,257263,257253,257243,257234,257224,257214,257205,257195,257185,257175,257166,257156,257146,257136,257127,257117,257107,257097,257087,257078,257068,257058,257048,257038,257028,257018,257008,256999,256989,256979,256969,256959,256949,256939,256929,256919,256909,256899,256889,256879,256869,256859,256849,256839,256829,256819,256809,256798,256788,256778,256768,256758,256748,256738,256728,256717,256707,256697,256687,256677,256666,256656,256646,256636,256625,256615,256605,256595,256584,256574,256564,256553,256543,256533,256522,256512,256502,256491,256481,256470,256460,256450,256439,256429,256418,256408,256397,256387,256376,256366,256355,256345,256334,256324,256313,256303,256292,256282,256271,256261,256250,256239,256229,256218,256207,256197,256186,256176,256165,256154,256143,256133,256122,256111,256101,256090,256079,256068,256058,256047,256036,256025,256014,256004,255993,255982,255971,255960,255949,255939,255928,255917,255906,255895,255884,255873,255862,255851,255840,255829,255818,255807,255796,255785,255774,255763,255752,255741,255730,255719,255708,255697,255686,255675,255664,255653,255642,255630,255619,255608,255597,255586,255575,255564,255552,255541,255530,255519,255507,255496,255485,255474,255462,255451,255440,255429,255417,255406,255395,255383,255372,255361,255349,255338,255326,255315,255304,255292,255281,255269,255258,255246,255235,255224,255212,255201,255189,255178,255166,255155,255143,255131,255120,255108,255097,255085,255074,255062,255050,255039,255027,255015,255004,254992,254981,254969,254957,254945,254934,254922,254910,254899,254887,254875,254863,254852,254840,254828,254816,254804,254793,254781,254769,254757,254745,254733,254721,254710,254698,254686,254674,254662,254650,254638,254626,254614,254602,254590,254578,254566,254554,254542,254530,254518,254506,254494,254482,254470,254458,254446,254434,254422,254410,254397,254385,254373,254361,254349,254337,254324,254312,254300,254288,254276,254263,254251,254239,254227,254214,254202,254190,254178,254165,254153,254141,254128,254116,254104,254091,254079,254067,254054,254042,254029,254017,254004,253992,253980,253967,253955,253942,253930,253917,253905,253892,253880,253867,253855,253842,253830,253817,253804,253792,253779,253767,253754,253741,253729,253716,253704,253691,253678,253666,253653,253640,253627,253615,253602,253589,253577,253564,253551,253538,253525,253513,253500,253487,253474,253461,253449,253436,253423,253410,253397,253384,253371,253359,253346,253333,253320,253307,253294,253281,253268,253255,253242,253229,253216,253203,253190,253177,253164,253151,253138,253125,253112,253099,253085,253072,253059,253046,253033,253020,253007,252994,252980,252967,252954,252941,252928,252914,252901,252888,252875,252861,252848,252835,252822,252808,252795,252782,252768,252755,252742,252728,252715,252702,252688,252675,252662,252648,252635,252621,252608,252594,252581,252568,252554,252541,252527,252514,252500,252487,252473,252460,252446,252432,252419,252405,252392,252378,252365,252351,252337,252324,252310,252296,252283,252269,252255,252242,252228,252214,252201,252187,252173,252159,252146,252132,252118,252104,252091,252077,252063,252049,252035,252022,252008,251994,251980,251966,251952,251938,251925,251911,251897,251883,251869,251855,251841,251827,251813,251799,251785,251771,251757,251743,251729,251715,251701,251687,251673,251659,251645,251631,251617,251602,251588,251574,251560,251546,251532,251518,251503,251489,251475,251461,251447,251432,251418,251404,251390,251375,251361,251347,251333,251318,251304,251290,251275,251261,251247,251232,251218,251204,251189,251175,251161,251146,251132,251117,251103,251088,251074,251060,251045,251031,251016,251002,250987,250973,250958,250944,250929,250914,250900,250885,250871,250856,250842,250827,250812,250798,250783,250768,250754,250739,250724,250710,250695,250680,250666,250651,250636,250622,250607,250592,250577,250562,250548,250533,250518,250503,250489,250474,250459,250444,250429,250414,250399,250385,250370,250355,250340,250325,250310,250295,250280,250265,250250,250235,250220,250205,250190,250175,250160,250145,250130,250115,250100,250085,250070,250055,250040,250025,250009,249994,249979,249964,249949,249934,249919,249903,249888,249873,249858,249843,249827,249812,249797,249782,249766,249751,249736,249721,249705,249690,249675,249659,249644,249629,249613,249598,249583,249567,249552,249536,249521,249506,249490,249475,249459,249444,249428,249413,249398,249382,249367,249351,249335,249320,249304,249289,249273,249258,249242,249227,249211,249195,249180,249164,249149,249133,249117,249102,249086,249070,249055,249039,249023,249008,248992,248976,248960,248945,248929,248913,248897,248882,248866,248850,248834,248818,248803,248787,248771,248755,248739,248723,248707,248691,248676,248660,248644,248628,248612,248596,248580,248564,248548,248532,248516,248500,248484,248468,248452,248436,248420,248404,248388,248372,248356,248340,248323,248307,248291,248275,248259,248243,248227,248211,248194,248178,248162,248146,248130,248113,248097,248081,248065,248048,248032,248016,248000,247983,247967,247951,247934,247918,247902,247885,247869,247853,247836,247820,247803,247787,247771,247754,247738,247721,247705,247688,247672,247655,247639,247622,247606,247589,247573,247556,247540,247523,247507,247490,247474,247457,247440,247424,247407,247391,247374,247357,247341,247324,247307,247291,247274,247257,247241,247224,247207,247190,247174,247157,247140,247123,247107,247090,247073,247056,247040,247023,247006,246989,246972,246955,246938,246922,246905,246888,246871,246854,246837,246820,246803,246786,246769,246752,246735,246718,246701,246684,246667,246650,246633,246616,246599,246582,246565,246548,246531,246514,246497,246480,246463,246445,246428,246411,246394,246377,246360,246342,246325,246308,246291,246274,246256,246239,246222,246205,246187,246170,246153,246136,246118,246101,246084,246066,246049,246032,246014,245997,245979,245962,245945,245927,245910,245892,245875,245858,245840,245823,245805,245788,245770,245753,245735,245718,245700,245683,245665,245648,245630,245613,245595,245577,245560,245542,245525,245507,245489,245472,245454,245436,245419,245401,245383,245366,245348,245330,245313,245295,245277,245259,245242,245224,245206,245188,245171,245153,245135,245117,245099,245081,245064,245046,245028,245010,244992,244974,244956,244938,244921,244903,244885,244867,244849,244831,244813,244795,244777,244759,244741,244723,244705,244687,244669,244651,244633,244615,244597,244578,244560,244542,244524,244506,244488,244470,244452,244433,244415,244397,244379,244361,244343,244324,244306,244288,244270,244251,244233,244215,244197,244178,244160,244142,244123,244105,244087,244068,244050,244032,244013,243995,243977,243958,243940,243921,243903,243885,243866,243848,243829,243811,243792,243774,243755,243737,243718,243700,243681,243663,243644,243626,243607,243588,243570,243551,243533,243514,243496,243477,243458,243440,243421,243402,243384,243365,243346,243328,243309,243290,243271,243253,243234,243215,243196,243178,243159,243140,243121,243103,243084,243065,243046,243027,243008,242990,242971,242952,242933,242914,242895,242876,242857,242838,242819,242800,242782,242763,242744,242725,242706,242687,242668,242649,242630,242611,242591,242572,242553,242534,242515,242496,242477,242458,242439,242420,242401,242381,242362,242343,242324,242305,242286,242266,242247,242228,242209,242189,242170,242151,242132,242112,242093,242074,242055,242035,242016,241997,241977,241958,241939,241919,241900,241881,241861,241842,241822,241803,241784,241764,241745,241725,241706,241686,241667,241647,241628,241608,241589,241569,241550,241530,241511,241491,241472,241452,241433,241413,241393,241374,241354,241334,241315,241295,241276,241256,241236,241217,241197,241177,241157,241138,241118,241098,241079,241059,241039,241019,241000,240980,240960,240940,240920,240901,240881,240861,240841,240821,240801,240781,240762,240742,240722,240702,240682,240662,240642,240622,240602,240582,240562,240542,240522,240502,240482,240462,240442,240422,240402,240382,240362,240342,240322,240302,240282,240262,240242,240221,240201,240181,240161,240141,240121,240101,240080,240060,240040,240020,240000,239979,239959,239939,239919,239898,239878,239858,239838,239817,239797,239777,239756,239736,239716,239695,239675,239655,239634,239614,239593,239573,239553,239532,239512,239491,239471,239450,239430,239410,239389,239369,239348,239328,239307,239287,239266,239245,239225,239204,239184,239163,239143,239122,239101,239081,239060,239040,239019,238998,238978,238957,238936,238916,238895,238874,238853,238833,238812,238791,238771,238750,238729,238708,238688,238667,238646,238625,238604,238583,238563,238542,238521,238500,238479,238458,238437,238417,238396,238375,238354,238333,238312,238291,238270,238249,238228,238207,238186,238165,238144,238123,238102,238081,238060,238039,238018,237997,237976,237955,237934,237913,237891,237870,237849,237828,237807,237786,237765,237743,237722,237701,237680,237659,237637,237616,237595,237574,237552,237531,237510,237489,237467,237446,237425,237403,237382,237361,237339,237318,237297,237275,237254,237233,237211,237190,237168,237147,237126,237104,237083,237061,237040,237018,236997,236975,236954,236932,236911,236889,236868,236846,236825,236803,236782,236760,236738,236717,236695,236674,236652,236630,236609,236587,236565,236544,236522,236500,236479,236457,236435,236414,236392,236370,236348,236327,236305,236283,236261,236240,236218,236196,236174,236152,236131,236109,236087,236065,236043,236021,235999,235978,235956,235934,235912,235890,235868,235846,235824,235802,235780,235758,235736,235714,235692,235670,235648,235626,235604,235582,235560,235538,235516,235494,235472,235450,235428,235405,235383,235361,235339,235317,235295,235273,235250,235228,235206,235184,235162,235139,235117,235095,235073,235050,235028,235006,234984,234961,234939,234917,234894,234872,234850,234828,234805,234783,234760,234738,234716,234693,234671,234649,234626,234604,234581,234559,234536,234514,234491,234469,234446,234424,234401,234379,234356,234334,234311,234289,234266,234244,234221,234199,234176,234153,234131,234108,234086,234063,234040,234018,233995,233972,233950,233927,233904,233882,233859,233836,233813,233791,233768,233745,233722,233700,233677,233654,233631,233609,233586,233563,233540,233517,233494,233472,233449,233426,233403,233380,233357,233334,233311,233288,233265,233243,233220,233197,233174,233151,233128,233105,233082,233059,233036,233013,232990,232967,232944,232920,232897,232874,232851,232828,232805,232782,232759,232736,232713,232689,232666,232643,232620,232597,232574,232550,232527,232504,232481,232457,232434,232411,232388,232364,232341,232318,232295,232271,232248,232225,232201,232178,232155,232131,232108,232085,232061,232038,232014,231991,231968,231944,231921,231897,231874,231850,231827,231804,231780,231757,231733,231710,231686,231663,231639,231615,231592,231568,231545,231521,231498,231474,231450,231427,231403,231380,231356,231332,231309,231285,231261,231238,231214,231190,231167,231143,231119,231096,231072,231048,231024,231001,230977,230953,230929,230905,230882,230858,230834,230810,230786,230762,230739,230715,230691,230667,230643,230619,230595,230571,230548,230524,230500,230476,230452,230428,230404,230380,230356,230332,230308,230284,230260,230236,230212,230188,230164,230140,230116,230091,230067,230043,230019,229995,229971,229947,229923,229898,229874,229850,229826,229802,229778,229753,229729,229705,229681,229657,229632,229608,229584,229560,229535,229511,229487,229462,229438,229414,229389,229365,229341,229316,229292,229268,229243,229219,229194,229170,229146,229121,229097,229072,229048,229024,228999,228975,228950,228926,228901,228877,228852,228828,228803,228779,228754,228729,228705,228680,228656,228631,228607,228582,228557,228533,228508,228483,228459,228434,228409,228385,228360,228335,228311,228286,228261,228237,228212,228187,228162,228138,228113,228088,228063,228039,228014,227989,227964,227939,227914,227890,227865,227840,227815,227790,227765,227740,227716,227691,227666,227641,227616,227591,227566,227541,227516,227491,227466,227441,227416,227391,227366,227341,227316,227291,227266,227241,227216,227191,227166,227141,227115,227090,227065,227040,227015,226990,226965,226940,226914,226889,226864,226839,226814,226788,226763,226738,226713,226688,226662,226637,226612,226586,226561,226536,226511,226485,226460,226435,226409,226384,226359,226333,226308,226283,226257,226232,226206,226181,226156,226130,226105,226079,226054,226028,226003,225977,225952,225926,225901,225875,225850,225824,225799,225773,225748,225722,225697,225671,225646,225620,225594,225569,225543,225517,225492,225466,225441,225415,225389,225364,225338,225312,225287,225261,225235,225209,225184,225158,225132,225106,225081,225055,225029,225003,224978,224952,224926,224900,224874,224848,224823,224797,224771,224745,224719,224693,224667,224641,224615,224590,224564,224538,224512,224486,224460,224434,224408,224382,224356,224330,224304,224278,224252,224226,224200,224174,224148,224122,224096,224069,224043,224017,223991,223965,223939,223913,223887,223860,223834,223808,223782,223756,223730,223703,223677,223651,223625,223599,223572,223546,223520,223493,223467,223441,223415,223388,223362,223336,223309,223283,223257,223230,223204,223178,223151,223125,223099,223072,223046,223019,222993,222966,222940,222914,222887,222861,222834,222808,222781,222755,222728,222702,222675,222649,222622,222596,222569,222542,222516,222489,222463,222436,222410,222383,222356,222330,222303,222276,222250,222223,222196,222170,222143,222116,222090,222063,222036,222010,221983,221956,221929,221903,221876,221849,221822,221795,221769,221742,221715,221688,221661,221634,221608,221581,221554,221527,221500,221473,221446,221419,221393,221366,221339,221312,221285,221258,221231,221204,221177,221150,221123,221096,221069,221042,221015,220988,220961,220934,220907,220880,220853,220826,220798,220771,220744,220717,220690,220663,220636,220609,220581,220554,220527,220500,220473,220446,220418,220391,220364,220337,220309,220282,220255,220228,220200,220173,220146,220119,220091,220064,220037,220009,219982,219955,219927,219900,219873,219845,219818,219790,219763,219736,219708,219681,219653,219626,219598,219571,219544,219516,219489,219461,219434,219406,219379,219351,219324,219296,219268,219241,219213,219186,219158,219131,219103,219075,219048,219020,218993,218965,218937,218910,218882,218854,218827,218799,218771,218744,218716,218688,218660,218633,218605,218577,218549,218522,218494,218466,218438,218411,218383,218355,218327,218299,218271,218244,218216,218188,218160,218132,218104,218076,218049,218021,217993,217965,217937,217909,217881,217853,217825,217797,217769,217741,217713,217685,217657,217629,217601,217573,217545,217517,217489,217461,217433,217405,217377,217348,217320,217292,217264,217236,217208,217180,217152,217123,217095,217067,217039,217011,216982,216954,216926,216898,216870,216841,216813,216785,216757,216728,216700,216672,216643,216615,216587,216558,216530,216502,216473,216445,216417,216388,216360,216332,216303,216275,216246,216218,216190,216161,216133,216104,216076,216047,216019,215990,215962,215933,215905,215876,215848,215819,215791,215762,215734,215705,215677,215648,215619,215591,215562,215534,215505,215476,215448,215419,215390,215362,215333,215304,215276,215247,215218,215190,215161,215132,215104,215075,215046,215017,214989,214960,214931,214902,214873,214845,214816,214787,214758,214729,214701,214672,214643,214614,214585,214556,214527,214498,214470,214441,214412,214383,214354,214325,214296,214267,214238,214209,214180,214151,214122,214093,214064,214035,214006,213977,213948,213919,213890,213861,213832,213803,213774,213745,213715,213686,213657,213628,213599,213570,213541,213511,213482,213453,213424,213395,213366,213336,213307,213278,213249,213219,213190,213161,213132,213102,213073,213044,213015,212985,212956,212927,212897,212868,212839,212809,212780,212751,212721,212692,212662,212633,212604,212574,212545,212515,212486,212456,212427,212398,212368,212339,212309,212280,212250,212221,212191,212162,212132,212103,212073,212043,212014,211984,211955,211925,211896,211866,211836,211807,211777,211748,211718,211688,211659,211629,211599,211570,211540,211510,211481,211451,211421,211391,211362,211332,211302,211272,211243,211213,211183,211153,211124,211094,211064,211034,211004,210974,210945,210915,210885,210855,210825,210795,210765,210736,210706,210676,210646,210616,210586,210556,210526,210496,210466,210436,210406,210376,210346,210316,210286,210256,210226,210196,210166,210136,210106,210076,210046,210016,209986,209956,209926,209895,209865,209835,209805,209775,209745,209715,209684,209654,209624,209594,209564,209534,209503,209473,209443,209413,209382,209352,209322,209292,209261,209231,209201,209170,209140,209110,209080,209049,209019,208989,208958,208928,208897,208867,208837,208806,208776,208746,208715,208685,208654,208624,208593,208563,208533,208502,208472,208441,208411,208380,208350,208319,208289,208258,208228,208197,208166,208136,208105,208075,208044,208014,207983,207952,207922,207891,207861,207830,207799,207769,207738,207707,207677,207646,207615,207585,207554,207523,207492,207462,207431,207400,207370,207339,207308,207277,207246,207216,207185,207154,207123,207092,207062,207031,207000,206969,206938,206907,206877,206846,206815,206784,206753,206722,206691,206660,206629,206598,206567,206537,206506,206475,206444,206413,206382,206351,206320,206289,206258,206227,206196,206165,206133,206102,206071,206040,206009,205978,205947,205916,205885,205854,205823,205791,205760,205729,205698,205667,205636,205604,205573,205542,205511,205480,205448,205417,205386,205355,205324,205292,205261,205230,205198,205167,205136,205105,205073,205042,205011,204979,204948,204917,204885,204854,204823,204791,204760,204728,204697,204666,204634,204603,204571,204540,204508,204477,204446,204414,204383,204351,204320,204288,204257,204225,204194,204162,204131,204099,204067,204036,204004,203973,203941,203910,203878,203846,203815,203783,203752,203720,203688,203657,203625,203593,203562,203530,203498,203467,203435,203403,203372,203340,203308,203276,203245,203213,203181,203149,203118,203086,203054,203022,202990,202959,202927,202895,202863,202831,202799,202768,202736,202704,202672,202640,202608,202576,202544,202512,202481,202449,202417,202385,202353,202321,202289,202257,202225,202193,202161,202129,202097,202065,202033,202001,201969,201937,201905,201873,201841,201808,201776,201744,201712,201680,201648,201616,201584,201552,201519,201487,201455,201423,201391,201359,201326,201294,201262,201230,201198,201165,201133,201101,201069,201036,201004,200972,200940,200907,200875,200843,200810,200778,200746,200713,200681,200649,200616,200584,200552,200519,200487,200454,200422,200390,200357,200325,200292,200260,200228,200195,200163,200130,200098,200065,200033,200000,199968,199935,199903,199870,199838,199805,199773,199740,199708,199675,199642,199610,199577,199545,199512,199479,199447,199414,199382,199349,199316,199284,199251,199218,199186,199153,199120,199088,199055,199022,198989,198957,198924,198891,198858,198826,198793,198760,198727,198695,198662,198629,198596,198563,198531,198498,198465,198432,198399,198366,198334,198301,198268,198235,198202,198169,198136,198103,198070,198037,198004,197972,197939,197906,197873,197840,197807,197774,197741,197708,197675,197642,197609,197576,197543,197510,197476,197443,197410,197377,197344,197311,197278,197245,197212,197179,197146,197112,197079,197046,197013,196980,196947,196913,196880,196847,196814,196781,196747,196714,196681,196648,196615,196581,196548,196515,196481,196448,196415,196382,196348,196315,196282,196248,196215,196182,196148,196115,196082,196048,196015,195982,195948,195915,195881,195848,195815,195781,195748,195714,195681,195647,195614,195580,195547,195513,195480,195446,195413,195379,195346,195312,195279,195245,195212,195178,195145,195111,195078,195044,195010,194977,194943,194910,194876,194842,194809,194775,194741,194708,194674,194640,194607,194573,194539,194506,194472,194438,194405,194371,194337,194303,194270,194236,194202,194168,194135,194101,194067,194033,193999,193966,193932,193898,193864,193830,193796,193763,193729,193695,193661,193627,193593,193559,193525,193492,193458,193424,193390,193356,193322,193288,193254,193220,193186,193152,193118,193084,193050,193016,192982,192948,192914,192880,192846,192812,192778,192744,192710,192676,192641,192607,192573,192539,192505,192471,192437,192403,192369,192334,192300,192266,192232,192198,192164,192129,192095,192061,192027,191992,191958,191924,191890,191856,191821,191787,191753,191718,191684,191650,191616,191581,191547,191513,191478,191444,191410,191375,191341,191307,191272,191238,191203,191169,191135,191100,191066,191031,190997,190963,190928,190894,190859,190825,190790,190756,190721,190687,190652,190618,190583,190549,190514,190480,190445,190411,190376,190342,190307,190272,190238,190203,190169,190134,190099,190065,190030,189996,189961,189926,189892,189857,189822,189788,189753,189718,189684,189649,189614,189580,189545,189510,189475,189441,189406,189371,189336,189302,189267,189232,189197,189162,189128,189093,189058,189023,188988,188954,188919,188884,188849,188814,188779,188744,188709,188675,188640,188605,188570,188535,188500,188465,188430,188395,188360,188325,188290,188255,188220,188185,188150,188115,188080,188045,188010,187975,187940,187905,187870,187835,187800,187765,187730,187695,187660,187625,187589,187554,187519,187484,187449,187414,187379,187343,187308,187273,187238,187203,187168,187132,187097,187062,187027,186992,186956,186921,186886,186851,186815,186780,186745,186710,186674,186639,186604,186568,186533,186498,186462,186427,186392,186356,186321,186286,186250,186215,186179,186144,186109,186073,186038,186002,185967,185932,185896,185861,185825,185790,185754,185719,185683,185648,185612,185577,185541,185506,185470,185435,185399,185364,185328,185293,185257,185222,185186,185150,185115,185079,185044,185008,184972,184937,184901,184866,184830,184794,184759,184723,184687,184652,184616,184580,184545,184509,184473,184437,184402,184366,184330,184294,184259,184223,184187,184151,184116,184080,184044,184008,183972,183937,183901,183865,183829,183793,183757,183722,183686,183650,183614,183578,183542,183506,183470,183435,183399,183363,183327,183291,183255,183219,183183,183147,183111,183075,183039,183003,182967,182931,182895,182859,182823,182787,182751,182715,182679,182643,182607,182571,182535,182499,182463,182426,182390,182354,182318,182282,182246,182210,182174,182137,182101,182065,182029,181993,181957,181920,181884,181848,181812,181776,181739,181703,181667,181631,181594,181558,181522,181486,181449,181413,181377,181341,181304,181268,181232,181195,181159,181123,181086,181050,181014,180977,180941,180904,180868,180832,180795,180759,180723,180686,180650,180613,180577,180540,180504,180467,180431,180395,180358,180322,180285,180249,180212,180176,180139,180103,180066,180029,179993,179956,179920,179883,179847,179810,179774,179737,179700,179664,179627,179591,179554,179517,179481,179444,179407,179371,179334,179297,179261,179224,179187,179151,179114,179077,179041,179004,178967,178930,178894,178857,178820,178783,178747,178710,178673,178636,178600,178563,178526,178489,178452,178415,178379,178342,178305,178268,178231,178194,178158,178121,178084,178047,178010,177973,177936,177899,177862,177825,177788,177752,177715,177678,177641,177604,177567,177530,177493,177456,177419,177382,177345,177308,177271,177234,177197,177160,177123,177085,177048,177011,176974,176937,176900,176863,176826,176789,176752,176714,176677,176640,176603,176566,176529,176492,176454,176417,176380,176343,176306,176268,176231,176194,176157,176120,176082,176045,176008,175971,175933,175896,175859,175822,175784,175747,175710,175672,175635,175598,175560,175523,175486,175448,175411,175374,175336,175299,175262,175224,175187,175149,175112,175075,175037,175000,174962,174925,174887,174850,174813,174775,174738,174700,174663,174625,174588,174550,174513,174475,174438,174400,174363,174325,174288,174250,174212,174175,174137,174100,174062,174025,173987,173949,173912,173874,173837,173799,173761,173724,173686,173648,173611,173573,173535,173498,173460,173422,173385,173347,173309,173271,173234,173196,173158,173121,173083,173045,173007,172969,172932,172894,172856,172818,172781,172743,172705,172667,172629,172591,172554,172516,172478,172440,172402,172364,172326,172289,172251,172213,172175,172137,172099,172061,172023,171985,171947,171909,171871,171834,171796,171758,171720,171682,171644,171606,171568,171530,171492,171454,171416,171378,171339,171301,171263,171225,171187,171149,171111,171073,171035,170997,170959,170921,170883,170844,170806,170768,170730,170692,170654,170616,170577,170539,170501,170463,170425,170386,170348,170310,170272,170234,170195,170157,170119,170081,170042,170004,169966,169928,169889,169851,169813,169774,169736,169698,169660,169621,169583,169545,169506,169468,169430,169391,169353,169314,169276,169238,169199,169161,169122,169084,169046,169007,168969,168930,168892,168853,168815,168777,168738,168700,168661,168623,168584,168546,168507,168469,168430,168392,168353,168315,168276,168238,168199,168160,168122,168083,168045,168006,167968,167929,167890,167852,167813,167774,167736,167697,167659,167620,167581,167543,167504,167465,167427,167388,167349,167311,167272,167233,167194,167156,167117,167078,167040,167001,166962,166923,166885,166846,166807,166768,166729,166691,166652,166613,166574,166535,166497,166458,166419,166380,166341,166302,166264,166225,166186,166147,166108,166069,166030,165991,165952,165914,165875,165836,165797,165758,165719,165680,165641,165602,165563,165524,165485,165446,165407,165368,165329,165290,165251,165212,165173,165134,165095,165056,165017,164978,164939,164900,164861,164821,164782,164743,164704,164665,164626,164587,164548,164509,164469,164430,164391,164352,164313,164274,164234,164195,164156,164117,164078,164039,163999,163960,163921,163882,163842,163803,163764,163725,163685,163646,163607,163568,163528,163489,163450,163410,163371,163332,163292,163253,163214,163174,163135,163096,163056,163017,162978,162938,162899,162860,162820,162781,162741,162702,162663,162623,162584,162544,162505,162465,162426,162386,162347,162308,162268,162229,162189,162150,162110,162071,162031,161992,161952,161913,161873,161833,161794,161754,161715,161675,161636,161596,161557,161517,161477,161438,161398,161359,161319,161279,161240,161200,161160,161121,161081,161041,161002,160962,160922,160883,160843,160803,160764,160724,160684,160644,160605,160565,160525,160486,160446,160406,160366,160327,160287,160247,160207,160167,160128,160088,160048,160008,159968,159929,159889,159849,159809,159769,159729,159689,159650,159610,159570,159530,159490,159450,159410,159370,159330,159291,159251,159211,159171,159131,159091,159051,159011,158971,158931,158891,158851,158811,158771,158731,158691,158651,158611,158571,158531,158491,158451,158411,158371,158331,158291,158251,158211,158170,158130,158090,158050,158010,157970,157930,157890,157850,157809,157769,157729,157689,157649,157609,157569,157528,157488,157448,157408,157368,157327,157287,157247,157207,157167,157126,157086,157046,157006,156965,156925,156885,156845,156804,156764,156724,156683,156643,156603,156562,156522,156482,156441,156401,156361,156320,156280,156240,156199,156159,156119,156078,156038,155997,155957,155917,155876,155836,155795,155755,155715,155674,155634,155593,155553,155512,155472,155431,155391,155350,155310,155269,155229,155188,155148,155107,155067,155026,154986,154945,154905,154864,154824,154783,154742,154702,154661,154621,154580,154539,154499,154458,154418,154377,154336,154296,154255,154214,154174,154133,154093,154052,154011,153970,153930,153889,153848,153808,153767,153726,153686,153645,153604,153563,153523,153482,153441,153400,153360,153319,153278,153237,153197,153156,153115,153074,153033,152993,152952,152911,152870,152829,152788,152748,152707,152666,152625,152584,152543,152502,152461,152421,152380,152339,152298,152257,152216,152175,152134,152093,152052,152011,151970,151929,151888,151847,151806,151765,151724,151683,151642,151601,151560,151519,151478,151437,151396,151355,151314,151273,151232,151191,151150,151109,151068,151027,150986,150945,150904,150862,150821,150780,150739,150698,150657,150616,150575,150533,150492,150451,150410,150369,150328,150286,150245,150204,150163,150122,150080,150039,149998,149957,149916,149874,149833,149792,149751,149709,149668,149627,149585,149544,149503,149462,149420,149379,149338,149296,149255,149214,149172,149131,149090,149048,149007,148966,148924,148883,148842,148800,148759,148717,148676,148635,148593,148552,148510,148469,148428,148386,148345,148303,148262,148220,148179,148137,148096,148054,148013,147971,147930,147888,147847,147805,147764,147722,147681,147639,147598,147556,147515,147473,147432,147390,147348,147307,147265,147224,147182,147141,147099,147057,147016,146974,146932,146891,146849,146808,146766,146724,146683,146641,146599,146558,146516,146474,146433,146391,146349,146307,146266,146224,146182,146141,146099,146057,146015,145974,145932,145890,145848,145807,145765,145723,145681,145639,145598,145556,145514,145472,145430,145389,145347,145305,145263,145221,145179,145137,145096,145054,145012,144970,144928,144886,144844,144802,144761,144719,144677,144635,144593,144551,144509,144467,144425,144383,144341,144299,144257,144215,144173,144131,144089,144047,144005,143963,143921,143879,143837,143795,143753,143711,143669,143627,143585,143543,143501,143459,143417,143375,143333,143291,143248,143206,143164,143122,143080,143038,142996,142954,142912,142869,142827,142785,142743,142701,142659,142616,142574,142532,142490,142448,142405,142363,142321,142279,142237,142194,142152,142110,142068,142025,141983,141941,141899,141856,141814,141772,141730,141687,141645,141603,141560,141518,141476,141433,141391,141349,141306,141264,141222,141179,141137,141095,141052,141010,140968,140925,140883,140840,140798,140756,140713,140671,140628,140586,140544,140501,140459,140416,140374,140331,140289,140246,140204,140161,140119,140077,140034,139992,139949,139907,139864,139821,139779,139736,139694,139651,139609,139566,139524,139481,139439,139396,139353,139311,139268,139226,139183,139141,139098,139055,139013,138970,138927,138885,138842,138800,138757,138714,138672,138629,138586,138544,138501,138458,138416,138373,138330,138288,138245,138202,138159,138117,138074,138031,137988,137946,137903,137860,137817,137775,137732,137689,137646,137604,137561,137518,137475,137432,137390,137347,137304,137261,137218,137176,137133,137090,137047,137004,136961,136918,136876,136833,136790,136747,136704,136661,136618,136575,136532,136490,136447,136404,136361,136318,136275,136232,136189,136146,136103,136060,136017,135974,135931,135888,135845,135802,135759,135716,135673,135630,135587,135544,135501,135458,135415,135372,135329,135286,135243,135200,135157,135114,135071,135028,134984,134941,134898,134855,134812,134769,134726,134683,134640,134596,134553,134510,134467,134424,134381,134338,134294,134251,134208,134165,134122,134078,134035,133992,133949,133906,133862,133819,133776,133733,133690,133646,133603,133560,133517,133473,133430,133387,133343,133300,133257,133214,133170,133127,133084,133040,132997,132954,132910,132867,132824,132780,132737,132694,132650,132607,132564,132520,132477,132434,132390,132347,132303,132260,132217,132173,132130,132086,132043,132000,131956,131913,131869,131826,131782,131739,131695,131652,131609,131565,131522,131478,131435,131391,131348,131304,131261,131217,131174,131130,131087,131043,130999,130956,130912,130869,130825,130782,130738,130695,130651,130607,130564,130520,130477,130433,130389,130346,130302,130259,130215,130171,130128,130084,130040,129997,129953,129909,129866,129822,129778,129735,129691,129647,129604,129560,129516,129473,129429,129385,129341,129298,129254,129210,129167,129123,129079,129035,128992,128948,128904,128860,128816,128773,128729,128685,128641,128598,128554,128510,128466,128422,128378,128335,128291,128247,128203,128159,128115,128072,128028,127984,127940,127896,127852,127808,127764,127721,127677,127633,127589,127545,127501,127457,127413,127369,127325,127281,127237,127193,127150,127106,127062,127018,126974,126930,126886,126842,126798,126754,126710,126666,126622,126578,126534,126490,126446,126402,126358,126314,126269,126225,126181,126137,126093,126049,126005,125961,125917,125873,125829,125785,125741,125696,125652,125608,125564,125520,125476,125432,125388,125343,125299,125255,125211,125167,125123,125078,125034,124990,124946,124902,124857,124813,124769,124725,124681,124636,124592,124548,124504,124460,124415,124371,124327,124283,124238,124194,124150,124105,124061,124017,123973,123928,123884,123840,123795,123751,123707,123662,123618,123574,123529,123485,123441,123396,123352,123308,123263,123219,123175,123130,123086,123042,122997,122953,122908,122864,122820,122775,122731,122686,122642,122597,122553,122509,122464,122420,122375,122331,122286,122242,122197,122153,122108,122064,122019,121975,121931,121886,121842,121797,121752,121708,121663,121619,121574,121530,121485,121441,121396,121352,121307,121263,121218,121173,121129,121084,121040,120995,120950,120906,120861,120817,120772,120727,120683,120638,120594,120549,120504,120460,120415,120370,120326,120281,120236,120192,120147,120102,120058,120013,119968,119924,119879,119834,119790,119745,119700,119655,119611,119566,119521,119476,119432,119387,119342,119297,119253,119208,119163,119118,119074,119029,118984,118939,118894,118850,118805,118760,118715,118670,118626,118581,118536,118491,118446,118401,118357,118312,118267,118222,118177,118132,118087,118042,117998,117953,117908,117863,117818,117773,117728,117683,117638,117593,117549,117504,117459,117414,117369,117324,117279,117234,117189,117144,117099,117054,117009,116964,116919,116874,116829,116784,116739,116694,116649,116604,116559,116514,116469,116424,116379,116334,116289,116244,116199,116154,116109,116064,116018,115973,115928,115883,115838,115793,115748,115703,115658,115613,115567,115522,115477,115432,115387,115342,115297,115252,115206,115161,115116,115071,115026,114981,114935,114890,114845,114800,114755,114710,114664,114619,114574,114529,114483,114438,114393,114348,114303,114257,114212,114167,114122,114076,114031,113986,113941,113895,113850,113805,113759,113714,113669,113624,113578,113533,113488,113442,113397,113352,113306,113261,113216,113170,113125,113080,113034,112989,112944,112898,112853,112808,112762,112717,112671,112626,112581,112535,112490,112444,112399,112354,112308,112263,112217,112172,112126,112081,112036,111990,111945,111899,111854,111808,111763,111717,111672,111626,111581,111535,111490,111444,111399,111353,111308,111262,111217,111171,111126,111080,111035,110989,110944,110898,110853,110807,110762,110716,110670,110625,110579,110534,110488,110443,110397,110351,110306,110260,110215,110169,110123,110078,110032,109986,109941,109895,109850,109804,109758,109713,109667,109621,109576,109530,109484,109439,109393,109347,109302,109256,109210,109165,109119,109073,109027,108982,108936,108890,108845,108799,108753,108707,108662,108616,108570,108524,108479,108433,108387,108341,108295,108250,108204,108158,108112,108067,108021,107975,107929,107883,107838,107792,107746,107700,107654,107608,107563,107517,107471,107425,107379,107333,107287,107242,107196,107150,107104,107058,107012,106966,106920,106875,106829,106783,106737,106691,106645,106599,106553,106507,106461,106415,106369,106323,106278,106232,106186,106140,106094,106048,106002,105956,105910,105864,105818,105772,105726,105680,105634,105588,105542,105496,105450,105404,105358,105312,105266,105220,105174,105128,105082,105035,104989,104943,104897,104851,104805,104759,104713,104667,104621,104575,104529,104483,104436,104390,104344,104298,104252,104206,104160,104114,104067,104021,103975,103929,103883,103837,103791,103744,103698,103652,103606,103560,103514,103467,103421,103375,103329,103283,103236,103190,103144,103098,103052,103005,102959,102913,102867,102820,102774,102728,102682,102635,102589,102543,102497,102450,102404,102358,102312,102265,102219,102173,102126,102080,102034,101988,101941,101895,101849,101802,101756,101710,101663,101617,101571,101524,101478,101432,101385,101339,101293,101246,101200,101153,101107,101061,101014,100968,100922,100875,100829,100782,100736,100690,100643,100597,100550,100504,100457,100411,100365,100318,100272,100225,100179,100132,100086,100039,99993,99947,99900,99854,99807,99761,99714,99668,99621,99575,99528,99482,99435,99389,99342,99296,99249,99203,99156,99110,99063,99016,98970,98923,98877,98830,98784,98737,98691,98644,98597,98551,98504,98458,98411,98364,98318,98271,98225,98178,98131,98085,98038,97992,97945,97898,97852,97805,97758,97712,97665,97619,97572,97525,97479,97432,97385,97339,97292,97245,97199,97152,97105,97058,97012,96965,96918,96872,96825,96778,96732,96685,96638,96591,96545,96498,96451,96404,96358,96311,96264,96217,96171,96124,96077,96030,95984,95937,95890,95843,95796,95750,95703,95656,95609,95562,95516,95469,95422,95375,95328,95282,95235,95188,95141,95094,95047,95001,94954,94907,94860,94813,94766,94719,94673,94626,94579,94532,94485,94438,94391,94344,94297,94251,94204,94157,94110,94063,94016,93969,93922,93875,93828,93781,93734,93687,93640,93594,93547,93500,93453,93406,93359,93312,93265,93218,93171,93124,93077,93030,92983,92936,92889,92842,92795,92748,92701,92654,92607,92560,92513,92466,92419,92372,92325,92278,92230,92183,92136,92089,92042,91995,91948,91901,91854,91807,91760,91713,91666,91619,91571,91524,91477,91430,91383,91336,91289,91242,91195,91147,91100,91053,91006,90959,90912,90865,90817,90770,90723,90676,90629,90582,90534,90487,90440,90393,90346,90299,90251,90204,90157,90110,90063,90015,89968,89921,89874,89826,89779,89732,89685,89638,89590,89543,89496,89449,89401,89354,89307,89260,89212,89165,89118,89070,89023,88976,88929,88881,88834,88787,88739,88692,88645,88598,88550,88503,88456,88408,88361,88314,88266,88219,88172,88124,88077,88030,87982,87935,87888,87840,87793,87745,87698,87651,87603,87556,87509,87461,87414,87366,87319,87272,87224,87177,87129,87082,87035,86987,86940,86892,86845,86798,86750,86703,86655,86608,86560,86513,86465,86418,86371,86323,86276,86228,86181,86133,86086,86038,85991,85943,85896,85848,85801,85753,85706,85658,85611,85563,85516,85468,85421,85373,85326,85278,85231,85183,85136,85088,85040,84993,84945,84898,84850,84803,84755,84708,84660,84612,84565,84517,84470,84422,84374,84327,84279,84232,84184,84136,84089,84041,83994,83946,83898,83851,83803,83756,83708,83660,83613,83565,83517,83470,83422,83374,83327,83279,83231,83184,83136,83088,83041,82993,82945,82898,82850,82802,82755,82707,82659,82612,82564,82516,82468,82421,82373,82325,82278,82230,82182,82134,82087,82039,81991,81943,81896,81848,81800,81752,81705,81657,81609,81561,81514,81466,81418,81370,81322,81275,81227,81179,81131,81083,81036,80988,80940,80892,80844,80797,80749,80701,80653,80605,80557,80510,80462,80414,80366,80318,80270,80223,80175,80127,80079,80031,79983,79935,79887,79840,79792,79744,79696,79648,79600,79552,79504,79457,79409,79361,79313,79265,79217,79169,79121,79073,79025,78977,78929,78881,78834,78786,78738,78690,78642,78594,78546,78498,78450,78402,78354,78306,78258,78210,78162,78114,78066,78018,77970,77922,77874,77826,77778,77730,77682,77634,77586,77538,77490,77442,77394,77346,77298,77250,77202,77154,77106,77058,77010,76962,76914,76866,76818,76770,76721,76673,76625,76577,76529,76481,76433,76385,76337,76289,76241,76193,76144,76096,76048,76000,75952,75904,75856,75808,75760,75711,75663,75615,75567,75519,75471,75423,75375,75326,75278,75230,75182,75134,75086,75037,74989,74941,74893,74845,74797,74748,74700,74652,74604,74556,74508,74459,74411,74363,74315,74267,74218,74170,74122,74074,74025,73977,73929,73881,73833,73784,73736,73688,73640,73591,73543,73495,73447,73398,73350,73302,73254,73205,73157,73109,73061,73012,72964,72916,72867,72819,72771,72723,72674,72626,72578,72529,72481,72433,72384,72336,72288,72239,72191,72143,72095,72046,71998,71950,71901,71853,71805,71756,71708,71659,71611,71563,71514,71466,71418,71369,71321,71273,71224,71176,71127,71079,71031,70982,70934,70886,70837,70789,70740,70692,70644,70595,70547,70498,70450,70401,70353,70305,70256,70208,70159,70111,70062,70014,69966,69917,69869,69820,69772,69723,69675,69626,69578,69530,69481,69433,69384,69336,69287,69239,69190,69142,69093,69045,68996,68948,68899,68851,68802,68754,68705,68657,68608,68560,68511,68463,68414,68366,68317,68269,68220,68171,68123,68074,68026,67977,67929,67880,67832,67783,67735,67686,67637,67589,67540,67492,67443,67395,67346,67297,67249,67200,67152,67103,67055,67006,66957,66909,66860,66812,66763,66714,66666,66617,66568,66520,66471,66423,66374,66325,66277,66228,66179,66131,66082,66034,65985,65936,65888,65839,65790,65742,65693,65644,65596,65547,65498,65450,65401,65352,65304,65255,65206,65158,65109,65060,65011,64963,64914,64865,64817,64768,64719,64671,64622,64573,64524,64476,64427,64378,64329,64281,64232,64183,64135,64086,64037,63988,63940,63891,63842,63793,63745,63696,63647,63598,63550,63501,63452,63403,63354,63306,63257,63208,63159,63111,63062,63013,62964,62915,62867,62818,62769,62720,62671,62623,62574,62525,62476,62427,62378,62330,62281,62232,62183,62134,62085,62037,61988,61939,61890,61841,61792,61744,61695,61646,61597,61548,61499,61450,61402,61353,61304,61255,61206,61157,61108,61059,61011,60962,60913,60864,60815,60766,60717,60668,60619,60570,60522,60473,60424,60375,60326,60277,60228,60179,60130,60081,60032,59983,59935,59886,59837,59788,59739,59690,59641,59592,59543,59494,59445,59396,59347,59298,59249,59200,59151,59102,59053,59004,58955,58906,58857,58808,58759,58711,58662,58613,58564,58515,58466,58417,58368,58319,58270,58221,58171,58122,58073,58024,57975,57926,57877,57828,57779,57730,57681,57632,57583,57534,57485,57436,57387,57338,57289,57240,57191,57142,57093,57044,56995,56946,56896,56847,56798,56749,56700,56651,56602,56553,56504,56455,56406,56357,56308,56258,56209,56160,56111,56062,56013,55964,55915,55866,55816,55767,55718,55669,55620,55571,55522,55473,55424,55374,55325,55276,55227,55178,55129,55080,55030,54981,54932,54883,54834,54785,54736,54686,54637,54588,54539,54490,54441,54391,54342,54293,54244,54195,54145,54096,54047,53998,53949,53900,53850,53801,53752,53703,53654,53604,53555,53506,53457,53408,53358,53309,53260,53211,53161,53112,53063,53014,52965,52915,52866,52817,52768,52718,52669,52620,52571,52521,52472,52423,52374,52324,52275,52226,52177,52127,52078,52029,51980,51930,51881,51832,51782,51733,51684,51635,51585,51536,51487,51438,51388,51339,51290,51240,51191,51142,51092,51043,50994,50945,50895,50846,50797,50747,50698,50649,50599,50550,50501,50451,50402,50353,50303,50254,50205,50155,50106,50057,50007,49958,49909,49859,49810,49761,49711,49662,49613,49563,49514,49464,49415,49366,49316,49267,49218,49168,49119,49070,49020,48971,48921,48872,48823,48773,48724,48674,48625,48576,48526,48477,48427,48378,48329,48279,48230,48180,48131,48082,48032,47983,47933,47884,47835,47785,47736,47686,47637,47587,47538,47489,47439,47390,47340,47291,47241,47192,47142,47093,47044,46994,46945,46895,46846,46796,46747,46697,46648,46598,46549,46500,46450,46401,46351,46302,46252,46203,46153,46104,46054,46005,45955,45906,45856,45807,45757,45708,45658,45609,45559,45510,45460,45411,45361,45312,45262,45213,45163,45114,45064,45015,44965,44916,44866,44817,44767,44718,44668,44619,44569,44519,44470,44420,44371,44321,44272,44222,44173,44123,44074,44024,43974,43925,43875,43826,43776,43727,43677,43628,43578,43528,43479,43429,43380,43330,43281,43231,43181,43132,43082,43033,42983,42933,42884,42834,42785,42735,42686,42636,42586,42537,42487,42438,42388,42338,42289,42239,42190,42140,42090,42041,41991,41941,41892,41842,41793,41743,41693,41644,41594,41544,41495,41445,41396,41346,41296,41247,41197,41147,41098,41048,40998,40949,40899,40849,40800,40750,40701,40651,40601,40552,40502,40452,40403,40353,40303,40254,40204,40154,40105,40055,40005,39956,39906,39856,39806,39757,39707,39657,39608,39558,39508,39459,39409,39359,39310,39260,39210,39160,39111,39061,39011,38962,38912,38862,38813,38763,38713,38663,38614,38564,38514,38465,38415,38365,38315,38266,38216,38166,38116,38067,38017,37967,37917,37868,37818,37768,37719,37669,37619,37569,37520,37470,37420,37370,37321,37271,37221,37171,37122,37072,37022,36972,36922,36873,36823,36773,36723,36674,36624,36574,36524,36475,36425,36375,36325,36275,36226,36176,36126,36076,36027,35977,35927,35877,35827,35778,35728,35678,35628,35578,35529,35479,35429,35379,35329,35280,35230,35180,35130,35080,35030,34981,34931,34881,34831,34781,34732,34682,34632,34582,34532,34482,34433,34383,34333,34283,34233,34183,34134,34084,34034,33984,33934,33884,33835,33785,33735,33685,33635,33585,33535,33486,33436,33386,33336,33286,33236,33186,33137,33087,33037,32987,32937,32887,32837,32788,32738,32688,32638,32588,32538,32488,32438,32389,32339,32289,32239,32189,32139,32089,32039,31989,31940,31890,31840,31790,31740,31690,31640,31590,31540,31490,31441,31391,31341,31291,31241,31191,31141,31091,31041,30991,30942,30892,30842,30792,30742,30692,30642,30592,30542,30492,30442,30392,30342,30293,30243,30193,30143,30093,30043,29993,29943,29893,29843,29793,29743,29693,29643,29593,29543,29494,29444,29394,29344,29294,29244,29194,29144,29094,29044,28994,28944,28894,28844,28794,28744,28694,28644,28594,28544,28494,28444,28394,28344,28295,28245,28195,28145,28095,28045,27995,27945,27895,27845,27795,27745,27695,27645,27595,27545,27495,27445,27395,27345,27295,27245,27195,27145,27095,27045,26995,26945,26895,26845,26795,26745,26695,26645,26595,26545,26495,26445,26395,26345,26295,26245,26195,26145,26095,26045,25995,25945,25895,25845,25795,25745,25695,25645,25595,25545,25495,25444,25394,25344,25294,25244,25194,25144,25094,25044,24994,24944,24894,24844,24794,24744,24694,24644,24594,24544,24494,24444,24394,24344,24294,24244,24193,24143,24093,24043,23993,23943,23893,23843,23793,23743,23693,23643,23593,23543,23493,23443,23393,23342,23292,23242,23192,23142,23092,23042,22992,22942,22892,22842,22792,22742,22692,22641,22591,22541,22491,22441,22391,22341,22291,22241,22191,22141,22091,22040,21990,21940,21890,21840,21790,21740,21690,21640,21590,21540,21489,21439,21389,21339,21289,21239,21189,21139,21089,21039,20988,20938,20888,20838,20788,20738,20688,20638,20588,20538,20487,20437,20387,20337,20287,20237,20187,20137,20086,20036,19986,19936,19886,19836,19786,19736,19686,19635,19585,19535,19485,19435,19385,19335,19285,19234,19184,19134,19084,19034,18984,18934,18883,18833,18783,18733,18683,18633,18583,18532,18482,18432,18382,18332,18282,18232,18181,18131,18081,18031,17981,17931,17881,17830,17780,17730,17680,17630,17580,17530,17479,17429,17379,17329,17279,17229,17178,17128,17078,17028,16978,16928,16878,16827,16777,16727,16677,16627,16577,16526,16476,16426,16376,16326,16276,16225,16175,16125,16075,16025,15975,15924,15874,15824,15774,15724,15673,15623,15573,15523,15473,15423,15372,15322,15272,15222,15172,15122,15071,15021,14971,14921,14871,14820,14770,14720,14670,14620,14569,14519,14469,14419,14369,14319,14268,14218,14168,14118,14068,14017,13967,13917,13867,13817,13766,13716,13666,13616,13566,13515,13465,13415,13365,13315,13264,13214,13164,13114,13064,13013,12963,12913,12863,12813,12762,12712,12662,12612,12562,12511,12461,12411,12361,12311,12260,12210,12160,12110,12059,12009,11959,11909,11859,11808,11758,11708,11658,11608,11557,11507,11457,11407,11356,11306,11256,11206,11156,11105,11055,11005,10955,10904,10854,10804,10754,10704,10653,10603,10553,10503,10452,10402,10352,10302,10252,10201,10151,10101,10051,10000,9950,9900,9850,9799,9749,9699,9649,9599,9548,9498,9448,9398,9347,9297,9247,9197,9146,9096,9046,8996,8946,8895,8845,8795,8745,8694,8644,8594,8544,8493,8443,8393,8343,8292,8242,8192,8142,8091,8041,7991,7941,7890,7840,7790,7740,7690,7639,7589,7539,7489,7438,7388,7338,7288,7237,7187,7137,7087,7036,6986,6936,6886,6835,6785,6735,6685,6634,6584,6534,6484,6433,6383,6333,6283,6232,6182,6132,6082,6031,5981,5931,5881,5830,5780,5730,5680,5629,5579,5529,5479,5428,5378,5328,5278,5227,5177,5127,5076,5026,4976,4926,4875,4825,4775,4725,4674,4624,4574,4524,4473,4423,4373,4323,4272,4222,4172,4122,4071,4021,3971,3921,3870,3820,3770,3720,3669,3619,3569,3518,3468,3418,3368,3317,3267,3217,3167,3116,3066,3016,2966,2915,2865,2815,2765,2714,2664,2614,2563,2513,2463,2413,2362,2312,2262,2212,2161,2111,2061,2011,1960,1910,1860,1810,1759,1709,1659,1608,1558,1508,1458,1407,1357,1307,1257,1206,1156,1106,1056,1005,955,905,855,804,754,704,653,603,553,503,452,402,352,302,251,201,151,101,50,0,-49,-100,-150,-200,-250,-301,-351,-401,-451,-502,-552,-602,-652,-703,-753,-803,-854,-904,-954,-1004,-1055,-1105,-1155,-1205,-1256,-1306,-1356,-1406,-1457,-1507,-1557,-1607,-1658,-1708,-1758,-1809,-1859,-1909,-1959,-2010,-2060,-2110,-2160,-2211,-2261,-2311,-2361,-2412,-2462,-2512,-2562,-2613,-2663,-2713,-2764,-2814,-2864,-2914,-2965,-3015,-3065,-3115,-3166,-3216,-3266,-3316,-3367,-3417,-3467,-3517,-3568,-3618,-3668,-3719,-3769,-3819,-3869,-3920,-3970,-4020,-4070,-4121,-4171,-4221,-4271,-4322,-4372,-4422,-4472,-4523,-4573,-4623,-4673,-4724,-4774,-4824,-4874,-4925,-4975,-5025,-5075,-5126,-5176,-5226,-5277,-5327,-5377,-5427,-5478,-5528,-5578,-5628,-5679,-5729,-5779,-5829,-5880,-5930,-5980,-6030,-6081,-6131,-6181,-6231,-6282,-6332,-6382,-6432,-6483,-6533,-6583,-6633,-6684,-6734,-6784,-6834,-6885,-6935,-6985,-7035,-7086,-7136,-7186,-7236,-7287,-7337,-7387,-7437,-7488,-7538,-7588,-7638,-7689,-7739,-7789,-7839,-7889,-7940,-7990,-8040,-8090,-8141,-8191,-8241,-8291,-8342,-8392,-8442,-8492,-8543,-8593,-8643,-8693,-8744,-8794,-8844,-8894,-8945,-8995,-9045,-9095,-9145,-9196,-9246,-9296,-9346,-9397,-9447,-9497,-9547,-9598,-9648,-9698,-9748,-9798,-9849,-9899,-9949,-9999,-10050,-10100,-10150,-10200,-10251,-10301,-10351,-10401,-10451,-10502,-10552,-10602,-10652,-10703,-10753,-10803,-10853,-10903,-10954,-11004,-11054,-11104,-11155,-11205,-11255,-11305,-11355,-11406,-11456,-11506,-11556,-11607,-11657,-11707,-11757,-11807,-11858,-11908,-11958,-12008,-12058,-12109,-12159,-12209,-12259,-12310,-12360,-12410,-12460,-12510,-12561,-12611,-12661,-12711,-12761,-12812,-12862,-12912,-12962,-13012,-13063,-13113,-13163,-13213,-13263,-13314,-13364,-13414,-13464,-13514,-13565,-13615,-13665,-13715,-13765,-13816,-13866,-13916,-13966,-14016,-14067,-14117,-14167,-14217,-14267,-14318,-14368,-14418,-14468,-14518,-14568,-14619,-14669,-14719,-14769,-14819,-14870,-14920,-14970,-15020,-15070,-15121,-15171,-15221,-15271,-15321,-15371,-15422,-15472,-15522,-15572,-15622,-15672,-15723,-15773,-15823,-15873,-15923,-15974,-16024,-16074,-16124,-16174,-16224,-16275,-16325,-16375,-16425,-16475,-16525,-16576,-16626,-16676,-16726,-16776,-16826,-16877,-16927,-16977,-17027,-17077,-17127,-17177,-17228,-17278,-17328,-17378,-17428,-17478,-17529,-17579,-17629,-17679,-17729,-17779,-17829,-17880,-17930,-17980,-18030,-18080,-18130,-18180,-18231,-18281,-18331,-18381,-18431,-18481,-18531,-18582,-18632,-18682,-18732,-18782,-18832,-18882,-18933,-18983,-19033,-19083,-19133,-19183,-19233,-19284,-19334,-19384,-19434,-19484,-19534,-19584,-19634,-19685,-19735,-19785,-19835,-19885,-19935,-19985,-20035,-20085,-20136,-20186,-20236,-20286,-20336,-20386,-20436,-20486,-20537,-20587,-20637,-20687,-20737,-20787,-20837,-20887,-20937,-20987,-21038,-21088,-21138,-21188,-21238,-21288,-21338,-21388,-21438,-21488,-21539,-21589,-21639,-21689,-21739,-21789,-21839,-21889,-21939,-21989,-22039,-22090,-22140,-22190,-22240,-22290,-22340,-22390,-22440,-22490,-22540,-22590,-22640,-22691,-22741,-22791,-22841,-22891,-22941,-22991,-23041,-23091,-23141,-23191,-23241,-23291,-23341,-23392,-23442,-23492,-23542,-23592,-23642,-23692,-23742,-23792,-23842,-23892,-23942,-23992,-24042,-24092,-24142,-24192,-24243,-24293,-24343,-24393,-24443,-24493,-24543,-24593,-24643,-24693,-24743,-24793,-24843,-24893,-24943,-24993,-25043,-25093,-25143,-25193,-25243,-25293,-25343,-25393,-25443,-25494,-25544,-25594,-25644,-25694,-25744,-25794,-25844,-25894,-25944,-25994,-26044,-26094,-26144,-26194,-26244,-26294,-26344,-26394,-26444,-26494,-26544,-26594,-26644,-26694,-26744,-26794,-26844,-26894,-26944,-26994,-27044,-27094,-27144,-27194,-27244,-27294,-27344,-27394,-27444,-27494,-27544,-27594,-27644,-27694,-27744,-27794,-27844,-27894,-27944,-27994,-28044,-28094,-28144,-28194,-28244,-28294,-28343,-28393,-28443,-28493,-28543,-28593,-28643,-28693,-28743,-28793,-28843,-28893,-28943,-28993,-29043,-29093,-29143,-29193,-29243,-29293,-29343,-29393,-29443,-29493,-29542,-29592,-29642,-29692,-29742,-29792,-29842,-29892,-29942,-29992,-30042,-30092,-30142,-30192,-30242,-30292,-30341,-30391,-30441,-30491,-30541,-30591,-30641,-30691,-30741,-30791,-30841,-30891,-30941,-30990,-31040,-31090,-31140,-31190,-31240,-31290,-31340,-31390,-31440,-31489,-31539,-31589,-31639,-31689,-31739,-31789,-31839,-31889,-31939,-31988,-32038,-32088,-32138,-32188,-32238,-32288,-32338,-32388,-32437,-32487,-32537,-32587,-32637,-32687,-32737,-32787,-32836,-32886,-32936,-32986,-33036,-33086,-33136,-33185,-33235,-33285,-33335,-33385,-33435,-33485,-33534,-33584,-33634,-33684,-33734,-33784,-33834,-33883,-33933,-33983,-34033,-34083,-34133,-34182,-34232,-34282,-34332,-34382,-34432,-34481,-34531,-34581,-34631,-34681,-34731,-34780,-34830,-34880,-34930,-34980,-35029,-35079,-35129,-35179,-35229,-35279,-35328,-35378,-35428,-35478,-35528,-35577,-35627,-35677,-35727,-35777,-35826,-35876,-35926,-35976,-36026,-36075,-36125,-36175,-36225,-36274,-36324,-36374,-36424,-36474,-36523,-36573,-36623,-36673,-36722,-36772,-36822,-36872,-36921,-36971,-37021,-37071,-37121,-37170,-37220,-37270,-37320,-37369,-37419,-37469,-37519,-37568,-37618,-37668,-37718,-37767,-37817,-37867,-37916,-37966,-38016,-38066,-38115,-38165,-38215,-38265,-38314,-38364,-38414,-38464,-38513,-38563,-38613,-38662,-38712,-38762,-38812,-38861,-38911,-38961,-39010,-39060,-39110,-39159,-39209,-39259,-39309,-39358,-39408,-39458,-39507,-39557,-39607,-39656,-39706,-39756,-39805,-39855,-39905,-39955,-40004,-40054,-40104,-40153,-40203,-40253,-40302,-40352,-40402,-40451,-40501,-40551,-40600,-40650,-40700,-40749,-40799,-40848,-40898,-40948,-40997,-41047,-41097,-41146,-41196,-41246,-41295,-41345,-41395,-41444,-41494,-41543,-41593,-41643,-41692,-41742,-41792,-41841,-41891,-41940,-41990,-42040,-42089,-42139,-42189,-42238,-42288,-42337,-42387,-42437,-42486,-42536,-42585,-42635,-42685,-42734,-42784,-42833,-42883,-42932,-42982,-43032,-43081,-43131,-43180,-43230,-43280,-43329,-43379,-43428,-43478,-43527,-43577,-43627,-43676,-43726,-43775,-43825,-43874,-43924,-43973,-44023,-44073,-44122,-44172,-44221,-44271,-44320,-44370,-44419,-44469,-44518,-44568,-44618,-44667,-44717,-44766,-44816,-44865,-44915,-44964,-45014,-45063,-45113,-45162,-45212,-45261,-45311,-45360,-45410,-45459,-45509,-45558,-45608,-45657,-45707,-45756,-45806,-45855,-45905,-45954,-46004,-46053,-46103,-46152,-46202,-46251,-46301,-46350,-46400,-46449,-46499,-46548,-46597,-46647,-46696,-46746,-46795,-46845,-46894,-46944,-46993,-47043,-47092,-47141,-47191,-47240,-47290,-47339,-47389,-47438,-47488,-47537,-47586,-47636,-47685,-47735,-47784,-47834,-47883,-47932,-47982,-48031,-48081,-48130,-48179,-48229,-48278,-48328,-48377,-48426,-48476,-48525,-48575,-48624,-48673,-48723,-48772,-48822,-48871,-48920,-48970,-49019,-49069,-49118,-49167,-49217,-49266,-49315,-49365,-49414,-49463,-49513,-49562,-49612,-49661,-49710,-49760,-49809,-49858,-49908,-49957,-50006,-50056,-50105,-50154,-50204,-50253,-50302,-50352,-50401,-50450,-50500,-50549,-50598,-50648,-50697,-50746,-50796,-50845,-50894,-50944,-50993,-51042,-51091,-51141,-51190,-51239,-51289,-51338,-51387,-51437,-51486,-51535,-51584,-51634,-51683,-51732,-51781,-51831,-51880,-51929,-51979,-52028,-52077,-52126,-52176,-52225,-52274,-52323,-52373,-52422,-52471,-52520,-52570,-52619,-52668,-52717,-52767,-52816,-52865,-52914,-52964,-53013,-53062,-53111,-53160,-53210,-53259,-53308,-53357,-53407,-53456,-53505,-53554,-53603,-53653,-53702,-53751,-53800,-53849,-53899,-53948,-53997,-54046,-54095,-54144,-54194,-54243,-54292,-54341,-54390,-54440,-54489,-54538,-54587,-54636,-54685,-54735,-54784,-54833,-54882,-54931,-54980,-55029,-55079,-55128,-55177,-55226,-55275,-55324,-55373,-55423,-55472,-55521,-55570,-55619,-55668,-55717,-55766,-55815,-55865,-55914,-55963,-56012,-56061,-56110,-56159,-56208,-56257,-56307,-56356,-56405,-56454,-56503,-56552,-56601,-56650,-56699,-56748,-56797,-56846,-56895,-56945,-56994,-57043,-57092,-57141,-57190,-57239,-57288,-57337,-57386,-57435,-57484,-57533,-57582,-57631,-57680,-57729,-57778,-57827,-57876,-57925,-57974,-58023,-58072,-58121,-58170,-58220,-58269,-58318,-58367,-58416,-58465,-58514,-58563,-58612,-58661,-58710,-58758,-58807,-58856,-58905,-58954,-59003,-59052,-59101,-59150,-59199,-59248,-59297,-59346,-59395,-59444,-59493,-59542,-59591,-59640,-59689,-59738,-59787,-59836,-59885,-59934,-59982,-60031,-60080,-60129,-60178,-60227,-60276,-60325,-60374,-60423,-60472,-60521,-60569,-60618,-60667,-60716,-60765,-60814,-60863,-60912,-60961,-61010,-61058,-61107,-61156,-61205,-61254,-61303,-61352,-61401,-61449,-61498,-61547,-61596,-61645,-61694,-61743,-61791,-61840,-61889,-61938,-61987,-62036,-62084,-62133,-62182,-62231,-62280,-62329,-62377,-62426,-62475,-62524,-62573,-62622,-62670,-62719,-62768,-62817,-62866,-62914,-62963,-63012,-63061,-63110,-63158,-63207,-63256,-63305,-63353,-63402,-63451,-63500,-63549,-63597,-63646,-63695,-63744,-63792,-63841,-63890,-63939,-63987,-64036,-64085,-64134,-64182,-64231,-64280,-64328,-64377,-64426,-64475,-64523,-64572,-64621,-64670,-64718,-64767,-64816,-64864,-64913,-64962,-65010,-65059,-65108,-65157,-65205,-65254,-65303,-65351,-65400,-65449,-65497,-65546,-65595,-65643,-65692,-65741,-65789,-65838,-65887,-65935,-65984,-66033,-66081,-66130,-66178,-66227,-66276,-66324,-66373,-66422,-66470,-66519,-66567,-66616,-66665,-66713,-66762,-66811,-66859,-66908,-66956,-67005,-67054,-67102,-67151,-67199,-67248,-67296,-67345,-67394,-67442,-67491,-67539,-67588,-67636,-67685,-67734,-67782,-67831,-67879,-67928,-67976,-68025,-68073,-68122,-68170,-68219,-68268,-68316,-68365,-68413,-68462,-68510,-68559,-68607,-68656,-68704,-68753,-68801,-68850,-68898,-68947,-68995,-69044,-69092,-69141,-69189,-69238,-69286,-69335,-69383,-69432,-69480,-69529,-69577,-69625,-69674,-69722,-69771,-69819,-69868,-69916,-69965,-70013,-70061,-70110,-70158,-70207,-70255,-70304,-70352,-70400,-70449,-70497,-70546,-70594,-70643,-70691,-70739,-70788,-70836,-70885,-70933,-70981,-71030,-71078,-71126,-71175,-71223,-71272,-71320,-71368,-71417,-71465,-71513,-71562,-71610,-71658,-71707,-71755,-71804,-71852,-71900,-71949,-71997,-72045,-72094,-72142,-72190,-72238,-72287,-72335,-72383,-72432,-72480,-72528,-72577,-72625,-72673,-72722,-72770,-72818,-72866,-72915,-72963,-73011,-73060,-73108,-73156,-73204,-73253,-73301,-73349,-73397,-73446,-73494,-73542,-73590,-73639,-73687,-73735,-73783,-73832,-73880,-73928,-73976,-74024,-74073,-74121,-74169,-74217,-74266,-74314,-74362,-74410,-74458,-74507,-74555,-74603,-74651,-74699,-74747,-74796,-74844,-74892,-74940,-74988,-75036,-75085,-75133,-75181,-75229,-75277,-75325,-75374,-75422,-75470,-75518,-75566,-75614,-75662,-75710,-75759,-75807,-75855,-75903,-75951,-75999,-76047,-76095,-76143,-76192,-76240,-76288,-76336,-76384,-76432,-76480,-76528,-76576,-76624,-76672,-76720,-76769,-76817,-76865,-76913,-76961,-77009,-77057,-77105,-77153,-77201,-77249,-77297,-77345,-77393,-77441,-77489,-77537,-77585,-77633,-77681,-77729,-77777,-77825,-77873,-77921,-77969,-78017,-78065,-78113,-78161,-78209,-78257,-78305,-78353,-78401,-78449,-78497,-78545,-78593,-78641,-78689,-78737,-78785,-78833,-78880,-78928,-78976,-79024,-79072,-79120,-79168,-79216,-79264,-79312,-79360,-79408,-79456,-79503,-79551,-79599,-79647,-79695,-79743,-79791,-79839,-79886,-79934,-79982,-80030,-80078,-80126,-80174,-80222,-80269,-80317,-80365,-80413,-80461,-80509,-80556,-80604,-80652,-80700,-80748,-80796,-80843,-80891,-80939,-80987,-81035,-81082,-81130,-81178,-81226,-81274,-81321,-81369,-81417,-81465,-81513,-81560,-81608,-81656,-81704,-81751,-81799,-81847,-81895,-81942,-81990,-82038,-82086,-82133,-82181,-82229,-82277,-82324,-82372,-82420,-82467,-82515,-82563,-82611,-82658,-82706,-82754,-82801,-82849,-82897,-82944,-82992,-83040,-83087,-83135,-83183,-83230,-83278,-83326,-83373,-83421,-83469,-83516,-83564,-83612,-83659,-83707,-83755,-83802,-83850,-83897,-83945,-83993,-84040,-84088,-84135,-84183,-84231,-84278,-84326,-84373,-84421,-84469,-84516,-84564,-84611,-84659,-84707,-84754,-84802,-84849,-84897,-84944,-84992,-85039,-85087,-85135,-85182,-85230,-85277,-85325,-85372,-85420,-85467,-85515,-85562,-85610,-85657,-85705,-85752,-85800,-85847,-85895,-85942,-85990,-86037,-86085,-86132,-86180,-86227,-86275,-86322,-86370,-86417,-86464,-86512,-86559,-86607,-86654,-86702,-86749,-86797,-86844,-86891,-86939,-86986,-87034,-87081,-87128,-87176,-87223,-87271,-87318,-87365,-87413,-87460,-87508,-87555,-87602,-87650,-87697,-87744,-87792,-87839,-87887,-87934,-87981,-88029,-88076,-88123,-88171,-88218,-88265,-88313,-88360,-88407,-88455,-88502,-88549,-88597,-88644,-88691,-88738,-88786,-88833,-88880,-88928,-88975,-89022,-89069,-89117,-89164,-89211,-89259,-89306,-89353,-89400,-89448,-89495,-89542,-89589,-89637,-89684,-89731,-89778,-89825,-89873,-89920,-89967,-90014,-90062,-90109,-90156,-90203,-90250,-90298,-90345,-90392,-90439,-90486,-90533,-90581,-90628,-90675,-90722,-90769,-90816,-90864,-90911,-90958,-91005,-91052,-91099,-91146,-91194,-91241,-91288,-91335,-91382,-91429,-91476,-91523,-91570,-91618,-91665,-91712,-91759,-91806,-91853,-91900,-91947,-91994,-92041,-92088,-92135,-92182,-92229,-92277,-92324,-92371,-92418,-92465,-92512,-92559,-92606,-92653,-92700,-92747,-92794,-92841,-92888,-92935,-92982,-93029,-93076,-93123,-93170,-93217,-93264,-93311,-93358,-93405,-93452,-93499,-93546,-93593,-93639,-93686,-93733,-93780,-93827,-93874,-93921,-93968,-94015,-94062,-94109,-94156,-94203,-94250,-94296,-94343,-94390,-94437,-94484,-94531,-94578,-94625,-94672,-94718,-94765,-94812,-94859,-94906,-94953,-95000,-95046,-95093,-95140,-95187,-95234,-95281,-95327,-95374,-95421,-95468,-95515,-95561,-95608,-95655,-95702,-95749,-95795,-95842,-95889,-95936,-95983,-96029,-96076,-96123,-96170,-96216,-96263,-96310,-96357,-96403,-96450,-96497,-96544,-96590,-96637,-96684,-96731,-96777,-96824,-96871,-96917,-96964,-97011,-97057,-97104,-97151,-97198,-97244,-97291,-97338,-97384,-97431,-97478,-97524,-97571,-97618,-97664,-97711,-97757,-97804,-97851,-97897,-97944,-97991,-98037,-98084,-98130,-98177,-98224,-98270,-98317,-98363,-98410,-98457,-98503,-98550,-98596,-98643,-98690,-98736,-98783,-98829,-98876,-98922,-98969,-99015,-99062,-99109,-99155,-99202,-99248,-99295,-99341,-99388,-99434,-99481,-99527,-99574,-99620,-99667,-99713,-99760,-99806,-99853,-99899,-99946,-99992,-100038,-100085,-100131,-100178,-100224,-100271,-100317,-100364,-100410,-100456,-100503,-100549,-100596,-100642,-100689,-100735,-100781,-100828,-100874,-100921,-100967,-101013,-101060,-101106,-101152,-101199,-101245,-101292,-101338,-101384,-101431,-101477,-101523,-101570,-101616,-101662,-101709,-101755,-101801,-101848,-101894,-101940,-101987,-102033,-102079,-102125,-102172,-102218,-102264,-102311,-102357,-102403,-102449,-102496,-102542,-102588,-102634,-102681,-102727,-102773,-102819,-102866,-102912,-102958,-103004,-103051,-103097,-103143,-103189,-103235,-103282,-103328,-103374,-103420,-103466,-103513,-103559,-103605,-103651,-103697,-103743,-103790,-103836,-103882,-103928,-103974,-104020,-104066,-104113,-104159,-104205,-104251,-104297,-104343,-104389,-104435,-104482,-104528,-104574,-104620,-104666,-104712,-104758,-104804,-104850,-104896,-104942,-104988,-105034,-105081,-105127,-105173,-105219,-105265,-105311,-105357,-105403,-105449,-105495,-105541,-105587,-105633,-105679,-105725,-105771,-105817,-105863,-105909,-105955,-106001,-106047,-106093,-106139,-106185,-106231,-106277,-106322,-106368,-106414,-106460,-106506,-106552,-106598,-106644,-106690,-106736,-106782,-106828,-106874,-106919,-106965,-107011,-107057,-107103,-107149,-107195,-107241,-107286,-107332,-107378,-107424,-107470,-107516,-107562,-107607,-107653,-107699,-107745,-107791,-107837,-107882,-107928,-107974,-108020,-108066,-108111,-108157,-108203,-108249,-108294,-108340,-108386,-108432,-108478,-108523,-108569,-108615,-108661,-108706,-108752,-108798,-108844,-108889,-108935,-108981,-109026,-109072,-109118,-109164,-109209,-109255,-109301,-109346,-109392,-109438,-109483,-109529,-109575,-109620,-109666,-109712,-109757,-109803,-109849,-109894,-109940,-109985,-110031,-110077,-110122,-110168,-110214,-110259,-110305,-110350,-110396,-110442,-110487,-110533,-110578,-110624,-110669,-110715,-110761,-110806,-110852,-110897,-110943,-110988,-111034,-111079,-111125,-111170,-111216,-111261,-111307,-111352,-111398,-111443,-111489,-111534,-111580,-111625,-111671,-111716,-111762,-111807,-111853,-111898,-111944,-111989,-112035,-112080,-112125,-112171,-112216,-112262,-112307,-112353,-112398,-112443,-112489,-112534,-112580,-112625,-112670,-112716,-112761,-112807,-112852,-112897,-112943,-112988,-113033,-113079,-113124,-113169,-113215,-113260,-113305,-113351,-113396,-113441,-113487,-113532,-113577,-113623,-113668,-113713,-113758,-113804,-113849,-113894,-113940,-113985,-114030,-114075,-114121,-114166,-114211,-114256,-114302,-114347,-114392,-114437,-114482,-114528,-114573,-114618,-114663,-114709,-114754,-114799,-114844,-114889,-114934,-114980,-115025,-115070,-115115,-115160,-115205,-115251,-115296,-115341,-115386,-115431,-115476,-115521,-115566,-115612,-115657,-115702,-115747,-115792,-115837,-115882,-115927,-115972,-116017,-116063,-116108,-116153,-116198,-116243,-116288,-116333,-116378,-116423,-116468,-116513,-116558,-116603,-116648,-116693,-116738,-116783,-116828,-116873,-116918,-116963,-117008,-117053,-117098,-117143,-117188,-117233,-117278,-117323,-117368,-117413,-117458,-117503,-117548,-117592,-117637,-117682,-117727,-117772,-117817,-117862,-117907,-117952,-117997,-118041,-118086,-118131,-118176,-118221,-118266,-118311,-118356,-118400,-118445,-118490,-118535,-118580,-118625,-118669,-118714,-118759,-118804,-118849,-118893,-118938,-118983,-119028,-119073,-119117,-119162,-119207,-119252,-119296,-119341,-119386,-119431,-119475,-119520,-119565,-119610,-119654,-119699,-119744,-119789,-119833,-119878,-119923,-119967,-120012,-120057,-120101,-120146,-120191,-120235,-120280,-120325,-120369,-120414,-120459,-120503,-120548,-120593,-120637,-120682,-120726,-120771,-120816,-120860,-120905,-120949,-120994,-121039,-121083,-121128,-121172,-121217,-121262,-121306,-121351,-121395,-121440,-121484,-121529,-121573,-121618,-121662,-121707,-121751,-121796,-121841,-121885,-121930,-121974,-122018,-122063,-122107,-122152,-122196,-122241,-122285,-122330,-122374,-122419,-122463,-122508,-122552,-122596,-122641,-122685,-122730,-122774,-122819,-122863,-122907,-122952,-122996,-123041,-123085,-123129,-123174,-123218,-123262,-123307,-123351,-123395,-123440,-123484,-123528,-123573,-123617,-123661,-123706,-123750,-123794,-123839,-123883,-123927,-123972,-124016,-124060,-124104,-124149,-124193,-124237,-124282,-124326,-124370,-124414,-124459,-124503,-124547,-124591,-124635,-124680,-124724,-124768,-124812,-124856,-124901,-124945,-124989,-125033,-125077,-125122,-125166,-125210,-125254,-125298,-125342,-125387,-125431,-125475,-125519,-125563,-125607,-125651,-125695,-125740,-125784,-125828,-125872,-125916,-125960,-126004,-126048,-126092,-126136,-126180,-126224,-126268,-126313,-126357,-126401,-126445,-126489,-126533,-126577,-126621,-126665,-126709,-126753,-126797,-126841,-126885,-126929,-126973,-127017,-127061,-127105,-127149,-127192,-127236,-127280,-127324,-127368,-127412,-127456,-127500,-127544,-127588,-127632,-127676,-127720,-127763,-127807,-127851,-127895,-127939,-127983,-128027,-128071,-128114,-128158,-128202,-128246,-128290,-128334,-128377,-128421,-128465,-128509,-128553,-128597,-128640,-128684,-128728,-128772,-128815,-128859,-128903,-128947,-128991,-129034,-129078,-129122,-129166,-129209,-129253,-129297,-129340,-129384,-129428,-129472,-129515,-129559,-129603,-129646,-129690,-129734,-129777,-129821,-129865,-129908,-129952,-129996,-130039,-130083,-130127,-130170,-130214,-130258,-130301,-130345,-130388,-130432,-130476,-130519,-130563,-130606,-130650,-130694,-130737,-130781,-130824,-130868,-130911,-130955,-130998,-131042,-131086,-131129,-131173,-131216,-131260,-131303,-131347,-131390,-131434,-131477,-131521,-131564,-131608,-131651,-131694,-131738,-131781,-131825,-131868,-131912,-131955,-131999,-132042,-132085,-132129,-132172,-132216,-132259,-132302,-132346,-132389,-132433,-132476,-132519,-132563,-132606,-132649,-132693,-132736,-132779,-132823,-132866,-132909,-132953,-132996,-133039,-133083,-133126,-133169,-133213,-133256,-133299,-133342,-133386,-133429,-133472,-133516,-133559,-133602,-133645,-133689,-133732,-133775,-133818,-133861,-133905,-133948,-133991,-134034,-134077,-134121,-134164,-134207,-134250,-134293,-134337,-134380,-134423,-134466,-134509,-134552,-134595,-134639,-134682,-134725,-134768,-134811,-134854,-134897,-134940,-134983,-135027,-135070,-135113,-135156,-135199,-135242,-135285,-135328,-135371,-135414,-135457,-135500,-135543,-135586,-135629,-135672,-135715,-135758,-135801,-135844,-135887,-135930,-135973,-136016,-136059,-136102,-136145,-136188,-136231,-136274,-136317,-136360,-136403,-136446,-136489,-136531,-136574,-136617,-136660,-136703,-136746,-136789,-136832,-136875,-136917,-136960,-137003,-137046,-137089,-137132,-137175,-137217,-137260,-137303,-137346,-137389,-137431,-137474,-137517,-137560,-137603,-137645,-137688,-137731,-137774,-137816,-137859,-137902,-137945,-137987,-138030,-138073,-138116,-138158,-138201,-138244,-138287,-138329,-138372,-138415,-138457,-138500,-138543,-138585,-138628,-138671,-138713,-138756,-138799,-138841,-138884,-138926,-138969,-139012,-139054,-139097,-139140,-139182,-139225,-139267,-139310,-139352,-139395,-139438,-139480,-139523,-139565,-139608,-139650,-139693,-139735,-139778,-139820,-139863,-139906,-139948,-139991,-140033,-140076,-140118,-140160,-140203,-140245,-140288,-140330,-140373,-140415,-140458,-140500,-140543,-140585,-140627,-140670,-140712,-140755,-140797,-140839,-140882,-140924,-140967,-141009,-141051,-141094,-141136,-141178,-141221,-141263,-141305,-141348,-141390,-141432,-141475,-141517,-141559,-141602,-141644,-141686,-141729,-141771,-141813,-141855,-141898,-141940,-141982,-142024,-142067,-142109,-142151,-142193,-142236,-142278,-142320,-142362,-142404,-142447,-142489,-142531,-142573,-142615,-142658,-142700,-142742,-142784,-142826,-142868,-142911,-142953,-142995,-143037,-143079,-143121,-143163,-143205,-143247,-143290,-143332,-143374,-143416,-143458,-143500,-143542,-143584,-143626,-143668,-143710,-143752,-143794,-143836,-143878,-143920,-143962,-144004,-144046,-144088,-144130,-144172,-144214,-144256,-144298,-144340,-144382,-144424,-144466,-144508,-144550,-144592,-144634,-144676,-144718,-144760,-144801,-144843,-144885,-144927,-144969,-145011,-145053,-145095,-145136,-145178,-145220,-145262,-145304,-145346,-145388,-145429,-145471,-145513,-145555,-145597,-145638,-145680,-145722,-145764,-145806,-145847,-145889,-145931,-145973,-146014,-146056,-146098,-146140,-146181,-146223,-146265,-146306,-146348,-146390,-146432,-146473,-146515,-146557,-146598,-146640,-146682,-146723,-146765,-146807,-146848,-146890,-146931,-146973,-147015,-147056,-147098,-147140,-147181,-147223,-147264,-147306,-147347,-147389,-147431,-147472,-147514,-147555,-147597,-147638,-147680,-147721,-147763,-147804,-147846,-147887,-147929,-147970,-148012,-148053,-148095,-148136,-148178,-148219,-148261,-148302,-148344,-148385,-148427,-148468,-148509,-148551,-148592,-148634,-148675,-148716,-148758,-148799,-148841,-148882,-148923,-148965,-149006,-149047,-149089,-149130,-149171,-149213,-149254,-149295,-149337,-149378,-149419,-149461,-149502,-149543,-149584,-149626,-149667,-149708,-149750,-149791,-149832,-149873,-149915,-149956,-149997,-150038,-150079,-150121,-150162,-150203,-150244,-150285,-150327,-150368,-150409,-150450,-150491,-150532,-150574,-150615,-150656,-150697,-150738,-150779,-150820,-150861,-150903,-150944,-150985,-151026,-151067,-151108,-151149,-151190,-151231,-151272,-151313,-151354,-151395,-151436,-151477,-151518,-151559,-151600,-151641,-151682,-151723,-151764,-151805,-151846,-151887,-151928,-151969,-152010,-152051,-152092,-152133,-152174,-152215,-152256,-152297,-152338,-152379,-152420,-152460,-152501,-152542,-152583,-152624,-152665,-152706,-152747,-152787,-152828,-152869,-152910,-152951,-152992,-153032,-153073,-153114,-153155,-153196,-153236,-153277,-153318,-153359,-153399,-153440,-153481,-153522,-153562,-153603,-153644,-153685,-153725,-153766,-153807,-153847,-153888,-153929,-153969,-154010,-154051,-154092,-154132,-154173,-154213,-154254,-154295,-154335,-154376,-154417,-154457,-154498,-154538,-154579,-154620,-154660,-154701,-154741,-154782,-154823,-154863,-154904,-154944,-154985,-155025,-155066,-155106,-155147,-155187,-155228,-155268,-155309,-155349,-155390,-155430,-155471,-155511,-155552,-155592,-155633,-155673,-155714,-155754,-155794,-155835,-155875,-155916,-155956,-155996,-156037,-156077,-156118,-156158,-156198,-156239,-156279,-156319,-156360,-156400,-156440,-156481,-156521,-156561,-156602,-156642,-156682,-156723,-156763,-156803,-156844,-156884,-156924,-156964,-157005,-157045,-157085,-157125,-157166,-157206,-157246,-157286,-157326,-157367,-157407,-157447,-157487,-157527,-157568,-157608,-157648,-157688,-157728,-157768,-157808,-157849,-157889,-157929,-157969,-158009,-158049,-158089,-158129,-158169,-158210,-158250,-158290,-158330,-158370,-158410,-158450,-158490,-158530,-158570,-158610,-158650,-158690,-158730,-158770,-158810,-158850,-158890,-158930,-158970,-159010,-159050,-159090,-159130,-159170,-159210,-159250,-159290,-159329,-159369,-159409,-159449,-159489,-159529,-159569,-159609,-159649,-159688,-159728,-159768,-159808,-159848,-159888,-159928,-159967,-160007,-160047,-160087,-160127,-160166,-160206,-160246,-160286,-160326,-160365,-160405,-160445,-160485,-160524,-160564,-160604,-160643,-160683,-160723,-160763,-160802,-160842,-160882,-160921,-160961,-161001,-161040,-161080,-161120,-161159,-161199,-161239,-161278,-161318,-161358,-161397,-161437,-161476,-161516,-161556,-161595,-161635,-161674,-161714,-161753,-161793,-161832,-161872,-161912,-161951,-161991,-162030,-162070,-162109,-162149,-162188,-162228,-162267,-162307,-162346,-162385,-162425,-162464,-162504,-162543,-162583,-162622,-162662,-162701,-162740,-162780,-162819,-162859,-162898,-162937,-162977,-163016,-163055,-163095,-163134,-163173,-163213,-163252,-163291,-163331,-163370,-163409,-163449,-163488,-163527,-163567,-163606,-163645,-163684,-163724,-163763,-163802,-163841,-163881,-163920,-163959,-163998,-164038,-164077,-164116,-164155,-164194,-164233,-164273,-164312,-164351,-164390,-164429,-164468,-164508,-164547,-164586,-164625,-164664,-164703,-164742,-164781,-164820,-164860,-164899,-164938,-164977,-165016,-165055,-165094,-165133,-165172,-165211,-165250,-165289,-165328,-165367,-165406,-165445,-165484,-165523,-165562,-165601,-165640,-165679,-165718,-165757,-165796,-165835,-165874,-165913,-165951,-165990,-166029,-166068,-166107,-166146,-166185,-166224,-166263,-166301,-166340,-166379,-166418,-166457,-166496,-166534,-166573,-166612,-166651,-166690,-166728,-166767,-166806,-166845,-166884,-166922,-166961,-167000,-167039,-167077,-167116,-167155,-167193,-167232,-167271,-167310,-167348,-167387,-167426,-167464,-167503,-167542,-167580,-167619,-167658,-167696,-167735,-167773,-167812,-167851,-167889,-167928,-167967,-168005,-168044,-168082,-168121,-168159,-168198,-168237,-168275,-168314,-168352,-168391,-168429,-168468,-168506,-168545,-168583,-168622,-168660,-168699,-168737,-168776,-168814,-168852,-168891,-168929,-168968,-169006,-169045,-169083,-169121,-169160,-169198,-169237,-169275,-169313,-169352,-169390,-169429,-169467,-169505,-169544,-169582,-169620,-169659,-169697,-169735,-169773,-169812,-169850,-169888,-169927,-169965,-170003,-170041,-170080,-170118,-170156,-170194,-170233,-170271,-170309,-170347,-170385,-170424,-170462,-170500,-170538,-170576,-170615,-170653,-170691,-170729,-170767,-170805,-170843,-170882,-170920,-170958,-170996,-171034,-171072,-171110,-171148,-171186,-171224,-171262,-171300,-171338,-171377,-171415,-171453,-171491,-171529,-171567,-171605,-171643,-171681,-171719,-171757,-171795,-171833,-171870,-171908,-171946,-171984,-172022,-172060,-172098,-172136,-172174,-172212,-172250,-172288,-172325,-172363,-172401,-172439,-172477,-172515,-172553,-172590,-172628,-172666,-172704,-172742,-172780,-172817,-172855,-172893,-172931,-172968,-173006,-173044,-173082,-173120,-173157,-173195,-173233,-173270,-173308,-173346,-173384,-173421,-173459,-173497,-173534,-173572,-173610,-173647,-173685,-173723,-173760,-173798,-173836,-173873,-173911,-173948,-173986,-174024,-174061,-174099,-174136,-174174,-174211,-174249,-174287,-174324,-174362,-174399,-174437,-174474,-174512,-174549,-174587,-174624,-174662,-174699,-174737,-174774,-174812,-174849,-174886,-174924,-174961,-174999,-175036,-175074,-175111,-175148,-175186,-175223,-175261,-175298,-175335,-175373,-175410,-175447,-175485,-175522,-175559,-175597,-175634,-175671,-175709,-175746,-175783,-175821,-175858,-175895,-175932,-175970,-176007,-176044,-176081,-176119,-176156,-176193,-176230,-176267,-176305,-176342,-176379,-176416,-176453,-176491,-176528,-176565,-176602,-176639,-176676,-176713,-176751,-176788,-176825,-176862,-176899,-176936,-176973,-177010,-177047,-177084,-177122,-177159,-177196,-177233,-177270,-177307,-177344,-177381,-177418,-177455,-177492,-177529,-177566,-177603,-177640,-177677,-177714,-177751,-177787,-177824,-177861,-177898,-177935,-177972,-178009,-178046,-178083,-178120,-178157,-178193,-178230,-178267,-178304,-178341,-178378,-178414,-178451,-178488,-178525,-178562,-178599,-178635,-178672,-178709,-178746,-178782,-178819,-178856,-178893,-178929,-178966,-179003,-179040,-179076,-179113,-179150,-179186,-179223,-179260,-179296,-179333,-179370,-179406,-179443,-179480,-179516,-179553,-179590,-179626,-179663,-179699,-179736,-179773,-179809,-179846,-179882,-179919,-179955,-179992,-180028,-180065,-180102,-180138,-180175,-180211,-180248,-180284,-180321,-180357,-180394,-180430,-180466,-180503,-180539,-180576,-180612,-180649,-180685,-180722,-180758,-180794,-180831,-180867,-180903,-180940,-180976,-181013,-181049,-181085,-181122,-181158,-181194,-181231,-181267,-181303,-181340,-181376,-181412,-181448,-181485,-181521,-181557,-181593,-181630,-181666,-181702,-181738,-181775,-181811,-181847,-181883,-181919,-181956,-181992,-182028,-182064,-182100,-182136,-182173,-182209,-182245,-182281,-182317,-182353,-182389,-182425,-182462,-182498,-182534,-182570,-182606,-182642,-182678,-182714,-182750,-182786,-182822,-182858,-182894,-182930,-182966,-183002,-183038,-183074,-183110,-183146,-183182,-183218,-183254,-183290,-183326,-183362,-183398,-183434,-183469,-183505,-183541,-183577,-183613,-183649,-183685,-183721,-183756,-183792,-183828,-183864,-183900,-183936,-183971,-184007,-184043,-184079,-184115,-184150,-184186,-184222,-184258,-184293,-184329,-184365,-184401,-184436,-184472,-184508,-184544,-184579,-184615,-184651,-184686,-184722,-184758,-184793,-184829,-184865,-184900,-184936,-184971,-185007,-185043,-185078,-185114,-185149,-185185,-185221,-185256,-185292,-185327,-185363,-185398,-185434,-185469,-185505,-185540,-185576,-185611,-185647,-185682,-185718,-185753,-185789,-185824,-185860,-185895,-185931,-185966,-186001,-186037,-186072,-186108,-186143,-186178,-186214,-186249,-186285,-186320,-186355,-186391,-186426,-186461,-186497,-186532,-186567,-186603,-186638,-186673,-186709,-186744,-186779,-186814,-186850,-186885,-186920,-186955,-186991,-187026,-187061,-187096,-187131,-187167,-187202,-187237,-187272,-187307,-187342,-187378,-187413,-187448,-187483,-187518,-187553,-187588,-187624,-187659,-187694,-187729,-187764,-187799,-187834,-187869,-187904,-187939,-187974,-188009,-188044,-188079,-188114,-188149,-188184,-188219,-188254,-188289,-188324,-188359,-188394,-188429,-188464,-188499,-188534,-188569,-188604,-188639,-188674,-188708,-188743,-188778,-188813,-188848,-188883,-188918,-188953,-188987,-189022,-189057,-189092,-189127,-189161,-189196,-189231,-189266,-189301,-189335,-189370,-189405,-189440,-189474,-189509,-189544,-189579,-189613,-189648,-189683,-189717,-189752,-189787,-189821,-189856,-189891,-189925,-189960,-189995,-190029,-190064,-190098,-190133,-190168,-190202,-190237,-190271,-190306,-190341,-190375,-190410,-190444,-190479,-190513,-190548,-190582,-190617,-190651,-190686,-190720,-190755,-190789,-190824,-190858,-190893,-190927,-190962,-190996,-191030,-191065,-191099,-191134,-191168,-191202,-191237,-191271,-191306,-191340,-191374,-191409,-191443,-191477,-191512,-191546,-191580,-191615,-191649,-191683,-191717,-191752,-191786,-191820,-191855,-191889,-191923,-191957,-191991,-192026,-192060,-192094,-192128,-192163,-192197,-192231,-192265,-192299,-192333,-192368,-192402,-192436,-192470,-192504,-192538,-192572,-192606,-192640,-192675,-192709,-192743,-192777,-192811,-192845,-192879,-192913,-192947,-192981,-193015,-193049,-193083,-193117,-193151,-193185,-193219,-193253,-193287,-193321,-193355,-193389,-193423,-193457,-193491,-193524,-193558,-193592,-193626,-193660,-193694,-193728,-193762,-193795,-193829,-193863,-193897,-193931,-193965,-193998,-194032,-194066,-194100,-194134,-194167,-194201,-194235,-194269,-194302,-194336,-194370,-194404,-194437,-194471,-194505,-194538,-194572,-194606,-194639,-194673,-194707,-194740,-194774,-194808,-194841,-194875,-194909,-194942,-194976,-195009,-195043,-195077,-195110,-195144,-195177,-195211,-195244,-195278,-195311,-195345,-195378,-195412,-195445,-195479,-195512,-195546,-195579,-195613,-195646,-195680,-195713,-195747,-195780,-195814,-195847,-195880,-195914,-195947,-195981,-196014,-196047,-196081,-196114,-196147,-196181,-196214,-196247,-196281,-196314,-196347,-196381,-196414,-196447,-196480,-196514,-196547,-196580,-196614,-196647,-196680,-196713,-196746,-196780,-196813,-196846,-196879,-196912,-196946,-196979,-197012,-197045,-197078,-197111,-197145,-197178,-197211,-197244,-197277,-197310,-197343,-197376,-197409,-197442,-197475,-197509,-197542,-197575,-197608,-197641,-197674,-197707,-197740,-197773,-197806,-197839,-197872,-197905,-197938,-197971,-198003,-198036,-198069,-198102,-198135,-198168,-198201,-198234,-198267,-198300,-198333,-198365,-198398,-198431,-198464,-198497,-198530,-198562,-198595,-198628,-198661,-198694,-198726,-198759,-198792,-198825,-198857,-198890,-198923,-198956,-198988,-199021,-199054,-199087,-199119,-199152,-199185,-199217,-199250,-199283,-199315,-199348,-199381,-199413,-199446,-199478,-199511,-199544,-199576,-199609,-199641,-199674,-199707,-199739,-199772,-199804,-199837,-199869,-199902,-199934,-199967,-199999,-200032,-200064,-200097,-200129,-200162,-200194,-200227,-200259,-200291,-200324,-200356,-200389,-200421,-200453,-200486,-200518,-200551,-200583,-200615,-200648,-200680,-200712,-200745,-200777,-200809,-200842,-200874,-200906,-200939,-200971,-201003,-201035,-201068,-201100,-201132,-201164,-201197,-201229,-201261,-201293,-201325,-201358,-201390,-201422,-201454,-201486,-201518,-201551,-201583,-201615,-201647,-201679,-201711,-201743,-201775,-201807,-201840,-201872,-201904,-201936,-201968,-202000,-202032,-202064,-202096,-202128,-202160,-202192,-202224,-202256,-202288,-202320,-202352,-202384,-202416,-202448,-202480,-202511,-202543,-202575,-202607,-202639,-202671,-202703,-202735,-202767,-202798,-202830,-202862,-202894,-202926,-202958,-202989,-203021,-203053,-203085,-203117,-203148,-203180,-203212,-203244,-203275,-203307,-203339,-203371,-203402,-203434,-203466,-203497,-203529,-203561,-203592,-203624,-203656,-203687,-203719,-203751,-203782,-203814,-203845,-203877,-203909,-203940,-203972,-204003,-204035,-204066,-204098,-204130,-204161,-204193,-204224,-204256,-204287,-204319,-204350,-204382,-204413,-204445,-204476,-204507,-204539,-204570,-204602,-204633,-204665,-204696,-204727,-204759,-204790,-204822,-204853,-204884,-204916,-204947,-204978,-205010,-205041,-205072,-205104,-205135,-205166,-205197,-205229,-205260,-205291,-205323,-205354,-205385,-205416,-205447,-205479,-205510,-205541,-205572,-205603,-205635,-205666,-205697,-205728,-205759,-205790,-205822,-205853,-205884,-205915,-205946,-205977,-206008,-206039,-206070,-206101,-206132,-206164,-206195,-206226,-206257,-206288,-206319,-206350,-206381,-206412,-206443,-206474,-206505,-206536,-206566,-206597,-206628,-206659,-206690,-206721,-206752,-206783,-206814,-206845,-206876,-206906,-206937,-206968,-206999,-207030,-207061,-207091,-207122,-207153,-207184,-207215,-207245,-207276,-207307,-207338,-207369,-207399,-207430,-207461,-207491,-207522,-207553,-207584,-207614,-207645,-207676,-207706,-207737,-207768,-207798,-207829,-207860,-207890,-207921,-207951,-207982,-208013,-208043,-208074,-208104,-208135,-208165,-208196,-208227,-208257,-208288,-208318,-208349,-208379,-208410,-208440,-208471,-208501,-208532,-208562,-208592,-208623,-208653,-208684,-208714,-208745,-208775,-208805,-208836,-208866,-208896,-208927,-208957,-208988,-209018,-209048,-209079,-209109,-209139,-209169,-209200,-209230,-209260,-209291,-209321,-209351,-209381,-209412,-209442,-209472,-209502,-209533,-209563,-209593,-209623,-209653,-209683,-209714,-209744,-209774,-209804,-209834,-209864,-209894,-209925,-209955,-209985,-210015,-210045,-210075,-210105,-210135,-210165,-210195,-210225,-210255,-210285,-210315,-210345,-210375,-210405,-210435,-210465,-210495,-210525,-210555,-210585,-210615,-210645,-210675,-210705,-210735,-210764,-210794,-210824,-210854,-210884,-210914,-210944,-210973,-211003,-211033,-211063,-211093,-211123,-211152,-211182,-211212,-211242,-211271,-211301,-211331,-211361,-211390,-211420,-211450,-211480,-211509,-211539,-211569,-211598,-211628,-211658,-211687,-211717,-211747,-211776,-211806,-211835,-211865,-211895,-211924,-211954,-211983,-212013,-212042,-212072,-212102,-212131,-212161,-212190,-212220,-212249,-212279,-212308,-212338,-212367,-212397,-212426,-212455,-212485,-212514,-212544,-212573,-212603,-212632,-212661,-212691,-212720,-212750,-212779,-212808,-212838,-212867,-212896,-212926,-212955,-212984,-213014,-213043,-213072,-213101,-213131,-213160,-213189,-213218,-213248,-213277,-213306,-213335,-213365,-213394,-213423,-213452,-213481,-213510,-213540,-213569,-213598,-213627,-213656,-213685,-213714,-213744,-213773,-213802,-213831,-213860,-213889,-213918,-213947,-213976,-214005,-214034,-214063,-214092,-214121,-214150,-214179,-214208,-214237,-214266,-214295,-214324,-214353,-214382,-214411,-214440,-214469,-214497,-214526,-214555,-214584,-214613,-214642,-214671,-214700,-214728,-214757,-214786,-214815,-214844,-214872,-214901,-214930,-214959,-214988,-215016,-215045,-215074,-215103,-215131,-215160,-215189,-215217,-215246,-215275,-215303,-215332,-215361,-215389,-215418,-215447,-215475,-215504,-215533,-215561,-215590,-215618,-215647,-215676,-215704,-215733,-215761,-215790,-215818,-215847,-215875,-215904,-215932,-215961,-215989,-216018,-216046,-216075,-216103,-216132,-216160,-216189,-216217,-216245,-216274,-216302,-216331,-216359,-216387,-216416,-216444,-216472,-216501,-216529,-216557,-216586,-216614,-216642,-216671,-216699,-216727,-216756,-216784,-216812,-216840,-216869,-216897,-216925,-216953,-216981,-217010,-217038,-217066,-217094,-217122,-217151,-217179,-217207,-217235,-217263,-217291,-217319,-217347,-217376,-217404,-217432,-217460,-217488,-217516,-217544,-217572,-217600,-217628,-217656,-217684,-217712,-217740,-217768,-217796,-217824,-217852,-217880,-217908,-217936,-217964,-217992,-218020,-218048,-218075,-218103,-218131,-218159,-218187,-218215,-218243,-218270,-218298,-218326,-218354,-218382,-218410,-218437,-218465,-218493,-218521,-218548,-218576,-218604,-218632,-218659,-218687,-218715,-218743,-218770,-218798,-218826,-218853,-218881,-218909,-218936,-218964,-218992,-219019,-219047,-219074,-219102,-219130,-219157,-219185,-219212,-219240,-219267,-219295,-219323,-219350,-219378,-219405,-219433,-219460,-219488,-219515,-219543,-219570,-219597,-219625,-219652,-219680,-219707,-219735,-219762,-219789,-219817,-219844,-219872,-219899,-219926,-219954,-219981,-220008,-220036,-220063,-220090,-220118,-220145,-220172,-220199,-220227,-220254,-220281,-220308,-220336,-220363,-220390,-220417,-220445,-220472,-220499,-220526,-220553,-220580,-220608,-220635,-220662,-220689,-220716,-220743,-220770,-220797,-220825,-220852,-220879,-220906,-220933,-220960,-220987,-221014,-221041,-221068,-221095,-221122,-221149,-221176,-221203,-221230,-221257,-221284,-221311,-221338,-221365,-221392,-221418,-221445,-221472,-221499,-221526,-221553,-221580,-221607,-221633,-221660,-221687,-221714,-221741,-221768,-221794,-221821,-221848,-221875,-221902,-221928,-221955,-221982,-222009,-222035,-222062,-222089,-222115,-222142,-222169,-222195,-222222,-222249,-222275,-222302,-222329,-222355,-222382,-222409,-222435,-222462,-222488,-222515,-222541,-222568,-222595,-222621,-222648,-222674,-222701,-222727,-222754,-222780,-222807,-222833,-222860,-222886,-222913,-222939,-222965,-222992,-223018,-223045,-223071,-223098,-223124,-223150,-223177,-223203,-223229,-223256,-223282,-223308,-223335,-223361,-223387,-223414,-223440,-223466,-223492,-223519,-223545,-223571,-223598,-223624,-223650,-223676,-223702,-223729,-223755,-223781,-223807,-223833,-223859,-223886,-223912,-223938,-223964,-223990,-224016,-224042,-224068,-224095,-224121,-224147,-224173,-224199,-224225,-224251,-224277,-224303,-224329,-224355,-224381,-224407,-224433,-224459,-224485,-224511,-224537,-224563,-224589,-224614,-224640,-224666,-224692,-224718,-224744,-224770,-224796,-224822,-224847,-224873,-224899,-224925,-224951,-224977,-225002,-225028,-225054,-225080,-225105,-225131,-225157,-225183,-225208,-225234,-225260,-225286,-225311,-225337,-225363,-225388,-225414,-225440,-225465,-225491,-225516,-225542,-225568,-225593,-225619,-225645,-225670,-225696,-225721,-225747,-225772,-225798,-225823,-225849,-225874,-225900,-225925,-225951,-225976,-226002,-226027,-226053,-226078,-226104,-226129,-226155,-226180,-226205,-226231,-226256,-226282,-226307,-226332,-226358,-226383,-226408,-226434,-226459,-226484,-226510,-226535,-226560,-226585,-226611,-226636,-226661,-226687,-226712,-226737,-226762,-226787,-226813,-226838,-226863,-226888,-226913,-226939,-226964,-226989,-227014,-227039,-227064,-227089,-227114,-227140,-227165,-227190,-227215,-227240,-227265,-227290,-227315,-227340,-227365,-227390,-227415,-227440,-227465,-227490,-227515,-227540,-227565,-227590,-227615,-227640,-227665,-227690,-227715,-227739,-227764,-227789,-227814,-227839,-227864,-227889,-227913,-227938,-227963,-227988,-228013,-228038,-228062,-228087,-228112,-228137,-228161,-228186,-228211,-228236,-228260,-228285,-228310,-228334,-228359,-228384,-228408,-228433,-228458,-228482,-228507,-228532,-228556,-228581,-228606,-228630,-228655,-228679,-228704,-228728,-228753,-228778,-228802,-228827,-228851,-228876,-228900,-228925,-228949,-228974,-228998,-229023,-229047,-229071,-229096,-229120,-229145,-229169,-229193,-229218,-229242,-229267,-229291,-229315,-229340,-229364,-229388,-229413,-229437,-229461,-229486,-229510,-229534,-229559,-229583,-229607,-229631,-229656,-229680,-229704,-229728,-229752,-229777,-229801,-229825,-229849,-229873,-229897,-229922,-229946,-229970,-229994,-230018,-230042,-230066,-230090,-230115,-230139,-230163,-230187,-230211,-230235,-230259,-230283,-230307,-230331,-230355,-230379,-230403,-230427,-230451,-230475,-230499,-230523,-230547,-230570,-230594,-230618,-230642,-230666,-230690,-230714,-230738,-230761,-230785,-230809,-230833,-230857,-230881,-230904,-230928,-230952,-230976,-231000,-231023,-231047,-231071,-231095,-231118,-231142,-231166,-231189,-231213,-231237,-231260,-231284,-231308,-231331,-231355,-231379,-231402,-231426,-231449,-231473,-231497,-231520,-231544,-231567,-231591,-231614,-231638,-231662,-231685,-231709,-231732,-231756,-231779,-231803,-231826,-231849,-231873,-231896,-231920,-231943,-231967,-231990,-232013,-232037,-232060,-232084,-232107,-232130,-232154,-232177,-232200,-232224,-232247,-232270,-232294,-232317,-232340,-232363,-232387,-232410,-232433,-232456,-232480,-232503,-232526,-232549,-232573,-232596,-232619,-232642,-232665,-232688,-232712,-232735,-232758,-232781,-232804,-232827,-232850,-232873,-232896,-232919,-232943,-232966,-232989,-233012,-233035,-233058,-233081,-233104,-233127,-233150,-233173,-233196,-233219,-233242,-233264,-233287,-233310,-233333,-233356,-233379,-233402,-233425,-233448,-233471,-233493,-233516,-233539,-233562,-233585,-233608,-233630,-233653,-233676,-233699,-233721,-233744,-233767,-233790,-233812,-233835,-233858,-233881,-233903,-233926,-233949,-233971,-233994,-234017,-234039,-234062,-234085,-234107,-234130,-234152,-234175,-234198,-234220,-234243,-234265,-234288,-234310,-234333,-234355,-234378,-234400,-234423,-234445,-234468,-234490,-234513,-234535,-234558,-234580,-234603,-234625,-234648,-234670,-234692,-234715,-234737,-234759,-234782,-234804,-234827,-234849,-234871,-234893,-234916,-234938,-234960,-234983,-235005,-235027,-235049,-235072,-235094,-235116,-235138,-235161,-235183,-235205,-235227,-235249,-235272,-235294,-235316,-235338,-235360,-235382,-235404,-235427,-235449,-235471,-235493,-235515,-235537,-235559,-235581,-235603,-235625,-235647,-235669,-235691,-235713,-235735,-235757,-235779,-235801,-235823,-235845,-235867,-235889,-235911,-235933,-235955,-235977,-235998,-236020,-236042,-236064,-236086,-236108,-236130,-236151,-236173,-236195,-236217,-236239,-236260,-236282,-236304,-236326,-236347,-236369,-236391,-236413,-236434,-236456,-236478,-236499,-236521,-236543,-236564,-236586,-236608,-236629,-236651,-236673,-236694,-236716,-236737,-236759,-236781,-236802,-236824,-236845,-236867,-236888,-236910,-236931,-236953,-236974,-236996,-237017,-237039,-237060,-237082,-237103,-237125,-237146,-237167,-237189,-237210,-237232,-237253,-237274,-237296,-237317,-237338,-237360,-237381,-237402,-237424,-237445,-237466,-237488,-237509,-237530,-237551,-237573,-237594,-237615,-237636,-237658,-237679,-237700,-237721,-237742,-237764,-237785,-237806,-237827,-237848,-237869,-237890,-237912,-237933,-237954,-237975,-237996,-238017,-238038,-238059,-238080,-238101,-238122,-238143,-238164,-238185,-238206,-238227,-238248,-238269,-238290,-238311,-238332,-238353,-238374,-238395,-238416,-238436,-238457,-238478,-238499,-238520,-238541,-238562,-238582,-238603,-238624,-238645,-238666,-238687,-238707,-238728,-238749,-238770,-238790,-238811,-238832,-238852,-238873,-238894,-238915,-238935,-238956,-238977,-238997,-239018,-239039,-239059,-239080,-239100,-239121,-239142,-239162,-239183,-239203,-239224,-239244,-239265,-239286,-239306,-239327,-239347,-239368,-239388,-239409,-239429,-239449,-239470,-239490,-239511,-239531,-239552,-239572,-239592,-239613,-239633,-239654,-239674,-239694,-239715,-239735,-239755,-239776,-239796,-239816,-239837,-239857,-239877,-239897,-239918,-239938,-239958,-239978,-239999,-240019,-240039,-240059,-240079,-240100,-240120,-240140,-240160,-240180,-240200,-240220,-240241,-240261,-240281,-240301,-240321,-240341,-240361,-240381,-240401,-240421,-240441,-240461,-240481,-240501,-240521,-240541,-240561,-240581,-240601,-240621,-240641,-240661,-240681,-240701,-240721,-240741,-240761,-240780,-240800,-240820,-240840,-240860,-240880,-240900,-240919,-240939,-240959,-240979,-240999,-241018,-241038,-241058,-241078,-241097,-241117,-241137,-241156,-241176,-241196,-241216,-241235,-241255,-241275,-241294,-241314,-241333,-241353,-241373,-241392,-241412,-241432,-241451,-241471,-241490,-241510,-241529,-241549,-241568,-241588,-241607,-241627,-241646,-241666,-241685,-241705,-241724,-241744,-241763,-241783,-241802,-241821,-241841,-241860,-241880,-241899,-241918,-241938,-241957,-241976,-241996,-242015,-242034,-242054,-242073,-242092,-242111,-242131,-242150,-242169,-242188,-242208,-242227,-242246,-242265,-242285,-242304,-242323,-242342,-242361,-242380,-242400,-242419,-242438,-242457,-242476,-242495,-242514,-242533,-242552,-242571,-242590,-242610,-242629,-242648,-242667,-242686,-242705,-242724,-242743,-242762,-242781,-242799,-242818,-242837,-242856,-242875,-242894,-242913,-242932,-242951,-242970,-242989,-243007,-243026,-243045,-243064,-243083,-243102,-243120,-243139,-243158,-243177,-243195,-243214,-243233,-243252,-243270,-243289,-243308,-243327,-243345,-243364,-243383,-243401,-243420,-243439,-243457,-243476,-243495,-243513,-243532,-243550,-243569,-243587,-243606,-243625,-243643,-243662,-243680,-243699,-243717,-243736,-243754,-243773,-243791,-243810,-243828,-243847,-243865,-243884,-243902,-243920,-243939,-243957,-243976,-243994,-244012,-244031,-244049,-244067,-244086,-244104,-244122,-244141,-244159,-244177,-244196,-244214,-244232,-244250,-244269,-244287,-244305,-244323,-244342,-244360,-244378,-244396,-244414,-244432,-244451,-244469,-244487,-244505,-244523,-244541,-244559,-244577,-244596,-244614,-244632,-244650,-244668,-244686,-244704,-244722,-244740,-244758,-244776,-244794,-244812,-244830,-244848,-244866,-244884,-244902,-244920,-244937,-244955,-244973,-244991,-245009,-245027,-245045,-245063,-245080,-245098,-245116,-245134,-245152,-245170,-245187,-245205,-245223,-245241,-245258,-245276,-245294,-245312,-245329,-245347,-245365,-245382,-245400,-245418,-245435,-245453,-245471,-245488,-245506,-245524,-245541,-245559,-245576,-245594,-245612,-245629,-245647,-245664,-245682,-245699,-245717,-245734,-245752,-245769,-245787,-245804,-245822,-245839,-245857,-245874,-245891,-245909,-245926,-245944,-245961,-245978,-245996,-246013,-246031,-246048,-246065,-246083,-246100,-246117,-246135,-246152,-246169,-246186,-246204,-246221,-246238,-246255,-246273,-246290,-246307,-246324,-246341,-246359,-246376,-246393,-246410,-246427,-246444,-246462,-246479,-246496,-246513,-246530,-246547,-246564,-246581,-246598,-246615,-246632,-246649,-246666,-246683,-246700,-246717,-246734,-246751,-246768,-246785,-246802,-246819,-246836,-246853,-246870,-246887,-246904,-246921,-246937,-246954,-246971,-246988,-247005,-247022,-247039,-247055,-247072,-247089,-247106,-247122,-247139,-247156,-247173,-247189,-247206,-247223,-247240,-247256,-247273,-247290,-247306,-247323,-247340,-247356,-247373,-247390,-247406,-247423,-247439,-247456,-247473,-247489,-247506,-247522,-247539,-247555,-247572,-247588,-247605,-247621,-247638,-247654,-247671,-247687,-247704,-247720,-247737,-247753,-247770,-247786,-247802,-247819,-247835,-247852,-247868,-247884,-247901,-247917,-247933,-247950,-247966,-247982,-247999,-248015,-248031,-248047,-248064,-248080,-248096,-248112,-248129,-248145,-248161,-248177,-248193,-248210,-248226,-248242,-248258,-248274,-248290,-248306,-248322,-248339,-248355,-248371,-248387,-248403,-248419,-248435,-248451,-248467,-248483,-248499,-248515,-248531,-248547,-248563,-248579,-248595,-248611,-248627,-248643,-248659,-248675,-248690,-248706,-248722,-248738,-248754,-248770,-248786,-248802,-248817,-248833,-248849,-248865,-248881,-248896,-248912,-248928,-248944,-248959,-248975,-248991,-249007,-249022,-249038,-249054,-249069,-249085,-249101,-249116,-249132,-249148,-249163,-249179,-249194,-249210,-249226,-249241,-249257,-249272,-249288,-249303,-249319,-249334,-249350,-249366,-249381,-249397,-249412,-249427,-249443,-249458,-249474,-249489,-249505,-249520,-249535,-249551,-249566,-249582,-249597,-249612,-249628,-249643,-249658,-249674,-249689,-249704,-249720,-249735,-249750,-249765,-249781,-249796,-249811,-249826,-249842,-249857,-249872,-249887,-249902,-249918,-249933,-249948,-249963,-249978,-249993,-250008,-250024,-250039,-250054,-250069,-250084,-250099,-250114,-250129,-250144,-250159,-250174,-250189,-250204,-250219,-250234,-250249,-250264,-250279,-250294,-250309,-250324,-250339,-250354,-250369,-250384,-250398,-250413,-250428,-250443,-250458,-250473,-250488,-250502,-250517,-250532,-250547,-250561,-250576,-250591,-250606,-250621,-250635,-250650,-250665,-250679,-250694,-250709,-250723,-250738,-250753,-250767,-250782,-250797,-250811,-250826,-250841,-250855,-250870,-250884,-250899,-250913,-250928,-250943,-250957,-250972,-250986,-251001,-251015,-251030,-251044,-251059,-251073,-251087,-251102,-251116,-251131,-251145,-251160,-251174,-251188,-251203,-251217,-251231,-251246,-251260,-251274,-251289,-251303,-251317,-251332,-251346,-251360,-251374,-251389,-251403,-251417,-251431,-251446,-251460,-251474,-251488,-251502,-251517,-251531,-251545,-251559,-251573,-251587,-251601,-251616,-251630,-251644,-251658,-251672,-251686,-251700,-251714,-251728,-251742,-251756,-251770,-251784,-251798,-251812,-251826,-251840,-251854,-251868,-251882,-251896,-251910,-251924,-251937,-251951,-251965,-251979,-251993,-252007,-252021,-252034,-252048,-252062,-252076,-252090,-252103,-252117,-252131,-252145,-252158,-252172,-252186,-252200,-252213,-252227,-252241,-252254,-252268,-252282,-252295,-252309,-252323,-252336,-252350,-252364,-252377,-252391,-252404,-252418,-252431,-252445,-252459,-252472,-252486,-252499,-252513,-252526,-252540,-252553,-252567,-252580,-252593,-252607,-252620,-252634,-252647,-252661,-252674,-252687,-252701,-252714,-252727,-252741,-252754,-252767,-252781,-252794,-252807,-252821,-252834,-252847,-252860,-252874,-252887,-252900,-252913,-252927,-252940,-252953,-252966,-252979,-252993,-253006,-253019,-253032,-253045,-253058,-253071,-253084,-253098,-253111,-253124,-253137,-253150,-253163,-253176,-253189,-253202,-253215,-253228,-253241,-253254,-253267,-253280,-253293,-253306,-253319,-253332,-253345,-253358,-253370,-253383,-253396,-253409,-253422,-253435,-253448,-253460,-253473,-253486,-253499,-253512,-253524,-253537,-253550,-253563,-253576,-253588,-253601,-253614,-253626,-253639,-253652,-253665,-253677,-253690,-253703,-253715,-253728,-253740,-253753,-253766,-253778,-253791,-253803,-253816,-253829,-253841,-253854,-253866,-253879,-253891,-253904,-253916,-253929,-253941,-253954,-253966,-253979,-253991,-254003,-254016,-254028,-254041,-254053,-254066,-254078,-254090,-254103,-254115,-254127,-254140,-254152,-254164,-254177,-254189,-254201,-254213,-254226,-254238,-254250,-254262,-254275,-254287,-254299,-254311,-254323,-254336,-254348,-254360,-254372,-254384,-254396,-254409,-254421,-254433,-254445,-254457,-254469,-254481,-254493,-254505,-254517,-254529,-254541,-254553,-254565,-254577,-254589,-254601,-254613,-254625,-254637,-254649,-254661,-254673,-254685,-254697,-254709,-254720,-254732,-254744,-254756,-254768,-254780,-254792,-254803,-254815,-254827,-254839,-254851,-254862,-254874,-254886,-254898,-254909,-254921,-254933,-254944,-254956,-254968,-254980,-254991,-255003,-255014,-255026,-255038,-255049,-255061,-255073,-255084,-255096,-255107,-255119,-255130,-255142,-255154,-255165,-255177,-255188,-255200,-255211,-255223,-255234,-255245,-255257,-255268,-255280,-255291,-255303,-255314,-255325,-255337,-255348,-255360,-255371,-255382,-255394,-255405,-255416,-255428,-255439,-255450,-255461,-255473,-255484,-255495,-255506,-255518,-255529,-255540,-255551,-255563,-255574,-255585,-255596,-255607,-255618,-255629,-255641,-255652,-255663,-255674,-255685,-255696,-255707,-255718,-255729,-255740,-255751,-255762,-255773,-255784,-255795,-255806,-255817,-255828,-255839,-255850,-255861,-255872,-255883,-255894,-255905,-255916,-255927,-255938,-255948,-255959,-255970,-255981,-255992,-256003,-256013,-256024,-256035,-256046,-256057,-256067,-256078,-256089,-256100,-256110,-256121,-256132,-256142,-256153,-256164,-256175,-256185,-256196,-256206,-256217,-256228,-256238,-256249,-256260,-256270,-256281,-256291,-256302,-256312,-256323,-256333,-256344,-256354,-256365,-256375,-256386,-256396,-256407,-256417,-256428,-256438,-256449,-256459,-256469,-256480,-256490,-256501,-256511,-256521,-256532,-256542,-256552,-256563,-256573,-256583,-256594,-256604,-256614,-256624,-256635,-256645,-256655,-256665,-256676,-256686,-256696,-256706,-256716,-256727,-256737,-256747,-256757,-256767,-256777,-256787,-256797,-256808,-256818,-256828,-256838,-256848,-256858,-256868,-256878,-256888,-256898,-256908,-256918,-256928,-256938,-256948,-256958,-256968,-256978,-256988,-256998,-257007,-257017,-257027,-257037,-257047,-257057,-257067,-257077,-257086,-257096,-257106,-257116,-257126,-257135,-257145,-257155,-257165,-257174,-257184,-257194,-257204,-257213,-257223,-257233,-257242,-257252,-257262,-257271,-257281,-257291,-257300,-257310,-257319,-257329,-257339,-257348,-257358,-257367,-257377,-257386,-257396,-257405,-257415,-257424,-257434,-257443,-257453,-257462,-257472,-257481,-257491,-257500,-257509,-257519,-257528,-257538,-257547,-257556,-257566,-257575,-257584,-257594,-257603,-257612,-257622,-257631,-257640,-257650,-257659,-257668,-257677,-257687,-257696,-257705,-257714,-257723,-257733,-257742,-257751,-257760,-257769,-257778,-257788,-257797,-257806,-257815,-257824,-257833,-257842,-257851,-257860,-257869,-257878,-257887,-257896,-257905,-257914,-257923,-257932,-257941,-257950,-257959,-257968,-257977,-257986,-257995,-258004,-258013,-258022,-258030,-258039,-258048,-258057,-258066,-258075,-258083,-258092,-258101,-258110,-258119,-258127,-258136,-258145,-258154,-258162,-258171,-258180,-258189,-258197,-258206,-258215,-258223,-258232,-258241,-258249,-258258,-258266,-258275,-258284,-258292,-258301,-258309,-258318,-258326,-258335,-258344,-258352,-258361,-258369,-258378,-258386,-258395,-258403,-258411,-258420,-258428,-258437,-258445,-258454,-258462,-258470,-258479,-258487,-258495,-258504,-258512,-258521,-258529,-258537,-258545,-258554,-258562,-258570,-258579,-258587,-258595,-258603,-258612,-258620,-258628,-258636,-258644,-258653,-258661,-258669,-258677,-258685,-258693,-258701,-258710,-258718,-258726,-258734,-258742,-258750,-258758,-258766,-258774,-258782,-258790,-258798,-258806,-258814,-258822,-258830,-258838,-258846,-258854,-258862,-258870,-258878,-258886,-258894,-258901,-258909,-258917,-258925,-258933,-258941,-258949,-258956,-258964,-258972,-258980,-258988,-258995,-259003,-259011,-259019,-259026,-259034,-259042,-259049,-259057,-259065,-259072,-259080,-259088,-259095,-259103,-259111,-259118,-259126,-259134,-259141,-259149,-259156,-259164,-259171,-259179,-259186,-259194,-259201,-259209,-259216,-259224,-259231,-259239,-259246,-259254,-259261,-259269,-259276,-259284,-259291,-259298,-259306,-259313,-259320,-259328,-259335,-259342,-259350,-259357,-259364,-259372,-259379,-259386,-259394,-259401,-259408,-259415,-259422,-259430,-259437,-259444,-259451,-259458,-259466,-259473,-259480,-259487,-259494,-259501,-259508,-259516,-259523,-259530,-259537,-259544,-259551,-259558,-259565,-259572,-259579,-259586,-259593,-259600,-259607,-259614,-259621,-259628,-259635,-259642,-259649,-259656,-259663,-259669,-259676,-259683,-259690,-259697,-259704,-259711,-259717,-259724,-259731,-259738,-259745,-259751,-259758,-259765,-259772,-259778,-259785,-259792,-259799,-259805,-259812,-259819,-259825,-259832,-259839,-259845,-259852,-259859,-259865,-259872,-259878,-259885,-259892,-259898,-259905,-259911,-259918,-259924,-259931,-259937,-259944,-259950,-259957,-259963,-259970,-259976,-259983,-259989,-259996,-260002,-260008,-260015,-260021,-260028,-260034,-260040,-260047,-260053,-260059,-260066,-260072,-260078,-260084,-260091,-260097,-260103,-260110,-260116,-260122,-260128,-260134,-260141,-260147,-260153,-260159,-260165,-260172,-260178,-260184,-260190,-260196,-260202,-260208,-260214,-260220,-260227,-260233,-260239,-260245,-260251,-260257,-260263,-260269,-260275,-260281,-260287,-260293,-260299,-260305,-260311,-260316,-260322,-260328,-260334,-260340,-260346,-260352,-260358,-260364,-260369,-260375,-260381,-260387,-260393,-260398,-260404,-260410,-260416,-260422,-260427,-260433,-260439,-260444,-260450,-260456,-260462,-260467,-260473,-260479,-260484,-260490,-260495,-260501,-260507,-260512,-260518,-260524,-260529,-260535,-260540,-260546,-260551,-260557,-260562,-260568,-260573,-260579,-260584,-260590,-260595,-260601,-260606,-260612,-260617,-260622,-260628,-260633,-260639,-260644,-260649,-260655,-260660,-260665,-260671,-260676,-260681,-260687,-260692,-260697,-260702,-260708,-260713,-260718,-260723,-260729,-260734,-260739,-260744,-260749,-260755,-260760,-260765,-260770,-260775,-260780,-260785,-260790,-260796,-260801,-260806,-260811,-260816,-260821,-260826,-260831,-260836,-260841,-260846,-260851,-260856,-260861,-260866,-260871,-260876,-260881,-260886,-260891,-260895,-260900,-260905,-260910,-260915,-260920,-260925,-260929,-260934,-260939,-260944,-260949,-260954,-260958,-260963,-260968,-260973,-260977,-260982,-260987,-260991,-260996,-261001,-261006,-261010,-261015,-261020,-261024,-261029,-261033,-261038,-261043,-261047,-261052,-261056,-261061,-261066,-261070,-261075,-261079,-261084,-261088,-261093,-261097,-261102,-261106,-261111,-261115,-261119,-261124,-261128,-261133,-261137,-261142,-261146,-261150,-261155,-261159,-261163,-261168,-261172,-261176,-261181,-261185,-261189,-261194,-261198,-261202,-261206,-261211,-261215,-261219,-261223,-261227,-261232,-261236,-261240,-261244,-261248,-261252,-261257,-261261,-261265,-261269,-261273,-261277,-261281,-261285,-261289,-261293,-261297,-261301,-261305,-261309,-261313,-261317,-261321,-261325,-261329,-261333,-261337,-261341,-261345,-261349,-261353,-261357,-261361,-261365,-261368,-261372,-261376,-261380,-261384,-261388,-261391,-261395,-261399,-261403,-261407,-261410,-261414,-261418,-261422,-261425,-261429,-261433,-261436,-261440,-261444,-261447,-261451,-261455,-261458,-261462,-261466,-261469,-261473,-261476,-261480,-261484,-261487,-261491,-261494,-261498,-261501,-261505,-261508,-261512,-261515,-261519,-261522,-261526,-261529,-261532,-261536,-261539,-261543,-261546,-261550,-261553,-261556,-261560,-261563,-261566,-261570,-261573,-261576,-261580,-261583,-261586,-261589,-261593,-261596,-261599,-261602,-261606,-261609,-261612,-261615,-261618,-261622,-261625,-261628,-261631,-261634,-261637,-261640,-261643,-261647,-261650,-261653,-261656,-261659,-261662,-261665,-261668,-261671,-261674,-261677,-261680,-261683,-261686,-261689,-261692,-261695,-261698,-261701,-261704,-261707,-261709,-261712,-261715,-261718,-261721,-261724,-261727,-261729,-261732,-261735,-261738,-261741,-261743,-261746,-261749,-261752,-261754,-261757,-261760,-261763,-261765,-261768,-261771,-261773,-261776,-261779,-261781,-261784,-261787,-261789,-261792,-261794,-261797,-261800,-261802,-261805,-261807,-261810,-261812,-261815,-261817,-261820,-261822,-261825,-261827,-261830,-261832,-261835,-261837,-261839,-261842,-261844,-261847,-261849,-261851,-261854,-261856,-261858,-261861,-261863,-261865,-261868,-261870,-261872,-261875,-261877,-261879,-261881,-261884,-261886,-261888,-261890,-261893,-261895,-261897,-261899,-261901,-261903,-261906,-261908,-261910,-261912,-261914,-261916,-261918,-261920,-261922,-261924,-261926,-261928,-261931,-261933,-261935,-261937,-261939,-261941,-261942,-261944,-261946,-261948,-261950,-261952,-261954,-261956,-261958,-261960,-261962,-261964,-261965,-261967,-261969,-261971,-261973,-261974,-261976,-261978,-261980,-261982,-261983,-261985,-261987,-261989,-261990,-261992,-261994,-261995,-261997,-261999,-262000,-262002,-262004,-262005,-262007,-262009,-262010,-262012,-262013,-262015,-262017,-262018,-262020,-262021,-262023,-262024,-262026,-262027,-262029,-262030,-262032,-262033,-262035,-262036,-262037,-262039,-262040,-262042,-262043,-262044,-262046,-262047,-262049,-262050,-262051,-262053,-262054,-262055,-262056,-262058,-262059,-262060,-262062,-262063,-262064,-262065,-262066,-262068,-262069,-262070,-262071,-262072,-262074,-262075,-262076,-262077,-262078,-262079,-262080,-262081,-262083,-262084,-262085,-262086,-262087,-262088,-262089,-262090,-262091,-262092,-262093,-262094,-262095,-262096,-262097,-262098,-262099,-262100,-262100,-262101,-262102,-262103,-262104,-262105,-262106,-262107,-262107,-262108,-262109,-262110,-262111,-262111,-262112,-262113,-262114,-262114,-262115,-262116,-262117,-262117,-262118,-262119,-262119,-262120,-262121,-262121,-262122,-262123,-262123,-262124,-262124,-262125,-262126,-262126,-262127,-262127,-262128,-262128,-262129,-262129,-262130,-262130,-262131,-262131,-262132,-262132,-262133,-262133,-262134,-262134,-262134,-262135,-262135,-262136,-262136,-262136,-262137,-262137,-262137,-262138,-262138,-262138,-262139,-262139,-262139,-262139,-262140,-262140,-262140,-262140,-262141,-262141,-262141,-262141,-262141,-262142,-262142,-262142,-262142,-262142,-262142,-262142,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262143,-262142,-262142,-262142,-262142,-262142,-262142,-262142,-262141,-262141,-262141,-262141,-262141,-262140,-262140,-262140,-262140,-262139,-262139,-262139,-262139,-262138,-262138,-262138,-262137,-262137,-262137,-262136,-262136,-262136,-262135,-262135,-262134,-262134,-262134,-262133,-262133,-262132,-262132,-262131,-262131,-262130,-262130,-262129,-262129,-262128,-262128,-262127,-262127,-262126,-262126,-262125,-262124,-262124,-262123,-262123,-262122,-262121,-262121,-262120,-262119,-262119,-262118,-262117,-262117,-262116,-262115,-262114,-262114,-262113,-262112,-262111,-262111,-262110,-262109,-262108,-262107,-262107,-262106,-262105,-262104,-262103,-262102,-262101,-262100,-262100,-262099,-262098,-262097,-262096,-262095,-262094,-262093,-262092,-262091,-262090,-262089,-262088,-262087,-262086,-262085,-262084,-262083,-262081,-262080,-262079,-262078,-262077,-262076,-262075,-262074,-262072,-262071,-262070,-262069,-262068,-262066,-262065,-262064,-262063,-262062,-262060,-262059,-262058,-262056,-262055,-262054,-262053,-262051,-262050,-262049,-262047,-262046,-262044,-262043,-262042,-262040,-262039,-262037,-262036,-262035,-262033,-262032,-262030,-262029,-262027,-262026,-262024,-262023,-262021,-262020,-262018,-262017,-262015,-262013,-262012,-262010,-262009,-262007,-262005,-262004,-262002,-262000,-261999,-261997,-261995,-261994,-261992,-261990,-261989,-261987,-261985,-261983,-261982,-261980,-261978,-261976,-261974,-261973,-261971,-261969,-261967,-261965,-261964,-261962,-261960,-261958,-261956,-261954,-261952,-261950,-261948,-261946,-261944,-261942,-261941,-261939,-261937,-261935,-261933,-261931,-261928,-261926,-261924,-261922,-261920,-261918,-261916,-261914,-261912,-261910,-261908,-261906,-261903,-261901,-261899,-261897,-261895,-261893,-261890,-261888,-261886,-261884,-261881,-261879,-261877,-261875,-261872,-261870,-261868,-261865,-261863,-261861,-261858,-261856,-261854,-261851,-261849,-261847,-261844,-261842,-261839,-261837,-261835,-261832,-261830,-261827,-261825,-261822,-261820,-261817,-261815,-261812,-261810,-261807,-261805,-261802,-261800,-261797,-261794,-261792,-261789,-261787,-261784,-261781,-261779,-261776,-261773,-261771,-261768,-261765,-261763,-261760,-261757,-261754,-261752,-261749,-261746,-261743,-261741,-261738,-261735,-261732,-261729,-261727,-261724,-261721,-261718,-261715,-261712,-261709,-261707,-261704,-261701,-261698,-261695,-261692,-261689,-261686,-261683,-261680,-261677,-261674,-261671,-261668,-261665,-261662,-261659,-261656,-261653,-261650,-261647,-261643,-261640,-261637,-261634,-261631,-261628,-261625,-261622,-261618,-261615,-261612,-261609,-261606,-261602,-261599,-261596,-261593,-261589,-261586,-261583,-261580,-261576,-261573,-261570,-261566,-261563,-261560,-261556,-261553,-261550,-261546,-261543,-261539,-261536,-261532,-261529,-261526,-261522,-261519,-261515,-261512,-261508,-261505,-261501,-261498,-261494,-261491,-261487,-261484,-261480,-261476,-261473,-261469,-261466,-261462,-261458,-261455,-261451,-261447,-261444,-261440,-261436,-261433,-261429,-261425,-261422,-261418,-261414,-261410,-261407,-261403,-261399,-261395,-261391,-261388,-261384,-261380,-261376,-261372,-261368,-261365,-261361,-261357,-261353,-261349,-261345,-261341,-261337,-261333,-261329,-261325,-261321,-261317,-261313,-261309,-261305,-261301,-261297,-261293,-261289,-261285,-261281,-261277,-261273,-261269,-261265,-261261,-261257,-261252,-261248,-261244,-261240,-261236,-261232,-261227,-261223,-261219,-261215,-261211,-261206,-261202,-261198,-261194,-261189,-261185,-261181,-261176,-261172,-261168,-261163,-261159,-261155,-261150,-261146,-261142,-261137,-261133,-261128,-261124,-261119,-261115,-261111,-261106,-261102,-261097,-261093,-261088,-261084,-261079,-261075,-261070,-261066,-261061,-261056,-261052,-261047,-261043,-261038,-261033,-261029,-261024,-261020,-261015,-261010,-261006,-261001,-260996,-260991,-260987,-260982,-260977,-260973,-260968,-260963,-260958,-260954,-260949,-260944,-260939,-260934,-260929,-260925,-260920,-260915,-260910,-260905,-260900,-260895,-260891,-260886,-260881,-260876,-260871,-260866,-260861,-260856,-260851,-260846,-260841,-260836,-260831,-260826,-260821,-260816,-260811,-260806,-260801,-260796,-260790,-260785,-260780,-260775,-260770,-260765,-260760,-260755,-260749,-260744,-260739,-260734,-260729,-260723,-260718,-260713,-260708,-260702,-260697,-260692,-260687,-260681,-260676,-260671,-260665,-260660,-260655,-260649,-260644,-260639,-260633,-260628,-260622,-260617,-260612,-260606,-260601,-260595,-260590,-260584,-260579,-260573,-260568,-260562,-260557,-260551,-260546,-260540,-260535,-260529,-260524,-260518,-260512,-260507,-260501,-260495,-260490,-260484,-260479,-260473,-260467,-260462,-260456,-260450,-260444,-260439,-260433,-260427,-260422,-260416,-260410,-260404,-260398,-260393,-260387,-260381,-260375,-260369,-260364,-260358,-260352,-260346,-260340,-260334,-260328,-260322,-260316,-260311,-260305,-260299,-260293,-260287,-260281,-260275,-260269,-260263,-260257,-260251,-260245,-260239,-260233,-260227,-260220,-260214,-260208,-260202,-260196,-260190,-260184,-260178,-260172,-260165,-260159,-260153,-260147,-260141,-260134,-260128,-260122,-260116,-260110,-260103,-260097,-260091,-260084,-260078,-260072,-260066,-260059,-260053,-260047,-260040,-260034,-260028,-260021,-260015,-260008,-260002,-259996,-259989,-259983,-259976,-259970,-259963,-259957,-259950,-259944,-259937,-259931,-259924,-259918,-259911,-259905,-259898,-259892,-259885,-259878,-259872,-259865,-259859,-259852,-259845,-259839,-259832,-259825,-259819,-259812,-259805,-259799,-259792,-259785,-259778,-259772,-259765,-259758,-259751,-259745,-259738,-259731,-259724,-259717,-259711,-259704,-259697,-259690,-259683,-259676,-259669,-259663,-259656,-259649,-259642,-259635,-259628,-259621,-259614,-259607,-259600,-259593,-259586,-259579,-259572,-259565,-259558,-259551,-259544,-259537,-259530,-259523,-259516,-259508,-259501,-259494,-259487,-259480,-259473,-259466,-259458,-259451,-259444,-259437,-259430,-259422,-259415,-259408,-259401,-259394,-259386,-259379,-259372,-259364,-259357,-259350,-259342,-259335,-259328,-259320,-259313,-259306,-259298,-259291,-259284,-259276,-259269,-259261,-259254,-259246,-259239,-259231,-259224,-259216,-259209,-259201,-259194,-259186,-259179,-259171,-259164,-259156,-259149,-259141,-259134,-259126,-259118,-259111,-259103,-259095,-259088,-259080,-259072,-259065,-259057,-259049,-259042,-259034,-259026,-259019,-259011,-259003,-258995,-258988,-258980,-258972,-258964,-258956,-258949,-258941,-258933,-258925,-258917,-258909,-258901,-258894,-258886,-258878,-258870,-258862,-258854,-258846,-258838,-258830,-258822,-258814,-258806,-258798,-258790,-258782,-258774,-258766,-258758,-258750,-258742,-258734,-258726,-258718,-258710,-258701,-258693,-258685,-258677,-258669,-258661,-258653,-258644,-258636,-258628,-258620,-258612,-258603,-258595,-258587,-258579,-258570,-258562,-258554,-258545,-258537,-258529,-258521,-258512,-258504,-258495,-258487,-258479,-258470,-258462,-258454,-258445,-258437,-258428,-258420,-258411,-258403,-258395,-258386,-258378,-258369,-258361,-258352,-258344,-258335,-258326,-258318,-258309,-258301,-258292,-258284,-258275,-258266,-258258,-258249,-258241,-258232,-258223,-258215,-258206,-258197,-258189,-258180,-258171,-258162,-258154,-258145,-258136,-258127,-258119,-258110,-258101,-258092,-258083,-258075,-258066,-258057,-258048,-258039,-258030,-258022,-258013,-258004,-257995,-257986,-257977,-257968,-257959,-257950,-257941,-257932,-257923,-257914,-257905,-257896,-257887,-257878,-257869,-257860,-257851,-257842,-257833,-257824,-257815,-257806,-257797,-257788,-257778,-257769,-257760,-257751,-257742,-257733,-257723,-257714,-257705,-257696,-257687,-257677,-257668,-257659,-257650,-257640,-257631,-257622,-257612,-257603,-257594,-257584,-257575,-257566,-257556,-257547,-257538,-257528,-257519,-257509,-257500,-257491,-257481,-257472,-257462,-257453,-257443,-257434,-257424,-257415,-257405,-257396,-257386,-257377,-257367,-257358,-257348,-257339,-257329,-257319,-257310,-257300,-257291,-257281,-257271,-257262,-257252,-257242,-257233,-257223,-257213,-257204,-257194,-257184,-257174,-257165,-257155,-257145,-257135,-257126,-257116,-257106,-257096,-257086,-257077,-257067,-257057,-257047,-257037,-257027,-257017,-257007,-256998,-256988,-256978,-256968,-256958,-256948,-256938,-256928,-256918,-256908,-256898,-256888,-256878,-256868,-256858,-256848,-256838,-256828,-256818,-256808,-256797,-256787,-256777,-256767,-256757,-256747,-256737,-256727,-256716,-256706,-256696,-256686,-256676,-256665,-256655,-256645,-256635,-256624,-256614,-256604,-256594,-256583,-256573,-256563,-256552,-256542,-256532,-256521,-256511,-256501,-256490,-256480,-256469,-256459,-256449,-256438,-256428,-256417,-256407,-256396,-256386,-256375,-256365,-256354,-256344,-256333,-256323,-256312,-256302,-256291,-256281,-256270,-256260,-256249,-256238,-256228,-256217,-256206,-256196,-256185,-256175,-256164,-256153,-256142,-256132,-256121,-256110,-256100,-256089,-256078,-256067,-256057,-256046,-256035,-256024,-256013,-256003,-255992,-255981,-255970,-255959,-255948,-255938,-255927,-255916,-255905,-255894,-255883,-255872,-255861,-255850,-255839,-255828,-255817,-255806,-255795,-255784,-255773,-255762,-255751,-255740,-255729,-255718,-255707,-255696,-255685,-255674,-255663,-255652,-255641,-255629,-255618,-255607,-255596,-255585,-255574,-255563,-255551,-255540,-255529,-255518,-255506,-255495,-255484,-255473,-255461,-255450,-255439,-255428,-255416,-255405,-255394,-255382,-255371,-255360,-255348,-255337,-255325,-255314,-255303,-255291,-255280,-255268,-255257,-255245,-255234,-255223,-255211,-255200,-255188,-255177,-255165,-255154,-255142,-255130,-255119,-255107,-255096,-255084,-255073,-255061,-255049,-255038,-255026,-255014,-255003,-254991,-254980,-254968,-254956,-254944,-254933,-254921,-254909,-254898,-254886,-254874,-254862,-254851,-254839,-254827,-254815,-254803,-254792,-254780,-254768,-254756,-254744,-254732,-254720,-254709,-254697,-254685,-254673,-254661,-254649,-254637,-254625,-254613,-254601,-254589,-254577,-254565,-254553,-254541,-254529,-254517,-254505,-254493,-254481,-254469,-254457,-254445,-254433,-254421,-254409,-254396,-254384,-254372,-254360,-254348,-254336,-254323,-254311,-254299,-254287,-254275,-254262,-254250,-254238,-254226,-254213,-254201,-254189,-254177,-254164,-254152,-254140,-254127,-254115,-254103,-254090,-254078,-254066,-254053,-254041,-254028,-254016,-254003,-253991,-253979,-253966,-253954,-253941,-253929,-253916,-253904,-253891,-253879,-253866,-253854,-253841,-253829,-253816,-253803,-253791,-253778,-253766,-253753,-253740,-253728,-253715,-253703,-253690,-253677,-253665,-253652,-253639,-253626,-253614,-253601,-253588,-253576,-253563,-253550,-253537,-253524,-253512,-253499,-253486,-253473,-253460,-253448,-253435,-253422,-253409,-253396,-253383,-253370,-253358,-253345,-253332,-253319,-253306,-253293,-253280,-253267,-253254,-253241,-253228,-253215,-253202,-253189,-253176,-253163,-253150,-253137,-253124,-253111,-253098,-253084,-253071,-253058,-253045,-253032,-253019,-253006,-252993,-252979,-252966,-252953,-252940,-252927,-252913,-252900,-252887,-252874,-252860,-252847,-252834,-252821,-252807,-252794,-252781,-252767,-252754,-252741,-252727,-252714,-252701,-252687,-252674,-252661,-252647,-252634,-252620,-252607,-252593,-252580,-252567,-252553,-252540,-252526,-252513,-252499,-252486,-252472,-252459,-252445,-252431,-252418,-252404,-252391,-252377,-252364,-252350,-252336,-252323,-252309,-252295,-252282,-252268,-252254,-252241,-252227,-252213,-252200,-252186,-252172,-252158,-252145,-252131,-252117,-252103,-252090,-252076,-252062,-252048,-252034,-252021,-252007,-251993,-251979,-251965,-251951,-251937,-251924,-251910,-251896,-251882,-251868,-251854,-251840,-251826,-251812,-251798,-251784,-251770,-251756,-251742,-251728,-251714,-251700,-251686,-251672,-251658,-251644,-251630,-251616,-251601,-251587,-251573,-251559,-251545,-251531,-251517,-251502,-251488,-251474,-251460,-251446,-251431,-251417,-251403,-251389,-251374,-251360,-251346,-251332,-251317,-251303,-251289,-251274,-251260,-251246,-251231,-251217,-251203,-251188,-251174,-251160,-251145,-251131,-251116,-251102,-251087,-251073,-251059,-251044,-251030,-251015,-251001,-250986,-250972,-250957,-250943,-250928,-250913,-250899,-250884,-250870,-250855,-250841,-250826,-250811,-250797,-250782,-250767,-250753,-250738,-250723,-250709,-250694,-250679,-250665,-250650,-250635,-250621,-250606,-250591,-250576,-250561,-250547,-250532,-250517,-250502,-250488,-250473,-250458,-250443,-250428,-250413,-250398,-250384,-250369,-250354,-250339,-250324,-250309,-250294,-250279,-250264,-250249,-250234,-250219,-250204,-250189,-250174,-250159,-250144,-250129,-250114,-250099,-250084,-250069,-250054,-250039,-250024,-250008,-249993,-249978,-249963,-249948,-249933,-249918,-249902,-249887,-249872,-249857,-249842,-249826,-249811,-249796,-249781,-249765,-249750,-249735,-249720,-249704,-249689,-249674,-249658,-249643,-249628,-249612,-249597,-249582,-249566,-249551,-249535,-249520,-249505,-249489,-249474,-249458,-249443,-249427,-249412,-249397,-249381,-249366,-249350,-249334,-249319,-249303,-249288,-249272,-249257,-249241,-249226,-249210,-249194,-249179,-249163,-249148,-249132,-249116,-249101,-249085,-249069,-249054,-249038,-249022,-249007,-248991,-248975,-248959,-248944,-248928,-248912,-248896,-248881,-248865,-248849,-248833,-248817,-248802,-248786,-248770,-248754,-248738,-248722,-248706,-248690,-248675,-248659,-248643,-248627,-248611,-248595,-248579,-248563,-248547,-248531,-248515,-248499,-248483,-248467,-248451,-248435,-248419,-248403,-248387,-248371,-248355,-248339,-248322,-248306,-248290,-248274,-248258,-248242,-248226,-248210,-248193,-248177,-248161,-248145,-248129,-248112,-248096,-248080,-248064,-248047,-248031,-248015,-247999,-247982,-247966,-247950,-247933,-247917,-247901,-247884,-247868,-247852,-247835,-247819,-247802,-247786,-247770,-247753,-247737,-247720,-247704,-247687,-247671,-247654,-247638,-247621,-247605,-247588,-247572,-247555,-247539,-247522,-247506,-247489,-247473,-247456,-247439,-247423,-247406,-247390,-247373,-247356,-247340,-247323,-247306,-247290,-247273,-247256,-247240,-247223,-247206,-247189,-247173,-247156,-247139,-247122,-247106,-247089,-247072,-247055,-247039,-247022,-247005,-246988,-246971,-246954,-246937,-246921,-246904,-246887,-246870,-246853,-246836,-246819,-246802,-246785,-246768,-246751,-246734,-246717,-246700,-246683,-246666,-246649,-246632,-246615,-246598,-246581,-246564,-246547,-246530,-246513,-246496,-246479,-246462,-246444,-246427,-246410,-246393,-246376,-246359,-246341,-246324,-246307,-246290,-246273,-246255,-246238,-246221,-246204,-246186,-246169,-246152,-246135,-246117,-246100,-246083,-246065,-246048,-246031,-246013,-245996,-245978,-245961,-245944,-245926,-245909,-245891,-245874,-245857,-245839,-245822,-245804,-245787,-245769,-245752,-245734,-245717,-245699,-245682,-245664,-245647,-245629,-245612,-245594,-245576,-245559,-245541,-245524,-245506,-245488,-245471,-245453,-245435,-245418,-245400,-245382,-245365,-245347,-245329,-245312,-245294,-245276,-245258,-245241,-245223,-245205,-245187,-245170,-245152,-245134,-245116,-245098,-245080,-245063,-245045,-245027,-245009,-244991,-244973,-244955,-244937,-244920,-244902,-244884,-244866,-244848,-244830,-244812,-244794,-244776,-244758,-244740,-244722,-244704,-244686,-244668,-244650,-244632,-244614,-244596,-244577,-244559,-244541,-244523,-244505,-244487,-244469,-244451,-244432,-244414,-244396,-244378,-244360,-244342,-244323,-244305,-244287,-244269,-244250,-244232,-244214,-244196,-244177,-244159,-244141,-244122,-244104,-244086,-244067,-244049,-244031,-244012,-243994,-243976,-243957,-243939,-243920,-243902,-243884,-243865,-243847,-243828,-243810,-243791,-243773,-243754,-243736,-243717,-243699,-243680,-243662,-243643,-243625,-243606,-243587,-243569,-243550,-243532,-243513,-243495,-243476,-243457,-243439,-243420,-243401,-243383,-243364,-243345,-243327,-243308,-243289,-243270,-243252,-243233,-243214,-243195,-243177,-243158,-243139,-243120,-243102,-243083,-243064,-243045,-243026,-243007,-242989,-242970,-242951,-242932,-242913,-242894,-242875,-242856,-242837,-242818,-242799,-242781,-242762,-242743,-242724,-242705,-242686,-242667,-242648,-242629,-242610,-242590,-242571,-242552,-242533,-242514,-242495,-242476,-242457,-242438,-242419,-242400,-242380,-242361,-242342,-242323,-242304,-242285,-242265,-242246,-242227,-242208,-242188,-242169,-242150,-242131,-242111,-242092,-242073,-242054,-242034,-242015,-241996,-241976,-241957,-241938,-241918,-241899,-241880,-241860,-241841,-241821,-241802,-241783,-241763,-241744,-241724,-241705,-241685,-241666,-241646,-241627,-241607,-241588,-241568,-241549,-241529,-241510,-241490,-241471,-241451,-241432,-241412,-241392,-241373,-241353,-241333,-241314,-241294,-241275,-241255,-241235,-241216,-241196,-241176,-241156,-241137,-241117,-241097,-241078,-241058,-241038,-241018,-240999,-240979,-240959,-240939,-240919,-240900,-240880,-240860,-240840,-240820,-240800,-240780,-240761,-240741,-240721,-240701,-240681,-240661,-240641,-240621,-240601,-240581,-240561,-240541,-240521,-240501,-240481,-240461,-240441,-240421,-240401,-240381,-240361,-240341,-240321,-240301,-240281,-240261,-240241,-240220,-240200,-240180,-240160,-240140,-240120,-240100,-240079,-240059,-240039,-240019,-239999,-239978,-239958,-239938,-239918,-239897,-239877,-239857,-239837,-239816,-239796,-239776,-239755,-239735,-239715,-239694,-239674,-239654,-239633,-239613,-239592,-239572,-239552,-239531,-239511,-239490,-239470,-239449,-239429,-239409,-239388,-239368,-239347,-239327,-239306,-239286,-239265,-239244,-239224,-239203,-239183,-239162,-239142,-239121,-239100,-239080,-239059,-239039,-239018,-238997,-238977,-238956,-238935,-238915,-238894,-238873,-238852,-238832,-238811,-238790,-238770,-238749,-238728,-238707,-238687,-238666,-238645,-238624,-238603,-238582,-238562,-238541,-238520,-238499,-238478,-238457,-238436,-238416,-238395,-238374,-238353,-238332,-238311,-238290,-238269,-238248,-238227,-238206,-238185,-238164,-238143,-238122,-238101,-238080,-238059,-238038,-238017,-237996,-237975,-237954,-237933,-237912,-237890,-237869,-237848,-237827,-237806,-237785,-237764,-237742,-237721,-237700,-237679,-237658,-237636,-237615,-237594,-237573,-237551,-237530,-237509,-237488,-237466,-237445,-237424,-237402,-237381,-237360,-237338,-237317,-237296,-237274,-237253,-237232,-237210,-237189,-237167,-237146,-237125,-237103,-237082,-237060,-237039,-237017,-236996,-236974,-236953,-236931,-236910,-236888,-236867,-236845,-236824,-236802,-236781,-236759,-236737,-236716,-236694,-236673,-236651,-236629,-236608,-236586,-236564,-236543,-236521,-236499,-236478,-236456,-236434,-236413,-236391,-236369,-236347,-236326,-236304,-236282,-236260,-236239,-236217,-236195,-236173,-236151,-236130,-236108,-236086,-236064,-236042,-236020,-235998,-235977,-235955,-235933,-235911,-235889,-235867,-235845,-235823,-235801,-235779,-235757,-235735,-235713,-235691,-235669,-235647,-235625,-235603,-235581,-235559,-235537,-235515,-235493,-235471,-235449,-235427,-235404,-235382,-235360,-235338,-235316,-235294,-235272,-235249,-235227,-235205,-235183,-235161,-235138,-235116,-235094,-235072,-235049,-235027,-235005,-234983,-234960,-234938,-234916,-234893,-234871,-234849,-234827,-234804,-234782,-234759,-234737,-234715,-234692,-234670,-234648,-234625,-234603,-234580,-234558,-234535,-234513,-234490,-234468,-234445,-234423,-234400,-234378,-234355,-234333,-234310,-234288,-234265,-234243,-234220,-234198,-234175,-234152,-234130,-234107,-234085,-234062,-234039,-234017,-233994,-233971,-233949,-233926,-233903,-233881,-233858,-233835,-233812,-233790,-233767,-233744,-233721,-233699,-233676,-233653,-233630,-233608,-233585,-233562,-233539,-233516,-233493,-233471,-233448,-233425,-233402,-233379,-233356,-233333,-233310,-233287,-233264,-233242,-233219,-233196,-233173,-233150,-233127,-233104,-233081,-233058,-233035,-233012,-232989,-232966,-232943,-232919,-232896,-232873,-232850,-232827,-232804,-232781,-232758,-232735,-232712,-232688,-232665,-232642,-232619,-232596,-232573,-232549,-232526,-232503,-232480,-232456,-232433,-232410,-232387,-232363,-232340,-232317,-232294,-232270,-232247,-232224,-232200,-232177,-232154,-232130,-232107,-232084,-232060,-232037,-232013,-231990,-231967,-231943,-231920,-231896,-231873,-231849,-231826,-231803,-231779,-231756,-231732,-231709,-231685,-231662,-231638,-231614,-231591,-231567,-231544,-231520,-231497,-231473,-231449,-231426,-231402,-231379,-231355,-231331,-231308,-231284,-231260,-231237,-231213,-231189,-231166,-231142,-231118,-231095,-231071,-231047,-231023,-231000,-230976,-230952,-230928,-230904,-230881,-230857,-230833,-230809,-230785,-230761,-230738,-230714,-230690,-230666,-230642,-230618,-230594,-230570,-230547,-230523,-230499,-230475,-230451,-230427,-230403,-230379,-230355,-230331,-230307,-230283,-230259,-230235,-230211,-230187,-230163,-230139,-230115,-230090,-230066,-230042,-230018,-229994,-229970,-229946,-229922,-229897,-229873,-229849,-229825,-229801,-229777,-229752,-229728,-229704,-229680,-229656,-229631,-229607,-229583,-229559,-229534,-229510,-229486,-229461,-229437,-229413,-229388,-229364,-229340,-229315,-229291,-229267,-229242,-229218,-229193,-229169,-229145,-229120,-229096,-229071,-229047,-229023,-228998,-228974,-228949,-228925,-228900,-228876,-228851,-228827,-228802,-228778,-228753,-228728,-228704,-228679,-228655,-228630,-228606,-228581,-228556,-228532,-228507,-228482,-228458,-228433,-228408,-228384,-228359,-228334,-228310,-228285,-228260,-228236,-228211,-228186,-228161,-228137,-228112,-228087,-228062,-228038,-228013,-227988,-227963,-227938,-227913,-227889,-227864,-227839,-227814,-227789,-227764,-227739,-227715,-227690,-227665,-227640,-227615,-227590,-227565,-227540,-227515,-227490,-227465,-227440,-227415,-227390,-227365,-227340,-227315,-227290,-227265,-227240,-227215,-227190,-227165,-227140,-227114,-227089,-227064,-227039,-227014,-226989,-226964,-226939,-226913,-226888,-226863,-226838,-226813,-226787,-226762,-226737,-226712,-226687,-226661,-226636,-226611,-226585,-226560,-226535,-226510,-226484,-226459,-226434,-226408,-226383,-226358,-226332,-226307,-226282,-226256,-226231,-226205,-226180,-226155,-226129,-226104,-226078,-226053,-226027,-226002,-225976,-225951,-225925,-225900,-225874,-225849,-225823,-225798,-225772,-225747,-225721,-225696,-225670,-225645,-225619,-225593,-225568,-225542,-225516,-225491,-225465,-225440,-225414,-225388,-225363,-225337,-225311,-225286,-225260,-225234,-225208,-225183,-225157,-225131,-225105,-225080,-225054,-225028,-225002,-224977,-224951,-224925,-224899,-224873,-224847,-224822,-224796,-224770,-224744,-224718,-224692,-224666,-224640,-224614,-224589,-224563,-224537,-224511,-224485,-224459,-224433,-224407,-224381,-224355,-224329,-224303,-224277,-224251,-224225,-224199,-224173,-224147,-224121,-224095,-224068,-224042,-224016,-223990,-223964,-223938,-223912,-223886,-223859,-223833,-223807,-223781,-223755,-223729,-223702,-223676,-223650,-223624,-223598,-223571,-223545,-223519,-223492,-223466,-223440,-223414,-223387,-223361,-223335,-223308,-223282,-223256,-223229,-223203,-223177,-223150,-223124,-223098,-223071,-223045,-223018,-222992,-222965,-222939,-222913,-222886,-222860,-222833,-222807,-222780,-222754,-222727,-222701,-222674,-222648,-222621,-222595,-222568,-222541,-222515,-222488,-222462,-222435,-222409,-222382,-222355,-222329,-222302,-222275,-222249,-222222,-222195,-222169,-222142,-222115,-222089,-222062,-222035,-222009,-221982,-221955,-221928,-221902,-221875,-221848,-221821,-221794,-221768,-221741,-221714,-221687,-221660,-221633,-221607,-221580,-221553,-221526,-221499,-221472,-221445,-221418,-221392,-221365,-221338,-221311,-221284,-221257,-221230,-221203,-221176,-221149,-221122,-221095,-221068,-221041,-221014,-220987,-220960,-220933,-220906,-220879,-220852,-220825,-220797,-220770,-220743,-220716,-220689,-220662,-220635,-220608,-220580,-220553,-220526,-220499,-220472,-220445,-220417,-220390,-220363,-220336,-220308,-220281,-220254,-220227,-220199,-220172,-220145,-220118,-220090,-220063,-220036,-220008,-219981,-219954,-219926,-219899,-219872,-219844,-219817,-219789,-219762,-219735,-219707,-219680,-219652,-219625,-219597,-219570,-219543,-219515,-219488,-219460,-219433,-219405,-219378,-219350,-219323,-219295,-219267,-219240,-219212,-219185,-219157,-219130,-219102,-219074,-219047,-219019,-218992,-218964,-218936,-218909,-218881,-218853,-218826,-218798,-218770,-218743,-218715,-218687,-218659,-218632,-218604,-218576,-218548,-218521,-218493,-218465,-218437,-218410,-218382,-218354,-218326,-218298,-218270,-218243,-218215,-218187,-218159,-218131,-218103,-218075,-218048,-218020,-217992,-217964,-217936,-217908,-217880,-217852,-217824,-217796,-217768,-217740,-217712,-217684,-217656,-217628,-217600,-217572,-217544,-217516,-217488,-217460,-217432,-217404,-217376,-217347,-217319,-217291,-217263,-217235,-217207,-217179,-217151,-217122,-217094,-217066,-217038,-217010,-216981,-216953,-216925,-216897,-216869,-216840,-216812,-216784,-216756,-216727,-216699,-216671,-216642,-216614,-216586,-216557,-216529,-216501,-216472,-216444,-216416,-216387,-216359,-216331,-216302,-216274,-216245,-216217,-216189,-216160,-216132,-216103,-216075,-216046,-216018,-215989,-215961,-215932,-215904,-215875,-215847,-215818,-215790,-215761,-215733,-215704,-215676,-215647,-215618,-215590,-215561,-215533,-215504,-215475,-215447,-215418,-215389,-215361,-215332,-215303,-215275,-215246,-215217,-215189,-215160,-215131,-215103,-215074,-215045,-215016,-214988,-214959,-214930,-214901,-214872,-214844,-214815,-214786,-214757,-214728,-214700,-214671,-214642,-214613,-214584,-214555,-214526,-214497,-214469,-214440,-214411,-214382,-214353,-214324,-214295,-214266,-214237,-214208,-214179,-214150,-214121,-214092,-214063,-214034,-214005,-213976,-213947,-213918,-213889,-213860,-213831,-213802,-213773,-213744,-213714,-213685,-213656,-213627,-213598,-213569,-213540,-213510,-213481,-213452,-213423,-213394,-213365,-213335,-213306,-213277,-213248,-213218,-213189,-213160,-213131,-213101,-213072,-213043,-213014,-212984,-212955,-212926,-212896,-212867,-212838,-212808,-212779,-212750,-212720,-212691,-212661,-212632,-212603,-212573,-212544,-212514,-212485,-212455,-212426,-212397,-212367,-212338,-212308,-212279,-212249,-212220,-212190,-212161,-212131,-212102,-212072,-212042,-212013,-211983,-211954,-211924,-211895,-211865,-211835,-211806,-211776,-211747,-211717,-211687,-211658,-211628,-211598,-211569,-211539,-211509,-211480,-211450,-211420,-211390,-211361,-211331,-211301,-211271,-211242,-211212,-211182,-211152,-211123,-211093,-211063,-211033,-211003,-210973,-210944,-210914,-210884,-210854,-210824,-210794,-210764,-210735,-210705,-210675,-210645,-210615,-210585,-210555,-210525,-210495,-210465,-210435,-210405,-210375,-210345,-210315,-210285,-210255,-210225,-210195,-210165,-210135,-210105,-210075,-210045,-210015,-209985,-209955,-209925,-209894,-209864,-209834,-209804,-209774,-209744,-209714,-209683,-209653,-209623,-209593,-209563,-209533,-209502,-209472,-209442,-209412,-209381,-209351,-209321,-209291,-209260,-209230,-209200,-209169,-209139,-209109,-209079,-209048,-209018,-208988,-208957,-208927,-208896,-208866,-208836,-208805,-208775,-208745,-208714,-208684,-208653,-208623,-208592,-208562,-208532,-208501,-208471,-208440,-208410,-208379,-208349,-208318,-208288,-208257,-208227,-208196,-208165,-208135,-208104,-208074,-208043,-208013,-207982,-207951,-207921,-207890,-207860,-207829,-207798,-207768,-207737,-207706,-207676,-207645,-207614,-207584,-207553,-207522,-207491,-207461,-207430,-207399,-207369,-207338,-207307,-207276,-207245,-207215,-207184,-207153,-207122,-207091,-207061,-207030,-206999,-206968,-206937,-206906,-206876,-206845,-206814,-206783,-206752,-206721,-206690,-206659,-206628,-206597,-206566,-206536,-206505,-206474,-206443,-206412,-206381,-206350,-206319,-206288,-206257,-206226,-206195,-206164,-206132,-206101,-206070,-206039,-206008,-205977,-205946,-205915,-205884,-205853,-205822,-205790,-205759,-205728,-205697,-205666,-205635,-205603,-205572,-205541,-205510,-205479,-205447,-205416,-205385,-205354,-205323,-205291,-205260,-205229,-205197,-205166,-205135,-205104,-205072,-205041,-205010,-204978,-204947,-204916,-204884,-204853,-204822,-204790,-204759,-204727,-204696,-204665,-204633,-204602,-204570,-204539,-204507,-204476,-204445,-204413,-204382,-204350,-204319,-204287,-204256,-204224,-204193,-204161,-204130,-204098,-204066,-204035,-204003,-203972,-203940,-203909,-203877,-203845,-203814,-203782,-203751,-203719,-203687,-203656,-203624,-203592,-203561,-203529,-203497,-203466,-203434,-203402,-203371,-203339,-203307,-203275,-203244,-203212,-203180,-203148,-203117,-203085,-203053,-203021,-202989,-202958,-202926,-202894,-202862,-202830,-202798,-202767,-202735,-202703,-202671,-202639,-202607,-202575,-202543,-202511,-202480,-202448,-202416,-202384,-202352,-202320,-202288,-202256,-202224,-202192,-202160,-202128,-202096,-202064,-202032,-202000,-201968,-201936,-201904,-201872,-201840,-201807,-201775,-201743,-201711,-201679,-201647,-201615,-201583,-201551,-201518,-201486,-201454,-201422,-201390,-201358,-201325,-201293,-201261,-201229,-201197,-201164,-201132,-201100,-201068,-201035,-201003,-200971,-200939,-200906,-200874,-200842,-200809,-200777,-200745,-200712,-200680,-200648,-200615,-200583,-200551,-200518,-200486,-200453,-200421,-200389,-200356,-200324,-200291,-200259,-200227,-200194,-200162,-200129,-200097,-200064,-200032,-199999,-199967,-199934,-199902,-199869,-199837,-199804,-199772,-199739,-199707,-199674,-199641,-199609,-199576,-199544,-199511,-199478,-199446,-199413,-199381,-199348,-199315,-199283,-199250,-199217,-199185,-199152,-199119,-199087,-199054,-199021,-198988,-198956,-198923,-198890,-198857,-198825,-198792,-198759,-198726,-198694,-198661,-198628,-198595,-198562,-198530,-198497,-198464,-198431,-198398,-198365,-198333,-198300,-198267,-198234,-198201,-198168,-198135,-198102,-198069,-198036,-198003,-197971,-197938,-197905,-197872,-197839,-197806,-197773,-197740,-197707,-197674,-197641,-197608,-197575,-197542,-197509,-197475,-197442,-197409,-197376,-197343,-197310,-197277,-197244,-197211,-197178,-197145,-197111,-197078,-197045,-197012,-196979,-196946,-196912,-196879,-196846,-196813,-196780,-196746,-196713,-196680,-196647,-196614,-196580,-196547,-196514,-196480,-196447,-196414,-196381,-196347,-196314,-196281,-196247,-196214,-196181,-196147,-196114,-196081,-196047,-196014,-195981,-195947,-195914,-195880,-195847,-195814,-195780,-195747,-195713,-195680,-195646,-195613,-195579,-195546,-195512,-195479,-195445,-195412,-195378,-195345,-195311,-195278,-195244,-195211,-195177,-195144,-195110,-195077,-195043,-195009,-194976,-194942,-194909,-194875,-194841,-194808,-194774,-194740,-194707,-194673,-194639,-194606,-194572,-194538,-194505,-194471,-194437,-194404,-194370,-194336,-194302,-194269,-194235,-194201,-194167,-194134,-194100,-194066,-194032,-193998,-193965,-193931,-193897,-193863,-193829,-193795,-193762,-193728,-193694,-193660,-193626,-193592,-193558,-193524,-193491,-193457,-193423,-193389,-193355,-193321,-193287,-193253,-193219,-193185,-193151,-193117,-193083,-193049,-193015,-192981,-192947,-192913,-192879,-192845,-192811,-192777,-192743,-192709,-192675,-192640,-192606,-192572,-192538,-192504,-192470,-192436,-192402,-192368,-192333,-192299,-192265,-192231,-192197,-192163,-192128,-192094,-192060,-192026,-191991,-191957,-191923,-191889,-191855,-191820,-191786,-191752,-191717,-191683,-191649,-191615,-191580,-191546,-191512,-191477,-191443,-191409,-191374,-191340,-191306,-191271,-191237,-191202,-191168,-191134,-191099,-191065,-191030,-190996,-190962,-190927,-190893,-190858,-190824,-190789,-190755,-190720,-190686,-190651,-190617,-190582,-190548,-190513,-190479,-190444,-190410,-190375,-190341,-190306,-190271,-190237,-190202,-190168,-190133,-190098,-190064,-190029,-189995,-189960,-189925,-189891,-189856,-189821,-189787,-189752,-189717,-189683,-189648,-189613,-189579,-189544,-189509,-189474,-189440,-189405,-189370,-189335,-189301,-189266,-189231,-189196,-189161,-189127,-189092,-189057,-189022,-188987,-188953,-188918,-188883,-188848,-188813,-188778,-188743,-188708,-188674,-188639,-188604,-188569,-188534,-188499,-188464,-188429,-188394,-188359,-188324,-188289,-188254,-188219,-188184,-188149,-188114,-188079,-188044,-188009,-187974,-187939,-187904,-187869,-187834,-187799,-187764,-187729,-187694,-187659,-187624,-187588,-187553,-187518,-187483,-187448,-187413,-187378,-187342,-187307,-187272,-187237,-187202,-187167,-187131,-187096,-187061,-187026,-186991,-186955,-186920,-186885,-186850,-186814,-186779,-186744,-186709,-186673,-186638,-186603,-186567,-186532,-186497,-186461,-186426,-186391,-186355,-186320,-186285,-186249,-186214,-186178,-186143,-186108,-186072,-186037,-186001,-185966,-185931,-185895,-185860,-185824,-185789,-185753,-185718,-185682,-185647,-185611,-185576,-185540,-185505,-185469,-185434,-185398,-185363,-185327,-185292,-185256,-185221,-185185,-185149,-185114,-185078,-185043,-185007,-184971,-184936,-184900,-184865,-184829,-184793,-184758,-184722,-184686,-184651,-184615,-184579,-184544,-184508,-184472,-184436,-184401,-184365,-184329,-184293,-184258,-184222,-184186,-184150,-184115,-184079,-184043,-184007,-183971,-183936,-183900,-183864,-183828,-183792,-183756,-183721,-183685,-183649,-183613,-183577,-183541,-183505,-183469,-183434,-183398,-183362,-183326,-183290,-183254,-183218,-183182,-183146,-183110,-183074,-183038,-183002,-182966,-182930,-182894,-182858,-182822,-182786,-182750,-182714,-182678,-182642,-182606,-182570,-182534,-182498,-182462,-182425,-182389,-182353,-182317,-182281,-182245,-182209,-182173,-182136,-182100,-182064,-182028,-181992,-181956,-181919,-181883,-181847,-181811,-181775,-181738,-181702,-181666,-181630,-181593,-181557,-181521,-181485,-181448,-181412,-181376,-181340,-181303,-181267,-181231,-181194,-181158,-181122,-181085,-181049,-181013,-180976,-180940,-180903,-180867,-180831,-180794,-180758,-180722,-180685,-180649,-180612,-180576,-180539,-180503,-180466,-180430,-180394,-180357,-180321,-180284,-180248,-180211,-180175,-180138,-180102,-180065,-180028,-179992,-179955,-179919,-179882,-179846,-179809,-179773,-179736,-179699,-179663,-179626,-179590,-179553,-179516,-179480,-179443,-179406,-179370,-179333,-179296,-179260,-179223,-179186,-179150,-179113,-179076,-179040,-179003,-178966,-178929,-178893,-178856,-178819,-178782,-178746,-178709,-178672,-178635,-178599,-178562,-178525,-178488,-178451,-178414,-178378,-178341,-178304,-178267,-178230,-178193,-178157,-178120,-178083,-178046,-178009,-177972,-177935,-177898,-177861,-177824,-177787,-177751,-177714,-177677,-177640,-177603,-177566,-177529,-177492,-177455,-177418,-177381,-177344,-177307,-177270,-177233,-177196,-177159,-177122,-177084,-177047,-177010,-176973,-176936,-176899,-176862,-176825,-176788,-176751,-176713,-176676,-176639,-176602,-176565,-176528,-176491,-176453,-176416,-176379,-176342,-176305,-176267,-176230,-176193,-176156,-176119,-176081,-176044,-176007,-175970,-175932,-175895,-175858,-175821,-175783,-175746,-175709,-175671,-175634,-175597,-175559,-175522,-175485,-175447,-175410,-175373,-175335,-175298,-175261,-175223,-175186,-175148,-175111,-175074,-175036,-174999,-174961,-174924,-174886,-174849,-174812,-174774,-174737,-174699,-174662,-174624,-174587,-174549,-174512,-174474,-174437,-174399,-174362,-174324,-174287,-174249,-174211,-174174,-174136,-174099,-174061,-174024,-173986,-173948,-173911,-173873,-173836,-173798,-173760,-173723,-173685,-173647,-173610,-173572,-173534,-173497,-173459,-173421,-173384,-173346,-173308,-173270,-173233,-173195,-173157,-173120,-173082,-173044,-173006,-172968,-172931,-172893,-172855,-172817,-172780,-172742,-172704,-172666,-172628,-172590,-172553,-172515,-172477,-172439,-172401,-172363,-172325,-172288,-172250,-172212,-172174,-172136,-172098,-172060,-172022,-171984,-171946,-171908,-171870,-171833,-171795,-171757,-171719,-171681,-171643,-171605,-171567,-171529,-171491,-171453,-171415,-171377,-171338,-171300,-171262,-171224,-171186,-171148,-171110,-171072,-171034,-170996,-170958,-170920,-170882,-170843,-170805,-170767,-170729,-170691,-170653,-170615,-170576,-170538,-170500,-170462,-170424,-170385,-170347,-170309,-170271,-170233,-170194,-170156,-170118,-170080,-170041,-170003,-169965,-169927,-169888,-169850,-169812,-169773,-169735,-169697,-169659,-169620,-169582,-169544,-169505,-169467,-169429,-169390,-169352,-169313,-169275,-169237,-169198,-169160,-169121,-169083,-169045,-169006,-168968,-168929,-168891,-168852,-168814,-168776,-168737,-168699,-168660,-168622,-168583,-168545,-168506,-168468,-168429,-168391,-168352,-168314,-168275,-168237,-168198,-168159,-168121,-168082,-168044,-168005,-167967,-167928,-167889,-167851,-167812,-167773,-167735,-167696,-167658,-167619,-167580,-167542,-167503,-167464,-167426,-167387,-167348,-167310,-167271,-167232,-167193,-167155,-167116,-167077,-167039,-167000,-166961,-166922,-166884,-166845,-166806,-166767,-166728,-166690,-166651,-166612,-166573,-166534,-166496,-166457,-166418,-166379,-166340,-166301,-166263,-166224,-166185,-166146,-166107,-166068,-166029,-165990,-165951,-165913,-165874,-165835,-165796,-165757,-165718,-165679,-165640,-165601,-165562,-165523,-165484,-165445,-165406,-165367,-165328,-165289,-165250,-165211,-165172,-165133,-165094,-165055,-165016,-164977,-164938,-164899,-164860,-164820,-164781,-164742,-164703,-164664,-164625,-164586,-164547,-164508,-164468,-164429,-164390,-164351,-164312,-164273,-164233,-164194,-164155,-164116,-164077,-164038,-163998,-163959,-163920,-163881,-163841,-163802,-163763,-163724,-163684,-163645,-163606,-163567,-163527,-163488,-163449,-163409,-163370,-163331,-163291,-163252,-163213,-163173,-163134,-163095,-163055,-163016,-162977,-162937,-162898,-162859,-162819,-162780,-162740,-162701,-162662,-162622,-162583,-162543,-162504,-162464,-162425,-162385,-162346,-162307,-162267,-162228,-162188,-162149,-162109,-162070,-162030,-161991,-161951,-161912,-161872,-161832,-161793,-161753,-161714,-161674,-161635,-161595,-161556,-161516,-161476,-161437,-161397,-161358,-161318,-161278,-161239,-161199,-161159,-161120,-161080,-161040,-161001,-160961,-160921,-160882,-160842,-160802,-160763,-160723,-160683,-160643,-160604,-160564,-160524,-160485,-160445,-160405,-160365,-160326,-160286,-160246,-160206,-160166,-160127,-160087,-160047,-160007,-159967,-159928,-159888,-159848,-159808,-159768,-159728,-159688,-159649,-159609,-159569,-159529,-159489,-159449,-159409,-159369,-159329,-159290,-159250,-159210,-159170,-159130,-159090,-159050,-159010,-158970,-158930,-158890,-158850,-158810,-158770,-158730,-158690,-158650,-158610,-158570,-158530,-158490,-158450,-158410,-158370,-158330,-158290,-158250,-158210,-158169,-158129,-158089,-158049,-158009,-157969,-157929,-157889,-157849,-157808,-157768,-157728,-157688,-157648,-157608,-157568,-157527,-157487,-157447,-157407,-157367,-157326,-157286,-157246,-157206,-157166,-157125,-157085,-157045,-157005,-156964,-156924,-156884,-156844,-156803,-156763,-156723,-156682,-156642,-156602,-156561,-156521,-156481,-156440,-156400,-156360,-156319,-156279,-156239,-156198,-156158,-156118,-156077,-156037,-155996,-155956,-155916,-155875,-155835,-155794,-155754,-155714,-155673,-155633,-155592,-155552,-155511,-155471,-155430,-155390,-155349,-155309,-155268,-155228,-155187,-155147,-155106,-155066,-155025,-154985,-154944,-154904,-154863,-154823,-154782,-154741,-154701,-154660,-154620,-154579,-154538,-154498,-154457,-154417,-154376,-154335,-154295,-154254,-154213,-154173,-154132,-154092,-154051,-154010,-153969,-153929,-153888,-153847,-153807,-153766,-153725,-153685,-153644,-153603,-153562,-153522,-153481,-153440,-153399,-153359,-153318,-153277,-153236,-153196,-153155,-153114,-153073,-153032,-152992,-152951,-152910,-152869,-152828,-152787,-152747,-152706,-152665,-152624,-152583,-152542,-152501,-152460,-152420,-152379,-152338,-152297,-152256,-152215,-152174,-152133,-152092,-152051,-152010,-151969,-151928,-151887,-151846,-151805,-151764,-151723,-151682,-151641,-151600,-151559,-151518,-151477,-151436,-151395,-151354,-151313,-151272,-151231,-151190,-151149,-151108,-151067,-151026,-150985,-150944,-150903,-150861,-150820,-150779,-150738,-150697,-150656,-150615,-150574,-150532,-150491,-150450,-150409,-150368,-150327,-150285,-150244,-150203,-150162,-150121,-150079,-150038,-149997,-149956,-149915,-149873,-149832,-149791,-149750,-149708,-149667,-149626,-149584,-149543,-149502,-149461,-149419,-149378,-149337,-149295,-149254,-149213,-149171,-149130,-149089,-149047,-149006,-148965,-148923,-148882,-148841,-148799,-148758,-148716,-148675,-148634,-148592,-148551,-148509,-148468,-148427,-148385,-148344,-148302,-148261,-148219,-148178,-148136,-148095,-148053,-148012,-147970,-147929,-147887,-147846,-147804,-147763,-147721,-147680,-147638,-147597,-147555,-147514,-147472,-147431,-147389,-147347,-147306,-147264,-147223,-147181,-147140,-147098,-147056,-147015,-146973,-146931,-146890,-146848,-146807,-146765,-146723,-146682,-146640,-146598,-146557,-146515,-146473,-146432,-146390,-146348,-146306,-146265,-146223,-146181,-146140,-146098,-146056,-146014,-145973,-145931,-145889,-145847,-145806,-145764,-145722,-145680,-145638,-145597,-145555,-145513,-145471,-145429,-145388,-145346,-145304,-145262,-145220,-145178,-145136,-145095,-145053,-145011,-144969,-144927,-144885,-144843,-144801,-144760,-144718,-144676,-144634,-144592,-144550,-144508,-144466,-144424,-144382,-144340,-144298,-144256,-144214,-144172,-144130,-144088,-144046,-144004,-143962,-143920,-143878,-143836,-143794,-143752,-143710,-143668,-143626,-143584,-143542,-143500,-143458,-143416,-143374,-143332,-143290,-143247,-143205,-143163,-143121,-143079,-143037,-142995,-142953,-142911,-142868,-142826,-142784,-142742,-142700,-142658,-142615,-142573,-142531,-142489,-142447,-142404,-142362,-142320,-142278,-142236,-142193,-142151,-142109,-142067,-142024,-141982,-141940,-141898,-141855,-141813,-141771,-141729,-141686,-141644,-141602,-141559,-141517,-141475,-141432,-141390,-141348,-141305,-141263,-141221,-141178,-141136,-141094,-141051,-141009,-140967,-140924,-140882,-140839,-140797,-140755,-140712,-140670,-140627,-140585,-140543,-140500,-140458,-140415,-140373,-140330,-140288,-140245,-140203,-140160,-140118,-140076,-140033,-139991,-139948,-139906,-139863,-139820,-139778,-139735,-139693,-139650,-139608,-139565,-139523,-139480,-139438,-139395,-139352,-139310,-139267,-139225,-139182,-139140,-139097,-139054,-139012,-138969,-138926,-138884,-138841,-138799,-138756,-138713,-138671,-138628,-138585,-138543,-138500,-138457,-138415,-138372,-138329,-138287,-138244,-138201,-138158,-138116,-138073,-138030,-137987,-137945,-137902,-137859,-137816,-137774,-137731,-137688,-137645,-137603,-137560,-137517,-137474,-137431,-137389,-137346,-137303,-137260,-137217,-137175,-137132,-137089,-137046,-137003,-136960,-136917,-136875,-136832,-136789,-136746,-136703,-136660,-136617,-136574,-136531,-136489,-136446,-136403,-136360,-136317,-136274,-136231,-136188,-136145,-136102,-136059,-136016,-135973,-135930,-135887,-135844,-135801,-135758,-135715,-135672,-135629,-135586,-135543,-135500,-135457,-135414,-135371,-135328,-135285,-135242,-135199,-135156,-135113,-135070,-135027,-134983,-134940,-134897,-134854,-134811,-134768,-134725,-134682,-134639,-134595,-134552,-134509,-134466,-134423,-134380,-134337,-134293,-134250,-134207,-134164,-134121,-134077,-134034,-133991,-133948,-133905,-133861,-133818,-133775,-133732,-133689,-133645,-133602,-133559,-133516,-133472,-133429,-133386,-133342,-133299,-133256,-133213,-133169,-133126,-133083,-133039,-132996,-132953,-132909,-132866,-132823,-132779,-132736,-132693,-132649,-132606,-132563,-132519,-132476,-132433,-132389,-132346,-132302,-132259,-132216,-132172,-132129,-132085,-132042,-131999,-131955,-131912,-131868,-131825,-131781,-131738,-131694,-131651,-131608,-131564,-131521,-131477,-131434,-131390,-131347,-131303,-131260,-131216,-131173,-131129,-131086,-131042,-130998,-130955,-130911,-130868,-130824,-130781,-130737,-130694,-130650,-130606,-130563,-130519,-130476,-130432,-130388,-130345,-130301,-130258,-130214,-130170,-130127,-130083,-130039,-129996,-129952,-129908,-129865,-129821,-129777,-129734,-129690,-129646,-129603,-129559,-129515,-129472,-129428,-129384,-129340,-129297,-129253,-129209,-129166,-129122,-129078,-129034,-128991,-128947,-128903,-128859,-128815,-128772,-128728,-128684,-128640,-128597,-128553,-128509,-128465,-128421,-128377,-128334,-128290,-128246,-128202,-128158,-128114,-128071,-128027,-127983,-127939,-127895,-127851,-127807,-127763,-127720,-127676,-127632,-127588,-127544,-127500,-127456,-127412,-127368,-127324,-127280,-127236,-127192,-127149,-127105,-127061,-127017,-126973,-126929,-126885,-126841,-126797,-126753,-126709,-126665,-126621,-126577,-126533,-126489,-126445,-126401,-126357,-126313,-126268,-126224,-126180,-126136,-126092,-126048,-126004,-125960,-125916,-125872,-125828,-125784,-125740,-125695,-125651,-125607,-125563,-125519,-125475,-125431,-125387,-125342,-125298,-125254,-125210,-125166,-125122,-125077,-125033,-124989,-124945,-124901,-124856,-124812,-124768,-124724,-124680,-124635,-124591,-124547,-124503,-124459,-124414,-124370,-124326,-124282,-124237,-124193,-124149,-124104,-124060,-124016,-123972,-123927,-123883,-123839,-123794,-123750,-123706,-123661,-123617,-123573,-123528,-123484,-123440,-123395,-123351,-123307,-123262,-123218,-123174,-123129,-123085,-123041,-122996,-122952,-122907,-122863,-122819,-122774,-122730,-122685,-122641,-122596,-122552,-122508,-122463,-122419,-122374,-122330,-122285,-122241,-122196,-122152,-122107,-122063,-122018,-121974,-121930,-121885,-121841,-121796,-121751,-121707,-121662,-121618,-121573,-121529,-121484,-121440,-121395,-121351,-121306,-121262,-121217,-121172,-121128,-121083,-121039,-120994,-120949,-120905,-120860,-120816,-120771,-120726,-120682,-120637,-120593,-120548,-120503,-120459,-120414,-120369,-120325,-120280,-120235,-120191,-120146,-120101,-120057,-120012,-119967,-119923,-119878,-119833,-119789,-119744,-119699,-119654,-119610,-119565,-119520,-119475,-119431,-119386,-119341,-119296,-119252,-119207,-119162,-119117,-119073,-119028,-118983,-118938,-118893,-118849,-118804,-118759,-118714,-118669,-118625,-118580,-118535,-118490,-118445,-118400,-118356,-118311,-118266,-118221,-118176,-118131,-118086,-118041,-117997,-117952,-117907,-117862,-117817,-117772,-117727,-117682,-117637,-117592,-117548,-117503,-117458,-117413,-117368,-117323,-117278,-117233,-117188,-117143,-117098,-117053,-117008,-116963,-116918,-116873,-116828,-116783,-116738,-116693,-116648,-116603,-116558,-116513,-116468,-116423,-116378,-116333,-116288,-116243,-116198,-116153,-116108,-116063,-116017,-115972,-115927,-115882,-115837,-115792,-115747,-115702,-115657,-115612,-115566,-115521,-115476,-115431,-115386,-115341,-115296,-115251,-115205,-115160,-115115,-115070,-115025,-114980,-114934,-114889,-114844,-114799,-114754,-114709,-114663,-114618,-114573,-114528,-114482,-114437,-114392,-114347,-114302,-114256,-114211,-114166,-114121,-114075,-114030,-113985,-113940,-113894,-113849,-113804,-113758,-113713,-113668,-113623,-113577,-113532,-113487,-113441,-113396,-113351,-113305,-113260,-113215,-113169,-113124,-113079,-113033,-112988,-112943,-112897,-112852,-112807,-112761,-112716,-112670,-112625,-112580,-112534,-112489,-112443,-112398,-112353,-112307,-112262,-112216,-112171,-112125,-112080,-112035,-111989,-111944,-111898,-111853,-111807,-111762,-111716,-111671,-111625,-111580,-111534,-111489,-111443,-111398,-111352,-111307,-111261,-111216,-111170,-111125,-111079,-111034,-110988,-110943,-110897,-110852,-110806,-110761,-110715,-110669,-110624,-110578,-110533,-110487,-110442,-110396,-110350,-110305,-110259,-110214,-110168,-110122,-110077,-110031,-109985,-109940,-109894,-109849,-109803,-109757,-109712,-109666,-109620,-109575,-109529,-109483,-109438,-109392,-109346,-109301,-109255,-109209,-109164,-109118,-109072,-109026,-108981,-108935,-108889,-108844,-108798,-108752,-108706,-108661,-108615,-108569,-108523,-108478,-108432,-108386,-108340,-108294,-108249,-108203,-108157,-108111,-108066,-108020,-107974,-107928,-107882,-107837,-107791,-107745,-107699,-107653,-107607,-107562,-107516,-107470,-107424,-107378,-107332,-107286,-107241,-107195,-107149,-107103,-107057,-107011,-106965,-106919,-106874,-106828,-106782,-106736,-106690,-106644,-106598,-106552,-106506,-106460,-106414,-106368,-106322,-106277,-106231,-106185,-106139,-106093,-106047,-106001,-105955,-105909,-105863,-105817,-105771,-105725,-105679,-105633,-105587,-105541,-105495,-105449,-105403,-105357,-105311,-105265,-105219,-105173,-105127,-105081,-105034,-104988,-104942,-104896,-104850,-104804,-104758,-104712,-104666,-104620,-104574,-104528,-104482,-104435,-104389,-104343,-104297,-104251,-104205,-104159,-104113,-104066,-104020,-103974,-103928,-103882,-103836,-103790,-103743,-103697,-103651,-103605,-103559,-103513,-103466,-103420,-103374,-103328,-103282,-103235,-103189,-103143,-103097,-103051,-103004,-102958,-102912,-102866,-102819,-102773,-102727,-102681,-102634,-102588,-102542,-102496,-102449,-102403,-102357,-102311,-102264,-102218,-102172,-102125,-102079,-102033,-101987,-101940,-101894,-101848,-101801,-101755,-101709,-101662,-101616,-101570,-101523,-101477,-101431,-101384,-101338,-101292,-101245,-101199,-101152,-101106,-101060,-101013,-100967,-100921,-100874,-100828,-100781,-100735,-100689,-100642,-100596,-100549,-100503,-100456,-100410,-100364,-100317,-100271,-100224,-100178,-100131,-100085,-100038,-99992,-99946,-99899,-99853,-99806,-99760,-99713,-99667,-99620,-99574,-99527,-99481,-99434,-99388,-99341,-99295,-99248,-99202,-99155,-99109,-99062,-99015,-98969,-98922,-98876,-98829,-98783,-98736,-98690,-98643,-98596,-98550,-98503,-98457,-98410,-98363,-98317,-98270,-98224,-98177,-98130,-98084,-98037,-97991,-97944,-97897,-97851,-97804,-97757,-97711,-97664,-97618,-97571,-97524,-97478,-97431,-97384,-97338,-97291,-97244,-97198,-97151,-97104,-97057,-97011,-96964,-96917,-96871,-96824,-96777,-96731,-96684,-96637,-96590,-96544,-96497,-96450,-96403,-96357,-96310,-96263,-96216,-96170,-96123,-96076,-96029,-95983,-95936,-95889,-95842,-95795,-95749,-95702,-95655,-95608,-95561,-95515,-95468,-95421,-95374,-95327,-95281,-95234,-95187,-95140,-95093,-95046,-95000,-94953,-94906,-94859,-94812,-94765,-94718,-94672,-94625,-94578,-94531,-94484,-94437,-94390,-94343,-94296,-94250,-94203,-94156,-94109,-94062,-94015,-93968,-93921,-93874,-93827,-93780,-93733,-93686,-93639,-93593,-93546,-93499,-93452,-93405,-93358,-93311,-93264,-93217,-93170,-93123,-93076,-93029,-92982,-92935,-92888,-92841,-92794,-92747,-92700,-92653,-92606,-92559,-92512,-92465,-92418,-92371,-92324,-92277,-92229,-92182,-92135,-92088,-92041,-91994,-91947,-91900,-91853,-91806,-91759,-91712,-91665,-91618,-91570,-91523,-91476,-91429,-91382,-91335,-91288,-91241,-91194,-91146,-91099,-91052,-91005,-90958,-90911,-90864,-90816,-90769,-90722,-90675,-90628,-90581,-90533,-90486,-90439,-90392,-90345,-90298,-90250,-90203,-90156,-90109,-90062,-90014,-89967,-89920,-89873,-89825,-89778,-89731,-89684,-89637,-89589,-89542,-89495,-89448,-89400,-89353,-89306,-89259,-89211,-89164,-89117,-89069,-89022,-88975,-88928,-88880,-88833,-88786,-88738,-88691,-88644,-88597,-88549,-88502,-88455,-88407,-88360,-88313,-88265,-88218,-88171,-88123,-88076,-88029,-87981,-87934,-87887,-87839,-87792,-87744,-87697,-87650,-87602,-87555,-87508,-87460,-87413,-87365,-87318,-87271,-87223,-87176,-87128,-87081,-87034,-86986,-86939,-86891,-86844,-86797,-86749,-86702,-86654,-86607,-86559,-86512,-86464,-86417,-86370,-86322,-86275,-86227,-86180,-86132,-86085,-86037,-85990,-85942,-85895,-85847,-85800,-85752,-85705,-85657,-85610,-85562,-85515,-85467,-85420,-85372,-85325,-85277,-85230,-85182,-85135,-85087,-85039,-84992,-84944,-84897,-84849,-84802,-84754,-84707,-84659,-84611,-84564,-84516,-84469,-84421,-84373,-84326,-84278,-84231,-84183,-84135,-84088,-84040,-83993,-83945,-83897,-83850,-83802,-83755,-83707,-83659,-83612,-83564,-83516,-83469,-83421,-83373,-83326,-83278,-83230,-83183,-83135,-83087,-83040,-82992,-82944,-82897,-82849,-82801,-82754,-82706,-82658,-82611,-82563,-82515,-82467,-82420,-82372,-82324,-82277,-82229,-82181,-82133,-82086,-82038,-81990,-81942,-81895,-81847,-81799,-81751,-81704,-81656,-81608,-81560,-81513,-81465,-81417,-81369,-81321,-81274,-81226,-81178,-81130,-81082,-81035,-80987,-80939,-80891,-80843,-80796,-80748,-80700,-80652,-80604,-80556,-80509,-80461,-80413,-80365,-80317,-80269,-80222,-80174,-80126,-80078,-80030,-79982,-79934,-79886,-79839,-79791,-79743,-79695,-79647,-79599,-79551,-79503,-79456,-79408,-79360,-79312,-79264,-79216,-79168,-79120,-79072,-79024,-78976,-78928,-78880,-78833,-78785,-78737,-78689,-78641,-78593,-78545,-78497,-78449,-78401,-78353,-78305,-78257,-78209,-78161,-78113,-78065,-78017,-77969,-77921,-77873,-77825,-77777,-77729,-77681,-77633,-77585,-77537,-77489,-77441,-77393,-77345,-77297,-77249,-77201,-77153,-77105,-77057,-77009,-76961,-76913,-76865,-76817,-76769,-76720,-76672,-76624,-76576,-76528,-76480,-76432,-76384,-76336,-76288,-76240,-76192,-76143,-76095,-76047,-75999,-75951,-75903,-75855,-75807,-75759,-75710,-75662,-75614,-75566,-75518,-75470,-75422,-75374,-75325,-75277,-75229,-75181,-75133,-75085,-75036,-74988,-74940,-74892,-74844,-74796,-74747,-74699,-74651,-74603,-74555,-74507,-74458,-74410,-74362,-74314,-74266,-74217,-74169,-74121,-74073,-74024,-73976,-73928,-73880,-73832,-73783,-73735,-73687,-73639,-73590,-73542,-73494,-73446,-73397,-73349,-73301,-73253,-73204,-73156,-73108,-73060,-73011,-72963,-72915,-72866,-72818,-72770,-72722,-72673,-72625,-72577,-72528,-72480,-72432,-72383,-72335,-72287,-72238,-72190,-72142,-72094,-72045,-71997,-71949,-71900,-71852,-71804,-71755,-71707,-71658,-71610,-71562,-71513,-71465,-71417,-71368,-71320,-71272,-71223,-71175,-71126,-71078,-71030,-70981,-70933,-70885,-70836,-70788,-70739,-70691,-70643,-70594,-70546,-70497,-70449,-70400,-70352,-70304,-70255,-70207,-70158,-70110,-70061,-70013,-69965,-69916,-69868,-69819,-69771,-69722,-69674,-69625,-69577,-69529,-69480,-69432,-69383,-69335,-69286,-69238,-69189,-69141,-69092,-69044,-68995,-68947,-68898,-68850,-68801,-68753,-68704,-68656,-68607,-68559,-68510,-68462,-68413,-68365,-68316,-68268,-68219,-68170,-68122,-68073,-68025,-67976,-67928,-67879,-67831,-67782,-67734,-67685,-67636,-67588,-67539,-67491,-67442,-67394,-67345,-67296,-67248,-67199,-67151,-67102,-67054,-67005,-66956,-66908,-66859,-66811,-66762,-66713,-66665,-66616,-66567,-66519,-66470,-66422,-66373,-66324,-66276,-66227,-66178,-66130,-66081,-66033,-65984,-65935,-65887,-65838,-65789,-65741,-65692,-65643,-65595,-65546,-65497,-65449,-65400,-65351,-65303,-65254,-65205,-65157,-65108,-65059,-65010,-64962,-64913,-64864,-64816,-64767,-64718,-64670,-64621,-64572,-64523,-64475,-64426,-64377,-64328,-64280,-64231,-64182,-64134,-64085,-64036,-63987,-63939,-63890,-63841,-63792,-63744,-63695,-63646,-63597,-63549,-63500,-63451,-63402,-63353,-63305,-63256,-63207,-63158,-63110,-63061,-63012,-62963,-62914,-62866,-62817,-62768,-62719,-62670,-62622,-62573,-62524,-62475,-62426,-62377,-62329,-62280,-62231,-62182,-62133,-62084,-62036,-61987,-61938,-61889,-61840,-61791,-61743,-61694,-61645,-61596,-61547,-61498,-61449,-61401,-61352,-61303,-61254,-61205,-61156,-61107,-61058,-61010,-60961,-60912,-60863,-60814,-60765,-60716,-60667,-60618,-60569,-60521,-60472,-60423,-60374,-60325,-60276,-60227,-60178,-60129,-60080,-60031,-59982,-59934,-59885,-59836,-59787,-59738,-59689,-59640,-59591,-59542,-59493,-59444,-59395,-59346,-59297,-59248,-59199,-59150,-59101,-59052,-59003,-58954,-58905,-58856,-58807,-58758,-58710,-58661,-58612,-58563,-58514,-58465,-58416,-58367,-58318,-58269,-58220,-58170,-58121,-58072,-58023,-57974,-57925,-57876,-57827,-57778,-57729,-57680,-57631,-57582,-57533,-57484,-57435,-57386,-57337,-57288,-57239,-57190,-57141,-57092,-57043,-56994,-56945,-56895,-56846,-56797,-56748,-56699,-56650,-56601,-56552,-56503,-56454,-56405,-56356,-56307,-56257,-56208,-56159,-56110,-56061,-56012,-55963,-55914,-55865,-55815,-55766,-55717,-55668,-55619,-55570,-55521,-55472,-55423,-55373,-55324,-55275,-55226,-55177,-55128,-55079,-55029,-54980,-54931,-54882,-54833,-54784,-54735,-54685,-54636,-54587,-54538,-54489,-54440,-54390,-54341,-54292,-54243,-54194,-54144,-54095,-54046,-53997,-53948,-53899,-53849,-53800,-53751,-53702,-53653,-53603,-53554,-53505,-53456,-53407,-53357,-53308,-53259,-53210,-53160,-53111,-53062,-53013,-52964,-52914,-52865,-52816,-52767,-52717,-52668,-52619,-52570,-52520,-52471,-52422,-52373,-52323,-52274,-52225,-52176,-52126,-52077,-52028,-51979,-51929,-51880,-51831,-51781,-51732,-51683,-51634,-51584,-51535,-51486,-51437,-51387,-51338,-51289,-51239,-51190,-51141,-51091,-51042,-50993,-50944,-50894,-50845,-50796,-50746,-50697,-50648,-50598,-50549,-50500,-50450,-50401,-50352,-50302,-50253,-50204,-50154,-50105,-50056,-50006,-49957,-49908,-49858,-49809,-49760,-49710,-49661,-49612,-49562,-49513,-49463,-49414,-49365,-49315,-49266,-49217,-49167,-49118,-49069,-49019,-48970,-48920,-48871,-48822,-48772,-48723,-48673,-48624,-48575,-48525,-48476,-48426,-48377,-48328,-48278,-48229,-48179,-48130,-48081,-48031,-47982,-47932,-47883,-47834,-47784,-47735,-47685,-47636,-47586,-47537,-47488,-47438,-47389,-47339,-47290,-47240,-47191,-47141,-47092,-47043,-46993,-46944,-46894,-46845,-46795,-46746,-46696,-46647,-46597,-46548,-46499,-46449,-46400,-46350,-46301,-46251,-46202,-46152,-46103,-46053,-46004,-45954,-45905,-45855,-45806,-45756,-45707,-45657,-45608,-45558,-45509,-45459,-45410,-45360,-45311,-45261,-45212,-45162,-45113,-45063,-45014,-44964,-44915,-44865,-44816,-44766,-44717,-44667,-44618,-44568,-44518,-44469,-44419,-44370,-44320,-44271,-44221,-44172,-44122,-44073,-44023,-43973,-43924,-43874,-43825,-43775,-43726,-43676,-43627,-43577,-43527,-43478,-43428,-43379,-43329,-43280,-43230,-43180,-43131,-43081,-43032,-42982,-42932,-42883,-42833,-42784,-42734,-42685,-42635,-42585,-42536,-42486,-42437,-42387,-42337,-42288,-42238,-42189,-42139,-42089,-42040,-41990,-41940,-41891,-41841,-41792,-41742,-41692,-41643,-41593,-41543,-41494,-41444,-41395,-41345,-41295,-41246,-41196,-41146,-41097,-41047,-40997,-40948,-40898,-40848,-40799,-40749,-40700,-40650,-40600,-40551,-40501,-40451,-40402,-40352,-40302,-40253,-40203,-40153,-40104,-40054,-40004,-39955,-39905,-39855,-39805,-39756,-39706,-39656,-39607,-39557,-39507,-39458,-39408,-39358,-39309,-39259,-39209,-39159,-39110,-39060,-39010,-38961,-38911,-38861,-38812,-38762,-38712,-38662,-38613,-38563,-38513,-38464,-38414,-38364,-38314,-38265,-38215,-38165,-38115,-38066,-38016,-37966,-37916,-37867,-37817,-37767,-37718,-37668,-37618,-37568,-37519,-37469,-37419,-37369,-37320,-37270,-37220,-37170,-37121,-37071,-37021,-36971,-36921,-36872,-36822,-36772,-36722,-36673,-36623,-36573,-36523,-36474,-36424,-36374,-36324,-36274,-36225,-36175,-36125,-36075,-36026,-35976,-35926,-35876,-35826,-35777,-35727,-35677,-35627,-35577,-35528,-35478,-35428,-35378,-35328,-35279,-35229,-35179,-35129,-35079,-35029,-34980,-34930,-34880,-34830,-34780,-34731,-34681,-34631,-34581,-34531,-34481,-34432,-34382,-34332,-34282,-34232,-34182,-34133,-34083,-34033,-33983,-33933,-33883,-33834,-33784,-33734,-33684,-33634,-33584,-33534,-33485,-33435,-33385,-33335,-33285,-33235,-33185,-33136,-33086,-33036,-32986,-32936,-32886,-32836,-32787,-32737,-32687,-32637,-32587,-32537,-32487,-32437,-32388,-32338,-32288,-32238,-32188,-32138,-32088,-32038,-31988,-31939,-31889,-31839,-31789,-31739,-31689,-31639,-31589,-31539,-31489,-31440,-31390,-31340,-31290,-31240,-31190,-31140,-31090,-31040,-30990,-30941,-30891,-30841,-30791,-30741,-30691,-30641,-30591,-30541,-30491,-30441,-30391,-30341,-30292,-30242,-30192,-30142,-30092,-30042,-29992,-29942,-29892,-29842,-29792,-29742,-29692,-29642,-29592,-29542,-29493,-29443,-29393,-29343,-29293,-29243,-29193,-29143,-29093,-29043,-28993,-28943,-28893,-28843,-28793,-28743,-28693,-28643,-28593,-28543,-28493,-28443,-28393,-28343,-28294,-28244,-28194,-28144,-28094,-28044,-27994,-27944,-27894,-27844,-27794,-27744,-27694,-27644,-27594,-27544,-27494,-27444,-27394,-27344,-27294,-27244,-27194,-27144,-27094,-27044,-26994,-26944,-26894,-26844,-26794,-26744,-26694,-26644,-26594,-26544,-26494,-26444,-26394,-26344,-26294,-26244,-26194,-26144,-26094,-26044,-25994,-25944,-25894,-25844,-25794,-25744,-25694,-25644,-25594,-25544,-25494,-25443,-25393,-25343,-25293,-25243,-25193,-25143,-25093,-25043,-24993,-24943,-24893,-24843,-24793,-24743,-24693,-24643,-24593,-24543,-24493,-24443,-24393,-24343,-24293,-24243,-24192,-24142,-24092,-24042,-23992,-23942,-23892,-23842,-23792,-23742,-23692,-23642,-23592,-23542,-23492,-23442,-23392,-23341,-23291,-23241,-23191,-23141,-23091,-23041,-22991,-22941,-22891,-22841,-22791,-22741,-22691,-22640,-22590,-22540,-22490,-22440,-22390,-22340,-22290,-22240,-22190,-22140,-22090,-22039,-21989,-21939,-21889,-21839,-21789,-21739,-21689,-21639,-21589,-21539,-21488,-21438,-21388,-21338,-21288,-21238,-21188,-21138,-21088,-21038,-20987,-20937,-20887,-20837,-20787,-20737,-20687,-20637,-20587,-20537,-20486,-20436,-20386,-20336,-20286,-20236,-20186,-20136,-20085,-20035,-19985,-19935,-19885,-19835,-19785,-19735,-19685,-19634,-19584,-19534,-19484,-19434,-19384,-19334,-19284,-19233,-19183,-19133,-19083,-19033,-18983,-18933,-18882,-18832,-18782,-18732,-18682,-18632,-18582,-18531,-18481,-18431,-18381,-18331,-18281,-18231,-18180,-18130,-18080,-18030,-17980,-17930,-17880,-17829,-17779,-17729,-17679,-17629,-17579,-17529,-17478,-17428,-17378,-17328,-17278,-17228,-17177,-17127,-17077,-17027,-16977,-16927,-16877,-16826,-16776,-16726,-16676,-16626,-16576,-16525,-16475,-16425,-16375,-16325,-16275,-16224,-16174,-16124,-16074,-16024,-15974,-15923,-15873,-15823,-15773,-15723,-15672,-15622,-15572,-15522,-15472,-15422,-15371,-15321,-15271,-15221,-15171,-15121,-15070,-15020,-14970,-14920,-14870,-14819,-14769,-14719,-14669,-14619,-14568,-14518,-14468,-14418,-14368,-14318,-14267,-14217,-14167,-14117,-14067,-14016,-13966,-13916,-13866,-13816,-13765,-13715,-13665,-13615,-13565,-13514,-13464,-13414,-13364,-13314,-13263,-13213,-13163,-13113,-13063,-13012,-12962,-12912,-12862,-12812,-12761,-12711,-12661,-12611,-12561,-12510,-12460,-12410,-12360,-12310,-12259,-12209,-12159,-12109,-12058,-12008,-11958,-11908,-11858,-11807,-11757,-11707,-11657,-11607,-11556,-11506,-11456,-11406,-11355,-11305,-11255,-11205,-11155,-11104,-11054,-11004,-10954,-10903,-10853,-10803,-10753,-10703,-10652,-10602,-10552,-10502,-10451,-10401,-10351,-10301,-10251,-10200,-10150,-10100,-10050,-9999,-9949,-9899,-9849,-9798,-9748,-9698,-9648,-9598,-9547,-9497,-9447,-9397,-9346,-9296,-9246,-9196,-9145,-9095,-9045,-8995,-8945,-8894,-8844,-8794,-8744,-8693,-8643,-8593,-8543,-8492,-8442,-8392,-8342,-8291,-8241,-8191,-8141,-8090,-8040,-7990,-7940,-7889,-7839,-7789,-7739,-7689,-7638,-7588,-7538,-7488,-7437,-7387,-7337,-7287,-7236,-7186,-7136,-7086,-7035,-6985,-6935,-6885,-6834,-6784,-6734,-6684,-6633,-6583,-6533,-6483,-6432,-6382,-6332,-6282,-6231,-6181,-6131,-6081,-6030,-5980,-5930,-5880,-5829,-5779,-5729,-5679,-5628,-5578,-5528,-5478,-5427,-5377,-5327,-5277,-5226,-5176,-5126,-5075,-5025,-4975,-4925,-4874,-4824,-4774,-4724,-4673,-4623,-4573,-4523,-4472,-4422,-4372,-4322,-4271,-4221,-4171,-4121,-4070,-4020,-3970,-3920,-3869,-3819,-3769,-3719,-3668,-3618,-3568,-3517,-3467,-3417,-3367,-3316,-3266,-3216,-3166,-3115,-3065,-3015,-2965,-2914,-2864,-2814,-2764,-2713,-2663,-2613,-2562,-2512,-2462,-2412,-2361,-2311,-2261,-2211,-2160,-2110,-2060,-2010,-1959,-1909,-1859,-1809,-1758,-1708,-1658,-1607,-1557,-1507,-1457,-1406,-1356,-1306,-1256,-1205,-1155,-1105,-1055,-1004,-954,-904,-854,-803,-753,-703,-652,-602,-552,-502,-451,-401,-351,-301,-250,-200,-150,-100,-49,0,50,101,151,201,251,302,352,402,452,503,553,603,653,704,754,804,855,905,955,1005,1056,1106,1156,1206,1257,1307,1357,1407,1458,1508,1558,1608,1659,1709,1759,1810,1860,1910,1960,2011,2061,2111,2161,2212,2262,2312,2362,2413,2463,2513,2563,2614,2664,2714,2765,2815,2865,2915,2966,3016,3066,3116,3167,3217,3267,3317,3368,3418,3468,3518,3569,3619,3669,3720,3770,3820,3870,3921,3971,4021,4071,4122,4172,4222,4272,4323,4373,4423,4473,4524,4574,4624,4674,4725,4775,4825,4875,4926,4976,5026,5076,5127,5177,5227,5278,5328,5378,5428,5479,5529,5579,5629,5680,5730,5780,5830,5881,5931,5981,6031,6082,6132,6182,6232,6283,6333,6383,6433,6484,6534,6584,6634,6685,6735,6785,6835,6886,6936,6986,7036,7087,7137,7187,7237,7288,7338,7388,7438,7489,7539,7589,7639,7690,7740,7790,7840,7890,7941,7991,8041,8091,8142,8192,8242,8292,8343,8393,8443,8493,8544,8594,8644,8694,8745,8795,8845,8895,8946,8996,9046,9096,9146,9197,9247,9297,9347,9398,9448,9498,9548,9599,9649,9699,9749,9799,9850,9900,9950,10000,10051,10101,10151,10201,10252,10302,10352,10402,10452,10503,10553,10603,10653,10704,10754,10804,10854,10904,10955,11005,11055,11105,11156,11206,11256,11306,11356,11407,11457,11507,11557,11608,11658,11708,11758,11808,11859,11909,11959,12009,12059,12110,12160,12210,12260,12311,12361,12411,12461,12511,12562,12612,12662,12712,12762,12813,12863,12913,12963,13013,13064,13114,13164,13214,13264,13315,13365,13415,13465,13515,13566,13616,13666,13716,13766,13817,13867,13917,13967,14017,14068,14118,14168,14218,14268,14319,14369,14419,14469,14519,14569,14620,14670,14720,14770,14820,14871,14921,14971,15021,15071,15122,15172,15222,15272,15322,15372,15423,15473,15523,15573,15623,15673,15724,15774,15824,15874,15924,15975,16025,16075,16125,16175,16225,16276,16326,16376,16426,16476,16526,16577,16627,16677,16727,16777,16827,16878,16928,16978,17028,17078,17128,17178,17229,17279,17329,17379,17429,17479,17530,17580,17630,17680,17730,17780,17830,17881,17931,17981,18031,18081,18131,18181,18232,18282,18332,18382,18432,18482,18532,18583,18633,18683,18733,18783,18833,18883,18934,18984,19034,19084,19134,19184,19234,19285,19335,19385,19435,19485,19535,19585,19635,19686,19736,19786,19836,19886,19936,19986,20036,20086,20137,20187,20237,20287,20337,20387,20437,20487,20538,20588,20638,20688,20738,20788,20838,20888,20938,20988,21039,21089,21139,21189,21239,21289,21339,21389,21439,21489,21540,21590,21640,21690,21740,21790,21840,21890,21940,21990,22040,22091,22141,22191,22241,22291,22341,22391,22441,22491,22541,22591,22641,22692,22742,22792,22842,22892,22942,22992,23042,23092,23142,23192,23242,23292,23342,23393,23443,23493,23543,23593,23643,23693,23743,23793,23843,23893,23943,23993,24043,24093,24143,24193,24244,24294,24344,24394,24444,24494,24544,24594,24644,24694,24744,24794,24844,24894,24944,24994,25044,25094,25144,25194,25244,25294,25344,25394,25444,25495,25545,25595,25645,25695,25745,25795,25845,25895,25945,25995,26045,26095,26145,26195,26245,26295,26345,26395,26445,26495,26545,26595,26645,26695,26745,26795,26845,26895,26945,26995,27045,27095,27145,27195,27245,27295,27345,27395,27445,27495,27545,27595,27645,27695,27745,27795,27845,27895,27945,27995,28045,28095,28145,28195,28245,28295,28344,28394,28444,28494,28544,28594,28644,28694,28744,28794,28844,28894,28944,28994,29044,29094,29144,29194,29244,29294,29344,29394,29444,29494,29543,29593,29643,29693,29743,29793,29843,29893,29943,29993,30043,30093,30143,30193,30243,30293,30342,30392,30442,30492,30542,30592,30642,30692,30742,30792,30842,30892,30942,30991,31041,31091,31141,31191,31241,31291,31341,31391,31441,31490,31540,31590,31640,31690,31740,31790,31840,31890,31940,31989,32039,32089,32139,32189,32239,32289,32339,32389,32438,32488,32538,32588,32638,32688,32738,32788,32837,32887,32937,32987,33037,33087,33137,33186,33236,33286,33336,33386,33436,33486,33535,33585,33635,33685,33735,33785,33835,33884,33934,33984,34034,34084,34134,34183,34233,34283,34333,34383,34433,34482,34532,34582,34632,34682,34732,34781,34831,34881,34931,34981,35030,35080,35130,35180,35230,35280,35329,35379,35429,35479,35529,35578,35628,35678,35728,35778,35827,35877,35927,35977,36027,36076,36126,36176,36226,36275,36325,36375,36425,36475,36524,36574,36624,36674,36723,36773,36823,36873,36922,36972,37022,37072,37122,37171,37221,37271,37321,37370,37420,37470,37520,37569,37619,37669,37719,37768,37818,37868,37917,37967,38017,38067,38116,38166,38216,38266,38315,38365,38415,38465,38514,38564,38614,38663,38713,38763,38813,38862,38912,38962,39011,39061,39111,39160,39210,39260,39310,39359,39409,39459,39508,39558,39608,39657,39707,39757,39806,39856,39906,39956,40005,40055,40105,40154,40204,40254,40303,40353,40403,40452,40502,40552,40601,40651,40701,40750,40800,40849,40899,40949,40998,41048,41098,41147,41197,41247,41296,41346,41396,41445,41495,41544,41594,41644,41693,41743,41793,41842,41892,41941,41991,42041,42090,42140,42190,42239,42289,42338,42388,42438,42487,42537,42586,42636,42686,42735,42785,42834,42884,42933,42983,43033,43082,43132,43181,43231,43281,43330,43380,43429,43479,43528,43578,43628,43677,43727,43776,43826,43875,43925,43974,44024,44074,44123,44173,44222,44272,44321,44371,44420,44470,44519,44569,44619,44668,44718,44767,44817,44866,44916,44965,45015,45064,45114,45163,45213,45262,45312,45361,45411,45460,45510,45559,45609,45658,45708,45757,45807,45856,45906,45955,46005,46054,46104,46153,46203,46252,46302,46351,46401,46450,46500,46549,46598,46648,46697,46747,46796,46846,46895,46945,46994,47044,47093,47142,47192,47241,47291,47340,47390,47439,47489,47538,47587,47637,47686,47736,47785,47835,47884,47933,47983,48032,48082,48131,48180,48230,48279,48329,48378,48427,48477,48526,48576,48625,48674,48724,48773,48823,48872,48921,48971,49020,49070,49119,49168,49218,49267,49316,49366,49415,49464,49514,49563,49613,49662,49711,49761,49810,49859,49909,49958,50007,50057,50106,50155,50205,50254,50303,50353,50402,50451,50501,50550,50599,50649,50698,50747,50797,50846,50895,50945,50994,51043,51092,51142,51191,51240,51290,51339,51388,51438,51487,51536,51585,51635,51684,51733,51782,51832,51881,51930,51980,52029,52078,52127,52177,52226,52275,52324,52374,52423,52472,52521,52571,52620,52669,52718,52768,52817,52866,52915,52965,53014,53063,53112,53161,53211,53260,53309,53358,53408,53457,53506,53555,53604,53654,53703,53752,53801,53850,53900,53949,53998,54047,54096,54145,54195,54244,54293,54342,54391,54441,54490,54539,54588,54637,54686,54736,54785,54834,54883,54932,54981,55030,55080,55129,55178,55227,55276,55325,55374,55424,55473,55522,55571,55620,55669,55718,55767,55816,55866,55915,55964,56013,56062,56111,56160,56209,56258,56308,56357,56406,56455,56504,56553,56602,56651,56700,56749,56798,56847,56896,56946,56995,57044,57093,57142,57191,57240,57289,57338,57387,57436,57485,57534,57583,57632,57681,57730,57779,57828,57877,57926,57975,58024,58073,58122,58171,58221,58270,58319,58368,58417,58466,58515,58564,58613,58662,58711,58759,58808,58857,58906,58955,59004,59053,59102,59151,59200,59249,59298,59347,59396,59445,59494,59543,59592,59641,59690,59739,59788,59837,59886,59935,59983,60032,60081,60130,60179,60228,60277,60326,60375,60424,60473,60522,60570,60619,60668,60717,60766,60815,60864,60913,60962,61011,61059,61108,61157,61206,61255,61304,61353,61402,61450,61499,61548,61597,61646,61695,61744,61792,61841,61890,61939,61988,62037,62085,62134,62183,62232,62281,62330,62378,62427,62476,62525,62574,62623,62671,62720,62769,62818,62867,62915,62964,63013,63062,63111,63159,63208,63257,63306,63354,63403,63452,63501,63550,63598,63647,63696,63745,63793,63842,63891,63940,63988,64037,64086,64135,64183,64232,64281,64329,64378,64427,64476,64524,64573,64622,64671,64719,64768,64817,64865,64914,64963,65011,65060,65109,65158,65206,65255,65304,65352,65401,65450,65498,65547,65596,65644,65693,65742,65790,65839,65888,65936,65985,66034,66082,66131,66179,66228,66277,66325,66374,66423,66471,66520,66568,66617,66666,66714,66763,66812,66860,66909,66957,67006,67055,67103,67152,67200,67249,67297,67346,67395,67443,67492,67540,67589,67637,67686,67735,67783,67832,67880,67929,67977,68026,68074,68123,68171,68220,68269,68317,68366,68414,68463,68511,68560,68608,68657,68705,68754,68802,68851,68899,68948,68996,69045,69093,69142,69190,69239,69287,69336,69384,69433,69481,69530,69578,69626,69675,69723,69772,69820,69869,69917,69966,70014,70062,70111,70159,70208,70256,70305,70353,70401,70450,70498,70547,70595,70644,70692,70740,70789,70837,70886,70934,70982,71031,71079,71127,71176,71224,71273,71321,71369,71418,71466,71514,71563,71611,71659,71708,71756,71805,71853,71901,71950,71998,72046,72095,72143,72191,72239,72288,72336,72384,72433,72481,72529,72578,72626,72674,72723,72771,72819,72867,72916,72964,73012,73061,73109,73157,73205,73254,73302,73350,73398,73447,73495,73543,73591,73640,73688,73736,73784,73833,73881,73929,73977,74025,74074,74122,74170,74218,74267,74315,74363,74411,74459,74508,74556,74604,74652,74700,74748,74797,74845,74893,74941,74989,75037,75086,75134,75182,75230,75278,75326,75375,75423,75471,75519,75567,75615,75663,75711,75760,75808,75856,75904,75952,76000,76048,76096,76144,76193,76241,76289,76337,76385,76433,76481,76529,76577,76625,76673,76721,76770,76818,76866,76914,76962,77010,77058,77106,77154,77202,77250,77298,77346,77394,77442,77490,77538,77586,77634,77682,77730,77778,77826,77874,77922,77970,78018,78066,78114,78162,78210,78258,78306,78354,78402,78450,78498,78546,78594,78642,78690,78738,78786,78834,78881,78929,78977,79025,79073,79121,79169,79217,79265,79313,79361,79409,79457,79504,79552,79600,79648,79696,79744,79792,79840,79887,79935,79983,80031,80079,80127,80175,80223,80270,80318,80366,80414,80462,80510,80557,80605,80653,80701,80749,80797,80844,80892,80940,80988,81036,81083,81131,81179,81227,81275,81322,81370,81418,81466,81514,81561,81609,81657,81705,81752,81800,81848,81896,81943,81991,82039,82087,82134,82182,82230,82278,82325,82373,82421,82468,82516,82564,82612,82659,82707,82755,82802,82850,82898,82945,82993,83041,83088,83136,83184,83231,83279,83327,83374,83422,83470,83517,83565,83613,83660,83708,83756,83803,83851,83898,83946,83994,84041,84089,84136,84184,84232,84279,84327,84374,84422,84470,84517,84565,84612,84660,84708,84755,84803,84850,84898,84945,84993,85040,85088,85136,85183,85231,85278,85326,85373,85421,85468,85516,85563,85611,85658,85706,85753,85801,85848,85896,85943,85991,86038,86086,86133,86181,86228,86276,86323,86371,86418,86465,86513,86560,86608,86655,86703,86750,86798,86845,86892,86940,86987,87035,87082,87129,87177,87224,87272,87319,87366,87414,87461,87509,87556,87603,87651,87698,87745,87793,87840,87888,87935,87982,88030,88077,88124,88172,88219,88266,88314,88361,88408,88456,88503,88550,88598,88645,88692,88739,88787,88834,88881,88929,88976,89023,89070,89118,89165,89212,89260,89307,89354,89401,89449,89496,89543,89590,89638,89685,89732,89779,89826,89874,89921,89968,90015,90063,90110,90157,90204,90251,90299,90346,90393,90440,90487,90534,90582,90629,90676,90723,90770,90817,90865,90912,90959,91006,91053,91100,91147,91195,91242,91289,91336,91383,91430,91477,91524,91571,91619,91666,91713,91760,91807,91854,91901,91948,91995,92042,92089,92136,92183,92230,92278,92325,92372,92419,92466,92513,92560,92607,92654,92701,92748,92795,92842,92889,92936,92983,93030,93077,93124,93171,93218,93265,93312,93359,93406,93453,93500,93547,93594,93640,93687,93734,93781,93828,93875,93922,93969,94016,94063,94110,94157,94204,94251,94297,94344,94391,94438,94485,94532,94579,94626,94673,94719,94766,94813,94860,94907,94954,95001,95047,95094,95141,95188,95235,95282,95328,95375,95422,95469,95516,95562,95609,95656,95703,95750,95796,95843,95890,95937,95984,96030,96077,96124,96171,96217,96264,96311,96358,96404,96451,96498,96545,96591,96638,96685,96732,96778,96825,96872,96918,96965,97012,97058,97105,97152,97199,97245,97292,97339,97385,97432,97479,97525,97572,97619,97665,97712,97758,97805,97852,97898,97945,97992,98038,98085,98131,98178,98225,98271,98318,98364,98411,98458,98504,98551,98597,98644,98691,98737,98784,98830,98877,98923,98970,99016,99063,99110,99156,99203,99249,99296,99342,99389,99435,99482,99528,99575,99621,99668,99714,99761,99807,99854,99900,99947,99993,100039,100086,100132,100179,100225,100272,100318,100365,100411,100457,100504,100550,100597,100643,100690,100736,100782,100829,100875,100922,100968,101014,101061,101107,101153,101200,101246,101293,101339,101385,101432,101478,101524,101571,101617,101663,101710,101756,101802,101849,101895,101941,101988,102034,102080,102126,102173,102219,102265,102312,102358,102404,102450,102497,102543,102589,102635,102682,102728,102774,102820,102867,102913,102959,103005,103052,103098,103144,103190,103236,103283,103329,103375,103421,103467,103514,103560,103606,103652,103698,103744,103791,103837,103883,103929,103975,104021,104067,104114,104160,104206,104252,104298,104344,104390,104436,104483,104529,104575,104621,104667,104713,104759,104805,104851,104897,104943,104989,105035,105082,105128,105174,105220,105266,105312,105358,105404,105450,105496,105542,105588,105634,105680,105726,105772,105818,105864,105910,105956,106002,106048,106094,106140,106186,106232,106278,106323,106369,106415,106461,106507,106553,106599,106645,106691,106737,106783,106829,106875,106920,106966,107012,107058,107104,107150,107196,107242,107287,107333,107379,107425,107471,107517,107563,107608,107654,107700,107746,107792,107838,107883,107929,107975,108021,108067,108112,108158,108204,108250,108295,108341,108387,108433,108479,108524,108570,108616,108662,108707,108753,108799,108845,108890,108936,108982,109027,109073,109119,109165,109210,109256,109302,109347,109393,109439,109484,109530,109576,109621,109667,109713,109758,109804,109850,109895,109941,109986,110032,110078,110123,110169,110215,110260,110306,110351,110397,110443,110488,110534,110579,110625,110670,110716,110762,110807,110853,110898,110944,110989,111035,111080,111126,111171,111217,111262,111308,111353,111399,111444,111490,111535,111581,111626,111672,111717,111763,111808,111854,111899,111945,111990,112036,112081,112126,112172,112217,112263,112308,112354,112399,112444,112490,112535,112581,112626,112671,112717,112762,112808,112853,112898,112944,112989,113034,113080,113125,113170,113216,113261,113306,113352,113397,113442,113488,113533,113578,113624,113669,113714,113759,113805,113850,113895,113941,113986,114031,114076,114122,114167,114212,114257,114303,114348,114393,114438,114483,114529,114574,114619,114664,114710,114755,114800,114845,114890,114935,114981,115026,115071,115116,115161,115206,115252,115297,115342,115387,115432,115477,115522,115567,115613,115658,115703,115748,115793,115838,115883,115928,115973,116018,116064,116109,116154,116199,116244,116289,116334,116379,116424,116469,116514,116559,116604,116649,116694,116739,116784,116829,116874,116919,116964,117009,117054,117099,117144,117189,117234,117279,117324,117369,117414,117459,117504,117549,117593,117638,117683,117728,117773,117818,117863,117908,117953,117998,118042,118087,118132,118177,118222,118267,118312,118357,118401,118446,118491,118536,118581,118626,118670,118715,118760,118805,118850,118894,118939,118984,119029,119074,119118,119163,119208,119253,119297,119342,119387,119432,119476,119521,119566,119611,119655,119700,119745,119790,119834,119879,119924,119968,120013,120058,120102,120147,120192,120236,120281,120326,120370,120415,120460,120504,120549,120594,120638,120683,120727,120772,120817,120861,120906,120950,120995,121040,121084,121129,121173,121218,121263,121307,121352,121396,121441,121485,121530,121574,121619,121663,121708,121752,121797,121842,121886,121931,121975,122019,122064,122108,122153,122197,122242,122286,122331,122375,122420,122464,122509,122553,122597,122642,122686,122731,122775,122820,122864,122908,122953,122997,123042,123086,123130,123175,123219,123263,123308,123352,123396,123441,123485,123529,123574,123618,123662,123707,123751,123795,123840,123884,123928,123973,124017,124061,124105,124150,124194,124238,124283,124327,124371,124415,124460,124504,124548,124592,124636,124681,124725,124769,124813,124857,124902,124946,124990,125034,125078,125123,125167,125211,125255,125299,125343,125388,125432,125476,125520,125564,125608,125652,125696,125741,125785,125829,125873,125917,125961,126005,126049,126093,126137,126181,126225,126269,126314,126358,126402,126446,126490,126534,126578,126622,126666,126710,126754,126798,126842,126886,126930,126974,127018,127062,127106,127150,127193,127237,127281,127325,127369,127413,127457,127501,127545,127589,127633,127677,127721,127764,127808,127852,127896,127940,127984,128028,128072,128115,128159,128203,128247,128291,128335,128378,128422,128466,128510,128554,128598,128641,128685,128729,128773,128816,128860,128904,128948,128992,129035,129079,129123,129167,129210,129254,129298,129341,129385,129429,129473,129516,129560,129604,129647,129691,129735,129778,129822,129866,129909,129953,129997,130040,130084,130128,130171,130215,130259,130302,130346,130389,130433,130477,130520,130564,130607,130651,130695,130738,130782,130825,130869,130912,130956,130999,131043,131087,131130,131174,131217,131261,131304,131348,131391,131435,131478,131522,131565,131609,131652,131695,131739,131782,131826,131869,131913,131956,132000,132043,132086,132130,132173,132217,132260,132303,132347,132390,132434,132477,132520,132564,132607,132650,132694,132737,132780,132824,132867,132910,132954,132997,133040,133084,133127,133170,133214,133257,133300,133343,133387,133430,133473,133517,133560,133603,133646,133690,133733,133776,133819,133862,133906,133949,133992,134035,134078,134122,134165,134208,134251,134294,134338,134381,134424,134467,134510,134553,134596,134640,134683,134726,134769,134812,134855,134898,134941,134984,135028,135071,135114,135157,135200,135243,135286,135329,135372,135415,135458,135501,135544,135587,135630,135673,135716,135759,135802,135845,135888,135931,135974,136017,136060,136103,136146,136189,136232,136275,136318,136361,136404,136447,136490,136532,136575,136618,136661,136704,136747,136790,136833,136876,136918,136961,137004,137047,137090,137133,137176,137218,137261,137304,137347,137390,137432,137475,137518,137561,137604,137646,137689,137732,137775,137817,137860,137903,137946,137988,138031,138074,138117,138159,138202,138245,138288,138330,138373,138416,138458,138501,138544,138586,138629,138672,138714,138757,138800,138842,138885,138927,138970,139013,139055,139098,139141,139183,139226,139268,139311,139353,139396,139439,139481,139524,139566,139609,139651,139694,139736,139779,139821,139864,139907,139949,139992,140034,140077,140119,140161,140204,140246,140289,140331,140374,140416,140459,140501,140544,140586,140628,140671,140713,140756,140798,140840,140883,140925,140968,141010,141052,141095,141137,141179,141222,141264,141306,141349,141391,141433,141476,141518,141560,141603,141645,141687,141730,141772,141814,141856,141899,141941,141983,142025,142068,142110,142152,142194,142237,142279,142321,142363,142405,142448,142490,142532,142574,142616,142659,142701,142743,142785,142827,142869,142912,142954,142996,143038,143080,143122,143164,143206,143248,143291,143333,143375,143417,143459,143501,143543,143585,143627,143669,143711,143753,143795,143837,143879,143921,143963,144005,144047,144089,144131,144173,144215,144257,144299,144341,144383,144425,144467,144509,144551,144593,144635,144677,144719,144761,144802,144844,144886,144928,144970,145012,145054,145096,145137,145179,145221,145263,145305,145347,145389,145430,145472,145514,145556,145598,145639,145681,145723,145765,145807,145848,145890,145932,145974,146015,146057,146099,146141,146182,146224,146266,146307,146349,146391,146433,146474,146516,146558,146599,146641,146683,146724,146766,146808,146849,146891,146932,146974,147016,147057,147099,147141,147182,147224,147265,147307,147348,147390,147432,147473,147515,147556,147598,147639,147681,147722,147764,147805,147847,147888,147930,147971,148013,148054,148096,148137,148179,148220,148262,148303,148345,148386,148428,148469,148510,148552,148593,148635,148676,148717,148759,148800,148842,148883,148924,148966,149007,149048,149090,149131,149172,149214,149255,149296,149338,149379,149420,149462,149503,149544,149585,149627,149668,149709,149751,149792,149833,149874,149916,149957,149998,150039,150080,150122,150163,150204,150245,150286,150328,150369,150410,150451,150492,150533,150575,150616,150657,150698,150739,150780,150821,150862,150904,150945,150986,151027,151068,151109,151150,151191,151232,151273,151314,151355,151396,151437,151478,151519,151560,151601,151642,151683,151724,151765,151806,151847,151888,151929,151970,152011,152052,152093,152134,152175,152216,152257,152298,152339,152380,152421,152461,152502,152543,152584,152625,152666,152707,152748,152788,152829,152870,152911,152952,152993,153033,153074,153115,153156,153197,153237,153278,153319,153360,153400,153441,153482,153523,153563,153604,153645,153686,153726,153767,153808,153848,153889,153930,153970,154011,154052,154093,154133,154174,154214,154255,154296,154336,154377,154418,154458,154499,154539,154580,154621,154661,154702,154742,154783,154824,154864,154905,154945,154986,155026,155067,155107,155148,155188,155229,155269,155310,155350,155391,155431,155472,155512,155553,155593,155634,155674,155715,155755,155795,155836,155876,155917,155957,155997,156038,156078,156119,156159,156199,156240,156280,156320,156361,156401,156441,156482,156522,156562,156603,156643,156683,156724,156764,156804,156845,156885,156925,156965,157006,157046,157086,157126,157167,157207,157247,157287,157327,157368,157408,157448,157488,157528,157569,157609,157649,157689,157729,157769,157809,157850,157890,157930,157970,158010,158050,158090,158130,158170,158211,158251,158291,158331,158371,158411,158451,158491,158531,158571,158611,158651,158691,158731,158771,158811,158851,158891,158931,158971,159011,159051,159091,159131,159171,159211,159251,159291,159330,159370,159410,159450,159490,159530,159570,159610,159650,159689,159729,159769,159809,159849,159889,159929,159968,160008,160048,160088,160128,160167,160207,160247,160287,160327,160366,160406,160446,160486,160525,160565,160605,160644,160684,160724,160764,160803,160843,160883,160922,160962,161002,161041,161081,161121,161160,161200,161240,161279,161319,161359,161398,161438,161477,161517,161557,161596,161636,161675,161715,161754,161794,161833,161873,161913,161952,161992,162031,162071,162110,162150,162189,162229,162268,162308,162347,162386,162426,162465,162505,162544,162584,162623,162663,162702,162741,162781,162820,162860,162899,162938,162978,163017,163056,163096,163135,163174,163214,163253,163292,163332,163371,163410,163450,163489,163528,163568,163607,163646,163685,163725,163764,163803,163842,163882,163921,163960,163999,164039,164078,164117,164156,164195,164234,164274,164313,164352,164391,164430,164469,164509,164548,164587,164626,164665,164704,164743,164782,164821,164861,164900,164939,164978,165017,165056,165095,165134,165173,165212,165251,165290,165329,165368,165407,165446,165485,165524,165563,165602,165641,165680,165719,165758,165797,165836,165875,165914,165952,165991,166030,166069,166108,166147,166186,166225,166264,166302,166341,166380,166419,166458,166497,166535,166574,166613,166652,166691,166729,166768,166807,166846,166885,166923,166962,167001,167040,167078,167117,167156,167194,167233,167272,167311,167349,167388,167427,167465,167504,167543,167581,167620,167659,167697,167736,167774,167813,167852,167890,167929,167968,168006,168045,168083,168122,168160,168199,168238,168276,168315,168353,168392,168430,168469,168507,168546,168584,168623,168661,168700,168738,168777,168815,168853,168892,168930,168969,169007,169046,169084,169122,169161,169199,169238,169276,169314,169353,169391,169430,169468,169506,169545,169583,169621,169660,169698,169736,169774,169813,169851,169889,169928,169966,170004,170042,170081,170119,170157,170195,170234,170272,170310,170348,170386,170425,170463,170501,170539,170577,170616,170654,170692,170730,170768,170806,170844,170883,170921,170959,170997,171035,171073,171111,171149,171187,171225,171263,171301,171339,171378,171416,171454,171492,171530,171568,171606,171644,171682,171720,171758,171796,171834,171871,171909,171947,171985,172023,172061,172099,172137,172175,172213,172251,172289,172326,172364,172402,172440,172478,172516,172554,172591,172629,172667,172705,172743,172781,172818,172856,172894,172932,172969,173007,173045,173083,173121,173158,173196,173234,173271,173309,173347,173385,173422,173460,173498,173535,173573,173611,173648,173686,173724,173761,173799,173837,173874,173912,173949,173987,174025,174062,174100,174137,174175,174212,174250,174288,174325,174363,174400,174438,174475,174513,174550,174588,174625,174663,174700,174738,174775,174813,174850,174887,174925,174962,175000,175037,175075,175112,175149,175187,175224,175262,175299,175336,175374,175411,175448,175486,175523,175560,175598,175635,175672,175710,175747,175784,175822,175859,175896,175933,175971,176008,176045,176082,176120,176157,176194,176231,176268,176306,176343,176380,176417,176454,176492,176529,176566,176603,176640,176677,176714,176752,176789,176826,176863,176900,176937,176974,177011,177048,177085,177123,177160,177197,177234,177271,177308,177345,177382,177419,177456,177493,177530,177567,177604,177641,177678,177715,177752,177788,177825,177862,177899,177936,177973,178010,178047,178084,178121,178158,178194,178231,178268,178305,178342,178379,178415,178452,178489,178526,178563,178600,178636,178673,178710,178747,178783,178820,178857,178894,178930,178967,179004,179041,179077,179114,179151,179187,179224,179261,179297,179334,179371,179407,179444,179481,179517,179554,179591,179627,179664,179700,179737,179774,179810,179847,179883,179920,179956,179993,180029,180066,180103,180139,180176,180212,180249,180285,180322,180358,180395,180431,180467,180504,180540,180577,180613,180650,180686,180723,180759,180795,180832,180868,180904,180941,180977,181014,181050,181086,181123,181159,181195,181232,181268,181304,181341,181377,181413,181449,181486,181522,181558,181594,181631,181667,181703,181739,181776,181812,181848,181884,181920,181957,181993,182029,182065,182101,182137,182174,182210,182246,182282,182318,182354,182390,182426,182463,182499,182535,182571,182607,182643,182679,182715,182751,182787,182823,182859,182895,182931,182967,183003,183039,183075,183111,183147,183183,183219,183255,183291,183327,183363,183399,183435,183470,183506,183542,183578,183614,183650,183686,183722,183757,183793,183829,183865,183901,183937,183972,184008,184044,184080,184116,184151,184187,184223,184259,184294,184330,184366,184402,184437,184473,184509,184545,184580,184616,184652,184687,184723,184759,184794,184830,184866,184901,184937,184972,185008,185044,185079,185115,185150,185186,185222,185257,185293,185328,185364,185399,185435,185470,185506,185541,185577,185612,185648,185683,185719,185754,185790,185825,185861,185896,185932,185967,186002,186038,186073,186109,186144,186179,186215,186250,186286,186321,186356,186392,186427,186462,186498,186533,186568,186604,186639,186674,186710,186745,186780,186815,186851,186886,186921,186956,186992,187027,187062,187097,187132,187168,187203,187238,187273,187308,187343,187379,187414,187449,187484,187519,187554,187589,187625,187660,187695,187730,187765,187800,187835,187870,187905,187940,187975,188010,188045,188080,188115,188150,188185,188220,188255,188290,188325,188360,188395,188430,188465,188500,188535,188570,188605,188640,188675,188709,188744,188779,188814,188849,188884,188919,188954,188988,189023,189058,189093,189128,189162,189197,189232,189267,189302,189336,189371,189406,189441,189475,189510,189545,189580,189614,189649,189684,189718,189753,189788,189822,189857,189892,189926,189961,189996,190030,190065,190099,190134,190169,190203,190238,190272,190307,190342,190376,190411,190445,190480,190514,190549,190583,190618,190652,190687,190721,190756,190790,190825,190859,190894,190928,190963,190997,191031,191066,191100,191135,191169,191203,191238,191272,191307,191341,191375,191410,191444,191478,191513,191547,191581,191616,191650,191684,191718,191753,191787,191821,191856,191890,191924,191958,191992,192027,192061,192095,192129,192164,192198,192232,192266,192300,192334,192369,192403,192437,192471,192505,192539,192573,192607,192641,192676,192710,192744,192778,192812,192846,192880,192914,192948,192982,193016,193050,193084,193118,193152,193186,193220,193254,193288,193322,193356,193390,193424,193458,193492,193525,193559,193593,193627,193661,193695,193729,193763,193796,193830,193864,193898,193932,193966,193999,194033,194067,194101,194135,194168,194202,194236,194270,194303,194337,194371,194405,194438,194472,194506,194539,194573,194607,194640,194674,194708,194741,194775,194809,194842,194876,194910,194943,194977,195010,195044,195078,195111,195145,195178,195212,195245,195279,195312,195346,195379,195413,195446,195480,195513,195547,195580,195614,195647,195681,195714,195748,195781,195815,195848,195881,195915,195948,195982,196015,196048,196082,196115,196148,196182,196215,196248,196282,196315,196348,196382,196415,196448,196481,196515,196548,196581,196615,196648,196681,196714,196747,196781,196814,196847,196880,196913,196947,196980,197013,197046,197079,197112,197146,197179,197212,197245,197278,197311,197344,197377,197410,197443,197476,197510,197543,197576,197609,197642,197675,197708,197741,197774,197807,197840,197873,197906,197939,197972,198004,198037,198070,198103,198136,198169,198202,198235,198268,198301,198334,198366,198399,198432,198465,198498,198531,198563,198596,198629,198662,198695,198727,198760,198793,198826,198858,198891,198924,198957,198989,199022,199055,199088,199120,199153,199186,199218,199251,199284,199316,199349,199382,199414,199447,199479,199512,199545,199577,199610,199642,199675,199708,199740,199773,199805,199838,199870,199903,199935,199968,200000,200033,200065,200098,200130,200163,200195,200228,200260,200292,200325,200357,200390,200422,200454,200487,200519,200552,200584,200616,200649,200681,200713,200746,200778,200810,200843,200875,200907,200940,200972,201004,201036,201069,201101,201133,201165,201198,201230,201262,201294,201326,201359,201391,201423,201455,201487,201519,201552,201584,201616,201648,201680,201712,201744,201776,201808,201841,201873,201905,201937,201969,202001,202033,202065,202097,202129,202161,202193,202225,202257,202289,202321,202353,202385,202417,202449,202481,202512,202544,202576,202608,202640,202672,202704,202736,202768,202799,202831,202863,202895,202927,202959,202990,203022,203054,203086,203118,203149,203181,203213,203245,203276,203308,203340,203372,203403,203435,203467,203498,203530,203562,203593,203625,203657,203688,203720,203752,203783,203815,203846,203878,203910,203941,203973,204004,204036,204067,204099,204131,204162,204194,204225,204257,204288,204320,204351,204383,204414,204446,204477,204508,204540,204571,204603,204634,204666,204697,204728,204760,204791,204823,204854,204885,204917,204948,204979,205011,205042,205073,205105,205136,205167,205198,205230,205261,205292,205324,205355,205386,205417,205448,205480,205511,205542,205573,205604,205636,205667,205698,205729,205760,205791,205823,205854,205885,205916,205947,205978,206009,206040,206071,206102,206133,206165,206196,206227,206258,206289,206320,206351,206382,206413,206444,206475,206506,206537,206567,206598,206629,206660,206691,206722,206753,206784,206815,206846,206877,206907,206938,206969,207000,207031,207062,207092,207123,207154,207185,207216,207246,207277,207308,207339,207370,207400,207431,207462,207492,207523,207554,207585,207615,207646,207677,207707,207738,207769,207799,207830,207861,207891,207922,207952,207983,208014,208044,208075,208105,208136,208166,208197,208228,208258,208289,208319,208350,208380,208411,208441,208472,208502,208533,208563,208593,208624,208654,208685,208715,208746,208776,208806,208837,208867,208897,208928,208958,208989,209019,209049,209080,209110,209140,209170,209201,209231,209261,209292,209322,209352,209382,209413,209443,209473,209503,209534,209564,209594,209624,209654,209684,209715,209745,209775,209805,209835,209865,209895,209926,209956,209986,210016,210046,210076,210106,210136,210166,210196,210226,210256,210286,210316,210346,210376,210406,210436,210466,210496,210526,210556,210586,210616,210646,210676,210706,210736,210765,210795,210825,210855,210885,210915,210945,210974,211004,211034,211064,211094,211124,211153,211183,211213,211243,211272,211302,211332,211362,211391,211421,211451,211481,211510,211540,211570,211599,211629,211659,211688,211718,211748,211777,211807,211836,211866,211896,211925,211955,211984,212014,212043,212073,212103,212132,212162,212191,212221,212250,212280,212309,212339,212368,212398,212427,212456,212486,212515,212545,212574,212604,212633,212662,212692,212721,212751,212780,212809,212839,212868,212897,212927,212956,212985,213015,213044,213073,213102,213132,213161,213190,213219,213249,213278,213307,213336,213366,213395,213424,213453,213482,213511,213541,213570,213599,213628,213657,213686,213715,213745,213774,213803,213832,213861,213890,213919,213948,213977,214006,214035,214064,214093,214122,214151,214180,214209,214238,214267,214296,214325,214354,214383,214412,214441,214470,214498,214527,214556,214585,214614,214643,214672,214701,214729,214758,214787,214816,214845,214873,214902,214931,214960,214989,215017,215046,215075,215104,215132,215161,215190,215218,215247,215276,215304,215333,215362,215390,215419,215448,215476,215505,215534,215562,215591,215619,215648,215677,215705,215734,215762,215791,215819,215848,215876,215905,215933,215962,215990,216019,216047,216076,216104,216133,216161,216190,216218,216246,216275,216303,216332,216360,216388,216417,216445,216473,216502,216530,216558,216587,216615,216643,216672,216700,216728,216757,216785,216813,216841,216870,216898,216926,216954,216982,217011,217039,217067,217095,217123,217152,217180,217208,217236,217264,217292,217320,217348,217377,217405,217433,217461,217489,217517,217545,217573,217601,217629,217657,217685,217713,217741,217769,217797,217825,217853,217881,217909,217937,217965,217993,218021,218049,218076,218104,218132,218160,218188,218216,218244,218271,218299,218327,218355,218383,218411,218438,218466,218494,218522,218549,218577,218605,218633,218660,218688,218716,218744,218771,218799,218827,218854,218882,218910,218937,218965,218993,219020,219048,219075,219103,219131,219158,219186,219213,219241,219268,219296,219324,219351,219379,219406,219434,219461,219489,219516,219544,219571,219598,219626,219653,219681,219708,219736,219763,219790,219818,219845,219873,219900,219927,219955,219982,220009,220037,220064,220091,220119,220146,220173,220200,220228,220255,220282,220309,220337,220364,220391,220418,220446,220473,220500,220527,220554,220581,220609,220636,220663,220690,220717,220744,220771,220798,220826,220853,220880,220907,220934,220961,220988,221015,221042,221069,221096,221123,221150,221177,221204,221231,221258,221285,221312,221339,221366,221393,221419,221446,221473,221500,221527,221554,221581,221608,221634,221661,221688,221715,221742,221769,221795,221822,221849,221876,221903,221929,221956,221983,222010,222036,222063,222090,222116,222143,222170,222196,222223,222250,222276,222303,222330,222356,222383,222410,222436,222463,222489,222516,222542,222569,222596,222622,222649,222675,222702,222728,222755,222781,222808,222834,222861,222887,222914,222940,222966,222993,223019,223046,223072,223099,223125,223151,223178,223204,223230,223257,223283,223309,223336,223362,223388,223415,223441,223467,223493,223520,223546,223572,223599,223625,223651,223677,223703,223730,223756,223782,223808,223834,223860,223887,223913,223939,223965,223991,224017,224043,224069,224096,224122,224148,224174,224200,224226,224252,224278,224304,224330,224356,224382,224408,224434,224460,224486,224512,224538,224564,224590,224615,224641,224667,224693,224719,224745,224771,224797,224823,224848,224874,224900,224926,224952,224978,225003,225029,225055,225081,225106,225132,225158,225184,225209,225235,225261,225287,225312,225338,225364,225389,225415,225441,225466,225492,225517,225543,225569,225594,225620,225646,225671,225697,225722,225748,225773,225799,225824,225850,225875,225901,225926,225952,225977,226003,226028,226054,226079,226105,226130,226156,226181,226206,226232,226257,226283,226308,226333,226359,226384,226409,226435,226460,226485,226511,226536,226561,226586,226612,226637,226662,226688,226713,226738,226763,226788,226814,226839,226864,226889,226914,226940,226965,226990,227015,227040,227065,227090,227115,227141,227166,227191,227216,227241,227266,227291,227316,227341,227366,227391,227416,227441,227466,227491,227516,227541,227566,227591,227616,227641,227666,227691,227716,227740,227765,227790,227815,227840,227865,227890,227914,227939,227964,227989,228014,228039,228063,228088,228113,228138,228162,228187,228212,228237,228261,228286,228311,228335,228360,228385,228409,228434,228459,228483,228508,228533,228557,228582,228607,228631,228656,228680,228705,228729,228754,228779,228803,228828,228852,228877,228901,228926,228950,228975,228999,229024,229048,229072,229097,229121,229146,229170,229194,229219,229243,229268,229292,229316,229341,229365,229389,229414,229438,229462,229487,229511,229535,229560,229584,229608,229632,229657,229681,229705,229729,229753,229778,229802,229826,229850,229874,229898,229923,229947,229971,229995,230019,230043,230067,230091,230116,230140,230164,230188,230212,230236,230260,230284,230308,230332,230356,230380,230404,230428,230452,230476,230500,230524,230548,230571,230595,230619,230643,230667,230691,230715,230739,230762,230786,230810,230834,230858,230882,230905,230929,230953,230977,231001,231024,231048,231072,231096,231119,231143,231167,231190,231214,231238,231261,231285,231309,231332,231356,231380,231403,231427,231450,231474,231498,231521,231545,231568,231592,231615,231639,231663,231686,231710,231733,231757,231780,231804,231827,231850,231874,231897,231921,231944,231968,231991,232014,232038,232061,232085,232108,232131,232155,232178,232201,232225,232248,232271,232295,232318,232341,232364,232388,232411,232434,232457,232481,232504,232527,232550,232574,232597,232620,232643,232666,232689,232713,232736,232759,232782,232805,232828,232851,232874,232897,232920,232944,232967,232990,233013,233036,233059,233082,233105,233128,233151,233174,233197,233220,233243,233265,233288,233311,233334,233357,233380,233403,233426,233449,233472,233494,233517,233540,233563,233586,233609,233631,233654,233677,233700,233722,233745,233768,233791,233813,233836,233859,233882,233904,233927,233950,233972,233995,234018,234040,234063,234086,234108,234131,234153,234176,234199,234221,234244,234266,234289,234311,234334,234356,234379,234401,234424,234446,234469,234491,234514,234536,234559,234581,234604,234626,234649,234671,234693,234716,234738,234760,234783,234805,234828,234850,234872,234894,234917,234939,234961,234984,235006,235028,235050,235073,235095,235117,235139,235162,235184,235206,235228,235250,235273,235295,235317,235339,235361,235383,235405,235428,235450,235472,235494,235516,235538,235560,235582,235604,235626,235648,235670,235692,235714,235736,235758,235780,235802,235824,235846,235868,235890,235912,235934,235956,235978,235999,236021,236043,236065,236087,236109,236131,236152,236174,236196,236218,236240,236261,236283,236305,236327,236348,236370,236392,236414,236435,236457,236479,236500,236522,236544,236565,236587,236609,236630,236652,236674,236695,236717,236738,236760,236782,236803,236825,236846,236868,236889,236911,236932,236954,236975,236997,237018,237040,237061,237083,237104,237126,237147,237168,237190,237211,237233,237254,237275,237297,237318,237339,237361,237382,237403,237425,237446,237467,237489,237510,237531,237552,237574,237595,237616,237637,237659,237680,237701,237722,237743,237765,237786,237807,237828,237849,237870,237891,237913,237934,237955,237976,237997,238018,238039,238060,238081,238102,238123,238144,238165,238186,238207,238228,238249,238270,238291,238312,238333,238354,238375,238396,238417,238437,238458,238479,238500,238521,238542,238563,238583,238604,238625,238646,238667,238688,238708,238729,238750,238771,238791,238812,238833,238853,238874,238895,238916,238936,238957,238978,238998,239019,239040,239060,239081,239101,239122,239143,239163,239184,239204,239225,239245,239266,239287,239307,239328,239348,239369,239389,239410,239430,239450,239471,239491,239512,239532,239553,239573,239593,239614,239634,239655,239675,239695,239716,239736,239756,239777,239797,239817,239838,239858,239878,239898,239919,239939,239959,239979,240000,240020,240040,240060,240080,240101,240121,240141,240161,240181,240201,240221,240242,240262,240282,240302,240322,240342,240362,240382,240402,240422,240442,240462,240482,240502,240522,240542,240562,240582,240602,240622,240642,240662,240682,240702,240722,240742,240762,240781,240801,240821,240841,240861,240881,240901,240920,240940,240960,240980,241000,241019,241039,241059,241079,241098,241118,241138,241157,241177,241197,241217,241236,241256,241276,241295,241315,241334,241354,241374,241393,241413,241433,241452,241472,241491,241511,241530,241550,241569,241589,241608,241628,241647,241667,241686,241706,241725,241745,241764,241784,241803,241822,241842,241861,241881,241900,241919,241939,241958,241977,241997,242016,242035,242055,242074,242093,242112,242132,242151,242170,242189,242209,242228,242247,242266,242286,242305,242324,242343,242362,242381,242401,242420,242439,242458,242477,242496,242515,242534,242553,242572,242591,242611,242630,242649,242668,242687,242706,242725,242744,242763,242782,242800,242819,242838,242857,242876,242895,242914,242933,242952,242971,242990,243008,243027,243046,243065,243084,243103,243121,243140,243159,243178,243196,243215,243234,243253,243271,243290,243309,243328,243346,243365,243384,243402,243421,243440,243458,243477,243496,243514,243533,243551,243570,243588,243607,243626,243644,243663,243681,243700,243718,243737,243755,243774,243792,243811,243829,243848,243866,243885,243903,243921,243940,243958,243977,243995,244013,244032,244050,244068,244087,244105,244123,244142,244160,244178,244197,244215,244233,244251,244270,244288,244306,244324,244343,244361,244379,244397,244415,244433,244452,244470,244488,244506,244524,244542,244560,244578,244597,244615,244633,244651,244669,244687,244705,244723,244741,244759,244777,244795,244813,244831,244849,244867,244885,244903,244921,244938,244956,244974,244992,245010,245028,245046,245064,245081,245099,245117,245135,245153,245171,245188,245206,245224,245242,245259,245277,245295,245313,245330,245348,245366,245383,245401,245419,245436,245454,245472,245489,245507,245525,245542,245560,245577,245595,245613,245630,245648,245665,245683,245700,245718,245735,245753,245770,245788,245805,245823,245840,245858,245875,245892,245910,245927,245945,245962,245979,245997,246014,246032,246049,246066,246084,246101,246118,246136,246153,246170,246187,246205,246222,246239,246256,246274,246291,246308,246325,246342,246360,246377,246394,246411,246428,246445,246463,246480,246497,246514,246531,246548,246565,246582,246599,246616,246633,246650,246667,246684,246701,246718,246735,246752,246769,246786,246803,246820,246837,246854,246871,246888,246905,246922,246938,246955,246972,246989,247006,247023,247040,247056,247073,247090,247107,247123,247140,247157,247174,247190,247207,247224,247241,247257,247274,247291,247307,247324,247341,247357,247374,247391,247407,247424,247440,247457,247474,247490,247507,247523,247540,247556,247573,247589,247606,247622,247639,247655,247672,247688,247705,247721,247738,247754,247771,247787,247803,247820,247836,247853,247869,247885,247902,247918,247934,247951,247967,247983,248000,248016,248032,248048,248065,248081,248097,248113,248130,248146,248162,248178,248194,248211,248227,248243,248259,248275,248291,248307,248323,248340,248356,248372,248388,248404,248420,248436,248452,248468,248484,248500,248516,248532,248548,248564,248580,248596,248612,248628,248644,248660,248676,248691,248707,248723,248739,248755,248771,248787,248803,248818,248834,248850,248866,248882,248897,248913,248929,248945,248960,248976,248992,249008,249023,249039,249055,249070,249086,249102,249117,249133,249149,249164,249180,249195,249211,249227,249242,249258,249273,249289,249304,249320,249335,249351,249367,249382,249398,249413,249428,249444,249459,249475,249490,249506,249521,249536,249552,249567,249583,249598,249613,249629,249644,249659,249675,249690,249705,249721,249736,249751,249766,249782,249797,249812,249827,249843,249858,249873,249888,249903,249919,249934,249949,249964,249979,249994,250009,250025,250040,250055,250070,250085,250100,250115,250130,250145,250160,250175,250190,250205,250220,250235,250250,250265,250280,250295,250310,250325,250340,250355,250370,250385,250399,250414,250429,250444,250459,250474,250489,250503,250518,250533,250548,250562,250577,250592,250607,250622,250636,250651,250666,250680,250695,250710,250724,250739,250754,250768,250783,250798,250812,250827,250842,250856,250871,250885,250900,250914,250929,250944,250958,250973,250987,251002,251016,251031,251045,251060,251074,251088,251103,251117,251132,251146,251161,251175,251189,251204,251218,251232,251247,251261,251275,251290,251304,251318,251333,251347,251361,251375,251390,251404,251418,251432,251447,251461,251475,251489,251503,251518,251532,251546,251560,251574,251588,251602,251617,251631,251645,251659,251673,251687,251701,251715,251729,251743,251757,251771,251785,251799,251813,251827,251841,251855,251869,251883,251897,251911,251925,251938,251952,251966,251980,251994,252008,252022,252035,252049,252063,252077,252091,252104,252118,252132,252146,252159,252173,252187,252201,252214,252228,252242,252255,252269,252283,252296,252310,252324,252337,252351,252365,252378,252392,252405,252419,252432,252446,252460,252473,252487,252500,252514,252527,252541,252554,252568,252581,252594,252608,252621,252635,252648,252662,252675,252688,252702,252715,252728,252742,252755,252768,252782,252795,252808,252822,252835,252848,252861,252875,252888,252901,252914,252928,252941,252954,252967,252980,252994,253007,253020,253033,253046,253059,253072,253085,253099,253112,253125,253138,253151,253164,253177,253190,253203,253216,253229,253242,253255,253268,253281,253294,253307,253320,253333,253346,253359,253371,253384,253397,253410,253423,253436,253449,253461,253474,253487,253500,253513,253525,253538,253551,253564,253577,253589,253602,253615,253627,253640,253653,253666,253678,253691,253704,253716,253729,253741,253754,253767,253779,253792,253804,253817,253830,253842,253855,253867,253880,253892,253905,253917,253930,253942,253955,253967,253980,253992,254004,254017,254029,254042,254054,254067,254079,254091,254104,254116,254128,254141,254153,254165,254178,254190,254202,254214,254227,254239,254251,254263,254276,254288,254300,254312,254324,254337,254349,254361,254373,254385,254397,254410,254422,254434,254446,254458,254470,254482,254494,254506,254518,254530,254542,254554,254566,254578,254590,254602,254614,254626,254638,254650,254662,254674,254686,254698,254710,254721,254733,254745,254757,254769,254781,254793,254804,254816,254828,254840,254852,254863,254875,254887,254899,254910,254922,254934,254945,254957,254969,254981,254992,255004,255015,255027,255039,255050,255062,255074,255085,255097,255108,255120,255131,255143,255155,255166,255178,255189,255201,255212,255224,255235,255246,255258,255269,255281,255292,255304,255315,255326,255338,255349,255361,255372,255383,255395,255406,255417,255429,255440,255451,255462,255474,255485,255496,255507,255519,255530,255541,255552,255564,255575,255586,255597,255608,255619,255630,255642,255653,255664,255675,255686,255697,255708,255719,255730,255741,255752,255763,255774,255785,255796,255807,255818,255829,255840,255851,255862,255873,255884,255895,255906,255917,255928,255939,255949,255960,255971,255982,255993,256004,256014,256025,256036,256047,256058,256068,256079,256090,256101,256111,256122,256133,256143,256154,256165,256176,256186,256197,256207,256218,256229,256239,256250,256261,256271,256282,256292,256303,256313,256324,256334,256345,256355,256366,256376,256387,256397,256408,256418,256429,256439,256450,256460,256470,256481,256491,256502,256512,256522,256533,256543,256553,256564,256574,256584,256595,256605,256615,256625,256636,256646,256656,256666,256677,256687,256697,256707,256717,256728,256738,256748,256758,256768,256778,256788,256798,256809,256819,256829,256839,256849,256859,256869,256879,256889,256899,256909,256919,256929,256939,256949,256959,256969,256979,256989,256999,257008,257018,257028,257038,257048,257058,257068,257078,257087,257097,257107,257117,257127,257136,257146,257156,257166,257175,257185,257195,257205,257214,257224,257234,257243,257253,257263,257272,257282,257292,257301,257311,257320,257330,257340,257349,257359,257368,257378,257387,257397,257406,257416,257425,257435,257444,257454,257463,257473,257482,257492,257501,257510,257520,257529,257539,257548,257557,257567,257576,257585,257595,257604,257613,257623,257632,257641,257651,257660,257669,257678,257688,257697,257706,257715,257724,257734,257743,257752,257761,257770,257779,257789,257798,257807,257816,257825,257834,257843,257852,257861,257870,257879,257888,257897,257906,257915,257924,257933,257942,257951,257960,257969,257978,257987,257996,258005,258014,258023,258031,258040,258049,258058,258067,258076,258084,258093,258102,258111,258120,258128,258137,258146,258155,258163,258172,258181,258190,258198,258207,258216,258224,258233,258242,258250,258259,258267,258276,258285,258293,258302,258310,258319,258327,258336,258345,258353,258362,258370,258379,258387,258396,258404,258412,258421,258429,258438,258446,258455,258463,258471,258480,258488,258496,258505,258513,258522,258530,258538,258546,258555,258563,258571,258580,258588,258596,258604,258613,258621,258629,258637,258645,258654,258662,258670,258678,258686,258694,258702,258711,258719,258727,258735,258743,258751,258759,258767,258775,258783,258791,258799,258807,258815,258823,258831,258839,258847,258855,258863,258871,258879,258887,258895,258902,258910,258918,258926,258934,258942,258950,258957,258965,258973,258981,258989,258996,259004,259012,259020,259027,259035,259043,259050,259058,259066,259073,259081,259089,259096,259104,259112,259119,259127,259135,259142,259150,259157,259165,259172,259180,259187,259195,259202,259210,259217,259225,259232,259240,259247,259255,259262,259270,259277,259285,259292,259299,259307,259314,259321,259329,259336,259343,259351,259358,259365,259373,259380,259387,259395,259402,259409,259416,259423,259431,259438,259445,259452,259459,259467,259474,259481,259488,259495,259502,259509,259517,259524,259531,259538,259545,259552,259559,259566,259573,259580,259587,259594,259601,259608,259615,259622,259629,259636,259643,259650,259657,259664,259670,259677,259684,259691,259698,259705,259712,259718,259725,259732,259739,259746,259752,259759,259766,259773,259779,259786,259793,259800,259806,259813,259820,259826,259833,259840,259846,259853,259860,259866,259873,259879,259886,259893,259899,259906,259912,259919,259925,259932,259938,259945,259951,259958,259964,259971,259977,259984,259990,259997,260003,260009,260016,260022,260029,260035,260041,260048,260054,260060,260067,260073,260079,260085,260092,260098,260104,260111,260117,260123,260129,260135,260142,260148,260154,260160,260166,260173,260179,260185,260191,260197,260203,260209,260215,260221,260228,260234,260240,260246,260252,260258,260264,260270,260276,260282,260288,260294,260300,260306,260312,260317,260323,260329,260335,260341,260347,260353,260359,260365,260370,260376,260382,260388,260394,260399,260405,260411,260417,260423,260428,260434,260440,260445,260451,260457,260463,260468,260474,260480,260485,260491,260496,260502,260508,260513,260519,260525,260530,260536,260541,260547,260552,260558,260563,260569,260574,260580,260585,260591,260596,260602,260607,260613,260618,260623,260629,260634,260640,260645,260650,260656,260661,260666,260672,260677,260682,260688,260693,260698,260703,260709,260714,260719,260724,260730,260735,260740,260745,260750,260756,260761,260766,260771,260776,260781,260786,260791,260797,260802,260807,260812,260817,260822,260827,260832,260837,260842,260847,260852,260857,260862,260867,260872,260877,260882,260887,260892,260896,260901,260906,260911,260916,260921,260926,260930,260935,260940,260945,260950,260955,260959,260964,260969,260974,260978,260983,260988,260992,260997,261002,261007,261011,261016,261021,261025,261030,261034,261039,261044,261048,261053,261057,261062,261067,261071,261076,261080,261085,261089,261094,261098,261103,261107,261112,261116,261120,261125,261129,261134,261138,261143,261147,261151,261156,261160,261164,261169,261173,261177,261182,261186,261190,261195,261199,261203,261207,261212,261216,261220,261224,261228,261233,261237,261241,261245,261249,261253,261258,261262,261266,261270,261274,261278,261282,261286,261290,261294,261298,261302,261306,261310,261314,261318,261322,261326,261330,261334,261338,261342,261346,261350,261354,261358,261362,261366,261369,261373,261377,261381,261385,261389,261392,261396,261400,261404,261408,261411,261415,261419,261423,261426,261430,261434,261437,261441,261445,261448,261452,261456,261459,261463,261467,261470,261474,261477,261481,261485,261488,261492,261495,261499,261502,261506,261509,261513,261516,261520,261523,261527,261530,261533,261537,261540,261544,261547,261551,261554,261557,261561,261564,261567,261571,261574,261577,261581,261584,261587,261590,261594,261597,261600,261603,261607,261610,261613,261616,261619,261623,261626,261629,261632,261635,261638,261641,261644,261648,261651,261654,261657,261660,261663,261666,261669,261672,261675,261678,261681,261684,261687,261690,261693,261696,261699,261702,261705,261708,261710,261713,261716,261719,261722,261725,261728,261730,261733,261736,261739,261742,261744,261747,261750,261753,261755,261758,261761,261764,261766,261769,261772,261774,261777,261780,261782,261785,261788,261790,261793,261795,261798,261801,261803,261806,261808,261811,261813,261816,261818,261821,261823,261826,261828,261831,261833,261836,261838,261840,261843,261845,261848,261850,261852,261855,261857,261859,261862,261864,261866,261869,261871,261873,261876,261878,261880,261882,261885,261887,261889,261891,261894,261896,261898,261900,261902,261904,261907,261909,261911,261913,261915,261917,261919,261921,261923,261925,261927,261929,261932,261934,261936,261938,261940,261942,261943,261945,261947,261949,261951,261953,261955,261957,261959,261961,261963,261965,261966,261968,261970,261972,261974,261975,261977,261979,261981,261983,261984,261986,261988,261990,261991,261993,261995,261996,261998,262000,262001,262003,262005,262006,262008,262010,262011,262013,262014,262016,262018,262019,262021,262022,262024,262025,262027,262028,262030,262031,262033,262034,262036,262037,262038,262040,262041,262043,262044,262045,262047,262048,262050,262051,262052,262054,262055,262056,262057,262059,262060,262061,262063,262064,262065,262066,262067,262069,262070,262071,262072,262073,262075,262076,262077,262078,262079,262080,262081,262082,262084,262085,262086,262087,262088,262089,262090,262091,262092,262093,262094,262095,262096,262097,262098,262099,262100,262101,262101,262102,262103,262104,262105,262106,262107,262108,262108,262109,262110,262111,262112,262112,262113,262114,262115,262115,262116,262117,262118,262118,262119,262120,262120,262121,262122,262122,262123,262124,262124,262125,262125,262126,262127,262127,262128,262128,262129,262129,262130,262130,262131,262131,262132,262132,262133,262133,262134,262134,262135,262135,262135,262136,262136,262137,262137,262137,262138,262138,262138,262139,262139,262139,262140,262140,262140,262140,262141,262141,262141,262141,262142,262142,262142,262142,262142,262143,262143,262143,262143,262143,262143,262143,262144,262144,262144,262144,262144,262144,262144,262144,262144,262144,262144,0};
diff --git a/apps/plugins/pdbox/PDa/intern/cos~.c b/apps/plugins/pdbox/PDa/intern/cos~.c
index 30ec4e49a7..38625d7419 100644
--- a/apps/plugins/pdbox/PDa/intern/cos~.c
+++ b/apps/plugins/pdbox/PDa/intern/cos~.c
@@ -60,63 +60,3 @@ void cos_tilde_setup(void)
class_sethelpsymbol(cos_class, gensym("osc~-help.pd"));
}
-#include <m_pd.h>
-#include <m_fixed.h>
-#include "cos_table.h"
-
-/* ------------------------ cos~ ----------------------------- */
-#define FRAC ((1<<(fix1-ILOGCOSTABSIZE))-1)
-
-static t_class *cos_class;
-
-typedef struct _cos
-{
- t_object x_obj;
- float x_f;
-} t_cos;
-
-static void *cos_new(void)
-{
- t_cos *x = (t_cos *)pd_new(cos_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *cos_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- t_sample *tab = cos_table;
- int off;
- int frac;
- unsigned int phase;
-
- while (n--) {
- phase = *in++;
- phase &= ((1<<fix1)-1);
- off = fixtoi((long long)phase<<ILOGCOSTABSIZE);
-
- frac = phase&(itofix(1)-1);
- *out = mult(*(tab + off),itofix(1) - frac) +
- mult(*(tab + off + 1),frac);
- out++;
- }
- return (w+4);
-}
-
-static void cos_dsp(t_cos *x, t_signal **sp)
-{
- dsp_add(cos_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-
-void cos_tilde_setup(void)
-{
- cos_class = class_new(gensym("cos~"), (t_newmethod)cos_new, 0,
- sizeof(t_cos), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(cos_class, t_cos, x_f);
- class_addmethod(cos_class, (t_method)cos_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(cos_class, gensym("osc~-help.pd"));
-}
diff --git a/apps/plugins/pdbox/PDa/intern/dbtopow~.c b/apps/plugins/pdbox/PDa/intern/dbtopow~.c
index 92ba76d550..ad4a826f9e 100644
--- a/apps/plugins/pdbox/PDa/intern/dbtopow~.c
+++ b/apps/plugins/pdbox/PDa/intern/dbtopow~.c
@@ -50,55 +50,4 @@ void dbtopow_tilde_setup(void)
CLASS_MAINSIGNALIN(dbtopow_tilde_class, t_dbtopow_tilde, x_f);
class_addmethod(dbtopow_tilde_class, (t_method)dbtopow_tilde_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-#define LOGTEN 2.302585092994
-
-typedef struct dbtopow_tilde
-{
- t_object x_obj;
- float x_f;
-} t_dbtopow_tilde;
-
-t_class *dbtopow_tilde_class;
-
-static void *dbtopow_tilde_new(void)
-{
- t_dbtopow_tilde *x = (t_dbtopow_tilde *)pd_new(dbtopow_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-static t_int *dbtopow_tilde_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- float f = *in;
- if (f <= 0) *out = 0;
- else
- {
- if (f > 870)
- f = 870;
- *out = exp((LOGTEN * 0.1) * (f-100.));
- }
- }
- return (w + 4);
-}
-
-static void dbtopow_tilde_dsp(t_dbtopow_tilde *x, t_signal **sp)
-{
- post("warning: %s not usable yet",__FUNCTION__);
- dsp_add(dbtopow_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void dbtopow_tilde_setup(void)
-{
- dbtopow_tilde_class = class_new(gensym("dbtopow~"), (t_newmethod)dbtopow_tilde_new, 0,
- sizeof(t_dbtopow_tilde), 0, 0);
- CLASS_MAINSIGNALIN(dbtopow_tilde_class, t_dbtopow_tilde, x_f);
- class_addmethod(dbtopow_tilde_class, (t_method)dbtopow_tilde_dsp, gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/dbtorms~.c b/apps/plugins/pdbox/PDa/intern/dbtorms~.c
index 9d45a076eb..703d0883b9 100644
--- a/apps/plugins/pdbox/PDa/intern/dbtorms~.c
+++ b/apps/plugins/pdbox/PDa/intern/dbtorms~.c
@@ -51,56 +51,4 @@ void dbtorms_tilde_setup(void)
CLASS_MAINSIGNALIN(dbtorms_tilde_class, t_dbtorms_tilde, x_f);
class_addmethod(dbtorms_tilde_class, (t_method)dbtorms_tilde_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-
-#define LOGTEN 2.302585092994
-
-typedef struct dbtorms_tilde
-{
- t_object x_obj;
- float x_f;
-} t_dbtorms_tilde;
-
-t_class *dbtorms_tilde_class;
-
-static void *dbtorms_tilde_new(void)
-{
- t_dbtorms_tilde *x = (t_dbtorms_tilde *)pd_new(dbtorms_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *dbtorms_tilde_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- float f = *in;
- if (f <= 0) *out = 0;
- else
- {
- if (f > 485)
- f = 485;
- *out = exp((LOGTEN * 0.05) * (f-100.));
- }
- }
- return (w + 4);
-}
-static void dbtorms_tilde_dsp(t_dbtorms_tilde *x, t_signal **sp)
-{
- post("warning: %s not usable yet",__FUNCTION__);
- dsp_add(dbtorms_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void dbtorms_tilde_setup(void)
-{
- dbtorms_tilde_class = class_new(gensym("dbtorms~"), (t_newmethod)dbtorms_tilde_new, 0,
- sizeof(t_dbtorms_tilde), 0, 0);
- CLASS_MAINSIGNALIN(dbtorms_tilde_class, t_dbtorms_tilde, x_f);
- class_addmethod(dbtorms_tilde_class, (t_method)dbtorms_tilde_dsp, gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/delay.h b/apps/plugins/pdbox/PDa/intern/delay.h
index 1aacd5682f..3b86dee53d 100644
--- a/apps/plugins/pdbox/PDa/intern/delay.h
+++ b/apps/plugins/pdbox/PDa/intern/delay.h
@@ -41,44 +41,3 @@ static void sigdelwrite_checkvecsize(t_sigdelwrite *x, int vecsize)
#endif
-#ifndef __DELAY_H__
-#define __DELAY_H__
-
-
-extern t_class *sigdelwrite_class;
-
-
-typedef struct delwritectl
-{
- int c_n;
- t_sample *c_vec;
- int c_phase;
-} t_delwritectl;
-
-typedef struct _sigdelwrite
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_delwritectl x_cspace;
- int x_sortno; /* DSP sort number at which this was last put on chain */
- int x_rsortno; /* DSP sort # for first delread or write in chain */
- int x_vecsize; /* vector size for delread~ to use */
- float x_f;
-} t_sigdelwrite;
-
-#define XTRASAMPS 4
-#define SAMPBLK 4
-
- /* routine to check that all delwrites/delreads/vds have same vecsize */
-static void sigdelwrite_checkvecsize(t_sigdelwrite *x, int vecsize)
-{
- if (x->x_rsortno != ugen_getsortno())
- {
- x->x_vecsize = vecsize;
- x->x_rsortno = ugen_getsortno();
- }
- else if (vecsize != x->x_vecsize)
- pd_error(x, "delread/delwrite/vd vector size mismatch");
-}
-
-#endif
diff --git a/apps/plugins/pdbox/PDa/intern/delread~.c b/apps/plugins/pdbox/PDa/intern/delread~.c
index b0a58393be..ed7d2f2d80 100644
--- a/apps/plugins/pdbox/PDa/intern/delread~.c
+++ b/apps/plugins/pdbox/PDa/intern/delread~.c
@@ -98,103 +98,4 @@ void delread_tilde_setup(void)
gensym("dsp"), 0);
class_addfloat(sigdelread_class, (t_method)sigdelread_float);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-#include "delay.h"
-
-extern int ugen_getsortno(void);
-
-#define DEFDELVS 64 /* LATER get this from canvas at DSP time */
-static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */
-
-static t_class *sigdelread_class;
-
-typedef struct _sigdelread
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_float x_deltime; /* delay in msec */
- int x_delsamps; /* delay in samples */
- t_float x_sr; /* samples per msec */
- t_float x_n; /* vector size */
- int x_zerodel; /* 0 or vecsize depending on read/write order */
-} t_sigdelread;
-
-static void sigdelread_float(t_sigdelread *x, t_float f);
-
-static void *sigdelread_new(t_symbol *s, t_floatarg f)
-{
- t_sigdelread *x = (t_sigdelread *)pd_new(sigdelread_class);
- x->x_sym = s;
- x->x_sr = 1;
- x->x_n = 1;
- x->x_zerodel = 0;
- sigdelread_float(x, f);
- outlet_new(&x->x_obj, &s_signal);
- return (x);
-}
-static void sigdelread_float(t_sigdelread *x, t_float f)
-{
- int samps;
- t_sigdelwrite *delwriter =
- (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
- x->x_deltime = f;
- if (delwriter)
- {
- int delsize = delwriter->x_cspace.c_n;
- x->x_delsamps = (int)(0.5 + x->x_sr * x->x_deltime)
- + x->x_n - x->x_zerodel;
- if (x->x_delsamps < x->x_n) x->x_delsamps = x->x_n;
- else if (x->x_delsamps > delwriter->x_cspace.c_n - DEFDELVS)
- x->x_delsamps = delwriter->x_cspace.c_n - DEFDELVS;
- }
-}
-
-static t_int *sigdelread_perform(t_int *w)
-{
- t_sample *out = (t_sample *)(w[1]);
- t_delwritectl *c = (t_delwritectl *)(w[2]);
- int delsamps = *(int *)(w[3]);
- int n = (int)(w[4]);
- int phase = c->c_phase - delsamps, nsamps = c->c_n;
- t_sample *vp = c->c_vec, *bp, *ep = vp + (c->c_n + XTRASAMPS);
-
- if (phase < 0) phase += nsamps;
- bp = vp + phase;
- while (n--)
- {
- *out++ = *bp++;
- if (bp == ep) bp -= nsamps;
- }
- return (w+5);
-}
-
-static void sigdelread_dsp(t_sigdelread *x, t_signal **sp)
-{
- t_sigdelwrite *delwriter =
- (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
- x->x_sr = sp[0]->s_sr * 0.001;
- x->x_n = sp[0]->s_n;
- if (delwriter)
- {
- sigdelwrite_checkvecsize(delwriter, sp[0]->s_n);
- x->x_zerodel = (delwriter->x_sortno == ugen_getsortno() ?
- 0 : delwriter->x_vecsize);
- sigdelread_float(x, x->x_deltime);
- dsp_add(sigdelread_perform, 4,
- sp[0]->s_vec, &delwriter->x_cspace, &x->x_delsamps, sp[0]->s_n);
- }
- else if (*x->x_sym->s_name)
- error("delread~: %s: no such delwrite~",x->x_sym->s_name);
-}
-
-void delread_tilde_setup(void)
-{
- sigdelread_class = class_new(gensym("delread~"),
- (t_newmethod)sigdelread_new, 0,
- sizeof(t_sigdelread), 0, A_DEFSYM, A_DEFFLOAT, 0);
- class_addmethod(sigdelread_class, (t_method)sigdelread_dsp,
- gensym("dsp"), 0);
- class_addfloat(sigdelread_class, (t_method)sigdelread_float);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/delwrite~.c b/apps/plugins/pdbox/PDa/intern/delwrite~.c
index 290793d9e4..825ff2396a 100644
--- a/apps/plugins/pdbox/PDa/intern/delwrite~.c
+++ b/apps/plugins/pdbox/PDa/intern/delwrite~.c
@@ -82,87 +82,4 @@ void delwrite_tilde_setup(void)
class_addmethod(sigdelwrite_class, (t_method)sigdelwrite_dsp,
gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-extern int ugen_getsortno(void);
-
-#define DEFDELVS 64 /* LATER get this from canvas at DSP time */
-static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */
-
-#include "delay.h"
-
-t_class *sigdelwrite_class;
-
-static void *sigdelwrite_new(t_symbol *s, t_floatarg msec)
-{
- int nsamps;
- t_sigdelwrite *x = (t_sigdelwrite *)pd_new(sigdelwrite_class);
- if (!*s->s_name) s = gensym("delwrite~");
- pd_bind(&x->x_obj.ob_pd, s);
- x->x_sym = s;
- nsamps = msec * sys_getsr() * (float)(0.001f);
- if (nsamps < 1) nsamps = 1;
- nsamps += ((- nsamps) & (SAMPBLK - 1));
- nsamps += DEFDELVS;
- x->x_cspace.c_n = nsamps;
- x->x_cspace.c_vec =
- (t_sample *)getbytes((nsamps + XTRASAMPS) * sizeof(float));
- x->x_cspace.c_phase = XTRASAMPS;
- x->x_sortno = 0;
- x->x_vecsize = 0;
- x->x_f = 0;
- return (x);
-}
-static t_int *sigdelwrite_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_delwritectl *c = (t_delwritectl *)(w[2]);
- int n = (int)(w[3]);
- int phase = c->c_phase, nsamps = c->c_n;
- t_sample *vp = c->c_vec, *bp = vp + phase, *ep = vp + (c->c_n + XTRASAMPS);
- phase += n;
- while (n--)
- {
- t_sample f = *in++;
- if (PD_BADFLOAT(f))
- f = 0;
- *bp++ = f;
- if (bp == ep)
- {
- vp[0] = ep[-4];
- vp[1] = ep[-3];
- vp[2] = ep[-2];
- vp[3] = ep[-1];
- bp = vp + XTRASAMPS;
- phase -= nsamps;
- }
- }
- c->c_phase = phase;
- return (w+4);
-}
-
-static void sigdelwrite_dsp(t_sigdelwrite *x, t_signal **sp)
-{
- dsp_add(sigdelwrite_perform, 3, sp[0]->s_vec, &x->x_cspace, sp[0]->s_n);
- x->x_sortno = ugen_getsortno();
- sigdelwrite_checkvecsize(x, sp[0]->s_n);
-}
-
-static void sigdelwrite_free(t_sigdelwrite *x)
-{
- pd_unbind(&x->x_obj.ob_pd, x->x_sym);
- freebytes(x->x_cspace.c_vec,
- (x->x_cspace.c_n + XTRASAMPS) * sizeof(float));
-}
-
-void delwrite_tilde_setup(void)
-{
- sigdelwrite_class = class_new(gensym("delwrite~"),
- (t_newmethod)sigdelwrite_new, (t_method)sigdelwrite_free,
- sizeof(t_sigdelwrite), 0, A_DEFSYM, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(sigdelwrite_class, t_sigdelwrite, x_f);
- class_addmethod(sigdelwrite_class, (t_method)sigdelwrite_dsp,
- gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/env~.c b/apps/plugins/pdbox/PDa/intern/env~.c
index a9bf6998e1..8f42658461 100644
--- a/apps/plugins/pdbox/PDa/intern/env~.c
+++ b/apps/plugins/pdbox/PDa/intern/env~.c
@@ -124,131 +124,3 @@ void env_tilde_setup(void )
class_addmethod(sigenv_class, (t_method)sigenv_dsp, gensym("dsp"), 0);
}
-
-
-#define FIXEDPOINT
-#include <m_pd.h>
-#include <m_fixed.h>
-
-
-#define MAXOVERLAP 10
-#define MAXVSTAKEN 64
-
-typedef struct sigenv
-{
- t_object x_obj; /* header */
- void *x_outlet; /* a "float" outlet */
- void *x_clock; /* a "clock" object */
- t_sample *x_buf; /* a Hanning window */
- int x_phase; /* number of points since last output */
- int x_period; /* requested period of output */
- int x_realperiod; /* period rounded up to vecsize multiple */
- int x_npoints; /* analysis window size in samples */
- t_float x_result; /* result to output */
- t_sample x_sumbuf[MAXOVERLAP]; /* summing buffer */
- t_float x_f;
-} t_sigenv;
-
-t_class *sigenv_class;
-static void sigenv_tick(t_sigenv *x);
-
-static void *sigenv_new(t_floatarg fnpoints, t_floatarg fperiod)
-{
- int npoints = fnpoints;
- int period = fperiod;
- t_sigenv *x;
- t_sample *buf;
- int i;
-
- if (npoints < 1) npoints = 1024;
- if (period < 1) period = npoints/2;
- if (period < npoints / MAXOVERLAP + 1)
- period = npoints / MAXOVERLAP + 1;
- if (!(buf = getbytes(sizeof(t_sample) * (npoints + MAXVSTAKEN))))
- {
- error("env: couldn't allocate buffer");
- return (0);
- }
- x = (t_sigenv *)pd_new(sigenv_class);
- x->x_buf = buf;
- x->x_npoints = npoints;
- x->x_phase = 0;
- x->x_period = period;
- for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0;
- for (i = 0; i < npoints; i++)
- buf[i] = ftofix((1. - cos((2 * 3.14159 * i) / npoints))/npoints);
- for (; i < npoints+MAXVSTAKEN; i++) buf[i] = 0;
- x->x_clock = clock_new(x, (t_method)sigenv_tick);
- x->x_outlet = outlet_new(&x->x_obj, gensym("float"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigenv_perform(t_int *w)
-{
- t_sigenv *x = (t_sigenv *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- int count;
- t_sample *sump;
- in += n;
- for (count = x->x_phase, sump = x->x_sumbuf;
- count < x->x_npoints; count += x->x_realperiod, sump++)
- {
- t_sample *hp = x->x_buf + count;
- t_sample *fp = in;
- t_sample sum = *sump;
- int i;
-
- for (i = 0; i < n; i++)
- {
- fp--;
- sum += *hp++ * ((*fp * *fp)>>16)>>16;
- }
- *sump = sum;
- }
- sump[0] = 0;
- x->x_phase -= n;
- if (x->x_phase < 0)
- {
- x->x_result = x->x_sumbuf[0];
- for (count = x->x_realperiod, sump = x->x_sumbuf;
- count < x->x_npoints; count += x->x_realperiod, sump++)
- sump[0] = sump[1];
- sump[0] = 0;
- x->x_phase = x->x_realperiod - n;
- clock_delay(x->x_clock, 0L);
- }
- return (w+4);
-}
-
-static void sigenv_dsp(t_sigenv *x, t_signal **sp)
-{
- if (x->x_period % sp[0]->s_n) x->x_realperiod =
- x->x_period + sp[0]->s_n - (x->x_period % sp[0]->s_n);
- else x->x_realperiod = x->x_period;
- dsp_add(sigenv_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
- if (sp[0]->s_n > MAXVSTAKEN) bug("sigenv_dsp");
-}
-
-static void sigenv_tick(t_sigenv *x) /* callback function for the clock */
-{
- outlet_float(x->x_outlet, powtodb(x->x_result*3.051757e-05));
-}
-
-static void sigenv_ff(t_sigenv *x) /* cleanup on free */
-{
- clock_free(x->x_clock);
- freebytes(x->x_buf, (x->x_npoints + MAXVSTAKEN) * sizeof(float));
-}
-
-
-void env_tilde_setup(void )
-{
- sigenv_class = class_new(gensym("env~"), (t_newmethod)sigenv_new,
- (t_method)sigenv_ff, sizeof(t_sigenv), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(sigenv_class, t_sigenv, x_f);
- class_addmethod(sigenv_class, (t_method)sigenv_dsp, gensym("dsp"), 0);
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/intern/ftom~.c b/apps/plugins/pdbox/PDa/intern/ftom~.c
index 253fd7bf73..fb40ff6e7c 100644
--- a/apps/plugins/pdbox/PDa/intern/ftom~.c
+++ b/apps/plugins/pdbox/PDa/intern/ftom~.c
@@ -42,47 +42,4 @@ void ftom_tilde_setup(void)
CLASS_MAINSIGNALIN(ftom_tilde_class, t_ftom_tilde, x_f);
class_addmethod(ftom_tilde_class, (t_method)ftom_tilde_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-typedef struct ftom_tilde
-{
- t_object x_obj;
- float x_f;
-} t_ftom_tilde;
-
-t_class *ftom_tilde_class;
-
-static void *ftom_tilde_new(void)
-{
- t_ftom_tilde *x = (t_ftom_tilde *)pd_new(ftom_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-static t_int *ftom_tilde_perform(t_int *w)
-{
- t_sample *in = *(t_sample **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; *in++, out++)
- {
- t_sample f = *in;
- *out = ftofix((fixtof(f) > 0 ? 17.3123405046 * log(.12231220585 * fixtof(f)) : -1500));
- }
- return (w + 4);
-}
-
-static void ftom_tilde_dsp(t_ftom_tilde *x, t_signal **sp)
-{
- post("warning: %s not usable yet",__FUNCTION__);
- dsp_add(ftom_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void ftom_tilde_setup(void)
-{
- ftom_tilde_class = class_new(gensym("ftom~"), (t_newmethod)ftom_tilde_new, 0,
- sizeof(t_ftom_tilde), 0, 0);
- CLASS_MAINSIGNALIN(ftom_tilde_class, t_ftom_tilde, x_f);
- class_addmethod(ftom_tilde_class, (t_method)ftom_tilde_dsp, gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/hip~.c b/apps/plugins/pdbox/PDa/intern/hip~.c
index a2a8c40cf2..6c6de41809 100644
--- a/apps/plugins/pdbox/PDa/intern/hip~.c
+++ b/apps/plugins/pdbox/PDa/intern/hip~.c
@@ -90,95 +90,4 @@ void hip_tilde_setup(void)
class_addmethod(sighip_class, (t_method)sighip_clear, gensym("clear"), 0);
class_sethelpsymbol(sighip_class, gensym("lop~-help.pd"));
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-typedef struct hipctl
-{
- t_sample c_x;
- t_sample c_coef;
-} t_hipctl;
-
-typedef struct sighip
-{
- t_object x_obj;
- float x_sr;
- float x_hz;
- t_hipctl x_cspace;
- t_hipctl *x_ctl;
- float x_f;
-} t_sighip;
-
-t_class *sighip_class;
-static void sighip_ft1(t_sighip *x, t_floatarg f);
-
-static void *sighip_new(t_floatarg f)
-{
- t_sighip *x = (t_sighip *)pd_new(sighip_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_sr = 44100;
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_x = 0;
- sighip_ft1(x, f);
- x->x_f = 0;
- return (x);
-}
-static void sighip_ft1(t_sighip *x, t_floatarg f)
-{
- t_float coeff;
- if (f < 0.001) f = 10;
- x->x_hz = f;
- coeff = 1 - f * (2 * 3.14159) / x->x_sr;
- if (coeff < 0) coeff = 0;
- x->x_ctl->c_coef = ftofix(coeff);
-}
-
-static t_int *sighip_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- t_hipctl *c = (t_hipctl *)(w[3]);
- int n = (t_int)(w[4]);
- int i;
- t_sample last = c->c_x;
- t_sample coef = c->c_coef;
- for (i = 0; i < n; i++)
- {
- t_sample new = *in++ + mult(coef,last);
- *out++ = new - last;
- last = new;
- }
- if (PD_BADFLOAT(last))
- last = 0;
- c->c_x = last;
- return (w+5);
-}
-
-static void sighip_dsp(t_sighip *x, t_signal **sp)
-{
- x->x_sr = sp[0]->s_sr;
- sighip_ft1(x, x->x_hz);
- dsp_add(sighip_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-static void sighip_clear(t_sighip *x, t_floatarg q)
-{
- x->x_cspace.c_x = 0;
-}
-
-void hip_tilde_setup(void)
-{
- sighip_class = class_new(gensym("hip~"), (t_newmethod)sighip_new, 0,
- sizeof(t_sighip), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(sighip_class, t_sighip, x_f);
- class_addmethod(sighip_class, (t_method)sighip_dsp, gensym("dsp"), 0);
- class_addmethod(sighip_class, (t_method)sighip_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addmethod(sighip_class, (t_method)sighip_clear, gensym("clear"), 0);
- class_sethelpsymbol(sighip_class, gensym("lop~-help.pd"));
-}
diff --git a/apps/plugins/pdbox/PDa/intern/intern_setup.c b/apps/plugins/pdbox/PDa/intern/intern_setup.c
index aec879973b..017f72a349 100644
--- a/apps/plugins/pdbox/PDa/intern/intern_setup.c
+++ b/apps/plugins/pdbox/PDa/intern/intern_setup.c
@@ -45,50 +45,4 @@ void d_intern_setup() {
vsnapshot_tilde_setup();
wrap_tilde_setup();
}
-#include <stdio.h>
-void d_intern_setup() {
- fprintf(stderr,"setup\n");
- biquad_tilde_setup();
- bp_tilde_setup();
- clip_tilde_setup();
- cos_tilde_setup();
- dbtopow_tilde_setup();
- dbtorms_tilde_setup();
- delread_tilde_setup();
- delwrite_tilde_setup();
- env_tilde_setup();
- ftom_tilde_setup();
- hip_tilde_setup();
- line_tilde_setup();
- lop_tilde_setup();
- mtof_tilde_setup();
- noise_tilde_setup();
- osc_tilde_setup();
- phasor_tilde_setup();
- powtodb_tilde_setup();
- print_tilde_setup();
- rmstodb_tilde_setup();
- rsqrt_tilde_setup();
- samphold_tilde_setup();
- sfread_tilde_setup();
- sfwrite_tilde_setup();
- sig_tilde_setup();
- snapshot_tilde_setup();
- sqrt_tilde_setup();
- tabosc4_tilde_setup();
- tabplay_tilde_setup();
- tabread4_tilde_setup();
- tabread_tilde_setup();
- tabread_setup();
- tabreceive_tilde_setup();
- tabsend_tilde_setup();
- tabwrite_tilde_setup();
- tabwrite_setup();
- threshold_tilde_setup();
- vcf_tilde_setup();
- vd_tilde_setup();
- vline_tilde_setup();
- vsnapshot_tilde_setup();
- wrap_tilde_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/intern/line~.c b/apps/plugins/pdbox/PDa/intern/line~.c
index ac7af8721e..f37f23c19d 100644
--- a/apps/plugins/pdbox/PDa/intern/line~.c
+++ b/apps/plugins/pdbox/PDa/intern/line~.c
@@ -98,105 +98,3 @@ void line_tilde_setup(void)
class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0);
}
-
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *line_class;
-
-typedef struct _line
-{
- t_object x_obj;
- t_sample x_target;
- t_sample x_value;
- t_sample x_biginc;
- t_sample x_inc;
- t_sample x_1overn;
- t_sample x_msectodsptick;
- t_floatarg x_inletvalue;
- t_floatarg x_inletwas;
- int x_ticksleft;
- int x_retarget;
-} t_line;
-
-static t_int *line_perform(t_int *w)
-{
- t_line *x = (t_line *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- t_sample f = x->x_value;
-
- if (x->x_retarget)
- {
- int nticks = mult(ftofix(x->x_inletwas),x->x_msectodsptick);
- if (!nticks) nticks = itofix(1);
- x->x_ticksleft = fixtoi(nticks);
- x->x_biginc = (x->x_target - x->x_value);
- x->x_biginc = idiv(x->x_biginc,nticks);
- x->x_inc = mult(x->x_1overn, x->x_biginc);
- x->x_retarget = 0;
- }
- if (x->x_ticksleft)
- {
- t_sample f = x->x_value;
- while (n--) *out++ = f, f += x->x_inc;
- x->x_value += x->x_biginc;
- x->x_ticksleft--;
- }
- else
- {
- x->x_value = x->x_target;
- while (n--) *out++ = x->x_value;
- }
- return (w+4);
-}
-
-static void line_float(t_line *x, t_float f)
-{
- if (x->x_inletvalue <= 0)
- {
- x->x_target = x->x_value = ftofix(f);
- x->x_ticksleft = x->x_retarget = 0;
- }
- else
- {
- x->x_target = ftofix(f);
- x->x_retarget = 1;
- x->x_inletwas = x->x_inletvalue;
- x->x_inletvalue = 0;
- }
-}
-
-static void line_stop(t_line *x)
-{
- x->x_target = x->x_value;
- x->x_ticksleft = x->x_retarget = 0;
-}
-
-static void line_dsp(t_line *x, t_signal **sp)
-{
- dsp_add(line_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
- x->x_1overn = ftofix(1)/sp[0]->s_n;
- x->x_msectodsptick = idiv(sp[0]->s_sr, (1000 * sp[0]->s_n));
-}
-
-static void *line_new(void)
-{
- t_line *x = (t_line *)pd_new(line_class);
- outlet_new(&x->x_obj, gensym("signal"));
- floatinlet_new(&x->x_obj, &x->x_inletvalue);
- x->x_ticksleft = x->x_retarget = 0;
- x->x_value = x->x_target = x->x_inletvalue = x->x_inletwas = 0;
- return (x);
-}
-
-void line_tilde_setup(void)
-{
- line_class = class_new(gensym("line~"), line_new, 0,
- sizeof(t_line), 0, 0);
- class_addfloat(line_class, (t_method)line_float);
- class_addmethod(line_class, (t_method)line_dsp, gensym("dsp"), 0);
- class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0);
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/intern/lop~.c b/apps/plugins/pdbox/PDa/intern/lop~.c
index 49a17a7c5f..9d36091711 100644
--- a/apps/plugins/pdbox/PDa/intern/lop~.c
+++ b/apps/plugins/pdbox/PDa/intern/lop~.c
@@ -88,93 +88,4 @@ void lop_tilde_setup(void)
gensym("ft1"), A_FLOAT, 0);
class_addmethod(siglop_class, (t_method)siglop_clear, gensym("clear"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-typedef struct lopctl
-{
- t_sample c_x;
- t_sample c_coef;
-} t_lopctl;
-
-typedef struct siglop
-{
- t_object x_obj;
- float x_sr;
- float x_hz;
- t_lopctl x_cspace;
- t_lopctl *x_ctl;
- float x_f;
-} t_siglop;
-
-t_class *siglop_class;
-
-static void siglop_ft1(t_siglop *x, t_floatarg f);
-
-static void *siglop_new(t_floatarg f)
-{
- t_siglop *x = (t_siglop *)pd_new(siglop_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_sr = 44100;
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_x = 0;
- siglop_ft1(x, f);
- x->x_f = 0;
- return (x);
-}
-
-static void siglop_ft1(t_siglop *x, t_floatarg f)
-{
- t_float coeff;
- if (f < 0.001) f = 10;
- x->x_hz = f;
- coeff = f * (2 * 3.14159) / x->x_sr;
- if (coeff > 1) coeff = 1;
- x->x_ctl->c_coef = ftofix(coeff);
-}
-static void siglop_clear(t_siglop *x, t_floatarg q)
-{
- x->x_cspace.c_x = 0;
-}
-
-
-static t_int *siglop_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- t_lopctl *c = (t_lopctl *)(w[3]);
- int n = (t_int)(w[4]);
- int i;
- t_sample last = c->c_x;
- t_sample coef = c->c_coef;
- t_sample feedback = ftofix(1) - coef;
- for (i = 0; i < n; i++)
- last = *out++ = mult(coef, *in++) + mult(feedback,last);
- if (PD_BADFLOAT(last))
- last = 0;
- c->c_x = last;
- return (w+5);
-}
-
-static void siglop_dsp(t_siglop *x, t_signal **sp)
-{
- x->x_sr = sp[0]->s_sr;
- siglop_ft1(x, x->x_hz);
- dsp_add(siglop_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-void lop_tilde_setup(void)
-{
- siglop_class = class_new(gensym("lop~"), (t_newmethod)siglop_new, 0,
- sizeof(t_siglop), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(siglop_class, t_siglop, x_f);
- class_addmethod(siglop_class, (t_method)siglop_dsp, gensym("dsp"), 0);
- class_addmethod(siglop_class, (t_method)siglop_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addmethod(siglop_class, (t_method)siglop_clear, gensym("clear"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/makefile b/apps/plugins/pdbox/PDa/intern/makefile
index 99c508ab78..8873faae74 100644
--- a/apps/plugins/pdbox/PDa/intern/makefile
+++ b/apps/plugins/pdbox/PDa/intern/makefile
@@ -23,26 +23,3 @@ install:
%.$(EXT) : %.o
$(CC) -o $@ $(EFLAGS) $+
-
-SOURCE = $(shell ls *.c)
-TARGETS = $(SOURCE:.c=.pd_linux)
-
-EXT= pd_linux
-
-CFLAGS += -O2 -I../src -DFIXEDPOINT
-EFLAGS = -shared -Wl,-export-dynamic
-
-
-
-all: $(TARGETS)
-
-clean:
- -rm $(TARGETS)
- -rm *.o *~
-
-install:
- install -d $(DESTDIR)/$(PREFIX)/lib/pd/extra
- cp $(TARGETS) $(DESTDIR)/$(PREFIX)/lib/pd/extra
-
-%.$(EXT) : %.o
- $(CC) -o $@ $(EFLAGS) $+
diff --git a/apps/plugins/pdbox/PDa/intern/mtof~.c b/apps/plugins/pdbox/PDa/intern/mtof~.c
index 1db7dc52a7..cf0fd66da6 100644
--- a/apps/plugins/pdbox/PDa/intern/mtof~.c
+++ b/apps/plugins/pdbox/PDa/intern/mtof~.c
@@ -47,52 +47,4 @@ void mtof_tilde_setup(void)
CLASS_MAINSIGNALIN(mtof_tilde_class, t_mtof_tilde, x_f);
class_addmethod(mtof_tilde_class, (t_method)mtof_tilde_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-typedef struct mtof_tilde
-{
- t_object x_obj;
- float x_f;
-} t_mtof_tilde;
-
-t_class *mtof_tilde_class;
-
-static void *mtof_tilde_new(void)
-{
- t_mtof_tilde *x = (t_mtof_tilde *)pd_new(mtof_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *mtof_tilde_perform(t_int *w)
-{
- t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- t_sample f = *in;
- if (f <= ftofix(-1500.)) *out = 0;
- else
- {
- if (f > ftofix(1499.)) f = ftofix(1499.);
- *out = ftofix(8.17579891564 * exp(.0577622650 * fixtof(f)));
- }
- }
- return (w + 4);
-}
-
-static void mtof_tilde_dsp(t_mtof_tilde *x, t_signal **sp)
-{
- post("warning: %s not usable yet",__FUNCTION__);
- dsp_add(mtof_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-void mtof_tilde_setup(void)
-{
- mtof_tilde_class = class_new(gensym("mtof~"), (t_newmethod)mtof_tilde_new, 0,
- sizeof(t_mtof_tilde), 0, 0);
- CLASS_MAINSIGNALIN(mtof_tilde_class, t_mtof_tilde, x_f);
- class_addmethod(mtof_tilde_class, (t_method)mtof_tilde_dsp, gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/noise~.c b/apps/plugins/pdbox/PDa/intern/noise~.c
index 2f61b9d395..1b10ae91be 100644
--- a/apps/plugins/pdbox/PDa/intern/noise~.c
+++ b/apps/plugins/pdbox/PDa/intern/noise~.c
@@ -52,59 +52,3 @@ void noise_tilde_setup(void)
class_addmethod(noise_class, (t_method)noise_dsp, gensym("dsp"), 0);
}
-
-#include <m_pd.h>
-#include <m_fixed.h>
-
-
-static t_class *noise_class;
-
-typedef struct _noise
-{
- t_object x_obj;
- int x_val;
-} t_noise;
-
-static void *noise_new(void)
-{
- t_noise *x = (t_noise *)pd_new(noise_class);
- static int init = 307;
- x->x_val = (init *= 1319);
- outlet_new(&x->x_obj, gensym("signal"));
- return (x);
-}
-
-static t_int *noise_perform(t_int *w)
-{
- t_sample *out = (t_sample *)(w[1]);
- int *vp = (int *)(w[2]);
- int n = (int)(w[3]);
- int val = *vp;
- while (n--)
- {
-#ifndef FIXEDPOINT
- *out++ = ((t_sample)((val & 0x7fffffff) - 0x40000000)) *
- (t_sample)(1.0 / 0x40000000);
-#else
- *out++=val>>(32-fix1);
-#endif
- val = val * 435898247 + 382842987;
-
- }
- *vp = val;
- return (w+4);
-}
-
-static void noise_dsp(t_noise *x, t_signal **sp)
-{
- dsp_add(noise_perform, 3, sp[0]->s_vec, &x->x_val, sp[0]->s_n);
-}
-
-void noise_tilde_setup(void)
-{
- noise_class = class_new(gensym("noise~"), (t_newmethod)noise_new, 0,
- sizeof(t_noise), 0, 0);
- class_addmethod(noise_class, (t_method)noise_dsp, gensym("dsp"), 0);
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/intern/osc~.c b/apps/plugins/pdbox/PDa/intern/osc~.c
index f8e89970e9..b2cc843b55 100644
--- a/apps/plugins/pdbox/PDa/intern/osc~.c
+++ b/apps/plugins/pdbox/PDa/intern/osc~.c
@@ -84,91 +84,3 @@ void osc_tilde_setup(void)
class_addmethod(osc_class, (t_method)osc_ft1, gensym("ft1"), A_FLOAT, 0);
}
-
-
-
-#include <m_pd.h>
-#include <m_fixed.h>
-#include "cos_table.h"
-
-/* ------------------------ osc~ ----------------------------- */
-
-static t_class *osc_class, *scalarosc_class;
-
-typedef struct _osc
-{
- t_object x_obj;
- unsigned int x_phase;
- t_sample x_conv;
- t_sample x_f; /* frequency if scalar */
-} t_osc;
-
-static void *osc_new(t_floatarg f)
-{
- t_osc *x = (t_osc *)pd_new(osc_class);
- x->x_f = ftofix(f);
- outlet_new(&x->x_obj, gensym("signal"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- x->x_phase = 0;
- x->x_conv = 0;
- return (x);
-}
-
-
-static t_int *osc_perform(t_int *w)
-{
- t_osc *x = (t_osc *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- t_sample *tab = cos_table;
- unsigned int phase = x->x_phase;
- int conv = x->x_conv;
- int off;
- int frac;
- while (n--) {
- phase+= mult(conv ,(*in++));
- phase &= (itofix(1) -1);
- off = fixtoi((long long)phase<<ILOGCOSTABSIZE);
-
-#ifdef NO_INTERPOLATION
- *out = *(tab+off);
-#else
-// frac = phase & (itofix(1)-1);
- frac = phase & ((1<<ILOGCOSTABSIZE)-1);
- frac <<= (fix1-ILOGCOSTABSIZE);
- *out = mult(*(tab + off),(itofix(1) - frac)) +
- mult(*(tab + off + 1),frac);
-#endif
- out++;
- }
- x->x_phase = phase;
-
- return (w+5);
-}
-
-static void osc_dsp(t_osc *x, t_signal **sp)
-{
- post("samplerate %f",sp[0]->s_sr);
- x->x_conv = ftofix(1000.)/sp[0]->s_sr;
- post("conf %d",x->x_conv);
- x->x_conv = mult(x->x_conv + 500,ftofix(0.001));
- post("conf %d",x->x_conv);
- dsp_add(osc_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void osc_ft1(t_osc *x, t_float f)
-{
- x->x_phase = ftofix(f); /* *2 ??? */
-}
-
-void osc_tilde_setup(void)
-{
- osc_class = class_new(gensym("osc~"), (t_newmethod)osc_new, 0,
- sizeof(t_osc), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(osc_class, t_osc, x_f);
- class_addmethod(osc_class, (t_method)osc_dsp, gensym("dsp"), 0);
- class_addmethod(osc_class, (t_method)osc_ft1, gensym("ft1"), A_FLOAT, 0);
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/intern/phasor~.c b/apps/plugins/pdbox/PDa/intern/phasor~.c
index b823286b89..551d7b08f9 100644
--- a/apps/plugins/pdbox/PDa/intern/phasor~.c
+++ b/apps/plugins/pdbox/PDa/intern/phasor~.c
@@ -67,72 +67,3 @@ void phasor_tilde_setup(void)
class_sethelpsymbol(phasor_class, gensym("osc~-help.pd"));
}
-
-#include <m_pd.h>
-#include <m_fixed.h>
-
-/* -------------------------- phasor~ ------------------------------ */
-static t_class *phasor_class;
-
-typedef struct _phasor
-{
- t_object x_obj;
- unsigned int x_phase;
- t_sample x_conv;
- t_sample x_f; /* scalar frequency */
-} t_phasor;
-
-static void *phasor_new(t_floatarg f)
-{
- t_phasor *x = (t_phasor *)pd_new(phasor_class);
- x->x_f = ftofix(f);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- x->x_phase = 0;
- x->x_conv = 0;
- outlet_new(&x->x_obj, gensym("signal"));
- return (x);
-}
-
-static t_int *phasor_perform(t_int *w)
-{
- t_phasor *x = (t_phasor *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- unsigned int phase = x->x_phase;
- int conv = x->x_conv;
-
- while (n--) {
- phase+= mult(conv , (*in++));
- phase &= (itofix(1) - 1);
- *out++ = phase;
- }
- x->x_phase = phase;
-
- return (w+5);
-}
-
-static void phasor_dsp(t_phasor *x, t_signal **sp)
-{
- x->x_conv = ftofix(1000.)/sp[0]->s_sr;
- x->x_conv = mult(x->x_conv + 500,ftofix(0.001));
- dsp_add(phasor_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-
-static void phasor_ft1(t_phasor *x, t_float f)
-{
- x->x_phase = ftofix(f);
-}
-
-void phasor_tilde_setup(void)
-{
- phasor_class = class_new(gensym("phasor~"), (t_newmethod)phasor_new, 0,
- sizeof(t_phasor), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(phasor_class, t_phasor, x_f);
- class_addmethod(phasor_class, (t_method)phasor_dsp, gensym("dsp"), 0);
- class_addmethod(phasor_class, (t_method)phasor_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_sethelpsymbol(phasor_class, gensym("osc~-help.pd"));
-}
-
diff --git a/apps/plugins/pdbox/PDa/intern/powtodb~.c b/apps/plugins/pdbox/PDa/intern/powtodb~.c
index 65cf6c0c36..5fead1511c 100644
--- a/apps/plugins/pdbox/PDa/intern/powtodb~.c
+++ b/apps/plugins/pdbox/PDa/intern/powtodb~.c
@@ -51,56 +51,3 @@ void powtodb_tilde_setup(void)
class_addmethod(powtodb_tilde_class, (t_method)powtodb_tilde_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-#define LOGTEN 2.302585092994
-
-
-typedef struct powtodb_tilde
-{
- t_object x_obj;
- float x_f;
-} t_powtodb_tilde;
-
-t_class *powtodb_tilde_class;
-
-static void *powtodb_tilde_new(void)
-{
- t_powtodb_tilde *x = (t_powtodb_tilde *)pd_new(powtodb_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *powtodb_tilde_perform(t_int *w)
-{
- t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- float f = *in;
- if (f <= 0) *out = 0;
- else
- {
- float g = 100 + 10./LOGTEN * log(f);
- *out = (g < 0 ? 0 : g);
- }
- }
- return (w + 4);
-}
-
-static void powtodb_tilde_dsp(t_powtodb_tilde *x, t_signal **sp)
-{
- post("warning: %s not usable yet",__FUNCTION__);
- dsp_add(powtodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void powtodb_tilde_setup(void)
-{
- powtodb_tilde_class = class_new(gensym("powtodb~"), (t_newmethod)powtodb_tilde_new, 0,
- sizeof(t_powtodb_tilde), 0, 0);
- CLASS_MAINSIGNALIN(powtodb_tilde_class, t_powtodb_tilde, x_f);
- class_addmethod(powtodb_tilde_class, (t_method)powtodb_tilde_dsp, gensym("dsp"), 0);
-}
-
diff --git a/apps/plugins/pdbox/PDa/intern/print~.c b/apps/plugins/pdbox/PDa/intern/print~.c
index 3051ca37be..699555a1bc 100644
--- a/apps/plugins/pdbox/PDa/intern/print~.c
+++ b/apps/plugins/pdbox/PDa/intern/print~.c
@@ -76,81 +76,4 @@ void print_tilde_setup(void)
class_addbang(print_class, print_bang);
class_addfloat(print_class, print_float);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *print_class;
-
-typedef struct _print
-{
- t_object x_obj;
- float x_f;
- t_symbol *x_sym;
- int x_count;
-} t_print;
-static t_int *print_perform(t_int *w)
-{
- t_print *x = (t_print *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- if (x->x_count)
- {
- post("%s:", x->x_sym->s_name);
- if (n == 1) post("%8g", in[0]);
- else if (n == 2) post("%8g %8g", in[0], in[1]);
- else if (n == 4) post("%8g %8g %8g %8g",
- in[0], in[1], in[2], in[3]);
- else while (n > 0)
- {
- post("%-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g",
- fixtof(in[0]),
- fixtof(in[1]),
- fixtof(in[2]),
- fixtof(in[3]),
- fixtof(in[4]),
- fixtof(in[5]),
- fixtof(in[6]),
- fixtof(in[7]));
- n -= 8;
- in += 8;
- }
- x->x_count--;
- }
- return (w+4);
-}
-
-static void print_dsp(t_print *x, t_signal **sp)
-{
- dsp_add(print_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
-}
-
-static void print_float(t_print *x, t_float f)
-{
- if (f < 0) f = 0;
- x->x_count = f;
-}
-
-static void print_bang(t_print *x)
-{
- x->x_count = 1;
-}
-
-static void *print_new(t_symbol *s)
-{
- t_print *x = (t_print *)pd_new(print_class);
- x->x_sym = (s->s_name[0]? s : gensym("print~"));
- x->x_count = 0;
- x->x_f = 0;
- return (x);
-}
-
-void print_tilde_setup(void)
-{
- print_class = class_new(gensym("print~"), (t_newmethod)print_new, 0,
- sizeof(t_print), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(print_class, t_print, x_f);
- class_addmethod(print_class, (t_method)print_dsp, gensym("dsp"), 0);
- class_addbang(print_class, print_bang);
- class_addfloat(print_class, print_float);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/rmstodb~.c b/apps/plugins/pdbox/PDa/intern/rmstodb~.c
index e57345880a..ee2b2a9874 100644
--- a/apps/plugins/pdbox/PDa/intern/rmstodb~.c
+++ b/apps/plugins/pdbox/PDa/intern/rmstodb~.c
@@ -50,55 +50,4 @@ void rmstodb_tilde_setup(void)
CLASS_MAINSIGNALIN(rmstodb_tilde_class, t_rmstodb_tilde, x_f);
class_addmethod(rmstodb_tilde_class, (t_method)rmstodb_tilde_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-#define LOGTEN 2.302585092994
-
-
-typedef struct rmstodb_tilde
-{
- t_object x_obj;
- float x_f;
-} t_rmstodb_tilde;
-
-t_class *rmstodb_tilde_class;
-static void *rmstodb_tilde_new(void)
-{
- t_rmstodb_tilde *x = (t_rmstodb_tilde *)pd_new(rmstodb_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *rmstodb_tilde_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- float f = *in;
- if (f <= 0) *out = 0;
- else
- {
- float g = 100 + 20./LOGTEN * log(f);
- *out = (g < 0 ? 0 : g);
- }
- }
- return (w + 4);
-}
-
-static void rmstodb_tilde_dsp(t_rmstodb_tilde *x, t_signal **sp)
-{
- post("warning: %s not usable yet",__FUNCTION__);
- dsp_add(rmstodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void rmstodb_tilde_setup(void)
-{
- rmstodb_tilde_class = class_new(gensym("rmstodb~"), (t_newmethod)rmstodb_tilde_new, 0,
- sizeof(t_rmstodb_tilde), 0, 0);
- CLASS_MAINSIGNALIN(rmstodb_tilde_class, t_rmstodb_tilde, x_f);
- class_addmethod(rmstodb_tilde_class, (t_method)rmstodb_tilde_dsp, gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/rsqrt~.c b/apps/plugins/pdbox/PDa/intern/rsqrt~.c
index e33a21a0e9..dd7e2a135b 100644
--- a/apps/plugins/pdbox/PDa/intern/rsqrt~.c
+++ b/apps/plugins/pdbox/PDa/intern/rsqrt~.c
@@ -103,108 +103,3 @@ void rsqrt_tilde_setup(void)
class_addmethod(sigrsqrt_class, (t_method)sigrsqrt_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-/* sigrsqrt - reciprocal square root good to 8 mantissa bits */
-
-#define DUMTAB1SIZE 256
-#define DUMTAB2SIZE 1024
-
-static float rsqrt_exptab[DUMTAB1SIZE], rsqrt_mantissatab[DUMTAB2SIZE];
-
-static void init_rsqrt(void)
-{
- int i;
- for (i = 0; i < DUMTAB1SIZE; i++)
- {
- float f;
- long l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23;
- *(long *)(&f) = l;
- rsqrt_exptab[i] = 1./sqrt(f);
- }
- for (i = 0; i < DUMTAB2SIZE; i++)
- {
- float f = 1 + (1./DUMTAB2SIZE) * i;
- rsqrt_mantissatab[i] = 1./sqrt(f);
- }
-}
-
- /* these are used in externs like "bonk" */
-
-float q8_rsqrt(float f)
-{
- long l = *(long *)(&f);
- if (f < 0) return (0);
- else return (rsqrt_exptab[(l >> 23) & 0xff] *
- rsqrt_mantissatab[(l >> 13) & 0x3ff]);
-}
-
-float q8_sqrt(float f)
-{
- long l = *(long *)(&f);
- if (f < 0) return (0);
- else return (f * rsqrt_exptab[(l >> 23) & 0xff] *
- rsqrt_mantissatab[(l >> 13) & 0x3ff]);
-}
-
- /* the old names are OK unless we're in IRIX N32 */
-
-#ifndef N32
-float qsqrt(float f) {return (q8_sqrt(f)); }
-float qrsqrt(float f) {return (q8_rsqrt(f)); }
-#endif
-
-
-
-typedef struct sigrsqrt
-{
- t_object x_obj;
- float x_f;
-} t_sigrsqrt;
-
-static t_class *sigrsqrt_class;
-
-static void *sigrsqrt_new(void)
-{
- t_sigrsqrt *x = (t_sigrsqrt *)pd_new(sigrsqrt_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigrsqrt_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- while (n--)
- {
- float f = *in;
- long l = *(long *)(in++);
- if (f < 0) *out++ = 0;
- else
- {
- float g = rsqrt_exptab[(l >> 23) & 0xff] *
- rsqrt_mantissatab[(l >> 13) & 0x3ff];
- *out++ = 1.5 * g - 0.5 * g * g * g * f;
- }
- }
- return (w + 4);
-}
-
-static void sigrsqrt_dsp(t_sigrsqrt *x, t_signal **sp)
-{
- dsp_add(sigrsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void rsqrt_tilde_setup(void)
-{
- init_rsqrt();
- sigrsqrt_class = class_new(gensym("rsqrt~"), (t_newmethod)sigrsqrt_new, 0,
- sizeof(t_sigrsqrt), 0, 0);
- /* an old name for it: */
- class_addcreator(sigrsqrt_new, gensym("q8_rsqrt~"), 0);
- CLASS_MAINSIGNALIN(sigrsqrt_class, t_sigrsqrt, x_f);
- class_addmethod(sigrsqrt_class, (t_method)sigrsqrt_dsp, gensym("dsp"), 0);
-}
-
diff --git a/apps/plugins/pdbox/PDa/intern/samphold~.c b/apps/plugins/pdbox/PDa/intern/samphold~.c
index 5ccf3d9cfe..8f0656c795 100644
--- a/apps/plugins/pdbox/PDa/intern/samphold~.c
+++ b/apps/plugins/pdbox/PDa/intern/samphold~.c
@@ -73,78 +73,4 @@ void samphold_tilde_setup(void)
class_addmethod(sigsamphold_class, (t_method)sigsamphold_dsp,
gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-typedef struct sigsamphold
-{
- t_object x_obj;
- t_sample x_f;
- t_sample x_lastin;
- t_sample x_lastout;
-} t_sigsamphold;
-
-t_class *sigsamphold_class;
-
-static void *sigsamphold_new(void)
-{
- t_sigsamphold *x = (t_sigsamphold *)pd_new(sigsamphold_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_lastin = 0;
- x->x_lastout = 0;
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigsamphold_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- t_sigsamphold *x = (t_sigsamphold *)(w[4]);
- int n = (t_int)(w[5]);
- int i;
- t_sample lastin = x->x_lastin;
- t_sample lastout = x->x_lastout;
- for (i = 0; i < n; i++, *in1++)
- {
- t_sample next = *in2++;
- if (next < lastin) lastout = *in1;
- *out++ = lastout;
- lastin = next;
- }
- x->x_lastin = lastin;
- x->x_lastout = lastout;
- return (w+6);
-}
-static void sigsamphold_dsp(t_sigsamphold *x, t_signal **sp)
-{
- dsp_add(sigsamphold_perform, 5,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec,
- x, sp[0]->s_n);
-}
-
-static void sigsamphold_reset(t_sigsamphold *x)
-{
- x->x_lastin = 0x7fffffff;
-}
-
-static void sigsamphold_set(t_sigsamphold *x, t_float f)
-{
- x->x_lastout = f;
-}
-
-void samphold_tilde_setup(void)
-{
- sigsamphold_class = class_new(gensym("samphold~"),
- (t_newmethod)sigsamphold_new, 0, sizeof(t_sigsamphold), 0, 0);
- CLASS_MAINSIGNALIN(sigsamphold_class, t_sigsamphold, x_f);
- class_addmethod(sigsamphold_class, (t_method)sigsamphold_set,
- gensym("set"), A_FLOAT, 0);
- class_addmethod(sigsamphold_class, (t_method)sigsamphold_reset,
- gensym("reset"), 0);
- class_addmethod(sigsamphold_class, (t_method)sigsamphold_dsp,
- gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/sformat.h b/apps/plugins/pdbox/PDa/intern/sformat.h
index b75ef98c9a..93d353785b 100644
--- a/apps/plugins/pdbox/PDa/intern/sformat.h
+++ b/apps/plugins/pdbox/PDa/intern/sformat.h
@@ -54,57 +54,3 @@ typedef struct _wave
#endif
-#ifndef SFORMAT_H__
-#define SFORMAT_H__
-
-typedef unsigned short uint16;
-typedef unsigned long uint32;
-
-#define FORMAT_WAVE 0
-#define FORMAT_AIFF 1
-#define FORMAT_NEXT 2
-
-/* the NeXTStep sound header structure; can be big or little endian */
-
-typedef struct _nextstep
-{
- char ns_fileid[4]; /* magic number '.snd' if file is big-endian */
- uint32 ns_onset; /* byte offset of first sample */
- uint32 ns_length; /* length of sound in bytes */
- uint32 ns_format; /* format; see below */
- uint32 ns_sr; /* sample rate */
- uint32 ns_nchans; /* number of channels */
- char ns_info[4]; /* comment */
-} t_nextstep;
-
-#define NS_FORMAT_LINEAR_16 3
-#define NS_FORMAT_LINEAR_24 4
-#define NS_FORMAT_FLOAT 6
-#define SCALE (1./(1024. * 1024. * 1024. * 2.))
-
-/* the WAVE header. All Wave files are little endian. We assume
- the "fmt" chunk comes first which is usually the case but perhaps not
- always; same for AIFF and the "COMM" chunk. */
-
-typedef unsigned word;
-typedef unsigned long dword;
-
-typedef struct _wave
-{
- char w_fileid[4]; /* chunk id 'RIFF' */
- uint32 w_chunksize; /* chunk size */
- char w_waveid[4]; /* wave chunk id 'WAVE' */
- char w_fmtid[4]; /* format chunk id 'fmt ' */
- uint32 w_fmtchunksize; /* format chunk size */
- uint16 w_fmttag; /* format tag, 1 for PCM */
- uint16 w_nchannels; /* number of channels */
- uint32 w_samplespersec; /* sample rate in hz */
- uint32 w_navgbytespersec; /* average bytes per second */
- uint16 w_nblockalign; /* number of bytes per sample */
- uint16 w_nbitspersample; /* number of bits in a sample */
- char w_datachunkid[4]; /* data chunk id 'data' */
- uint32 w_datachunksize; /* length of data chunk */
-} t_wave;
-
-
-#endif
diff --git a/apps/plugins/pdbox/PDa/intern/sfread~.c b/apps/plugins/pdbox/PDa/intern/sfread~.c
index 0980583fa3..3882777ed9 100644
--- a/apps/plugins/pdbox/PDa/intern/sfread~.c
+++ b/apps/plugins/pdbox/PDa/intern/sfread~.c
@@ -286,291 +286,3 @@ void sfread_tilde_setup(void)
}
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-
-#include <m_pd.h>
-#include <m_fixed.h>
-#include "g_canvas.h"
-
-/* ------------------------ sfread~ ----------------------------- */
-
-#include "sformat.h"
-
-static t_class *sfread_class;
-
-
-typedef struct _sfread
-{
- t_object x_obj;
- void* x_mapaddr;
- int x_fd;
-
- int x_play;
- int x_channels;
- long long x_size;
- int x_loop;
- t_time x_pos;
-
- t_sample x_skip;
- t_sample x_speed;
-
- t_glist * x_glist;
- t_outlet *x_bangout;
-} t_sfread;
-
-
-void sfread_open(t_sfread *x,t_symbol *filename)
-{
- struct stat fstate;
- char fname[MAXPDSTRING];
-
- if (filename == &s_) {
- post("sfread: open without filename");
- return;
- }
-
- canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name,
- fname, MAXPDSTRING);
-
-
- /* close the old file */
-
- if (x->x_mapaddr) munmap(x->x_mapaddr,x->x_size);
- if (x->x_fd >= 0) close(x->x_fd);
-
- if ((x->x_fd = open(fname,O_RDONLY)) < 0)
- {
- error("can't open %s",fname);
- x->x_play = 0;
- x->x_mapaddr = NULL;
- return;
- }
-
- /* get the size */
-
- fstat(x->x_fd,&fstate);
- x->x_size = fstate.st_size;
-
- /* map the file into memory */
-
- if (!(x->x_mapaddr = mmap(NULL,x->x_size,PROT_READ,MAP_PRIVATE,x->x_fd,0)))
- {
- error("can't mmap %s",fname);
- return;
- }
-}
-
-#define MAX_CHANS 4
-
-static t_int *sfread_perform(t_int *w)
-{
- t_sfread* x = (t_sfread*)(w[1]);
- short* buf = x->x_mapaddr;
- t_time tmp;
- int c = x->x_channels;
- t_time pos = x->x_pos;
- t_sample speed = x->x_speed;
- t_time end = itofix(x->x_size/sizeof(short)/c);
- int i,n;
- t_sample* out[MAX_CHANS];
-
- for (i=0;i<c;i++)
- out[i] = (t_sample *)(w[3+i]);
- n = (int)(w[3+c]);
-
- /* loop */
-
- if (pos > end)
- pos = end;
-
- if (pos + n*speed >= end) { // playing forward end
- if (!x->x_loop) {
- x->x_play=0;
- }
- pos = x->x_skip;
- }
- tmp = n*speed;
-
- if (pos + n*speed <= 0) { // playing backwards end
- if (!x->x_loop) {
- x->x_play=0;
- }
- pos = end;
-
- }
- if (x->x_play && x->x_mapaddr) {
- t_time aoff = fixtoi(pos)*c;
- while (n--) {
- long frac = (long long)((1<<fix1)-1)&pos;
-
- for (i=0;i<c;i++) {
- t_sample bs = *(buf+aoff+i)<<(fix1-16);
- t_sample cs = *(buf+aoff+i+1)<<(fix1-16);
- *out[i]++ = bs + mult((cs - bs),frac);
-
- }
- pos += speed;
- aoff = fixtoi(pos)*c;
- if (aoff > end) {
- if (x->x_loop) pos = x->x_skip;
- else break;
- }
- if (aoff < x->x_skip) {
- if (x->x_loop) pos = end;
- else break;
- }
- }
- /* Fill with zero in case of end */
- n++;
- while (n--)
- for (i=0;i<c;i++)
- *out[i]++ = 0;
- }
- else {
- while (n--) {
- for (i=0;i<c;i++)
- *out[i]++ = 0.;
- }
- }
-
- x->x_pos = pos;
- return (w+c+4);
-}
-
-
-static void sfread_float(t_sfread *x, t_floatarg f)
-{
- int t = f;
- if (t && x->x_mapaddr) {
- x->x_play=1;
- }
- else {
- x->x_play=0;
- }
-
-}
-
-static void sfread_loop(t_sfread *x, t_floatarg f)
-{
- x->x_loop = f;
-}
-
-
-
-static void sfread_size(t_sfread* x)
-{
- t_atom a;
-
- SETFLOAT(&a,x->x_size*0.5/x->x_channels);
- outlet_list(x->x_bangout, gensym("size"),1,&a);
-}
-
-static void sfread_state(t_sfread* x)
-{
- t_atom a;
-
- SETFLOAT(&a,x->x_play);
- outlet_list(x->x_bangout, gensym("state"),1,&a);
-}
-
-
-
-
-static void sfread_bang(t_sfread* x)
-{
- x->x_pos = x->x_skip;
- sfread_float(x,1.0);
-}
-
-
-static void sfread_dsp(t_sfread *x, t_signal **sp)
-{
-/* post("sfread: dsp"); */
- switch (x->x_channels) {
- case 1:
- dsp_add(sfread_perform, 4, x, sp[0]->s_vec,
- sp[1]->s_vec, sp[0]->s_n);
- break;
- case 2:
- dsp_add(sfread_perform, 5, x, sp[0]->s_vec,
- sp[1]->s_vec,sp[2]->s_vec, sp[0]->s_n);
- break;
- case 4:
- dsp_add(sfread_perform, 6, x, sp[0]->s_vec,
- sp[1]->s_vec,sp[2]->s_vec,
- sp[3]->s_vec,sp[4]->s_vec,
- sp[0]->s_n);
- break;
- }
-}
-
-
-static void sfread_speed(t_sfread* x, t_floatarg f)
-{
- x->x_speed = ftofix(f);
-}
-
-static void sfread_offset(t_sfread* x, t_floatarg f)
-{
- x->x_pos = (int)f;
-}
-
-static void *sfread_new(t_floatarg chan,t_floatarg skip)
-{
- t_sfread *x = (t_sfread *)pd_new(sfread_class);
- t_int c = chan;
-
- x->x_glist = (t_glist*) canvas_getcurrent();
-
- if (c<1 || c > MAX_CHANS) c = 1;
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2"));
-
-
- x->x_fd = -1;
- x->x_mapaddr = NULL;
-
- x->x_size = 0;
- x->x_loop = 0;
- x->x_channels = c;
- x->x_mapaddr=NULL;
- x->x_pos = 0;
- x->x_skip = 0;
- x->x_speed = ftofix(1.0);
- x->x_play = 0;
-
- while (c--) {
- outlet_new(&x->x_obj, gensym("signal"));
- }
-
- x->x_bangout = outlet_new(&x->x_obj, &s_float);
-
- return (x);
-}
-
-void sfread_tilde_setup(void)
-{
- /* sfread */
-
- sfread_class = class_new(gensym("sfread~"), (t_newmethod)sfread_new, 0,
- sizeof(t_sfread), 0,A_DEFFLOAT,A_DEFFLOAT,0);
- class_addmethod(sfread_class, nullfn, gensym("signal"), 0);
- class_addmethod(sfread_class, (t_method) sfread_dsp, gensym("dsp"), 0);
- class_addmethod(sfread_class, (t_method) sfread_open, gensym("open"), A_SYMBOL,A_NULL);
- class_addmethod(sfread_class, (t_method) sfread_size, gensym("size"), 0);
- class_addmethod(sfread_class, (t_method) sfread_offset, gensym("ft1"), A_FLOAT, A_NULL);
- class_addmethod(sfread_class, (t_method) sfread_speed, gensym("ft2"), A_FLOAT, A_NULL);
- class_addmethod(sfread_class, (t_method) sfread_state, gensym("state"), 0);
- class_addfloat(sfread_class, sfread_float);
- class_addbang(sfread_class,sfread_bang);
- class_addmethod(sfread_class,(t_method)sfread_loop,gensym("loop"),A_FLOAT,A_NULL);
-
-}
-
diff --git a/apps/plugins/pdbox/PDa/intern/sfwrite~.c b/apps/plugins/pdbox/PDa/intern/sfwrite~.c
index dd3bfc4a09..6b054f17b9 100644
--- a/apps/plugins/pdbox/PDa/intern/sfwrite~.c
+++ b/apps/plugins/pdbox/PDa/intern/sfwrite~.c
@@ -239,242 +239,3 @@ void sfwrite_tilde_setup(void)
class_addfloat(sfwrite_class, sfwrite_float);
}
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-
-#include <m_pd.h>
-#include <m_fixed.h>
-#include "g_canvas.h"
-
-
-#define BLOCKTIME 10
-
-#define MAX_CHANS 4
-
-#include "sformat.h"
-
-static t_class *sfwrite_class;
-
-typedef struct _sfwrite
-{
- t_object x_obj;
- t_symbol* filename;
- int x_file;
-
- t_int rec;
- t_int x_channels;
- uint32 size;
- t_glist * x_glist;
- t_int x_blocked;
- t_int x_blockwarn;
-} t_sfwrite;
-
-
-static void sfwrite_wave_setup(t_sfwrite* x,t_wave* w)
-{
-
- strncpy(w->w_fileid,"RIFF",4); /* chunk id 'RIFF' */
- w->w_chunksize = x->size + sizeof(t_wave) -8; /* chunk size */
- strncpy(w->w_waveid,"WAVE",4); /* wave chunk id 'WAVE' */
- strncpy(w->w_fmtid,"fmt ",4); /* format chunk id 'fmt '*/
- w->w_fmtchunksize = 16; /* format chunk size */
- w->w_fmttag = 1; /* format tag, 1 for PCM */
- w->w_nchannels = x->x_channels; /* number of channels */
- w->w_samplespersec = 44100; /* sample rate in hz */
- w->w_navgbytespersec = 44100*x->x_channels*2; /* average bytes per second */
- w->w_nblockalign = 4; /* number of bytes per sample */
- w->w_nbitspersample = 16; /* number of bits in a sample */
- strncpy(w->w_datachunkid,"data",4); /* data chunk id 'data'*/
- w->w_datachunksize = x->size; /* length of data chunk */
-}
-
-
-
-static void sfwrite_close(t_sfwrite *x)
-{
- if (x->x_file > 0) {
- t_wave w;
- sfwrite_wave_setup(x,&w);
- lseek(x->x_file,0,SEEK_SET);
- write(x->x_file,&w,sizeof(w));
- close(x->x_file);
- }
- x->x_file = -1;
-}
-
-
-static void sfwrite_open(t_sfwrite *x,t_symbol *filename)
-{
- char fname[MAXPDSTRING];
-
- if (filename == &s_) {
- post("sfwrite: open without filename");
- return;
- }
-
- canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name,
- fname, MAXPDSTRING);
-
- x->x_blocked = 0;
- x->filename = filename;
- post("sfwrite: filename = %s",x->filename->s_name);
-
- sfwrite_close(x);
-
- if ((x->x_file = open(fname,O_RDWR | O_CREAT,0664)) < 0)
- {
- error("can't create %s",fname);
- return;
- }
-
- /* skip the header */
-
- lseek(x->x_file,sizeof(t_wave),SEEK_SET);
- x->size = 0;
-
-
-}
-
-static void sfwrite_block(t_sfwrite *x, t_floatarg f)
-{
- x->x_blockwarn = f;
-}
-
-
-static void sfwrite_float(t_sfwrite *x, t_floatarg f)
-{
- int t = f;
- if (t) {
- post("sfwrite: start", f);
- x->rec=1;
- }
- else {
- post("sfwrite: stop", f);
- x->rec=0;
- }
-
-}
-
-
-static short out[4*64];
-
-static t_int *sfwrite_perform(t_int *w)
-{
- t_sfwrite* x = (t_sfwrite*)(w[1]);
- t_sample * in[4];
- int c = x->x_channels;
- int i,num,n;
- short* tout = out;
- int ret;
- int timebefore,timeafter;
- double late;
-
- for (i=0;i < c;i++) {
- in[i] = (t_sample *)(w[2+i]);
- }
-
- n = num = (int)(w[2+c]);
-
- /* loop */
-
- if (x->rec && x->x_file) {
-
- while (n--) {
- for (i=0;i<c;i++) {
- *tout++ = (*(in[i])++)>>(fix1-16);
- }
- }
-
- timebefore = sys_getrealtime();
- if ((ret =write(x->x_file,out,sizeof(short)*num*c)) < (signed int)sizeof(short)*num*c) {
- post("sfwrite: short write %d",ret);
-
- }
- timeafter = sys_getrealtime();
- late = timeafter - timebefore;
-
-#if 0
- /* OK, we let only 10 ms block here */
- if (late > BLOCKTIME && x->x_blockwarn) {
- post("sfwrite blocked %f ms",late*1000);
- x->x_blocked++;
- if (x->x_blocked > x->x_blockwarn) {
- x->rec = 0;
- post("maximum blockcount %d reached, recording stopped (set blockcount with \"block <num>\"",x->x_blockwarn);
- }
- }
-#endif
- x->size +=64*x->x_channels*sizeof(short) ;
- }
-
- return (w+3+c);
-}
-
-
-
-static void sfwrite_dsp(t_sfwrite *x, t_signal **sp)
-{
- switch (x->x_channels) {
- case 1:
- dsp_add(sfwrite_perform, 3, x, sp[0]->s_vec,
- sp[0]->s_n);
- break;
- case 2:
- dsp_add(sfwrite_perform, 4, x, sp[0]->s_vec,
- sp[1]->s_vec, sp[0]->s_n);
- break;
- case 4:
- dsp_add(sfwrite_perform, 6, x, sp[0]->s_vec,
- sp[1]->s_vec,
- sp[2]->s_vec,
- sp[3]->s_vec,
- sp[0]->s_n);
- break;
- }
-}
-
-static void sfwrite_free(t_sfwrite* x)
-{
- sfwrite_close(x);
-}
-
-
-static void *sfwrite_new(t_floatarg chan)
-{
- t_sfwrite *x = (t_sfwrite *)pd_new(sfwrite_class);
- t_int c = chan;
-
- if (c<1 || c > MAX_CHANS) c = 1;
-
- x->x_glist = (t_glist*) canvas_getcurrent();
- x->x_channels = c--;
- x->x_file=0;
- x->rec = 0;
- x->size = 0;
- x->x_blocked = 0;
- x->x_blockwarn = 10;
- while (c--) {
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- }
-
-
- return (x);
-}
-
-void sfwrite_tilde_setup(void)
-{
- sfwrite_class = class_new(gensym("sfwrite~"), (t_newmethod)sfwrite_new, (t_method)sfwrite_free,
- sizeof(t_sfwrite), 0,A_DEFFLOAT,0);
- class_addmethod(sfwrite_class,nullfn,gensym("signal"), 0);
- class_addmethod(sfwrite_class, (t_method) sfwrite_dsp, gensym("dsp"), 0);
- class_addmethod(sfwrite_class, (t_method) sfwrite_open, gensym("open"), A_SYMBOL,A_NULL);
- class_addmethod(sfwrite_class, (t_method) sfwrite_close, gensym("close"), 0);
- class_addmethod(sfwrite_class, (t_method)sfwrite_block,gensym("block"),A_DEFFLOAT,0);
- class_addfloat(sfwrite_class, sfwrite_float);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/sig~.c b/apps/plugins/pdbox/PDa/intern/sig~.c
index 70a616ce23..6cee184134 100644
--- a/apps/plugins/pdbox/PDa/intern/sig~.c
+++ b/apps/plugins/pdbox/PDa/intern/sig~.c
@@ -65,70 +65,4 @@ void sig_tilde_setup(void)
class_addfloat(sig_tilde_class, (t_method)sig_tilde_float);
class_addmethod(sig_tilde_class, (t_method)sig_tilde_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *sig_tilde_class;
-
-typedef struct _sig
-{
- t_object x_obj;
- t_sample x_f;
-} t_sig;
-
-static t_int *sig_tilde_perform(t_int *w)
-{
- t_sample f = *(t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- while (n--)
- *out++ = f;
- return (w+4);
-}
-
-static t_int *sig_tilde_perf8(t_int *w)
-{
- t_sample f = *(t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = (int)(w[3]);
-
- for (; n; n -= 8, out += 8)
- {
- out[0] = f;
- out[1] = f;
- out[2] = f;
- out[3] = f;
- out[4] = f;
- out[5] = f;
- out[6] = f;
- out[7] = f;
- }
- return (w+4);
-}
-
-static void sig_tilde_float(t_sig *x, t_float f)
-{
- x->x_f = ftofix(f);
-}
-
-static void sig_tilde_dsp(t_sig *x, t_signal **sp)
-{
- dsp_add(sig_tilde_perform, 3, &x->x_f, sp[0]->s_vec, sp[0]->s_n);
-}
-
-static void *sig_tilde_new(t_floatarg f)
-{
- t_sig *x = (t_sig *)pd_new(sig_tilde_class);
- x->x_f = ftofix(f);
- outlet_new(&x->x_obj, gensym("signal"));
- return (x);
-}
-
-void sig_tilde_setup(void)
-{
- sig_tilde_class = class_new(gensym("sig~"), (t_newmethod)sig_tilde_new, 0,
- sizeof(t_sig), 0, A_DEFFLOAT, 0);
- class_addfloat(sig_tilde_class, (t_method)sig_tilde_float);
- class_addmethod(sig_tilde_class, (t_method)sig_tilde_dsp, gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/snapshot~.c b/apps/plugins/pdbox/PDa/intern/snapshot~.c
index f63aeb76cd..cd3557a3df 100644
--- a/apps/plugins/pdbox/PDa/intern/snapshot~.c
+++ b/apps/plugins/pdbox/PDa/intern/snapshot~.c
@@ -55,60 +55,4 @@ void snapshot_tilde_setup(void)
gensym("set"), A_DEFFLOAT, 0);
class_addbang(snapshot_tilde_class, snapshot_tilde_bang);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-
-static t_class *snapshot_tilde_class;
-
-typedef struct _snapshot
-{
- t_object x_obj;
- t_sample x_value;
- float x_f;
-} t_snapshot;
-
-static void *snapshot_tilde_new(void)
-{
- t_snapshot *x = (t_snapshot *)pd_new(snapshot_tilde_class);
- x->x_value = 0;
- outlet_new(&x->x_obj, &s_float);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *snapshot_tilde_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- *out = *in;
- return (w+3);
-}
-
-static void snapshot_tilde_dsp(t_snapshot *x, t_signal **sp)
-{
- dsp_add(snapshot_tilde_perform, 2, sp[0]->s_vec + (sp[0]->s_n-1),
- &x->x_value);
-}
-
-static void snapshot_tilde_bang(t_snapshot *x)
-{
- outlet_float(x->x_obj.ob_outlet, fixtof(x->x_value));
-}
-
-static void snapshot_tilde_set(t_snapshot *x, t_floatarg f)
-{
- x->x_value = ftofix(f);
-}
-void snapshot_tilde_setup(void)
-{
- snapshot_tilde_class = class_new(gensym("snapshot~"), snapshot_tilde_new, 0,
- sizeof(t_snapshot), 0, 0);
- CLASS_MAINSIGNALIN(snapshot_tilde_class, t_snapshot, x_f);
- class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_set,
- gensym("set"), A_DEFFLOAT, 0);
- class_addbang(snapshot_tilde_class, snapshot_tilde_bang);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/sqrt~.c b/apps/plugins/pdbox/PDa/intern/sqrt~.c
index 5e4b649f8e..f5362f094f 100644
--- a/apps/plugins/pdbox/PDa/intern/sqrt~.c
+++ b/apps/plugins/pdbox/PDa/intern/sqrt~.c
@@ -75,80 +75,3 @@ void sqrt_tilde_setup(void)
class_addmethod(sigsqrt_class, (t_method)sigsqrt_dsp, gensym("dsp"), 0);
}
-#define DUMTAB1SIZE 256
-#define DUMTAB2SIZE 1024
-
-#include<m_pd.h>
-#include<m_fixed.h>
-
-/* sigsqrt - square root good to 8 mantissa bits */
-
-static float rsqrt_exptab[DUMTAB1SIZE], rsqrt_mantissatab[DUMTAB2SIZE];
-
-static void init_rsqrt(void)
-{
- int i;
- for (i = 0; i < DUMTAB1SIZE; i++)
- {
- float f;
- long l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23;
- *(long *)(&f) = l;
- rsqrt_exptab[i] = 1./sqrt(f);
- }
- for (i = 0; i < DUMTAB2SIZE; i++)
- {
- float f = 1 + (1./DUMTAB2SIZE) * i;
- rsqrt_mantissatab[i] = 1./sqrt(f);
- }
-}
-
-typedef struct sigsqrt
-{
- t_object x_obj;
- float x_f;
-} t_sigsqrt;
-
-static t_class *sigsqrt_class;
-
-static void *sigsqrt_new(void)
-{
- t_sigsqrt *x = (t_sigsqrt *)pd_new(sigsqrt_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-t_int *sigsqrt_perform(t_int *w) /* not static; also used in d_fft.c */
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- while (n--)
- {
- float f = *in;
- long l = *(long *)(in++);
- if (f < 0) *out++ = 0;
- else
- {
- float g = rsqrt_exptab[(l >> 23) & 0xff] *
- rsqrt_mantissatab[(l >> 13) & 0x3ff];
- *out++ = f * (1.5 * g - 0.5 * g * g * g * f);
- }
- }
- return (w + 4);
-}
-
-static void sigsqrt_dsp(t_sigsqrt *x, t_signal **sp)
-{
- dsp_add(sigsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void sqrt_tilde_setup(void)
-{
- init_rsqrt();
- sigsqrt_class = class_new(gensym("sqrt~"), (t_newmethod)sigsqrt_new, 0,
- sizeof(t_sigsqrt), 0, 0);
- class_addcreator(sigsqrt_new, gensym("q8_sqrt~"), 0); /* old name */
- CLASS_MAINSIGNALIN(sigsqrt_class, t_sigsqrt, x_f);
- class_addmethod(sigsqrt_class, (t_method)sigsqrt_dsp, gensym("dsp"), 0);
-}
-
diff --git a/apps/plugins/pdbox/PDa/intern/tabosc4~.c b/apps/plugins/pdbox/PDa/intern/tabosc4~.c
index ec8ed84f31..f9b6ad0ac3 100644
--- a/apps/plugins/pdbox/PDa/intern/tabosc4~.c
+++ b/apps/plugins/pdbox/PDa/intern/tabosc4~.c
@@ -131,134 +131,3 @@ void tabosc4_tilde_setup(void)
gensym("ft1"), A_FLOAT, 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *tabosc4_tilde_class;
-
-typedef struct _tabosc4_tilde
-{
- t_object x_obj;
- int x_fnpoints;
- int x_lognpoints;
- t_sample *x_vec;
- t_symbol *x_arrayname;
- t_sample x_f;
- unsigned int x_phase;
- t_sample x_conv;
-} t_tabosc4_tilde;
-
-static void *tabosc4_tilde_new(t_symbol *s)
-{
- t_tabosc4_tilde *x = (t_tabosc4_tilde *)pd_new(tabosc4_tilde_class);
- x->x_arrayname = s;
- x->x_vec = 0;
- x->x_fnpoints = 512;
- outlet_new(&x->x_obj, gensym("signal"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- x->x_f = 0;
- post("new done");
- return (x);
-}
-
-static t_int *tabosc4_tilde_perform(t_int *w)
-{
- t_tabosc4_tilde *x = (t_tabosc4_tilde *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- t_sample *tab = x->x_vec;
- unsigned int phase = x->x_phase;
- int conv = x->x_conv;
- int off;
- int frac;
- int logp = x->x_lognpoints;
-
- if (!tab) goto zero;
-
- while (n--) {
- t_sample f2;
- phase+= mult(conv ,(*in++));
- phase &= (itofix(1) -1);
- off = fixtoi((long long)phase<<logp);
-
-#ifdef NO_INTERPOLATION
- *out = *(tab+off);
-#else
- frac = phase & ((1<<logp)-1);
- frac <<= (fix1-logp);
-
- f2 = (off == x->x_fnpoints) ?
- mult(*(tab),frac) :
- mult(*(tab + off + 1),frac);
-
- *out = mult(*(tab + off),(itofix(1) - frac)) + f2;
-#endif
- out++;
- }
- x->x_phase = phase;
-
- return (w+5);
-
-zero:
- while (n--) *out++ = 0;
-
- return (w+5);
-}
-
-void tabosc4_tilde_set(t_tabosc4_tilde *x, t_symbol *s)
-{
- t_garray *a;
- int npoints, pointsinarray;
- x->x_arrayname = s;
-
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name)
- pd_error(x, "tabosc4~: %s: no such array", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &pointsinarray, &x->x_vec))
- {
- pd_error(x, "%s: bad template for tabosc4~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else
- {
- int i;
- x->x_fnpoints = pointsinarray;
- x->x_lognpoints = ilog2(pointsinarray);
- post("tabosc~: using %d (log %d) points of array",x->x_fnpoints,x->x_lognpoints);
-
- garray_usedindsp(a);
- }
-}
-
-static void tabosc4_tilde_ft1(t_tabosc4_tilde *x, t_float f)
-{
- x->x_phase = f;
-}
-
-static void tabosc4_tilde_dsp(t_tabosc4_tilde *x, t_signal **sp)
-{
- x->x_conv = ftofix(1000.)/sp[0]->s_sr;
- x->x_conv = mult(x->x_conv + 500,ftofix(0.001));
-
- tabosc4_tilde_set(x, x->x_arrayname);
- dsp_add(tabosc4_tilde_perform, 4, x,
- sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void tabosc4_tilde_setup(void)
-{
- tabosc4_tilde_class = class_new(gensym("tabosc4~"),
- (t_newmethod)tabosc4_tilde_new, 0,
- sizeof(t_tabosc4_tilde), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabosc4_tilde_class, t_tabosc4_tilde, x_f);
- class_addmethod(tabosc4_tilde_class, (t_method)tabosc4_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabosc4_tilde_class, (t_method)tabosc4_tilde_set,
- gensym("set"), A_SYMBOL, 0);
- class_addmethod(tabosc4_tilde_class, (t_method)tabosc4_tilde_ft1,
- gensym("ft1"), A_FLOAT, 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/tabplay~.c b/apps/plugins/pdbox/PDa/intern/tabplay~.c
index c0032a1e12..5ac0d2701a 100644
--- a/apps/plugins/pdbox/PDa/intern/tabplay~.c
+++ b/apps/plugins/pdbox/PDa/intern/tabplay~.c
@@ -131,134 +131,3 @@ void tabplay_tilde_setup(void)
class_addlist(tabplay_tilde_class, tabplay_tilde_list);
}
-#define FIXEDPOINT
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *tabplay_tilde_class;
-
-typedef struct _tabplay_tilde
-{
- t_object x_obj;
- t_outlet *x_bangout;
- int x_phase;
- int x_nsampsintab;
- int x_limit;
- t_sample *x_vec;
- t_symbol *x_arrayname;
- t_clock *x_clock;
-} t_tabplay_tilde;
-
-static void tabplay_tilde_tick(t_tabplay_tilde *x);
-
-static void *tabplay_tilde_new(t_symbol *s)
-{
- t_tabplay_tilde *x = (t_tabplay_tilde *)pd_new(tabplay_tilde_class);
- x->x_clock = clock_new(x, (t_method)tabplay_tilde_tick);
- x->x_phase = 0x7fffffff;
- x->x_limit = 0;
- x->x_arrayname = s;
- outlet_new(&x->x_obj, &s_signal);
- x->x_bangout = outlet_new(&x->x_obj, &s_bang);
- return (x);
-}
-
-static t_int *tabplay_tilde_perform(t_int *w)
-{
- t_tabplay_tilde *x = (t_tabplay_tilde *)(w[1]);
- t_sample *out = (t_sample *)(w[2]), *fp;
- int n = (int)(w[3]), phase = x->x_phase,
- endphase = (x->x_nsampsintab < x->x_limit ?
- x->x_nsampsintab : x->x_limit), nxfer, n3;
- if (!x->x_vec || phase >= endphase)
- goto zero;
-
- nxfer = endphase - phase;
- fp = x->x_vec + phase;
- if (nxfer > n)
- nxfer = n;
- n3 = n - nxfer;
- phase += nxfer;
- while (nxfer--)
- *out++ = *fp++;
- if (phase >= endphase)
- {
- clock_delay(x->x_clock, 0);
- x->x_phase = 0x7fffffff;
- while (n3--)
- *out++ = 0;
- }
- else x->x_phase = phase;
-
- return (w+4);
-zero:
- while (n--) *out++ = 0;
- return (w+4);
-}
-
-void tabplay_tilde_set(t_tabplay_tilde *x, t_symbol *s)
-{
- t_garray *a;
-
- x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name) pd_error(x, "tabplay~: %s: no such array",
- x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec))
- {
- error("%s: bad template for tabplay~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else garray_usedindsp(a);
-}
-
-static void tabplay_tilde_dsp(t_tabplay_tilde *x, t_signal **sp)
-{
- tabplay_tilde_set(x, x->x_arrayname);
- dsp_add(tabplay_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
-}
-
-static void tabplay_tilde_list(t_tabplay_tilde *x, t_symbol *s,
- int argc, t_atom *argv)
-{
- long start = atom_getfloatarg(0, argc, argv);
- long length = atom_getfloatarg(1, argc, argv);
- if (start < 0) start = 0;
- if (length <= 0)
- x->x_limit = 0x7fffffff;
- else
- x->x_limit = start + length;
- x->x_phase = start;
-}
-
-static void tabplay_tilde_stop(t_tabplay_tilde *x)
-{
- x->x_phase = 0x7fffffff;
-}
-
-static void tabplay_tilde_tick(t_tabplay_tilde *x)
-{
- outlet_bang(x->x_bangout);
-}
-
-static void tabplay_tilde_free(t_tabplay_tilde *x)
-{
- clock_free(x->x_clock);
-}
-
-void tabplay_tilde_setup(void)
-{
- tabplay_tilde_class = class_new(gensym("tabplay~"),
- (t_newmethod)tabplay_tilde_new, (t_method)tabplay_tilde_free,
- sizeof(t_tabplay_tilde), 0, A_DEFSYM, 0);
- class_addmethod(tabplay_tilde_class, (t_method)tabplay_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabplay_tilde_class, (t_method)tabplay_tilde_stop,
- gensym("stop"), 0);
- class_addmethod(tabplay_tilde_class, (t_method)tabplay_tilde_set,
- gensym("set"), A_DEFSYM, 0);
- class_addlist(tabplay_tilde_class, tabplay_tilde_list);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/tabread.c b/apps/plugins/pdbox/PDa/intern/tabread.c
index 5cd51b3036..16beb5977a 100644
--- a/apps/plugins/pdbox/PDa/intern/tabread.c
+++ b/apps/plugins/pdbox/PDa/intern/tabread.c
@@ -50,55 +50,4 @@ void tabread_setup(void)
class_addmethod(tabread_class, (t_method)tabread_set, gensym("set"),
A_SYMBOL, 0);
}
-#include <m_pd.h>
-
-/* ---------- tabread: control, non-interpolating ------------------------ */
-
-static t_class *tabread_class;
-
-typedef struct _tabread
-{
- t_object x_obj;
- t_symbol *x_arrayname;
-} t_tabread;
-
-static void tabread_float(t_tabread *x, t_float f)
-{
- t_garray *a;
- int npoints;
- t_sample *vec;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- pd_error(x, "%s: no such array", x->x_arrayname->s_name);
- else if (!garray_getfloatarray(a, &npoints, &vec))
- pd_error(x, "%s: bad template for tabread", x->x_arrayname->s_name);
- else
- {
- int n = f;
- if (n < 0) n = 0;
- else if (n >= npoints) n = npoints - 1;
- outlet_float(x->x_obj.ob_outlet, (npoints ? fixtof(vec[n]) : 0));
- }
-}
-
-static void tabread_set(t_tabread *x, t_symbol *s)
-{
- x->x_arrayname = s;
-}
-
-static void *tabread_new(t_symbol *s)
-{
- t_tabread *x = (t_tabread *)pd_new(tabread_class);
- x->x_arrayname = s;
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-void tabread_setup(void)
-{
- tabread_class = class_new(gensym("tabread"), (t_newmethod)tabread_new,
- 0, sizeof(t_tabread), 0, A_DEFSYM, 0);
- class_addfloat(tabread_class, (t_method)tabread_float);
- class_addmethod(tabread_class, (t_method)tabread_set, gensym("set"),
- A_SYMBOL, 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/tabread4~.c b/apps/plugins/pdbox/PDa/intern/tabread4~.c
index e530a9fce8..47a6fc3ddf 100644
--- a/apps/plugins/pdbox/PDa/intern/tabread4~.c
+++ b/apps/plugins/pdbox/PDa/intern/tabread4~.c
@@ -104,107 +104,3 @@ void tabread4_tilde_setup(void)
gensym("set"), A_SYMBOL, 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-
-static t_class *tabread4_tilde_class;
-
-typedef struct _tabread4_tilde
-{
- t_object x_obj;
- int x_npoints;
- t_sample *x_vec;
- t_symbol *x_arrayname;
- float x_f;
-} t_tabread4_tilde;
-
-static void *tabread4_tilde_new(t_symbol *s)
-{
- t_tabread4_tilde *x = (t_tabread4_tilde *)pd_new(tabread4_tilde_class);
- x->x_arrayname = s;
- x->x_vec = 0;
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *tabread4_tilde_perform(t_int *w)
-{
- t_tabread4_tilde *x = (t_tabread4_tilde *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- int maxindex;
- t_sample *buf = x->x_vec, *fp;
- int i;
-
- maxindex = x->x_npoints - 3;
-
- if (!buf) goto zero;
-
- for (i = 0; i < n; i++)
- {
- t_time findex = ((long long) mult((*in++),ftofix(44.1)));
- int index = fixtoi(findex);
- t_sample frac;
- // post("%d: index %d f %lld",index,findex,*in);
-
- if (index < 1)
- index = 1, frac = 0;
- else if (index > maxindex)
- index = maxindex, frac = 1;
- else frac = findex - itofix(index);
- fp = buf + index;
- *out++ = fp[0] + mult(frac,fp[1]-fp[0]);
- }
- return (w+5);
- zero:
- while (n--) *out++ = 0;
-
- return (w+5);
-}
-
-void tabread4_tilde_set(t_tabread4_tilde *x, t_symbol *s)
-{
- t_garray *a;
-
- x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name)
- error("tabread4~: %s: no such array", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &x->x_npoints, &x->x_vec))
- {
- error("%s: bad template for tabread4~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else garray_usedindsp(a);
-}
-
-static void tabread4_tilde_dsp(t_tabread4_tilde *x, t_signal **sp)
-{
- tabread4_tilde_set(x, x->x_arrayname);
-
- dsp_add(tabread4_tilde_perform, 4, x,
- sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-
-}
-
-static void tabread4_tilde_free(t_tabread4_tilde *x)
-{
-}
-
-void tabread4_tilde_setup(void)
-{
- tabread4_tilde_class = class_new(gensym("tabread4~"),
- (t_newmethod)tabread4_tilde_new, (t_method)tabread4_tilde_free,
- sizeof(t_tabread4_tilde), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabread4_tilde_class, t_tabread4_tilde, x_f);
- class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_set,
- gensym("set"), A_SYMBOL, 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/tabread~.c b/apps/plugins/pdbox/PDa/intern/tabread~.c
index f1f4fd4729..5a7ea5d57f 100644
--- a/apps/plugins/pdbox/PDa/intern/tabread~.c
+++ b/apps/plugins/pdbox/PDa/intern/tabread~.c
@@ -95,100 +95,4 @@ void tabread_tilde_setup(void)
class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_set,
gensym("set"), A_SYMBOL, 0);
}
-#define FIXEDPOINT
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *tabread_tilde_class;
-
-typedef struct _tabread_tilde
-{
- t_object x_obj;
- int x_npoints;
- t_sample *x_vec;
- t_symbol *x_arrayname;
- float x_f;
-} t_tabread_tilde;
-
-static void *tabread_tilde_new(t_symbol *s)
-{
- t_tabread_tilde *x = (t_tabread_tilde *)pd_new(tabread_tilde_class);
- x->x_arrayname = s;
- x->x_vec = 0;
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *tabread_tilde_perform(t_int *w)
-{
- t_tabread_tilde *x = (t_tabread_tilde *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- int maxindex;
- t_sample *buf = x->x_vec, *fp;
- int i;
-
- maxindex = x->x_npoints - 1;
- if (!buf) goto zero;
-
- for (i = 0; i < n; i++)
- {
- int index = ((long long) mult((*in++),ftofix(44.1)) >> fix1);
- if (index < 0)
- index = 0;
- else if (index > maxindex)
- index = maxindex;
- *out++ = buf[index];
- }
- return (w+5);
- zero:
- while (n--) *out++ = 0;
-
- return (w+5);
-}
-
-void tabread_tilde_set(t_tabread_tilde *x, t_symbol *s)
-{
- t_garray *a;
-
- x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name)
- error("tabread~: %s: no such array", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &x->x_npoints, &x->x_vec))
- {
- error("%s: bad template for tabread~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else garray_usedindsp(a);
-}
-static void tabread_tilde_dsp(t_tabread_tilde *x, t_signal **sp)
-{
- tabread_tilde_set(x, x->x_arrayname);
-
- dsp_add(tabread_tilde_perform, 4, x,
- sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-
-}
-
-static void tabread_tilde_free(t_tabread_tilde *x)
-{
-}
-
-void tabread_tilde_setup(void)
-{
- tabread_tilde_class = class_new(gensym("tabread~"),
- (t_newmethod)tabread_tilde_new, (t_method)tabread_tilde_free,
- sizeof(t_tabread_tilde), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabread_tilde_class, t_tabread_tilde, x_f);
- class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_set,
- gensym("set"), A_SYMBOL, 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/tabreceive~.c b/apps/plugins/pdbox/PDa/intern/tabreceive~.c
index 82f2ff388a..e51a5c015e 100644
--- a/apps/plugins/pdbox/PDa/intern/tabreceive~.c
+++ b/apps/plugins/pdbox/PDa/intern/tabreceive~.c
@@ -59,64 +59,3 @@ void tabreceive_tilde_setup(void)
gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *tabreceive_class;
-
-typedef struct _tabreceive
-{
- t_object x_obj;
- t_sample *x_vec;
- t_symbol *x_arrayname;
-} t_tabreceive;
-
-static t_int *tabreceive_perform(t_int *w)
-{
- t_tabreceive *x = (t_tabreceive *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = w[3];
- t_sample *from = x->x_vec;
- if (from) while (n--) *out++ = *from++;
- else while (n--) *out++ = 0;
- return (w+4);
-}
-
-static void tabreceive_dsp(t_tabreceive *x, t_signal **sp)
-{
- t_garray *a;
- int vecsize;
-
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*x->x_arrayname->s_name)
- error("tabsend~: %s: no such array", x->x_arrayname->s_name);
- }
- else if (!garray_getfloatarray(a, &vecsize, &x->x_vec))
- error("%s: bad template for tabreceive~", x->x_arrayname->s_name);
- else
- {
- int n = sp[0]->s_n;
- if (n < vecsize) vecsize = n;
- garray_usedindsp(a);
- dsp_add(tabreceive_perform, 3, x, sp[0]->s_vec, vecsize);
- }
-}
-
-static void *tabreceive_new(t_symbol *s)
-{
- t_tabreceive *x = (t_tabreceive *)pd_new(tabreceive_class);
- x->x_arrayname = s;
- outlet_new(&x->x_obj, &s_signal);
- return (x);
-}
-
-void tabreceive_tilde_setup(void)
-{
- tabreceive_class = class_new(gensym("tabreceive~"),
- (t_newmethod)tabreceive_new, 0,
- sizeof(t_tabreceive), 0, A_DEFSYM, 0);
- class_addmethod(tabreceive_class, (t_method)tabreceive_dsp,
- gensym("dsp"), 0);
-}
-
diff --git a/apps/plugins/pdbox/PDa/intern/tabsend~.c b/apps/plugins/pdbox/PDa/intern/tabsend~.c
index 4d7ac9007e..9021bac951 100644
--- a/apps/plugins/pdbox/PDa/intern/tabsend~.c
+++ b/apps/plugins/pdbox/PDa/intern/tabsend~.c
@@ -97,100 +97,3 @@ void tabsend_tilde_setup(void)
class_addmethod(tabsend_class, (t_method)tabsend_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-static t_class *tabsend_class;
-
-typedef struct _tabsend
-{
- t_object x_obj;
- t_sample *x_vec;
- int x_graphperiod;
- int x_graphcount;
- t_symbol *x_arrayname;
- t_clock *x_clock;
- float x_f;
-} t_tabsend;
-
-static void tabsend_tick(t_tabsend *x);
-
-static void *tabsend_new(t_symbol *s)
-{
- t_tabsend *x = (t_tabsend *)pd_new(tabsend_class);
- x->x_graphcount = 0;
- x->x_arrayname = s;
- x->x_clock = clock_new(x, (t_method)tabsend_tick);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *tabsend_perform(t_int *w)
-{
- t_tabsend *x = (t_tabsend *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- int n = w[3];
- t_sample *dest = x->x_vec;
- int i = x->x_graphcount;
- if (!x->x_vec) goto bad;
-
- while (n--)
- {
- t_sample f = *in++;
- if (PD_BADFLOAT(f))
- f = 0;
- *dest++ = f;
- }
- if (!i--)
- {
- clock_delay(x->x_clock, 0);
- i = x->x_graphperiod;
- }
- x->x_graphcount = i;
-bad:
- return (w+4);
-}
-
-static void tabsend_dsp(t_tabsend *x, t_signal **sp)
-{
- int i, vecsize;
- t_garray *a;
-
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*x->x_arrayname->s_name)
- error("tabsend~: %s: no such array", x->x_arrayname->s_name);
- }
- else if (!garray_getfloatarray(a, &vecsize, &x->x_vec))
- error("%s: bad template for tabsend~", x->x_arrayname->s_name);
- else
- {
- int n = sp[0]->s_n;
- int ticksper = sp[0]->s_sr/n;
- if (ticksper < 1) ticksper = 1;
- x->x_graphperiod = ticksper;
- if (x->x_graphcount > ticksper) x->x_graphcount = ticksper;
- if (n < vecsize) vecsize = n;
- garray_usedindsp(a);
- dsp_add(tabsend_perform, 3, x, sp[0]->s_vec, vecsize);
- }
-}
-
-static void tabsend_tick(t_tabsend *x)
-{
- t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class);
- if (!a) bug("tabsend_tick");
- else garray_redraw(a);
-}
-
-static void tabsend_free(t_tabsend *x)
-{
- clock_free(x->x_clock);
-}
-
-void tabsend_tilde_setup(void)
-{
- tabsend_class = class_new(gensym("tabsend~"), (t_newmethod)tabsend_new,
- (t_method)tabsend_free, sizeof(t_tabsend), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabsend_class, t_tabsend, x_f);
- class_addmethod(tabsend_class, (t_method)tabsend_dsp, gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/tabwrite.c b/apps/plugins/pdbox/PDa/intern/tabwrite.c
index 8d6a6c0da8..ff4e40d042 100644
--- a/apps/plugins/pdbox/PDa/intern/tabwrite.c
+++ b/apps/plugins/pdbox/PDa/intern/tabwrite.c
@@ -82,87 +82,4 @@ void tabwrite_setup(void)
class_addfloat(tabwrite_class, (t_method)tabwrite_float);
class_addmethod(tabwrite_class, (t_method)tabwrite_set, gensym("set"), A_SYMBOL, 0);
}
-#include <m_pd.h>
-/* ------------------ tabwrite: control ------------------------ */
-
-static t_class *tabwrite_class;
-
-typedef struct _tabwrite
-{
- t_object x_obj;
- t_symbol *x_arrayname;
- t_clock *x_clock;
- float x_ft1;
- double x_updtime;
- int x_set;
-} t_tabwrite;
-
-static void tabwrite_tick(t_tabwrite *x)
-{
- t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class);
- if (!a) bug("tabwrite_tick");
- else garray_redraw(a);
- x->x_set = 0;
- x->x_updtime = clock_getsystime();
-}
-static void tabwrite_float(t_tabwrite *x, t_float f)
-{
- int i, vecsize;
- t_garray *a;
- t_sample *vec;
-
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- pd_error(x, "%s: no such array", x->x_arrayname->s_name);
- else if (!garray_getfloatarray(a, &vecsize, &vec))
- pd_error(x, "%s: bad template for tabwrite", x->x_arrayname->s_name);
- else
- {
- int n = x->x_ft1;
- double timesince = clock_gettimesince(x->x_updtime);
- if (n < 0) n = 0;
- else if (n >= vecsize) n = vecsize-1;
- vec[n] = ftofix(f);
- if (timesince > 1000)
- {
- tabwrite_tick(x);
- }
- else
- {
- if (x->x_set == 0)
- {
- clock_delay(x->x_clock, 1000 - timesince);
- x->x_set = 1;
- }
- }
- }
-}
-
-static void tabwrite_set(t_tabwrite *x, t_symbol *s)
-{
- x->x_arrayname = s;
-}
-
-static void tabwrite_free(t_tabwrite *x)
-{
- clock_free(x->x_clock);
-}
-
-static void *tabwrite_new(t_symbol *s)
-{
- t_tabwrite *x = (t_tabwrite *)pd_new(tabwrite_class);
- x->x_ft1 = 0;
- x->x_arrayname = s;
- x->x_updtime = clock_getsystime();
- x->x_clock = clock_new(x, (t_method)tabwrite_tick);
- floatinlet_new(&x->x_obj, &x->x_ft1);
- return (x);
-}
-
-void tabwrite_setup(void)
-{
- tabwrite_class = class_new(gensym("tabwrite"), (t_newmethod)tabwrite_new,
- (t_method)tabwrite_free, sizeof(t_tabwrite), 0, A_DEFSYM, 0);
- class_addfloat(tabwrite_class, (t_method)tabwrite_float);
- class_addmethod(tabwrite_class, (t_method)tabwrite_set, gensym("set"), A_SYMBOL, 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/tabwrite~.c b/apps/plugins/pdbox/PDa/intern/tabwrite~.c
index 47a49cd833..6f9113c30c 100644
--- a/apps/plugins/pdbox/PDa/intern/tabwrite~.c
+++ b/apps/plugins/pdbox/PDa/intern/tabwrite~.c
@@ -131,134 +131,3 @@ void tabwrite_tilde_setup(void)
class_addfloat(tabwrite_tilde_class, tabwrite_tilde_float);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *tabwrite_tilde_class;
-
-typedef struct _tabwrite_tilde
-{
- t_object x_obj;
- int x_phase;
- int x_nsampsintab;
- t_sample *x_vec;
- t_symbol *x_arrayname;
- t_clock *x_clock;
- float x_f;
-} t_tabwrite_tilde;
-
-static void tabwrite_tilde_tick(t_tabwrite_tilde *x);
-
-static void *tabwrite_tilde_new(t_symbol *s)
-{
- t_tabwrite_tilde *x = (t_tabwrite_tilde *)pd_new(tabwrite_tilde_class);
- x->x_clock = clock_new(x, (t_method)tabwrite_tilde_tick);
- x->x_phase = 0x7fffffff;
- x->x_arrayname = s;
- x->x_f = 0;
- return (x);
-}
-
-static t_int *tabwrite_tilde_perform(t_int *w)
-{
- t_tabwrite_tilde *x = (t_tabwrite_tilde *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- int n = (int)(w[3]), phase = x->x_phase, endphase = x->x_nsampsintab;
- if (!x->x_vec) goto bad;
-
- if (endphase > phase)
- {
- int nxfer = endphase - phase;
- t_sample *fp = x->x_vec + phase;
- if (nxfer > n) nxfer = n;
- phase += nxfer;
- while (nxfer--)
- {
- t_sample f = *in++;
- *fp++ = f;
- }
- if (phase >= endphase)
- {
- clock_delay(x->x_clock, 0);
- phase = 0x7fffffff;
- }
- x->x_phase = phase;
- }
-bad:
- return (w+4);
-}
-
-void tabwrite_tilde_set(t_tabwrite_tilde *x, t_symbol *s)
-{
- t_garray *a;
-
- x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name) pd_error(x, "tabwrite~: %s: no such array",
- x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec))
- {
- error("%s: bad template for tabwrite~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else garray_usedindsp(a);
-}
-
-static void tabwrite_tilde_dsp(t_tabwrite_tilde *x, t_signal **sp)
-{
- tabwrite_tilde_set(x, x->x_arrayname);
- dsp_add(tabwrite_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
-}
-
-static void tabwrite_tilde_bang(t_tabwrite_tilde *x)
-{
- x->x_phase = 0;
-}
-
-static void tabwrite_tilde_float(t_tabwrite_tilde *x,t_float n)
-{
- if (n < x->x_nsampsintab)
- x->x_phase = n;
- else
- x->x_phase = 0;
-}
-
-static void tabwrite_tilde_stop(t_tabwrite_tilde *x)
-{
- if (x->x_phase != 0x7fffffff)
- {
- tabwrite_tilde_tick(x);
- x->x_phase = 0x7fffffff;
- }
-}
-
-static void tabwrite_tilde_tick(t_tabwrite_tilde *x)
-{
- t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class);
- if (!a) bug("tabwrite_tilde_tick");
- else garray_redraw(a);
-}
-
-static void tabwrite_tilde_free(t_tabwrite_tilde *x)
-{
- clock_free(x->x_clock);
-}
-
-void tabwrite_tilde_setup(void)
-{
- tabwrite_tilde_class = class_new(gensym("tabwrite~"),
- (t_newmethod)tabwrite_tilde_new, (t_method)tabwrite_tilde_free,
- sizeof(t_tabwrite_tilde), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabwrite_tilde_class, t_tabwrite_tilde, x_f);
- class_addmethod(tabwrite_tilde_class, (t_method)tabwrite_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabwrite_tilde_class, (t_method)tabwrite_tilde_set,
- gensym("set"), A_SYMBOL, 0);
- class_addmethod(tabwrite_tilde_class, (t_method)tabwrite_tilde_stop,
- gensym("stop"), 0);
- class_addbang(tabwrite_tilde_class, tabwrite_tilde_bang);
- class_addfloat(tabwrite_tilde_class, tabwrite_tilde_float);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/threshold~.c b/apps/plugins/pdbox/PDa/intern/threshold~.c
index 78b15f7342..2b8fcf8629 100644
--- a/apps/plugins/pdbox/PDa/intern/threshold~.c
+++ b/apps/plugins/pdbox/PDa/intern/threshold~.c
@@ -133,138 +133,4 @@ void threshold_tilde_setup( void)
class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_dsp,
gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-static t_class *threshold_tilde_class;
-
-typedef struct _threshold_tilde
-{
- t_object x_obj;
- t_outlet *x_outlet1; /* bang out for high thresh */
- t_outlet *x_outlet2; /* bang out for low thresh */
- t_clock *x_clock; /* wakeup for message output */
- float x_f; /* scalar inlet */
- int x_state; /* 1 = high, 0 = low */
- t_sample x_hithresh; /* value of high threshold */
- t_sample x_lothresh; /* value of low threshold */
- float x_deadwait; /* msec remaining in dead period */
- float x_msecpertick; /* msec per DSP tick */
- float x_hideadtime; /* hi dead time in msec */
- float x_lodeadtime; /* lo dead time in msec */
-} t_threshold_tilde;
-
-static void threshold_tilde_tick(t_threshold_tilde *x);
-static void threshold_tilde_set(t_threshold_tilde *x,
- t_floatarg hithresh, t_floatarg hideadtime,
- t_floatarg lothresh, t_floatarg lodeadtime);
-
-static t_threshold_tilde *threshold_tilde_new(t_floatarg hithresh,
- t_floatarg hideadtime, t_floatarg lothresh, t_floatarg lodeadtime)
-{
- t_threshold_tilde *x = (t_threshold_tilde *)
- pd_new(threshold_tilde_class);
- x->x_state = 0; /* low state */
- x->x_deadwait = 0; /* no dead time */
- x->x_clock = clock_new(x, (t_method)threshold_tilde_tick);
- x->x_outlet1 = outlet_new(&x->x_obj, &s_bang);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_bang);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- x->x_msecpertick = 0.;
- x->x_f = 0;
- threshold_tilde_set(x, hithresh, hideadtime, lothresh, lodeadtime);
- return (x);
-}
-
- /* "set" message to specify thresholds and dead times */
-static void threshold_tilde_set(t_threshold_tilde *x,
- t_floatarg hithresh, t_floatarg hideadtime,
- t_floatarg lothresh, t_floatarg lodeadtime)
-{
- if (lothresh > hithresh)
- lothresh = hithresh;
- x->x_hithresh = ftofix(hithresh);
- x->x_hideadtime = hideadtime;
- x->x_lothresh = ftofix(lothresh);
- x->x_lodeadtime = lodeadtime;
-}
-
- /* number in inlet sets state -- note incompatible with JMAX which used
- "int" message for this, impossible here because of auto signal conversion */
-static void threshold_tilde_ft1(t_threshold_tilde *x, t_floatarg f)
-{
- x->x_state = (f != 0);
- x->x_deadwait = 0;
-}
-
-static void threshold_tilde_tick(t_threshold_tilde *x)
-{
- if (x->x_state)
- outlet_bang(x->x_outlet1);
- else outlet_bang(x->x_outlet2);
-}
-static t_int *threshold_tilde_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_threshold_tilde *x = (t_threshold_tilde *)(w[2]);
- int n = (t_int)(w[3]);
- if (x->x_deadwait > 0)
- x->x_deadwait -= x->x_msecpertick;
- else if (x->x_state)
- {
- /* we're high; look for low sample */
- for (; n--; in1++)
- {
- if (*in1 < x->x_lothresh)
- {
- clock_delay(x->x_clock, 0L);
- x->x_state = 0;
- x->x_deadwait = x->x_lodeadtime;
- goto done;
- }
- }
- }
- else
- {
- /* we're low; look for high sample */
- for (; n--; in1++)
- {
- if (*in1 >= x->x_hithresh)
- {
- clock_delay(x->x_clock, 0L);
- x->x_state = 1;
- x->x_deadwait = x->x_hideadtime;
- goto done;
- }
- }
- }
-done:
- return (w+4);
-}
-
-void threshold_tilde_dsp(t_threshold_tilde *x, t_signal **sp)
-{
- x->x_msecpertick = 1000. * sp[0]->s_n / sp[0]->s_sr;
- dsp_add(threshold_tilde_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
-}
-
-static void threshold_tilde_ff(t_threshold_tilde *x)
-{
- clock_free(x->x_clock);
-}
-
-void threshold_tilde_setup( void)
-{
- threshold_tilde_class = class_new(gensym("threshold~"),
- (t_newmethod)threshold_tilde_new, (t_method)threshold_tilde_ff,
- sizeof(t_threshold_tilde), 0,
- A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(threshold_tilde_class, t_threshold_tilde, x_f);
- class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_set,
- gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_dsp,
- gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/vcf~.c b/apps/plugins/pdbox/PDa/intern/vcf~.c
index 1ff09812a1..e78993a567 100644
--- a/apps/plugins/pdbox/PDa/intern/vcf~.c
+++ b/apps/plugins/pdbox/PDa/intern/vcf~.c
@@ -117,122 +117,3 @@ void vcf_tilde_setup(void)
class_sethelpsymbol(sigvcf_class, gensym("lop~-help.pd"));
}
-#include <m_pd.h>
-#include <m_fixed.h>
-#include "cos_table.h"
-
-/* ---------------- vcf~ - 2-pole bandpass filter. ----------------- */
-/* GG: complex resonator with signal frequency control
- this time using the bigger cos_table without interpolation
- really have to switch to a separate fixpoint format sometime
-*/
-
-typedef struct vcfctl
-{
- t_sample c_re;
- t_sample c_im;
- t_sample c_q;
- t_sample c_isr;
-} t_vcfctl;
-
-typedef struct sigvcf
-{
- t_object x_obj;
- t_vcfctl x_cspace;
- t_vcfctl *x_ctl;
- float x_f;
-} t_sigvcf;
-
-t_class *sigvcf_class;
-
-static void *sigvcf_new(t_floatarg q)
-{
- t_sigvcf *x = (t_sigvcf *)pd_new(sigvcf_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- outlet_new(&x->x_obj, gensym("signal"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_re = 0;
- x->x_cspace.c_im = 0;
- x->x_cspace.c_q = ftofix(q);
- x->x_cspace.c_isr = 0;
- x->x_f = 0;
- return (x);
-}
-
-static void sigvcf_ft1(t_sigvcf *x, t_floatarg f)
-{
- x->x_ctl->c_q = (f > 0 ? ftofix(f) : 0);
-}
-
-static t_int *sigvcf_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out1 = (t_sample *)(w[3]);
- t_sample *out2 = (t_sample *)(w[4]);
- t_vcfctl *c = (t_vcfctl *)(w[5]);
- int n = (t_int)(w[6]);
- int i;
- t_sample re = c->c_re, re2;
- t_sample im = c->c_im;
- t_sample q = c->c_q;
- t_sample qinv = (q > 0 ? idiv(ftofix(1.0),q) : 0);
- t_sample ampcorrect = ftofix(2.0f) - idiv(ftofix(2.0f) , (q + ftofix(2.0f)));
- t_sample isr = c->c_isr;
- t_sample coefr, coefi;
- t_sample *tab = cos_table;
- t_sample oneminusr,cfindx,cf,r;
-
- for (i = 0; i < n; i++)
- {
- cf = mult(*in2++,isr);
- if (cf < 0) cf = 0;
- cfindx = mult(cf,ftofix(0.15915494))>>(fix1-ILOGCOSTABSIZE); /* 1/2*PI */
- r = (qinv > 0 ? ftofix(1.01) - mult(cf,qinv) : 0);
-
- if (r < 0) r = 0;
- oneminusr = ftofix(1.02f) - r; /* hand adapted */
-
- /* r*cos(cf) */
- coefr = mult(r,tab[cfindx]);
-
- /* r*sin(cf) */
- cfindx-=(ICOSTABSIZE>>2);
- cfindx += cfindx < 0 ? ICOSTABSIZE:0;
- coefi = mult(r,tab[cfindx]);
-
- re2 = re;
- *out1++ = re = mult(ampcorrect,mult(oneminusr,*in1++))
- + mult(coefr,re2) - mult(coefi, im);
- *out2++ = im = mult(coefi,re2) + mult(coefr,im);
- }
- c->c_re = re;
- c->c_im = im;
- return (w+7);
-}
-
-static void sigvcf_dsp(t_sigvcf *x, t_signal **sp)
-{
- /* TODO sr is hardcoded */
- x->x_ctl->c_isr = ftofix(0.0001424758);
-// idiv(ftofix(6.28318),ftofix(sp[0]->s_sr));
- post("%f",fixtof(x->x_ctl->c_isr));
- dsp_add(sigvcf_perform, 6,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-void vcf_tilde_setup(void)
-{
- sigvcf_class = class_new(gensym("vcf~"), (t_newmethod)sigvcf_new, 0,
- sizeof(t_sigvcf), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(sigvcf_class, t_sigvcf, x_f);
- class_addmethod(sigvcf_class, (t_method)sigvcf_dsp, gensym("dsp"), 0);
- class_addmethod(sigvcf_class, (t_method)sigvcf_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_sethelpsymbol(sigvcf_class, gensym("lop~-help.pd"));
-}
-
diff --git a/apps/plugins/pdbox/PDa/intern/vd~.c b/apps/plugins/pdbox/PDa/intern/vd~.c
index 2c68b27e25..471df56753 100644
--- a/apps/plugins/pdbox/PDa/intern/vd~.c
+++ b/apps/plugins/pdbox/PDa/intern/vd~.c
@@ -90,95 +90,4 @@ void vd_tilde_setup(void)
class_addmethod(sigvd_class, (t_method)sigvd_dsp, gensym("dsp"), 0);
CLASS_MAINSIGNALIN(sigvd_class, t_sigvd, x_f);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-#include "delay.h"
-
-extern int ugen_getsortno(void);
-
-#define DEFDELVS 64 /* LATER get this from canvas at DSP time */
-static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */
-
-static t_class *sigvd_class;
-
-typedef struct _sigvd
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_sample x_sr; /* samples per msec */
- int x_zerodel; /* 0 or vecsize depending on read/write order */
- float x_f;
-} t_sigvd;
-
-static void *sigvd_new(t_symbol *s)
-{
- t_sigvd *x = (t_sigvd *)pd_new(sigvd_class);
- if (!*s->s_name) s = gensym("vd~");
- x->x_sym = s;
- x->x_sr = 1;
- x->x_zerodel = 0;
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigvd_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- t_delwritectl *ctl = (t_delwritectl *)(w[3]);
- t_sigvd *x = (t_sigvd *)(w[4]);
- int n = (int)(w[5]);
-
- int nsamps = ctl->c_n;
- int fn = n;
- t_sample limit = nsamps - n - 1;
- t_sample *vp = ctl->c_vec, *bp, *wp = vp + ctl->c_phase;
- t_sample zerodel = x->x_zerodel;
- while (n--)
- {
- t_time delsamps = ((long long) mult((*in++),ftofix(44.1)));//- itofix(zerodel);
- int index = fixtoi(delsamps);
- t_sample frac;
- // post("%d: index %d f %lld",index,findex,*in);
-
- frac = delsamps - itofix(index);
- index+=fn;
- if (index < 1 ) index += nsamps ;
- if (index > limit) index-= nsamps;
- bp = wp - index;
- if (bp < vp + 2) bp += nsamps;
- *out++ = bp[-1] + mult(frac,bp[-1]-bp[0]);
- wp++;
- }
- return (w+6);
-}
-
-
-
-static void sigvd_dsp(t_sigvd *x, t_signal **sp)
-{
- t_sigdelwrite *delwriter =
- (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
- x->x_sr = sp[0]->s_sr * 0.001;
- if (delwriter)
- {
- sigdelwrite_checkvecsize(delwriter, sp[0]->s_n);
- x->x_zerodel = (delwriter->x_sortno == ugen_getsortno() ?
- 0 : delwriter->x_vecsize);
- dsp_add(sigvd_perform, 5,
- sp[0]->s_vec, sp[1]->s_vec,
- &delwriter->x_cspace, x, sp[0]->s_n);
- }
- else error("vd~: %s: no such delwrite~",x->x_sym->s_name);
-}
-
-void vd_tilde_setup(void)
-{
- sigvd_class = class_new(gensym("vd~"), (t_newmethod)sigvd_new, 0,
- sizeof(t_sigvd), 0, A_DEFSYM, 0);
- class_addmethod(sigvd_class, (t_method)sigvd_dsp, gensym("dsp"), 0);
- CLASS_MAINSIGNALIN(sigvd_class, t_sigvd, x_f);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/vline~.c b/apps/plugins/pdbox/PDa/intern/vline~.c
index 74edb83bc6..15f0d1793e 100644
--- a/apps/plugins/pdbox/PDa/intern/vline~.c
+++ b/apps/plugins/pdbox/PDa/intern/vline~.c
@@ -182,187 +182,4 @@ void vline_tilde_setup(void)
class_addmethod(vline_tilde_class, (t_method)vline_tilde_stop,
gensym("stop"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-
-
-static t_class *vline_tilde_class;
-
-typedef struct _vseg
-{
- t_time s_targettime;
- t_time s_starttime;
- t_sample s_target;
- struct _vseg *s_next;
-} t_vseg;
-
-typedef struct _vline
-{
- t_object x_obj;
- t_sample x_value;
- t_sample x_inc;
- t_time x_referencetime;
- t_time x_samppermsec;
- t_time x_msecpersamp;
- t_time x_targettime;
- t_sample x_target;
- float x_inlet1;
- float x_inlet2;
- t_vseg *x_list;
-} t_vline;
-
-static t_int *vline_tilde_perform(t_int *w)
-{
- t_vline *x = (t_vline *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = (int)(w[3]), i;
- t_sample f = x->x_value;
- t_sample inc = x->x_inc;
- t_time msecpersamp = x->x_msecpersamp;
- t_time samppermsec = x->x_samppermsec;
- t_time timenow = clock_gettimesince(x->x_referencetime) - n * msecpersamp;
- t_vseg *s = x->x_list;
- for (i = 0; i < n; i++)
- {
- t_time timenext = timenow + msecpersamp;
- checknext:
- if (s)
- {
- /* has starttime elapsed? If so update value and increment */
- if (s->s_starttime < timenext)
- {
- if (x->x_targettime <= timenext)
- f = x->x_target, inc = 0;
- /* if zero-length segment bash output value */
- if (s->s_targettime <= s->s_starttime)
- {
- f = s->s_target;
- inc = 0;
- }
- else
- {
- t_time incpermsec = div((s->s_target - f),
- (s->s_targettime - s->s_starttime));
- f = mult(f + incpermsec,(timenext - s->s_starttime));
- inc = mult(incpermsec,msecpersamp);
- }
- x->x_inc = inc;
- x->x_target = s->s_target;
- x->x_targettime = s->s_targettime;
- x->x_list = s->s_next;
- t_freebytes(s, sizeof(*s));
- s = x->x_list;
- goto checknext;
- }
- }
- if (x->x_targettime <= timenext)
- f = x->x_target, inc = 0;
- *out++ = f;
- f = f + inc;
- timenow = timenext;
- }
- x->x_value = f;
- return (w+4);
-}
-static void vline_tilde_stop(t_vline *x)
-{
- t_vseg *s1, *s2;
- for (s1 = x->x_list; s1; s1 = s2)
- s2 = s1->s_next, t_freebytes(s1, sizeof(*s1));
- x->x_list = 0;
- x->x_inc = 0;
- x->x_inlet1 = x->x_inlet2 = 0;
-}
-
-static void vline_tilde_float(t_vline *x, t_float f)
-{
- t_time timenow = clock_gettimesince(x->x_referencetime);
- t_sample inlet1 = (x->x_inlet1 < 0 ? 0 : (t_sample)x->x_inlet1);
- t_sample inlet2 = (t_sample) x->x_inlet2;
- t_time starttime = timenow + inlet2;
- t_vseg *s1, *s2, *deletefrom = 0,
- *snew = (t_vseg *)t_getbytes(sizeof(*snew));
- if (PD_BADFLOAT(f))
- f = 0;
-
- /* negative delay input means stop and jump immediately to new value */
- if (inlet2 < 0)
- {
- vline_tilde_stop(x);
- x->x_value = ftofix(f);
- return;
- }
- /* check if we supplant the first item in the list. We supplant
- an item by having an earlier starttime, or an equal starttime unless
- the equal one was instantaneous and the new one isn't (in which case
- we'll do a jump-and-slide starting at that time.) */
- if (!x->x_list || x->x_list->s_starttime > starttime ||
- (x->x_list->s_starttime == starttime &&
- (x->x_list->s_targettime > x->x_list->s_starttime || inlet1 <= 0)))
- {
- deletefrom = x->x_list;
- x->x_list = snew;
- }
- else
- {
- for (s1 = x->x_list; s2 = s1->s_next; s1 = s2)
- {
- if (s2->s_starttime > starttime ||
- (s2->s_starttime == starttime &&
- (s2->s_targettime > s2->s_starttime || inlet1 <= 0)))
- {
- deletefrom = s2;
- s1->s_next = snew;
- goto didit;
- }
- }
- s1->s_next = snew;
- deletefrom = 0;
- didit: ;
- }
- while (deletefrom)
- {
- s1 = deletefrom->s_next;
- t_freebytes(deletefrom, sizeof(*deletefrom));
- deletefrom = s1;
- }
- snew->s_next = 0;
- snew->s_target = f;
- snew->s_starttime = starttime;
- snew->s_targettime = starttime + inlet1;
- x->x_inlet1 = x->x_inlet2 = 0;
-}
-
-static void vline_tilde_dsp(t_vline *x, t_signal **sp)
-{
- dsp_add(vline_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
- x->x_samppermsec = idiv(ftofix(sp[0]->s_sr),ftofix(1000));
- x->x_msecpersamp = idiv(ftofix(1000),ftofix(sp[0]->s_sr));
-}
-
-static void *vline_tilde_new(void)
-{
- t_vline *x = (t_vline *)pd_new(vline_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- floatinlet_new(&x->x_obj, &x->x_inlet1);
- floatinlet_new(&x->x_obj, &x->x_inlet2);
- x->x_inlet1 = x->x_inlet2 = 0;
- x->x_value = x->x_inc = 0;
- x->x_referencetime = clock_getlogicaltime();
- x->x_list = 0;
- x->x_samppermsec = 0;
- return (x);
-}
-
-void vline_tilde_setup(void)
-{
- vline_tilde_class = class_new(gensym("vline~"), vline_tilde_new,
- (t_method)vline_tilde_stop, sizeof(t_vline), 0, 0);
- class_addfloat(vline_tilde_class, (t_method)vline_tilde_float);
- class_addmethod(vline_tilde_class, (t_method)vline_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(vline_tilde_class, (t_method)vline_tilde_stop,
- gensym("stop"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/intern/vsnapshot~.c b/apps/plugins/pdbox/PDa/intern/vsnapshot~.c
index afa9417248..282a6f21f8 100644
--- a/apps/plugins/pdbox/PDa/intern/vsnapshot~.c
+++ b/apps/plugins/pdbox/PDa/intern/vsnapshot~.c
@@ -86,91 +86,3 @@ void vsnapshot_tilde_setup(void)
class_addbang(vsnapshot_tilde_class, vsnapshot_tilde_bang);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-
-static t_class *vsnapshot_tilde_class;
-
-typedef struct _vsnapshot
-{
- t_object x_obj;
- int x_n;
- int x_gotone;
- t_sample *x_vec;
- float x_f;
- float x_sampspermsec;
- double x_time;
-} t_vsnapshot;
-
-static void *vsnapshot_tilde_new(void)
-{
- t_vsnapshot *x = (t_vsnapshot *)pd_new(vsnapshot_tilde_class);
- outlet_new(&x->x_obj, &s_float);
- x->x_f = 0;
- x->x_n = 0;
- x->x_vec = 0;
- x->x_gotone = 0;
- return (x);
-}
-
-static t_int *vsnapshot_tilde_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_vsnapshot *x = (t_vsnapshot *)(w[2]);
- t_sample *out = x->x_vec;
- int n = x->x_n, i;
- for (i = 0; i < n; i++)
- out[i] = in[i];
- x->x_time = clock_getlogicaltime();
- x->x_gotone = 1;
- return (w+3);
-}
-
-static void vsnapshot_tilde_dsp(t_vsnapshot *x, t_signal **sp)
-{
- int n = sp[0]->s_n;
- if (n != x->x_n)
- {
- if (x->x_vec)
- t_freebytes(x->x_vec, x->x_n * sizeof(t_sample));
- x->x_vec = (t_sample *)getbytes(n * sizeof(t_sample));
- x->x_gotone = 0;
- x->x_n = n;
- }
- x->x_sampspermsec = sp[0]->s_sr / 1000;
- dsp_add(vsnapshot_tilde_perform, 2, sp[0]->s_vec, x);
-}
-
-static void vsnapshot_tilde_bang(t_vsnapshot *x)
-{
- float val;
- if (x->x_gotone)
- {
- int indx = clock_gettimesince(x->x_time) * x->x_sampspermsec;
- if (indx < 0)
- indx = 0;
- else if (indx >= x->x_n)
- indx = x->x_n - 1;
- val = x->x_vec[indx];
- }
- else val = 0;
- outlet_float(x->x_obj.ob_outlet, val);
-}
-
-static void vsnapshot_tilde_ff(t_vsnapshot *x)
-{
- if (x->x_vec)
- t_freebytes(x->x_vec, x->x_n * sizeof(t_sample));
-}
-
-void vsnapshot_tilde_setup(void)
-{
- vsnapshot_tilde_class = class_new(gensym("vsnapshot~"),
- vsnapshot_tilde_new, (t_method)vsnapshot_tilde_ff,
- sizeof(t_vsnapshot), 0, 0);
- CLASS_MAINSIGNALIN(vsnapshot_tilde_class, t_vsnapshot, x_f);
- class_addmethod(vsnapshot_tilde_class, (t_method)vsnapshot_tilde_dsp, gensym("dsp"), 0);
- class_addbang(vsnapshot_tilde_class, vsnapshot_tilde_bang);
-}
-
diff --git a/apps/plugins/pdbox/PDa/intern/wrap~.c b/apps/plugins/pdbox/PDa/intern/wrap~.c
index dda79f2fcd..c011babdfc 100644
--- a/apps/plugins/pdbox/PDa/intern/wrap~.c
+++ b/apps/plugins/pdbox/PDa/intern/wrap~.c
@@ -51,54 +51,3 @@ void wrap_tilde_setup(void)
class_addmethod(sigwrap_class, (t_method)sigwrap_dsp, gensym("dsp"), 0);
}
-#include <m_pd.h>
-#include <m_fixed.h>
-
-typedef struct wrap
-{
- t_object x_obj;
- float x_f;
-} t_sigwrap;
-
-t_class *sigwrap_class;
-
-static void *sigwrap_new(void)
-{
- t_sigwrap *x = (t_sigwrap *)pd_new(sigwrap_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigwrap_perform(t_int *w)
-{
- t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2);
- t_int n = *(t_int *)(w+3);
- while (n--)
- {
- t_sample f = *in++;
-
-#ifndef FIXEDPOINT
- int k = f;
- if (f > 0) *out++ = f-k;
- else *out++ = f - (k-1);
-#else
- int k = ftofix(1.) - 1;
- *out = f&k;
-#endif
- }
- return (w + 4);
-}
-
-static void sigwrap_dsp(t_sigwrap *x, t_signal **sp)
-{
- dsp_add(sigwrap_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void wrap_tilde_setup(void)
-{
- sigwrap_class = class_new(gensym("wrap~"), (t_newmethod)sigwrap_new, 0,
- sizeof(t_sigwrap), 0, 0);
- CLASS_MAINSIGNALIN(sigwrap_class, t_sigwrap, x_f);
- class_addmethod(sigwrap_class, (t_method)sigwrap_dsp, gensym("dsp"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/src/build.ipod b/apps/plugins/pdbox/PDa/src/build.ipod
index bb78632b2d..5d940bf56e 100644
--- a/apps/plugins/pdbox/PDa/src/build.ipod
+++ b/apps/plugins/pdbox/PDa/src/build.ipod
@@ -4,7 +4,3 @@
make CFLAGS="-O6 -ffast-math -fexpensive-optimizations -mcpu=arm7tdmi " -k ipod
make CFLAGS="-O2 -ffast-math -fexpensive-optimizations -mcpu=arm7tdmi" ipod
-# The compiler for iPod has a bug with -O6, thats why we try to compile twice
-
-make CFLAGS="-O6 -ffast-math -fexpensive-optimizations -mcpu=arm7tdmi " -k ipod
-make CFLAGS="-O2 -ffast-math -fexpensive-optimizations -mcpu=arm7tdmi" ipod
diff --git a/apps/plugins/pdbox/PDa/src/d_arithmetic.c b/apps/plugins/pdbox/PDa/src/d_arithmetic.c
index 72404ba50d..30744882f4 100644
--- a/apps/plugins/pdbox/PDa/src/d_arithmetic.c
+++ b/apps/plugins/pdbox/PDa/src/d_arithmetic.c
@@ -840,845 +840,3 @@ void d_arithmetic_setup(void)
min_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* arithmetic binops (+, -, *, /).
-If no creation argument is given, there are two signal inlets for vector/vector
-operation; otherwise it's vector/scalar and the second inlet takes a float
-to reset the value.
-*/
-
-#include "m_pd.h"
-
-/* ----------------------------- plus ----------------------------- */
-static t_class *plus_class, *scalarplus_class;
-
-typedef struct _plus
-{
- t_object x_obj;
- float x_f;
-} t_plus;
-
-typedef struct _scalarplus
-{
- t_object x_obj;
- float x_f;
- t_float x_g; /* inlet value */
-} t_scalarplus;
-
-static void *plus_new(t_symbol *s, int argc, t_atom *argv)
-{
- if (argc > 1) post("+~: extra arguments ignored");
- if (argc)
- {
- t_scalarplus *x = (t_scalarplus *)pd_new(scalarplus_class);
- floatinlet_new(&x->x_obj, &x->x_g);
- x->x_g = atom_getfloatarg(0, argc, argv);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
- else
- {
- t_plus *x = (t_plus *)pd_new(plus_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
-}
-
-t_int *plus_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--) *out++ = *in1++ + *in2++;
- return (w+5);
-}
-
-t_int *plus_perf8(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
- {
- t_sample f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
- t_sample f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
-
- t_sample g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
- t_sample g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
-
- out[0] = f0 + g0; out[1] = f1 + g1; out[2] = f2 + g2; out[3] = f3 + g3;
- out[4] = f4 + g4; out[5] = f5 + g5; out[6] = f6 + g6; out[7] = f7 + g7;
- }
- return (w+5);
-}
-
-t_int *scalarplus_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample f = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--) *out++ = *in++ + f;
- return (w+5);
-}
-
-t_int *scalarplus_perf8(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample g = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in += 8, out += 8)
- {
- t_sample f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
- t_sample f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
-
- out[0] = f0 + g; out[1] = f1 + g; out[2] = f2 + g; out[3] = f3 + g;
- out[4] = f4 + g; out[5] = f5 + g; out[6] = f6 + g; out[7] = f7 + g;
- }
- return (w+5);
-}
-
-void dsp_add_plus(t_sample *in1, t_sample *in2, t_sample *out, int n)
-{
- if (n&7)
- dsp_add(plus_perform, 4, in1, in2, out, n);
- else
- dsp_add(plus_perf8, 4, in1, in2, out, n);
-}
-
-static void plus_dsp(t_plus *x, t_signal **sp)
-{
- dsp_add_plus(sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
-}
-
-static void scalarplus_dsp(t_scalarplus *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(scalarplus_perform, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
- else
- dsp_add(scalarplus_perf8, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void plus_setup(void)
-{
- plus_class = class_new(gensym("+~"), (t_newmethod)plus_new, 0,
- sizeof(t_plus), 0, A_GIMME, 0);
- class_addmethod(plus_class, (t_method)plus_dsp, gensym("dsp"), 0);
- CLASS_MAINSIGNALIN(plus_class, t_plus, x_f);
- class_sethelpsymbol(plus_class, gensym("sigbinops"));
- scalarplus_class = class_new(gensym("+~"), 0, 0,
- sizeof(t_scalarplus), 0, 0);
- CLASS_MAINSIGNALIN(scalarplus_class, t_scalarplus, x_f);
- class_addmethod(scalarplus_class, (t_method)scalarplus_dsp, gensym("dsp"),
- 0);
- class_sethelpsymbol(scalarplus_class, gensym("sigbinops"));
-}
-
-/* ----------------------------- minus ----------------------------- */
-static t_class *minus_class, *scalarminus_class;
-
-typedef struct _minus
-{
- t_object x_obj;
- float x_f;
-} t_minus;
-
-typedef struct _scalarminus
-{
- t_object x_obj;
- float x_f;
- t_float x_g;
-} t_scalarminus;
-
-static void *minus_new(t_symbol *s, int argc, t_atom *argv)
-{
- if (argc > 1) post("-~: extra arguments ignored");
- if (argc)
- {
- t_scalarminus *x = (t_scalarminus *)pd_new(scalarminus_class);
- floatinlet_new(&x->x_obj, &x->x_g);
- x->x_g = atom_getfloatarg(0, argc, argv);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
- else
- {
- t_minus *x = (t_minus *)pd_new(minus_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
-}
-
-t_int *minus_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--) *out++ = *in1++ - *in2++;
- return (w+5);
-}
-
-t_int *minus_perf8(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
- {
- t_sample f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
- t_sample f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
-
- t_sample g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
- t_sample g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
-
- out[0] = f0 - g0; out[1] = f1 - g1; out[2] = f2 - g2; out[3] = f3 - g3;
- out[4] = f4 - g4; out[5] = f5 - g5; out[6] = f6 - g6; out[7] = f7 - g7;
- }
- return (w+5);
-}
-
-t_int *scalarminus_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample f = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--) *out++ = *in++ - f;
- return (w+5);
-}
-
-t_int *scalarminus_perf8(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample g = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in += 8, out += 8)
- {
- t_sample f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
- t_sample f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
-
- out[0] = f0 - g; out[1] = f1 - g; out[2] = f2 - g; out[3] = f3 - g;
- out[4] = f4 - g; out[5] = f5 - g; out[6] = f6 - g; out[7] = f7 - g;
- }
- return (w+5);
-}
-
-static void minus_dsp(t_minus *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(minus_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
- else
- dsp_add(minus_perf8, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
-}
-
-static void scalarminus_dsp(t_scalarminus *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(scalarminus_perform, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
- else
- dsp_add(scalarminus_perf8, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void minus_setup(void)
-{
- minus_class = class_new(gensym("-~"), (t_newmethod)minus_new, 0,
- sizeof(t_minus), 0, A_GIMME, 0);
- CLASS_MAINSIGNALIN(minus_class, t_minus, x_f);
- class_addmethod(minus_class, (t_method)minus_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(minus_class, gensym("sigbinops"));
- scalarminus_class = class_new(gensym("-~"), 0, 0,
- sizeof(t_scalarminus), 0, 0);
- CLASS_MAINSIGNALIN(scalarminus_class, t_scalarminus, x_f);
- class_addmethod(scalarminus_class, (t_method)scalarminus_dsp, gensym("dsp"),
- 0);
- class_sethelpsymbol(scalarminus_class, gensym("sigbinops"));
-}
-
-/* ----------------------------- times ----------------------------- */
-
-static t_class *times_class, *scalartimes_class;
-
-typedef struct _times
-{
- t_object x_obj;
- float x_f;
-} t_times;
-
-typedef struct _scalartimes
-{
- t_object x_obj;
- float x_f;
- t_float x_g;
-} t_scalartimes;
-
-static void *times_new(t_symbol *s, int argc, t_atom *argv)
-{
- if (argc > 1) post("*~: extra arguments ignored");
- if (argc)
- {
- t_scalartimes *x = (t_scalartimes *)pd_new(scalartimes_class);
- floatinlet_new(&x->x_obj, &x->x_g);
- x->x_g = atom_getfloatarg(0, argc, argv);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
- else
- {
- t_times *x = (t_times *)pd_new(times_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
-}
-
-t_int *times_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--) *out++ = mult(*in1++,*in2++);
- return (w+5);
-}
-
-t_int *times_perf8(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
- {
- t_sample f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
- t_sample f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
-
- t_sample g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
- t_sample g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
-
- out[0] = mult(f0,g0); out[1] = mult(f1,g1); out[2] = mult(f2,g2); out[3] = mult(f3,g3);
- out[4] = mult(f4,g4); out[5] = mult(f5,g5); out[6] = mult(f6,g6); out[7] = mult(f7,g7);
- }
- return (w+5);
-}
-
-t_int *scalartimes_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample f = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--) *out++ = mult(*in++,f);
- return (w+5);
-}
-
-t_int *scalartimes_perf8(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample g = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in += 8, out += 8)
- {
- t_sample f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
- t_sample f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
-
- out[0] = mult(f0,g); out[1] = mult(f1,g); out[2] = mult(f2,g); out[3] = mult(f3,g);
- out[4] = mult(f4,g); out[5] = mult(f5,g); out[6] = mult(f6,g); out[7] = mult(f7,g);
- }
- return (w+5);
-}
-
-static void times_dsp(t_times *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(times_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
- else
- dsp_add(times_perf8, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
-}
-
-static void scalartimes_dsp(t_scalartimes *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(scalartimes_perform, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
- else
- dsp_add(scalartimes_perf8, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void times_setup(void)
-{
- times_class = class_new(gensym("*~"), (t_newmethod)times_new, 0,
- sizeof(t_times), 0, A_GIMME, 0);
- CLASS_MAINSIGNALIN(times_class, t_times, x_f);
- class_addmethod(times_class, (t_method)times_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(times_class, gensym("sigbinops"));
- scalartimes_class = class_new(gensym("*~"), 0, 0,
- sizeof(t_scalartimes), 0, 0);
- CLASS_MAINSIGNALIN(scalartimes_class, t_scalartimes, x_f);
- class_addmethod(scalartimes_class, (t_method)scalartimes_dsp, gensym("dsp"),
- 0);
- class_sethelpsymbol(scalartimes_class, gensym("sigbinops"));
-}
-
-/* ----------------------------- over ----------------------------- */
-static t_class *over_class, *scalarover_class;
-
-typedef struct _over
-{
- t_object x_obj;
- float x_f;
-} t_over;
-
-typedef struct _scalarover
-{
- t_object x_obj;
- float x_f;
- t_float x_g;
-} t_scalarover;
-
-static void *over_new(t_symbol *s, int argc, t_atom *argv)
-{
- if (argc > 1) post("/~: extra arguments ignored");
- if (argc)
- {
- t_scalarover *x = (t_scalarover *)pd_new(scalarover_class);
- floatinlet_new(&x->x_obj, &x->x_g);
- x->x_g = atom_getfloatarg(0, argc, argv);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
- else
- {
- t_over *x = (t_over *)pd_new(over_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
-}
-
-t_int *over_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--)
- {
- float g = *in2++;
- *out++ = (g ? *in1++ / g : 0);
- }
- return (w+5);
-}
-
-t_int *over_perf8(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
- {
- t_sample f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
- t_sample f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
-
- t_sample g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
- t_sample g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
-
- out[0] = (g0? idiv(f0,g0) : 0);
- out[1] = (g1? idiv(f1,g1) : 0);
- out[2] = (g2? idiv(f2,g2) : 0);
- out[3] = (g3? idiv(f3,g3) : 0);
- out[4] = (g4? idiv(f4,g4) : 0);
- out[5] = (g5? idiv(f5,g5) : 0);
- out[6] = (g6? idiv(f6,g6) : 0);
- out[7] = (g7? idiv(f7,g7) : 0);
- }
- return (w+5);
-}
-
-t_int *scalarover_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample f = idiv(ftofix(1.),ftofix(*(t_float *)(w[2])));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--) *out++ = mult(*in++,f);
- return (w+5);
-}
-
-t_int *scalarover_perf8(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample g = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- if (g) g = idiv(ftofix(1.f),g);
- for (; n; n -= 8, in += 8, out += 8)
- {
- t_sample f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
- t_sample f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
-
- out[0] = mult(f0,g); out[1] = mult(f1,g); out[2] = mult(f2,g); out[3] = mult(f3,g);
- out[4] = mult(f4,g); out[5] = mult(f5,g); out[6] = mult(f6,g); out[7] = mult(f7,g);
- }
- return (w+5);
-}
-
-static void over_dsp(t_over *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(over_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
- else
- dsp_add(over_perf8, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
-}
-
-static void scalarover_dsp(t_scalarover *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(scalarover_perform, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
- else
- dsp_add(scalarover_perf8, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void over_setup(void)
-{
- over_class = class_new(gensym("/~"), (t_newmethod)over_new, 0,
- sizeof(t_over), 0, A_GIMME, 0);
- CLASS_MAINSIGNALIN(over_class, t_over, x_f);
- class_addmethod(over_class, (t_method)over_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(over_class, gensym("sigbinops"));
- scalarover_class = class_new(gensym("/~"), 0, 0,
- sizeof(t_scalarover), 0, 0);
- CLASS_MAINSIGNALIN(scalarover_class, t_scalarover, x_f);
- class_addmethod(scalarover_class, (t_method)scalarover_dsp, gensym("dsp"),
- 0);
- class_sethelpsymbol(scalarover_class, gensym("sigbinops"));
-}
-
-/* ----------------------------- max ----------------------------- */
-static t_class *max_class, *scalarmax_class;
-
-typedef struct _max
-{
- t_object x_obj;
- float x_f;
-} t_max;
-
-typedef struct _scalarmax
-{
- t_object x_obj;
- float x_f;
- t_float x_g;
-} t_scalarmax;
-
-static void *max_new(t_symbol *s, int argc, t_atom *argv)
-{
- if (argc > 1) post("max~: extra arguments ignored");
- if (argc)
- {
- t_scalarmax *x = (t_scalarmax *)pd_new(scalarmax_class);
- floatinlet_new(&x->x_obj, &x->x_g);
- x->x_g = atom_getfloatarg(0, argc, argv);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
- else
- {
- t_max *x = (t_max *)pd_new(max_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
-}
-
-t_int *max_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--)
- {
- t_sample f = *in1++, g = *in2++;
- *out++ = (f > g ? f : g);
- }
- return (w+5);
-}
-
-t_int *max_perf8(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
- {
- t_sample f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
- t_sample f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
-
- t_sample g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
- t_sample g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
-
- out[0] = (f0 > g0 ? f0 : g0); out[1] = (f1 > g1 ? f1 : g1);
- out[2] = (f2 > g2 ? f2 : g2); out[3] = (f3 > g3 ? f3 : g3);
- out[4] = (f4 > g4 ? f4 : g4); out[5] = (f5 > g5 ? f5 : g5);
- out[6] = (f6 > g6 ? f6 : g6); out[7] = (f7 > g7 ? f7 : g7);
- }
- return (w+5);
-}
-
-t_int *scalarmax_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample f = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--)
- {
- t_sample g = *in++;
- *out++ = (f > g ? f : g);
- }
- return (w+5);
-}
-
-t_int *scalarmax_perf8(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample g = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in += 8, out += 8)
- {
- t_sample f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
- t_sample f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
-
- out[0] = (f0 > g ? f0 : g); out[1] = (f1 > g ? f1 : g);
- out[2] = (f2 > g ? f2 : g); out[3] = (f3 > g ? f3 : g);
- out[4] = (f4 > g ? f4 : g); out[5] = (f5 > g ? f5 : g);
- out[6] = (f6 > g ? f6 : g); out[7] = (f7 > g ? f7 : g);
- }
- return (w+5);
-}
-
-static void max_dsp(t_max *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(max_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
- else
- dsp_add(max_perf8, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
-}
-
-static void scalarmax_dsp(t_scalarmax *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(scalarmax_perform, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
- else
- dsp_add(scalarmax_perf8, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void max_setup(void)
-{
- max_class = class_new(gensym("max~"), (t_newmethod)max_new, 0,
- sizeof(t_max), 0, A_GIMME, 0);
- CLASS_MAINSIGNALIN(max_class, t_max, x_f);
- class_addmethod(max_class, (t_method)max_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(max_class, gensym("sigbinops"));
- scalarmax_class = class_new(gensym("max~"), 0, 0,
- sizeof(t_scalarmax), 0, 0);
- CLASS_MAINSIGNALIN(scalarmax_class, t_scalarmax, x_f);
- class_addmethod(scalarmax_class, (t_method)scalarmax_dsp, gensym("dsp"),
- 0);
- class_sethelpsymbol(scalarmax_class, gensym("sigbinops"));
-}
-
-/* ----------------------------- min ----------------------------- */
-static t_class *min_class, *scalarmin_class;
-
-typedef struct _min
-{
- t_object x_obj;
- float x_f;
-} t_min;
-
-typedef struct _scalarmin
-{
- t_object x_obj;
- t_float x_g;
- float x_f;
-} t_scalarmin;
-
-static void *min_new(t_symbol *s, int argc, t_atom *argv)
-{
- if (argc > 1) post("min~: extra arguments ignored");
- if (argc)
- {
- t_scalarmin *x = (t_scalarmin *)pd_new(scalarmin_class);
- floatinlet_new(&x->x_obj, &x->x_g);
- x->x_g = atom_getfloatarg(0, argc, argv);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
- else
- {
- t_min *x = (t_min *)pd_new(min_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
- }
-}
-
-t_int *min_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--)
- {
- t_sample f = *in1++, g = *in2++;
- *out++ = (f < g ? f : g);
- }
- return (w+5);
-}
-
-t_int *min_perf8(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
- {
- t_sample f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
- t_sample f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
-
- t_sample g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
- t_sample g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
-
- out[0] = (f0 < g0 ? f0 : g0); out[1] = (f1 < g1 ? f1 : g1);
- out[2] = (f2 < g2 ? f2 : g2); out[3] = (f3 < g3 ? f3 : g3);
- out[4] = (f4 < g4 ? f4 : g4); out[5] = (f5 < g5 ? f5 : g5);
- out[6] = (f6 < g6 ? f6 : g6); out[7] = (f7 < g7 ? f7 : g7);
- }
- return (w+5);
-}
-
-t_int *scalarmin_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample f = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- while (n--)
- {
- t_sample g = *in++;
- *out++ = (f < g ? f : g);
- }
- return (w+5);
-}
-
-t_int *scalarmin_perf8(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample g = ftofix(*(t_float *)(w[2]));
- t_sample *out = (t_sample *)(w[3]);
- int n = (int)(w[4]);
- for (; n; n -= 8, in += 8, out += 8)
- {
- t_sample f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
- t_sample f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
-
- out[0] = (f0 < g ? f0 : g); out[1] = (f1 < g ? f1 : g);
- out[2] = (f2 < g ? f2 : g); out[3] = (f3 < g ? f3 : g);
- out[4] = (f4 < g ? f4 : g); out[5] = (f5 < g ? f5 : g);
- out[6] = (f6 < g ? f6 : g); out[7] = (f7 < g ? f7 : g);
- }
- return (w+5);
-}
-
-static void min_dsp(t_min *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(min_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
- else
- dsp_add(min_perf8, 4,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
-}
-
-static void scalarmin_dsp(t_scalarmin *x, t_signal **sp)
-{
- if (sp[0]->s_n&7)
- dsp_add(scalarmin_perform, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
- else
- dsp_add(scalarmin_perf8, 4, sp[0]->s_vec, &x->x_g,
- sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void min_setup(void)
-{
- min_class = class_new(gensym("min~"), (t_newmethod)min_new, 0,
- sizeof(t_min), 0, A_GIMME, 0);
- CLASS_MAINSIGNALIN(min_class, t_min, x_f);
- class_addmethod(min_class, (t_method)min_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(min_class, gensym("sigbinops"));
- scalarmin_class = class_new(gensym("min~"), 0, 0,
- sizeof(t_scalarmin), 0, 0);
- CLASS_MAINSIGNALIN(scalarmin_class, t_scalarmin, x_f);
- class_addmethod(scalarmin_class, (t_method)scalarmin_dsp, gensym("dsp"),
- 0);
- class_sethelpsymbol(scalarmin_class, gensym("sigbinops"));
-}
-
-/* ----------------------- global setup routine ---------------- */
-void d_arithmetic_setup(void)
-{
- plus_setup();
- minus_setup();
- times_setup();
- over_setup();
- max_setup();
- min_setup();
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/d_array.c b/apps/plugins/pdbox/PDa/src/d_array.c
index 14ae464b0b..7139e4dc3d 100644
--- a/apps/plugins/pdbox/PDa/src/d_array.c
+++ b/apps/plugins/pdbox/PDa/src/d_array.c
@@ -1072,1077 +1072,3 @@ void d_array_setup(void)
tabwrite_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* sampling */
-
-/* LATER make tabread4 and tabread~ */
-
-#include "m_pd.h"
-
-
-/* ------------------------- tabwrite~ -------------------------- */
-
-static t_class *tabwrite_tilde_class;
-
-typedef struct _tabwrite_tilde
-{
- t_object x_obj;
- int x_phase;
- int x_nsampsintab;
- float *x_vec;
- t_symbol *x_arrayname;
- t_clock *x_clock;
- float x_f;
-} t_tabwrite_tilde;
-
-static void tabwrite_tilde_tick(t_tabwrite_tilde *x);
-
-static void *tabwrite_tilde_new(t_symbol *s)
-{
- t_tabwrite_tilde *x = (t_tabwrite_tilde *)pd_new(tabwrite_tilde_class);
- x->x_clock = clock_new(x, (t_method)tabwrite_tilde_tick);
- x->x_phase = 0x7fffffff;
- x->x_arrayname = s;
- x->x_f = 0;
- return (x);
-}
-
-static t_int *tabwrite_tilde_perform(t_int *w)
-{
- t_tabwrite_tilde *x = (t_tabwrite_tilde *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- int n = (int)(w[3]), phase = x->x_phase, endphase = x->x_nsampsintab;
- if (!x->x_vec) goto bad;
-
- if (endphase > phase)
- {
- int nxfer = endphase - phase;
- float *fp = x->x_vec + phase;
- if (nxfer > n) nxfer = n;
- phase += nxfer;
- while (nxfer--)
- {
- float f = *in++;
- if (PD_BIGORSMALL(f))
- f = 0;
- *fp++ = f;
- }
- if (phase >= endphase)
- {
- clock_delay(x->x_clock, 0);
- phase = 0x7fffffff;
- }
- x->x_phase = phase;
- }
-bad:
- return (w+4);
-}
-
-void tabwrite_tilde_set(t_tabwrite_tilde *x, t_symbol *s)
-{
- t_garray *a;
-
- x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name) pd_error(x, "tabwrite~: %s: no such array",
- x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec))
- {
- pd_error(x, "%s: bad template for tabwrite~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else garray_usedindsp(a);
-}
-
-static void tabwrite_tilde_dsp(t_tabwrite_tilde *x, t_signal **sp)
-{
- tabwrite_tilde_set(x, x->x_arrayname);
- dsp_add(tabwrite_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
-}
-
-static void tabwrite_tilde_bang(t_tabwrite_tilde *x)
-{
- x->x_phase = 0;
-}
-
-static void tabwrite_tilde_stop(t_tabwrite_tilde *x)
-{
- if (x->x_phase != 0x7fffffff)
- {
- tabwrite_tilde_tick(x);
- x->x_phase = 0x7fffffff;
- }
-}
-
-static void tabwrite_tilde_tick(t_tabwrite_tilde *x)
-{
- t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class);
- if (!a) bug("tabwrite_tilde_tick");
- else garray_redraw(a);
-}
-
-static void tabwrite_tilde_free(t_tabwrite_tilde *x)
-{
- clock_free(x->x_clock);
-}
-
-static void tabwrite_tilde_setup(void)
-{
- tabwrite_tilde_class = class_new(gensym("tabwrite~"),
- (t_newmethod)tabwrite_tilde_new, (t_method)tabwrite_tilde_free,
- sizeof(t_tabwrite_tilde), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabwrite_tilde_class, t_tabwrite_tilde, x_f);
- class_addmethod(tabwrite_tilde_class, (t_method)tabwrite_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabwrite_tilde_class, (t_method)tabwrite_tilde_set,
- gensym("set"), A_SYMBOL, 0);
- class_addmethod(tabwrite_tilde_class, (t_method)tabwrite_tilde_stop,
- gensym("stop"), 0);
- class_addbang(tabwrite_tilde_class, tabwrite_tilde_bang);
-}
-
-/* ------------ tabplay~ - non-transposing sample playback --------------- */
-
-static t_class *tabplay_tilde_class;
-
-typedef struct _tabplay_tilde
-{
- t_object x_obj;
- t_outlet *x_bangout;
- int x_phase;
- int x_nsampsintab;
- int x_limit;
- float *x_vec;
- t_symbol *x_arrayname;
- t_clock *x_clock;
-} t_tabplay_tilde;
-
-static void tabplay_tilde_tick(t_tabplay_tilde *x);
-
-static void *tabplay_tilde_new(t_symbol *s)
-{
- t_tabplay_tilde *x = (t_tabplay_tilde *)pd_new(tabplay_tilde_class);
- x->x_clock = clock_new(x, (t_method)tabplay_tilde_tick);
- x->x_phase = 0x7fffffff;
- x->x_limit = 0;
- x->x_arrayname = s;
- outlet_new(&x->x_obj, &s_signal);
- x->x_bangout = outlet_new(&x->x_obj, &s_bang);
- return (x);
-}
-
-static t_int *tabplay_tilde_perform(t_int *w)
-{
- t_tabplay_tilde *x = (t_tabplay_tilde *)(w[1]);
- t_float *out = (t_float *)(w[2]), *fp;
- int n = (int)(w[3]), phase = x->x_phase,
- endphase = (x->x_nsampsintab < x->x_limit ?
- x->x_nsampsintab : x->x_limit), nxfer, n3;
- if (!x->x_vec || phase >= endphase)
- goto zero;
-
- nxfer = endphase - phase;
- fp = x->x_vec + phase;
- if (nxfer > n)
- nxfer = n;
- n3 = n - nxfer;
- phase += nxfer;
- while (nxfer--)
- *out++ = *fp++;
- if (phase >= endphase)
- {
- clock_delay(x->x_clock, 0);
- x->x_phase = 0x7fffffff;
- while (n3--)
- *out++ = 0;
- }
- else x->x_phase = phase;
-
- return (w+4);
-zero:
- while (n--) *out++ = 0;
- return (w+4);
-}
-
-void tabplay_tilde_set(t_tabplay_tilde *x, t_symbol *s)
-{
- t_garray *a;
-
- x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name) pd_error(x, "tabplay~: %s: no such array",
- x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec))
- {
- pd_error(x, "%s: bad template for tabplay~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else garray_usedindsp(a);
-}
-
-static void tabplay_tilde_dsp(t_tabplay_tilde *x, t_signal **sp)
-{
- tabplay_tilde_set(x, x->x_arrayname);
- dsp_add(tabplay_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
-}
-
-static void tabplay_tilde_list(t_tabplay_tilde *x, t_symbol *s,
- int argc, t_atom *argv)
-{
- long start = atom_getfloatarg(0, argc, argv);
- long length = atom_getfloatarg(1, argc, argv);
- if (start < 0) start = 0;
- if (length <= 0)
- x->x_limit = 0x7fffffff;
- else
- x->x_limit = start + length;
- x->x_phase = start;
-}
-
-static void tabplay_tilde_stop(t_tabplay_tilde *x)
-{
- x->x_phase = 0x7fffffff;
-}
-
-static void tabplay_tilde_tick(t_tabplay_tilde *x)
-{
- outlet_bang(x->x_bangout);
-}
-
-static void tabplay_tilde_free(t_tabplay_tilde *x)
-{
- clock_free(x->x_clock);
-}
-
-static void tabplay_tilde_setup(void)
-{
- tabplay_tilde_class = class_new(gensym("tabplay~"),
- (t_newmethod)tabplay_tilde_new, (t_method)tabplay_tilde_free,
- sizeof(t_tabplay_tilde), 0, A_DEFSYM, 0);
- class_addmethod(tabplay_tilde_class, (t_method)tabplay_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabplay_tilde_class, (t_method)tabplay_tilde_stop,
- gensym("stop"), 0);
- class_addmethod(tabplay_tilde_class, (t_method)tabplay_tilde_set,
- gensym("set"), A_DEFSYM, 0);
- class_addlist(tabplay_tilde_class, tabplay_tilde_list);
-}
-
-/******************** tabread~ ***********************/
-
-static t_class *tabread_tilde_class;
-
-typedef struct _tabread_tilde
-{
- t_object x_obj;
- int x_npoints;
- float *x_vec;
- t_symbol *x_arrayname;
- float x_f;
-} t_tabread_tilde;
-
-static void *tabread_tilde_new(t_symbol *s)
-{
- t_tabread_tilde *x = (t_tabread_tilde *)pd_new(tabread_tilde_class);
- x->x_arrayname = s;
- x->x_vec = 0;
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *tabread_tilde_perform(t_int *w)
-{
- t_tabread_tilde *x = (t_tabread_tilde *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
- int n = (int)(w[4]);
- int maxindex;
- float *buf = x->x_vec, *fp;
- int i;
-
- maxindex = x->x_npoints - 1;
- if (!buf) goto zero;
-
- for (i = 0; i < n; i++)
- {
- int index = *in++;
- if (index < 0)
- index = 0;
- else if (index > maxindex)
- index = maxindex;
- *out++ = buf[index];
- }
- return (w+5);
- zero:
- while (n--) *out++ = 0;
-
- return (w+5);
-}
-
-void tabread_tilde_set(t_tabread_tilde *x, t_symbol *s)
-{
- t_garray *a;
-
- x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name)
- pd_error(x, "tabread~: %s: no such array", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &x->x_npoints, &x->x_vec))
- {
- pd_error(x, "%s: bad template for tabread~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else garray_usedindsp(a);
-}
-
-static void tabread_tilde_dsp(t_tabread_tilde *x, t_signal **sp)
-{
- tabread_tilde_set(x, x->x_arrayname);
-
- dsp_add(tabread_tilde_perform, 4, x,
- sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-
-}
-
-static void tabread_tilde_free(t_tabread_tilde *x)
-{
-}
-
-static void tabread_tilde_setup(void)
-{
- tabread_tilde_class = class_new(gensym("tabread~"),
- (t_newmethod)tabread_tilde_new, (t_method)tabread_tilde_free,
- sizeof(t_tabread_tilde), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabread_tilde_class, t_tabread_tilde, x_f);
- class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_set,
- gensym("set"), A_SYMBOL, 0);
-}
-
-/******************** tabread4~ ***********************/
-
-static t_class *tabread4_tilde_class;
-
-typedef struct _tabread4_tilde
-{
- t_object x_obj;
- int x_npoints;
- float *x_vec;
- t_symbol *x_arrayname;
- float x_f;
-} t_tabread4_tilde;
-
-static void *tabread4_tilde_new(t_symbol *s)
-{
- t_tabread4_tilde *x = (t_tabread4_tilde *)pd_new(tabread4_tilde_class);
- x->x_arrayname = s;
- x->x_vec = 0;
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *tabread4_tilde_perform(t_int *w)
-{
- t_tabread4_tilde *x = (t_tabread4_tilde *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
- int n = (int)(w[4]);
- int maxindex;
- float *buf = x->x_vec, *fp;
- int i;
-
- maxindex = x->x_npoints - 3;
-
- if (!buf) goto zero;
-
-#if 0 /* test for spam -- I'm not ready to deal with this */
- for (i = 0, xmax = 0, xmin = maxindex, fp = in1; i < n; i++, fp++)
- {
- float f = *in1;
- if (f < xmin) xmin = f;
- else if (f > xmax) xmax = f;
- }
- if (xmax < xmin + x->c_maxextent) xmax = xmin + x->c_maxextent;
- for (i = 0, splitlo = xmin+ x->c_maxextent, splithi = xmax - x->c_maxextent,
- fp = in1; i < n; i++, fp++)
- {
- float f = *in1;
- if (f > splitlo && f < splithi) goto zero;
- }
-#endif
-
- for (i = 0; i < n; i++)
- {
- float findex = *in++;
- int index = findex;
- float frac, a, b, c, d, cminusb;
- static int count;
- if (index < 1)
- index = 1, frac = 0;
- else if (index > maxindex)
- index = maxindex, frac = 1;
- else frac = findex - index;
- fp = buf + index;
- a = fp[-1];
- b = fp[0];
- c = fp[1];
- d = fp[2];
- /* if (!i && !(count++ & 1023))
- post("fp = %lx, shit = %lx, b = %f", fp, buf->b_shit, b); */
- cminusb = c-b;
- *out++ = b + frac * (
- cminusb - 0.1666667f * (1.-frac) * (
- (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b)
- )
- );
- }
- return (w+5);
- zero:
- while (n--) *out++ = 0;
-
- return (w+5);
-}
-
-void tabread4_tilde_set(t_tabread4_tilde *x, t_symbol *s)
-{
- t_garray *a;
-
- x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name)
- pd_error(x, "tabread4~: %s: no such array", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &x->x_npoints, &x->x_vec))
- {
- pd_error(x, "%s: bad template for tabread4~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else garray_usedindsp(a);
-}
-
-static void tabread4_tilde_dsp(t_tabread4_tilde *x, t_signal **sp)
-{
- tabread4_tilde_set(x, x->x_arrayname);
-
- dsp_add(tabread4_tilde_perform, 4, x,
- sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-
-}
-
-static void tabread4_tilde_free(t_tabread4_tilde *x)
-{
-}
-
-static void tabread4_tilde_setup(void)
-{
- tabread4_tilde_class = class_new(gensym("tabread4~"),
- (t_newmethod)tabread4_tilde_new, (t_method)tabread4_tilde_free,
- sizeof(t_tabread4_tilde), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabread4_tilde_class, t_tabread4_tilde, x_f);
- class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_set,
- gensym("set"), A_SYMBOL, 0);
-}
-
-/******************** tabosc4~ ***********************/
-
-/* this is all copied from d_osc.c... what include file could this go in? */
-#define UNITBIT32 1572864. /* 3*2^19; bit 32 has place value 1 */
-
- /* machine-dependent definitions. These ifdefs really
- should have been by CPU type and not by operating system! */
-#ifdef IRIX
- /* big-endian. Most significant byte is at low address in memory */
-#define HIOFFSET 0 /* word offset to find MSB */
-#define LOWOFFSET 1 /* word offset to find LSB */
-#define int32 long /* a data type that has 32 bits */
-#else
-#ifdef MSW
- /* little-endian; most significant byte is at highest address */
-#define HIOFFSET 1
-#define LOWOFFSET 0
-#define int32 long
-#else
-#ifdef __FreeBSD__
-#include <machine/endian.h>
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define HIOFFSET 1
-#define LOWOFFSET 0
-#else
-#define HIOFFSET 0 /* word offset to find MSB */
-#define LOWOFFSET 1 /* word offset to find LSB */
-#endif /* BYTE_ORDER */
-#include <sys/types.h>
-#define int32 int32_t
-#endif
-
-#ifdef __linux__
-#include <endian.h>
-#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN)
-#error No byte order defined
-#endif
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define HIOFFSET 1
-#define LOWOFFSET 0
-#else
-#define HIOFFSET 0 /* word offset to find MSB */
-#define LOWOFFSET 1 /* word offset to find LSB */
-#endif /* __BYTE_ORDER */
-
-#include <sys/types.h>
-#define int32 int32_t
-
-#else
-#ifdef MACOSX
-#define HIOFFSET 0 /* word offset to find MSB */
-#define LOWOFFSET 1 /* word offset to find LSB */
-#define int32 int /* a data type that has 32 bits */
-
-#endif /* MACOSX */
-#endif /* __linux__ */
-#endif /* MSW */
-#endif /* SGI */
-
-union tabfudge
-{
- double tf_d;
- int32 tf_i[2];
-};
-
-static t_class *tabosc4_tilde_class;
-
-typedef struct _tabosc4_tilde
-{
- t_object x_obj;
- float x_fnpoints;
- float x_finvnpoints;
- float *x_vec;
- t_symbol *x_arrayname;
- float x_f;
- double x_phase;
- float x_conv;
-} t_tabosc4_tilde;
-
-static void *tabosc4_tilde_new(t_symbol *s)
-{
- t_tabosc4_tilde *x = (t_tabosc4_tilde *)pd_new(tabosc4_tilde_class);
- x->x_arrayname = s;
- x->x_vec = 0;
- x->x_fnpoints = 512.;
- x->x_finvnpoints = (1./512.);
- outlet_new(&x->x_obj, gensym("signal"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *tabosc4_tilde_perform(t_int *w)
-{
- t_tabosc4_tilde *x = (t_tabosc4_tilde *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
- int n = (int)(w[4]);
- int normhipart;
- union tabfudge tf;
- float fnpoints = x->x_fnpoints;
- int mask = fnpoints - 1;
- float conv = fnpoints * x->x_conv;
- int maxindex;
- float *tab = x->x_vec, *addr;
- int i;
- double dphase = fnpoints * x->x_phase + UNITBIT32;
-
- if (!tab) goto zero;
- tf.tf_d = UNITBIT32;
- normhipart = tf.tf_i[HIOFFSET];
-
-#if 1
- while (n--)
- {
- float frac, a, b, c, d, cminusb;
- tf.tf_d = dphase;
- dphase += *in++ * conv;
- addr = tab + (tf.tf_i[HIOFFSET] & mask);
- tf.tf_i[HIOFFSET] = normhipart;
- frac = tf.tf_d - UNITBIT32;
- a = addr[0];
- b = addr[1];
- c = addr[2];
- d = addr[3];
- cminusb = c-b;
- *out++ = b + frac * (
- cminusb - 0.1666667f * (1.-frac) * (
- (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b)
- )
- );
- }
-#endif
-
- tf.tf_d = UNITBIT32 * fnpoints;
- normhipart = tf.tf_i[HIOFFSET];
- tf.tf_d = dphase + (UNITBIT32 * fnpoints - UNITBIT32);
- tf.tf_i[HIOFFSET] = normhipart;
- x->x_phase = (tf.tf_d - UNITBIT32 * fnpoints) * x->x_finvnpoints;
- return (w+5);
- zero:
- while (n--) *out++ = 0;
-
- return (w+5);
-}
-
-void tabosc4_tilde_set(t_tabosc4_tilde *x, t_symbol *s)
-{
- t_garray *a;
- int npoints, pointsinarray;
-
- x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name)
- pd_error(x, "tabosc4~: %s: no such array", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!garray_getfloatarray(a, &pointsinarray, &x->x_vec))
- {
- pd_error(x, "%s: bad template for tabosc4~", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if ((npoints = pointsinarray - 3) != (1 << ilog2(pointsinarray - 3)))
- {
- pd_error(x, "%s: number of points (%d) not a power of 2 plus three",
- x->x_arrayname->s_name, pointsinarray);
- x->x_vec = 0;
- garray_usedindsp(a);
- }
- else
- {
- x->x_fnpoints = npoints;
- x->x_finvnpoints = 1./npoints;
- garray_usedindsp(a);
- }
-}
-
-static void tabosc4_tilde_ft1(t_tabosc4_tilde *x, t_float f)
-{
- x->x_phase = f;
-}
-
-static void tabosc4_tilde_dsp(t_tabosc4_tilde *x, t_signal **sp)
-{
- x->x_conv = 1. / sp[0]->s_sr;
- tabosc4_tilde_set(x, x->x_arrayname);
-
- dsp_add(tabosc4_tilde_perform, 4, x,
- sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void tabosc4_tilde_setup(void)
-{
- tabosc4_tilde_class = class_new(gensym("tabosc4~"),
- (t_newmethod)tabosc4_tilde_new, 0,
- sizeof(t_tabosc4_tilde), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabosc4_tilde_class, t_tabosc4_tilde, x_f);
- class_addmethod(tabosc4_tilde_class, (t_method)tabosc4_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(tabosc4_tilde_class, (t_method)tabosc4_tilde_set,
- gensym("set"), A_SYMBOL, 0);
- class_addmethod(tabosc4_tilde_class, (t_method)tabosc4_tilde_ft1,
- gensym("ft1"), A_FLOAT, 0);
-}
-
-/* ------------------------ tabsend~ ------------------------- */
-
-static t_class *tabsend_class;
-
-typedef struct _tabsend
-{
- t_object x_obj;
- float *x_vec;
- int x_graphperiod;
- int x_graphcount;
- t_symbol *x_arrayname;
- t_clock *x_clock;
- float x_f;
-} t_tabsend;
-
-static void tabsend_tick(t_tabsend *x);
-
-static void *tabsend_new(t_symbol *s)
-{
- t_tabsend *x = (t_tabsend *)pd_new(tabsend_class);
- x->x_graphcount = 0;
- x->x_arrayname = s;
- x->x_clock = clock_new(x, (t_method)tabsend_tick);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *tabsend_perform(t_int *w)
-{
- t_tabsend *x = (t_tabsend *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- int n = w[3];
- t_float *dest = x->x_vec;
- int i = x->x_graphcount;
- if (!x->x_vec) goto bad;
-
- while (n--)
- {
- float f = *in++;
- if (PD_BIGORSMALL(f))
- f = 0;
- *dest++ = f;
- }
- if (!i--)
- {
- clock_delay(x->x_clock, 0);
- i = x->x_graphperiod;
- }
- x->x_graphcount = i;
-bad:
- return (w+4);
-}
-
-static void tabsend_dsp(t_tabsend *x, t_signal **sp)
-{
- int i, vecsize;
- t_garray *a;
-
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*x->x_arrayname->s_name)
- pd_error(x, "tabsend~: %s: no such array", x->x_arrayname->s_name);
- }
- else if (!garray_getfloatarray(a, &vecsize, &x->x_vec))
- pd_error(x, "%s: bad template for tabsend~", x->x_arrayname->s_name);
- else
- {
- int n = sp[0]->s_n;
- int ticksper = sp[0]->s_sr/n;
- if (ticksper < 1) ticksper = 1;
- x->x_graphperiod = ticksper;
- if (x->x_graphcount > ticksper) x->x_graphcount = ticksper;
- if (n < vecsize) vecsize = n;
- garray_usedindsp(a);
- dsp_add(tabsend_perform, 3, x, sp[0]->s_vec, vecsize);
- }
-}
-
-static void tabsend_tick(t_tabsend *x)
-{
- t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class);
- if (!a) bug("tabsend_tick");
- else garray_redraw(a);
-}
-
-static void tabsend_free(t_tabsend *x)
-{
- clock_free(x->x_clock);
-}
-
-static void tabsend_setup(void)
-{
- tabsend_class = class_new(gensym("tabsend~"), (t_newmethod)tabsend_new,
- (t_method)tabsend_free, sizeof(t_tabsend), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(tabsend_class, t_tabsend, x_f);
- class_addmethod(tabsend_class, (t_method)tabsend_dsp, gensym("dsp"), 0);
-}
-
-/* ------------------------ tabreceive~ ------------------------- */
-
-static t_class *tabreceive_class;
-
-typedef struct _tabreceive
-{
- t_object x_obj;
- float *x_vec;
- t_symbol *x_arrayname;
-} t_tabreceive;
-
-static t_int *tabreceive_perform(t_int *w)
-{
- t_tabreceive *x = (t_tabreceive *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = w[3];
- t_float *from = x->x_vec;
- if (from) while (n--) *out++ = *from++;
- else while (n--) *out++ = 0;
- return (w+4);
-}
-
-static void tabreceive_dsp(t_tabreceive *x, t_signal **sp)
-{
- t_garray *a;
- int vecsize;
-
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*x->x_arrayname->s_name)
- pd_error(x, "tabsend~: %s: no such array", x->x_arrayname->s_name);
- }
- else if (!garray_getfloatarray(a, &vecsize, &x->x_vec))
- pd_error(x, "%s: bad template for tabreceive~", x->x_arrayname->s_name);
- else
- {
- int n = sp[0]->s_n;
- if (n < vecsize) vecsize = n;
- garray_usedindsp(a);
- dsp_add(tabreceive_perform, 3, x, sp[0]->s_vec, vecsize);
- }
-}
-
-static void *tabreceive_new(t_symbol *s)
-{
- t_tabreceive *x = (t_tabreceive *)pd_new(tabreceive_class);
- x->x_arrayname = s;
- outlet_new(&x->x_obj, &s_signal);
- return (x);
-}
-
-static void tabreceive_setup(void)
-{
- tabreceive_class = class_new(gensym("tabreceive~"),
- (t_newmethod)tabreceive_new, 0,
- sizeof(t_tabreceive), 0, A_DEFSYM, 0);
- class_addmethod(tabreceive_class, (t_method)tabreceive_dsp,
- gensym("dsp"), 0);
-}
-
-
-/* ---------- tabread: control, non-interpolating ------------------------ */
-
-static t_class *tabread_class;
-
-typedef struct _tabread
-{
- t_object x_obj;
- t_symbol *x_arrayname;
-} t_tabread;
-
-static void tabread_float(t_tabread *x, t_float f)
-{
- t_garray *a;
- int npoints;
- t_float *vec;
-
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- pd_error(x, "%s: no such array", x->x_arrayname->s_name);
- else if (!garray_getfloatarray(a, &npoints, &vec))
- pd_error(x, "%s: bad template for tabread", x->x_arrayname->s_name);
- else
- {
- int n = f;
- if (n < 0) n = 0;
- else if (n >= npoints) n = npoints - 1;
- outlet_float(x->x_obj.ob_outlet, (npoints ? vec[n] : 0));
- }
-}
-
-static void tabread_set(t_tabread *x, t_symbol *s)
-{
- x->x_arrayname = s;
-}
-
-static void *tabread_new(t_symbol *s)
-{
- t_tabread *x = (t_tabread *)pd_new(tabread_class);
- x->x_arrayname = s;
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-static void tabread_setup(void)
-{
- tabread_class = class_new(gensym("tabread"), (t_newmethod)tabread_new,
- 0, sizeof(t_tabread), 0, A_DEFSYM, 0);
- class_addfloat(tabread_class, (t_method)tabread_float);
- class_addmethod(tabread_class, (t_method)tabread_set, gensym("set"),
- A_SYMBOL, 0);
-}
-
-/* ---------- tabread4: control, non-interpolating ------------------------ */
-
-static t_class *tabread4_class;
-
-typedef struct _tabread4
-{
- t_object x_obj;
- t_symbol *x_arrayname;
-} t_tabread4;
-
-static void tabread4_float(t_tabread4 *x, t_float f)
-{
- t_garray *a;
- int npoints;
- t_float *vec;
-
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- pd_error(x, "%s: no such array", x->x_arrayname->s_name);
- else if (!garray_getfloatarray(a, &npoints, &vec))
- pd_error(x, "%s: bad template for tabread4", x->x_arrayname->s_name);
- else if (npoints < 4)
- outlet_float(x->x_obj.ob_outlet, 0);
- else if (f <= 1)
- outlet_float(x->x_obj.ob_outlet, vec[1]);
- else if (f >= npoints - 2)
- outlet_float(x->x_obj.ob_outlet, vec[npoints - 2]);
- else
- {
- int n = f;
- float a, b, c, d, cminusb, frac, *fp;
- if (n >= npoints - 2)
- n = npoints - 3;
- fp = vec + n;
- frac = f - n;
- a = fp[-1];
- b = fp[0];
- c = fp[1];
- d = fp[2];
- cminusb = c-b;
- outlet_float(x->x_obj.ob_outlet, b + frac * (
- cminusb - 0.1666667f * (1.-frac) * (
- (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b))));
- }
-}
-
-static void tabread4_set(t_tabread4 *x, t_symbol *s)
-{
- x->x_arrayname = s;
-}
-
-static void *tabread4_new(t_symbol *s)
-{
- t_tabread4 *x = (t_tabread4 *)pd_new(tabread4_class);
- x->x_arrayname = s;
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-static void tabread4_setup(void)
-{
- tabread4_class = class_new(gensym("tabread4"), (t_newmethod)tabread4_new,
- 0, sizeof(t_tabread4), 0, A_DEFSYM, 0);
- class_addfloat(tabread4_class, (t_method)tabread4_float);
- class_addmethod(tabread4_class, (t_method)tabread4_set, gensym("set"),
- A_SYMBOL, 0);
-}
-
-/* ------------------ tabwrite: control ------------------------ */
-
-static t_class *tabwrite_class;
-
-typedef struct _tabwrite
-{
- t_object x_obj;
- t_symbol *x_arrayname;
- t_clock *x_clock;
- float x_ft1;
- double x_updtime;
- int x_set;
-} t_tabwrite;
-
-static void tabwrite_tick(t_tabwrite *x)
-{
- t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class);
- if (!a) bug("tabwrite_tick");
- else garray_redraw(a);
- x->x_set = 0;
- x->x_updtime = clock_getsystime();
-}
-
-static void tabwrite_float(t_tabwrite *x, t_float f)
-{
- int i, vecsize;
- t_garray *a;
- t_float *vec;
-
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- pd_error(x, "%s: no such array", x->x_arrayname->s_name);
- else if (!garray_getfloatarray(a, &vecsize, &vec))
- pd_error(x, "%s: bad template for tabwrite", x->x_arrayname->s_name);
- else
- {
- int n = x->x_ft1;
- double timesince = clock_gettimesince(x->x_updtime);
- if (n < 0) n = 0;
- else if (n >= vecsize) n = vecsize-1;
- vec[n] = f;
- if (timesince > 1000)
- {
- tabwrite_tick(x);
- }
- else
- {
- if (x->x_set == 0)
- {
- clock_delay(x->x_clock, 1000 - timesince);
- x->x_set = 1;
- }
- }
- }
-}
-
-static void tabwrite_set(t_tabwrite *x, t_symbol *s)
-{
- x->x_arrayname = s;
-}
-
-static void tabwrite_free(t_tabwrite *x)
-{
- clock_free(x->x_clock);
-}
-
-static void *tabwrite_new(t_symbol *s)
-{
- t_tabwrite *x = (t_tabwrite *)pd_new(tabwrite_class);
- x->x_ft1 = 0;
- x->x_arrayname = s;
- x->x_updtime = clock_getsystime();
- x->x_clock = clock_new(x, (t_method)tabwrite_tick);
- floatinlet_new(&x->x_obj, &x->x_ft1);
- return (x);
-}
-
-void tabwrite_setup(void)
-{
- tabwrite_class = class_new(gensym("tabwrite"), (t_newmethod)tabwrite_new,
- (t_method)tabwrite_free, sizeof(t_tabwrite), 0, A_DEFSYM, 0);
- class_addfloat(tabwrite_class, (t_method)tabwrite_float);
- class_addmethod(tabwrite_class, (t_method)tabwrite_set, gensym("set"), A_SYMBOL, 0);
-}
-
-/* ------------------------ global setup routine ------------------------- */
-
-void d_array_setup(void)
-{
- tabwrite_tilde_setup();
- tabplay_tilde_setup();
- tabread_tilde_setup();
- tabread4_tilde_setup();
- tabosc4_tilde_setup();
- tabsend_setup();
- tabreceive_setup();
- tabread_setup();
- tabread4_setup();
- tabwrite_setup();
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/d_ctl.c b/apps/plugins/pdbox/PDa/src/d_ctl.c
index d3262af800..809899addf 100644
--- a/apps/plugins/pdbox/PDa/src/d_ctl.c
+++ b/apps/plugins/pdbox/PDa/src/d_ctl.c
@@ -782,787 +782,4 @@ void d_ctl_setup(void)
}
#endif
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* sig~ and line~ control-to-signal converters;
- snapshot~ signal-to-control converter.
-*/
-
-#include "m_pd.h"
-#include "math.h"
-
-/* -------------------------- sig~ ------------------------------ */
-static t_class *sig_tilde_class;
-
-typedef struct _sig
-{
- t_object x_obj;
- float x_f;
-} t_sig;
-
-static t_int *sig_tilde_perform(t_int *w)
-{
- t_float f = *(t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
- while (n--)
- *out++ = f;
- return (w+4);
-}
-
-static t_int *sig_tilde_perf8(t_int *w)
-{
- t_float f = *(t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
-
- for (; n; n -= 8, out += 8)
- {
- out[0] = f;
- out[1] = f;
- out[2] = f;
- out[3] = f;
- out[4] = f;
- out[5] = f;
- out[6] = f;
- out[7] = f;
- }
- return (w+4);
-}
-
-void dsp_add_scalarcopy(t_sample *in, t_sample *out, int n)
-{
- if (n&7)
- dsp_add(sig_tilde_perform, 3, in, out, n);
- else
- dsp_add(sig_tilde_perf8, 3, in, out, n);
-}
-
-static void sig_tilde_float(t_sig *x, t_float f)
-{
- x->x_f = f;
-}
-
-static void sig_tilde_dsp(t_sig *x, t_signal **sp)
-{
- dsp_add(sig_tilde_perform, 3, &x->x_f, sp[0]->s_vec, sp[0]->s_n);
-}
-
-static void *sig_tilde_new(t_floatarg f)
-{
- t_sig *x = (t_sig *)pd_new(sig_tilde_class);
- x->x_f = f;
- outlet_new(&x->x_obj, gensym("signal"));
- return (x);
-}
-
-static void sig_tilde_setup(void)
-{
- sig_tilde_class = class_new(gensym("sig~"), (t_newmethod)sig_tilde_new, 0,
- sizeof(t_sig), 0, A_DEFFLOAT, 0);
- class_addfloat(sig_tilde_class, (t_method)sig_tilde_float);
- class_addmethod(sig_tilde_class, (t_method)sig_tilde_dsp, gensym("dsp"), 0);
-}
-
-
-#ifndef FIXEDPOINT
-
-/* -------------------------- line~ ------------------------------ */
-static t_class *line_tilde_class;
-
-typedef struct _line
-{
- t_object x_obj;
- float x_target;
- float x_value;
- float x_biginc;
- float x_inc;
- float x_1overn;
- float x_dspticktomsec;
- float x_inletvalue;
- float x_inletwas;
- int x_ticksleft;
- int x_retarget;
-} t_line;
-
-static t_int *line_tilde_perform(t_int *w)
-{
- t_line *x = (t_line *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
- float f = x->x_value;
-
- if (PD_BIGORSMALL(f))
- x->x_value = f = 0;
- if (x->x_retarget)
- {
- int nticks = x->x_inletwas * x->x_dspticktomsec;
- if (!nticks) nticks = 1;
- x->x_ticksleft = nticks;
- x->x_biginc = (x->x_target - x->x_value)/(float)nticks;
- x->x_inc = x->x_1overn * x->x_biginc;
- x->x_retarget = 0;
- }
- if (x->x_ticksleft)
- {
- float f = x->x_value;
- while (n--) *out++ = f, f += x->x_inc;
- x->x_value += x->x_biginc;
- x->x_ticksleft--;
- }
- else
- {
- x->x_value = x->x_target;
- while (n--) *out++ = x->x_value;
- }
- return (w+4);
-}
-
-static void line_tilde_float(t_line *x, t_float f)
-{
- if (x->x_inletvalue <= 0)
- {
- x->x_target = x->x_value = f;
- x->x_ticksleft = x->x_retarget = 0;
- }
- else
- {
- x->x_target = f;
- x->x_retarget = 1;
- x->x_inletwas = x->x_inletvalue;
- x->x_inletvalue = 0;
- }
-}
-
-static void line_tilde_stop(t_line *x)
-{
- x->x_target = x->x_value;
- x->x_ticksleft = x->x_retarget = 0;
-}
-
-static void line_tilde_dsp(t_line *x, t_signal **sp)
-{
- dsp_add(line_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
- x->x_1overn = 1./sp[0]->s_n;
- x->x_dspticktomsec = sp[0]->s_sr / (1000 * sp[0]->s_n);
-}
-
-static void *line_tilde_new(void)
-{
- t_line *x = (t_line *)pd_new(line_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- floatinlet_new(&x->x_obj, &x->x_inletvalue);
- x->x_ticksleft = x->x_retarget = 0;
- x->x_value = x->x_target = x->x_inletvalue = x->x_inletwas = 0;
- return (x);
-}
-
-static void line_tilde_setup(void)
-{
- line_tilde_class = class_new(gensym("line~"), line_tilde_new, 0,
- sizeof(t_line), 0, 0);
- class_addfloat(line_tilde_class, (t_method)line_tilde_float);
- class_addmethod(line_tilde_class, (t_method)line_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(line_tilde_class, (t_method)line_tilde_stop,
- gensym("stop"), 0);
-}
-
-/* -------------------------- vline~ ------------------------------ */
-static t_class *vline_tilde_class;
-
-typedef struct _vseg
-{
- double s_targettime;
- double s_starttime;
- float s_target;
- struct _vseg *s_next;
-} t_vseg;
-
-typedef struct _vline
-{
- t_object x_obj;
- double x_value;
- double x_inc;
- double x_referencetime;
- double x_samppermsec;
- double x_msecpersamp;
- double x_targettime;
- float x_target;
- float x_inlet1;
- float x_inlet2;
- t_vseg *x_list;
-} t_vline;
-
-static t_int *vline_tilde_perform(t_int *w)
-{
- t_vline *x = (t_vline *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]), i;
- double f = x->x_value;
- double inc = x->x_inc;
- double msecpersamp = x->x_msecpersamp;
- double samppermsec = x->x_samppermsec;
- double timenow = clock_gettimesince(x->x_referencetime) - n * msecpersamp;
- t_vseg *s = x->x_list;
- for (i = 0; i < n; i++)
- {
- double timenext = timenow + msecpersamp;
- checknext:
- if (s)
- {
- /* has starttime elapsed? If so update value and increment */
- if (s->s_starttime < timenext)
- {
- if (x->x_targettime <= timenext)
- f = x->x_target, inc = 0;
- /* if zero-length segment bash output value */
- if (s->s_targettime <= s->s_starttime)
- {
- f = s->s_target;
- inc = 0;
- }
- else
- {
- double incpermsec = (s->s_target - f)/
- (s->s_targettime - s->s_starttime);
- f = f + incpermsec * (timenext - s->s_starttime);
- inc = incpermsec * msecpersamp;
- }
- x->x_inc = inc;
- x->x_target = s->s_target;
- x->x_targettime = s->s_targettime;
- x->x_list = s->s_next;
- t_freebytes(s, sizeof(*s));
- s = x->x_list;
- goto checknext;
- }
- }
- if (x->x_targettime <= timenext)
- f = x->x_target, inc = x->x_inc = 0, x->x_targettime = 1e20;
- *out++ = f;
- f = f + inc;
- timenow = timenext;
- }
- x->x_value = f;
- return (w+4);
-}
-
-static void vline_tilde_stop(t_vline *x)
-{
- t_vseg *s1, *s2;
- for (s1 = x->x_list; s1; s1 = s2)
- s2 = s1->s_next, t_freebytes(s1, sizeof(*s1));
- x->x_list = 0;
- x->x_inc = 0;
- x->x_inlet1 = x->x_inlet2 = 0;
- x->x_target = x->x_value;
- x->x_targettime = 1e20;
-}
-
-static void vline_tilde_float(t_vline *x, t_float f)
-{
- double timenow = clock_gettimesince(x->x_referencetime);
- float inlet1 = (x->x_inlet1 < 0 ? 0 : x->x_inlet1);
- float inlet2 = x->x_inlet2;
- double starttime = timenow + inlet2;
- t_vseg *s1, *s2, *deletefrom = 0, *snew;
- if (PD_BIGORSMALL(f))
- f = 0;
-
- /* negative delay input means stop and jump immediately to new value */
- if (inlet2 < 0)
- {
- x->x_value = f;
- vline_tilde_stop(x);
- return;
- }
- snew = (t_vseg *)t_getbytes(sizeof(*snew));
- /* check if we supplant the first item in the list. We supplant
- an item by having an earlier starttime, or an equal starttime unless
- the equal one was instantaneous and the new one isn't (in which case
- we'll do a jump-and-slide starting at that time.) */
- if (!x->x_list || x->x_list->s_starttime > starttime ||
- (x->x_list->s_starttime == starttime &&
- (x->x_list->s_targettime > x->x_list->s_starttime || inlet1 <= 0)))
- {
- deletefrom = x->x_list;
- x->x_list = snew;
- }
- else
- {
- for (s1 = x->x_list; s2 = s1->s_next; s1 = s2)
- {
- if (s2->s_starttime > starttime ||
- (s2->s_starttime == starttime &&
- (s2->s_targettime > s2->s_starttime || inlet1 <= 0)))
- {
- deletefrom = s2;
- s1->s_next = snew;
- goto didit;
- }
- }
- s1->s_next = snew;
- deletefrom = 0;
- didit: ;
- }
- while (deletefrom)
- {
- s1 = deletefrom->s_next;
- t_freebytes(deletefrom, sizeof(*deletefrom));
- deletefrom = s1;
- }
- snew->s_next = 0;
- snew->s_target = f;
- snew->s_starttime = starttime;
- snew->s_targettime = starttime + inlet1;
- x->x_inlet1 = x->x_inlet2 = 0;
-}
-
-static void vline_tilde_dsp(t_vline *x, t_signal **sp)
-{
- dsp_add(vline_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
- x->x_samppermsec = ((double)(sp[0]->s_sr)) / 1000;
- x->x_msecpersamp = ((double)1000) / sp[0]->s_sr;
-}
-static void *vline_tilde_new(void)
-{
- t_vline *x = (t_vline *)pd_new(vline_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- floatinlet_new(&x->x_obj, &x->x_inlet1);
- floatinlet_new(&x->x_obj, &x->x_inlet2);
- x->x_inlet1 = x->x_inlet2 = 0;
- x->x_value = x->x_inc = 0;
- x->x_referencetime = clock_getlogicaltime();
- x->x_list = 0;
- x->x_samppermsec = 0;
- x->x_targettime = 1e20;
- return (x);
-}
-
-static void vline_tilde_setup(void)
-{
- vline_tilde_class = class_new(gensym("vline~"), vline_tilde_new,
- (t_method)vline_tilde_stop, sizeof(t_vline), 0, 0);
- class_addfloat(vline_tilde_class, (t_method)vline_tilde_float);
- class_addmethod(vline_tilde_class, (t_method)vline_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(vline_tilde_class, (t_method)vline_tilde_stop,
- gensym("stop"), 0);
-}
-
-/* -------------------------- snapshot~ ------------------------------ */
-static t_class *snapshot_tilde_class;
-
-typedef struct _snapshot
-{
- t_object x_obj;
- t_sample x_value;
- float x_f;
-} t_snapshot;
-
-static void *snapshot_tilde_new(void)
-{
- t_snapshot *x = (t_snapshot *)pd_new(snapshot_tilde_class);
- x->x_value = 0;
- outlet_new(&x->x_obj, &s_float);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *snapshot_tilde_perform(t_int *w)
-{
- t_float *in = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- *out = *in;
- return (w+3);
-}
-
-static void snapshot_tilde_dsp(t_snapshot *x, t_signal **sp)
-{
- dsp_add(snapshot_tilde_perform, 2, sp[0]->s_vec + (sp[0]->s_n-1),
- &x->x_value);
-}
-
-static void snapshot_tilde_bang(t_snapshot *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_value);
-}
-
-static void snapshot_tilde_set(t_snapshot *x, t_floatarg f)
-{
- x->x_value = f;
-}
-
-static void snapshot_tilde_setup(void)
-{
- snapshot_tilde_class = class_new(gensym("snapshot~"), snapshot_tilde_new, 0,
- sizeof(t_snapshot), 0, 0);
- CLASS_MAINSIGNALIN(snapshot_tilde_class, t_snapshot, x_f);
- class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_dsp,
- gensym("dsp"), 0);
- class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_set,
- gensym("set"), A_DEFFLOAT, 0);
- class_addbang(snapshot_tilde_class, snapshot_tilde_bang);
-}
-
-/* -------------------------- vsnapshot~ ------------------------------ */
-static t_class *vsnapshot_tilde_class;
-
-typedef struct _vsnapshot
-{
- t_object x_obj;
- int x_n;
- int x_gotone;
- t_sample *x_vec;
- float x_f;
- float x_sampspermsec;
- double x_time;
-} t_vsnapshot;
-
-static void *vsnapshot_tilde_new(void)
-{
- t_vsnapshot *x = (t_vsnapshot *)pd_new(vsnapshot_tilde_class);
- outlet_new(&x->x_obj, &s_float);
- x->x_f = 0;
- x->x_n = 0;
- x->x_vec = 0;
- x->x_gotone = 0;
- return (x);
-}
-
-static t_int *vsnapshot_tilde_perform(t_int *w)
-{
- t_float *in = (t_float *)(w[1]);
- t_vsnapshot *x = (t_vsnapshot *)(w[2]);
- t_float *out = x->x_vec;
- int n = x->x_n, i;
- for (i = 0; i < n; i++)
- out[i] = in[i];
- x->x_time = clock_getlogicaltime();
- x->x_gotone = 1;
- return (w+3);
-}
-
-static void vsnapshot_tilde_dsp(t_vsnapshot *x, t_signal **sp)
-{
- int n = sp[0]->s_n;
- if (n != x->x_n)
- {
- if (x->x_vec)
- t_freebytes(x->x_vec, x->x_n * sizeof(t_sample));
- x->x_vec = (t_sample *)getbytes(n * sizeof(t_sample));
- x->x_gotone = 0;
- x->x_n = n;
- }
- x->x_sampspermsec = sp[0]->s_sr / 1000;
- dsp_add(vsnapshot_tilde_perform, 2, sp[0]->s_vec, x);
-}
-
-static void vsnapshot_tilde_bang(t_vsnapshot *x)
-{
- float val;
- if (x->x_gotone)
- {
- int indx = clock_gettimesince(x->x_time) * x->x_sampspermsec;
- if (indx < 0)
- indx = 0;
- else if (indx >= x->x_n)
- indx = x->x_n - 1;
- val = x->x_vec[indx];
- }
- else val = 0;
- outlet_float(x->x_obj.ob_outlet, val);
-}
-
-static void vsnapshot_tilde_ff(t_vsnapshot *x)
-{
- if (x->x_vec)
- t_freebytes(x->x_vec, x->x_n * sizeof(t_sample));
-}
-
-static void vsnapshot_tilde_setup(void)
-{
- vsnapshot_tilde_class = class_new(gensym("vsnapshot~"),
- vsnapshot_tilde_new, (t_method)vsnapshot_tilde_ff,
- sizeof(t_vsnapshot), 0, 0);
- CLASS_MAINSIGNALIN(vsnapshot_tilde_class, t_vsnapshot, x_f);
- class_addmethod(vsnapshot_tilde_class, (t_method)vsnapshot_tilde_dsp, gensym("dsp"), 0);
- class_addbang(vsnapshot_tilde_class, vsnapshot_tilde_bang);
-}
-
-
-/* ---------------- env~ - simple envelope follower. ----------------- */
-
-#define MAXOVERLAP 10
-#define MAXVSTAKEN 64
-
-typedef struct sigenv
-{
- t_object x_obj; /* header */
- void *x_outlet; /* a "float" outlet */
- void *x_clock; /* a "clock" object */
- float *x_buf; /* a Hanning window */
- int x_phase; /* number of points since last output */
- int x_period; /* requested period of output */
- int x_realperiod; /* period rounded up to vecsize multiple */
- int x_npoints; /* analysis window size in samples */
- float x_result; /* result to output */
- float x_sumbuf[MAXOVERLAP]; /* summing buffer */
- float x_f;
-} t_sigenv;
-
-t_class *env_tilde_class;
-static void env_tilde_tick(t_sigenv *x);
-
-static void *env_tilde_new(t_floatarg fnpoints, t_floatarg fperiod)
-{
- int npoints = fnpoints;
- int period = fperiod;
- t_sigenv *x;
- float *buf;
- int i;
-
- if (npoints < 1) npoints = 1024;
- if (period < 1) period = npoints/2;
- if (period < npoints / MAXOVERLAP + 1)
- period = npoints / MAXOVERLAP + 1;
- if (!(buf = getbytes(sizeof(float) * (npoints + MAXVSTAKEN))))
- {
- error("env: couldn't allocate buffer");
- return (0);
- }
- x = (t_sigenv *)pd_new(env_tilde_class);
- x->x_buf = buf;
- x->x_npoints = npoints;
- x->x_phase = 0;
- x->x_period = period;
- for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0;
- for (i = 0; i < npoints; i++)
- buf[i] = (1. - cos((2 * 3.14159 * i) / npoints))/npoints;
- for (; i < npoints+MAXVSTAKEN; i++) buf[i] = 0;
- x->x_clock = clock_new(x, (t_method)env_tilde_tick);
- x->x_outlet = outlet_new(&x->x_obj, gensym("float"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *env_tilde_perform(t_int *w)
-{
- t_sigenv *x = (t_sigenv *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- int n = (int)(w[3]);
- int count;
- float *sump;
- in += n;
- for (count = x->x_phase, sump = x->x_sumbuf;
- count < x->x_npoints; count += x->x_realperiod, sump++)
- {
- float *hp = x->x_buf + count;
- float *fp = in;
- float sum = *sump;
- int i;
-
- for (i = 0; i < n; i++)
- {
- fp--;
- sum += *hp++ * (*fp * *fp);
- }
- *sump = sum;
- }
- sump[0] = 0;
- x->x_phase -= n;
- if (x->x_phase < 0)
- {
- x->x_result = x->x_sumbuf[0];
- for (count = x->x_realperiod, sump = x->x_sumbuf;
- count < x->x_npoints; count += x->x_realperiod, sump++)
- sump[0] = sump[1];
- sump[0] = 0;
- x->x_phase = x->x_realperiod - n;
- clock_delay(x->x_clock, 0L);
- }
- return (w+4);
-}
-
-static void env_tilde_dsp(t_sigenv *x, t_signal **sp)
-{
- if (x->x_period % sp[0]->s_n) x->x_realperiod =
- x->x_period + sp[0]->s_n - (x->x_period % sp[0]->s_n);
- else x->x_realperiod = x->x_period;
- dsp_add(env_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
- if (sp[0]->s_n > MAXVSTAKEN) bug("env_tilde_dsp");
-}
-
-static void env_tilde_tick(t_sigenv *x) /* callback function for the clock */
-{
- outlet_float(x->x_outlet, powtodb(x->x_result));
-}
-
-static void env_tilde_ff(t_sigenv *x) /* cleanup on free */
-{
- clock_free(x->x_clock);
- freebytes(x->x_buf, (x->x_npoints + MAXVSTAKEN) * sizeof(float));
-}
-
-
-void env_tilde_setup(void )
-{
- env_tilde_class = class_new(gensym("env~"), (t_newmethod)env_tilde_new,
- (t_method)env_tilde_ff, sizeof(t_sigenv), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(env_tilde_class, t_sigenv, x_f);
- class_addmethod(env_tilde_class, (t_method)env_tilde_dsp, gensym("dsp"), 0);
-}
-
-/* --------------------- threshold~ ----------------------------- */
-
-static t_class *threshold_tilde_class;
-
-typedef struct _threshold_tilde
-{
- t_object x_obj;
- t_outlet *x_outlet1; /* bang out for high thresh */
- t_outlet *x_outlet2; /* bang out for low thresh */
- t_clock *x_clock; /* wakeup for message output */
- float x_f; /* scalar inlet */
- int x_state; /* 1 = high, 0 = low */
- float x_hithresh; /* value of high threshold */
- float x_lothresh; /* value of low threshold */
- float x_deadwait; /* msec remaining in dead period */
- float x_msecpertick; /* msec per DSP tick */
- float x_hideadtime; /* hi dead time in msec */
- float x_lodeadtime; /* lo dead time in msec */
-} t_threshold_tilde;
-
-static void threshold_tilde_tick(t_threshold_tilde *x);
-static void threshold_tilde_set(t_threshold_tilde *x,
- t_floatarg hithresh, t_floatarg hideadtime,
- t_floatarg lothresh, t_floatarg lodeadtime);
-
-static t_threshold_tilde *threshold_tilde_new(t_floatarg hithresh,
- t_floatarg hideadtime, t_floatarg lothresh, t_floatarg lodeadtime)
-{
- t_threshold_tilde *x = (t_threshold_tilde *)
- pd_new(threshold_tilde_class);
- x->x_state = 0; /* low state */
- x->x_deadwait = 0; /* no dead time */
- x->x_clock = clock_new(x, (t_method)threshold_tilde_tick);
- x->x_outlet1 = outlet_new(&x->x_obj, &s_bang);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_bang);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- x->x_msecpertick = 0.;
- x->x_f = 0;
- threshold_tilde_set(x, hithresh, hideadtime, lothresh, lodeadtime);
- return (x);
-}
-
- /* "set" message to specify thresholds and dead times */
-static void threshold_tilde_set(t_threshold_tilde *x,
- t_floatarg hithresh, t_floatarg hideadtime,
- t_floatarg lothresh, t_floatarg lodeadtime)
-{
- if (lothresh > hithresh)
- lothresh = hithresh;
- x->x_hithresh = hithresh;
- x->x_hideadtime = hideadtime;
- x->x_lothresh = lothresh;
- x->x_lodeadtime = lodeadtime;
-}
-
- /* number in inlet sets state -- note incompatible with JMAX which used
- "int" message for this, impossible here because of auto signal conversion */
-static void threshold_tilde_ft1(t_threshold_tilde *x, t_floatarg f)
-{
- x->x_state = (f != 0);
- x->x_deadwait = 0;
-}
-
-static void threshold_tilde_tick(t_threshold_tilde *x)
-{
- if (x->x_state)
- outlet_bang(x->x_outlet1);
- else outlet_bang(x->x_outlet2);
-}
-
-static t_int *threshold_tilde_perform(t_int *w)
-{
- float *in1 = (float *)(w[1]);
- t_threshold_tilde *x = (t_threshold_tilde *)(w[2]);
- int n = (t_int)(w[3]);
- if (x->x_deadwait > 0)
- x->x_deadwait -= x->x_msecpertick;
- else if (x->x_state)
- {
- /* we're high; look for low sample */
- for (; n--; in1++)
- {
- if (*in1 < x->x_lothresh)
- {
- clock_delay(x->x_clock, 0L);
- x->x_state = 0;
- x->x_deadwait = x->x_lodeadtime;
- goto done;
- }
- }
- }
- else
- {
- /* we're low; look for high sample */
- for (; n--; in1++)
- {
- if (*in1 >= x->x_hithresh)
- {
- clock_delay(x->x_clock, 0L);
- x->x_state = 1;
- x->x_deadwait = x->x_hideadtime;
- goto done;
- }
- }
- }
-done:
- return (w+4);
-}
-
-void threshold_tilde_dsp(t_threshold_tilde *x, t_signal **sp)
-{
- x->x_msecpertick = 1000. * sp[0]->s_n / sp[0]->s_sr;
- dsp_add(threshold_tilde_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
-}
-
-static void threshold_tilde_ff(t_threshold_tilde *x)
-{
- clock_free(x->x_clock);
-}
-
-static void threshold_tilde_setup( void)
-{
- threshold_tilde_class = class_new(gensym("threshold~"),
- (t_newmethod)threshold_tilde_new, (t_method)threshold_tilde_ff,
- sizeof(t_threshold_tilde), 0,
- A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(threshold_tilde_class, t_threshold_tilde, x_f);
- class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_set,
- gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_dsp,
- gensym("dsp"), 0);
-}
-
-/* ------------------------ global setup routine ------------------------- */
-
-void d_ctl_setup(void)
-{
- sig_tilde_setup();
- line_tilde_setup();
- vline_tilde_setup();
- snapshot_tilde_setup();
- vsnapshot_tilde_setup();
- env_tilde_setup();
- threshold_tilde_setup();
-}
-
-#endif
diff --git a/apps/plugins/pdbox/PDa/src/d_dac.c b/apps/plugins/pdbox/PDa/src/d_dac.c
index ce7c7127f0..1606b3a1f2 100644
--- a/apps/plugins/pdbox/PDa/src/d_dac.c
+++ b/apps/plugins/pdbox/PDa/src/d_dac.c
@@ -182,187 +182,3 @@ void d_dac_setup(void)
adc_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* The dac~ and adc~ routines.
-*/
-
-#include "m_pd.h"
-#include "s_stuff.h"
-
-/* ----------------------------- dac~ --------------------------- */
-static t_class *dac_class;
-
-typedef struct _dac
-{
- t_object x_obj;
- t_int x_n;
- t_int *x_vec;
- float x_f;
-} t_dac;
-
-static void *dac_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_dac *x = (t_dac *)pd_new(dac_class);
- t_atom defarg[2], *ap;
- int i;
- if (!argc)
- {
- argv = defarg;
- argc = 2;
- SETFLOAT(&defarg[0], 1);
- SETFLOAT(&defarg[1], 2);
- }
- x->x_n = argc;
- x->x_vec = (t_int *)getbytes(argc * sizeof(*x->x_vec));
- for (i = 0; i < argc; i++)
- x->x_vec[i] = atom_getintarg(i, argc, argv);
- for (i = 1; i < argc; i++)
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- x->x_f = 0;
- return (x);
-}
-
-static void dac_dsp(t_dac *x, t_signal **sp)
-{
- t_int i, *ip;
- t_signal **sp2;
- for (i = x->x_n, ip = x->x_vec, sp2 = sp; i--; ip++, sp2++)
- {
- int ch = *ip - 1;
- if ((*sp2)->s_n != DEFDACBLKSIZE)
- error("dac~: bad vector size");
- else if (ch >= 0 && ch < sys_get_outchannels())
- dsp_add(plus_perform, 4, sys_soundout + DEFDACBLKSIZE*ch,
- (*sp2)->s_vec, sys_soundout + DEFDACBLKSIZE*ch, DEFDACBLKSIZE);
- }
-}
-
-static void dac_free(t_dac *x)
-{
- freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec));
-}
-
-static void dac_setup(void)
-{
- dac_class = class_new(gensym("dac~"), (t_newmethod)dac_new,
- (t_method)dac_free, sizeof(t_dac), 0, A_GIMME, 0);
- CLASS_MAINSIGNALIN(dac_class, t_dac, x_f);
- class_addmethod(dac_class, (t_method)dac_dsp, gensym("dsp"), A_CANT, 0);
- class_sethelpsymbol(dac_class, gensym("adc~_dac~"));
-}
-
-/* ----------------------------- adc~ --------------------------- */
-static t_class *adc_class;
-
-typedef struct _adc
-{
- t_object x_obj;
- t_int x_n;
- t_int *x_vec;
-} t_adc;
-
-static void *adc_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_adc *x = (t_adc *)pd_new(adc_class);
- t_atom defarg[2], *ap;
- int i;
- if (!argc)
- {
- argv = defarg;
- argc = 2;
- SETFLOAT(&defarg[0], 1);
- SETFLOAT(&defarg[1], 2);
- }
- x->x_n = argc;
- x->x_vec = (t_int *)getbytes(argc * sizeof(*x->x_vec));
- for (i = 0; i < argc; i++)
- x->x_vec[i] = atom_getintarg(i, argc, argv);
- for (i = 0; i < argc; i++)
- outlet_new(&x->x_obj, &s_signal);
- return (x);
-}
-
-t_int *copy_perform(t_int *w)
-{
- t_float *in1 = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
- while (n--) *out++ = *in1++;
- return (w+4);
-}
-
-t_int *copy_perf8(t_int *w)
-{
- t_float *in1 = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
-
- for (; n; n -= 8, in1 += 8, out += 8)
- {
- float f0 = in1[0];
- float f1 = in1[1];
- float f2 = in1[2];
- float f3 = in1[3];
- float f4 = in1[4];
- float f5 = in1[5];
- float f6 = in1[6];
- float f7 = in1[7];
-
- out[0] = f0;
- out[1] = f1;
- out[2] = f2;
- out[3] = f3;
- out[4] = f4;
- out[5] = f5;
- out[6] = f6;
- out[7] = f7;
- }
- return (w+4);
-}
-
-void dsp_add_copy(t_sample *in, t_sample *out, int n)
-{
- if (n&7)
- dsp_add(copy_perform, 3, in, out, n);
- else
- dsp_add(copy_perf8, 3, in, out, n);
-}
-
-static void adc_dsp(t_adc *x, t_signal **sp)
-{
- t_int i, *ip;
- t_signal **sp2;
- for (i = x->x_n, ip = x->x_vec, sp2 = sp; i--; ip++, sp2++)
- {
- int ch = *ip - 1;
- if ((*sp2)->s_n != DEFDACBLKSIZE)
- error("adc~: bad vector size");
- else if (ch >= 0 && ch < sys_get_inchannels())
- dsp_add_copy(sys_soundin + DEFDACBLKSIZE*ch,
- (*sp2)->s_vec, DEFDACBLKSIZE);
- else dsp_add_zero((*sp2)->s_vec, DEFDACBLKSIZE);
- }
-}
-
-static void adc_free(t_adc *x)
-{
- freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec));
-}
-
-static void adc_setup(void)
-{
- adc_class = class_new(gensym("adc~"), (t_newmethod)adc_new,
- (t_method)adc_free, sizeof(t_adc), 0, A_GIMME, 0);
- class_addmethod(adc_class, (t_method)adc_dsp, gensym("dsp"), A_CANT, 0);
- class_sethelpsymbol(adc_class, gensym("adc~_dac~"));
-}
-
-void d_dac_setup(void)
-{
- dac_setup();
- adc_setup();
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/d_delay.c b/apps/plugins/pdbox/PDa/src/d_delay.c
index 37fb90ea5b..d04ded9e90 100644
--- a/apps/plugins/pdbox/PDa/src/d_delay.c
+++ b/apps/plugins/pdbox/PDa/src/d_delay.c
@@ -317,322 +317,3 @@ void d_delay_setup(void)
sigvd_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* send~, delread~, throw~, catch~ */
-
-#include "m_pd.h"
-extern int ugen_getsortno(void);
-
-#define DEFDELVS 64 /* LATER get this from canvas at DSP time */
-static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */
-
-/* ----------------------------- delwrite~ ----------------------------- */
-static t_class *sigdelwrite_class;
-
-typedef struct delwritectl
-{
- int c_n;
- float *c_vec;
- int c_phase;
-} t_delwritectl;
-
-typedef struct _sigdelwrite
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_delwritectl x_cspace;
- int x_sortno; /* DSP sort number at which this was last put on chain */
- int x_rsortno; /* DSP sort # for first delread or write in chain */
- int x_vecsize; /* vector size for delread~ to use */
- float x_f;
-} t_sigdelwrite;
-
-#define XTRASAMPS 4
-#define SAMPBLK 4
-
- /* routine to check that all delwrites/delreads/vds have same vecsize */
-static void sigdelwrite_checkvecsize(t_sigdelwrite *x, int vecsize)
-{
- /*
- LATER this should really check sample rate and blocking, once that is
- supported. Probably we don't actually care about vecsize.
- For now just suppress this check... */
-#if 0
- if (x->x_rsortno != ugen_getsortno())
- {
- x->x_vecsize = vecsize;
- x->x_rsortno = ugen_getsortno();
- }
- else if (vecsize != x->x_vecsize)
- pd_error(x, "delread/delwrite/vd vector size mismatch");
-#endif
-}
-
-static void *sigdelwrite_new(t_symbol *s, t_floatarg msec)
-{
- int nsamps;
- t_sigdelwrite *x = (t_sigdelwrite *)pd_new(sigdelwrite_class);
- if (!*s->s_name) s = gensym("delwrite~");
- pd_bind(&x->x_obj.ob_pd, s);
- x->x_sym = s;
- nsamps = msec * sys_getsr() * (float)(0.001f);
- if (nsamps < 1) nsamps = 1;
- nsamps += ((- nsamps) & (SAMPBLK - 1));
- nsamps += DEFDELVS;
- x->x_cspace.c_n = nsamps;
- x->x_cspace.c_vec =
- (float *)getbytes((nsamps + XTRASAMPS) * sizeof(float));
- x->x_cspace.c_phase = XTRASAMPS;
- x->x_sortno = 0;
- x->x_vecsize = 0;
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigdelwrite_perform(t_int *w)
-{
- t_float *in = (t_float *)(w[1]);
- t_delwritectl *c = (t_delwritectl *)(w[2]);
- int n = (int)(w[3]);
- int phase = c->c_phase, nsamps = c->c_n;
- float *vp = c->c_vec, *bp = vp + phase, *ep = vp + (c->c_n + XTRASAMPS);
- phase += n;
- while (n--)
- {
- float f = *in++;
- if (PD_BIGORSMALL(f))
- f = 0;
- *bp++ = f;
- if (bp == ep)
- {
- vp[0] = ep[-4];
- vp[1] = ep[-3];
- vp[2] = ep[-2];
- vp[3] = ep[-1];
- bp = vp + XTRASAMPS;
- phase -= nsamps;
- }
- }
- c->c_phase = phase;
- return (w+4);
-}
-
-static void sigdelwrite_dsp(t_sigdelwrite *x, t_signal **sp)
-{
- dsp_add(sigdelwrite_perform, 3, sp[0]->s_vec, &x->x_cspace, sp[0]->s_n);
- x->x_sortno = ugen_getsortno();
- sigdelwrite_checkvecsize(x, sp[0]->s_n);
-}
-
-static void sigdelwrite_free(t_sigdelwrite *x)
-{
- pd_unbind(&x->x_obj.ob_pd, x->x_sym);
- freebytes(x->x_cspace.c_vec,
- (x->x_cspace.c_n + XTRASAMPS) * sizeof(float));
-}
-
-static void sigdelwrite_setup(void)
-{
- sigdelwrite_class = class_new(gensym("delwrite~"),
- (t_newmethod)sigdelwrite_new, (t_method)sigdelwrite_free,
- sizeof(t_sigdelwrite), 0, A_DEFSYM, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(sigdelwrite_class, t_sigdelwrite, x_f);
- class_addmethod(sigdelwrite_class, (t_method)sigdelwrite_dsp,
- gensym("dsp"), 0);
-}
-
-/* ----------------------------- delread~ ----------------------------- */
-static t_class *sigdelread_class;
-
-typedef struct _sigdelread
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_float x_deltime; /* delay in msec */
- int x_delsamps; /* delay in samples */
- t_float x_sr; /* samples per msec */
- t_float x_n; /* vector size */
- int x_zerodel; /* 0 or vecsize depending on read/write order */
-} t_sigdelread;
-
-static void sigdelread_float(t_sigdelread *x, t_float f);
-
-static void *sigdelread_new(t_symbol *s, t_floatarg f)
-{
- t_sigdelread *x = (t_sigdelread *)pd_new(sigdelread_class);
- x->x_sym = s;
- x->x_sr = 1;
- x->x_n = 1;
- x->x_zerodel = 0;
- sigdelread_float(x, f);
- outlet_new(&x->x_obj, &s_signal);
- return (x);
-}
-
-static void sigdelread_float(t_sigdelread *x, t_float f)
-{
- int samps;
- t_sigdelwrite *delwriter =
- (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
- x->x_deltime = f;
- if (delwriter)
- {
- int delsize = delwriter->x_cspace.c_n;
- x->x_delsamps = (int)(0.5 + x->x_sr * x->x_deltime)
- + x->x_n - x->x_zerodel;
- if (x->x_delsamps < x->x_n) x->x_delsamps = x->x_n;
- else if (x->x_delsamps > delwriter->x_cspace.c_n - DEFDELVS)
- x->x_delsamps = delwriter->x_cspace.c_n - DEFDELVS;
- }
-}
-
-static t_int *sigdelread_perform(t_int *w)
-{
- t_float *out = (t_float *)(w[1]);
- t_delwritectl *c = (t_delwritectl *)(w[2]);
- int delsamps = *(int *)(w[3]);
- int n = (int)(w[4]);
- int phase = c->c_phase - delsamps, nsamps = c->c_n;
- float *vp = c->c_vec, *bp, *ep = vp + (c->c_n + XTRASAMPS);
-
- if (phase < 0) phase += nsamps;
- bp = vp + phase;
- while (n--)
- {
- *out++ = *bp++;
- if (bp == ep) bp -= nsamps;
- }
- return (w+5);
-}
-
-static void sigdelread_dsp(t_sigdelread *x, t_signal **sp)
-{
- t_sigdelwrite *delwriter =
- (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
- x->x_sr = sp[0]->s_sr * 0.001;
- x->x_n = sp[0]->s_n;
- if (delwriter)
- {
- sigdelwrite_checkvecsize(delwriter, sp[0]->s_n);
- x->x_zerodel = (delwriter->x_sortno == ugen_getsortno() ?
- 0 : delwriter->x_vecsize);
- sigdelread_float(x, x->x_deltime);
- dsp_add(sigdelread_perform, 4,
- sp[0]->s_vec, &delwriter->x_cspace, &x->x_delsamps, sp[0]->s_n);
- }
- else if (*x->x_sym->s_name)
- error("delread~: %s: no such delwrite~",x->x_sym->s_name);
-}
-
-static void sigdelread_setup(void)
-{
- sigdelread_class = class_new(gensym("delread~"),
- (t_newmethod)sigdelread_new, 0,
- sizeof(t_sigdelread), 0, A_DEFSYM, A_DEFFLOAT, 0);
- class_addmethod(sigdelread_class, (t_method)sigdelread_dsp,
- gensym("dsp"), 0);
- class_addfloat(sigdelread_class, (t_method)sigdelread_float);
-}
-
-
-/* ----------------------------- vd~ ----------------------------- */
-static t_class *sigvd_class;
-
-typedef struct _sigvd
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_float x_sr; /* samples per msec */
- int x_zerodel; /* 0 or vecsize depending on read/write order */
- float x_f;
-} t_sigvd;
-
-static void *sigvd_new(t_symbol *s)
-{
- t_sigvd *x = (t_sigvd *)pd_new(sigvd_class);
- if (!*s->s_name) s = gensym("vd~");
- x->x_sym = s;
- x->x_sr = 1;
- x->x_zerodel = 0;
- outlet_new(&x->x_obj, &s_signal);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigvd_perform(t_int *w)
-{
- t_float *in = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- t_delwritectl *ctl = (t_delwritectl *)(w[3]);
- t_sigvd *x = (t_sigvd *)(w[4]);
- int n = (int)(w[5]);
-
- int nsamps = ctl->c_n;
- float limit = nsamps - n - 1;
- float fn = n-1;
- float *vp = ctl->c_vec, *bp, *wp = vp + ctl->c_phase;
- float zerodel = x->x_zerodel;
- while (n--)
- {
- float delsamps = x->x_sr * *in++ - zerodel, frac;
- int idelsamps;
- float a, b, c, d, cminusb;
- if (delsamps < 1.00001f) delsamps = 1.00001f;
- if (delsamps > limit) delsamps = limit;
- delsamps += fn;
- fn = fn - 1.0f;
- idelsamps = delsamps;
- frac = delsamps - (float)idelsamps;
- bp = wp - idelsamps;
- if (bp < vp + 4) bp += nsamps;
- d = bp[-3];
- c = bp[-2];
- b = bp[-1];
- a = bp[0];
- cminusb = c-b;
- *out++ = b + frac * (
- cminusb - 0.1666667f * (1.-frac) * (
- (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b)
- )
- );
- }
- return (w+6);
-}
-
-static void sigvd_dsp(t_sigvd *x, t_signal **sp)
-{
- t_sigdelwrite *delwriter =
- (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
- x->x_sr = sp[0]->s_sr * 0.001;
- if (delwriter)
- {
- sigdelwrite_checkvecsize(delwriter, sp[0]->s_n);
- x->x_zerodel = (delwriter->x_sortno == ugen_getsortno() ?
- 0 : delwriter->x_vecsize);
- dsp_add(sigvd_perform, 5,
- sp[0]->s_vec, sp[1]->s_vec,
- &delwriter->x_cspace, x, sp[0]->s_n);
- }
- else error("vd~: %s: no such delwrite~",x->x_sym->s_name);
-}
-
-static void sigvd_setup(void)
-{
- sigvd_class = class_new(gensym("vd~"), (t_newmethod)sigvd_new, 0,
- sizeof(t_sigvd), 0, A_DEFSYM, 0);
- class_addmethod(sigvd_class, (t_method)sigvd_dsp, gensym("dsp"), 0);
- CLASS_MAINSIGNALIN(sigvd_class, t_sigvd, x_f);
-}
-
-/* ----------------------- global setup routine ---------------- */
-
-void d_delay_setup(void)
-{
- sigdelwrite_setup();
- sigdelread_setup();
- sigvd_setup();
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/d_fft.c b/apps/plugins/pdbox/PDa/src/d_fft.c
index 9916fdcb88..7b70561a0e 100644
--- a/apps/plugins/pdbox/PDa/src/d_fft.c
+++ b/apps/plugins/pdbox/PDa/src/d_fft.c
@@ -342,347 +342,4 @@ void d_fft_setup(void)
sigrifft_setup();
// sigframp_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include "m_pd.h"
-
-/* ------------------------ fft~ and ifft~ -------------------------------- */
-static t_class *sigfft_class, *sigifft_class;
-
-typedef struct fft
-{
- t_object x_obj;
- float x_f;
-} t_sigfft;
-
-static void *sigfft_new(void)
-{
- t_sigfft *x = (t_sigfft *)pd_new(sigfft_class);
- outlet_new(&x->x_obj, gensym("signal"));
- outlet_new(&x->x_obj, gensym("signal"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- x->x_f = 0;
- return (x);
-}
-
-static void *sigifft_new(void)
-{
- t_sigfft *x = (t_sigfft *)pd_new(sigifft_class);
- outlet_new(&x->x_obj, gensym("signal"));
- outlet_new(&x->x_obj, gensym("signal"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigfft_swap(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- int n = w[3];
- for (;n--; in1++, in2++)
- {
- float f = *in1;
- *in1 = *in2;
- *in2 = f;
- }
- return (w+4);
-}
-
-static t_int *sigfft_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- int n = w[3];
- mayer_fft(n, in1, in2);
- return (w+4);
-}
-
-static t_int *sigifft_perform(t_int *w)
-{
- t_sample *in1 = (t_sample *)(w[1]);
- t_sample *in2 = (t_sample *)(w[2]);
- int n = w[3];
- mayer_ifft(n, in1, in2);
- return (w+4);
-}
-
-static void sigfft_dspx(t_sigfft *x, t_signal **sp, t_int *(*f)(t_int *w))
-{
- int n = sp[0]->s_n;
- t_sample *in1 = sp[0]->s_vec;
- t_sample *in2 = sp[1]->s_vec;
- t_sample *out1 = sp[2]->s_vec;
- t_sample *out2 = sp[3]->s_vec;
- if (out1 == in2 && out2 == in1)
- dsp_add(sigfft_swap, 3, out1, out2, n);
- else if (out1 == in2)
- {
- dsp_add(copy_perform, 3, in2, out2, n);
- dsp_add(copy_perform, 3, in1, out1, n);
- }
- else
- {
- if (out1 != in1) dsp_add(copy_perform, 3, in1, out1, n);
- if (out2 != in2) dsp_add(copy_perform, 3, in2, out2, n);
- }
- dsp_add(f, 3, sp[2]->s_vec, sp[3]->s_vec, n);
-}
-
-static void sigfft_dsp(t_sigfft *x, t_signal **sp)
-{
- sigfft_dspx(x, sp, sigfft_perform);
-}
-
-static void sigifft_dsp(t_sigfft *x, t_signal **sp)
-{
- sigfft_dspx(x, sp, sigifft_perform);
-}
-
-static void sigfft_setup(void)
-{
- sigfft_class = class_new(gensym("fft~"), sigfft_new, 0,
- sizeof(t_sigfft), 0, 0);
- CLASS_MAINSIGNALIN(sigfft_class, t_sigfft, x_f);
- class_addmethod(sigfft_class, (t_method)sigfft_dsp, gensym("dsp"), 0);
-
- sigifft_class = class_new(gensym("ifft~"), sigifft_new, 0,
- sizeof(t_sigfft), 0, 0);
- CLASS_MAINSIGNALIN(sigifft_class, t_sigfft, x_f);
- class_addmethod(sigifft_class, (t_method)sigifft_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(sigifft_class, gensym("fft~"));
-}
-
-/* ----------------------- rfft~ -------------------------------- */
-
-static t_class *sigrfft_class;
-
-typedef struct rfft
-{
- t_object x_obj;
- float x_f;
-} t_sigrfft;
-
-static void *sigrfft_new(void)
-{
- t_sigrfft *x = (t_sigrfft *)pd_new(sigrfft_class);
- outlet_new(&x->x_obj, gensym("signal"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigrfft_flip(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = w[3];
- while (n--) *(--out) = *in++;
- *(--out) = 0; /* to hell with it */
- return (w+4);
-}
-static t_int *sigrfft_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- int n = w[2];
- mayer_realfft(n, in);
- return (w+3);
-}
-
-static void sigrfft_dsp(t_sigrfft *x, t_signal **sp)
-{
- int n = sp[0]->s_n, n2 = (n>>1);
- t_sample *in1 = sp[0]->s_vec;
- t_sample *out1 = sp[1]->s_vec;
- t_sample *out2 = sp[2]->s_vec;
- if (n < 4)
- {
- error("fft: minimum 4 points");
- return;
- }
- if (in1 == out2) /* this probably never happens */
- {
- dsp_add(sigrfft_perform, 2, out2, n);
- dsp_add(copy_perform, 3, out2, out1, n2);
- dsp_add(sigrfft_flip, 3, out2 + (n2+1), out2 + n2, n2-1);
- }
- else
- {
- if (in1 != out1) dsp_add(copy_perform, 3, in1, out1, n);
- dsp_add(sigrfft_perform, 2, out1, n);
- dsp_add(sigrfft_flip, 3, out1 + (n2+1), out2 + n2, n2-1);
- }
- dsp_add_zero(out1 + n2, n2);
- dsp_add_zero(out2 + n2, n2);
-}
-
-static void sigrfft_setup(void)
-{
- sigrfft_class = class_new(gensym("rfft~"), sigrfft_new, 0,
- sizeof(t_sigrfft), 0, 0);
- CLASS_MAINSIGNALIN(sigrfft_class, t_sigrfft, x_f);
- class_addmethod(sigrfft_class, (t_method)sigrfft_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(sigrfft_class, gensym("fft~"));
-}
-
-/* ----------------------- rifft~ -------------------------------- */
-
-static t_class *sigrifft_class;
-
-typedef struct rifft
-{
- t_object x_obj;
- float x_f;
-} t_sigrifft;
-
-static void *sigrifft_new(void)
-{
- t_sigrifft *x = (t_sigrifft *)pd_new(sigrifft_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigrifft_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- int n = w[2];
- mayer_realifft(n, in);
- return (w+3);
-}
-
-static void sigrifft_dsp(t_sigrifft *x, t_signal **sp)
-{
- int n = sp[0]->s_n, n2 = (n>>1);
- t_sample *in1 = sp[0]->s_vec;
- t_sample *in2 = sp[1]->s_vec;
- t_sample *out1 = sp[2]->s_vec;
- if (n < 4)
- {
- error("fft: minimum 4 points");
- return;
- }
- if (in2 == out1)
- {
- dsp_add(sigrfft_flip, 3, out1+1, out1 + n, (n2-1));
- dsp_add(copy_perform, 3, in1, out1, n2);
- }
- else
- {
- if (in1 != out1) dsp_add(copy_perform, 3, in1, out1, n2);
- dsp_add(sigrfft_flip, 3, in2+1, out1 + n, n2-1);
- }
- dsp_add(sigrifft_perform, 2, out1, n);
-}
-
-static void sigrifft_setup(void)
-{
- sigrifft_class = class_new(gensym("rifft~"), sigrifft_new, 0,
- sizeof(t_sigrifft), 0, 0);
- CLASS_MAINSIGNALIN(sigrifft_class, t_sigrifft, x_f);
- class_addmethod(sigrifft_class, (t_method)sigrifft_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(sigrifft_class, gensym("fft~"));
-}
-
-/* ----------------------- framp~ -------------------------------- */
-
-#if 0
-static t_class *sigframp_class;
-
-typedef struct framp
-{
- t_object x_obj;
- float x_f;
-} t_sigframp;
-
-static void *sigframp_new(void)
-{
- t_sigframp *x = (t_sigframp *)pd_new(sigframp_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, gensym("signal"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigframp_perform(t_int *w)
-{
- float *inreal = (t_float *)(w[1]);
- float *inimag = (t_float *)(w[2]);
- float *outfreq = (t_float *)(w[3]);
- float *outamp = (t_float *)(w[4]);
- float lastreal = 0, currentreal = inreal[0], nextreal = inreal[1];
- float lastimag = 0, currentimag = inimag[0], nextimag = inimag[1];
- int n = w[5];
- int m = n + 1;
- float fbin = 1, oneovern2 = 1.f/((float)n * (float)n);
-
- inreal += 2;
- inimag += 2;
- *outamp++ = *outfreq++ = 0;
- n -= 2;
- while (n--)
- {
- float re, im, pow, freq;
- lastreal = currentreal;
- currentreal = nextreal;
- nextreal = *inreal++;
- lastimag = currentimag;
- currentimag = nextimag;
- nextimag = *inimag++;
- re = currentreal - 0.5f * (lastreal + nextreal);
- im = currentimag - 0.5f * (lastimag + nextimag);
- pow = re * re + im * im;
- if (pow > 1e-19)
- {
- float detune = ((lastreal - nextreal) * re +
- (lastimag - nextimag) * im) / (2.0f * pow);
- if (detune > 2 || detune < -2) freq = pow = 0;
- else freq = fbin + detune;
- }
- else freq = pow = 0;
- *outfreq++ = freq;
- *outamp++ = oneovern2 * pow;
- fbin += 1.0f;
- }
- while (m--) *outamp++ = *outfreq++ = 0;
- return (w+6);
-}
-
-t_int *sigsqrt_perform(t_int *w);
-
-static void sigframp_dsp(t_sigframp *x, t_signal **sp)
-{
- int n = sp[0]->s_n, n2 = (n>>1);
- if (n < 4)
- {
- error("framp: minimum 4 points");
- return;
- }
- dsp_add(sigframp_perform, 5, sp[0]->s_vec, sp[1]->s_vec,
- sp[2]->s_vec, sp[3]->s_vec, n2);
- dsp_add(sigsqrt_perform, 3, sp[3]->s_vec, sp[3]->s_vec, n2);
-}
-
-static void sigframp_setup(void)
-{
- sigframp_class = class_new(gensym("framp~"), sigframp_new, 0,
- sizeof(t_sigframp), 0, 0);
- CLASS_MAINSIGNALIN(sigframp_class, t_sigframp, x_f);
- class_addmethod(sigframp_class, (t_method)sigframp_dsp, gensym("dsp"), 0);
-}
-#endif
-
-/* ------------------------ global setup routine ------------------------- */
-
-void d_fft_setup(void)
-{
- sigfft_setup();
- sigrfft_setup();
- sigrifft_setup();
-// sigframp_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/d_fftroutine.c b/apps/plugins/pdbox/PDa/src/d_fftroutine.c
index dde24fa358..41948132d7 100644
--- a/apps/plugins/pdbox/PDa/src/d_fftroutine.c
+++ b/apps/plugins/pdbox/PDa/src/d_fftroutine.c
@@ -999,1004 +999,4 @@ void pd_fft(float *buf, int npoints, int inverse)
buf, RECT, LINEAR, buf, RECT, LINEAR, 0);
for (i = npoints << 1, fp = buf; i--; fp++) *fp *= renorm;
}
-/*****************************************************************************/
-/* */
-/* Fast Fourier Transform */
-/* Network Abstraction, Definitions */
-/* Kevin Peterson, MIT Media Lab, EMS */
-/* UROP - Fall '86 */
-/* REV: 6/12/87(KHP) - To incorporate link list of different sized networks */
-/* */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* added debug option 5/91 brown@nadia */
-/* change sign at AAA */
-/* */
-/* Fast Fourier Transform */
-/* FFT Network Interaction and Support Modules */
-/* Kevin Peterson, MIT Media Lab, EMS */
-/* UROP - Fall '86 */
-/* REV: 6/12/87(KHP) - Generalized to one procedure call with typed I/O */
-/* */
-/*****************************************************************************/
-
-/* Overview:
-
- My realization of the FFT involves a representation of a network of
- "butterfly" elements that takes a set of 'N' sound samples as input and
- computes the discrete Fourier transform. This network consists of a
- series of stages (log2 N), each stage consisting of N/2 parallel butterfly
- elements. Consecutive stages are connected by specific, predetermined flow
- paths, (see Oppenheim, Schafer for details) and each butterfly element has
- an associated multiplicative coefficient.
-
- FFT NETWORK:
- -----------
- ____ _ ____ _ ____ _ ____ _ ____
- o--| |o-| |-o| |o-| |-o| |o-| |-o| |o-| |-o| |--o
- |reg1| | | |W^r1| | | |reg1| | | |W^r1| | | |reg1|
- | | | | | | | | | | | | | | | | | | .....
- | | | | | | | | | | | | | | | | | |
- o--|____|o-| |-o|____|o-| |-o|____|o-| |-o|____|o-| |-o|____|--o
- | | | | | | | |
- | | | | | | | |
- ____ | | ____ | | ____ | | ____ | | ____
- o--| |o-| |-o| |o-| |-o| |o-| |-o| |o-| |-o| |--o
- |reg2| | | |W^r2| | | |reg2| | | |W^r2| | | |reg2|
- | | | | | | | | | | | | | | | | | | .....
- | | | | | | | | | | | | | | | | | |
- o--|____|o-| |-o|____|o-| |-o|____|o-| |-o|____|o-| |-o|____|--o
- | | | | | | | |
- | | | | | | | |
- : : : : : : : : :
- : : : : : : : : :
- : : : : : : : : :
- : : : : : : : : :
- : : : : : : : : :
-
- ____ | | ____ | | ____ | | ____ | | ____
- o--| |o-| |-o| |o-| |-o| |o-| |-o| |o-| |-o| |--o
- |reg | | | |W^r | | | |reg | | | |W^r | | | |reg |
- | N/2| | | | N/2| | | | N/2| | | | N/2| | | | N/2| .....
- | | | | | | | | | | | | | | | | | |
- o--|____|o-|_|-o|____|o-|_|-o|____|o-|_|-o|____|o-|_|-o|____|--o
-
- ^ ^ ^ ^
- Initial | Bttrfly | Rd/Wrt | Bttrfly | Rd/Wrt
- Buffer | | Register | | Register
- |____________|____________|____________|
- |
- |
- Interconnect
- Paths
-
- The use of "in-place" computation permits one to use only one set of
- registers realized by an array of complex number structures. To describe
- the coefficients for each butterfly I am using a two dimensional array
- (stage, butterfly) of complex numbers. The predetermined stage connections
- will be described in a two dimensional array of indicies. These indicies
- will be used to determine the order of reading at each stage of the
- computation.
-*/
-
-
-/*****************************************************************************/
-/* INCLUDE FILES */
-/*****************************************************************************/
-
-#include <stdio.h>
-#include <math.h>
-#include <stdlib.h>
-
- /* the following is needed only to declare pd_fft() as exportable in MSW */
-#include "m_pd.h"
-
-/* some basic definitions */
-#ifndef BOOL
-#define BOOL int
-#define TRUE 1
-#define FALSE 0
-#endif
-
-#define SAMPLE float /* data type used in calculation */
-
-#define SHORT_SIZE sizeof(short)
-#define INT_SIZE sizeof(int)
-#define FLOAT_SIZE sizeof(float)
-#define SAMPLE_SIZE sizeof(SAMPLE)
-#define PNTR_SIZE sizeof(char *)
-
-#define PI 3.1415927
-#define TWO_PI 6.2831854
-
-/* type definitions for I/O buffers */
-#define REAL 0 /* real only */
-#define IMAG 2 /* imaginary only */
-#define RECT 8 /* real and imaginary */
-#define MAG 16 /* magnitude only */
-#define PHASE 32 /* phase only */
-#define POLAR 64 /* magnitude and phase*/
-
-/* scale definitions for I/O buffers */
-#define LINEAR 0
-#define DB 1 /* 20log10 */
-
-/* transform direction definition */
-#define FORWARD 1 /* Forward FFT */
-#define INVERSE 2 /* Inverse FFT */
-
-/* window type definitions */
-#define HANNING 1
-#define RECTANGULAR 0
-
-
-
-/* network structure definition */
-
-typedef struct Tfft_net {
- int n;
- int stages;
- int bps;
- int direction;
- int window_type;
- int *load_index;
- SAMPLE *window, *inv_window;
- SAMPLE *regr;
- SAMPLE *regi;
- SAMPLE **indexpr;
- SAMPLE **indexpi;
- SAMPLE **indexqr;
- SAMPLE **indexqi;
- SAMPLE *coeffr, *inv_coeffr;
- SAMPLE *coeffi, *inv_coeffi;
- struct Tfft_net *next;
-} FFT_NET;
-
-
-void cfft(int trnsfrm_dir, int npnt, int window,
- float *source_buf, int source_form, int source_scale,
- float *result_buf, int result_form, int result_scale, int debug);
-
-
-/*****************************************************************************/
-/* GLOBAL DECLARATIONS */
-/*****************************************************************************/
-
-static FFT_NET *firstnet;
-
-/* prototypes */
-
-void net_alloc(FFT_NET *fft_net);
-void net_dealloc(FFT_NET *fft_net);
-int power_of_two(int n);
-void create_hanning(SAMPLE *window, int n, SAMPLE scale);
-void create_rectangular(SAMPLE *window, int n, SAMPLE scale);
-void short_to_float(short *short_buf, float *float_buf, int n);
-void load_registers(FFT_NET *fft_net, float *buf, int buf_form,
- int buf_scale, int trnsfrm_dir);
-void compute_fft(FFT_NET *fft_net);
-void store_registers(FFT_NET *fft_net, float *buf, int buf_form,
- int buf_scale, int debug);
-void build_fft_network(FFT_NET *fft_net, int n, int window_type);
-
-/*****************************************************************************/
-/* GENERALIZED FAST FOURIER TRANSFORM MODULE */
-/*****************************************************************************/
-
-void cfft(int trnsfrm_dir, int npnt, int window,
- float *source_buf, int source_form, int source_scale,
- float *result_buf, int result_form, int result_scale, int debug)
-
-/* modifies: result_buf
- effects: Computes npnt FFT specified by form, scale, and dir parameters.
- Source samples (single precision float) are taken from soure_buf and
- the transfrmd representation is stored in result_buf (single precision
- float). The parameters are defined as follows:
-
- trnsfrm_dir = FORWARD | INVERSE
- npnt = 2^k for some any positive integer k
- window = HANNING | RECTANGULAR
- (RECT = real and imag parts, POLAR = magnitude and phase)
- source_form = REAL | IMAG | RECT | POLAR
- result_form = REAL | IMAG | RECT | MAG | PHASE | POLAR
- xxxxxx_scale= LINEAR | DB ( 20log10 |mag| )
-
- The input/output buffers are stored in a form appropriate to the type.
- For example: REAL => {real, real, real ...},
- MAG => {mag, mag, mag, ... },
- RECT => {real, imag, real, imag, ... },
- POLAR => {mag, phase, mag, phase, ... }.
-
- To look at the magnitude (in db) of a 1024 point FFT of a real time
- signal we have:
-
- fft(FORWARD, 1024, RECTANGULAR, input, REAL, LINEAR, output, MAG, DB)
-
- All possible input and output combinations are possible given the
- choice of type and scale parameters.
-*/
-
-{
- FFT_NET *thisnet = (FFT_NET *)0;
- FFT_NET *lastnet = (FFT_NET *)0;
-
- /* A linked list of fft networks of different sizes is maintained to
- avoid building with every call. The network is built on the first
- call but reused for subsequent calls requesting the same size
- transformation.
- */
-
- thisnet=firstnet;
- while (thisnet) {
- if (!(thisnet->n == npnt) || !(thisnet->window_type == window)) {
- /* current net doesn't match size or window type */
- lastnet=thisnet;
- thisnet=thisnet->next;
- continue; /* keep looking */
- }
-
- else { /* network matches desired size */
- load_registers(thisnet, source_buf, source_form, source_scale,
- trnsfrm_dir);
- compute_fft(thisnet); /* do transformation */
- store_registers(thisnet, result_buf, result_form, result_scale,debug);
- return;
- }
- }
-
- /* none of existing networks match required size*/
-
- if (lastnet) { /* add new network to end of list */
- thisnet = (FFT_NET *)malloc(sizeof(FFT_NET)); /* allocate */
- thisnet->next = 0;
- lastnet->next = thisnet; /* add to end of list */
- }
- else { /* first network to be created */
- thisnet=firstnet=(FFT_NET *)malloc(sizeof(FFT_NET)); /* alloc. */
- thisnet->next = 0;
- }
-
- /* build new network and compute transformation */
- build_fft_network(thisnet, npnt, window);
- load_registers(thisnet, source_buf, source_form, source_scale,
- trnsfrm_dir);
- compute_fft(thisnet);
- store_registers(thisnet, result_buf, result_form, result_scale,debug);
- return;
-}
-
-void fft_clear(void)
-
-/* effects: Deallocates all preserved FFT networks. Should be used when
- finished with all computations.
-*/
-
-{
- FFT_NET *thisnet, *nextnet;
-
- if (firstnet) {
- thisnet=firstnet;
- do {
- nextnet = thisnet->next;
- net_dealloc(thisnet);
- free((char *)thisnet);
- } while (thisnet = nextnet);
- }
-}
-
-
-/*****************************************************************************/
-/* NETWORK CONSTRUCTION */
-/*****************************************************************************/
-
-void build_fft_network(FFT_NET *fft_net, int n, int window_type)
-
-
-/* modifies:fft_net
- effects: Constructs the fft network as described in fft.h. Butterfly
- coefficients, read/write indicies, bit reversed load indicies,
- and array allocations are computed.
-*/
-
-{
- int cntr, i, j, s;
- int stages, bps;
- int **p, **q, *pp, *qp;
- SAMPLE two_pi_div_n = TWO_PI / n;
-
-
- /* network definition */
- fft_net->n = n;
- fft_net->bps = bps = n/2;
- for (i = 0, j = n; j > 1; j >>= 1, i++);
- fft_net->stages = stages = i;
- fft_net->direction = FORWARD;
- fft_net->window_type = window_type;
- fft_net->next = (FFT_NET *)0;
-
- /* allocate registers, index, coefficient arrays */
- net_alloc(fft_net);
-
-
- /* create appropriate windows */
- if (window_type==HANNING) {
- create_hanning(fft_net->window, n, 1.);
- create_hanning(fft_net->inv_window, n, 1./n);
- }
- else {
- create_rectangular(fft_net->window, n, 1.);
- create_rectangular(fft_net->inv_window, n, 1./n);
- }
-
-
- /* calculate butterfly coefficients */ {
-
- int num_diff_coeffs, power_inc, power;
- SAMPLE *coeffpr = fft_net->coeffr;
- SAMPLE *coeffpi = fft_net->coeffi;
- SAMPLE *inv_coeffpr = fft_net->inv_coeffr;
- SAMPLE *inv_coeffpi = fft_net->inv_coeffi;
-
- /* stage one coeffs are 1 + 0j */
- for (i = 0; i < bps; i++) {
- *coeffpr = *inv_coeffpr = 1.;
- *coeffpi = *inv_coeffpi = 0.;
- coeffpr++; inv_coeffpr++;
- coeffpi++; inv_coeffpi++;
- }
-
- /* stage 2 to last stage coeffs need calculation */
- /* (1<<r <=> 2^r */
- for (s = 2; s <= stages; s++) {
-
- num_diff_coeffs = n / (1 << (stages - s + 1));
- power_inc = 1 << (stages -s);
- cntr = 0;
-
- for (i = bps/num_diff_coeffs; i > 0; i--) {
-
- power = 0;
-
- for (j = num_diff_coeffs; j > 0; j--) {
- *coeffpr = cos(two_pi_div_n*power);
- *inv_coeffpr = cos(two_pi_div_n*power);
-/* AAA change these signs */ *coeffpi = -sin(two_pi_div_n*power);
-/* change back */ *inv_coeffpi = sin(two_pi_div_n*power);
- power += power_inc;
- coeffpr++; inv_coeffpr++;
- coeffpi++; inv_coeffpi++;
- }
- }
- }
- }
-
- /* calculate network indicies: stage exchange indicies are
- calculated and then used as offset values from the base
- register locations. The final addresses are then stored in
- fft_net.
- */ {
-
- int index, inc;
- SAMPLE **indexpr = fft_net->indexpr;
- SAMPLE **indexpi = fft_net->indexpi;
- SAMPLE **indexqr = fft_net->indexqr;
- SAMPLE **indexqi = fft_net->indexqi;
- SAMPLE *regr = fft_net->regr;
- SAMPLE *regi = fft_net->regi;
-
-
- /* allocate temporary 2d stage exchange index, 1d temp
- load index */
- p = (int **)malloc(stages * PNTR_SIZE);
- q = (int **)malloc(stages * PNTR_SIZE);
-
- for (s = 0; s < stages; s++) {
- p[s] = (int *)malloc(bps * INT_SIZE);
- q[s] = (int *)malloc(bps * INT_SIZE);
- }
-
- /* calculate stage exchange indicies: */
- for (s = 0; s < stages; s++) {
- pp = p[s];
- qp = q[s];
- inc = 1 << s;
- cntr = 1 << (stages-s-1);
- i = j = index = 0;
-
- do {
- do {
- qp[i] = index + inc;
- pp[i++] = index++;
- } while (++j < inc);
- index = qp[i-1] + 1;
- j = 0;
- } while (--cntr);
- }
-
- /* compute actual address values using indicies as offsets */
- for (s = 0; s < stages; s++) {
- for (i = 0; i < bps; i++) {
- *indexpr++ = regr + p[s][i];
- *indexpi++ = regi + p[s][i];
- *indexqr++ = regr + q[s][i];
- *indexqi++ = regi + q[s][i];
- }
- }
- }
-
-
- /* calculate load indicies (bit reverse ordering) */
- /* bit reverse ordering achieved by passing normal
- order indicies backwards through the network */
-
- /* init to normal order indicies */ {
- int *load_index,*load_indexp;
- int *temp_indexp, *temp_index;
- temp_index=temp_indexp=(int *)malloc(n * INT_SIZE);
-
- i = 0; j = n;
- load_index = load_indexp = fft_net->load_index;
-
- while (j--)
- *load_indexp++ = i++;
-
- /* pass indicies backwards through net */
- for (s = stages - 1; s > 0; s--) {
- pp = p[s];
- qp = q[s];
-
- for (i = 0; i < bps; i++) {
- temp_index[pp[i]]=load_index[2*i];
- temp_index[qp[i]]=load_index[2*i+1];
- }
- j = n;
- load_indexp = load_index;
- temp_indexp = temp_index;
- while (j--)
- *load_indexp++ = *temp_indexp++;
- }
-
- /* free all temporary arrays */
- free((char *)temp_index);
- for (s = 0; s < stages; s++) {
- free((char *)p[s]);free((char *)q[s]);
- }
- free((char *)p);free((char *)q);
- }
-}
-
-
-
-/*****************************************************************************/
-/* REGISTER LOAD AND STORE */
-/*****************************************************************************/
-
-void load_registers(FFT_NET *fft_net, float *buf, int buf_form,
- int buf_scale, int trnsfrm_dir)
-
-/* effects: Multiplies the input buffer with the appropriate window and
- stores the resulting values in the initial registers of the
- network. Input buffer must contain values appropriate to form.
- For RECT, the buffer contains real num. followed by imag num,
- and for POLAR, it contains magnitude followed by phase. Pure
- inputs are listed normally. Both LINEAR and DB scales are
- interpreted.
-*/
-
-{
- int *load_index = fft_net->load_index;
- SAMPLE *window;
- int index, i = 0, n = fft_net->n;
-
- if (trnsfrm_dir==FORWARD) window = fft_net->window;
- else if (trnsfrm_dir==INVERSE) window = fft_net->inv_window;
- else {
- fprintf(stderr, "load_registers:illegal transform direction\n");
- exit(0);
- }
- fft_net->direction = trnsfrm_dir;
-
- switch(buf_scale) {
- case LINEAR: {
- switch (buf_form) {
- case REAL: { /* pure REAL */
- while (i < fft_net->n) {
- index = load_index[i];
- fft_net->regr[i]=(SAMPLE)buf[index] * window[index];
- fft_net->regi[i]=0.;
- i++;
- }
- } break;
-
- case IMAG: { /* pure IMAGinary */
- while (i < fft_net->n) {
- index = load_index[i];
- fft_net->regr[i]=0;
- fft_net->regi[i]=(SAMPLE)buf[index] * window[index];
- i++;
- }
- } break;
-
- case RECT: { /* both REAL and IMAGinary */
- while (i < fft_net->n) {
- index = load_index[i];
- fft_net->regr[i]=(SAMPLE)buf[index*2] * window[index];
- fft_net->regi[i]=(SAMPLE)buf[index*2+1] * window[index];
- i++;
- }
- } break;
-
- case POLAR: { /* magnitude followed by phase */
- while (i < fft_net->n) {
- index = load_index[i];
- fft_net->regr[i]=(SAMPLE)(buf[index*2] * cos(buf[index*2+1]))
- * window[index];
- fft_net->regi[i]=(SAMPLE)(buf[index*2] * sin(buf[index*2+1]))
- * window[index];
- i++;
- }
- } break;
-
- default: {
- fprintf(stderr, "load_registers:illegal input form\n");
- exit(0);
- } break;
- }
- } break;
-
- case DB: {
-
- switch (buf_form) {
- case REAL: { /* log pure REAL */
- while (i < fft_net->n) {
- index = load_index[i];
- fft_net->regr[i]=(SAMPLE)pow(10., (1./20.)*buf[index])
- * window[index]; /* window scaling after linearization */
- fft_net->regi[i]=0.;
- i++;
- }
- } break;
-
- case IMAG: { /* log pure IMAGinary */
- while (i < fft_net->n) {
- index = load_index[i];
- fft_net->regr[i]=0.;
- fft_net->regi[i]=(SAMPLE)pow(10., (1./20.)*buf[index])
- * window[index];
- i++;
- }
- } break;
-
- case RECT: { /* log REAL and log IMAGinary */
- while (i < fft_net->n) {
- index = load_index[i];
- fft_net->regr[i]=(SAMPLE)pow(10., (1./20.)*buf[index*2])
- * window[index];
- fft_net->regi[i]=(SAMPLE)pow(10., (1./20.)*buf[index*2+1])
- * window[index];
- i++;
- }
- } break;
-
- case POLAR: { /* log mag followed by phase */
- while (i < fft_net->n) {
- index = load_index[i];
- fft_net->regr[i]=(SAMPLE)(pow(10., (1./20.)*buf[index*2])
- * cos(buf[index*2+1])) * window[index];
- fft_net->regi[i]=(SAMPLE)(pow(10., (1./20.)*buf[index*2])
- * sin(buf[index*2+1])) * window[index];
- i++;
- }
- } break;
-
- default: {
- fprintf(stderr, "load_registers:illegal input form\n");
- exit(0);
- } break;
- }
- } break;
-
- default: {
- fprintf(stderr, "load_registers:illegal input scale\n");
- exit(0);
- } break;
- }
-}
-
-
-void store_registers(FFT_NET *fft_net, float *buf, int buf_form,
- int buf_scale, int debug)
-
-/* modifies: buf
- effects: Writes the final contents of the network registers into buf in
- either linear or db scale, polar or rectangular form. If any of
- the pure forms(REAL, IMAG, MAG, or PHASE) are used then only the
- corresponding part of the registers is stored in buf.
-*/
-
-{
- int i;
- SAMPLE real, imag, mag, phase;
- int n;
-
- i = 0;
- n = fft_net->n;
-
- switch (buf_scale) {
- case LINEAR: {
-
- switch (buf_form) {
- case REAL: { /* pure REAL */
- do {
- *buf++ = (float)fft_net->regr[i];
- } while (++i < n);
- } break;
-
- case IMAG: { /* pure IMAGinary */
- do {
- *buf++ = (float)fft_net->regi[i];
- } while (++i < n);
- } break;
-
- case RECT: { /* both REAL and IMAGinary */
- do {
- *buf++ = (float)fft_net->regr[i];
- *buf++ = (float)fft_net->regi[i];
- } while (++i < n);
- } break;
-
- case MAG: { /* magnitude only */
- do {
- real = fft_net->regr[i];
- imag = fft_net->regi[i];
- *buf++ = (float)sqrt(real*real+imag*imag);
- } while (++i < n);
- } break;
-
- case PHASE: { /* phase only */
- do {
- real = fft_net->regr[i];
- imag = fft_net->regi[i];
- if (real > .00001)
- *buf++ = (float)atan2(imag, real);
- else { /* deal with bad case */
- if (imag > 0){ *buf++ = PI / 2.;
- if(debug) fprintf(stderr,"real=0 and imag > 0\n");}
- else if (imag < 0){ *buf++ = -PI / 2.;
- if(debug) fprintf(stderr,"real=0 and imag < 0\n");}
- else { *buf++ = 0;
- if(debug) fprintf(stderr,"real=0 and imag=0\n");}
- }
- } while (++i < n);
- } break;
-
- case POLAR: { /* magnitude and phase */
- do {
- real = fft_net->regr[i];
- imag = fft_net->regi[i];
- *buf++ = (float)sqrt(real*real+imag*imag);
- if (real) /* a hack to avoid div by zero */
- *buf++ = (float)atan2(imag, real);
- else { /* deal with bad case */
- if (imag > 0) *buf++ = PI / 2.;
- else if (imag < 0) *buf++ = -PI / 2.;
- else *buf++ = 0;
- }
- } while (++i < n);
- } break;
-
- default: {
- fprintf(stderr, "store_registers:illegal output form\n");
- exit(0);
- } break;
- }
- } break;
-
- case DB: {
-
- switch (buf_form) {
- case REAL: { /* real only */
- do {
- *buf++ = (float)20.*log10(fft_net->regr[i]);
- } while (++i < n);
- } break;
-
- case IMAG: { /* imag only */
- do {
- *buf++ = (float)20.*log10(fft_net->regi[i]);
- } while (++i < n);
- } break;
-
- case RECT: { /* real and imag */
- do {
- *buf++ = (float)20.*log10(fft_net->regr[i]);
- *buf++ = (float)20.*log10(fft_net->regi[i]);
- } while (++i < n);
- } break;
-
- case MAG: { /* magnitude only */
- do {
- real = fft_net->regr[i];
- imag = fft_net->regi[i];
- *buf++ = (float)20.*log10(sqrt(real*real+imag*imag));
- } while (++i < n);
- } break;
-
- case PHASE: { /* phase only */
- do {
- real = fft_net->regr[i];
- imag = fft_net->regi[i];
- if (real)
- *buf++ = (float)atan2(imag, real);
- else { /* deal with bad case */
- if (imag > 0) *buf++ = PI / 2.;
- else if (imag < 0) *buf++ = -PI / 2.;
- else *buf++ = 0;
- }
- } while (++i < n);
- } break;
-
- case POLAR: { /* magnitude and phase */
- do {
- real = fft_net->regr[i];
- imag = fft_net->regi[i];
- *buf++ = (float)20.*log10(sqrt(real*real+imag*imag));
- if (real)
- *buf++ = (float)atan2(imag, real);
- else { /* deal with bad case */
- if (imag > 0) *buf++ = PI / 2.;
- else if (imag < 0) *buf++ = -PI / 2.;
- else *buf++ = 0;
- }
- } while (++i < n);
- } break;
-
- default: {
- fprintf(stderr, "store_registers:illegal output form\n");
- exit(0);
- } break;
- }
- } break;
-
- default: {
- fprintf(stderr, "store_registers:illegal output scale\n");
- exit(0);
- } break;
- }
-}
-
-
-
-/*****************************************************************************/
-/* COMPUTE TRANSFORMATION */
-/*****************************************************************************/
-
-void compute_fft(FFT_NET *fft_net)
-
-
-/* modifies: fft_net
- effects: Passes the values (already loaded) in the registers through
- the network, multiplying with appropriate coefficients at each
- stage. The fft result will be in the registers at the end of
- the computation. The direction of the transformation is indicated
- by the network flag 'direction'. The form of the computation is:
-
- X(pn) = X(p) + C*X(q)
- X(qn) = X(p) - C*X(q)
-
- where X(pn,qn) represents the output of the registers at each stage.
- The calculations are actually done in place. Register pointers are
- used to speed up the calculations.
-
- Register and coefficient addresses involved in the calculations
- are stored sequentially and are accessed as such. fft_net->indexp,
- indexq contain pointers to the relevant addresses, and fft_net->coeffs,
- inv_coeffs points to the appropriate coefficients at each stage of the
- computation.
-*/
-
-{
- SAMPLE **xpr, **xpi, **xqr, **xqi, *cr, *ci;
- int i;
- SAMPLE tpr, tpi, tqr, tqi;
- int bps = fft_net->bps;
- int cnt = bps * (fft_net->stages - 1);
-
- /* predetermined register addresses and coefficients */
- xpr = fft_net->indexpr;
- xpi = fft_net->indexpi;
- xqr = fft_net->indexqr;
- xqi = fft_net->indexqi;
-
- if (fft_net->direction==FORWARD) { /* FORWARD FFT coefficients */
- cr = fft_net->coeffr;
- ci = fft_net->coeffi;
- }
- else { /* INVERSE FFT coefficients */
- cr = fft_net->inv_coeffr;
- ci = fft_net->inv_coeffi;
- }
-
- /* stage one coefficients are 1 + 0j so C*X(q)=X(q) */
- /* bps mults can be avoided */
-
- for (i = 0; i < bps; i++) {
-
- /* add X(p) and X(q) */
- tpr = **xpr + **xqr;
- tpi = **xpi + **xqi;
- tqr = **xpr - **xqr;
- tqi = **xpi - **xqi;
-
- /* exchange register with temp */
- **xpr = tpr;
- **xpi = tpi;
- **xqr = tqr;
- **xqi = tqi;
-
- /* next set of register for calculations: */
- xpr++; xpi++; xqr++; xqi++; cr++; ci++;
-
- }
-
- for (i = 0; i < cnt; i++) {
-
- /* mult X(q) by coeff C */
- tqr = **xqr * *cr - **xqi * *ci;
- tqi = **xqr * *ci + **xqi * *cr;
-
- /* exchange register with temp */
- **xqr = tqr;
- **xqi = tqi;
-
- /* add X(p) and X(q) */
- tpr = **xpr + **xqr;
- tpi = **xpi + **xqi;
- tqr = **xpr - **xqr;
- tqi = **xpi - **xqi;
-
- /* exchange register with temp */
- **xpr = tpr;
- **xpi = tpi;
- **xqr = tqr;
- **xqi = tqi;
- /* next set of register for calculations: */
- xpr++; xpi++; xqr++; xqi++; cr++; ci++;
- }
-}
-
-
-/****************************************************************************/
-/* SUPPORT MODULES */
-/****************************************************************************/
-
-void net_alloc(FFT_NET *fft_net)
-
-
-/* effects: Allocates appropriate two dimensional arrays and assigns
- correct internal pointers.
-*/
-
-{
-
- int stages, bps, n;
-
- n = fft_net->n;
- stages = fft_net->stages;
- bps = fft_net->bps;
-
-
- /* two dimensional arrays with elements stored sequentially */
-
- fft_net->load_index = (int *)malloc(n * INT_SIZE);
- fft_net->regr = (SAMPLE *)malloc(n * SAMPLE_SIZE);
- fft_net->regi = (SAMPLE *)malloc(n * SAMPLE_SIZE);
- fft_net->coeffr = (SAMPLE *)malloc(stages*bps*SAMPLE_SIZE);
- fft_net->coeffi = (SAMPLE *)malloc(stages*bps*SAMPLE_SIZE);
- fft_net->inv_coeffr = (SAMPLE *)malloc(stages*bps*SAMPLE_SIZE);
- fft_net->inv_coeffi = (SAMPLE *)malloc(stages*bps*SAMPLE_SIZE);
- fft_net->indexpr = (SAMPLE **)malloc(stages * bps * PNTR_SIZE);
- fft_net->indexpi = (SAMPLE **)malloc(stages * bps * PNTR_SIZE);
- fft_net->indexqr = (SAMPLE **)malloc(stages * bps * PNTR_SIZE);
- fft_net->indexqi = (SAMPLE **)malloc(stages * bps * PNTR_SIZE);
-
- /* one dimensional load window */
- fft_net->window = (SAMPLE *)malloc(n * SAMPLE_SIZE);
- fft_net->inv_window = (SAMPLE *)malloc(n * SAMPLE_SIZE);
-}
-
-void net_dealloc(FFT_NET *fft_net)
-
-
-/* effects: Deallocates given FFT network.
-*/
-
-{
-
- free((char *)fft_net->load_index);
- free((char *)fft_net->regr);
- free((char *)fft_net->regi);
- free((char *)fft_net->coeffr);
- free((char *)fft_net->coeffi);
- free((char *)fft_net->inv_coeffr);
- free((char *)fft_net->inv_coeffi);
- free((char *)fft_net->indexpr);
- free((char *)fft_net->indexpi);
- free((char *)fft_net->indexqr);
- free((char *)fft_net->indexqi);
- free((char *)fft_net->window);
- free((char *)fft_net->inv_window);
-}
-
-
-BOOL power_of_two(n)
-
-int n;
-
-/* effects: Returns TRUE if n is a power of two, otherwise FALSE.
-*/
-
-{
- int i;
-
- for (i = n; i > 1; i >>= 1)
- if (i & 1) return FALSE; /* more than one bit high */
- return TRUE;
-}
-
-
-void create_hanning(SAMPLE *window, int n, SAMPLE scale)
-
-/* effects: Fills the buffer window with a hanning window of the appropriate
- size scaled by scale.
-*/
-
-{
- SAMPLE a, pi_div_n = PI/n;
- int k;
-
- for (k=1; k <= n; k++) {
- a = sin(k * pi_div_n);
- *window++ = scale * a * a;
- }
-}
-
-
-void create_rectangular(SAMPLE *window, int n, SAMPLE scale)
-
-/* effects: Fills the buffer window with a rectangular window of the
- appropriate size of height scale.
-*/
-
-{
- while (n--)
- *window++ = scale;
-}
-
-
-void short_to_float(short *short_buf, float *float_buf, int n)
-
-/* effects; Converts short_buf to floats and stores them in float_buf.
-*/
-
-{
- while (n--) {
- *float_buf++ = (float)*short_buf++;
- }
-}
-
-
-/* here's the meat: */
-
-void pd_fft(float *buf, int npoints, int inverse)
-{
- double renorm;
- float *fp, *fp2;
- int i;
- renorm = (inverse ? npoints : 1.);
- cfft((inverse ? INVERSE : FORWARD), npoints, RECTANGULAR,
- buf, RECT, LINEAR, buf, RECT, LINEAR, 0);
- for (i = npoints << 1, fp = buf; i--; fp++) *fp *= renorm;
-}
diff --git a/apps/plugins/pdbox/PDa/src/d_filter.c b/apps/plugins/pdbox/PDa/src/d_filter.c
index 05bb7cd58e..8b81a3a0d3 100644
--- a/apps/plugins/pdbox/PDa/src/d_filter.c
+++ b/apps/plugins/pdbox/PDa/src/d_filter.c
@@ -545,550 +545,4 @@ void d_filter_setup(void)
sigbiquad_setup();
sigsamphold_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* "filters", both linear and nonlinear.
-*/
-#include "m_pd.h"
-#include <math.h>
-
-/* ---------------- hip~ - 1-pole 1-zero hipass filter. ----------------- */
-
-typedef struct hipctl
-{
- float c_x;
- float c_coef;
-} t_hipctl;
-
-typedef struct sighip
-{
- t_object x_obj;
- float x_sr;
- float x_hz;
- t_hipctl x_cspace;
- t_hipctl *x_ctl;
- float x_f;
-} t_sighip;
-
-t_class *sighip_class;
-static void sighip_ft1(t_sighip *x, t_floatarg f);
-
-static void *sighip_new(t_floatarg f)
-{
- t_sighip *x = (t_sighip *)pd_new(sighip_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_sr = 44100;
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_x = 0;
- sighip_ft1(x, f);
- x->x_f = 0;
- return (x);
-}
-
-static void sighip_ft1(t_sighip *x, t_floatarg f)
-{
- if (f < 0) f = 0;
- x->x_hz = f;
- x->x_ctl->c_coef = 1 - f * (2 * 3.14159) / x->x_sr;
- if (x->x_ctl->c_coef < 0)
- x->x_ctl->c_coef = 0;
- else if (x->x_ctl->c_coef > 1)
- x->x_ctl->c_coef = 1;
-}
-
-static t_int *sighip_perform(t_int *w)
-{
- float *in = (float *)(w[1]);
- float *out = (float *)(w[2]);
- t_hipctl *c = (t_hipctl *)(w[3]);
- int n = (t_int)(w[4]);
- int i;
- float last = c->c_x;
- float coef = c->c_coef;
- if (coef < 1)
- {
- for (i = 0; i < n; i++)
- {
- float new = *in++ + coef * last;
- *out++ = new - last;
- last = new;
- }
- if (PD_BIGORSMALL(last))
- last = 0;
- c->c_x = last;
- }
- else
- {
- for (i = 0; i < n; i++)
- *out++ = *in++;
- c->c_x = 0;
- }
- return (w+5);
-}
-
-static void sighip_dsp(t_sighip *x, t_signal **sp)
-{
- x->x_sr = sp[0]->s_sr;
- sighip_ft1(x, x->x_hz);
- dsp_add(sighip_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-static void sighip_clear(t_sighip *x, t_floatarg q)
-{
- x->x_cspace.c_x = 0;
-}
-
-void sighip_setup(void)
-{
- sighip_class = class_new(gensym("hip~"), (t_newmethod)sighip_new, 0,
- sizeof(t_sighip), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(sighip_class, t_sighip, x_f);
- class_addmethod(sighip_class, (t_method)sighip_dsp, gensym("dsp"), 0);
- class_addmethod(sighip_class, (t_method)sighip_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addmethod(sighip_class, (t_method)sighip_clear, gensym("clear"), 0);
-}
-
-/* ---------------- lop~ - 1-pole lopass filter. ----------------- */
-
-typedef struct lopctl
-{
- float c_x;
- float c_coef;
-} t_lopctl;
-
-typedef struct siglop
-{
- t_object x_obj;
- float x_sr;
- float x_hz;
- t_lopctl x_cspace;
- t_lopctl *x_ctl;
- float x_f;
-} t_siglop;
-
-t_class *siglop_class;
-
-static void siglop_ft1(t_siglop *x, t_floatarg f);
-
-static void *siglop_new(t_floatarg f)
-{
- t_siglop *x = (t_siglop *)pd_new(siglop_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_sr = 44100;
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_x = 0;
- siglop_ft1(x, f);
- x->x_f = 0;
- return (x);
-}
-
-static void siglop_ft1(t_siglop *x, t_floatarg f)
-{
- if (f < 0) f = 0;
- x->x_hz = f;
- x->x_ctl->c_coef = f * (2 * 3.14159) / x->x_sr;
- if (x->x_ctl->c_coef > 1)
- x->x_ctl->c_coef = 1;
- else if (x->x_ctl->c_coef < 0)
- x->x_ctl->c_coef = 0;
-}
-
-static void siglop_clear(t_siglop *x, t_floatarg q)
-{
- x->x_cspace.c_x = 0;
-}
-
-static t_int *siglop_perform(t_int *w)
-{
- float *in = (float *)(w[1]);
- float *out = (float *)(w[2]);
- t_lopctl *c = (t_lopctl *)(w[3]);
- int n = (t_int)(w[4]);
- int i;
- float last = c->c_x;
- float coef = c->c_coef;
- float feedback = 1 - coef;
- for (i = 0; i < n; i++)
- last = *out++ = coef * *in++ + feedback * last;
- if (PD_BIGORSMALL(last))
- last = 0;
- c->c_x = last;
- return (w+5);
-}
-
-static void siglop_dsp(t_siglop *x, t_signal **sp)
-{
- x->x_sr = sp[0]->s_sr;
- siglop_ft1(x, x->x_hz);
- dsp_add(siglop_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-void siglop_setup(void)
-{
- siglop_class = class_new(gensym("lop~"), (t_newmethod)siglop_new, 0,
- sizeof(t_siglop), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(siglop_class, t_siglop, x_f);
- class_addmethod(siglop_class, (t_method)siglop_dsp, gensym("dsp"), 0);
- class_addmethod(siglop_class, (t_method)siglop_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addmethod(siglop_class, (t_method)siglop_clear, gensym("clear"), 0);
-}
-
-/* ---------------- bp~ - 2-pole bandpass filter. ----------------- */
-
-typedef struct bpctl
-{
- float c_x1;
- float c_x2;
- float c_coef1;
- float c_coef2;
- float c_gain;
-} t_bpctl;
-
-typedef struct sigbp
-{
- t_object x_obj;
- float x_sr;
- float x_freq;
- float x_q;
- t_bpctl x_cspace;
- t_bpctl *x_ctl;
- float x_f;
-} t_sigbp;
-
-t_class *sigbp_class;
-
-static void sigbp_docoef(t_sigbp *x, t_floatarg f, t_floatarg q);
-
-static void *sigbp_new(t_floatarg f, t_floatarg q)
-{
- t_sigbp *x = (t_sigbp *)pd_new(sigbp_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft2"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_sr = 44100;
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_x1 = 0;
- x->x_cspace.c_x2 = 0;
- sigbp_docoef(x, f, q);
- x->x_f = 0;
- return (x);
-}
-
-static float sigbp_qcos(float f)
-{
- if (f >= -(0.5f*3.14159f) && f <= 0.5f*3.14159f)
- {
- float g = f*f;
- return (((g*g*g * (-1.0f/720.0f) + g*g*(1.0f/24.0f)) - g*0.5) + 1);
- }
- else return (0);
-}
-
-static void sigbp_docoef(t_sigbp *x, t_floatarg f, t_floatarg q)
-{
- float r, oneminusr, omega;
- if (f < 0.001) f = 10;
- if (q < 0) q = 0;
- x->x_freq = f;
- x->x_q = q;
- omega = f * (2.0f * 3.14159f) / x->x_sr;
- if (q < 0.001) oneminusr = 1.0f;
- else oneminusr = omega/q;
- if (oneminusr > 1.0f) oneminusr = 1.0f;
- r = 1.0f - oneminusr;
- x->x_ctl->c_coef1 = 2.0f * sigbp_qcos(omega) * r;
- x->x_ctl->c_coef2 = - r * r;
- x->x_ctl->c_gain = 2 * oneminusr * (oneminusr + r * omega);
- /* post("r %f, omega %f, coef1 %f, coef2 %f",
- r, omega, x->x_ctl->c_coef1, x->x_ctl->c_coef2); */
-}
-
-static void sigbp_ft1(t_sigbp *x, t_floatarg f)
-{
- sigbp_docoef(x, f, x->x_q);
-}
-
-static void sigbp_ft2(t_sigbp *x, t_floatarg q)
-{
- sigbp_docoef(x, x->x_freq, q);
-}
-
-static void sigbp_clear(t_sigbp *x, t_floatarg q)
-{
- x->x_ctl->c_x1 = x->x_ctl->c_x2 = 0;
-}
-static t_int *sigbp_perform(t_int *w)
-{
- float *in = (float *)(w[1]);
- float *out = (float *)(w[2]);
- t_bpctl *c = (t_bpctl *)(w[3]);
- int n = (t_int)(w[4]);
- int i;
- float last = c->c_x1;
- float prev = c->c_x2;
- float coef1 = c->c_coef1;
- float coef2 = c->c_coef2;
- float gain = c->c_gain;
- for (i = 0; i < n; i++)
- {
- float output = *in++ + coef1 * last + coef2 * prev;
- *out++ = gain * output;
- prev = last;
- last = output;
- }
- if (PD_BIGORSMALL(last))
- last = 0;
- if (PD_BIGORSMALL(prev))
- prev = 0;
- c->c_x1 = last;
- c->c_x2 = prev;
- return (w+5);
-}
-
-static void sigbp_dsp(t_sigbp *x, t_signal **sp)
-{
- x->x_sr = sp[0]->s_sr;
- sigbp_docoef(x, x->x_freq, x->x_q);
- dsp_add(sigbp_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-void sigbp_setup(void)
-{
- sigbp_class = class_new(gensym("bp~"), (t_newmethod)sigbp_new, 0,
- sizeof(t_sigbp), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(sigbp_class, t_sigbp, x_f);
- class_addmethod(sigbp_class, (t_method)sigbp_dsp, gensym("dsp"), 0);
- class_addmethod(sigbp_class, (t_method)sigbp_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addmethod(sigbp_class, (t_method)sigbp_ft2,
- gensym("ft2"), A_FLOAT, 0);
- class_addmethod(sigbp_class, (t_method)sigbp_clear, gensym("clear"), 0);
-}
-
-/* ---------------- biquad~ - raw biquad filter ----------------- */
-
-typedef struct biquadctl
-{
- float c_x1;
- float c_x2;
- float c_fb1;
- float c_fb2;
- float c_ff1;
- float c_ff2;
- float c_ff3;
-} t_biquadctl;
-
-typedef struct sigbiquad
-{
- t_object x_obj;
- float x_f;
- t_biquadctl x_cspace;
- t_biquadctl *x_ctl;
-} t_sigbiquad;
-
-t_class *sigbiquad_class;
-
-static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv);
-
-static void *sigbiquad_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_sigbiquad *x = (t_sigbiquad *)pd_new(sigbiquad_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_x1 = x->x_cspace.c_x2 = 0;
- sigbiquad_list(x, s, argc, argv);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigbiquad_perform(t_int *w)
-{
- float *in = (float *)(w[1]);
- float *out = (float *)(w[2]);
- t_biquadctl *c = (t_biquadctl *)(w[3]);
- int n = (t_int)(w[4]);
- int i;
- float last = c->c_x1;
- float prev = c->c_x2;
- float fb1 = c->c_fb1;
- float fb2 = c->c_fb2;
- float ff1 = c->c_ff1;
- float ff2 = c->c_ff2;
- float ff3 = c->c_ff3;
- for (i = 0; i < n; i++)
- {
- float output = *in++ + fb1 * last + fb2 * prev;
- if (PD_BIGORSMALL(output))
- output = 0;
- *out++ = ff1 * output + ff2 * last + ff3 * prev;
- prev = last;
- last = output;
- }
- c->c_x1 = last;
- c->c_x2 = prev;
- return (w+5);
-}
-
-static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv)
-{
- float fb1 = atom_getfloatarg(0, argc, argv);
- float fb2 = atom_getfloatarg(1, argc, argv);
- float ff1 = atom_getfloatarg(2, argc, argv);
- float ff2 = atom_getfloatarg(3, argc, argv);
- float ff3 = atom_getfloatarg(4, argc, argv);
- float discriminant = fb1 * fb1 + 4 * fb2;
- t_biquadctl *c = x->x_ctl;
- if (discriminant < 0) /* imaginary roots -- resonant filter */
- {
- /* they're conjugates so we just check that the product
- is less than one */
- if (fb2 >= -1.0f) goto stable;
- }
- else /* real roots */
- {
- /* check that the parabola 1 - fb1 x - fb2 x^2 has a
- vertex between -1 and 1, and that it's nonnegative
- at both ends, which implies both roots are in [1-,1]. */
- if (fb1 <= 2.0f && fb1 >= -2.0f &&
- 1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0)
- goto stable;
- }
- /* if unstable, just bash to zero */
- fb1 = fb2 = ff1 = ff2 = ff3 = 0;
-stable:
- c->c_fb1 = fb1;
- c->c_fb2 = fb2;
- c->c_ff1 = ff1;
- c->c_ff2 = ff2;
- c->c_ff3 = ff3;
-}
-
-static void sigbiquad_set(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_biquadctl *c = x->x_ctl;
- c->c_x1 = atom_getfloatarg(0, argc, argv);
- c->c_x2 = atom_getfloatarg(1, argc, argv);
-}
-
-static void sigbiquad_dsp(t_sigbiquad *x, t_signal **sp)
-{
- dsp_add(sigbiquad_perform, 4,
- sp[0]->s_vec, sp[1]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-void sigbiquad_setup(void)
-{
- sigbiquad_class = class_new(gensym("biquad~"), (t_newmethod)sigbiquad_new,
- 0, sizeof(t_sigbiquad), 0, A_GIMME, 0);
- CLASS_MAINSIGNALIN(sigbiquad_class, t_sigbiquad, x_f);
- class_addmethod(sigbiquad_class, (t_method)sigbiquad_dsp, gensym("dsp"), 0);
- class_addlist(sigbiquad_class, sigbiquad_list);
- class_addmethod(sigbiquad_class, (t_method)sigbiquad_set, gensym("set"),
- A_GIMME, 0);
- class_addmethod(sigbiquad_class, (t_method)sigbiquad_set, gensym("clear"),
- A_GIMME, 0);
-}
-
-/* ---------------- samphold~ - sample and hold ----------------- */
-
-typedef struct sigsamphold
-{
- t_object x_obj;
- float x_f;
- float x_lastin;
- float x_lastout;
-} t_sigsamphold;
-
-t_class *sigsamphold_class;
-
-static void *sigsamphold_new(void)
-{
- t_sigsamphold *x = (t_sigsamphold *)pd_new(sigsamphold_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_lastin = 0;
- x->x_lastout = 0;
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigsamphold_perform(t_int *w)
-{
- float *in1 = (float *)(w[1]);
- float *in2 = (float *)(w[2]);
- float *out = (float *)(w[3]);
- t_sigsamphold *x = (t_sigsamphold *)(w[4]);
- int n = (t_int)(w[5]);
- int i;
- float lastin = x->x_lastin;
- float lastout = x->x_lastout;
- for (i = 0; i < n; i++, *in1++)
- {
- float next = *in2++;
- if (next < lastin) lastout = *in1;
- *out++ = lastout;
- lastin = next;
- }
- x->x_lastin = lastin;
- x->x_lastout = lastout;
- return (w+6);
-}
-
-static void sigsamphold_dsp(t_sigsamphold *x, t_signal **sp)
-{
- dsp_add(sigsamphold_perform, 5,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec,
- x, sp[0]->s_n);
-}
-
-static void sigsamphold_reset(t_sigsamphold *x)
-{
- x->x_lastin = 1e20;
-}
-
-static void sigsamphold_set(t_sigsamphold *x, t_float f)
-{
- x->x_lastout = f;
-}
-
-void sigsamphold_setup(void)
-{
- sigsamphold_class = class_new(gensym("samphold~"),
- (t_newmethod)sigsamphold_new, 0, sizeof(t_sigsamphold), 0, 0);
- CLASS_MAINSIGNALIN(sigsamphold_class, t_sigsamphold, x_f);
- class_addmethod(sigsamphold_class, (t_method)sigsamphold_set,
- gensym("set"), A_FLOAT, 0);
- class_addmethod(sigsamphold_class, (t_method)sigsamphold_reset,
- gensym("reset"), 0);
- class_addmethod(sigsamphold_class, (t_method)sigsamphold_dsp,
- gensym("dsp"), 0);
-}
-
-/* ------------------------ setup routine ------------------------- */
-
-void d_filter_setup(void)
-{
- sighip_setup();
- siglop_setup();
- sigbp_setup();
- sigbiquad_setup();
- sigsamphold_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/d_global.c b/apps/plugins/pdbox/PDa/src/d_global.c
index 2b129ac5f4..893abe1f7d 100644
--- a/apps/plugins/pdbox/PDa/src/d_global.c
+++ b/apps/plugins/pdbox/PDa/src/d_global.c
@@ -306,311 +306,3 @@ void d_global_setup(void)
sigthrow_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* send~, receive~, throw~, catch~ */
-
-#include "m_pd.h"
-#include <string.h>
-
-#define DEFSENDVS 64 /* LATER get send to get this from canvas */
-
-/* ----------------------------- send~ ----------------------------- */
-static t_class *sigsend_class;
-
-typedef struct _sigsend
-{
- t_object x_obj;
- t_symbol *x_sym;
- int x_n;
- t_sample *x_vec;
- float x_f;
-} t_sigsend;
-
-static void *sigsend_new(t_symbol *s)
-{
- t_sigsend *x = (t_sigsend *)pd_new(sigsend_class);
- pd_bind(&x->x_obj.ob_pd, s);
- x->x_sym = s;
- x->x_n = DEFSENDVS;
- x->x_vec = (t_sample *)getbytes(DEFSENDVS * sizeof(t_sample));
- memset((char *)(x->x_vec), 0, DEFSENDVS * sizeof(t_sample));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigsend_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- while (n--)
- {
- *out = (PD_BIGORSMALL(*in) ? 0 : *in);
- out++;
- in++;
- }
- return (w+4);
-}
-
-static void sigsend_dsp(t_sigsend *x, t_signal **sp)
-{
- if (x->x_n == sp[0]->s_n)
- dsp_add(sigsend_perform, 3, sp[0]->s_vec, x->x_vec, sp[0]->s_n);
- else error("sigsend %s: unexpected vector size", x->x_sym->s_name);
-}
-
-static void sigsend_free(t_sigsend *x)
-{
- pd_unbind(&x->x_obj.ob_pd, x->x_sym);
- freebytes(x->x_vec, x->x_n * sizeof(float));
-}
-
-static void sigsend_setup(void)
-{
- sigsend_class = class_new(gensym("send~"), (t_newmethod)sigsend_new,
- (t_method)sigsend_free, sizeof(t_sigsend), 0, A_DEFSYM, 0);
- class_addcreator((t_newmethod)sigsend_new, gensym("s~"), A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(sigsend_class, t_sigsend, x_f);
- class_addmethod(sigsend_class, (t_method)sigsend_dsp, gensym("dsp"), 0);
-}
-
-/* ----------------------------- receive~ ----------------------------- */
-static t_class *sigreceive_class;
-
-typedef struct _sigreceive
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_sample *x_wherefrom;
- int x_n;
-} t_sigreceive;
-
-static void *sigreceive_new(t_symbol *s)
-{
- t_sigreceive *x = (t_sigreceive *)pd_new(sigreceive_class);
- x->x_n = DEFSENDVS; /* LATER find our vector size correctly */
- x->x_sym = s;
- x->x_wherefrom = 0;
- outlet_new(&x->x_obj, &s_signal);
- return (x);
-}
-
-static t_int *sigreceive_perform(t_int *w)
-{
- t_sigreceive *x = (t_sigreceive *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- t_sample *in = x->x_wherefrom;
- if (in)
- {
- while (n--)
- *out++ = *in++;
- }
- else
- {
- while (n--)
- *out++ = 0;
- }
- return (w+4);
-}
-
-static void sigreceive_set(t_sigreceive *x, t_symbol *s)
-{
- t_sigsend *sender = (t_sigsend *)pd_findbyclass((x->x_sym = s),
- sigsend_class);
- if (sender)
- {
- if (sender->x_n == x->x_n)
- x->x_wherefrom = sender->x_vec;
- else
- {
- pd_error(x, "receive~ %s: vector size mismatch", x->x_sym->s_name);
- x->x_wherefrom = 0;
- }
- }
- else
- {
- pd_error(x, "receive~ %s: no matching send", x->x_sym->s_name);
- x->x_wherefrom = 0;
- }
-}
-
-static void sigreceive_dsp(t_sigreceive *x, t_signal **sp)
-{
- if (sp[0]->s_n != x->x_n)
- {
- pd_error(x, "receive~ %s: vector size mismatch", x->x_sym->s_name);
- }
- else
- {
- sigreceive_set(x, x->x_sym);
- dsp_add(sigreceive_perform, 3,
- x, sp[0]->s_vec, sp[0]->s_n);
- }
-}
-
-static void sigreceive_setup(void)
-{
- sigreceive_class = class_new(gensym("receive~"),
- (t_newmethod)sigreceive_new, 0,
- sizeof(t_sigreceive), 0, A_DEFSYM, 0);
- class_addcreator((t_newmethod)sigreceive_new, gensym("r~"), A_DEFSYM, 0);
- class_addmethod(sigreceive_class, (t_method)sigreceive_set, gensym("set"),
- A_SYMBOL, 0);
- class_addmethod(sigreceive_class, (t_method)sigreceive_dsp, gensym("dsp"),
- 0);
- class_sethelpsymbol(sigreceive_class, gensym("send~"));
-}
-
-/* ----------------------------- catch~ ----------------------------- */
-static t_class *sigcatch_class;
-
-typedef struct _sigcatch
-{
- t_object x_obj;
- t_symbol *x_sym;
- int x_n;
- t_sample *x_vec;
-} t_sigcatch;
-
-static void *sigcatch_new(t_symbol *s)
-{
- t_sigcatch *x = (t_sigcatch *)pd_new(sigcatch_class);
- pd_bind(&x->x_obj.ob_pd, s);
- x->x_sym = s;
- x->x_n = DEFSENDVS;
- x->x_vec = (t_sample *)getbytes(DEFSENDVS * sizeof(t_sample));
- memset((char *)(x->x_vec), 0, DEFSENDVS * sizeof(t_sample));
- outlet_new(&x->x_obj, &s_signal);
- return (x);
-}
-
-static t_int *sigcatch_perform(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]);
- t_sample *out = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- while (n--) *out++ = *in, *in++ = 0;
- return (w+4);
-}
-
-static void sigcatch_dsp(t_sigcatch *x, t_signal **sp)
-{
- if (x->x_n == sp[0]->s_n)
- dsp_add(sigcatch_perform, 3, x->x_vec, sp[0]->s_vec, sp[0]->s_n);
- else error("sigcatch %s: unexpected vector size", x->x_sym->s_name);
-}
-
-static void sigcatch_free(t_sigcatch *x)
-{
- pd_unbind(&x->x_obj.ob_pd, x->x_sym);
- freebytes(x->x_vec, x->x_n * sizeof(float));
-}
-
-static void sigcatch_setup(void)
-{
- sigcatch_class = class_new(gensym("catch~"), (t_newmethod)sigcatch_new,
- (t_method)sigcatch_free, sizeof(t_sigcatch), CLASS_NOINLET, A_DEFSYM, 0);
- class_addmethod(sigcatch_class, (t_method)sigcatch_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(sigcatch_class, gensym("throw~"));
-}
-
-/* ----------------------------- throw~ ----------------------------- */
-static t_class *sigthrow_class;
-
-typedef struct _sigthrow
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_sample *x_whereto;
- int x_n;
- t_float x_f;
-} t_sigthrow;
-
-static void *sigthrow_new(t_symbol *s)
-{
- t_sigthrow *x = (t_sigthrow *)pd_new(sigthrow_class);
- x->x_sym = s;
- x->x_whereto = 0;
- x->x_n = DEFSENDVS;
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigthrow_perform(t_int *w)
-{
- t_sigthrow *x = (t_sigthrow *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- t_sample *out = x->x_whereto;
- if (out)
- {
- while (n--)
- {
- *out += (PD_BIGORSMALL(*in) ? 0 : *in);
- out++;
- in++;
- }
- }
- return (w+4);
-}
-
-static void sigthrow_set(t_sigthrow *x, t_symbol *s)
-{
- t_sigcatch *catcher = (t_sigcatch *)pd_findbyclass((x->x_sym = s),
- sigcatch_class);
- if (catcher)
- {
- if (catcher->x_n == x->x_n)
- x->x_whereto = catcher->x_vec;
- else
- {
- pd_error(x, "throw~ %s: vector size mismatch", x->x_sym->s_name);
- x->x_whereto = 0;
- }
- }
- else
- {
- pd_error(x, "throw~ %s: no matching catch", x->x_sym->s_name);
- x->x_whereto = 0;
- }
-}
-
-static void sigthrow_dsp(t_sigthrow *x, t_signal **sp)
-{
- if (sp[0]->s_n != x->x_n)
- {
- pd_error(x, "throw~ %s: vector size mismatch", x->x_sym->s_name);
- }
- else
- {
- sigthrow_set(x, x->x_sym);
- dsp_add(sigthrow_perform, 3,
- x, sp[0]->s_vec, sp[0]->s_n);
- }
-}
-
-static void sigthrow_setup(void)
-{
- sigthrow_class = class_new(gensym("throw~"), (t_newmethod)sigthrow_new, 0,
- sizeof(t_sigthrow), 0, A_DEFSYM, 0);
- class_addcreator((t_newmethod)sigthrow_new, gensym("r~"), A_DEFSYM, 0);
- class_addmethod(sigthrow_class, (t_method)sigthrow_set, gensym("set"),
- A_SYMBOL, 0);
- CLASS_MAINSIGNALIN(sigthrow_class, t_sigthrow, x_f);
- class_addmethod(sigthrow_class, (t_method)sigthrow_dsp, gensym("dsp"), 0);
-}
-
-/* ----------------------- global setup routine ---------------- */
-
-void d_global_setup(void)
-{
- sigsend_setup();
- sigreceive_setup();
- sigcatch_setup();
- sigthrow_setup();
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/d_imayer_fft.c b/apps/plugins/pdbox/PDa/src/d_imayer_fft.c
index d8e9e9f243..05d944ed44 100644
--- a/apps/plugins/pdbox/PDa/src/d_imayer_fft.c
+++ b/apps/plugins/pdbox/PDa/src/d_imayer_fft.c
@@ -514,519 +514,4 @@ int main()
}
#endif
-/*
-** Algorithm: complex multiplication
-**
-** Performance: Bad accuracy, great speed.
-**
-** The simplest, way of generating trig values. Note, this method is
-** not stable, and errors accumulate rapidly.
-**
-** Computation: 2 *, 1 + per value.
-*/
-
-
-#include "m_fixed.h"
-
-
-#define TRIG_FAST
-
-#ifdef TRIG_FAST
-char mtrig_algorithm[] = "Simple";
-#define TRIG_VARS \
- t_fixed t_c,t_s;
-#define TRIG_INIT(k,c,s) \
- { \
- t_c = fcostab[k]; \
- t_s = fsintab[k]; \
- c = itofix(1); \
- s = 0; \
- }
-#define TRIG_NEXT(k,c,s) \
- { \
- t_fixed t = c; \
- c = mult(t,t_c) - mult(s,t_s); \
- s = mult(t,t_s) + mult(s,t_c); \
- }
-#define TRIG_23(k,c1,s1,c2,s2,c3,s3) \
- { \
- c2 = mult(c1,c1) - mult(s1,s1); \
- s2 = (mult(c1,s1)<<2); \
- c3 = mult(c2,c1) - mult(s2,s1); \
- s3 = mult(c2,s1) + mult(s2,c1); \
- }
-#endif
-#define TRIG_RESET(k,c,s)
-
-/*
-** Algorithm: O. Buneman's trig generator.
-**
-** Performance: Good accuracy, mediocre speed.
-**
-** Manipulates a log(n) table to stably create n evenly spaced trig
-** values. The newly generated values lay halfway between two
-** known values, and are calculated by appropriatelly scaling the
-** average of the known trig values appropriatelly according to the
-** angle between them. This process is inherently stable; and is
-** about as accurate as most trig library functions. The errors
-** caused by this code segment are primarily due to the less stable
-** method to calculate values for 2t and s 3t. Note: I believe this
-** algorithm is patented(!), see readme file for more details.
-**
-** Computation: 1 +, 1 *, much integer math, per trig value
-**
-*/
-
-#ifdef TRIG_GOOD
-#define TRIG_VARS \
- int t_lam=0; \
- double coswrk[TRIG_TABLE_SIZE],sinwrk[TRIG_TABLE_SIZE];
-#define TRIG_INIT(k,c,s) \
- { \
- int i; \
- for (i=0 ; i<=k ; i++) \
- {coswrk[i]=fcostab[i];sinwrk[i]=fsintab[i];} \
- t_lam = 0; \
- c = 1; \
- s = 0; \
- }
-#define TRIG_NEXT(k,c,s) \
- { \
- int i,j; \
- (t_lam)++; \
- for (i=0 ; !((1<<i)&t_lam) ; i++); \
- i = k-i; \
- s = sinwrk[i]; \
- c = coswrk[i]; \
- if (i>1) \
- { \
- for (j=k-i+2 ; (1<<j)&t_lam ; j++); \
- j = k - j; \
- sinwrk[i] = halsec[i] * (sinwrk[i-1] + sinwrk[j]); \
- coswrk[i] = halsec[i] * (coswrk[i-1] + coswrk[j]); \
- } \
- }
-#endif
-
-
-#define TRIG_TAB_SIZE 22
-
-static long long halsec[TRIG_TAB_SIZE]= {1,2,3};
-
-#define FFTmult(x,y) mult(x,y)
-
-
-
-
-#include "d_imayer_tables.h"
-
-#define SQRT2 ftofix(1.414213562373095048801688724209698)
-
-
-void imayer_fht(t_fixed *fz, int n)
-{
- int k,k1,k2,k3,k4,kx;
- t_fixed *fi,*fn,*gi;
- TRIG_VARS;
-
- for (k1=1,k2=0;k1<n;k1++)
- {
- t_fixed aa;
- for (k=n>>1; (!((k2^=k)&k)); k>>=1);
- if (k1>k2)
- {
- aa=fz[k1];fz[k1]=fz[k2];fz[k2]=aa;
- }
- }
- for ( k=0 ; (1<<k)<n ; k++ );
- k &= 1;
- if (k==0)
- {
- for (fi=fz,fn=fz+n;fi<fn;fi+=4)
- {
- t_fixed f0,f1,f2,f3;
- f1 = fi[0 ]-fi[1 ];
- f0 = fi[0 ]+fi[1 ];
- f3 = fi[2 ]-fi[3 ];
- f2 = fi[2 ]+fi[3 ];
- fi[2 ] = (f0-f2);
- fi[0 ] = (f0+f2);
- fi[3 ] = (f1-f3);
- fi[1 ] = (f1+f3);
- }
- }
- else
- {
- for (fi=fz,fn=fz+n,gi=fi+1;fi<fn;fi+=8,gi+=8)
- {
- t_fixed bs1,bc1,bs2,bc2,bs3,bc3,bs4,bc4,
- bg0,bf0,bf1,bg1,bf2,bg2,bf3,bg3;
- bc1 = fi[0 ] - gi[0 ];
- bs1 = fi[0 ] + gi[0 ];
- bc2 = fi[2 ] - gi[2 ];
- bs2 = fi[2 ] + gi[2 ];
- bc3 = fi[4 ] - gi[4 ];
- bs3 = fi[4 ] + gi[4 ];
- bc4 = fi[6 ] - gi[6 ];
- bs4 = fi[6 ] + gi[6 ];
- bf1 = (bs1 - bs2);
- bf0 = (bs1 + bs2);
- bg1 = (bc1 - bc2);
- bg0 = (bc1 + bc2);
- bf3 = (bs3 - bs4);
- bf2 = (bs3 + bs4);
- bg3 = FFTmult(SQRT2,bc4);
- bg2 = FFTmult(SQRT2,bc3);
- fi[4 ] = bf0 - bf2;
- fi[0 ] = bf0 + bf2;
- fi[6 ] = bf1 - bf3;
- fi[2 ] = bf1 + bf3;
- gi[4 ] = bg0 - bg2;
- gi[0 ] = bg0 + bg2;
- gi[6 ] = bg1 - bg3;
- gi[2 ] = bg1 + bg3;
- }
- }
- if (n<16) return;
- do
- {
- t_fixed s1,c1;
- int ii;
- k += 2;
- k1 = 1 << k;
- k2 = k1 << 1;
- k4 = k2 << 1;
- k3 = k2 + k1;
- kx = k1 >> 1;
- fi = fz;
- gi = fi + kx;
- fn = fz + n;
- do
- {
- t_fixed g0,f0,f1,g1,f2,g2,f3,g3;
- f1 = fi[0 ] - fi[k1];
- f0 = fi[0 ] + fi[k1];
- f3 = fi[k2] - fi[k3];
- f2 = fi[k2] + fi[k3];
- fi[k2] = f0 - f2;
- fi[0 ] = f0 + f2;
- fi[k3] = f1 - f3;
- fi[k1] = f1 + f3;
- g1 = gi[0 ] - gi[k1];
- g0 = gi[0 ] + gi[k1];
- g3 = FFTmult(SQRT2, gi[k3]);
- g2 = FFTmult(SQRT2, gi[k2]);
- gi[k2] = g0 - g2;
- gi[0 ] = g0 + g2;
- gi[k3] = g1 - g3;
- gi[k1] = g1 + g3;
- gi += k4;
- fi += k4;
- } while (fi<fn);
- TRIG_INIT(k,c1,s1);
- for (ii=1;ii<kx;ii++)
- {
- t_fixed c2,s2;
- TRIG_NEXT(k,c1,s1);
- c2 = FFTmult(c1,c1) - FFTmult(s1,s1);
- s2 = 2*FFTmult(c1,s1);
- fn = fz + n;
- fi = fz +ii;
- gi = fz +k1-ii;
- do
- {
- t_fixed a,b,g0,f0,f1,g1,f2,g2,f3,g3;
- b = FFTmult(s2,fi[k1]) - FFTmult(c2,gi[k1]);
- a = FFTmult(c2,fi[k1]) + FFTmult(s2,gi[k1]);
- f1 = fi[0 ] - a;
- f0 = fi[0 ] + a;
- g1 = gi[0 ] - b;
- g0 = gi[0 ] + b;
- b = FFTmult(s2,fi[k3]) - FFTmult(c2,gi[k3]);
- a = FFTmult(c2,fi[k3]) + FFTmult(s2,gi[k3]);
- f3 = fi[k2] - a;
- f2 = fi[k2] + a;
- g3 = gi[k2] - b;
- g2 = gi[k2] + b;
- b = FFTmult(s1,f2) - FFTmult(c1,g3);
- a = FFTmult(c1,f2) + FFTmult(s1,g3);
- fi[k2] = f0 - a;
- fi[0 ] = f0 + a;
- gi[k3] = g1 - b;
- gi[k1] = g1 + b;
- b = FFTmult(c1,g2) - FFTmult(s1,f3);
- a = FFTmult(s1,g2) + FFTmult(c1,f3);
- gi[k2] = g0 - a;
- gi[0 ] = g0 + a;
- fi[k3] = f1 - b;
- fi[k1] = f1 + b;
- gi += k4;
- fi += k4;
- } while (fi<fn);
- }
- TRIG_RESET(k,c1,s1);
- } while (k4<n);
-}
-
-
-void imayer_fft(int n, t_fixed *real, t_fixed *imag)
-{
- t_fixed a,b,c,d;
- t_fixed q,r,s,t;
- int i,j,k;
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i]; b = real[j]; q=a+b; r=a-b;
- c = imag[i]; d = imag[j]; s=c+d; t=c-d;
- real[i] = (q+t)>>1; real[j] = (q-t)>>1;
- imag[i] = (s-r)>>1; imag[j] = (s+r)>>1;
- }
- imayer_fht(real,n);
- imayer_fht(imag,n);
-}
-
-void imayer_ifft(int n, t_fixed *real, t_fixed *imag)
-{
- t_fixed a,b,c,d;
- t_fixed q,r,s,t;
- int i,j,k;
- imayer_fht(real,n);
- imayer_fht(imag,n);
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i]; b = real[j]; q=a+b; r=a-b;
- c = imag[i]; d = imag[j]; s=c+d; t=c-d;
- imag[i] = (s+r)>>1; imag[j] = (s-r)>>1;
- real[i] = (q-t)>>1; real[j] = (q+t)>>1;
- }
-}
-
-void imayer_realfft(int n, t_fixed *real)
-{
- t_fixed a,b,c,d;
- int i,j,k;
- imayer_fht(real,n);
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i];
- b = real[j];
- real[j] = (a-b)>>1;
- real[i] = (a+b)>>1;
- }
-}
-
-void imayer_realifft(int n, t_fixed *real)
-{
- t_fixed a,b,c,d;
- int i,j,k;
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i];
- b = real[j];
- real[j] = (a-b);
- real[i] = (a+b);
- }
- imayer_fht(real,n);
-}
-
-
-
-#ifdef TEST
-
-static double dfcostab[TRIG_TAB_SIZE]=
- {
- .00000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768847,
- .92387953251128675612818318939678828682241662586364,
- .98078528040323044912618223613423903697393373089333,
- .99518472667219688624483695310947992157547486872985,
- .99879545620517239271477160475910069444320361470461,
- .99969881869620422011576564966617219685006108125772,
- .99992470183914454092164649119638322435060646880221,
- .99998117528260114265699043772856771617391725094433,
- .99999529380957617151158012570011989955298763362218,
- .99999882345170190992902571017152601904826792288976,
- .99999970586288221916022821773876567711626389934930,
- .99999992646571785114473148070738785694820115568892,
- .99999998161642929380834691540290971450507605124278,
- .99999999540410731289097193313960614895889430318945,
- .99999999885102682756267330779455410840053741619428,
- .99999999971275670684941397221864177608908945791828,
- .99999999992818917670977509588385049026048033310951
- };
-static double dfsintab[TRIG_TAB_SIZE]=
- {
- 1.0000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768846,
- .38268343236508977172845998403039886676134456248561,
- .19509032201612826784828486847702224092769161775195,
- .09801714032956060199419556388864184586113667316749,
- .04906767432741801425495497694268265831474536302574,
- .02454122852291228803173452945928292506546611923944,
- .01227153828571992607940826195100321214037231959176,
- .00613588464915447535964023459037258091705788631738,
- .00306795676296597627014536549091984251894461021344,
- .00153398018628476561230369715026407907995486457522,
- .00076699031874270452693856835794857664314091945205,
- .00038349518757139558907246168118138126339502603495,
- .00019174759731070330743990956198900093346887403385,
- .00009587379909597734587051721097647635118706561284,
- .00004793689960306688454900399049465887274686668768,
- .00002396844980841821872918657716502182009476147489,
- .00001198422490506970642152156159698898480473197753
- };
-
-static double dhalsec[TRIG_TAB_SIZE]=
- {
- 0,
- 0,
- .54119610014619698439972320536638942006107206337801,
- .50979557910415916894193980398784391368261849190893,
- .50241928618815570551167011928012092247859337193963,
- .50060299823519630134550410676638239611758632599591,
- .50015063602065098821477101271097658495974913010340,
- .50003765191554772296778139077905492847503165398345,
- .50000941253588775676512870469186533538523133757983,
- .50000235310628608051401267171204408939326297376426,
- .50000058827484117879868526730916804925780637276181,
- .50000014706860214875463798283871198206179118093251,
- .50000003676714377807315864400643020315103490883972,
- .50000000919178552207366560348853455333939112569380,
- .50000000229794635411562887767906868558991922348920,
- .50000000057448658687873302235147272458812263401372,
- .50000000014362164661654736863252589967935073278768,
- .50000000003590541164769084922906986545517021050714
- };
-
-
-#include <stdio.h>
-
-
-int writetables()
-{
- int i;
-
- printf("/* Tables for fixed point lookup with %d bit precision*/\n\n",fix1);
-
- printf("static int fsintab[TRIG_TAB_SIZE]= {\n");
-
- for (i=0;i<TRIG_TAB_SIZE-1;i++)
- printf("%ld, \n",ftofix(dfsintab[i]));
- printf("%ld }; \n",ftofix(dfsintab[i]));
-
-
- printf("\n\nstatic int fcostab[TRIG_TAB_SIZE]= {\n");
-
- for (i=0;i<TRIG_TAB_SIZE-1;i++)
- printf("%ld, \n",ftofix(dfcostab[i]));
- printf("%ld }; \n",ftofix(dfcostab[i]));
-
-}
-
-
-#define OUTPUT \
- fprintf(stderr,"Integer - Float\n");\
- for (i=0;i<NP;i++)\
- fprintf(stderr,"%f %f --> %f %f\n",fixtof(r[i]),fixtof(im[i]),\
- fr[i],fim[i]);\
- fprintf(stderr,"\n\n");
-
-
-
-int main()
-{
- int i;
- t_fixed r[256];
- t_fixed im[256];
- float fr[256];
- float fim[256];
-
-
-#if 1
- writetables();
- exit(0);
-#endif
-
-
-#if 0
- t_fixed c1,s1,c2,s2,c3,s3;
- int k;
- int i;
-
- TRIG_VARS;
-
- for (k=2;k<10;k+=2) {
- TRIG_INIT(k,c1,s1);
- for (i=0;i<8;i++) {
- TRIG_NEXT(k,c1,s1);
- TRIG_23(k,c1,s1,c2,s2,c3,s3);
- printf("TRIG value k=%d,%d val1 = %f %f\n",k,i,fixtof(c1),fixtof(s1));
- }
- }
-#endif
-
-
-
-#if 1
-
- #define NP 16
-
- for (i=0;i<NP;i++) {
- fr[i] = 0.;
- r[i] = 0.;
- fim[i] = 0.;
- im[i] = 0;
- }
-
-#if 0
- for (i=0;i<NP;i++) {
- if (i&1) {
- fr[i] = 0.1*i;
- r[i] = ftofix(0.1*i);
- }
- else {
- fr[i] = 0.;
- r[i] = 0.;
- }
- }
-#endif
-#if 0
- for (i=0;i<NP;i++) {
- fr[i] = 0.1;
- r[i] = ftofix(0.1);
- }
-#endif
-
- r[1] = ftofix(0.1);
- fr[1] = 0.1;
-
-
-
- /* TEST RUN */
-
- OUTPUT
-
- imayer_fft(NP,r,im);
- mayer_fft(NP,fr,fim);
-// imayer_fht(r,NP);
-// mayer_fht(fr,NP);
-
-#if 1
- for (i=0;i<NP;i++) {
- r[i] = mult(ftofix(0.01),r[i]);
- fr[i] = 0.01*fr[i];
- }
-#endif
-
- OUTPUT
-
-
- imayer_fft(NP,r,im);
- mayer_fft(NP,fr,fim);
-
- OUTPUT
-
-
-#endif
-
-
-}
-
-#endif
diff --git a/apps/plugins/pdbox/PDa/src/d_imayer_tables.h b/apps/plugins/pdbox/PDa/src/d_imayer_tables.h
index e02d62490b..122725d8c0 100644
--- a/apps/plugins/pdbox/PDa/src/d_imayer_tables.h
+++ b/apps/plugins/pdbox/PDa/src/d_imayer_tables.h
@@ -48,53 +48,4 @@ static int fcostab[TRIG_TAB_SIZE]= {
0,
0,
0 };
-/* Tables for fixed point lookup with 18 bit precision*/
-
-static int fsintab[TRIG_TAB_SIZE]= {
-262144,
-185363,
-100318,
-51141,
-25694,
-12862,
-6433,
-3216,
-1608,
-804,
-402,
-201,
-100,
-50,
-25,
-12,
-6,
-3,
-0,
-0,
-0,
-0 };
-
-static int fcostab[TRIG_TAB_SIZE]= {
-0,
-185363,
-242189,
-257106,
-260881,
-261828,
-262065,
-262124,
-262139,
-262142,
-262143,
-262143,
-262143,
-262143,
-262143,
-262143,
-262143,
-262143,
-0,
-0,
-0,
-0 };
diff --git a/apps/plugins/pdbox/PDa/src/d_math.c b/apps/plugins/pdbox/PDa/src/d_math.c
index ee8a96692c..d64e2e3483 100644
--- a/apps/plugins/pdbox/PDa/src/d_math.c
+++ b/apps/plugins/pdbox/PDa/src/d_math.c
@@ -571,576 +571,3 @@ void d_math_setup(void)
class_sethelpsymbol(powtodb_tilde_class, s);
}
-/* Copyright (c) 1997-2001 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* mathematical functions and other transfer functions, including tilde
- versions of stuff from x_acoustics.c.
-*/
-
-#include "m_pd.h"
-#include <math.h>
-#define LOGTEN 2.302585092994
-
-/* ------------------------- clip~ -------------------------- */
-static t_class *clip_class;
-
-typedef struct _clip
-{
- t_object x_obj;
- float x_f;
- t_sample x_lo;
- t_sample x_hi;
-} t_clip;
-
-static void *clip_new(t_floatarg lo, t_floatarg hi)
-{
- t_clip *x = (t_clip *)pd_new(clip_class);
- x->x_lo = lo;
- x->x_hi = hi;
- outlet_new(&x->x_obj, gensym("signal"));
- floatinlet_new(&x->x_obj, &x->x_lo);
- floatinlet_new(&x->x_obj, &x->x_hi);
- x->x_f = 0;
- return (x);
-}
-
-static t_int *clip_perform(t_int *w)
-{
- t_clip *x = (t_clip *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
- int n = (int)(w[4]);
- while (n--)
- {
- float f = *in++;
- if (f < x->x_lo) f = x->x_lo;
- if (f > x->x_hi) f = x->x_hi;
- *out++ = f;
- }
- return (w+5);
-}
-
-static void clip_dsp(t_clip *x, t_signal **sp)
-{
- dsp_add(clip_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void clip_setup(void)
-{
- clip_class = class_new(gensym("clip~"), (t_newmethod)clip_new, 0,
- sizeof(t_clip), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(clip_class, t_clip, x_f);
- class_addmethod(clip_class, (t_method)clip_dsp, gensym("dsp"), 0);
-}
-
-/* sigrsqrt - reciprocal square root good to 8 mantissa bits */
-
-#define DUMTAB1SIZE 256
-#define DUMTAB2SIZE 1024
-
-static float rsqrt_exptab[DUMTAB1SIZE], rsqrt_mantissatab[DUMTAB2SIZE];
-
-static void init_rsqrt(void)
-{
- int i;
- for (i = 0; i < DUMTAB1SIZE; i++)
- {
- float f;
- long l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23;
- *(long *)(&f) = l;
- rsqrt_exptab[i] = 1./sqrt(f);
- }
- for (i = 0; i < DUMTAB2SIZE; i++)
- {
- float f = 1 + (1./DUMTAB2SIZE) * i;
- rsqrt_mantissatab[i] = 1./sqrt(f);
- }
-}
-
- /* these are used in externs like "bonk" */
-
-float q8_rsqrt(float f)
-{
- long l = *(long *)(&f);
- if (f < 0) return (0);
- else return (rsqrt_exptab[(l >> 23) & 0xff] *
- rsqrt_mantissatab[(l >> 13) & 0x3ff]);
-}
-
-float q8_sqrt(float f)
-{
- long l = *(long *)(&f);
- if (f < 0) return (0);
- else return (f * rsqrt_exptab[(l >> 23) & 0xff] *
- rsqrt_mantissatab[(l >> 13) & 0x3ff]);
-}
-
- /* the old names are OK unless we're in IRIX N32 */
-
-#ifndef N32
-float qsqrt(float f) {return (q8_sqrt(f)); }
-float qrsqrt(float f) {return (q8_rsqrt(f)); }
-#endif
-
-
-
-typedef struct sigrsqrt
-{
- t_object x_obj;
- float x_f;
-} t_sigrsqrt;
-
-static t_class *sigrsqrt_class;
-
-static void *sigrsqrt_new(void)
-{
- t_sigrsqrt *x = (t_sigrsqrt *)pd_new(sigrsqrt_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigrsqrt_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- while (n--)
- {
- float f = *in;
- long l = *(long *)(in++);
- if (f < 0) *out++ = 0;
- else
- {
- float g = rsqrt_exptab[(l >> 23) & 0xff] *
- rsqrt_mantissatab[(l >> 13) & 0x3ff];
- *out++ = 1.5 * g - 0.5 * g * g * g * f;
- }
- }
- return (w + 4);
-}
-
-static void sigrsqrt_dsp(t_sigrsqrt *x, t_signal **sp)
-{
- dsp_add(sigrsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void sigrsqrt_setup(void)
-{
- init_rsqrt();
- sigrsqrt_class = class_new(gensym("rsqrt~"), (t_newmethod)sigrsqrt_new, 0,
- sizeof(t_sigrsqrt), 0, 0);
- /* an old name for it: */
- class_addcreator(sigrsqrt_new, gensym("q8_rsqrt~"), 0);
- CLASS_MAINSIGNALIN(sigrsqrt_class, t_sigrsqrt, x_f);
- class_addmethod(sigrsqrt_class, (t_method)sigrsqrt_dsp, gensym("dsp"), 0);
-}
-
-
-/* sigsqrt - square root good to 8 mantissa bits */
-
-typedef struct sigsqrt
-{
- t_object x_obj;
- float x_f;
-} t_sigsqrt;
-
-static t_class *sigsqrt_class;
-
-static void *sigsqrt_new(void)
-{
- t_sigsqrt *x = (t_sigsqrt *)pd_new(sigsqrt_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-t_int *sigsqrt_perform(t_int *w) /* not static; also used in d_fft.c */
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- while (n--)
- {
- float f = *in;
- long l = *(long *)(in++);
- if (f < 0) *out++ = 0;
- else
- {
- float g = rsqrt_exptab[(l >> 23) & 0xff] *
- rsqrt_mantissatab[(l >> 13) & 0x3ff];
- *out++ = f * (1.5 * g - 0.5 * g * g * g * f);
- }
- }
- return (w + 4);
-}
-
-static void sigsqrt_dsp(t_sigsqrt *x, t_signal **sp)
-{
- dsp_add(sigsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void sigsqrt_setup(void)
-{
- sigsqrt_class = class_new(gensym("sqrt~"), (t_newmethod)sigsqrt_new, 0,
- sizeof(t_sigsqrt), 0, 0);
- class_addcreator(sigsqrt_new, gensym("q8_sqrt~"), 0); /* old name */
- CLASS_MAINSIGNALIN(sigsqrt_class, t_sigsqrt, x_f);
- class_addmethod(sigsqrt_class, (t_method)sigsqrt_dsp, gensym("dsp"), 0);
-}
-
-/* ------------------------------ wrap~ -------------------------- */
-
-typedef struct wrap
-{
- t_object x_obj;
- float x_f;
-} t_sigwrap;
-
-t_class *sigwrap_class;
-
-static void *sigwrap_new(void)
-{
- t_sigwrap *x = (t_sigwrap *)pd_new(sigwrap_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *sigwrap_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- while (n--)
- {
- float f = *in++;
- int k = f;
- if (f > 0) *out++ = f-k;
- else *out++ = f - (k-1);
- }
- return (w + 4);
-}
-
-static void sigwrap_dsp(t_sigwrap *x, t_signal **sp)
-{
- dsp_add(sigwrap_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void sigwrap_setup(void)
-{
- sigwrap_class = class_new(gensym("wrap~"), (t_newmethod)sigwrap_new, 0,
- sizeof(t_sigwrap), 0, 0);
- CLASS_MAINSIGNALIN(sigwrap_class, t_sigwrap, x_f);
- class_addmethod(sigwrap_class, (t_method)sigwrap_dsp, gensym("dsp"), 0);
-}
-
-/* ------------------------------ mtof_tilde~ -------------------------- */
-
-typedef struct mtof_tilde
-{
- t_object x_obj;
- float x_f;
-} t_mtof_tilde;
-
-t_class *mtof_tilde_class;
-
-static void *mtof_tilde_new(void)
-{
- t_mtof_tilde *x = (t_mtof_tilde *)pd_new(mtof_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *mtof_tilde_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- float f = *in;
- if (f <= -1500) *out = 0;
- else
- {
- if (f > 1499) f = 1499;
- *out = 8.17579891564 * exp(.0577622650 * f);
- }
- }
- return (w + 4);
-}
-
-static void mtof_tilde_dsp(t_mtof_tilde *x, t_signal **sp)
-{
- dsp_add(mtof_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void mtof_tilde_setup(void)
-{
- mtof_tilde_class = class_new(gensym("mtof~"), (t_newmethod)mtof_tilde_new, 0,
- sizeof(t_mtof_tilde), 0, 0);
- CLASS_MAINSIGNALIN(mtof_tilde_class, t_mtof_tilde, x_f);
- class_addmethod(mtof_tilde_class, (t_method)mtof_tilde_dsp, gensym("dsp"), 0);
-}
-
-/* ------------------------------ ftom_tilde~ -------------------------- */
-
-typedef struct ftom_tilde
-{
- t_object x_obj;
- float x_f;
-} t_ftom_tilde;
-
-t_class *ftom_tilde_class;
-
-static void *ftom_tilde_new(void)
-{
- t_ftom_tilde *x = (t_ftom_tilde *)pd_new(ftom_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *ftom_tilde_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; *in++, out++)
- {
- float f = *in;
- *out = (f > 0 ? 17.3123405046 * log(.12231220585 * f) : -1500);
- }
- return (w + 4);
-}
-
-static void ftom_tilde_dsp(t_ftom_tilde *x, t_signal **sp)
-{
- dsp_add(ftom_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void ftom_tilde_setup(void)
-{
- ftom_tilde_class = class_new(gensym("ftom~"), (t_newmethod)ftom_tilde_new, 0,
- sizeof(t_ftom_tilde), 0, 0);
- CLASS_MAINSIGNALIN(ftom_tilde_class, t_ftom_tilde, x_f);
- class_addmethod(ftom_tilde_class, (t_method)ftom_tilde_dsp, gensym("dsp"), 0);
-}
-
-/* ------------------------------ dbtorms~ -------------------------- */
-
-typedef struct dbtorms_tilde
-{
- t_object x_obj;
- float x_f;
-} t_dbtorms_tilde;
-
-t_class *dbtorms_tilde_class;
-
-static void *dbtorms_tilde_new(void)
-{
- t_dbtorms_tilde *x = (t_dbtorms_tilde *)pd_new(dbtorms_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *dbtorms_tilde_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- float f = *in;
- if (f <= 0) *out = 0;
- else
- {
- if (f > 485)
- f = 485;
- *out = exp((LOGTEN * 0.05) * (f-100.));
- }
- }
- return (w + 4);
-}
-
-static void dbtorms_tilde_dsp(t_dbtorms_tilde *x, t_signal **sp)
-{
- dsp_add(dbtorms_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void dbtorms_tilde_setup(void)
-{
- dbtorms_tilde_class = class_new(gensym("dbtorms~"), (t_newmethod)dbtorms_tilde_new, 0,
- sizeof(t_dbtorms_tilde), 0, 0);
- CLASS_MAINSIGNALIN(dbtorms_tilde_class, t_dbtorms_tilde, x_f);
- class_addmethod(dbtorms_tilde_class, (t_method)dbtorms_tilde_dsp, gensym("dsp"), 0);
-}
-
-/* ------------------------------ rmstodb~ -------------------------- */
-
-typedef struct rmstodb_tilde
-{
- t_object x_obj;
- float x_f;
-} t_rmstodb_tilde;
-
-t_class *rmstodb_tilde_class;
-
-static void *rmstodb_tilde_new(void)
-{
- t_rmstodb_tilde *x = (t_rmstodb_tilde *)pd_new(rmstodb_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *rmstodb_tilde_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- float f = *in;
- if (f <= 0) *out = 0;
- else
- {
- float g = 100 + 20./LOGTEN * log(f);
- *out = (g < 0 ? 0 : g);
- }
- }
- return (w + 4);
-}
-
-static void rmstodb_tilde_dsp(t_rmstodb_tilde *x, t_signal **sp)
-{
- dsp_add(rmstodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void rmstodb_tilde_setup(void)
-{
- rmstodb_tilde_class = class_new(gensym("rmstodb~"), (t_newmethod)rmstodb_tilde_new, 0,
- sizeof(t_rmstodb_tilde), 0, 0);
- CLASS_MAINSIGNALIN(rmstodb_tilde_class, t_rmstodb_tilde, x_f);
- class_addmethod(rmstodb_tilde_class, (t_method)rmstodb_tilde_dsp, gensym("dsp"), 0);
-}
-
-/* ------------------------------ dbtopow~ -------------------------- */
-
-typedef struct dbtopow_tilde
-{
- t_object x_obj;
- float x_f;
-} t_dbtopow_tilde;
-
-t_class *dbtopow_tilde_class;
-
-static void *dbtopow_tilde_new(void)
-{
- t_dbtopow_tilde *x = (t_dbtopow_tilde *)pd_new(dbtopow_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *dbtopow_tilde_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- float f = *in;
- if (f <= 0) *out = 0;
- else
- {
- if (f > 870)
- f = 870;
- *out = exp((LOGTEN * 0.1) * (f-100.));
- }
- }
- return (w + 4);
-}
-
-static void dbtopow_tilde_dsp(t_dbtopow_tilde *x, t_signal **sp)
-{
- dsp_add(dbtopow_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void dbtopow_tilde_setup(void)
-{
- dbtopow_tilde_class = class_new(gensym("dbtopow~"), (t_newmethod)dbtopow_tilde_new, 0,
- sizeof(t_dbtopow_tilde), 0, 0);
- CLASS_MAINSIGNALIN(dbtopow_tilde_class, t_dbtopow_tilde, x_f);
- class_addmethod(dbtopow_tilde_class, (t_method)dbtopow_tilde_dsp, gensym("dsp"), 0);
-}
-
-/* ------------------------------ powtodb~ -------------------------- */
-
-typedef struct powtodb_tilde
-{
- t_object x_obj;
- float x_f;
-} t_powtodb_tilde;
-
-t_class *powtodb_tilde_class;
-
-static void *powtodb_tilde_new(void)
-{
- t_powtodb_tilde *x = (t_powtodb_tilde *)pd_new(powtodb_tilde_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *powtodb_tilde_perform(t_int *w)
-{
- float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
- t_int n = *(t_int *)(w+3);
- for (; n--; in++, out++)
- {
- float f = *in;
- if (f <= 0) *out = 0;
- else
- {
- float g = 100 + 10./LOGTEN * log(f);
- *out = (g < 0 ? 0 : g);
- }
- }
- return (w + 4);
-}
-
-static void powtodb_tilde_dsp(t_powtodb_tilde *x, t_signal **sp)
-{
- dsp_add(powtodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void powtodb_tilde_setup(void)
-{
- powtodb_tilde_class = class_new(gensym("powtodb~"), (t_newmethod)powtodb_tilde_new, 0,
- sizeof(t_powtodb_tilde), 0, 0);
- CLASS_MAINSIGNALIN(powtodb_tilde_class, t_powtodb_tilde, x_f);
- class_addmethod(powtodb_tilde_class, (t_method)powtodb_tilde_dsp, gensym("dsp"), 0);
-}
-
-
-/* ------------------------ global setup routine ------------------------- */
-
-void d_math_setup(void)
-{
- t_symbol *s = gensym("acoustics~.pd");
- clip_setup();
- sigrsqrt_setup();
- sigsqrt_setup();
- sigwrap_setup();
- mtof_tilde_setup();
- ftom_tilde_setup();
- dbtorms_tilde_setup();
- rmstodb_tilde_setup();
- dbtopow_tilde_setup();
- powtodb_tilde_setup();
-
- class_sethelpsymbol(mtof_tilde_class, s);
- class_sethelpsymbol(ftom_tilde_class, s);
- class_sethelpsymbol(dbtorms_tilde_class, s);
- class_sethelpsymbol(rmstodb_tilde_class, s);
- class_sethelpsymbol(dbtopow_tilde_class, s);
- class_sethelpsymbol(powtodb_tilde_class, s);
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/d_mayer_fft.c b/apps/plugins/pdbox/PDa/src/d_mayer_fft.c
index 7c29c6e7c8..95fb303e91 100644
--- a/apps/plugins/pdbox/PDa/src/d_mayer_fft.c
+++ b/apps/plugins/pdbox/PDa/src/d_mayer_fft.c
@@ -417,422 +417,4 @@ void mayer_realifft(int n, REAL *real)
}
mayer_fht(real,n);
}
-/*
-** FFT and FHT routines
-** Copyright 1988, 1993; Ron Mayer
-**
-** mayer_fht(fz,n);
-** Does a hartley transform of "n" points in the array "fz".
-** mayer_fft(n,real,imag)
-** Does a fourier transform of "n" points of the "real" and
-** "imag" arrays.
-** mayer_ifft(n,real,imag)
-** Does an inverse fourier transform of "n" points of the "real"
-** and "imag" arrays.
-** mayer_realfft(n,real)
-** Does a real-valued fourier transform of "n" points of the
-** "real" array. The real part of the transform ends
-** up in the first half of the array and the imaginary part of the
-** transform ends up in the second half of the array.
-** mayer_realifft(n,real)
-** The inverse of the realfft() routine above.
-**
-**
-** NOTE: This routine uses at least 2 patented algorithms, and may be
-** under the restrictions of a bunch of different organizations.
-** Although I wrote it completely myself, it is kind of a derivative
-** of a routine I once authored and released under the GPL, so it
-** may fall under the free software foundation's restrictions;
-** it was worked on as a Stanford Univ project, so they claim
-** some rights to it; it was further optimized at work here, so
-** I think this company claims parts of it. The patents are
-** held by R. Bracewell (the FHT algorithm) and O. Buneman (the
-** trig generator), both at Stanford Univ.
-** If it were up to me, I'd say go do whatever you want with it;
-** but it would be polite to give credit to the following people
-** if you use this anywhere:
-** Euler - probable inventor of the fourier transform.
-** Gauss - probable inventor of the FFT.
-** Hartley - probable inventor of the hartley transform.
-** Buneman - for a really cool trig generator
-** Mayer(me) - for authoring this particular version and
-** including all the optimizations in one package.
-** Thanks,
-** Ron Mayer; mayer@acuson.com
-**
-*/
-
-/* This is a slightly modified version of Mayer's contribution; write
-* msp@ucsd.edu for the original code. Kudos to Mayer for a fine piece
-* of work. -msp
-*/
-
-#ifdef MSW
-#pragma warning( disable : 4305 ) /* uncast const double to float */
-#pragma warning( disable : 4244 ) /* uncast double to float */
-#pragma warning( disable : 4101 ) /* unused local variables */
-#endif
-
-#define REAL float
-#define GOOD_TRIG
-
-#ifdef GOOD_TRIG
-#else
-#define FAST_TRIG
-#endif
-
-#if defined(GOOD_TRIG)
-#define FHT_SWAP(a,b,t) {(t)=(a);(a)=(b);(b)=(t);}
-#define TRIG_VARS \
- int t_lam=0;
-#define TRIG_INIT(k,c,s) \
- { \
- int i; \
- for (i=2 ; i<=k ; i++) \
- {coswrk[i]=costab[i];sinwrk[i]=sintab[i];} \
- t_lam = 0; \
- c = 1; \
- s = 0; \
- }
-#define TRIG_NEXT(k,c,s) \
- { \
- int i,j; \
- (t_lam)++; \
- for (i=0 ; !((1<<i)&t_lam) ; i++); \
- i = k-i; \
- s = sinwrk[i]; \
- c = coswrk[i]; \
- if (i>1) \
- { \
- for (j=k-i+2 ; (1<<j)&t_lam ; j++); \
- j = k - j; \
- sinwrk[i] = halsec[i] * (sinwrk[i-1] + sinwrk[j]); \
- coswrk[i] = halsec[i] * (coswrk[i-1] + coswrk[j]); \
- } \
- }
-#define TRIG_RESET(k,c,s)
-#endif
-
-#if defined(FAST_TRIG)
-#define TRIG_VARS \
- REAL t_c,t_s;
-#define TRIG_INIT(k,c,s) \
- { \
- t_c = costab[k]; \
- t_s = sintab[k]; \
- c = 1; \
- s = 0; \
- }
-#define TRIG_NEXT(k,c,s) \
- { \
- REAL t = c; \
- c = t*t_c - s*t_s; \
- s = t*t_s + s*t_c; \
- }
-#define TRIG_RESET(k,c,s)
-#endif
-
-static REAL halsec[20]=
- {
- 0,
- 0,
- .54119610014619698439972320536638942006107206337801,
- .50979557910415916894193980398784391368261849190893,
- .50241928618815570551167011928012092247859337193963,
- .50060299823519630134550410676638239611758632599591,
- .50015063602065098821477101271097658495974913010340,
- .50003765191554772296778139077905492847503165398345,
- .50000941253588775676512870469186533538523133757983,
- .50000235310628608051401267171204408939326297376426,
- .50000058827484117879868526730916804925780637276181,
- .50000014706860214875463798283871198206179118093251,
- .50000003676714377807315864400643020315103490883972,
- .50000000919178552207366560348853455333939112569380,
- .50000000229794635411562887767906868558991922348920,
- .50000000057448658687873302235147272458812263401372
- };
-static REAL costab[20]=
- {
- .00000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768847,
- .92387953251128675612818318939678828682241662586364,
- .98078528040323044912618223613423903697393373089333,
- .99518472667219688624483695310947992157547486872985,
- .99879545620517239271477160475910069444320361470461,
- .99969881869620422011576564966617219685006108125772,
- .99992470183914454092164649119638322435060646880221,
- .99998117528260114265699043772856771617391725094433,
- .99999529380957617151158012570011989955298763362218,
- .99999882345170190992902571017152601904826792288976,
- .99999970586288221916022821773876567711626389934930,
- .99999992646571785114473148070738785694820115568892,
- .99999998161642929380834691540290971450507605124278,
- .99999999540410731289097193313960614895889430318945,
- .99999999885102682756267330779455410840053741619428
- };
-static REAL sintab[20]=
- {
- 1.0000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768846,
- .38268343236508977172845998403039886676134456248561,
- .19509032201612826784828486847702224092769161775195,
- .09801714032956060199419556388864184586113667316749,
- .04906767432741801425495497694268265831474536302574,
- .02454122852291228803173452945928292506546611923944,
- .01227153828571992607940826195100321214037231959176,
- .00613588464915447535964023459037258091705788631738,
- .00306795676296597627014536549091984251894461021344,
- .00153398018628476561230369715026407907995486457522,
- .00076699031874270452693856835794857664314091945205,
- .00038349518757139558907246168118138126339502603495,
- .00019174759731070330743990956198900093346887403385,
- .00009587379909597734587051721097647635118706561284,
- .00004793689960306688454900399049465887274686668768
- };
-static REAL coswrk[20]=
- {
- .00000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768847,
- .92387953251128675612818318939678828682241662586364,
- .98078528040323044912618223613423903697393373089333,
- .99518472667219688624483695310947992157547486872985,
- .99879545620517239271477160475910069444320361470461,
- .99969881869620422011576564966617219685006108125772,
- .99992470183914454092164649119638322435060646880221,
- .99998117528260114265699043772856771617391725094433,
- .99999529380957617151158012570011989955298763362218,
- .99999882345170190992902571017152601904826792288976,
- .99999970586288221916022821773876567711626389934930,
- .99999992646571785114473148070738785694820115568892,
- .99999998161642929380834691540290971450507605124278,
- .99999999540410731289097193313960614895889430318945,
- .99999999885102682756267330779455410840053741619428
- };
-static REAL sinwrk[20]=
- {
- 1.0000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768846,
- .38268343236508977172845998403039886676134456248561,
- .19509032201612826784828486847702224092769161775195,
- .09801714032956060199419556388864184586113667316749,
- .04906767432741801425495497694268265831474536302574,
- .02454122852291228803173452945928292506546611923944,
- .01227153828571992607940826195100321214037231959176,
- .00613588464915447535964023459037258091705788631738,
- .00306795676296597627014536549091984251894461021344,
- .00153398018628476561230369715026407907995486457522,
- .00076699031874270452693856835794857664314091945205,
- .00038349518757139558907246168118138126339502603495,
- .00019174759731070330743990956198900093346887403385,
- .00009587379909597734587051721097647635118706561284,
- .00004793689960306688454900399049465887274686668768
- };
-
-
-#define SQRT2_2 0.70710678118654752440084436210484
-#define SQRT2 2*0.70710678118654752440084436210484
-
-void mayer_fht(REAL *fz, int n)
-{
-/* REAL a,b;
-REAL c1,s1,s2,c2,s3,c3,s4,c4;
- REAL f0,g0,f1,g1,f2,g2,f3,g3; */
- int k,k1,k2,k3,k4,kx;
- REAL *fi,*fn,*gi;
- TRIG_VARS;
- for (k1=1,k2=0;k1<n;k1++)
- {
- REAL aa;
- for (k=n>>1; (!((k2^=k)&k)); k>>=1);
- if (k1>k2)
- {
- aa=fz[k1];fz[k1]=fz[k2];fz[k2]=aa;
- }
- }
- for ( k=0 ; (1<<k)<n ; k++ );
- k &= 1;
- if (k==0)
- {
- for (fi=fz,fn=fz+n;fi<fn;fi+=4)
- {
- REAL f0,f1,f2,f3;
- f1 = fi[0 ]-fi[1 ];
- f0 = fi[0 ]+fi[1 ];
- f3 = fi[2 ]-fi[3 ];
- f2 = fi[2 ]+fi[3 ];
- fi[2 ] = (f0-f2);
- fi[0 ] = (f0+f2);
- fi[3 ] = (f1-f3);
- fi[1 ] = (f1+f3);
- }
- }
- else
- {
- for (fi=fz,fn=fz+n,gi=fi+1;fi<fn;fi+=8,gi+=8)
- {
- REAL bs1,bc1,bs2,bc2,bs3,bc3,bs4,bc4,
- bg0,bf0,bf1,bg1,bf2,bg2,bf3,bg3;
- bc1 = fi[0 ] - gi[0 ];
- bs1 = fi[0 ] + gi[0 ];
- bc2 = fi[2 ] - gi[2 ];
- bs2 = fi[2 ] + gi[2 ];
- bc3 = fi[4 ] - gi[4 ];
- bs3 = fi[4 ] + gi[4 ];
- bc4 = fi[6 ] - gi[6 ];
- bs4 = fi[6 ] + gi[6 ];
- bf1 = (bs1 - bs2);
- bf0 = (bs1 + bs2);
- bg1 = (bc1 - bc2);
- bg0 = (bc1 + bc2);
- bf3 = (bs3 - bs4);
- bf2 = (bs3 + bs4);
- bg3 = SQRT2*bc4;
- bg2 = SQRT2*bc3;
- fi[4 ] = bf0 - bf2;
- fi[0 ] = bf0 + bf2;
- fi[6 ] = bf1 - bf3;
- fi[2 ] = bf1 + bf3;
- gi[4 ] = bg0 - bg2;
- gi[0 ] = bg0 + bg2;
- gi[6 ] = bg1 - bg3;
- gi[2 ] = bg1 + bg3;
- }
- }
- if (n<16) return;
-
- do
- {
- REAL s1,c1;
- int ii;
- k += 2;
- k1 = 1 << k;
- k2 = k1 << 1;
- k4 = k2 << 1;
- k3 = k2 + k1;
- kx = k1 >> 1;
- fi = fz;
- gi = fi + kx;
- fn = fz + n;
- do
- {
- REAL g0,f0,f1,g1,f2,g2,f3,g3;
- f1 = fi[0 ] - fi[k1];
- f0 = fi[0 ] + fi[k1];
- f3 = fi[k2] - fi[k3];
- f2 = fi[k2] + fi[k3];
- fi[k2] = f0 - f2;
- fi[0 ] = f0 + f2;
- fi[k3] = f1 - f3;
- fi[k1] = f1 + f3;
- g1 = gi[0 ] - gi[k1];
- g0 = gi[0 ] + gi[k1];
- g3 = SQRT2 * gi[k3];
- g2 = SQRT2 * gi[k2];
- gi[k2] = g0 - g2;
- gi[0 ] = g0 + g2;
- gi[k3] = g1 - g3;
- gi[k1] = g1 + g3;
- gi += k4;
- fi += k4;
- } while (fi<fn);
- TRIG_INIT(k,c1,s1);
- for (ii=1;ii<kx;ii++)
- {
- REAL c2,s2;
- TRIG_NEXT(k,c1,s1);
- c2 = c1*c1 - s1*s1;
- s2 = 2*(c1*s1);
- fn = fz + n;
- fi = fz +ii;
- gi = fz +k1-ii;
- do
- {
- REAL a,b,g0,f0,f1,g1,f2,g2,f3,g3;
- b = s2*fi[k1] - c2*gi[k1];
- a = c2*fi[k1] + s2*gi[k1];
- f1 = fi[0 ] - a;
- f0 = fi[0 ] + a;
- g1 = gi[0 ] - b;
- g0 = gi[0 ] + b;
- b = s2*fi[k3] - c2*gi[k3];
- a = c2*fi[k3] + s2*gi[k3];
- f3 = fi[k2] - a;
- f2 = fi[k2] + a;
- g3 = gi[k2] - b;
- g2 = gi[k2] + b;
- b = s1*f2 - c1*g3;
- a = c1*f2 + s1*g3;
- fi[k2] = f0 - a;
- fi[0 ] = f0 + a;
- gi[k3] = g1 - b;
- gi[k1] = g1 + b;
- b = c1*g2 - s1*f3;
- a = s1*g2 + c1*f3;
- gi[k2] = g0 - a;
- gi[0 ] = g0 + a;
- fi[k3] = f1 - b;
- fi[k1] = f1 + b;
- gi += k4;
- fi += k4;
- } while (fi<fn);
- }
- TRIG_RESET(k,c1,s1);
- } while (k4<n);
-}
-
-void mayer_fft(int n, REAL *real, REAL *imag)
-{
- REAL a,b,c,d;
- REAL q,r,s,t;
- int i,j,k;
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i]; b = real[j]; q=a+b; r=a-b;
- c = imag[i]; d = imag[j]; s=c+d; t=c-d;
- real[i] = (q+t)*.5; real[j] = (q-t)*.5;
- imag[i] = (s-r)*.5; imag[j] = (s+r)*.5;
- }
- mayer_fht(real,n);
- mayer_fht(imag,n);
-}
-
-void mayer_ifft(int n, REAL *real, REAL *imag)
-{
- REAL a,b,c,d;
- REAL q,r,s,t;
- int i,j,k;
- mayer_fht(real,n);
- mayer_fht(imag,n);
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i]; b = real[j]; q=a+b; r=a-b;
- c = imag[i]; d = imag[j]; s=c+d; t=c-d;
- imag[i] = (s+r)*0.5; imag[j] = (s-r)*0.5;
- real[i] = (q-t)*0.5; real[j] = (q+t)*0.5;
- }
-}
-
-void mayer_realfft(int n, REAL *real)
-{
- REAL a,b,c,d;
- int i,j,k;
- mayer_fht(real,n);
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i];
- b = real[j];
- real[j] = (a-b)*0.5;
- real[i] = (a+b)*0.5;
- }
-}
-
-void mayer_realifft(int n, REAL *real)
-{
- REAL a,b,c,d;
- int i,j,k;
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i];
- b = real[j];
- real[j] = (a-b);
- real[i] = (a+b);
- }
- mayer_fht(real,n);
-}
diff --git a/apps/plugins/pdbox/PDa/src/d_misc.c b/apps/plugins/pdbox/PDa/src/d_misc.c
index f601d66d90..b6d36764b8 100644
--- a/apps/plugins/pdbox/PDa/src/d_misc.c
+++ b/apps/plugins/pdbox/PDa/src/d_misc.c
@@ -257,268 +257,3 @@ void d_misc_setup(void)
samplerate_tilde_setup();
}
-
-
-
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* miscellaneous: print~; more to come.
-*/
-
-#include "m_pd.h"
-#include <stdio.h>
-#include <string.h>
-
-/* ------------------------- print~ -------------------------- */
-static t_class *print_class;
-
-typedef struct _print
-{
- t_object x_obj;
- float x_f;
- t_symbol *x_sym;
- int x_count;
-} t_print;
-
-static t_int *print_perform(t_int *w)
-{
- t_print *x = (t_print *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- int n = (int)(w[3]);
- if (x->x_count)
- {
- post("%s:", x->x_sym->s_name);
- if (n == 1) post("%8g", in[0]);
- else if (n == 2) post("%8g %8g", in[0], in[1]);
- else if (n == 4) post("%8g %8g %8g %8g",
- in[0], in[1], in[2], in[3]);
- else while (n > 0)
- {
- post("%-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g",
- in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]);
- n -= 8;
- in += 8;
- }
- x->x_count--;
- }
- return (w+4);
-}
-
-static void print_dsp(t_print *x, t_signal **sp)
-{
- dsp_add(print_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
-}
-
-static void print_float(t_print *x, t_float f)
-{
- if (f < 0) f = 0;
- x->x_count = f;
-}
-
-static void print_bang(t_print *x)
-{
- x->x_count = 1;
-}
-
-static void *print_new(t_symbol *s)
-{
- t_print *x = (t_print *)pd_new(print_class);
- x->x_sym = (s->s_name[0]? s : gensym("print~"));
- x->x_count = 0;
- x->x_f = 0;
- return (x);
-}
-
-static void print_setup(void)
-{
- print_class = class_new(gensym("print~"), (t_newmethod)print_new, 0,
- sizeof(t_print), 0, A_DEFSYM, 0);
- CLASS_MAINSIGNALIN(print_class, t_print, x_f);
- class_addmethod(print_class, (t_method)print_dsp, gensym("dsp"), 0);
- class_addbang(print_class, print_bang);
- class_addfloat(print_class, print_float);
-}
-
-/* ------------------------- scope~ -------------------------- */
-/* this has been replaced by arrays; to be deleted later */
-
-#include "g_canvas.h"
-
-static t_class *scope_class;
-
-#define SCOPESIZE 256
-
-typedef struct _scope
-{
- t_object x_obj;
- t_sample x_samps[SCOPESIZE];
- int x_phase;
- int x_drawn;
- void *x_canvas;
-} t_scope;
-
-static t_int *scope_perform(t_int *w)
-{
- t_scope *x = (t_scope *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- int n = (int)(w[3]), phase = x->x_phase;
- while (n--)
- {
- x->x_samps[phase] = *in++;
- phase = (phase + 1) & (SCOPESIZE-1);
- }
- x->x_phase = phase;
- return (w+4);
-}
-
-static void scope_dsp(t_scope *x, t_signal **sp)
-{
- dsp_add(scope_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
-}
-
-static void scope_erase(t_scope *x)
-{
- if (x->x_drawn) sys_vgui(".x%x.c delete gumbo\n", x->x_canvas);
-}
-
-#define X1 10.
-#define X2 20.
-#define YC 5.
-static void scope_bang(t_scope *x)
-{
- int n, phase;
- char hugebuf[10000], *s = hugebuf;
- scope_erase(x);
- sys_vgui(".x%x.c create line 10c 5c 20c 5c -tags gumbo\n", x->x_canvas);
- sprintf(s, ".x%x.c create line ", (t_int)x->x_canvas);
- s += strlen(s);
- for (n = 0, phase = x->x_phase;
- n < SCOPESIZE; phase = ((phase+1) & (SCOPESIZE-1)), n++)
- {
- sprintf(s, "%fc %fc ", X1 + (X2 - X1) * (float)n * (1./SCOPESIZE),
- YC - 5 * x->x_samps[phase]);
- s += strlen(s);
- /* post("phase %d", phase); */
- }
- sprintf(s, "-tags gumbo\n");
- sys_gui(hugebuf);
- x->x_drawn = 1;
-}
-
-static void scope_free(t_scope *x)
-{
- scope_erase(x);
-}
-
-static void *scope_new(t_symbol *s)
-{
- t_scope *x = (t_scope *)pd_new(scope_class);
- error("scope: this is now obsolete; use arrays and tabwrite~ instead");
- x->x_phase = 0;
- x->x_drawn = 0;
- x->x_canvas = canvas_getcurrent();
- return (x);
-}
-
-static void scope_setup(void)
-{
- scope_class = class_new(gensym("scope~"), (t_newmethod)scope_new,
- (t_method)scope_free, sizeof(t_scope), 0, A_DEFSYM, 0);
- class_addmethod(scope_class, nullfn, gensym("signal"), 0);
- class_addmethod(scope_class, (t_method)scope_dsp, gensym("dsp"), 0);
- class_addbang(scope_class, scope_bang);
-}
-
-/* ------------------------ bang~ -------------------------- */
-
-static t_class *bang_tilde_class;
-
-typedef struct _bang
-{
- t_object x_obj;
- t_clock *x_clock;
-} t_bang;
-
-static t_int *bang_tilde_perform(t_int *w)
-{
- t_bang *x = (t_bang *)(w[1]);
- clock_delay(x->x_clock, 0);
- return (w+2);
-}
-
-static void bang_tilde_dsp(t_bang *x, t_signal **sp)
-{
- dsp_add(bang_tilde_perform, 1, x);
-}
-
-static void bang_tilde_tick(t_bang *x)
-{
- outlet_bang(x->x_obj.ob_outlet);
-}
-
-static void bang_tilde_free(t_bang *x)
-{
- clock_free(x->x_clock);
-}
-
-static void *bang_tilde_new(t_symbol *s)
-{
- t_bang *x = (t_bang *)pd_new(bang_tilde_class);
- x->x_clock = clock_new(x, (t_method)bang_tilde_tick);
- outlet_new(&x->x_obj, &s_bang);
- return (x);
-}
-
-static void bang_tilde_setup(void)
-{
- bang_tilde_class = class_new(gensym("bang~"), (t_newmethod)bang_tilde_new,
- (t_method)bang_tilde_free, sizeof(t_bang), 0, 0);
- class_addmethod(bang_tilde_class, (t_method)bang_tilde_dsp,
- gensym("dsp"), 0);
-}
-
-/* ------------------------ samplerate~~ -------------------------- */
-
-static t_class *samplerate_tilde_class;
-
-typedef struct _samplerate
-{
- t_object x_obj;
-} t_samplerate;
-
-static void samplerate_tilde_bang(t_samplerate *x)
-{
- outlet_float(x->x_obj.ob_outlet, sys_getsr());
-}
-
-static void *samplerate_tilde_new(t_symbol *s)
-{
- t_samplerate *x = (t_samplerate *)pd_new(samplerate_tilde_class);
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-static void samplerate_tilde_setup(void)
-{
- samplerate_tilde_class = class_new(gensym("samplerate~"),
- (t_newmethod)samplerate_tilde_new, 0, sizeof(t_samplerate), 0, 0);
- class_addbang(samplerate_tilde_class, samplerate_tilde_bang);
-}
-
-/* ------------------------ global setup routine ------------------------- */
-
-void d_misc_setup(void)
-{
-#ifndef FIXEDPOINT
- print_setup();
-#endif
- scope_setup();
- bang_tilde_setup();
- samplerate_tilde_setup();
-}
-
-
-
-
diff --git a/apps/plugins/pdbox/PDa/src/d_osc.c b/apps/plugins/pdbox/PDa/src/d_osc.c
index 8a3486d981..35b43b82c6 100644
--- a/apps/plugins/pdbox/PDa/src/d_osc.c
+++ b/apps/plugins/pdbox/PDa/src/d_osc.c
@@ -533,538 +533,3 @@ void d_osc_setup(void)
noise_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* sinusoidal oscillator and table lookup; see also tabosc4~ in d_array.c.
-*/
-
-#include "m_pd.h"
-#include "math.h"
-
-#define UNITBIT32 1572864. /* 3*2^19; bit 32 has place value 1 */
-
- /* machine-dependent definitions. These ifdefs really
- should have been by CPU type and not by operating system! */
-#ifdef IRIX
- /* big-endian. Most significant byte is at low address in memory */
-#define HIOFFSET 0 /* word offset to find MSB */
-#define LOWOFFSET 1 /* word offset to find LSB */
-#define int32 long /* a data type that has 32 bits */
-#else
-#ifdef MSW
- /* little-endian; most significant byte is at highest address */
-#define HIOFFSET 1
-#define LOWOFFSET 0
-#define int32 long
-#else
-#ifdef __FreeBSD__
-#include <machine/endian.h>
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define HIOFFSET 1
-#define LOWOFFSET 0
-#else
-#define HIOFFSET 0 /* word offset to find MSB */
-#define LOWOFFSET 1 /* word offset to find LSB */
-#endif /* BYTE_ORDER */
-#include <sys/types.h>
-#define int32 int32_t
-#endif
-#ifdef __linux__
-
-#include <endian.h>
-
-#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN)
-#error No byte order defined
-#endif
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define HIOFFSET 1
-#define LOWOFFSET 0
-#else
-#define HIOFFSET 0 /* word offset to find MSB */
-#define LOWOFFSET 1 /* word offset to find LSB */
-#endif /* __BYTE_ORDER */
-
-#include <sys/types.h>
-#define int32 int32_t
-
-#else
-#ifdef MACOSX
-#define HIOFFSET 0 /* word offset to find MSB */
-#define LOWOFFSET 1 /* word offset to find LSB */
-#define int32 int /* a data type that has 32 bits */
-
-#endif /* MACOSX */
-#endif /* __linux__ */
-#endif /* MSW */
-#endif /* SGI */
-
-union tabfudge
-{
- double tf_d;
- int32 tf_i[2];
-};
-
-
-/* -------------------------- phasor~ ------------------------------ */
-static t_class *phasor_class, *scalarphasor_class;
-
-#if 1 /* in the style of R. Hoeldrich (ICMC 1995 Banff) */
-
-typedef struct _phasor
-{
- t_object x_obj;
- double x_phase;
- float x_conv;
- float x_f; /* scalar frequency */
-} t_phasor;
-
-static void *phasor_new(t_floatarg f)
-{
- t_phasor *x = (t_phasor *)pd_new(phasor_class);
- x->x_f = f;
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- x->x_phase = 0;
- x->x_conv = 0;
- outlet_new(&x->x_obj, gensym("signal"));
- return (x);
-}
-
-static t_int *phasor_perform(t_int *w)
-{
- t_phasor *x = (t_phasor *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
- int n = (int)(w[4]);
- double dphase = x->x_phase + UNITBIT32;
- union tabfudge tf;
- int normhipart;
- float conv = x->x_conv;
-
- tf.tf_d = UNITBIT32;
- normhipart = tf.tf_i[HIOFFSET];
- tf.tf_d = dphase;
-
- while (n--)
- {
- tf.tf_i[HIOFFSET] = normhipart;
- dphase += *in++ * conv;
- *out++ = tf.tf_d - UNITBIT32;
- tf.tf_d = dphase;
- }
- tf.tf_i[HIOFFSET] = normhipart;
- x->x_phase = tf.tf_d - UNITBIT32;
- return (w+5);
-}
-
-static void phasor_dsp(t_phasor *x, t_signal **sp)
-{
- x->x_conv = 1./sp[0]->s_sr;
- dsp_add(phasor_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void phasor_ft1(t_phasor *x, t_float f)
-{
- x->x_phase = f;
-}
-
-static void phasor_setup(void)
-{
- phasor_class = class_new(gensym("phasor~"), (t_newmethod)phasor_new, 0,
- sizeof(t_phasor), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(phasor_class, t_phasor, x_f);
- class_addmethod(phasor_class, (t_method)phasor_dsp, gensym("dsp"), 0);
- class_addmethod(phasor_class, (t_method)phasor_ft1,
- gensym("ft1"), A_FLOAT, 0);
-}
-
-#endif /* Hoeldrich version */
-
-/* ------------------------ cos~ ----------------------------- */
-
-float *cos_table;
-
-static t_class *cos_class;
-
-typedef struct _cos
-{
- t_object x_obj;
- float x_f;
-} t_cos;
-
-static void *cos_new(void)
-{
- t_cos *x = (t_cos *)pd_new(cos_class);
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_f = 0;
- return (x);
-}
-
-static t_int *cos_perform(t_int *w)
-{
- t_float *in = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
- float *tab = cos_table, *addr, f1, f2, frac;
- double dphase;
- int normhipart;
- union tabfudge tf;
-
- tf.tf_d = UNITBIT32;
- normhipart = tf.tf_i[HIOFFSET];
-
-#if 0 /* this is the readable version of the code. */
- while (n--)
- {
- dphase = (double)(*in++ * (float)(COSTABSIZE)) + UNITBIT32;
- tf.tf_d = dphase;
- addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
- tf.tf_i[HIOFFSET] = normhipart;
- frac = tf.tf_d - UNITBIT32;
- f1 = addr[0];
- f2 = addr[1];
- *out++ = f1 + frac * (f2 - f1);
- }
-#endif
-#if 1 /* this is the same, unwrapped by hand. */
- dphase = (double)(*in++ * (float)(COSTABSIZE)) + UNITBIT32;
- tf.tf_d = dphase;
- addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
- tf.tf_i[HIOFFSET] = normhipart;
- while (--n)
- {
- dphase = (double)(*in++ * (float)(COSTABSIZE)) + UNITBIT32;
- frac = tf.tf_d - UNITBIT32;
- tf.tf_d = dphase;
- f1 = addr[0];
- f2 = addr[1];
- addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
- *out++ = f1 + frac * (f2 - f1);
- tf.tf_i[HIOFFSET] = normhipart;
- }
- frac = tf.tf_d - UNITBIT32;
- f1 = addr[0];
- f2 = addr[1];
- *out++ = f1 + frac * (f2 - f1);
-#endif
- return (w+4);
-}
-
-static void cos_dsp(t_cos *x, t_signal **sp)
-{
- dsp_add(cos_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void cos_maketable(void)
-{
- int i;
- float *fp, phase, phsinc = (2. * 3.14159) / COSTABSIZE;
- union tabfudge tf;
-
- if (cos_table) return;
- cos_table = (float *)getbytes(sizeof(float) * (COSTABSIZE+1));
- for (i = COSTABSIZE + 1, fp = cos_table, phase = 0; i--;
- fp++, phase += phsinc)
- *fp = cos(phase);
-
- /* here we check at startup whether the byte alignment
- is as we declared it. If not, the code has to be
- recompiled the other way. */
- tf.tf_d = UNITBIT32 + 0.5;
- if ((unsigned)tf.tf_i[LOWOFFSET] != 0x80000000)
- bug("cos~: unexpected machine alignment");
-}
-
-static void cos_setup(void)
-{
- cos_class = class_new(gensym("cos~"), (t_newmethod)cos_new, 0,
- sizeof(t_cos), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(cos_class, t_cos, x_f);
- class_addmethod(cos_class, (t_method)cos_dsp, gensym("dsp"), 0);
- cos_maketable();
-}
-
-/* ------------------------ osc~ ----------------------------- */
-
-static t_class *osc_class, *scalarosc_class;
-
-typedef struct _osc
-{
- t_object x_obj;
- double x_phase;
- float x_conv;
- float x_f; /* frequency if scalar */
-} t_osc;
-
-static void *osc_new(t_floatarg f)
-{
- t_osc *x = (t_osc *)pd_new(osc_class);
- x->x_f = f;
- outlet_new(&x->x_obj, gensym("signal"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
- x->x_phase = 0;
- x->x_conv = 0;
- return (x);
-}
-
-static t_int *osc_perform(t_int *w)
-{
- t_osc *x = (t_osc *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
- int n = (int)(w[4]);
- float *tab = cos_table, *addr, f1, f2, frac;
- double dphase = x->x_phase + UNITBIT32;
- int normhipart;
- union tabfudge tf;
- float conv = x->x_conv;
-
- tf.tf_d = UNITBIT32;
- normhipart = tf.tf_i[HIOFFSET];
-#if 0
- while (n--)
- {
- tf.tf_d = dphase;
- dphase += *in++ * conv;
- addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
- tf.tf_i[HIOFFSET] = normhipart;
- frac = tf.tf_d - UNITBIT32;
- f1 = addr[0];
- f2 = addr[1];
- *out++ = f1 + frac * (f2 - f1);
- }
-#endif
-#if 1
- tf.tf_d = dphase;
- dphase += *in++ * conv;
- addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
- tf.tf_i[HIOFFSET] = normhipart;
- frac = tf.tf_d - UNITBIT32;
- while (--n)
- {
- tf.tf_d = dphase;
- f1 = addr[0];
- dphase += *in++ * conv;
- f2 = addr[1];
- addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
- tf.tf_i[HIOFFSET] = normhipart;
- *out++ = f1 + frac * (f2 - f1);
- frac = tf.tf_d - UNITBIT32;
- }
- f1 = addr[0];
- f2 = addr[1];
- *out++ = f1 + frac * (f2 - f1);
-#endif
-
- tf.tf_d = UNITBIT32 * COSTABSIZE;
- normhipart = tf.tf_i[HIOFFSET];
- tf.tf_d = dphase + (UNITBIT32 * COSTABSIZE - UNITBIT32);
- tf.tf_i[HIOFFSET] = normhipart;
- x->x_phase = tf.tf_d - UNITBIT32 * COSTABSIZE;
- return (w+5);
-}
-
-static void osc_dsp(t_osc *x, t_signal **sp)
-{
- x->x_conv = COSTABSIZE/sp[0]->s_sr;
- dsp_add(osc_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-static void osc_ft1(t_osc *x, t_float f)
-{
- x->x_phase = COSTABSIZE * f;
-}
-
-static void osc_setup(void)
-{
- osc_class = class_new(gensym("osc~"), (t_newmethod)osc_new, 0,
- sizeof(t_osc), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(osc_class, t_osc, x_f);
- class_addmethod(osc_class, (t_method)osc_dsp, gensym("dsp"), 0);
- class_addmethod(osc_class, (t_method)osc_ft1, gensym("ft1"), A_FLOAT, 0);
-
- cos_maketable();
-}
-
-/* ---------------- vcf~ - 2-pole bandpass filter. ----------------- */
-
-typedef struct vcfctl
-{
- float c_re;
- float c_im;
- float c_q;
- float c_isr;
-} t_vcfctl;
-
-typedef struct sigvcf
-{
- t_object x_obj;
- t_vcfctl x_cspace;
- t_vcfctl *x_ctl;
- float x_f;
-} t_sigvcf;
-
-t_class *sigvcf_class;
-
-static void *sigvcf_new(t_floatarg q)
-{
- t_sigvcf *x = (t_sigvcf *)pd_new(sigvcf_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- outlet_new(&x->x_obj, gensym("signal"));
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_ctl = &x->x_cspace;
- x->x_cspace.c_re = 0;
- x->x_cspace.c_im = 0;
- x->x_cspace.c_q = q;
- x->x_cspace.c_isr = 0;
- x->x_f = 0;
- return (x);
-}
-
-static void sigvcf_ft1(t_sigvcf *x, t_floatarg f)
-{
- x->x_ctl->c_q = (f > 0 ? f : 0.f);
-}
-
-static t_int *sigvcf_perform(t_int *w)
-{
- float *in1 = (float *)(w[1]);
- float *in2 = (float *)(w[2]);
- float *out1 = (float *)(w[3]);
- float *out2 = (float *)(w[4]);
- t_vcfctl *c = (t_vcfctl *)(w[5]);
- int n = (t_int)(w[6]);
- int i;
- float re = c->c_re, re2;
- float im = c->c_im;
- float q = c->c_q;
- float qinv = (q > 0? 1.0f/q : 0);
- float ampcorrect = 2.0f - 2.0f / (q + 2.0f);
- float isr = c->c_isr;
- float coefr, coefi;
- float *tab = cos_table, *addr, f1, f2, frac;
- double dphase;
- int normhipart, tabindex;
- union tabfudge tf;
-
- tf.tf_d = UNITBIT32;
- normhipart = tf.tf_i[HIOFFSET];
-
- for (i = 0; i < n; i++)
- {
- float cf, cfindx, r, oneminusr;
- cf = *in2++ * isr;
- if (cf < 0) cf = 0;
- cfindx = cf * (float)(COSTABSIZE/6.28318f);
- r = (qinv > 0 ? 1 - cf * qinv : 0);
- if (r < 0) r = 0;
- oneminusr = 1.0f - r;
- dphase = ((double)(cfindx)) + UNITBIT32;
- tf.tf_d = dphase;
- tabindex = tf.tf_i[HIOFFSET] & (COSTABSIZE-1);
- addr = tab + tabindex;
- tf.tf_i[HIOFFSET] = normhipart;
- frac = tf.tf_d - UNITBIT32;
- f1 = addr[0];
- f2 = addr[1];
- coefr = r * (f1 + frac * (f2 - f1));
-
- addr = tab + ((tabindex - (COSTABSIZE/4)) & (COSTABSIZE-1));
- f1 = addr[0];
- f2 = addr[1];
- coefi = r * (f1 + frac * (f2 - f1));
-
- f1 = *in1++;
- re2 = re;
- *out1++ = re = ampcorrect * oneminusr * f1
- + coefr * re2 - coefi * im;
- *out2++ = im = coefi * re2 + coefr * im;
- }
- if (PD_BIGORSMALL(re))
- re = 0;
- if (PD_BIGORSMALL(im))
- im = 0;
- c->c_re = re;
- c->c_im = im;
- return (w+7);
-}
-
-static void sigvcf_dsp(t_sigvcf *x, t_signal **sp)
-{
- x->x_ctl->c_isr = 6.28318f/sp[0]->s_sr;
- dsp_add(sigvcf_perform, 6,
- sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec,
- x->x_ctl, sp[0]->s_n);
-
-}
-
-void sigvcf_setup(void)
-{
- sigvcf_class = class_new(gensym("vcf~"), (t_newmethod)sigvcf_new, 0,
- sizeof(t_sigvcf), 0, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(sigvcf_class, t_sigvcf, x_f);
- class_addmethod(sigvcf_class, (t_method)sigvcf_dsp, gensym("dsp"), 0);
- class_addmethod(sigvcf_class, (t_method)sigvcf_ft1,
- gensym("ft1"), A_FLOAT, 0);
-}
-
-/* -------------------------- noise~ ------------------------------ */
-static t_class *noise_class;
-
-typedef struct _noise
-{
- t_object x_obj;
- int x_val;
-} t_noise;
-
-static void *noise_new(void)
-{
- t_noise *x = (t_noise *)pd_new(noise_class);
- static int init = 307;
- x->x_val = (init *= 1319);
- outlet_new(&x->x_obj, gensym("signal"));
- return (x);
-}
-
-static t_int *noise_perform(t_int *w)
-{
- t_float *out = (t_float *)(w[1]);
- int *vp = (int *)(w[2]);
- int n = (int)(w[3]);
- int val = *vp;
- while (n--)
- {
- *out++ = ((float)((val & 0x7fffffff) - 0x40000000)) *
- (float)(1.0 / 0x40000000);
- val = val * 435898247 + 382842987;
- }
- *vp = val;
- return (w+4);
-}
-
-static void noise_dsp(t_noise *x, t_signal **sp)
-{
- dsp_add(noise_perform, 3, sp[0]->s_vec, &x->x_val, sp[0]->s_n);
-}
-
-static void noise_setup(void)
-{
- noise_class = class_new(gensym("noise~"), (t_newmethod)noise_new, 0,
- sizeof(t_noise), 0, 0);
- class_addmethod(noise_class, (t_method)noise_dsp, gensym("dsp"), 0);
-}
-
-
-/* ----------------------- global setup routine ---------------- */
-void d_osc_setup(void)
-{
- phasor_setup();
- cos_setup();
- osc_setup();
- sigvcf_setup();
- noise_setup();
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/d_resample.c b/apps/plugins/pdbox/PDa/src/d_resample.c
index 4e617ec4df..1aa672750d 100644
--- a/apps/plugins/pdbox/PDa/src/d_resample.c
+++ b/apps/plugins/pdbox/PDa/src/d_resample.c
@@ -223,228 +223,4 @@ void resampleto_dsp(t_resample *x,
return;
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* upsampling/downsampling methods for inlet~/outlet~
- *
- * mfg.gfd.uil
- * IOhannes
- *
- * 2509:forum::für::umläute:2001
- */
-
-
-
-#include "m_pd.h"
-
-/* --------------------- up/down-sampling --------------------- */
-t_int *downsampling_perform_0(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]); /* original signal */
- t_sample *out = (t_sample *)(w[2]); /* downsampled signal */
- int down = (int)(w[3]); /* downsampling factor */
- int parent = (int)(w[4]); /* original vectorsize */
-
- int n=parent/down;
-
- while(n--){
- *out++=*in;
- in+=down;
- }
-
- return (w+5);
-}
-
-t_int *upsampling_perform_0(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]); /* original signal */
- t_sample *out = (t_sample *)(w[2]); /* upsampled signal */
- int up = (int)(w[3]); /* upsampling factor */
- int parent = (int)(w[4]); /* original vectorsize */
-
- int n=parent*up;
- t_sample *dummy = out;
-
- while(n--)*out++=0;
-
- n = parent;
- out = dummy;
- while(n--){
- *out=*in++;
- out+=up;
- }
-
- return (w+5);
-}
-
-t_int *upsampling_perform_hold(t_int *w)
-{
- t_sample *in = (t_sample *)(w[1]); /* original signal */
- t_sample *out = (t_sample *)(w[2]); /* upsampled signal */
- int up = (int)(w[3]); /* upsampling factor */
- int parent = (int)(w[4]); /* original vectorsize */
- int i=up;
-
- int n=parent;
- t_sample *dum_out = out;
- t_sample *dum_in = in;
-
- while (i--) {
- n = parent;
- out = dum_out+i;
- in = dum_in;
- while(n--){
- *out=*in++;
- out+=up;
- }
- }
- return (w+5);
-}
-
-t_int *upsampling_perform_linear(t_int *w)
-{
- t_resample *x= (t_resample *)(w[1]);
- t_sample *in = (t_sample *)(w[2]); /* original signal */
- t_sample *out = (t_sample *)(w[3]); /* upsampled signal */
- int up = (int)(w[4]); /* upsampling factor */
- int parent = (int)(w[5]); /* original vectorsize */
- int length = parent*up;
- int n;
- t_sample *fp;
- t_sample a=*x->buffer, b=*in;
-
-
- for (n=0; n<length; n++) {
- t_float findex = (t_float)(n+1)/up;
- int index = findex;
- t_sample frac=findex - index;
- if (frac==0.)frac=1.;
- *out++ = frac * b + (1.-frac) * a;
- fp = in+index;
- b=*fp;
- a=(index)?*(fp-1):a;
- }
-
- *x->buffer = a;
- return (w+6);
-}
-
-/* ----------------------- public -------------------------------- */
-
-/* utils */
-
-void resample_init(t_resample *x)
-{
- x->method=0;
-
- x->downsample=x->upsample=1;
-
- x->s_n = x->coefsize = x->bufsize = 0;
- x->s_vec = x->coeffs = x->buffer = 0;
-}
-
-void resample_free(t_resample *x)
-{
- if (x->s_n) t_freebytes(x->s_vec, x->s_n*sizeof(*x->s_vec));
- if (x->coefsize) t_freebytes(x->coeffs, x->coefsize*sizeof(*x->coeffs));
- if (x->bufsize) t_freebytes(x->buffer, x->bufsize*sizeof(*x->buffer));
-
- x->s_n = x->coefsize = x->bufsize = 0;
- x->s_vec = x->coeffs = x->buffer = 0;
-}
-
-
-/* dsp-adding */
-
-void resample_dsp(t_resample *x,
- t_sample* in, int insize,
- t_sample* out, int outsize,
- int method)
-{
- if (insize == outsize){
- bug("nothing to be done");
- return;
- }
-
- if (insize > outsize) { /* downsampling */
- if (insize % outsize) {
- error("bad downsampling factor");
- return;
- }
- switch (method) {
- default:
- dsp_add(downsampling_perform_0, 4, in, out, insize/outsize, insize);
- }
-
-
- } else { /* upsampling */
- if (outsize % insize) {
- error("bad upsampling factor");
- return;
- }
- switch (method) {
- case 1:
- dsp_add(upsampling_perform_hold, 4, in, out, outsize/insize, insize);
- break;
- case 2:
- if (x->bufsize != 1) {
- t_freebytes(x->buffer, x->bufsize*sizeof(*x->buffer));
- x->bufsize = 1;
- x->buffer = t_getbytes(x->bufsize*sizeof(*x->buffer));
- }
- dsp_add(upsampling_perform_linear, 5, x, in, out, outsize/insize, insize);
- break;
- default:
- dsp_add(upsampling_perform_0, 4, in, out, outsize/insize, insize);
- }
- }
-}
-
-void resamplefrom_dsp(t_resample *x,
- t_sample *in,
- int insize, int outsize, int method)
-{
- if (insize==outsize) {
- t_freebytes(x->s_vec, x->s_n * sizeof(*x->s_vec));
- x->s_n = 0;
- x->s_vec = in;
- return;
- }
-
- if (x->s_n != outsize) {
- t_sample *buf=x->s_vec;
- t_freebytes(buf, x->s_n * sizeof(*buf));
- buf = (t_sample *)t_getbytes(outsize * sizeof(*buf));
- x->s_vec = buf;
- x->s_n = outsize;
- }
-
- resample_dsp(x, in, insize, x->s_vec, x->s_n, method);
- return;
-}
-
-void resampleto_dsp(t_resample *x,
- t_sample *out,
- int insize, int outsize, int method)
-{
- if (insize==outsize) {
- if (x->s_n)t_freebytes(x->s_vec, x->s_n * sizeof(*x->s_vec));
- x->s_n = 0;
- x->s_vec = out;
- return;
- }
-
- if (x->s_n != insize) {
- t_sample *buf=x->s_vec;
- t_freebytes(buf, x->s_n * sizeof(*buf));
- buf = (t_sample *)t_getbytes(insize * sizeof(*buf));
- x->s_vec = buf;
- x->s_n = insize;
- }
- resample_dsp(x, x->s_vec, x->s_n, out, outsize, method);
-
- return;
-}
diff --git a/apps/plugins/pdbox/PDa/src/d_soundfile.c b/apps/plugins/pdbox/PDa/src/d_soundfile.c
index 872a44a923..4b89e93fd4 100644
--- a/apps/plugins/pdbox/PDa/src/d_soundfile.c
+++ b/apps/plugins/pdbox/PDa/src/d_soundfile.c
@@ -2365,2370 +2365,3 @@ void d_soundfile_setup(void)
#endif
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* this file contains, first, a collection of soundfile access routines, a
-sort of soundfile library. Second, the "soundfiler" object is defined which
-uses the routines to read or write soundfiles, synchronously, from garrays.
-These operations are not to be done in "real time" as they may have to wait
-for disk accesses (even the write routine.) Finally, the realtime objects
-readsf~ and writesf~ are defined which confine disk operations to a separate
-thread so that they can be used in real time. The readsf~ and writesf~
-objects use Posix-like threads. */
-
-#ifdef UNIX
-#include <unistd.h>
-#include <fcntl.h>
-#endif
-#include <pthread.h>
-#ifdef MSW
-#include <io.h>
-#endif
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include "m_pd.h"
-
-#define MAXSFCHANS 64
-
-/***************** soundfile header structures ************************/
-
-typedef unsigned short uint16;
-typedef unsigned long uint32;
-
-#define FORMAT_WAVE 0
-#define FORMAT_AIFF 1
-#define FORMAT_NEXT 2
-
-/* the NeXTStep sound header structure; can be big or little endian */
-
-typedef struct _nextstep
-{
- char ns_fileid[4]; /* magic number '.snd' if file is big-endian */
- uint32 ns_onset; /* byte offset of first sample */
- uint32 ns_length; /* length of sound in bytes */
- uint32 ns_format; /* format; see below */
- uint32 ns_sr; /* sample rate */
- uint32 ns_nchans; /* number of channels */
- char ns_info[4]; /* comment */
-} t_nextstep;
-
-#define NS_FORMAT_LINEAR_16 3
-#define NS_FORMAT_LINEAR_24 4
-#define NS_FORMAT_FLOAT 6
-#define SCALE (1./(1024. * 1024. * 1024. * 2.))
-
-/* the WAVE header. All Wave files are little endian. We assume
- the "fmt" chunk comes first which is usually the case but perhaps not
- always; same for AIFF and the "COMM" chunk. */
-
-typedef unsigned word;
-typedef unsigned long dword;
-
-typedef struct _wave
-{
- char w_fileid[4]; /* chunk id 'RIFF' */
- uint32 w_chunksize; /* chunk size */
- char w_waveid[4]; /* wave chunk id 'WAVE' */
- char w_fmtid[4]; /* format chunk id 'fmt ' */
- uint32 w_fmtchunksize; /* format chunk size */
- uint16 w_fmttag; /* format tag (WAV_INT etc) */
- uint16 w_nchannels; /* number of channels */
- uint32 w_samplespersec; /* sample rate in hz */
- uint32 w_navgbytespersec; /* average bytes per second */
- uint16 w_nblockalign; /* number of bytes per frame */
- uint16 w_nbitspersample; /* number of bits in a sample */
- char w_datachunkid[4]; /* data chunk id 'data' */
- uint32 w_datachunksize; /* length of data chunk */
-} t_wave;
-
-typedef struct _fmt /* format chunk */
-{
- uint16 f_fmttag; /* format tag, 1 for PCM */
- uint16 f_nchannels; /* number of channels */
- uint32 f_samplespersec; /* sample rate in hz */
- uint32 f_navgbytespersec; /* average bytes per second */
- uint16 f_nblockalign; /* number of bytes per frame */
- uint16 f_nbitspersample; /* number of bits in a sample */
-} t_fmt;
-
-typedef struct _wavechunk /* ... and the last two items */
-{
- char wc_id[4]; /* data chunk id, e.g., 'data' or 'fmt ' */
- uint32 wc_size; /* length of data chunk */
-} t_wavechunk;
-
-#define WAV_INT 1
-#define WAV_FLOAT 3
-
-/* the AIFF header. I'm assuming AIFC is compatible but don't really know
- that. */
-
-typedef struct _datachunk
-{
- char dc_id[4]; /* data chunk id 'SSND' */
- uint32 dc_size; /* length of data chunk */
-} t_datachunk;
-
-typedef struct _comm
-{
- uint16 c_nchannels; /* number of channels */
- uint16 c_nframeshi; /* # of sample frames (hi) */
- uint16 c_nframeslo; /* # of sample frames (lo) */
- uint16 c_bitspersamp; /* bits per sample */
- unsigned char c_samprate[10]; /* sample rate, 80-bit float! */
-} t_comm;
-
- /* this version is more convenient for writing them out: */
-typedef struct _aiff
-{
- char a_fileid[4]; /* chunk id 'FORM' */
- uint32 a_chunksize; /* chunk size */
- char a_aiffid[4]; /* aiff chunk id 'AIFF' */
- char a_fmtid[4]; /* format chunk id 'COMM' */
- uint32 a_fmtchunksize; /* format chunk size, 18 */
- uint16 a_nchannels; /* number of channels */
- uint16 a_nframeshi; /* # of sample frames (hi) */
- uint16 a_nframeslo; /* # of sample frames (lo) */
- uint16 a_bitspersamp; /* bits per sample */
- unsigned char a_samprate[10]; /* sample rate, 80-bit float! */
-} t_aiff;
-
-#define AIFFHDRSIZE 38 /* probably not what sizeof() gives */
-
-
-#define AIFFPLUS (AIFFHDRSIZE + 8) /* header size including first chunk hdr */
-
-#define WHDR1 sizeof(t_nextstep)
-#define WHDR2 (sizeof(t_wave) > WHDR1 ? sizeof (t_wave) : WHDR1)
-#define WRITEHDRSIZE (AIFFPLUS > WHDR2 ? AIFFPLUS : WHDR2)
-
-#define READHDRSIZE (16 > WHDR2 + 2 ? 16 : WHDR2 + 2)
-
-#define OBUFSIZE MAXPDSTRING /* assume MAXPDSTRING is bigger than headers */
-
-#ifdef MSW
-#include <fcntl.h>
-#define BINCREATE _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY
-#else
-#define BINCREATE O_WRONLY | O_CREAT | O_TRUNC
-#endif
-
-/* this routine returns 1 if the high order byte comes at the lower
-address on our architecture (big-endianness.). It's 1 for Motorola,
-0 for Intel: */
-
-extern int garray_ambigendian(void);
-
-/* byte swappers */
-
-static uint32 swap4(uint32 n, int doit)
-{
- if (doit)
- return (((n & 0xff) << 24) | ((n & 0xff00) << 8) |
- ((n & 0xff0000) >> 8) | ((n & 0xff000000) >> 24));
- else return (n);
-}
-
-static uint16 swap2(uint32 n, int doit)
-{
- if (doit)
- return (((n & 0xff) << 8) | ((n & 0xff00) >> 8));
- else return (n);
-}
-
-static void swapstring(char *foo, int doit)
-{
- if (doit)
- {
- char a = foo[0], b = foo[1], c = foo[2], d = foo[3];
- foo[0] = d; foo[1] = c; foo[2] = b; foo[3] = a;
- }
-}
-
-/******************** soundfile access routines **********************/
-
-/* This routine opens a file, looks for either a nextstep or "wave" header,
-* seeks to end of it, and fills in bytes per sample and number of channels.
-* Only 2- and 3-byte fixed-point samples and 4-byte floating point samples
-* are supported. If "headersize" is nonzero, the
-* caller should supply the number of channels, endinanness, and bytes per
-* sample; the header is ignored. Otherwise, the routine tries to read the
-* header and fill in the properties.
-*/
-
-int open_soundfile(const char *dirname, const char *filename, int headersize,
- int *p_bytespersamp, int *p_bigendian, int *p_nchannels, long *p_bytelimit,
- long skipframes)
-{
- char buf[OBUFSIZE], *bufptr;
- int fd, format, nchannels, bigendian, bytespersamp, swap, sysrtn;
- long bytelimit = 0x7fffffff;
- errno = 0;
- fd = open_via_path(dirname, filename,
- "", buf, &bufptr, MAXPDSTRING, 1);
- if (fd < 0)
- return (-1);
- if (headersize >= 0) /* header detection overridden */
- {
- bigendian = *p_bigendian;
- nchannels = *p_nchannels;
- bytespersamp = *p_bytespersamp;
- bytelimit = *p_bytelimit;
- }
- else
- {
- int bytesread = read(fd, buf, READHDRSIZE);
- int format;
- if (bytesread < 4)
- goto badheader;
- if (!strncmp(buf, ".snd", 4))
- format = FORMAT_NEXT, bigendian = 1;
- else if (!strncmp(buf, "dns.", 4))
- format = FORMAT_NEXT, bigendian = 0;
- else if (!strncmp(buf, "RIFF", 4))
- {
- if (bytesread < 12 || strncmp(buf + 8, "WAVE", 4))
- goto badheader;
- format = FORMAT_WAVE, bigendian = 0;
- }
- else if (!strncmp(buf, "FORM", 4))
- {
- if (bytesread < 12 || strncmp(buf + 8, "AIFF", 4))
- goto badheader;
- format = FORMAT_AIFF, bigendian = 1;
- }
- else
- goto badheader;
- swap = (bigendian != garray_ambigendian());
- if (format == FORMAT_NEXT) /* nextstep header */
- {
- uint32 param;
- if (bytesread < (int)sizeof(t_nextstep))
- goto badheader;
- nchannels = swap4(((t_nextstep *)buf)->ns_nchans, swap);
- format = swap4(((t_nextstep *)buf)->ns_format, swap);
- headersize = swap4(((t_nextstep *)buf)->ns_onset, swap);
- if (format == NS_FORMAT_LINEAR_16)
- bytespersamp = 2;
- else if (format == NS_FORMAT_LINEAR_24)
- bytespersamp = 3;
- else if (format == NS_FORMAT_FLOAT)
- bytespersamp = 4;
- else goto badheader;
- bytelimit = 0x7fffffff;
- }
- else if (format == FORMAT_WAVE) /* wave header */
- {
- /* This is awful. You have to skip over chunks,
- except that if one happens to be a "fmt" chunk, you want to
- find out the format from that one. The case where the
- "fmt" chunk comes after the audio isn't handled. */
- headersize = 12;
- if (bytesread < 20)
- goto badheader;
- /* First we guess a number of channels, etc., in case there's
- no "fmt" chunk to follow. */
- nchannels = 1;
- bytespersamp = 2;
- /* copy the first chunk header to beginnning of buffer. */
- memcpy(buf, buf + headersize, sizeof(t_wavechunk));
- /* post("chunk %c %c %c %c",
- ((t_wavechunk *)buf)->wc_id[0],
- ((t_wavechunk *)buf)->wc_id[1],
- ((t_wavechunk *)buf)->wc_id[2],
- ((t_wavechunk *)buf)->wc_id[3]); */
- /* read chunks in loop until we get to the data chunk */
- while (strncmp(((t_wavechunk *)buf)->wc_id, "data", 4))
- {
- long chunksize = swap4(((t_wavechunk *)buf)->wc_size,
- swap), seekto = headersize + chunksize + 8, seekout;
-
- if (!strncmp(((t_wavechunk *)buf)->wc_id, "fmt ", 4))
- {
- long commblockonset = headersize + 8;
- seekout = lseek(fd, commblockonset, SEEK_SET);
- if (seekout != commblockonset)
- goto badheader;
- if (read(fd, buf, sizeof(t_fmt)) < (int) sizeof(t_fmt))
- goto badheader;
- nchannels = swap2(((t_fmt *)buf)->f_nchannels, swap);
- format = swap2(((t_fmt *)buf)->f_nbitspersample, swap);
- if (format == 16)
- bytespersamp = 2;
- else if (format == 24)
- bytespersamp = 3;
- else if (format == 32)
- bytespersamp = 4;
- else goto badheader;
- }
- seekout = lseek(fd, seekto, SEEK_SET);
- if (seekout != seekto)
- goto badheader;
- if (read(fd, buf, sizeof(t_wavechunk)) <
- (int) sizeof(t_wavechunk))
- goto badheader;
- /* post("new chunk %c %c %c %c at %d",
- ((t_wavechunk *)buf)->wc_id[0],
- ((t_wavechunk *)buf)->wc_id[1],
- ((t_wavechunk *)buf)->wc_id[2],
- ((t_wavechunk *)buf)->wc_id[3], seekto); */
- headersize = seekto;
- }
- bytelimit = swap4(((t_wavechunk *)buf)->wc_size, swap);
- headersize += 8;
- }
- else
- {
- /* AIFF. same as WAVE; actually predates it. Disgusting. */
- headersize = 12;
- if (bytesread < 20)
- goto badheader;
- /* First we guess a number of channels, etc., in case there's
- no COMM block to follow. */
- nchannels = 1;
- bytespersamp = 2;
- /* copy the first chunk header to beginnning of buffer. */
- memcpy(buf, buf + headersize, sizeof(t_datachunk));
- /* read chunks in loop until we get to the data chunk */
- while (strncmp(((t_datachunk *)buf)->dc_id, "SSND", 4))
- {
- long chunksize = swap4(((t_datachunk *)buf)->dc_size,
- swap), seekto = headersize + chunksize + 8, seekout;
- /* post("chunk %c %c %c %c seek %d",
- ((t_datachunk *)buf)->dc_id[0],
- ((t_datachunk *)buf)->dc_id[1],
- ((t_datachunk *)buf)->dc_id[2],
- ((t_datachunk *)buf)->dc_id[3], seekto); */
- if (!strncmp(((t_datachunk *)buf)->dc_id, "COMM", 4))
- {
- long commblockonset = headersize + 8;
- seekout = lseek(fd, commblockonset, SEEK_SET);
- if (seekout != commblockonset)
- goto badheader;
- if (read(fd, buf, sizeof(t_comm)) <
- (int) sizeof(t_comm))
- goto badheader;
- nchannels = swap2(((t_comm *)buf)->c_nchannels, swap);
- format = swap2(((t_comm *)buf)->c_bitspersamp, swap);
- if (format == 16)
- bytespersamp = 2;
- else if (format == 24)
- bytespersamp = 3;
- else goto badheader;
- }
- seekout = lseek(fd, seekto, SEEK_SET);
- if (seekout != seekto)
- goto badheader;
- if (read(fd, buf, sizeof(t_datachunk)) <
- (int) sizeof(t_datachunk))
- goto badheader;
- headersize = seekto;
- }
- bytelimit = swap4(((t_datachunk *)buf)->dc_size, swap);
- headersize += 8;
- }
- }
- /* seek past header and any sample frames to skip */
- sysrtn = lseek(fd, nchannels * bytespersamp * skipframes + headersize, 0);
- if (sysrtn != nchannels * bytespersamp * skipframes + headersize)
- return (-1);
- bytelimit -= nchannels * bytespersamp * skipframes;
- if (bytelimit < 0)
- bytelimit = 0;
- /* copy sample format back to caller */
- *p_bigendian = bigendian;
- *p_nchannels = nchannels;
- *p_bytespersamp = bytespersamp;
- *p_bytelimit = bytelimit;
- return (fd);
-badheader:
- /* the header wasn't recognized. We're threadable here so let's not
- print out the error... */
- errno = EIO;
- return (-1);
-}
-
-static void soundfile_xferin(int sfchannels, int nvecs, t_sample **vecs,
- long itemsread, unsigned char *buf, int nitems, int bytespersamp,
- int bigendian)
-{
- int i, j;
- unsigned char *sp, *sp2;
- t_sample *fp;
- int nchannels = (sfchannels < nvecs ? sfchannels : nvecs);
- int bytesperframe = bytespersamp * sfchannels;
- for (i = 0, sp = buf; i < nchannels; i++, sp += bytespersamp)
- {
- if (bytespersamp == 2)
- {
- if (bigendian)
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + itemsread;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- *fp = SCALE * ((sp2[0] << 24) | (sp2[1] << 16));
- }
- else
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + itemsread;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- *fp = ((short*)sp2)[0]<<(fix1-16);
- }
- }
- else if (bytespersamp == 3)
- {
- if (bigendian)
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + itemsread;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- *fp = SCALE * ((sp2[0] << 24) | (sp2[1] << 16)
- | (sp2[2] << 8));
- }
- else
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + itemsread;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- *fp = SCALE * ((sp2[2] << 24) | (sp2[1] << 16)
- | (sp2[0] << 8));
- }
- }
- else if (bytespersamp == 4)
- {
- if (bigendian)
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + itemsread;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- *(long *)fp = ((sp2[0] << 24) | (sp2[1] << 16)
- | (sp2[2] << 8) | sp2[3]);
- }
- else
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + itemsread;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- *(long *)fp = ((sp2[3] << 24) | (sp2[2] << 16)
- | (sp2[1] << 8) | sp2[0]);
- }
- }
- }
- /* zero out other outputs */
- for (i = sfchannels; i < nvecs; i++)
- for (j = nitems, fp = vecs[i]; j--; )
- *fp++ = 0;
-
-}
-
- /* soundfiler_write ...
-
- usage: write [flags] filename table ...
- flags:
- -nframes <frames>
- -skip <frames>
- -bytes <bytes per sample>
- -normalize
- -nextstep
- -wave
- -big
- -little
- */
-
- /* the routine which actually does the work should LATER also be called
- from garray_write16. */
-
-
- /* Parse arguments for writing. The "obj" argument is only for flagging
- errors. For streaming to a file the "normalize", "onset" and "nframes"
- arguments shouldn't be set but the calling routine flags this. */
-
-static int soundfiler_writeargparse(void *obj, int *p_argc, t_atom **p_argv,
- t_symbol **p_filesym,
- int *p_filetype, int *p_bytespersamp, int *p_swap, int *p_bigendian,
- int *p_normalize, long *p_onset, long *p_nframes, float *p_rate)
-{
- int argc = *p_argc;
- t_atom *argv = *p_argv;
- int bytespersamp = 2, bigendian = 0,
- endianness = -1, swap, filetype = -1, normalize = 0;
- long onset = 0, nframes = 0x7fffffff;
- t_symbol *filesym;
- float rate = -1;
-
- while (argc > 0 && argv->a_type == A_SYMBOL &&
- *argv->a_w.w_symbol->s_name == '-')
- {
- char *flag = argv->a_w.w_symbol->s_name + 1;
- if (!strcmp(flag, "skip"))
- {
- if (argc < 2 || argv[1].a_type != A_FLOAT ||
- ((onset = argv[1].a_w.w_float) < 0))
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(flag, "nframes"))
- {
- if (argc < 2 || argv[1].a_type != A_FLOAT ||
- ((nframes = argv[1].a_w.w_float) < 0))
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(flag, "bytes"))
- {
- if (argc < 2 || argv[1].a_type != A_FLOAT ||
- ((bytespersamp = argv[1].a_w.w_float) < 2) ||
- bytespersamp > 4)
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(flag, "normalize"))
- {
- normalize = 1;
- argc -= 1; argv += 1;
- }
- else if (!strcmp(flag, "wave"))
- {
- filetype = FORMAT_WAVE;
- argc -= 1; argv += 1;
- }
- else if (!strcmp(flag, "nextstep"))
- {
- filetype = FORMAT_NEXT;
- argc -= 1; argv += 1;
- }
- else if (!strcmp(flag, "aiff"))
- {
- filetype = FORMAT_AIFF;
- argc -= 1; argv += 1;
- }
- else if (!strcmp(flag, "big"))
- {
- endianness = 1;
- argc -= 1; argv += 1;
- }
- else if (!strcmp(flag, "little"))
- {
- endianness = 0;
- argc -= 1; argv += 1;
- }
- else if (!strcmp(flag, "r") || !strcmp(flag, "rate"))
- {
- if (argc < 2 || argv[1].a_type != A_FLOAT ||
- ((rate = argv[1].a_w.w_float) <= 0))
- goto usage;
- argc -= 2; argv += 2;
- }
- else goto usage;
- }
- if (!argc || argv->a_type != A_SYMBOL)
- goto usage;
- filesym = argv->a_w.w_symbol;
-
- /* check if format not specified and fill in */
- if (filetype < 0)
- {
- if (strlen(filesym->s_name) >= 5 &&
- (!strcmp(filesym->s_name + strlen(filesym->s_name) - 4, ".aif") ||
- !strcmp(filesym->s_name + strlen(filesym->s_name) - 4, ".AIF")))
- filetype = FORMAT_AIFF;
- if (strlen(filesym->s_name) >= 6 &&
- (!strcmp(filesym->s_name + strlen(filesym->s_name) - 5, ".aiff") ||
- !strcmp(filesym->s_name + strlen(filesym->s_name) - 5, ".AIFF")))
- filetype = FORMAT_AIFF;
- if (strlen(filesym->s_name) >= 5 &&
- (!strcmp(filesym->s_name + strlen(filesym->s_name) - 4, ".snd") ||
- !strcmp(filesym->s_name + strlen(filesym->s_name) - 4, ".SND")))
- filetype = FORMAT_NEXT;
- if (strlen(filesym->s_name) >= 4 &&
- (!strcmp(filesym->s_name + strlen(filesym->s_name) - 3, ".au") ||
- !strcmp(filesym->s_name + strlen(filesym->s_name) - 3, ".AU")))
- filetype = FORMAT_NEXT;
- if (filetype < 0)
- filetype = FORMAT_WAVE;
- }
- /* don't handle AIFF floating point samples */
- if (bytespersamp == 4)
- {
- if (filetype == FORMAT_AIFF)
- {
- pd_error(obj, "AIFF floating-point file format unavailable");
- goto usage;
- }
- }
- /* for WAVE force little endian; for nextstep use machine native */
- if (filetype == FORMAT_WAVE)
- {
- bigendian = 0;
- if (endianness == 1)
- pd_error(obj, "WAVE file forced to little endian");
- }
- else if (filetype == FORMAT_AIFF)
- {
- bigendian = 1;
- if (endianness == 0)
- pd_error(obj, "AIFF file forced to big endian");
- }
- else if (endianness == -1)
- {
- bigendian = garray_ambigendian();
- }
- else bigendian = endianness;
- swap = (bigendian != garray_ambigendian());
-
- argc--; argv++;
-
- *p_argc = argc;
- *p_argv = argv;
- *p_filesym = filesym;
- *p_filetype = filetype;
- *p_bytespersamp = bytespersamp;
- *p_swap = swap;
- *p_normalize = normalize;
- *p_onset = onset;
- *p_nframes = nframes;
- *p_bigendian = bigendian;
- *p_rate = rate;
- return (0);
-usage:
- return (-1);
-}
-
-static int create_soundfile(t_canvas *canvas, const char *filename,
- int filetype, int nframes, int bytespersamp,
- int bigendian, int nchannels, int swap, float samplerate)
-{
- char filenamebuf[MAXPDSTRING], buf2[MAXPDSTRING];
- char headerbuf[WRITEHDRSIZE];
- t_wave *wavehdr = (t_wave *)headerbuf;
- t_nextstep *nexthdr = (t_nextstep *)headerbuf;
- t_aiff *aiffhdr = (t_aiff *)headerbuf;
- int fd, headersize = 0;
-
- strncpy(filenamebuf, filename, MAXPDSTRING-10);
- filenamebuf[MAXPDSTRING-10] = 0;
-
- if (filetype == FORMAT_NEXT)
- {
- if (strcmp(filenamebuf + strlen(filenamebuf)-4, ".snd"))
- strcat(filenamebuf, ".snd");
- if (bigendian)
- strncpy(nexthdr->ns_fileid, ".snd", 4);
- else strncpy(nexthdr->ns_fileid, "dns.", 4);
- nexthdr->ns_onset = swap4(sizeof(*nexthdr), swap);
- nexthdr->ns_length = 0;
- nexthdr->ns_format = swap4((bytespersamp == 3 ? NS_FORMAT_LINEAR_24 :
- (bytespersamp == 4 ? NS_FORMAT_FLOAT : NS_FORMAT_LINEAR_16)), swap);
- nexthdr->ns_sr = swap4(samplerate, swap);
- nexthdr->ns_nchans = swap4(nchannels, swap);
- strcpy(nexthdr->ns_info, "Pd ");
- swapstring(nexthdr->ns_info, swap);
- headersize = sizeof(t_nextstep);
- }
- else if (filetype == FORMAT_AIFF)
- {
- long datasize = nframes * nchannels * bytespersamp;
- long longtmp;
- static unsigned char dogdoo[] =
- {0x40, 0x0e, 0xac, 0x44, 0, 0, 0, 0, 0, 0, 'S', 'S', 'N', 'D'};
- if (strcmp(filenamebuf + strlen(filenamebuf)-4, ".aif") &&
- strcmp(filenamebuf + strlen(filenamebuf)-5, ".aiff"))
- strcat(filenamebuf, ".aif");
- strncpy(aiffhdr->a_fileid, "FORM", 4);
- aiffhdr->a_chunksize = swap4(datasize + sizeof(*aiffhdr) + 4, swap);
- strncpy(aiffhdr->a_aiffid, "AIFF", 4);
- strncpy(aiffhdr->a_fmtid, "COMM", 4);
- aiffhdr->a_fmtchunksize = swap4(18, swap);
- aiffhdr->a_nchannels = swap2(nchannels, swap);
- longtmp = swap4(nframes, swap);
- memcpy(&aiffhdr->a_nframeshi, &longtmp, 4);
- aiffhdr->a_bitspersamp = swap2(8 * bytespersamp, swap);
- memcpy(aiffhdr->a_samprate, dogdoo, sizeof(dogdoo));
- longtmp = swap4(datasize, swap);
- memcpy(aiffhdr->a_samprate + sizeof(dogdoo), &longtmp, 4);
- headersize = AIFFPLUS;
- }
- else /* WAVE format */
- {
- long datasize = nframes * nchannels * bytespersamp;
- if (strcmp(filenamebuf + strlen(filenamebuf)-4, ".wav"))
- strcat(filenamebuf, ".wav");
- strncpy(wavehdr->w_fileid, "RIFF", 4);
- wavehdr->w_chunksize = swap4(datasize + sizeof(*wavehdr) - 8, swap);
- strncpy(wavehdr->w_waveid, "WAVE", 4);
- strncpy(wavehdr->w_fmtid, "fmt ", 4);
- wavehdr->w_fmtchunksize = swap4(16, swap);
- wavehdr->w_fmttag =
- swap2((bytespersamp == 4 ? WAV_FLOAT : WAV_INT), swap);
- wavehdr->w_nchannels = swap2(nchannels, swap);
- wavehdr->w_samplespersec = swap4(samplerate, swap);
- wavehdr->w_navgbytespersec =
- swap4((int)(samplerate * nchannels * bytespersamp), swap);
- wavehdr->w_nblockalign = swap2(nchannels * bytespersamp, swap);
- wavehdr->w_nbitspersample = swap2(8 * bytespersamp, swap);
- strncpy(wavehdr->w_datachunkid, "data", 4);
- wavehdr->w_datachunksize = swap4(datasize, swap);
- headersize = sizeof(t_wave);
- }
-
- canvas_makefilename(canvas, filenamebuf, buf2, MAXPDSTRING);
- sys_bashfilename(buf2, buf2);
- if ((fd = open(buf2, BINCREATE, 0666)) < 0)
- return (-1);
-
- if (write(fd, headerbuf, headersize) < headersize)
- {
- close (fd);
- return (-1);
- }
- return (fd);
-}
-
-static void soundfile_finishwrite(void *obj, char *filename, int fd,
- int filetype, long nframes, long itemswritten, int bytesperframe, int swap)
-{
- if (itemswritten < nframes)
- {
- if (nframes < 0x7fffffff)
- pd_error(obj, "soundfiler_write: %d out of %d bytes written",
- itemswritten, nframes);
- /* try to fix size fields in header */
- if (filetype == FORMAT_WAVE)
- {
- long datasize = itemswritten * bytesperframe, mofo;
-
- if (lseek(fd,
- ((char *)(&((t_wave *)0)->w_chunksize)) - (char *)0,
- SEEK_SET) == 0)
- goto baddonewrite;
- mofo = swap4(datasize + sizeof(t_wave) - 8, swap);
- if (write(fd, (char *)(&mofo), 4) < 4)
- goto baddonewrite;
- if (lseek(fd,
- ((char *)(&((t_wave *)0)->w_datachunksize)) - (char *)0,
- SEEK_SET) == 0)
- goto baddonewrite;
- mofo = swap4(datasize, swap);
- if (write(fd, (char *)(&mofo), 4) < 4)
- goto baddonewrite;
- }
- if (filetype == FORMAT_AIFF)
- {
- long mofo;
- if (lseek(fd,
- ((char *)(&((t_aiff *)0)->a_nframeshi)) - (char *)0,
- SEEK_SET) == 0)
- goto baddonewrite;
- mofo = swap4(nframes, swap);
- if (write(fd, (char *)(&mofo), 4) < 4)
- goto baddonewrite;
- }
- if (filetype == FORMAT_NEXT)
- {
- /* do it the lazy way: just set the size field to 'unknown size'*/
- uint32 nextsize = 0xffffffff;
- if (lseek(fd, 8, SEEK_SET) == 0)
- {
- goto baddonewrite;
- }
- if (write(fd, &nextsize, 4) < 4)
- {
- goto baddonewrite;
- }
- }
- }
- return;
-baddonewrite:
- post("%s: %s", filename, strerror(errno));
-}
-
-static void soundfile_xferout(int nchannels, t_sample **vecs,
- unsigned char *buf, int nitems, long onset, int bytespersamp,
- int bigendian, float normalfactor)
-{
- int i, j;
- unsigned char *sp, *sp2;
- t_sample *fp;
- int bytesperframe = bytespersamp * nchannels;
- long xx;
- for (i = 0, sp = buf; i < nchannels; i++, sp += bytespersamp)
- {
- if (bytespersamp == 2)
- {
- float ff = normalfactor * 32768.;
- if (bigendian)
- {
- for (j = 0, sp2 = sp, fp = vecs[i] + onset;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- {
- int xx = 32768. + (*fp * ff);
- xx -= 32768;
- if (xx < -32767)
- xx = -32767;
- if (xx > 32767)
- xx = 32767;
- sp2[0] = (xx >> 8);
- sp2[1] = xx;
- }
- }
- else
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + onset;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- {
- int xx = 32768. + (*fp * ff);
- xx -= 32768;
- if (xx < -32767)
- xx = -32767;
- if (xx > 32767)
- xx = 32767;
- sp2[1] = (xx >> 8);
- sp2[0] = xx;
- }
- }
- }
- else if (bytespersamp == 3)
- {
- float ff = normalfactor * 8388608.;
- if (bigendian)
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + onset;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- {
- int xx = 8388608. + (*fp * ff);
- xx -= 8388608;
- if (xx < -8388607)
- xx = -8388607;
- if (xx > 8388607)
- xx = 8388607;
- sp2[0] = (xx >> 16);
- sp2[1] = (xx >> 8);
- sp2[2] = xx;
- }
- }
- else
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + onset;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- {
- int xx = 8388608. + (*fp * ff);
- xx -= 8388608;
- if (xx < -8388607)
- xx = -8388607;
- if (xx > 8388607)
- xx = 8388607;
- sp2[2] = (xx >> 16);
- sp2[1] = (xx >> 8);
- sp2[0] = xx;
- }
- }
- }
- else if (bytespersamp == 4)
- {
- if (bigendian)
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + onset;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- {
- float f2 = *fp * normalfactor;
- xx = *(long *)&f2;
- sp2[0] = (xx >> 24); sp2[1] = (xx >> 16);
- sp2[2] = (xx >> 8); sp2[3] = xx;
- }
- }
- else
- {
- for (j = 0, sp2 = sp, fp=vecs[i] + onset;
- j < nitems; j++, sp2 += bytesperframe, fp++)
- {
- float f2 = *fp * normalfactor;
- xx = *(long *)&f2;
- sp2[3] = (xx >> 24); sp2[2] = (xx >> 16);
- sp2[1] = (xx >> 8); sp2[0] = xx;
- }
- }
- }
- }
-}
-
-
-/* ------- soundfiler - reads and writes soundfiles to/from "garrays" ---- */
-#define DEFMAXSIZE 4000000 /* default maximum 16 MB per channel */
-#define SAMPBUFSIZE 1024
-
-
-static t_class *soundfiler_class;
-
-typedef struct _soundfiler
-{
- t_object x_obj;
- t_canvas *x_canvas;
-} t_soundfiler;
-
-static t_soundfiler *soundfiler_new(void)
-{
- t_soundfiler *x = (t_soundfiler *)pd_new(soundfiler_class);
- x->x_canvas = canvas_getcurrent();
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
- /* soundfiler_read ...
-
- usage: read [flags] filename table ...
- flags:
- -skip <frames> ... frames to skip in file
- -nframes <frames>
- -onset <frames> ... onset in table to read into (NOT DONE YET)
- -raw <headersize channels bytes endian>
- -resize
- -maxsize <max-size>
- */
-
-static void soundfiler_read(t_soundfiler *x, t_symbol *s,
- int argc, t_atom *argv)
-{
- int headersize = -1, channels = 0, bytespersamp = 0, bigendian = 0,
- resize = 0, i, j;
- long skipframes = 0, nframes = 0, finalsize = 0, itemsleft,
- maxsize = DEFMAXSIZE, itemsread = 0, bytelimit = 0x7fffffff;
- int fd = -1;
- char endianness, *filename;
- t_garray *garrays[MAXSFCHANS];
- t_sample *vecs[MAXSFCHANS];
- char sampbuf[SAMPBUFSIZE];
- int bufframes, nitems;
- FILE *fp;
- while (argc > 0 && argv->a_type == A_SYMBOL &&
- *argv->a_w.w_symbol->s_name == '-')
- {
- char *flag = argv->a_w.w_symbol->s_name + 1;
- if (!strcmp(flag, "skip"))
- {
- if (argc < 2 || argv[1].a_type != A_FLOAT ||
- ((skipframes = argv[1].a_w.w_float) < 0))
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(flag, "nframes"))
- {
- if (argc < 2 || argv[1].a_type != A_FLOAT ||
- ((nframes = argv[1].a_w.w_float) < 0))
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(flag, "raw"))
- {
- if (argc < 5 ||
- argv[1].a_type != A_FLOAT ||
- ((headersize = argv[1].a_w.w_float) < 0) ||
- argv[2].a_type != A_FLOAT ||
- ((channels = argv[2].a_w.w_float) < 1) ||
- (channels > MAXSFCHANS) ||
- argv[3].a_type != A_FLOAT ||
- ((bytespersamp = argv[3].a_w.w_float) < 2) ||
- (bytespersamp > 4) ||
- argv[4].a_type != A_SYMBOL ||
- ((endianness = argv[4].a_w.w_symbol->s_name[0]) != 'b'
- && endianness != 'l' && endianness != 'n'))
- goto usage;
- if (endianness == 'b')
- bigendian = 1;
- else if (endianness == 'l')
- bigendian = 0;
- else
- bigendian = garray_ambigendian();
- argc -= 5; argv += 5;
- }
- else if (!strcmp(flag, "resize"))
- {
- resize = 1;
- argc -= 1; argv += 1;
- }
- else if (!strcmp(flag, "maxsize"))
- {
- if (argc < 2 || argv[1].a_type != A_FLOAT ||
- ((maxsize = argv[1].a_w.w_float) < 0))
- goto usage;
- resize = 1; /* maxsize implies resize. */
- argc -= 2; argv += 2;
- }
- else goto usage;
- }
- if (argc < 2 || argc > MAXSFCHANS + 1 || argv[0].a_type != A_SYMBOL)
- goto usage;
- filename = argv[0].a_w.w_symbol->s_name;
- argc--; argv++;
-
- for (i = 0; i < argc; i++)
- {
- int vecsize;
- if (argv[i].a_type != A_SYMBOL)
- goto usage;
- if (!(garrays[i] =
- (t_garray *)pd_findbyclass(argv[i].a_w.w_symbol, garray_class)))
- {
- pd_error(x, "%s: no such table", argv[i].a_w.w_symbol->s_name);
- goto done;
- }
- else if (!garray_getfloatarray(garrays[i], &vecsize, &vecs[i]))
- error("%s: bad template for tabwrite",
- argv[i].a_w.w_symbol->s_name);
- if (finalsize && finalsize != vecsize && !resize)
- {
- post("soundfiler_read: arrays have different lengths; resizing...");
- resize = 1;
- }
- finalsize = vecsize;
- }
- fd = open_soundfile(canvas_getdir(x->x_canvas)->s_name, filename,
- headersize, &bytespersamp, &bigendian, &channels, &bytelimit,
- skipframes);
-
- if (fd < 0)
- {
- pd_error(x, "soundfiler_read: %s: %s", filename, (errno == EIO ?
- "unknown or bad header format" : strerror(errno)));
- goto done;
- }
-
- if (resize)
- {
- /* figure out what to resize to */
- long poswas, eofis, framesinfile;
-
- poswas = lseek(fd, 0, SEEK_CUR);
- eofis = lseek(fd, 0, SEEK_END);
- if (poswas < 0 || eofis < 0)
- {
- pd_error(x, "lseek failed");
- goto done;
- }
- lseek(fd, poswas, SEEK_SET);
- framesinfile = (eofis - poswas) / (channels * bytespersamp);
- if (framesinfile > maxsize)
- {
- pd_error(x, "soundfiler_read: truncated to %d elements", maxsize);
- framesinfile = maxsize;
- }
- if (framesinfile > bytelimit / (channels * bytespersamp))
- framesinfile = bytelimit / (channels * bytespersamp);
- finalsize = framesinfile;
- for (i = 0; i < argc; i++)
- {
- int vecsize;
-
- garray_resize(garrays[i], finalsize);
- /* for sanity's sake let's clear the save-in-patch flag here */
- garray_setsaveit(garrays[i], 0);
- garray_getfloatarray(garrays[i], &vecsize, &vecs[i]);
- /* if the resize failed, garray_resize reported the error */
- if (vecsize != framesinfile)
- {
- pd_error(x, "resize failed");
- goto done;
- }
- }
- }
- if (!finalsize) finalsize = 0x7fffffff;
- if (finalsize > bytelimit / (channels * bytespersamp))
- finalsize = bytelimit / (channels * bytespersamp);
- fp = fdopen(fd, "rb");
- bufframes = SAMPBUFSIZE / (channels * bytespersamp);
-
- for (itemsread = 0; itemsread < finalsize; )
- {
- int thisread = finalsize - itemsread;
- thisread = (thisread > bufframes ? bufframes : thisread);
- nitems = fread(sampbuf, channels * bytespersamp, thisread, fp);
- if (nitems <= 0) break;
- soundfile_xferin(channels, argc, vecs, itemsread,
- (unsigned char *)sampbuf, nitems, bytespersamp, bigendian);
- itemsread += nitems;
- }
- /* zero out remaining elements of vectors */
-
- for (i = 0; i < argc; i++)
- {
- int nzero, vecsize;
- garray_getfloatarray(garrays[i], &vecsize, &vecs[i]);
- for (j = itemsread; j < vecsize; j++)
- vecs[i][j] = 0;
- }
- /* zero out vectors in excess of number of channels */
- for (i = channels; i < argc; i++)
- {
- int vecsize;
- t_sample *foo;
- garray_getfloatarray(garrays[i], &vecsize, &foo);
- for (j = 0; j < vecsize; j++)
- foo[j] = 0;
- }
- /* do all graphics updates */
- for (i = 0; i < argc; i++)
- garray_redraw(garrays[i]);
- fclose(fp);
- fd = -1;
- goto done;
-usage:
- pd_error(x, "usage: read [flags] filename tablename...");
- post("flags: -skip <n> -nframes <n> -resize -maxsize <n> ...");
- post("-raw <headerbytes> <channels> <bytespersamp> <endian (b, l, or n)>.");
-done:
- if (fd >= 0)
- close (fd);
- outlet_float(x->x_obj.ob_outlet, (float)itemsread);
-}
-
- /* this is broken out from soundfiler_write below so garray_write can
- call it too... not done yet though. */
-
-long soundfiler_dowrite(void *obj, t_canvas *canvas,
- int argc, t_atom *argv)
-{
- int headersize, bytespersamp, bigendian,
- endianness, swap, filetype, normalize, i, j, nchannels;
- long onset, nframes, itemsleft,
- maxsize = DEFMAXSIZE, itemswritten = 0;
- t_garray *garrays[MAXSFCHANS];
- t_sample *vecs[MAXSFCHANS];
- char sampbuf[SAMPBUFSIZE];
- int bufframes, nitems;
- int fd = -1;
- float normfactor, biggest = 0, samplerate;
- t_symbol *filesym;
-
- if (soundfiler_writeargparse(obj, &argc, &argv, &filesym, &filetype,
- &bytespersamp, &swap, &bigendian, &normalize, &onset, &nframes,
- &samplerate))
- goto usage;
- nchannels = argc;
- if (nchannels < 1 || nchannels > MAXSFCHANS)
- goto usage;
- if (samplerate < 0)
- samplerate = sys_getsr();
- for (i = 0; i < nchannels; i++)
- {
- int vecsize;
- if (argv[i].a_type != A_SYMBOL)
- goto usage;
- if (!(garrays[i] =
- (t_garray *)pd_findbyclass(argv[i].a_w.w_symbol, garray_class)))
- {
- pd_error(obj, "%s: no such table", argv[i].a_w.w_symbol->s_name);
- goto fail;
- }
- else if (!garray_getfloatarray(garrays[i], &vecsize, &vecs[i]))
- error("%s: bad template for tabwrite",
- argv[i].a_w.w_symbol->s_name);
- if (nframes > vecsize - onset)
- nframes = vecsize - onset;
-
- for (j = 0; j < vecsize; j++)
- {
- if (vecs[i][j] > biggest)
- biggest = vecs[i][j];
- else if (-vecs[i][j] > biggest)
- biggest = -vecs[i][j];
- }
- }
- if (nframes <= 0)
- {
- pd_error(obj, "soundfiler_write: no samples at onset %ld", onset);
- goto fail;
- }
-
- if ((fd = create_soundfile(canvas, filesym->s_name, filetype,
- nframes, bytespersamp, bigendian, nchannels,
- swap, samplerate)) < 0)
- {
- post("%s: %s\n", filesym->s_name, strerror(errno));
- goto fail;
- }
- if (!normalize)
- {
- if ((bytespersamp != 4) && (biggest > 1))
- {
- post("%s: normalizing max amplitude %f to 1", filesym->s_name, biggest);
- normalize = 1;
- }
- else post("%s: biggest amplitude = %f", filesym->s_name, biggest);
- }
- if (normalize)
- normfactor = (biggest > 0 ? 32767./(32768. * biggest) : 1);
- else normfactor = 1;
-
- bufframes = SAMPBUFSIZE / (nchannels * bytespersamp);
-
- for (itemswritten = 0; itemswritten < nframes; )
- {
- int thiswrite = nframes - itemswritten, nitems, nbytes;
- thiswrite = (thiswrite > bufframes ? bufframes : thiswrite);
- soundfile_xferout(argc, vecs, (unsigned char *)sampbuf, thiswrite,
- onset, bytespersamp, bigendian, normfactor);
- nbytes = write(fd, sampbuf, nchannels * bytespersamp * thiswrite);
- if (nbytes < nchannels * bytespersamp * thiswrite)
- {
- post("%s: %s", filesym->s_name, strerror(errno));
- if (nbytes > 0)
- itemswritten += nbytes / (nchannels * bytespersamp);
- break;
- }
- itemswritten += thiswrite;
- onset += thiswrite;
- }
- if (fd >= 0)
- {
- soundfile_finishwrite(obj, filesym->s_name, fd,
- filetype, nframes, itemswritten, nchannels * bytespersamp, swap);
- close (fd);
- }
- return ((float)itemswritten);
-usage:
- pd_error(obj, "usage: write [flags] filename tablename...");
- post("flags: -skip <n> -nframes <n> -bytes <n> -wave -aiff -nextstep ...");
- post("-big -little -normalize");
- post("(defaults to a 16-bit wave file).");
-fail:
- if (fd >= 0)
- close (fd);
- return (0);
-}
-
-static void soundfiler_write(t_soundfiler *x, t_symbol *s,
- int argc, t_atom *argv)
-{
- long bozo = soundfiler_dowrite(x, x->x_canvas,
- argc, argv);
- outlet_float(x->x_obj.ob_outlet, (float)bozo);
-}
-
-static void soundfiler_setup(void)
-{
- soundfiler_class = class_new(gensym("soundfiler"), (t_newmethod)soundfiler_new,
- 0, sizeof(t_soundfiler), 0, 0);
- class_addmethod(soundfiler_class, (t_method)soundfiler_read, gensym("read"),
- A_GIMME, 0);
- class_addmethod(soundfiler_class, (t_method)soundfiler_write,
- gensym("write"), A_GIMME, 0);
-}
-
-
-#ifndef FIXEDPOINT
-/************************* readsf object ******************************/
-
-/* READSF uses the Posix threads package; for the moment we're Linux
-only although this should be portable to the other platforms.
-
-Each instance of readsf~ owns a "child" thread for doing the UNIX (MSW?) file
-reading. The parent thread signals the child each time:
- (1) a file wants opening or closing;
- (2) we've eaten another 1/16 of the shared buffer (so that the
- child thread should check if it's time to read some more.)
-The child signals the parent whenever a read has completed. Signalling
-is done by setting "conditions" and putting data in mutex-controlled common
-areas.
-*/
-
-#define MAXBYTESPERSAMPLE 4
-#define MAXVECSIZE 128
-
-#define READSIZE 65536
-#define WRITESIZE 65536
-#define DEFBUFPERCHAN 262144
-#define MINBUFSIZE (4 * READSIZE)
-#define MAXBUFSIZE 16777216 /* arbitrary; just don't want to hang malloc */
-
-#define REQUEST_NOTHING 0
-#define REQUEST_OPEN 1
-#define REQUEST_CLOSE 2
-#define REQUEST_QUIT 3
-#define REQUEST_BUSY 4
-
-#define STATE_IDLE 0
-#define STATE_STARTUP 1
-#define STATE_STREAM 2
-
-static t_class *readsf_class;
-
-typedef struct _readsf
-{
- t_object x_obj;
- t_canvas *x_canvas;
- t_clock *x_clock;
- char *x_buf; /* soundfile buffer */
- int x_bufsize; /* buffer size in bytes */
- int x_noutlets; /* number of audio outlets */
- t_sample *(x_outvec[MAXSFCHANS]); /* audio vectors */
- int x_vecsize; /* vector size for transfers */
- t_outlet *x_bangout; /* bang-on-done outlet */
- int x_state; /* opened, running, or idle */
- float x_insamplerate; /* sample rate of input signal if known */
- /* parameters to communicate with subthread */
- int x_requestcode; /* pending request from parent to I/O thread */
- char *x_filename; /* file to open (string is permanently allocated) */
- int x_fileerror; /* slot for "errno" return */
- int x_skipheaderbytes; /* size of header we'll skip */
- int x_bytespersample; /* bytes per sample (2 or 3) */
- int x_bigendian; /* true if file is big-endian */
- int x_sfchannels; /* number of channels in soundfile */
- float x_samplerate; /* sample rate of soundfile */
- long x_onsetframes; /* number of sample frames to skip */
- long x_bytelimit; /* max number of data bytes to read */
- int x_fd; /* filedesc */
- int x_fifosize; /* buffer size appropriately rounded down */
- int x_fifohead; /* index of next byte to get from file */
- int x_fifotail; /* index of next byte the ugen will read */
- int x_eof; /* true if fifohead has stopped changing */
- int x_sigcountdown; /* counter for signalling child for more data */
- int x_sigperiod; /* number of ticks per signal */
- int x_filetype; /* writesf~ only; type of file to create */
- int x_itemswritten; /* writesf~ only; items writen */
- int x_swap; /* writesf~ only; true if byte swapping */
- float x_f; /* writesf~ only; scalar for signal inlet */
- pthread_mutex_t x_mutex;
- pthread_cond_t x_requestcondition;
- pthread_cond_t x_answercondition;
- pthread_t x_childthread;
-} t_readsf;
-
-
-/************** the child thread which performs file I/O ***********/
-
-#if 0
-static void pute(char *s) /* debug routine */
-{
- write(2, s, strlen(s));
-}
-#define DEBUG_SOUNDFILE
-#endif
-
-#if 1
-#define sfread_cond_wait pthread_cond_wait
-#define sfread_cond_signal pthread_cond_signal
-#else
-#include <sys/time.h> /* debugging version... */
-#include <sys/types.h>
-static void readsf_fakewait(pthread_mutex_t *b)
-{
- struct timeval timout;
- timout.tv_sec = 0;
- timout.tv_usec = 1000000;
- pthread_mutex_unlock(b);
- select(0, 0, 0, 0, &timout);
- pthread_mutex_lock(b);
-}
-
-#define sfread_cond_wait(a,b) readsf_fakewait(b)
-#define sfread_cond_signal(a)
-#endif
-
-static void *readsf_child_main(void *zz)
-{
- t_readsf *x = zz;
-#ifdef DEBUG_SOUNDFILE
- pute("1\n");
-#endif
- pthread_mutex_lock(&x->x_mutex);
- while (1)
- {
- int fd, fifohead;
- char *buf;
-#ifdef DEBUG_SOUNDFILE
- pute("0\n");
-#endif
- if (x->x_requestcode == REQUEST_NOTHING)
- {
-#ifdef DEBUG_SOUNDFILE
- pute("wait 2\n");
-#endif
- sfread_cond_signal(&x->x_answercondition);
- sfread_cond_wait(&x->x_requestcondition, &x->x_mutex);
-#ifdef DEBUG_SOUNDFILE
- pute("3\n");
-#endif
- }
- else if (x->x_requestcode == REQUEST_OPEN)
- {
- char boo[80];
- int sysrtn, wantbytes;
-
- /* copy file stuff out of the data structure so we can
- relinquish the mutex while we're in open_soundfile(). */
- long onsetframes = x->x_onsetframes;
- long bytelimit = 0x7fffffff;
- int skipheaderbytes = x->x_skipheaderbytes;
- int bytespersample = x->x_bytespersample;
- int sfchannels = x->x_sfchannels;
- int bigendian = x->x_bigendian;
- char *filename = x->x_filename;
- char *dirname = canvas_getdir(x->x_canvas)->s_name;
- /* alter the request code so that an ensuing "open" will get
- noticed. */
-#ifdef DEBUG_SOUNDFILE
- pute("4\n");
-#endif
- x->x_requestcode = REQUEST_BUSY;
- x->x_fileerror = 0;
-
- /* if there's already a file open, close it */
- if (x->x_fd >= 0)
- {
- fd = x->x_fd;
- pthread_mutex_unlock(&x->x_mutex);
- close (fd);
- pthread_mutex_lock(&x->x_mutex);
- x->x_fd = -1;
- if (x->x_requestcode != REQUEST_BUSY)
- goto lost;
- }
- /* open the soundfile with the mutex unlocked */
- pthread_mutex_unlock(&x->x_mutex);
- fd = open_soundfile(dirname, filename,
- skipheaderbytes, &bytespersample, &bigendian,
- &sfchannels, &bytelimit, onsetframes);
- pthread_mutex_lock(&x->x_mutex);
-
-#ifdef DEBUG_SOUNDFILE
- pute("5\n");
-#endif
- /* copy back into the instance structure. */
- x->x_bytespersample = bytespersample;
- x->x_sfchannels = sfchannels;
- x->x_bigendian = bigendian;
- x->x_fd = fd;
- x->x_bytelimit = bytelimit;
- if (fd < 0)
- {
- x->x_fileerror = errno;
- x->x_eof = 1;
-#ifdef DEBUG_SOUNDFILE
- pute("open failed\n");
- pute(filename);
- pute(dirname);
-#endif
- goto lost;
- }
- /* check if another request has been made; if so, field it */
- if (x->x_requestcode != REQUEST_BUSY)
- goto lost;
-#ifdef DEBUG_SOUNDFILE
- pute("6\n");
-#endif
- x->x_fifohead = 0;
- /* set fifosize from bufsize. fifosize must be a
- multiple of the number of bytes eaten for each DSP
- tick. We pessimistically assume MAXVECSIZE samples
- per tick since that could change. There could be a
- problem here if the vector size increases while a
- soundfile is being played... */
- x->x_fifosize = x->x_bufsize - (x->x_bufsize %
- (x->x_bytespersample * x->x_sfchannels * MAXVECSIZE));
- /* arrange for the "request" condition to be signalled 16
- times per buffer */
-#ifdef DEBUG_SOUNDFILE
- sprintf(boo, "fifosize %d\n",
- x->x_fifosize);
- pute(boo);
-#endif
- x->x_sigcountdown = x->x_sigperiod =
- (x->x_fifosize /
- (16 * x->x_bytespersample * x->x_sfchannels *
- x->x_vecsize));
- /* in a loop, wait for the fifo to get hungry and feed it */
-
- while (x->x_requestcode == REQUEST_BUSY)
- {
- int fifosize = x->x_fifosize;
-#ifdef DEBUG_SOUNDFILE
- pute("77\n");
-#endif
- if (x->x_eof)
- break;
- if (x->x_fifohead >= x->x_fifotail)
- {
- /* if the head is >= the tail, we can immediately read
- to the end of the fifo. Unless, that is, we would
- read all the way to the end of the buffer and the
- "tail" is zero; this would fill the buffer completely
- which isn't allowed because you can't tell a completely
- full buffer from an empty one. */
- if (x->x_fifotail || (fifosize - x->x_fifohead > READSIZE))
- {
- wantbytes = fifosize - x->x_fifohead;
- if (wantbytes > READSIZE)
- wantbytes = READSIZE;
- if (wantbytes > x->x_bytelimit)
- wantbytes = x->x_bytelimit;
-#ifdef DEBUG_SOUNDFILE
- sprintf(boo, "head %d, tail %d, size %d\n",
- x->x_fifohead, x->x_fifotail, wantbytes);
- pute(boo);
-#endif
- }
- else
- {
-#ifdef DEBUG_SOUNDFILE
- pute("wait 7a ...\n");
-#endif
- sfread_cond_signal(&x->x_answercondition);
-#ifdef DEBUG_SOUNDFILE
- pute("signalled\n");
-#endif
- sfread_cond_wait(&x->x_requestcondition,
- &x->x_mutex);
-#ifdef DEBUG_SOUNDFILE
- pute("7a done\n");
-#endif
- continue;
- }
- }
- else
- {
- /* otherwise check if there are at least READSIZE
- bytes to read. If not, wait and loop back. */
- wantbytes = x->x_fifotail - x->x_fifohead - 1;
- if (wantbytes < READSIZE)
- {
-#ifdef DEBUG_SOUNDFILE
- pute("wait 7...\n");
-#endif
- sfread_cond_signal(&x->x_answercondition);
- sfread_cond_wait(&x->x_requestcondition,
- &x->x_mutex);
-#ifdef DEBUG_SOUNDFILE
- pute("7 done\n");
-#endif
- continue;
- }
- else wantbytes = READSIZE;
- if (wantbytes > x->x_bytelimit)
- wantbytes = x->x_bytelimit;
- }
-#ifdef DEBUG_SOUNDFILE
- pute("8\n");
-#endif
- fd = x->x_fd;
- buf = x->x_buf;
- fifohead = x->x_fifohead;
- pthread_mutex_unlock(&x->x_mutex);
- sysrtn = read(fd, buf + fifohead, wantbytes);
- pthread_mutex_lock(&x->x_mutex);
- if (x->x_requestcode != REQUEST_BUSY)
- break;
- if (sysrtn < 0)
- {
-#ifdef DEBUG_SOUNDFILE
- pute("fileerror\n");
-#endif
- x->x_fileerror = errno;
- break;
- }
- else if (sysrtn == 0)
- {
- x->x_eof = 1;
- break;
- }
- else
- {
- x->x_fifohead += sysrtn;
- x->x_bytelimit -= sysrtn;
- if (x->x_bytelimit <= 0)
- {
- x->x_eof = 1;
- break;
- }
- if (x->x_fifohead == fifosize)
- x->x_fifohead = 0;
- }
-#ifdef DEBUG_SOUNDFILE
- sprintf(boo, "after: head %d, tail %d\n",
- x->x_fifohead, x->x_fifotail);
- pute(boo);
-#endif
- /* signal parent in case it's waiting for data */
- sfread_cond_signal(&x->x_answercondition);
- }
- lost:
-
- if (x->x_requestcode == REQUEST_BUSY)
- x->x_requestcode = REQUEST_NOTHING;
- /* fell out of read loop: close file if necessary,
- set EOF and signal once more */
- if (x->x_fd >= 0)
- {
- fd = x->x_fd;
- pthread_mutex_unlock(&x->x_mutex);
- close (fd);
- pthread_mutex_lock(&x->x_mutex);
- x->x_fd = -1;
- }
- sfread_cond_signal(&x->x_answercondition);
-
- }
- else if (x->x_requestcode == REQUEST_CLOSE)
- {
- if (x->x_fd >= 0)
- {
- fd = x->x_fd;
- pthread_mutex_unlock(&x->x_mutex);
- close (fd);
- pthread_mutex_lock(&x->x_mutex);
- x->x_fd = -1;
- }
- if (x->x_requestcode == REQUEST_CLOSE)
- x->x_requestcode = REQUEST_NOTHING;
- sfread_cond_signal(&x->x_answercondition);
- }
- else if (x->x_requestcode == REQUEST_QUIT)
- {
- if (x->x_fd >= 0)
- {
- fd = x->x_fd;
- pthread_mutex_unlock(&x->x_mutex);
- close (fd);
- pthread_mutex_lock(&x->x_mutex);
- x->x_fd = -1;
- }
- x->x_requestcode = REQUEST_NOTHING;
- sfread_cond_signal(&x->x_answercondition);
- break;
- }
- else
- {
-#ifdef DEBUG_SOUNDFILE
- pute("13\n");
-#endif
- }
- }
-#ifdef DEBUG_SOUNDFILE
- pute("thread exit\n");
-#endif
- pthread_mutex_unlock(&x->x_mutex);
- return (0);
-}
-
-/******** the object proper runs in the calling (parent) thread ****/
-
-static void readsf_tick(t_readsf *x);
-
-static void *readsf_new(t_floatarg fnchannels, t_floatarg fbufsize)
-{
- t_readsf *x;
- int nchannels = fnchannels, bufsize = fbufsize, i;
- char *buf;
-
- if (nchannels < 1)
- nchannels = 1;
- else if (nchannels > MAXSFCHANS)
- nchannels = MAXSFCHANS;
- if (bufsize <= 0) bufsize = DEFBUFPERCHAN * nchannels;
- else if (bufsize < MINBUFSIZE)
- bufsize = MINBUFSIZE;
- else if (bufsize > MAXBUFSIZE)
- bufsize = MAXBUFSIZE;
- buf = getbytes(bufsize);
- if (!buf) return (0);
-
- x = (t_readsf *)pd_new(readsf_class);
-
- for (i = 0; i < nchannels; i++)
- outlet_new(&x->x_obj, gensym("signal"));
- x->x_noutlets = nchannels;
- x->x_bangout = outlet_new(&x->x_obj, &s_bang);
- pthread_mutex_init(&x->x_mutex, 0);
- pthread_cond_init(&x->x_requestcondition, 0);
- pthread_cond_init(&x->x_answercondition, 0);
- x->x_vecsize = MAXVECSIZE;
- x->x_state = STATE_IDLE;
- x->x_clock = clock_new(x, (t_method)readsf_tick);
- x->x_canvas = canvas_getcurrent();
- x->x_bytespersample = 2;
- x->x_sfchannels = 1;
- x->x_fd = -1;
- x->x_buf = buf;
- x->x_bufsize = bufsize;
- x->x_fifosize = x->x_fifohead = x->x_fifotail = x->x_requestcode = 0;
- pthread_create(&x->x_childthread, 0, readsf_child_main, x);
- return (x);
-}
-
-static void readsf_tick(t_readsf *x)
-{
- outlet_bang(x->x_bangout);
-}
-
-static t_int *readsf_perform(t_int *w)
-{
- t_readsf *x = (t_readsf *)(w[1]);
- int vecsize = x->x_vecsize, noutlets = x->x_noutlets, i, j,
- bytespersample = x->x_bytespersample,
- bigendian = x->x_bigendian;
- float *fp;
- if (x->x_state == STATE_STREAM)
- {
- int wantbytes, nchannels, sfchannels = x->x_sfchannels;
- pthread_mutex_lock(&x->x_mutex);
- wantbytes = sfchannels * vecsize * bytespersample;
- while (
- !x->x_eof && x->x_fifohead >= x->x_fifotail &&
- x->x_fifohead < x->x_fifotail + wantbytes-1)
- {
-#ifdef DEBUG_SOUNDFILE
- pute("wait...\n");
-#endif
- sfread_cond_signal(&x->x_requestcondition);
- sfread_cond_wait(&x->x_answercondition, &x->x_mutex);
-#ifdef DEBUG_SOUNDFILE
- pute("done\n");
-#endif
- }
- if (x->x_eof && x->x_fifohead >= x->x_fifotail &&
- x->x_fifohead < x->x_fifotail + wantbytes-1)
- {
- int xfersize;
- if (x->x_fileerror)
- {
- pd_error(x, "dsp: %s: %s", x->x_filename,
- (x->x_fileerror == EIO ?
- "unknown or bad header format" :
- strerror(x->x_fileerror)));
- }
- clock_delay(x->x_clock, 0);
- x->x_state = STATE_IDLE;
-
- /* if there's a partial buffer left, copy it out. */
- xfersize = (x->x_fifohead - x->x_fifotail + 1) /
- (sfchannels * bytespersample);
- if (xfersize)
- {
- soundfile_xferin(sfchannels, noutlets, x->x_outvec, 0,
- (unsigned char *)(x->x_buf + x->x_fifotail), xfersize,
- bytespersample, bigendian);
- vecsize -= xfersize;
- }
- /* then zero out the (rest of the) output */
- for (i = 0; i < noutlets; i++)
- for (j = vecsize, fp = x->x_outvec[i] + xfersize; j--; )
- *fp++ = 0;
-
- sfread_cond_signal(&x->x_requestcondition);
- pthread_mutex_unlock(&x->x_mutex);
- return (w+2);
- }
-
- soundfile_xferin(sfchannels, noutlets, x->x_outvec, 0,
- (unsigned char *)(x->x_buf + x->x_fifotail), vecsize,
- bytespersample, bigendian);
-
- x->x_fifotail += wantbytes;
- if (x->x_fifotail >= x->x_fifosize)
- x->x_fifotail = 0;
- if ((--x->x_sigcountdown) <= 0)
- {
- sfread_cond_signal(&x->x_requestcondition);
- x->x_sigcountdown = x->x_sigperiod;
- }
- pthread_mutex_unlock(&x->x_mutex);
- }
- else
- {
- idle:
- for (i = 0; i < noutlets; i++)
- for (j = vecsize, fp = x->x_outvec[i]; j--; )
- *fp++ = 0;
- }
- return (w+2);
-}
-
-static void readsf_start(t_readsf *x)
-{
- /* start making output. If we're in the "startup" state change
- to the "running" state. */
- if (x->x_state == STATE_STARTUP)
- x->x_state = STATE_STREAM;
- else pd_error(x, "readsf: start requested with no prior 'open'");
-}
-
-static void readsf_stop(t_readsf *x)
-{
- /* LATER rethink whether you need the mutex just to set a variable? */
- pthread_mutex_lock(&x->x_mutex);
- x->x_state = STATE_IDLE;
- x->x_requestcode = REQUEST_CLOSE;
- sfread_cond_signal(&x->x_requestcondition);
- pthread_mutex_unlock(&x->x_mutex);
-}
-
-static void readsf_float(t_readsf *x, t_floatarg f)
-{
- if (f != 0)
- readsf_start(x);
- else readsf_stop(x);
-}
-
- /* open method. Called as:
- open filename [skipframes headersize channels bytespersamp endianness]
- (if headersize is zero, header is taken to be automatically
- detected; thus, use the special "-1" to mean a truly headerless file.)
- */
-
-static void readsf_open(t_readsf *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *filesym = atom_getsymbolarg(0, argc, argv);
- t_float onsetframes = atom_getfloatarg(1, argc, argv);
- t_float headerbytes = atom_getfloatarg(2, argc, argv);
- t_float channels = atom_getfloatarg(3, argc, argv);
- t_float bytespersamp = atom_getfloatarg(4, argc, argv);
- t_symbol *endian = atom_getsymbolarg(5, argc, argv);
- if (!*filesym->s_name)
- return;
- pthread_mutex_lock(&x->x_mutex);
- x->x_requestcode = REQUEST_OPEN;
- x->x_filename = filesym->s_name;
- x->x_fifotail = 0;
- x->x_fifohead = 0;
- if (*endian->s_name == 'b')
- x->x_bigendian = 1;
- else if (*endian->s_name == 'l')
- x->x_bigendian = 0;
- else if (*endian->s_name)
- pd_error(x, "endianness neither 'b' nor 'l'");
- else x->x_bigendian = garray_ambigendian();
- x->x_onsetframes = (onsetframes > 0 ? onsetframes : 0);
- x->x_skipheaderbytes = (headerbytes > 0 ? headerbytes :
- (headerbytes == 0 ? -1 : 0));
- x->x_sfchannels = (channels >= 1 ? channels : 1);
- x->x_bytespersample = (bytespersamp > 2 ? bytespersamp : 2);
- x->x_eof = 0;
- x->x_fileerror = 0;
- x->x_state = STATE_STARTUP;
- sfread_cond_signal(&x->x_requestcondition);
- pthread_mutex_unlock(&x->x_mutex);
-}
-
-static void readsf_dsp(t_readsf *x, t_signal **sp)
-{
- int i, noutlets = x->x_noutlets;
- pthread_mutex_lock(&x->x_mutex);
- x->x_vecsize = sp[0]->s_n;
-
- x->x_sigperiod = (x->x_fifosize /
- (x->x_bytespersample * x->x_sfchannels * x->x_vecsize));
- for (i = 0; i < noutlets; i++)
- x->x_outvec[i] = sp[i]->s_vec;
- pthread_mutex_unlock(&x->x_mutex);
- dsp_add(readsf_perform, 1, x);
-}
-
-static void readsf_print(t_readsf *x)
-{
- post("state %d", x->x_state);
- post("fifo head %d", x->x_fifohead);
- post("fifo tail %d", x->x_fifotail);
- post("fifo size %d", x->x_fifosize);
- post("fd %d", x->x_fd);
- post("eof %d", x->x_eof);
-}
-
-static void readsf_free(t_readsf *x)
-{
- /* request QUIT and wait for acknowledge */
- void *threadrtn;
- pthread_mutex_lock(&x->x_mutex);
- x->x_requestcode = REQUEST_QUIT;
- sfread_cond_signal(&x->x_requestcondition);
- while (x->x_requestcode != REQUEST_NOTHING)
- {
- sfread_cond_signal(&x->x_requestcondition);
- sfread_cond_wait(&x->x_answercondition, &x->x_mutex);
- }
- pthread_mutex_unlock(&x->x_mutex);
- if (pthread_join(x->x_childthread, &threadrtn))
- error("readsf_free: join failed");
-
- pthread_cond_destroy(&x->x_requestcondition);
- pthread_cond_destroy(&x->x_answercondition);
- pthread_mutex_destroy(&x->x_mutex);
- freebytes(x->x_buf, x->x_bufsize);
- clock_free(x->x_clock);
-}
-
-static void readsf_setup(void)
-{
- readsf_class = class_new(gensym("readsf~"), (t_newmethod)readsf_new,
- (t_method)readsf_free, sizeof(t_readsf), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addfloat(readsf_class, (t_method)readsf_float);
- class_addmethod(readsf_class, (t_method)readsf_start, gensym("start"), 0);
- class_addmethod(readsf_class, (t_method)readsf_stop, gensym("stop"), 0);
- class_addmethod(readsf_class, (t_method)readsf_dsp, gensym("dsp"), 0);
- class_addmethod(readsf_class, (t_method)readsf_open, gensym("open"),
- A_GIMME, 0);
- class_addmethod(readsf_class, (t_method)readsf_print, gensym("print"), 0);
-}
-
-/******************************* writesf *******************/
-
-static t_class *writesf_class;
-
-#define t_writesf t_readsf /* just re-use the structure */
-
-/************** the child thread which performs file I/O ***********/
-
-static void *writesf_child_main(void *zz)
-{
- t_writesf *x = zz;
-#ifdef DEBUG_SOUNDFILE
- pute("1\n");
-#endif
- pthread_mutex_lock(&x->x_mutex);
- while (1)
- {
-#ifdef DEBUG_SOUNDFILE
- pute("0\n");
-#endif
- if (x->x_requestcode == REQUEST_NOTHING)
- {
-#ifdef DEBUG_SOUNDFILE
- pute("wait 2\n");
-#endif
- sfread_cond_signal(&x->x_answercondition);
- sfread_cond_wait(&x->x_requestcondition, &x->x_mutex);
-#ifdef DEBUG_SOUNDFILE
- pute("3\n");
-#endif
- }
- else if (x->x_requestcode == REQUEST_OPEN)
- {
- char boo[80];
- int fd, sysrtn, writebytes;
-
- /* copy file stuff out of the data structure so we can
- relinquish the mutex while we're in open_soundfile(). */
- long onsetframes = x->x_onsetframes;
- long bytelimit = 0x7fffffff;
- int skipheaderbytes = x->x_skipheaderbytes;
- int bytespersample = x->x_bytespersample;
- int sfchannels = x->x_sfchannels;
- int bigendian = x->x_bigendian;
- int filetype = x->x_filetype;
- char *filename = x->x_filename;
- t_canvas *canvas = x->x_canvas;
- float samplerate = x->x_samplerate;
-
- /* alter the request code so that an ensuing "open" will get
- noticed. */
-#ifdef DEBUG_SOUNDFILE
- pute("4\n");
-#endif
- x->x_requestcode = REQUEST_BUSY;
- x->x_fileerror = 0;
-
- /* if there's already a file open, close it */
- if (x->x_fd >= 0)
- {
- pthread_mutex_unlock(&x->x_mutex);
- close (x->x_fd);
- pthread_mutex_lock(&x->x_mutex);
- x->x_fd = -1;
- if (x->x_requestcode != REQUEST_BUSY)
- continue;
- }
- /* open the soundfile with the mutex unlocked */
- pthread_mutex_unlock(&x->x_mutex);
- fd = create_soundfile(canvas, filename, filetype, 0,
- bytespersample, bigendian, sfchannels,
- garray_ambigendian() != bigendian, samplerate);
- pthread_mutex_lock(&x->x_mutex);
-#ifdef DEBUG_SOUNDFILE
- pute("5\n");
-#endif
-
- if (fd < 0)
- {
- x->x_fd = -1;
- x->x_eof = 1;
- x->x_fileerror = errno;
-#ifdef DEBUG_SOUNDFILE
- pute("open failed\n");
- pute(filename);
-#endif
- x->x_requestcode = REQUEST_NOTHING;
- continue;
- }
- /* check if another request has been made; if so, field it */
- if (x->x_requestcode != REQUEST_BUSY)
- continue;
-#ifdef DEBUG_SOUNDFILE
- pute("6\n");
-#endif
- x->x_fd = fd;
- x->x_fifotail = 0;
- x->x_itemswritten = 0;
- x->x_swap = garray_ambigendian() != bigendian;
- /* in a loop, wait for the fifo to have data and write it
- to disk */
- while (x->x_requestcode == REQUEST_BUSY ||
- (x->x_requestcode == REQUEST_CLOSE &&
- x->x_fifohead != x->x_fifotail))
- {
- int fifosize = x->x_fifosize, fifotail;
- char *buf = x->x_buf;
-#ifdef DEBUG_SOUNDFILE
- pute("77\n");
-#endif
-
- /* if the head is < the tail, we can immediately write
- from tail to end of fifo to disk; otherwise we hold off
- writing until there are at least WRITESIZE bytes in the
- buffer */
- if (x->x_fifohead < x->x_fifotail ||
- x->x_fifohead >= x->x_fifotail + WRITESIZE
- || (x->x_requestcode == REQUEST_CLOSE &&
- x->x_fifohead != x->x_fifotail))
- {
- writebytes = (x->x_fifohead < x->x_fifotail ?
- fifosize : x->x_fifohead) - x->x_fifotail;
- if (writebytes > READSIZE)
- writebytes = READSIZE;
- }
- else
- {
-#ifdef DEBUG_SOUNDFILE
- pute("wait 7a ...\n");
-#endif
- sfread_cond_signal(&x->x_answercondition);
-#ifdef DEBUG_SOUNDFILE
- pute("signalled\n");
-#endif
- sfread_cond_wait(&x->x_requestcondition,
- &x->x_mutex);
-#ifdef DEBUG_SOUNDFILE
- pute("7a done\n");
-#endif
- continue;
- }
-#ifdef DEBUG_SOUNDFILE
- pute("8\n");
-#endif
- fifotail = x->x_fifotail;
- fd = x->x_fd;
- pthread_mutex_unlock(&x->x_mutex);
- sysrtn = write(fd, buf + fifotail, writebytes);
- pthread_mutex_lock(&x->x_mutex);
- if (x->x_requestcode != REQUEST_BUSY &&
- x->x_requestcode != REQUEST_CLOSE)
- break;
- if (sysrtn < writebytes)
- {
-#ifdef DEBUG_SOUNDFILE
- pute("fileerror\n");
-#endif
- x->x_fileerror = errno;
- break;
- }
- else
- {
- x->x_fifotail += sysrtn;
- if (x->x_fifotail == fifosize)
- x->x_fifotail = 0;
- }
- x->x_itemswritten +=
- sysrtn / (x->x_bytespersample * x->x_sfchannels);
- sprintf(boo, "after: head %d, tail %d\n",
- x->x_fifohead, x->x_fifotail);
-#ifdef DEBUG_SOUNDFILE
- pute(boo);
-#endif
- /* signal parent in case it's waiting for data */
- sfread_cond_signal(&x->x_answercondition);
- }
- }
- else if (x->x_requestcode == REQUEST_CLOSE ||
- x->x_requestcode == REQUEST_QUIT)
- {
- int quit = (x->x_requestcode == REQUEST_QUIT);
- if (x->x_fd >= 0)
- {
- int bytesperframe = x->x_bytespersample * x->x_sfchannels;
- int bigendian = x->x_bigendian;
- char *filename = x->x_filename;
- int fd = x->x_fd;
- int filetype = x->x_filetype;
- int itemswritten = x->x_itemswritten;
- int swap = x->x_swap;
- pthread_mutex_unlock(&x->x_mutex);
-
- soundfile_finishwrite(x, filename, fd,
- filetype, 0x7fffffff, itemswritten,
- bytesperframe, swap);
- close (fd);
-
- pthread_mutex_lock(&x->x_mutex);
- x->x_fd = -1;
- }
- x->x_requestcode = REQUEST_NOTHING;
- sfread_cond_signal(&x->x_answercondition);
- if (quit)
- break;
- }
- else
- {
-#ifdef DEBUG_SOUNDFILE
- pute("13\n");
-#endif
- }
- }
-#ifdef DEBUG_SOUNDFILE
- pute("thread exit\n");
-#endif
- pthread_mutex_unlock(&x->x_mutex);
- return (0);
-}
-
-/******** the object proper runs in the calling (parent) thread ****/
-
-static void writesf_tick(t_writesf *x);
-
-static void *writesf_new(t_floatarg fnchannels, t_floatarg fbufsize)
-{
- t_writesf *x;
- int nchannels = fnchannels, bufsize = fbufsize, i;
- char *buf;
-
- if (nchannels < 1)
- nchannels = 1;
- else if (nchannels > MAXSFCHANS)
- nchannels = MAXSFCHANS;
- if (bufsize <= 0) bufsize = DEFBUFPERCHAN * nchannels;
- else if (bufsize < MINBUFSIZE)
- bufsize = MINBUFSIZE;
- else if (bufsize > MAXBUFSIZE)
- bufsize = MAXBUFSIZE;
- buf = getbytes(bufsize);
- if (!buf) return (0);
-
- x = (t_writesf *)pd_new(writesf_class);
-
- for (i = 1; i < nchannels; i++)
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
-
- x->x_f = 0;
- x->x_sfchannels = nchannels;
- pthread_mutex_init(&x->x_mutex, 0);
- pthread_cond_init(&x->x_requestcondition, 0);
- pthread_cond_init(&x->x_answercondition, 0);
- x->x_vecsize = MAXVECSIZE;
- x->x_insamplerate = x->x_samplerate = 0;
- x->x_state = STATE_IDLE;
- x->x_clock = 0; /* no callback needed here */
- x->x_canvas = canvas_getcurrent();
- x->x_bytespersample = 2;
- x->x_fd = -1;
- x->x_buf = buf;
- x->x_bufsize = bufsize;
- x->x_fifosize = x->x_fifohead = x->x_fifotail = x->x_requestcode = 0;
- pthread_create(&x->x_childthread, 0, writesf_child_main, x);
- return (x);
-}
-
-static t_int *writesf_perform(t_int *w)
-{
- t_writesf *x = (t_writesf *)(w[1]);
- int vecsize = x->x_vecsize, sfchannels = x->x_sfchannels, i, j,
- bytespersample = x->x_bytespersample,
- bigendian = x->x_bigendian;
- float *fp;
- if (x->x_state == STATE_STREAM)
- {
- int wantbytes;
- pthread_mutex_lock(&x->x_mutex);
- wantbytes = sfchannels * vecsize * bytespersample;
- while (x->x_fifotail > x->x_fifohead &&
- x->x_fifotail < x->x_fifohead + wantbytes + 1)
- {
-#ifdef DEBUG_SOUNDFILE
- pute("wait...\n");
-#endif
- sfread_cond_signal(&x->x_requestcondition);
- sfread_cond_wait(&x->x_answercondition, &x->x_mutex);
-#ifdef DEBUG_SOUNDFILE
- pute("done\n");
-#endif
- }
-
- soundfile_xferout(sfchannels, x->x_outvec,
- (unsigned char *)(x->x_buf + x->x_fifohead), vecsize, 0,
- bytespersample, bigendian, 1.);
-
- x->x_fifohead += wantbytes;
- if (x->x_fifohead >= x->x_fifosize)
- x->x_fifohead = 0;
- if ((--x->x_sigcountdown) <= 0)
- {
-#ifdef DEBUG_SOUNDFILE
- pute("signal 1\n");
-#endif
- sfread_cond_signal(&x->x_requestcondition);
- x->x_sigcountdown = x->x_sigperiod;
- }
- pthread_mutex_unlock(&x->x_mutex);
- }
- return (w+2);
-}
-
-static void writesf_start(t_writesf *x)
-{
- /* start making output. If we're in the "startup" state change
- to the "running" state. */
- if (x->x_state == STATE_STARTUP)
- x->x_state = STATE_STREAM;
- else
- pd_error(x, "writesf: start requested with no prior 'open'");
-}
-
-static void writesf_stop(t_writesf *x)
-{
- /* LATER rethink whether you need the mutex just to set a Svariable? */
- pthread_mutex_lock(&x->x_mutex);
- x->x_state = STATE_IDLE;
- x->x_requestcode = REQUEST_CLOSE;
-#ifdef DEBUG_SOUNDFILE
- pute("signal 2\n");
-#endif
- sfread_cond_signal(&x->x_requestcondition);
- pthread_mutex_unlock(&x->x_mutex);
-}
-
-
- /* open method. Called as: open [args] filename with args as in
- soundfiler_writeargparse().
- */
-
-static void writesf_open(t_writesf *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *filesym;
- int filetype, bytespersamp, swap, bigendian, normalize;
- long onset, nframes;
- float samplerate;
- if (soundfiler_writeargparse(x, &argc,
- &argv, &filesym, &filetype, &bytespersamp, &swap, &bigendian,
- &normalize, &onset, &nframes, &samplerate))
- {
- pd_error(x,
- "writesf~: usage: open [-bytes [234]] [-wave,-nextstep,-aiff] ...");
- post("... [-big,-little] [-rate ####] filename");
- }
- if (normalize || onset || (nframes != 0x7fffffff))
- pd_error(x, "normalize/onset/nframes argument to writesf~: ignored");
- if (argc)
- pd_error(x, "extra argument(s) to writesf~: ignored");
- pthread_mutex_lock(&x->x_mutex);
- x->x_bytespersample = bytespersamp;
- x->x_swap = swap;
- x->x_bigendian = bigendian;
- x->x_filename = filesym->s_name;
- x->x_filetype = filetype;
- x->x_itemswritten = 0;
- x->x_requestcode = REQUEST_OPEN;
- x->x_fifotail = 0;
- x->x_fifohead = 0;
- x->x_eof = 0;
- x->x_fileerror = 0;
- x->x_state = STATE_STARTUP;
- x->x_bytespersample = (bytespersamp > 2 ? bytespersamp : 2);
- if (samplerate > 0)
- x->x_samplerate = samplerate;
- else if (x->x_insamplerate > 0)
- x->x_samplerate = x->x_insamplerate;
- else x->x_samplerate = sys_getsr();
- /* set fifosize from bufsize. fifosize must be a
- multiple of the number of bytes eaten for each DSP
- tick. */
- x->x_fifosize = x->x_bufsize - (x->x_bufsize %
- (x->x_bytespersample * x->x_sfchannels * MAXVECSIZE));
- /* arrange for the "request" condition to be signalled 16
- times per buffer */
- x->x_sigcountdown = x->x_sigperiod =
- (x->x_fifosize /
- (16 * x->x_bytespersample * x->x_sfchannels *
- x->x_vecsize));
- sfread_cond_signal(&x->x_requestcondition);
- pthread_mutex_unlock(&x->x_mutex);
-}
-
-static void writesf_dsp(t_writesf *x, t_signal **sp)
-{
- int i, ninlets = x->x_sfchannels;
- pthread_mutex_lock(&x->x_mutex);
- x->x_vecsize = sp[0]->s_n;
-
- x->x_sigperiod = (x->x_fifosize /
- (x->x_bytespersample * ninlets * x->x_vecsize));
- for (i = 0; i < ninlets; i++)
- x->x_outvec[i] = sp[i]->s_vec;
- x->x_insamplerate = sp[0]->s_sr;
- pthread_mutex_unlock(&x->x_mutex);
- dsp_add(writesf_perform, 1, x);
-}
-
-static void writesf_print(t_writesf *x)
-{
- post("state %d", x->x_state);
- post("fifo head %d", x->x_fifohead);
- post("fifo tail %d", x->x_fifotail);
- post("fifo size %d", x->x_fifosize);
- post("fd %d", x->x_fd);
- post("eof %d", x->x_eof);
-}
-
-static void writesf_free(t_writesf *x)
-{
- /* request QUIT and wait for acknowledge */
- void *threadrtn;
- pthread_mutex_lock(&x->x_mutex);
- x->x_requestcode = REQUEST_QUIT;
- /* post("stopping writesf thread..."); */
- sfread_cond_signal(&x->x_requestcondition);
- while (x->x_requestcode != REQUEST_NOTHING)
- {
- /* post("signalling..."); */
- sfread_cond_signal(&x->x_requestcondition);
- sfread_cond_wait(&x->x_answercondition, &x->x_mutex);
- }
- pthread_mutex_unlock(&x->x_mutex);
- if (pthread_join(x->x_childthread, &threadrtn))
- error("writesf_free: join failed");
- /* post("... done."); */
-
- pthread_cond_destroy(&x->x_requestcondition);
- pthread_cond_destroy(&x->x_answercondition);
- pthread_mutex_destroy(&x->x_mutex);
- freebytes(x->x_buf, x->x_bufsize);
-}
-
-static void writesf_setup(void)
-{
- writesf_class = class_new(gensym("writesf~"), (t_newmethod)writesf_new,
- (t_method)writesf_free, sizeof(t_writesf), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addmethod(writesf_class, (t_method)writesf_start, gensym("start"), 0);
- class_addmethod(writesf_class, (t_method)writesf_stop, gensym("stop"), 0);
- class_addmethod(writesf_class, (t_method)writesf_dsp, gensym("dsp"), 0);
- class_addmethod(writesf_class, (t_method)writesf_open, gensym("open"),
- A_GIMME, 0);
- class_addmethod(writesf_class, (t_method)writesf_print, gensym("print"), 0);
- CLASS_MAINSIGNALIN(writesf_class, t_writesf, x_f);
-}
-
-#endif
-
-/* ------------------------ global setup routine ------------------------- */
-
-void d_soundfile_setup(void)
-{
- soundfiler_setup();
-#ifndef FIXEDPOINT
- readsf_setup();
- writesf_setup();
-#endif
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/d_ugen.c b/apps/plugins/pdbox/PDa/src/d_ugen.c
index 9820f190cc..2c359c384d 100644
--- a/apps/plugins/pdbox/PDa/src/d_ugen.c
+++ b/apps/plugins/pdbox/PDa/src/d_ugen.c
@@ -1124,1129 +1124,3 @@ void d_ugen_setup(void) /* really just block_setup */
class_addfloat(block_class, block_float);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* These routines build a copy of the DSP portion of a graph, which is
- then sorted into a linear list of DSP operations which are added to
- the DSP duty cycle called by the scheduler. Once that's been done,
- we delete the copy. The DSP objects are represented by "ugenbox"
- structures which are parallel to the DSP objects in the graph and
- have vectors of siginlets and sigoutlets which record their
- interconnections.
-*/
-
-/* hacked to run subpatches with different samplerates
- * only samplerates that are a power_of_2-multiple of the
- *
- * mfg.gfd.uil
- * IOhannes
- *
- * edited lines are marked with "IOhannes"
- *
- */
-
-
-#include "m_pd.h"
-#include "m_imp.h"
-#include <stdlib.h>
-#include <stdarg.h>
-
-extern t_class *vinlet_class, *voutlet_class, *canvas_class;
-t_sample *obj_findsignalscalar(t_object *x, int m);
-static int ugen_loud;
-EXTERN_STRUCT _vinlet;
-EXTERN_STRUCT _voutlet;
-
-void vinlet_dspprolog(struct _vinlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock,
- int switched);
-void voutlet_dspprolog(struct _voutlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock,
- int switched);
-void voutlet_dspepilog(struct _voutlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock,
- int switched);
-
-t_int *zero_perform(t_int *w) /* zero out a vector */
-{
- t_float *out = (t_float *)(w[1]);
- int n = (int)(w[2]);
- while (n--) *out++ = 0;
- return (w+3);
-}
-
-t_int *zero_perf8(t_int *w)
-{
- t_float *out = (t_float *)(w[1]);
- int n = (int)(w[2]);
-
- for (; n; n -= 8, out += 8)
- {
- out[0] = 0;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 0;
- out[5] = 0;
- out[6] = 0;
- out[7] = 0;
- }
- return (w+3);
-}
-
-void dsp_add_zero(t_sample *out, int n)
-{
- if (n&7)
- dsp_add(zero_perform, 2, out, n);
- else
- dsp_add(zero_perf8, 2, out, n);
-}
-
-/* ---------------------------- block~ ----------------------------- */
-
-/* The "block~ object maintains the containing canvas's DSP computation,
-calling it at a super- or sub-multiple of the containing canvas's
-calling frequency. The block~'s creation arguments specify block size
-and overlap. Block~ does no "dsp" computation in its own right, but it
-adds prolog and epilog code before and after the canvas's unit generators.
-
-A subcanvas need not have a block~ at all; if there's none, its
-ugens are simply put on the list without any prolog or epilog code.
-
-Block~ may be invoked as switch~, in which case it also acts to switch the
-subcanvas on and off. The overall order of scheduling for a subcanvas
-is thus,
-
- inlet and outlet prologue code (1)
- block prologue (2)
- the objects in the subcanvas, including inlets and outlets
- block epilogue (2)
- outlet epilogue code (2)
-
-where (1) means, "if reblocked" and (2) means, "if reblocked or switched".
-
-If we're reblocked, the inlet prolog and outlet epilog code takes care of
-overlapping and buffering to deal with vector size changes. If we're switched
-but not reblocked, the inlet prolog is not needed, and the output epilog is
-ONLY run when the block is switched off; in this case the epilog code simply
-copies zeros to all signal outlets.
-*/
-
-static int dsp_phase;
-static t_class *block_class;
-
-typedef struct _block
-{
- t_object x_obj;
- int x_vecsize;
- int x_overlap;
- int x_phase; /* from 0 to period-1; when zero we run the block */
- int x_period; /* submultiple of containing canvas */
- int x_frequency; /* supermultiple of comtaining canvas */
- int x_count;
- int x_blocklength; /* length of dspchain for this block */
- int x_epiloglength; /* length of epilog */
- char x_switched; /* true if we're acting as a a switch */
- char x_switchon; /* true if we're switched on */
- char x_reblock; /* true if inlets and outlets are reblocking */
- int x_upsample; /* IOhannes: upsampling-factor */
- int x_downsample; /* IOhannes: downsampling-factor */
-
-} t_block;
-
-static void block_set(t_block *x, t_floatarg fvecsize, t_floatarg foverlap,
- t_floatarg fupsample);
-
-static void *block_new(t_floatarg fvecsize, t_floatarg foverlap,
- t_floatarg fupsample) /* IOhannes */
-{
- t_block *x = (t_block *)pd_new(block_class);
- x->x_phase = 0;
- x->x_period = 1;
- x->x_frequency = 1;
- x->x_switched = 0;
- x->x_switchon = 1;
- block_set(x, fvecsize, foverlap, fupsample);
- return (x);
-}
-
-static void block_set(t_block *x, t_floatarg fvecsize, t_floatarg foverlap,
- t_floatarg fupsample)
-{
- int upsample, downsample; /* IOhannes */
- int vecsize = fvecsize;
- int overlap = foverlap;
- int dspstate = canvas_suspend_dsp();
- if (overlap < 1)
- overlap = 1;
- if (vecsize < 0)
- vecsize = 0; /* this means we'll get it from parent later. */
-
- /* IOhannes { */
- if (fupsample <= 0) upsample = downsample = 1;
- else if (fupsample >= 1) {
- upsample = fupsample;
- downsample = 1;
- } else {
- downsample = 1.0 / fupsample;
- upsample = 1;
- }
- /* } IOhannes */
-
- if (vecsize && (vecsize != (1 << ilog2(vecsize))))
- {
- pd_error(x, "block~: vector size not a power of 2");
- vecsize = 64;
- }
- if (overlap != (1 << ilog2(overlap)))
- {
- pd_error(x, "block~: overlap not a power of 2");
- overlap = 1;
- }
- /* IOhannes { */
- if (downsample != (1 << ilog2(downsample)))
- {
- pd_error(x, "block~: downsampling not a power of 2");
- downsample = 1;
- }
- if (upsample != (1 << ilog2(upsample)))
- {
- pd_error(x, "block~: upsampling not a power of 2");
- upsample = 1;
- }
- /* } IOhannes */
-
-
- x->x_vecsize = vecsize;
- x->x_overlap = overlap;
- /* IOhannes { */
- x->x_upsample = upsample;
- x->x_downsample = downsample;
- /* } IOhannes */
- canvas_resume_dsp(dspstate);
-}
-
-static void *switch_new(t_floatarg fvecsize, t_floatarg foverlap,
- t_floatarg fupsample) /* IOhannes */
-{
- t_block *x = (t_block *)(block_new(fvecsize, foverlap, fupsample)); /* IOhannes */
- x->x_switched = 1;
- x->x_switchon = 0;
- return (x);
-}
-
-static void block_float(t_block *x, t_floatarg f)
-{
- if (x->x_switched)
- x->x_switchon = (f != 0);
-}
-#define PROLOGCALL 2
-#define EPILOGCALL 2
-
-static t_int *block_prolog(t_int *w)
-{
- t_block *x = (t_block *)w[1];
- int phase = x->x_phase;
- /* if we're switched off, jump past the epilog code */
- if (!x->x_switchon)
- return (w + x->x_blocklength);
- if (phase)
- {
- phase++;
- if (phase == x->x_period) phase = 0;
- x->x_phase = phase;
- return (w + x->x_blocklength); /* skip block; jump past epilog */
- }
- else
- {
- x->x_count = x->x_frequency;
- x->x_phase = (x->x_period > 1 ? 1 : 0);
- return (w + PROLOGCALL); /* beginning of block is next ugen */
- }
-}
-
-static t_int *block_epilog(t_int *w)
-{
- t_block *x = (t_block *)w[1];
- int count = x->x_count - 1;
- if (!x->x_reblock)
- return (w + x->x_epiloglength + EPILOGCALL);
- if (count)
- {
- x->x_count = count;
- return (w - (x->x_blocklength -
- (PROLOGCALL + EPILOGCALL))); /* go to ugen after prolog */
- }
- else return (w + EPILOGCALL);
-}
-
-static void block_dsp(t_block *x, t_signal **sp)
-{
- /* do nothing here */
-}
-
-/* ------------------ DSP call list ----------------------- */
-
-static t_int *dsp_chain;
-static int dsp_chainsize;
-
-void dsp_add(t_perfroutine f, int n, ...)
-{
- int newsize = dsp_chainsize + n+1, i;
- va_list ap;
-
- dsp_chain = t_resizebytes(dsp_chain, dsp_chainsize * sizeof (t_int),
- newsize * sizeof (t_int));
- dsp_chain[dsp_chainsize-1] = (t_int)f;
- va_start(ap, n);
- for (i = 0; i < n; i++)
- dsp_chain[dsp_chainsize + i] = va_arg(ap, t_int);
- va_end(ap);
- dsp_chain[newsize-1] = 0;
- dsp_chainsize = newsize;
-}
-
- /* at Guenter's suggestion, here's a vectorized version */
-void dsp_addv(t_perfroutine f, int n, t_int *vec)
-{
- int newsize = dsp_chainsize + n+1, i;
-
- dsp_chain = t_resizebytes(dsp_chain, dsp_chainsize * sizeof (t_int),
- newsize * sizeof (t_int));
- dsp_chain[dsp_chainsize-1] = (t_int)f;
- for (i = 0; i < n; i++)
- dsp_chain[dsp_chainsize + i] = vec[i];
- dsp_chain[newsize-1] = 0;
- dsp_chainsize = newsize;
-}
-
-void dsp_tick(void)
-{
- if (dsp_chain)
- {
- t_int *ip;
- for (ip = dsp_chain; *ip; ) ip = (*(t_perfroutine)(*ip))(ip);
- dsp_phase++;
- }
-}
-
-/* ---------------- signals ---------------------------- */
-
-int ilog2(int n)
-{
- int r = -1;
- if (n <= 0) return(0);
- while (n)
- {
- r++;
- n >>= 1;
- }
- return (r);
-}
-
- /* list of signals which can be reused, sorted by buffer size */
-static t_signal *signal_freelist[MAXLOGSIG+1];
- /* list of reusable "borrowed" signals (which don't own sample buffers) */
-static t_signal *signal_freeborrowed;
- /* list of all signals allocated (not including "borrowed" ones) */
-static t_signal *signal_usedlist;
-
- /* call this when DSP is stopped to free all the signals */
-void signal_cleanup(void)
-{
- t_signal **svec, *sig, *sig2;
- int i;
- while (sig = signal_usedlist)
- {
- signal_usedlist = sig->s_nextused;
- if (!sig->s_isborrowed)
- t_freebytes(sig->s_vec, sig->s_n * sizeof (*sig->s_vec));
- t_freebytes(sig, sizeof *sig);
- }
- for (i = 0; i <= MAXLOGSIG; i++)
- signal_freelist[i] = 0;
- signal_freeborrowed = 0;
-}
-
- /* mark the signal "reusable." */
-void signal_makereusable(t_signal *sig)
-{
- int logn = ilog2(sig->s_n);
-#if 1
- t_signal *s5;
- for (s5 = signal_freeborrowed; s5; s5 = s5->s_nextfree)
- {
- if (s5 == sig)
- {
- bug("signal_free 3");
- return;
- }
- }
- for (s5 = signal_freelist[logn]; s5; s5 = s5->s_nextfree)
- {
- if (s5 == sig)
- {
- bug("signal_free 4");
- return;
- }
- }
-#endif
- if (ugen_loud) post("free %x: %d", sig, sig->s_isborrowed);
- if (sig->s_isborrowed)
- {
- /* if the signal is borrowed, decrement the borrowed-from signal's
- reference count, possibly marking it reusable too */
- t_signal *s2 = sig->s_borrowedfrom;
- if ((s2 == sig) || !s2)
- bug("signal_free");
- s2->s_refcount--;
- if (!s2->s_refcount)
- signal_makereusable(s2);
- sig->s_nextfree = signal_freeborrowed;
- signal_freeborrowed = sig;
- }
- else
- {
- /* if it's a real signal (not borrowed), put it on the free list
- so we can reuse it. */
- if (signal_freelist[logn] == sig) bug("signal_free 2");
- sig->s_nextfree = signal_freelist[logn];
- signal_freelist[logn] = sig;
- }
-}
-
- /* reclaim or make an audio signal. If n is zero, return a "borrowed"
- signal whose buffer and size will be obtained later via
- signal_setborrowed(). */
-
-t_signal *signal_new(int n, float sr)
-{
- int logn, n2;
- t_signal *ret, **whichlist;
- t_sample *fp;
- logn = ilog2(n);
- if (n)
- {
- if (n != (1 << logn))
- bug("signal buffer not a power of 2");
- if (logn > MAXLOGSIG)
- bug("signal buffer too large");
- whichlist = signal_freelist + logn;
- }
- else
- whichlist = &signal_freeborrowed;
-
- /* first try to reclaim one from the free list */
- if (ret = *whichlist)
- *whichlist = ret->s_nextfree;
- else
- {
- /* LATER figure out what to do for out-of-space here! */
- ret = (t_signal *)t_getbytes(sizeof *ret);
- if (n)
- {
- ret->s_vec = (t_sample *)getbytes(n * sizeof (*ret->s_vec));
- ret->s_isborrowed = 0;
- }
- else
- {
- ret->s_vec = 0;
- ret->s_isborrowed = 1;
- }
- ret->s_nextused = signal_usedlist;
- signal_usedlist = ret;
- }
- ret->s_n = n;
- ret->s_sr = sr;
- ret->s_refcount = 0;
- ret->s_borrowedfrom = 0;
- if (ugen_loud) post("new %x: %d", ret, ret->s_isborrowed);
- return (ret);
-}
-
-static t_signal *signal_newlike(const t_signal *sig)
-{
- return (signal_new(sig->s_n, sig->s_sr));
-}
-
-void signal_setborrowed(t_signal *sig, t_signal *sig2)
-{
- if (!sig->s_isborrowed || sig->s_borrowedfrom)
- bug("signal_setborrowed");
- if (sig == sig2)
- bug("signal_setborrowed 2");
- sig->s_borrowedfrom = sig2;
- sig->s_vec = sig2->s_vec;
- sig->s_n = sig2->s_n;
-}
-
-int signal_compatible(t_signal *s1, t_signal *s2)
-{
- return (s1->s_n == s2->s_n && s1->s_sr == s2->s_sr);
-}
-
-/* ------------------ ugen ("unit generator") sorting ----------------- */
-
-typedef struct _ugenbox
-{
- struct _siginlet *u_in;
- int u_nin;
- struct _sigoutlet *u_out;
- int u_nout;
- int u_phase;
- struct _ugenbox *u_next;
- t_object *u_obj;
- int u_done;
-} t_ugenbox;
-
-typedef struct _siginlet
-{
- int i_nconnect;
- int i_ngot;
- t_signal *i_signal;
-} t_siginlet;
-
-typedef struct _sigoutconnect
-{
- t_ugenbox *oc_who;
- int oc_inno;
- struct _sigoutconnect *oc_next;
-} t_sigoutconnect;
-
-typedef struct _sigoutlet
-{
- int o_nconnect;
- int o_nsent;
- t_signal *o_signal;
- t_sigoutconnect *o_connections;
-} t_sigoutlet;
-
-
-struct _dspcontext
-{
- struct _ugenbox *dc_ugenlist;
- struct _dspcontext *dc_parentcontext;
- int dc_ninlets;
- int dc_noutlets;
- t_signal **dc_iosigs;
- float dc_srate;
- int dc_vecsize;
- char dc_toplevel; /* true if "iosigs" is invalid. */
- char dc_reblock; /* true if we have to reblock inlets/outlets */
- char dc_switched; /* true if we're switched */
-
-};
-
-#define t_dspcontext struct _dspcontext
-
-static int ugen_sortno = 0;
-static t_dspcontext *ugen_currentcontext;
-
-void ugen_stop(void)
-{
- t_signal *s;
- int i;
- if (dsp_chain)
- {
- freebytes(dsp_chain, dsp_chainsize * sizeof (t_int));
- dsp_chain = 0;
- }
- signal_cleanup();
-
-}
-
-void ugen_start(void)
-{
- ugen_stop();
- ugen_sortno++;
- dsp_chain = (t_int *)getbytes(sizeof(*dsp_chain));
- dsp_chain[0] = 0;
- dsp_chainsize = 1;
- if (ugen_currentcontext) bug("ugen_start");
-}
-
-int ugen_getsortno(void)
-{
- return (ugen_sortno);
-}
-
-#if 0
-void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- int i, count;
- t_signal *sig;
- for (count = 0, sig = signal_usedlist; sig;
- count++, sig = sig->s_nextused)
- ;
- post("used signals %d", count);
- for (i = 0; i < MAXLOGSIG; i++)
- {
- for (count = 0, sig = signal_freelist[i]; sig;
- count++, sig = sig->s_nextfree)
- ;
- if (count)
- post("size %d: free %d", (1 << i), count);
- }
- for (count = 0, sig = signal_freeborrowed; sig;
- count++, sig = sig->s_nextfree)
- ;
- post("free borrowed %d", count);
-
- ugen_loud = argc;
-}
-#endif
-
- /* start building the graph for a canvas */
-t_dspcontext *ugen_start_graph(int toplevel, t_signal **sp,
- int ninlets, int noutlets)
-{
- t_dspcontext *dc = (t_dspcontext *)getbytes(sizeof(*dc));
- float parent_srate, srate;
- int parent_vecsize, vecsize;
-
- if (ugen_loud) post("ugen_start_graph...");
-
- dc->dc_ugenlist = 0;
- dc->dc_toplevel = toplevel;
- dc->dc_iosigs = sp;
- dc->dc_ninlets = ninlets;
- dc->dc_noutlets = noutlets;
- dc->dc_parentcontext = ugen_currentcontext;
- ugen_currentcontext = dc;
- return (dc);
-}
-
- /* first the canvas calls this to create all the boxes... */
-void ugen_add(t_dspcontext *dc, t_object *obj)
-{
- t_ugenbox *x = (t_ugenbox *)getbytes(sizeof *x);
- int i;
- t_sigoutlet *uout;
- t_siginlet *uin;
-
- x->u_next = dc->dc_ugenlist;
- dc->dc_ugenlist = x;
- x->u_obj = obj;
- x->u_nin = obj_nsiginlets(obj);
- x->u_in = getbytes(x->u_nin * sizeof (*x->u_in));
- for (uin = x->u_in, i = x->u_nin; i--; uin++)
- uin->i_nconnect = 0;
- x->u_nout = obj_nsigoutlets(obj);
- x->u_out = getbytes(x->u_nout * sizeof (*x->u_out));
- for (uout = x->u_out, i = x->u_nout; i--; uout++)
- uout->o_connections = 0, uout->o_nconnect = 0;
-}
-
- /* and then this to make all the connections. */
-void ugen_connect(t_dspcontext *dc, t_object *x1, int outno, t_object *x2,
- int inno)
-{
- t_ugenbox *u1, *u2;
- t_sigoutlet *uout;
- t_siginlet *uin;
- t_sigoutconnect *oc;
- int sigoutno = obj_sigoutletindex(x1, outno);
- int siginno = obj_siginletindex(x2, inno);
- if (ugen_loud)
- post("%s -> %s: %d->%d",
- class_getname(x1->ob_pd),
- class_getname(x2->ob_pd), outno, inno);
- for (u1 = dc->dc_ugenlist; u1 && u1->u_obj != x1; u1 = u1->u_next);
- for (u2 = dc->dc_ugenlist; u2 && u2->u_obj != x2; u2 = u2->u_next);
- if (!u1 || !u2 || siginno < 0)
- {
- pd_error(u1->u_obj,
- "signal outlet connect to nonsignal inlet (ignored)");
- return;
- }
- if (sigoutno < 0 || sigoutno >= u1->u_nout || siginno >= u2->u_nin)
- {
- bug("ugen_connect %s %s %d %d (%d %d)",
- class_getname(x1->ob_pd),
- class_getname(x2->ob_pd), sigoutno, siginno, u1->u_nout,
- u2->u_nin);
- }
- uout = u1->u_out + sigoutno;
- uin = u2->u_in + siginno;
-
- /* add a new connection to the outlet's list */
- oc = (t_sigoutconnect *)getbytes(sizeof *oc);
- oc->oc_next = uout->o_connections;
- uout->o_connections = oc;
- oc->oc_who = u2;
- oc->oc_inno = siginno;
- /* update inlet and outlet counts */
- uout->o_nconnect++;
- uin->i_nconnect++;
-}
-
- /* get the index of a ugenbox or -1 if it's not on the list */
-static int ugen_index(t_dspcontext *dc, t_ugenbox *x)
-{
- int ret;
- t_ugenbox *u;
- for (u = dc->dc_ugenlist, ret = 0; u; u = u->u_next, ret++)
- if (u == x) return (ret);
- return (-1);
-}
-
- /* put a ugenbox on the chain, recursively putting any others on that
- this one might uncover. */
-static void ugen_doit(t_dspcontext *dc, t_ugenbox *u)
-{
- t_sigoutlet *uout;
- t_siginlet *uin;
- t_sigoutconnect *oc, *oc2;
- t_class *class = pd_class(&u->u_obj->ob_pd);
- int i, n;
- /* suppress creating new signals for the outputs of signal
- inlets and subpatchs; except in the case we're an inlet and "blocking"
- is set. We don't yet know if a subcanvas will be "blocking" so there
- we delay new signal creation, which will be handled by calling
- signal_setborrowed in the ugen_done_graph routine below. */
- int nonewsigs = (class == canvas_class ||
- (class == vinlet_class) && !(dc->dc_reblock));
- /* when we encounter a subcanvas or a signal outlet, suppress freeing
- the input signals as they may be "borrowed" for the super or sub
- patch; same exception as above, but also if we're "switched" we
- have to do a copy rather than a borrow. */
- int nofreesigs = (class == canvas_class ||
- (class == voutlet_class) && !(dc->dc_reblock || dc->dc_switched));
- t_signal **insig, **outsig, **sig, *s1, *s2, *s3;
- t_ugenbox *u2;
-
- if (ugen_loud) post("doit %s %d %d", class_getname(class), nofreesigs,
- nonewsigs);
- for (i = 0, uin = u->u_in; i < u->u_nin; i++, uin++)
- {
- if (!uin->i_nconnect)
- {
- t_sample *scalar;
- s3 = signal_new(dc->dc_vecsize, dc->dc_srate);
- /* post("%s: unconnected signal inlet set to zero",
- class_getname(u->u_obj->ob_pd)); */
- if (scalar = obj_findsignalscalar(u->u_obj, i))
- dsp_add_scalarcopy(scalar, s3->s_vec, s3->s_n);
- else
- dsp_add_zero(s3->s_vec, s3->s_n);
- uin->i_signal = s3;
- s3->s_refcount = 1;
- }
- }
- insig = (t_signal **)getbytes((u->u_nin + u->u_nout) * sizeof(t_signal *));
- outsig = insig + u->u_nin;
- for (sig = insig, uin = u->u_in, i = u->u_nin; i--; sig++, uin++)
- {
- int newrefcount;
- *sig = uin->i_signal;
- newrefcount = --(*sig)->s_refcount;
- /* if the reference count went to zero, we free the signal now,
- unless it's a subcanvas or outlet; these might keep the
- signal around to send to objects connected to them. In this
- case we increment the reference count; the corresponding decrement
- is in sig_makereusable(). */
- if (nofreesigs)
- (*sig)->s_refcount++;
- else if (!newrefcount)
- signal_makereusable(*sig);
- }
- for (sig = outsig, uout = u->u_out, i = u->u_nout; i--; sig++, uout++)
- {
- /* similarly, for outlets of subcanvases we delay creating
- them; instead we create "borrowed" ones so that the refcount
- is known. The subcanvas replaces the fake signal with one showing
- where the output data actually is, to avoid having to copy it.
- For any other object, we just allocate a new output vector;
- since we've already freed the inputs the objects might get called
- "in place." */
- if (nonewsigs)
- {
- *sig = uout->o_signal =
- signal_new(0, dc->dc_srate);
- }
- else
- *sig = uout->o_signal = signal_new(dc->dc_vecsize, dc->dc_srate);
- (*sig)->s_refcount = uout->o_nconnect;
- }
- /* now call the DSP scheduling routine for the ugen. This
- routine must fill in "borrowed" signal outputs in case it's either
- a subcanvas or a signal inlet. */
- mess1(&u->u_obj->ob_pd, gensym("dsp"), insig);
-
- /* if any output signals aren't connected to anyone, free them
- now; otherwise they'll either get freed when the reference count
- goes back to zero, or even later as explained above. */
-
- for (sig = outsig, uout = u->u_out, i = u->u_nout; i--; sig++, uout++)
- {
- if (!(*sig)->s_refcount)
- signal_makereusable(*sig);
- }
- if (ugen_loud)
- {
- if (u->u_nin + u->u_nout == 0) post("put %s %d",
- class_getname(u->u_obj->ob_pd), ugen_index(dc, u));
- else if (u->u_nin + u->u_nout == 1) post("put %s %d (%x)",
- class_getname(u->u_obj->ob_pd), ugen_index(dc, u), sig[0]);
- else if (u->u_nin + u->u_nout == 2) post("put %s %d (%x %x)",
- class_getname(u->u_obj->ob_pd), ugen_index(dc, u),
- sig[0], sig[1]);
- else post("put %s %d (%x %x %x ...)",
- class_getname(u->u_obj->ob_pd), ugen_index(dc, u),
- sig[0], sig[1], sig[2]);
- }
-
- /* pass it on and trip anyone whose last inlet was filled */
- for (uout = u->u_out, i = u->u_nout; i--; uout++)
- {
- s1 = uout->o_signal;
- for (oc = uout->o_connections; oc; oc = oc->oc_next)
- {
- u2 = oc->oc_who;
- uin = &u2->u_in[oc->oc_inno];
- /* if there's already someone here, sum the two */
- if (s2 = uin->i_signal)
- {
- s1->s_refcount--;
- s2->s_refcount--;
- if (!signal_compatible(s1, s2))
- {
- pd_error(u->u_obj, "%s: incompatible signal inputs",
- class_getname(u->u_obj->ob_pd));
- return;
- }
- s3 = signal_newlike(s1);
- dsp_add_plus(s1->s_vec, s2->s_vec, s3->s_vec, s1->s_n);
- uin->i_signal = s3;
- s3->s_refcount = 1;
- if (!s1->s_refcount) signal_makereusable(s1);
- if (!s2->s_refcount) signal_makereusable(s2);
- }
- else uin->i_signal = s1;
- uin->i_ngot++;
- /* if we didn't fill this inlet don't bother yet */
- if (uin->i_ngot < uin->i_nconnect)
- goto notyet;
- /* if there's more than one, check them all */
- if (u2->u_nin > 1)
- {
- for (uin = u2->u_in, n = u2->u_nin; n--; uin++)
- if (uin->i_ngot < uin->i_nconnect) goto notyet;
- }
- /* so now we can schedule the ugen. */
- ugen_doit(dc, u2);
- notyet: ;
- }
- }
- t_freebytes(insig,(u->u_nin + u->u_nout) * sizeof(t_signal *));
- u->u_done = 1;
-}
-
- /* once the DSP graph is built, we call this routine to sort it.
- This routine also deletes the graph; later we might want to leave the
- graph around, in case the user is editing the DSP network, to save having
- to recreate it all the time. But not today. */
-
-void ugen_done_graph(t_dspcontext *dc)
-{
- t_ugenbox *u, *u2;
- t_sigoutlet *uout;
- t_siginlet *uin;
- t_sigoutconnect *oc, *oc2;
- int i, n;
- t_block *blk;
- t_dspcontext *parent_context = dc->dc_parentcontext;
- float parent_srate;
- int parent_vecsize;
- int period, frequency, phase, vecsize;
- float srate;
- int chainblockbegin; /* DSP chain onset before block prolog code */
- int chainblockend; /* and after block epilog code */
- int chainafterall; /* and after signal outlet epilog */
- int reblock = 0, switched;
- int downsample = 1, upsample = 1; /* IOhannes */
- /* debugging printout */
-
- if (ugen_loud)
- {
- post("ugen_done_graph...");
- for (u = dc->dc_ugenlist; u; u = u->u_next)
- {
- post("ugen: %s", class_getname(u->u_obj->ob_pd));
- for (uout = u->u_out, i = 0; i < u->u_nout; uout++, i++)
- for (oc = uout->o_connections; oc; oc = oc->oc_next)
- {
- post("... out %d to %s, index %d, inlet %d", i,
- class_getname(oc->oc_who->u_obj->ob_pd),
- ugen_index(dc, oc->oc_who), oc->oc_inno);
- }
- }
- }
-
- /* search for an object of class "block~" */
- for (u = dc->dc_ugenlist, blk = 0; u; u = u->u_next)
- {
- t_pd *zz = &u->u_obj->ob_pd;
- if (pd_class(zz) == block_class)
- {
- if (blk)
- pd_error(blk, "conflicting block~ objects in same page");
- else blk = (t_block *)zz;
- }
- }
-
- /* figure out block size, calling frequency, sample rate */
- if (parent_context)
- {
- parent_srate = parent_context->dc_srate;
- parent_vecsize = parent_context->dc_vecsize;
- }
- else
- {
- parent_srate = sys_getsr();
- parent_vecsize = sys_getblksize();
- }
- if (blk)
- {
- int realoverlap;
- vecsize = blk->x_vecsize;
- if (vecsize == 0)
- vecsize = parent_vecsize;
- realoverlap = blk->x_overlap;
- if (realoverlap > vecsize) realoverlap = vecsize;
- /* IOhannes { */
- downsample = blk->x_downsample;
- upsample = blk->x_upsample;
- if (downsample > parent_vecsize) downsample=parent_vecsize;
- period = (vecsize * downsample)/
- (parent_vecsize * realoverlap * upsample);
- frequency = (parent_vecsize * realoverlap * upsample)/
- (vecsize * downsample);
- /* } IOhannes*/
- phase = blk->x_phase;
- srate = parent_srate * realoverlap * upsample / downsample;
- /* IOhannes */
- if (period < 1) period = 1;
- if (frequency < 1) frequency = 1;
- blk->x_frequency = frequency;
- blk->x_period = period;
- blk->x_phase = dsp_phase & (period - 1);
- if (! parent_context || (realoverlap != 1) ||
- (vecsize != parent_vecsize) ||
- (downsample != 1) || (upsample != 1)) /* IOhannes */
- reblock = 1;
- switched = blk->x_switched;
- }
- else
- {
- srate = parent_srate;
- vecsize = parent_vecsize;
- downsample = upsample = 1;/* IOhannes */
- period = frequency = 1;
- phase = 0;
- if (!parent_context) reblock = 1;
- switched = 0;
- }
- dc->dc_reblock = reblock;
- dc->dc_switched = switched;
- dc->dc_srate = srate;
- dc->dc_vecsize = vecsize;
-
- /* if we're reblocking or switched, we now have to create output
- signals to fill in for the "borrowed" ones we have now. This
- is also possibly true even if we're not blocked/switched, in
- the case that there was a signal loop. But we don't know this
- yet. */
-
- if (dc->dc_iosigs && (switched || reblock))
- {
- t_signal **sigp;
- for (i = 0, sigp = dc->dc_iosigs + dc->dc_ninlets; i < dc->dc_noutlets;
- i++, sigp++)
- {
- if ((*sigp)->s_isborrowed && !(*sigp)->s_borrowedfrom)
- {
- signal_setborrowed(*sigp,
- signal_new(parent_vecsize, parent_srate));
- (*sigp)->s_refcount++;
-
- if (ugen_loud) post("set %x->%x", *sigp,
- (*sigp)->s_borrowedfrom);
- }
- }
- }
-
- if (ugen_loud)
- post("reblock %d, switched %d", reblock, switched);
-
- /* schedule prologs for inlets and outlets. If the "reblock" flag
- is set, an inlet will put code on the DSP chain to copy its input
- into an internal buffer here, before any unit generators' DSP code
- gets scheduled. If we don't "reblock", inlets will need to get
- pointers to their corresponding inlets/outlets on the box we're inside,
- if any. Outlets will also need pointers, unless we're switched, in
- which case outlet epilog code will kick in. */
-
- for (u = dc->dc_ugenlist; u; u = u->u_next)
- {
- t_pd *zz = &u->u_obj->ob_pd;
- t_signal **insigs = dc->dc_iosigs, **outsigs = dc->dc_iosigs;
- if (outsigs) outsigs += dc->dc_ninlets;
-
- if (pd_class(zz) == vinlet_class)
- vinlet_dspprolog((struct _vinlet *)zz,
- dc->dc_iosigs, vecsize, dsp_phase, period, frequency,
- downsample, upsample, /* IOhannes */
- reblock, switched);
- else if (pd_class(zz) == voutlet_class)
- voutlet_dspprolog((struct _voutlet *)zz,
- outsigs, vecsize, dsp_phase, period, frequency,
- downsample, upsample, /* IOhannes */
- reblock, switched);
- }
- chainblockbegin = dsp_chainsize;
-
- if (blk && (reblock || switched)) /* add the block DSP prolog */
- dsp_add(block_prolog, 1, blk);
-
- /* Initialize for sorting */
- for (u = dc->dc_ugenlist; u; u = u->u_next)
- {
- u->u_done = 0;
- for (uout = u->u_out, i = u->u_nout; i--; uout++)
- uout->o_nsent = 0;
- for (uin = u->u_in, i = u->u_nin; i--; uin++)
- uin->i_ngot = 0, uin->i_signal = 0;
- }
-
- /* Do the sort */
-
- for (u = dc->dc_ugenlist; u; u = u->u_next)
- {
- /* check that we have no connected signal inlets */
- if (u->u_done) continue;
- for (uin = u->u_in, i = u->u_nin; i--; uin++)
- if (uin->i_nconnect) goto next;
-
- ugen_doit(dc, u);
- next: ;
- }
-
- /* check for a DSP loop, which is evidenced here by the presence
- of ugens not yet scheduled. */
-
- for (u = dc->dc_ugenlist; u; u = u->u_next)
- if (!u->u_done)
- {
- t_signal **sigp;
- pd_error(u->u_obj,
- "DSP loop detected (some tilde objects not scheduled)");
- /* this might imply that we have unfilled "borrowed" outputs
- which we'd better fill in now. */
- for (i = 0, sigp = dc->dc_iosigs + dc->dc_ninlets; i < dc->dc_noutlets;
- i++, sigp++)
- {
- if ((*sigp)->s_isborrowed && !(*sigp)->s_borrowedfrom)
- {
- t_signal *s3 = signal_new(parent_vecsize, parent_srate);
- signal_setborrowed(*sigp, s3);
- (*sigp)->s_refcount++;
- dsp_add_zero(s3->s_vec, s3->s_n);
- if (ugen_loud)
- post("oops, belatedly set %x->%x", *sigp,
- (*sigp)->s_borrowedfrom);
- }
- }
- break; /* don't need to keep looking. */
- }
-
- if (blk && (reblock || switched)) /* add block DSP epilog */
- dsp_add(block_epilog, 1, blk);
- chainblockend = dsp_chainsize;
-
- /* add epilogs for outlets. */
-
- for (u = dc->dc_ugenlist; u; u = u->u_next)
- {
- t_pd *zz = &u->u_obj->ob_pd;
- if (pd_class(zz) == voutlet_class)
- {
- t_signal **iosigs = dc->dc_iosigs;
- if (iosigs) iosigs += dc->dc_ninlets;
- voutlet_dspepilog((struct _voutlet *)zz,
- iosigs, vecsize, dsp_phase, period, frequency,
- downsample, upsample, /* IOhannes */
- reblock, switched);
- }
- }
-
- chainafterall = dsp_chainsize;
- if (blk)
- {
- blk->x_blocklength = chainblockend - chainblockbegin;
- blk->x_epiloglength = chainafterall - chainblockend;
- blk->x_reblock = reblock;
- }
-
- if (ugen_loud)
- {
- t_int *ip;
- if (!dc->dc_parentcontext)
- for (i = dsp_chainsize, ip = dsp_chain; i--; ip++)
- post("chain %x", *ip);
- post("... ugen_done_graph done.");
- }
- /* now delete everything. */
- while (dc->dc_ugenlist)
- {
- for (uout = dc->dc_ugenlist->u_out, n = dc->dc_ugenlist->u_nout;
- n--; uout++)
- {
- oc = uout->o_connections;
- while (oc)
- {
- oc2 = oc->oc_next;
- freebytes(oc, sizeof *oc);
- oc = oc2;
- }
- }
- freebytes(dc->dc_ugenlist->u_out, dc->dc_ugenlist->u_nout *
- sizeof (*dc->dc_ugenlist->u_out));
- freebytes(dc->dc_ugenlist->u_in, dc->dc_ugenlist->u_nin *
- sizeof(*dc->dc_ugenlist->u_in));
- u = dc->dc_ugenlist;
- dc->dc_ugenlist = u->u_next;
- freebytes(u, sizeof *u);
- }
- if (ugen_currentcontext == dc)
- ugen_currentcontext = dc->dc_parentcontext;
- else bug("ugen_currentcontext");
- freebytes(dc, sizeof(*dc));
-
-}
-
-t_signal *ugen_getiosig(int index, int inout)
-{
- if (!ugen_currentcontext) bug("ugen_getiosig");
- if (ugen_currentcontext->dc_toplevel) return (0);
- if (inout) index += ugen_currentcontext->dc_ninlets;
- return (ugen_currentcontext->dc_iosigs[index]);
-}
-
-
-/* -------------------- setup routine -------------------------- */
-
-void d_ugen_setup(void) /* really just block_setup */
-{
- block_class = class_new(gensym("block~"), (t_newmethod)block_new, 0,
- sizeof(t_block), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT/*IOhannes*/, 0);
- class_addcreator((t_newmethod)switch_new, gensym("switch~"),
- A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT/*IOhannes*/, 0);
- class_addmethod(block_class, (t_method)block_set, gensym("set"),
- A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addmethod(block_class, (t_method)block_dsp, gensym("dsp"), 0);
- class_addfloat(block_class, block_float);
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/delme.pd b/apps/plugins/pdbox/PDa/src/delme.pd
index 8e2c4f240c..1d4b9fa031 100644
--- a/apps/plugins/pdbox/PDa/src/delme.pd
+++ b/apps/plugins/pdbox/PDa/src/delme.pd
@@ -6,11 +6,4 @@
#X connect 0 0 1 0;
#X connect 0 1 2 0;
#X connect 0 2 3 0;
-#N canvas 0 0 236 296 10;
-#X obj 79 77 gcanvas 80 80 0 0;
-#X floatatom 42 209 5 0 0 0 - - -;
-#X floatatom 107 205 5 0 0 0 - - -;
-#X floatatom 149 210 5 0 0 0 - - -;
-#X connect 0 0 1 0;
-#X connect 0 1 2 0;
-#X connect 0 2 3 0;
+
diff --git a/apps/plugins/pdbox/PDa/src/g_all_guis.c b/apps/plugins/pdbox/PDa/src/g_all_guis.c
index 9254bafebd..74a7656492 100644
--- a/apps/plugins/pdbox/PDa/src/g_all_guis.c
+++ b/apps/plugins/pdbox/PDa/src/g_all_guis.c
@@ -660,665 +660,4 @@ int iem_fstyletoint(t_iem_fstyle_flags *fstylep)
{
return ((fstylep->x_font_style << 0) & 63);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-#ifdef MSW
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-/* #define GGEE_HSLIDER_COMPATIBLE */
-
-/*------------------ global varaibles -------------------------*/
-
-int iemgui_color_hex[]=
-{
- 16579836, 10526880, 4210752, 16572640, 16572608,
- 16579784, 14220504, 14220540, 14476540, 16308476,
- 14737632, 8158332, 2105376, 16525352, 16559172,
- 15263784, 1370132, 2684148, 3952892, 16003312,
- 12369084, 6316128, 0, 9177096, 5779456,
- 7874580, 2641940, 17488, 5256, 5767248
-};
-
-int iemgui_vu_db2i[]=
-{
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 9, 9, 9, 9, 9,10,10,10,10,10,
- 11,11,11,11,11,12,12,12,12,12,
- 13,13,13,13,14,14,14,14,15,15,
- 15,15,16,16,16,16,17,17,17,18,
- 18,18,19,19,19,20,20,20,21,21,
- 22,22,23,23,24,24,25,26,27,28,
- 29,30,31,32,33,33,34,34,35,35,
- 36,36,37,37,37,38,38,38,39,39,
- 39,39,39,39,40,40
-};
-
-int iemgui_vu_col[]=
-{
- 0,17,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
- 15,15,15,15,15,15,15,15,15,15,14,14,13,13,13,13,13,13,13,13,13,13,13,19,19,19
-};
-
-char *iemgui_vu_scale_str[]=
-{
- "",
- "<-99",
- "",
- "",
- "",
- "-50",
- "",
- "",
- "",
- "-30",
- "",
- "",
- "",
- "-20",
- "",
- "",
- "",
- "-12",
- "",
- "",
- "",
- "-6",
- "",
- "",
- "",
- "-2",
- "",
- "",
- "",
- "-0dB",
- "",
- "",
- "",
- "+2",
- "",
- "",
- "",
- "+6",
- "",
- "",
- "",
- ">+12",
- "",
- "",
- "",
- "",
- "",
-};
-
-
-/*------------------ global functions -------------------------*/
-
-int iemgui_clip_size(int size)
-{
- if(size < IEM_GUI_MINSIZE)
- size = IEM_GUI_MINSIZE;
- return(size);
-}
-
-int iemgui_clip_font(int size)
-{
- if(size < IEM_FONT_MINSIZE)
- size = IEM_FONT_MINSIZE;
- return(size);
-}
-
-int iemgui_modulo_color(int col)
-{
- while(col >= IEM_GUI_MAX_COLOR)
- col -= IEM_GUI_MAX_COLOR;
- while(col < 0)
- col += IEM_GUI_MAX_COLOR;
- return(col);
-}
-
-t_symbol *iemgui_raute2dollar(t_symbol *s)
-{
- if (s->s_name[0] == '#')
- {
- char buf[MAXPDSTRING];
- strncpy(buf, s->s_name, MAXPDSTRING);
- buf[MAXPDSTRING-1] = 0;
- buf[0] = '$';
- return (gensym(buf));
- }
- else return (s);
-}
-
-t_symbol *iemgui_dollar2raute(t_symbol *s)
-{
- if (s->s_name[0] == '$')
- {
- char buf[MAXPDSTRING];
- strncpy(buf, s->s_name, MAXPDSTRING);
- buf[MAXPDSTRING-1] = 0;
- buf[0] = '#';
- return (gensym(buf));
- }
- else return (s);
-}
-
-void iemgui_verify_snd_ne_rcv(t_iemgui *iemgui)
-{
- iemgui->x_fsf.x_put_in2out = 1;
- if(iemgui->x_fsf.x_snd_able && iemgui->x_fsf.x_rcv_able)
- {
- if(!strcmp(iemgui->x_snd->s_name, iemgui->x_rcv->s_name))
- iemgui->x_fsf.x_put_in2out = 0;
- }
-}
-
-t_symbol *iemgui_new_dogetname(t_iemgui *iemgui, int indx, t_atom *argv)
-{
- if (IS_A_SYMBOL(argv, indx))
- return (atom_getsymbolarg(indx, 100000, argv));
- else if (IS_A_FLOAT(argv, indx))
- {
- char str[80];
- sprintf(str, "%d", (int)atom_getintarg(indx, 100000, argv));
- return (gensym(str));
- }
- else return (gensym("empty"));
-}
-
-void iemgui_new_getnames(t_iemgui *iemgui, int indx, t_atom *argv)
-{
- if (argv)
- {
- iemgui->x_snd = iemgui_new_dogetname(iemgui, indx, argv);
- iemgui->x_rcv = iemgui_new_dogetname(iemgui, indx+1, argv);
- iemgui->x_lab = iemgui_new_dogetname(iemgui, indx+2, argv);
- }
- else iemgui->x_snd = iemgui->x_rcv = iemgui->x_lab = gensym("empty");
- iemgui->x_snd_unexpanded = iemgui->x_rcv_unexpanded =
- iemgui->x_lab_unexpanded = 0;
- iemgui->x_binbufindex = indx;
- iemgui->x_labelbindex = indx + 3;
-}
-
- /* convert symbols in "$" form to the expanded symbols */
-void iemgui_all_dollararg2sym(t_iemgui *iemgui, t_symbol **srlsym)
-{
- /* save unexpanded ones for later */
- iemgui->x_snd_unexpanded = srlsym[0];
- iemgui->x_rcv_unexpanded = srlsym[1];
- iemgui->x_lab_unexpanded = srlsym[2];
- srlsym[0] = canvas_realizedollar(iemgui->x_glist, srlsym[0]);
- srlsym[1] = canvas_realizedollar(iemgui->x_glist, srlsym[1]);
- srlsym[2] = canvas_realizedollar(iemgui->x_glist, srlsym[2]);
-}
-
- /* initialize a single symbol in unexpanded form. We reach into the
- binbuf to grab them; if there's nothing there, set it to the
- fallback; if still nothing, set to "empty". */
-static void iemgui_init_sym2dollararg(t_iemgui *iemgui, t_symbol **symp,
- int indx, t_symbol *fallback)
-{
- if (!*symp)
- {
- t_binbuf *b = iemgui->x_obj.ob_binbuf;
- if (binbuf_getnatom(b) > indx)
- {
- char buf[80];
- atom_string(binbuf_getvec(b) + indx, buf, 80);
- *symp = gensym(buf);
- }
- else if (fallback)
- *symp = fallback;
- else *symp = gensym("empty");
- }
-}
-
- /* get the unexpanded versions of the symbols; initialize them if
- necessary. */
-void iemgui_all_sym2dollararg(t_iemgui *iemgui, t_symbol **srlsym)
-{
- iemgui_init_sym2dollararg(iemgui, &iemgui->x_snd_unexpanded,
- iemgui->x_binbufindex+1, iemgui->x_snd);
- iemgui_init_sym2dollararg(iemgui, &iemgui->x_rcv_unexpanded,
- iemgui->x_binbufindex+2, iemgui->x_rcv);
- iemgui_init_sym2dollararg(iemgui, &iemgui->x_lab_unexpanded,
- iemgui->x_labelbindex, iemgui->x_lab);
- srlsym[0] = iemgui->x_snd_unexpanded;
- srlsym[1] = iemgui->x_rcv_unexpanded;
- srlsym[2] = iemgui->x_lab_unexpanded;
-}
-
-void iemgui_first_dollararg2sym(t_iemgui *iemgui, t_symbol **srlsym)
-{
- /* delete this function */
-}
-
-void iemgui_all_col2save(t_iemgui *iemgui, int *bflcol)
-{
- bflcol[0] = -1 - (((0xfc0000 & iemgui->x_bcol) >> 6)|
- ((0xfc00 & iemgui->x_bcol) >> 4)|((0xfc & iemgui->x_bcol) >> 2));
- bflcol[1] = -1 - (((0xfc0000 & iemgui->x_fcol) >> 6)|
- ((0xfc00 & iemgui->x_fcol) >> 4)|((0xfc & iemgui->x_fcol) >> 2));
- bflcol[2] = -1 - (((0xfc0000 & iemgui->x_lcol) >> 6)|
- ((0xfc00 & iemgui->x_lcol) >> 4)|((0xfc & iemgui->x_lcol) >> 2));
-}
-
-void iemgui_all_colfromload(t_iemgui *iemgui, int *bflcol)
-{
- if(bflcol[0] < 0)
- {
- bflcol[0] = -1 - bflcol[0];
- iemgui->x_bcol = ((bflcol[0] & 0x3f000) << 6)|((bflcol[0] & 0xfc0) << 4)|
- ((bflcol[0] & 0x3f) << 2);
- }
- else
- {
- bflcol[0] = iemgui_modulo_color(bflcol[0]);
- iemgui->x_bcol = iemgui_color_hex[bflcol[0]];
- }
- if(bflcol[1] < 0)
- {
- bflcol[1] = -1 - bflcol[1];
- iemgui->x_fcol = ((bflcol[1] & 0x3f000) << 6)|((bflcol[1] & 0xfc0) << 4)|
- ((bflcol[1] & 0x3f) << 2);
- }
- else
- {
- bflcol[1] = iemgui_modulo_color(bflcol[1]);
- iemgui->x_fcol = iemgui_color_hex[bflcol[1]];
- }
- if(bflcol[2] < 0)
- {
- bflcol[2] = -1 - bflcol[2];
- iemgui->x_lcol = ((bflcol[2] & 0x3f000) << 6)|((bflcol[2] & 0xfc0) << 4)|
- ((bflcol[2] & 0x3f) << 2);
- }
- else
- {
- bflcol[2] = iemgui_modulo_color(bflcol[2]);
- iemgui->x_lcol = iemgui_color_hex[bflcol[2]];
- }
-}
-
-int iemgui_compatible_col(int i)
-{
- int j;
-
- if(i >= 0)
- {
- j = iemgui_modulo_color(i);
- return(iemgui_color_hex[(j)]);
- }
- else
- return((-1 -i)&0xffffff);
-}
-
-void iemgui_all_dollar2raute(t_symbol **srlsym)
-{
- srlsym[0] = iemgui_dollar2raute(srlsym[0]);
- srlsym[1] = iemgui_dollar2raute(srlsym[1]);
- srlsym[2] = iemgui_dollar2raute(srlsym[2]);
-}
-
-void iemgui_all_raute2dollar(t_symbol **srlsym)
-{
- srlsym[0] = iemgui_raute2dollar(srlsym[0]);
- srlsym[1] = iemgui_raute2dollar(srlsym[1]);
- srlsym[2] = iemgui_raute2dollar(srlsym[2]);
-}
-
-void iemgui_send(void *x, t_iemgui *iemgui, t_symbol *s)
-{
- t_symbol *snd;
- int pargc, tail_len, nth_arg, sndable=1, oldsndrcvable=0;
- t_atom *pargv;
-
- if(iemgui->x_fsf.x_rcv_able)
- oldsndrcvable += IEM_GUI_OLD_RCV_FLAG;
- if(iemgui->x_fsf.x_snd_able)
- oldsndrcvable += IEM_GUI_OLD_SND_FLAG;
-
- if(!strcmp(s->s_name, "empty")) sndable = 0;
- snd = iemgui_raute2dollar(s);
- 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);
- (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_IO + oldsndrcvable);
-}
-
-void iemgui_receive(void *x, t_iemgui *iemgui, t_symbol *s)
-{
- t_symbol *rcv;
- int pargc, tail_len, nth_arg, rcvable=1, oldsndrcvable=0;
- t_atom *pargv;
-
- if(iemgui->x_fsf.x_rcv_able)
- oldsndrcvable += IEM_GUI_OLD_RCV_FLAG;
- if(iemgui->x_fsf.x_snd_able)
- oldsndrcvable += IEM_GUI_OLD_SND_FLAG;
-
- if(!strcmp(s->s_name, "empty")) rcvable = 0;
- rcv = iemgui_raute2dollar(s);
- iemgui->x_rcv_unexpanded = rcv;
- iemgui->x_rcv = rcv = canvas_realizedollar(iemgui->x_glist, rcv);
- if(rcvable)
- {
- if(strcmp(rcv->s_name, iemgui->x_rcv->s_name))
- {
- if(iemgui->x_fsf.x_rcv_able)
- pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv);
- iemgui->x_rcv = rcv;
- pd_bind(&iemgui->x_obj.ob_pd, iemgui->x_rcv);
- }
- }
- else if(!rcvable && iemgui->x_fsf.x_rcv_able)
- {
- pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv);
- iemgui->x_rcv = rcv;
- }
- iemgui->x_fsf.x_rcv_able = rcvable;
- iemgui_verify_snd_ne_rcv(iemgui);
- (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_IO + oldsndrcvable);
-}
-
-void iemgui_label(void *x, t_iemgui *iemgui, t_symbol *s)
-{
- t_symbol *lab;
- int pargc, tail_len, nth_arg;
- t_atom *pargv;
-
- lab = iemgui_raute2dollar(s);
- iemgui->x_lab_unexpanded = lab;
- iemgui->x_lab = lab = canvas_realizedollar(iemgui->x_glist, lab);
-
- if(glist_isvisible(iemgui->x_glist))
- sys_vgui(".x%x.c itemconfigure %xLABEL -text {%s} \n",
- glist_getcanvas(iemgui->x_glist), x,
- strcmp(s->s_name, "empty")?iemgui->x_lab->s_name:"");
-}
-
-void iemgui_label_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
-{
- iemgui->x_ldx = (int)atom_getintarg(0, ac, av);
- iemgui->x_ldy = (int)atom_getintarg(1, ac, av);
- if(glist_isvisible(iemgui->x_glist))
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- glist_getcanvas(iemgui->x_glist), x,
- iemgui->x_obj.te_xpix+iemgui->x_ldx,
- iemgui->x_obj.te_ypix+iemgui->x_ldy);
-}
-
-void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
-{
- int f = (int)atom_getintarg(0, ac, av);
-
- if(f == 1) strcpy(iemgui->x_font, "helvetica");
- else if(f == 2) strcpy(iemgui->x_font, "times");
- else
- {
- f = 0;
- strcpy(iemgui->x_font, "courier");
- }
- iemgui->x_fsf.x_font_style = f;
- f = (int)atom_getintarg(1, ac, av);
- if(f < 4)
- f = 4;
- iemgui->x_fontsize = f;
- if(glist_isvisible(iemgui->x_glist))
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold}\n",
- glist_getcanvas(iemgui->x_glist), x, iemgui->x_font, iemgui->x_fontsize);
-}
-
-void iemgui_size(void *x, t_iemgui *iemgui)
-{
- if(glist_isvisible(iemgui->x_glist))
- {
- (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x);
- }
-}
-
-void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
-{
- iemgui->x_obj.te_xpix += (int)atom_getintarg(0, ac, av);
- iemgui->x_obj.te_ypix += (int)atom_getintarg(1, ac, av);
- if(glist_isvisible(iemgui->x_glist))
- {
- (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x);
- }
-}
-
-void iemgui_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
-{
- iemgui->x_obj.te_xpix = (int)atom_getintarg(0, ac, av);
- iemgui->x_obj.te_ypix = (int)atom_getintarg(1, ac, av);
- if(glist_isvisible(iemgui->x_glist))
- {
- (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x);
- }
-}
-
-void iemgui_color(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av)
-{
- iemgui->x_bcol = iemgui_compatible_col(atom_getintarg(0, ac, av));
- if(ac > 2)
- {
- iemgui->x_fcol = iemgui_compatible_col(atom_getintarg(1, ac, av));
- iemgui->x_lcol = iemgui_compatible_col(atom_getintarg(2, ac, av));
- }
- else
- iemgui->x_lcol = iemgui_compatible_col(atom_getintarg(1, ac, av));
- if(glist_isvisible(iemgui->x_glist))
- (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_CONFIG);
-}
-
-void iemgui_displace(t_gobj *z, t_glist *glist, int dx, int dy)
-{
- t_iemguidummy *x = (t_iemguidummy *)z;
-
- x->x_gui.x_obj.te_xpix += dx;
- x->x_gui.x_obj.te_ypix += dy;
- (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(glist), (t_text *)z);
-}
-
-void iemgui_select(t_gobj *z, t_glist *glist, int selected)
-{
- t_iemguidummy *x = (t_iemguidummy *)z;
-
- x->x_gui.x_fsf.x_selected = selected;
- (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_SELECT);
-}
-
-void iemgui_delete(t_gobj *z, t_glist *glist)
-{
- canvas_deletelinesfor(glist, (t_text *)z);
-}
-
-void iemgui_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_iemguidummy *x = (t_iemguidummy *)z;
-
- if (vis)
- (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_NEW);
- else
- (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_ERASE);
-}
-
-void iemgui_save(t_iemgui *iemgui, t_symbol **srl, int *bflcol)
-{
- srl[0] = iemgui->x_snd;
- srl[1] = iemgui->x_rcv;
- srl[2] = iemgui->x_lab;
- iemgui_all_sym2dollararg(iemgui, srl);
- iemgui_all_col2save(iemgui, bflcol);
-}
-
-void iemgui_properties(t_iemgui *iemgui, t_symbol **srl)
-{
- srl[0] = iemgui->x_snd;
- srl[1] = iemgui->x_rcv;
- srl[2] = iemgui->x_lab;
- iemgui_all_sym2dollararg(iemgui, srl);
- iemgui_all_dollar2raute(srl);
-}
-
-int iemgui_dialog(t_iemgui *iemgui, t_symbol **srl, int argc, t_atom *argv)
-{
- char str[144];
- int init = (int)atom_getintarg(5, argc, argv);
- int ldx = (int)atom_getintarg(10, argc, argv);
- int ldy = (int)atom_getintarg(11, argc, argv);
- int f = (int)atom_getintarg(12, argc, argv);
- int fs = (int)atom_getintarg(13, argc, argv);
- int bcol = (int)atom_getintarg(14, argc, argv);
- int fcol = (int)atom_getintarg(15, argc, argv);
- int lcol = (int)atom_getintarg(16, argc, argv);
- int sndable=1, rcvable=1, oldsndrcvable=0;
-
- if(iemgui->x_fsf.x_rcv_able)
- oldsndrcvable += IEM_GUI_OLD_RCV_FLAG;
- if(iemgui->x_fsf.x_snd_able)
- oldsndrcvable += IEM_GUI_OLD_SND_FLAG;
- if(IS_A_SYMBOL(argv,7))
- srl[0] = atom_getsymbolarg(7, argc, argv);
- else if(IS_A_FLOAT(argv,7))
- {
- sprintf(str, "%d", (int)atom_getintarg(7, argc, argv));
- srl[0] = gensym(str);
- }
- if(IS_A_SYMBOL(argv,8))
- srl[1] = atom_getsymbolarg(8, argc, argv);
- else if(IS_A_FLOAT(argv,8))
- {
- sprintf(str, "%d", (int)atom_getintarg(8, argc, argv));
- srl[1] = gensym(str);
- }
- if(IS_A_SYMBOL(argv,9))
- srl[2] = atom_getsymbolarg(9, argc, argv);
- else if(IS_A_FLOAT(argv,9))
- {
- sprintf(str, "%d", (int)atom_getintarg(9, argc, argv));
- srl[2] = gensym(str);
- }
- if(init != 0) init = 1;
- iemgui->x_isa.x_loadinit = init;
- if(!strcmp(srl[0]->s_name, "empty")) sndable = 0;
- if(!strcmp(srl[1]->s_name, "empty")) rcvable = 0;
- iemgui_all_raute2dollar(srl);
- iemgui_all_dollararg2sym(iemgui, srl);
- if(rcvable)
- {
- if(strcmp(srl[1]->s_name, iemgui->x_rcv->s_name))
- {
- if(iemgui->x_fsf.x_rcv_able)
- pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv);
- iemgui->x_rcv = srl[1];
- pd_bind(&iemgui->x_obj.ob_pd, iemgui->x_rcv);
- }
- }
- else if(!rcvable && iemgui->x_fsf.x_rcv_able)
- {
- pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv);
- iemgui->x_rcv = srl[1];
- }
- iemgui->x_snd = srl[0];
- iemgui->x_fsf.x_snd_able = sndable;
- iemgui->x_fsf.x_rcv_able = rcvable;
- iemgui->x_lcol = lcol & 0xffffff;
- iemgui->x_fcol = fcol & 0xffffff;
- iemgui->x_bcol = bcol & 0xffffff;
- iemgui->x_lab = srl[2];
- iemgui->x_ldx = ldx;
- iemgui->x_ldy = ldy;
- if(f == 1) strcpy(iemgui->x_font, "helvetica");
- else if(f == 2) strcpy(iemgui->x_font, "times");
- else
- {
- f = 0;
- strcpy(iemgui->x_font, "courier");
- }
- iemgui->x_fsf.x_font_style = f;
- if(fs < 4)
- fs = 4;
- iemgui->x_fontsize = fs;
- iemgui_verify_snd_ne_rcv(iemgui);
- return(oldsndrcvable);
-}
-
-void iem_inttosymargs(t_iem_init_symargs *symargp, int n)
-{
- memset(symargp, 0, sizeof(*symargp));
- symargp->x_loadinit = (n >> 0);
- symargp->x_scale = (n >> 20);
- symargp->x_flashed = 0;
- symargp->x_locked = 0;
- symargp->x_reverse = 0;
- symargp->dummy = 0;
-}
-
-int iem_symargstoint(t_iem_init_symargs *symargp)
-{
- return (
- (((symargp->x_loadinit & 1) << 0) |
- ((symargp->x_scale & 1) << 20)));
-}
-
-void iem_inttofstyle(t_iem_fstyle_flags *fstylep, int n)
-{
- memset(fstylep, 0, sizeof(*fstylep));
- fstylep->x_font_style = (n >> 0);
- fstylep->x_shiftdown = 0;
- fstylep->x_selected = 0;
- fstylep->x_finemoved = 0;
- fstylep->x_put_in2out = 0;
- fstylep->x_change = 0;
- fstylep->x_thick = 0;
- fstylep->x_lin0_log1 = 0;
- fstylep->x_steady = 0;
- fstylep->dummy = 0;
-}
-
-int iem_fstyletoint(t_iem_fstyle_flags *fstylep)
-{
- return ((fstylep->x_font_style << 0) & 63);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_all_guis.h b/apps/plugins/pdbox/PDa/src/g_all_guis.h
index 6d03ee9d3b..3779f1c20a 100644
--- a/apps/plugins/pdbox/PDa/src/g_all_guis.h
+++ b/apps/plugins/pdbox/PDa/src/g_all_guis.h
@@ -327,332 +327,4 @@ EXTERN void iem_inttosymargs(t_iem_init_symargs *symargp, int n);
EXTERN int iem_symargstoint(t_iem_init_symargs *symargp);
EXTERN void iem_inttofstyle(t_iem_fstyle_flags *fstylep, int n);
EXTERN int iem_fstyletoint(t_iem_fstyle_flags *fstylep);
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-/* g_7_guis.h written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-
-
-#define IEM_GUI_COLNR_WHITE 0
-#define IEM_GUI_COLNR_ML_GREY 1
-#define IEM_GUI_COLNR_D_GREY 2
-#define IEM_GUI_COLNR_L_RED 3
-#define IEM_GUI_COLNR_L_ORANGE 4
-#define IEM_GUI_COLNR_L_YELLOW 5
-#define IEM_GUI_COLNR_L_GREEN 6
-#define IEM_GUI_COLNR_L_CYAN 7
-#define IEM_GUI_COLNR_L_BLUE 8
-#define IEM_GUI_COLNR_L_MAGENTA 9
-
-#define IEM_GUI_COLNR_LL_GREY 10
-#define IEM_GUI_COLNR_M_GREY 11
-#define IEM_GUI_COLNR_DD_GREY 12
-#define IEM_GUI_COLNR_RED 13
-#define IEM_GUI_COLNR_ORANGE 14
-#define IEM_GUI_COLNR_YELLOW 15
-#define IEM_GUI_COLNR_GREEN 16
-#define IEM_GUI_COLNR_CYAN 17
-#define IEM_GUI_COLNR_BLUE 18
-#define IEM_GUI_COLNR_MAGENTA 19
-
-#define IEM_GUI_COLNR_L_GREY 20
-#define IEM_GUI_COLNR_MD_GREY 21
-#define IEM_GUI_COLNR_BLACK 22
-#define IEM_GUI_COLNR_D_RED 23
-#define IEM_GUI_COLNR_D_ORANGE 24
-#define IEM_GUI_COLNR_D_YELLOW 25
-#define IEM_GUI_COLNR_D_GREEN 26
-#define IEM_GUI_COLNR_D_CYAN 27
-#define IEM_GUI_COLNR_D_BLUE 28
-#define IEM_GUI_COLNR_D_MAGENTA 29
-
-#define IEM_GUI_COLOR_SELECTED 255
-#define IEM_GUI_COLOR_NORMAL 0
-
-#define IEM_GUI_MAX_COLOR 30
-
-#define IEM_GUI_DEFAULTSIZE 15
-#define IEM_GUI_MINSIZE 8
-#define IEM_GUI_MAXSIZE 1000
-#define IEM_SL_DEFAULTSIZE 128
-#define IEM_SL_MINSIZE 2
-#define IEM_FONT_MINSIZE 4
-
-#define IEM_BNG_DEFAULTHOLDFLASHTIME 250
-#define IEM_BNG_DEFAULTBREAKFLASHTIME 50
-#define IEM_BNG_MINHOLDFLASHTIME 50
-#define IEM_BNG_MINBREAKFLASHTIME 10
-
-#define IEM_VU_DEFAULTSIZE 3
-#define IEM_VU_LARGESMALL 2
-#define IEM_VU_MINSIZE 2
-#define IEM_VU_MAXSIZE 25
-#define IEM_VU_STEPS 40
-
-#define IEM_VU_MINDB -99.9
-#define IEM_VU_MAXDB 12.0
-#define IEM_VU_OFFSET 100.0
-
-#define IEM_RADIO_MAX 128
-
-#define IEM_SYM_UNIQUE_SND 256
-#define IEM_SYM_UNIQUE_RCV 512
-#define IEM_SYM_UNIQUE_LAB 1024
-#define IEM_SYM_UNIQUE_ALL 1792
-#define IEM_FONT_STYLE_ALL 255
-
-#define IEM_MAX_SYM_LEN 127
-
-#define IEM_GUI_DRAW_MODE_UPDATE 0
-#define IEM_GUI_DRAW_MODE_MOVE 1
-#define IEM_GUI_DRAW_MODE_NEW 2
-#define IEM_GUI_DRAW_MODE_SELECT 3
-#define IEM_GUI_DRAW_MODE_ERASE 4
-#define IEM_GUI_DRAW_MODE_CONFIG 5
-#define IEM_GUI_DRAW_MODE_IO 6
-
-
-#define IS_A_POINTER(atom,index) ((atom+index)->a_type == A_POINTER)
-#define IS_A_FLOAT(atom,index) ((atom+index)->a_type == A_FLOAT)
-#define IS_A_SYMBOL(atom,index) ((atom+index)->a_type == A_SYMBOL)
-#define IS_A_DOLLAR(atom,index) ((atom+index)->a_type == A_DOLLAR)
-#define IS_A_DOLLSYM(atom,index) ((atom+index)->a_type == A_DOLLSYM)
-
-#define IEM_FSTYLE_FLAGS_ALL 0x007fffff
-#define IEM_INIT_ARGS_ALL 0x01ffffff
-
-#define IEM_GUI_OLD_SND_FLAG 1
-#define IEM_GUI_OLD_RCV_FLAG 2
-
-#define IEM_GUI_COLOR_EDITED 16711680
-#define IEMGUI_MAX_NUM_LEN 32
-
-typedef struct _iem_fstyle_flags
-{
- unsigned int x_font_style:6;
- unsigned int x_rcv_able:1;
- unsigned int x_snd_able:1;
- unsigned int x_lab_is_unique:1;
- unsigned int x_rcv_is_unique:1;
- unsigned int x_snd_is_unique:1;
- unsigned int x_lab_arg_tail_len:6;
- unsigned int x_lab_is_arg_num:6;
- unsigned int x_shiftdown:1;
- unsigned int x_selected:1;
- unsigned int x_finemoved:1;
- unsigned int x_put_in2out:1;
- unsigned int x_change:1;
- unsigned int x_thick:1;
- unsigned int x_lin0_log1:1;
- unsigned int x_steady:1;
- unsigned int dummy:1;
-} t_iem_fstyle_flags;
-
-typedef struct _iem_init_symargs
-{
- unsigned int x_loadinit:1;
- unsigned int x_rcv_arg_tail_len:6;
- unsigned int x_snd_arg_tail_len:6;
- unsigned int x_rcv_is_arg_num:6;
- unsigned int x_snd_is_arg_num:6;
- unsigned int x_scale:1;
- unsigned int x_flashed:1;
- unsigned int x_locked:1;
- unsigned int x_reverse:1; /* bugfix */
- unsigned int dummy:3;
-} t_iem_init_symargs;
-
-typedef void (*t_iemfunptr)(void *x, t_glist *glist, int mode);
-
-typedef struct _iemgui
-{
- t_object x_obj;
- t_glist *x_glist;
- t_iemfunptr x_draw;
- int x_h;
- int x_w;
- int x_ldx;
- int x_ldy;
- char x_font[16];
- t_iem_fstyle_flags x_fsf;
- int x_fontsize;
- t_iem_init_symargs x_isa;
- int x_fcol;
- int x_bcol;
- int x_lcol;
- t_symbol *x_snd; /* send symbol */
- t_symbol *x_rcv; /* receive */
- t_symbol *x_lab; /* label */
- t_symbol *x_snd_unexpanded; /* same 3, with '$' unexpanded */
- t_symbol *x_rcv_unexpanded;
- t_symbol *x_lab_unexpanded;
- int x_binbufindex; /* where in binbuf to find these */
- int x_labelbindex; /* where in binbuf to find label */
-} t_iemgui;
-
-typedef struct _iemguidummy
-{
- t_iemgui x_gui;
- int x_dum1;
- int x_dum2;
- int x_dum3;
-} t_iemguidummy;
-
-typedef struct _bng
-{
- t_iemgui x_gui;
- int x_flashed;
- int x_flashtime_break;
- int x_flashtime_hold;
- t_clock *x_clock_hld;
- t_clock *x_clock_brk;
- t_clock *x_clock_lck;
-} t_bng;
-
-typedef struct _hslider
-{
- t_iemgui x_gui;
- int x_pos;
- int x_val;
- int x_center;
- int x_thick;
- int x_lin0_log1;
- int x_steady;
- double x_min;
- double x_max;
- double x_k;
-} t_hslider;
-
-typedef struct _hdial
-{
- t_iemgui x_gui;
- int x_on;
- int x_on_old;
- int x_change;
- int x_number;
- t_atom x_at[2];
-} t_hdial;
-
-typedef struct _toggle
-{
- t_iemgui x_gui;
- float x_on;
- float x_nonzero;
-} t_toggle;
-
-typedef struct _my_canvas
-{
- t_iemgui x_gui;
- t_atom x_at[3];
- int x_vis_w;
- int x_vis_h;
-} t_my_canvas;
-
-typedef struct _vslider
-{
- t_iemgui x_gui;
- int x_pos;
- int x_val;
- int x_lin0_log1;
- int x_steady;
- double x_min;
- double x_max;
- double x_k;
-} t_vslider;
-
-typedef struct _vu
-{
- t_iemgui x_gui;
- int x_led_size;
- int x_peak;
- int x_rms;
- float x_fp;
- float x_fr;
- int x_scale;
- void *x_out_rms;
- void *x_out_peak;
-} t_vu;
-
-typedef struct _my_numbox
-{
- t_iemgui x_gui;
- t_clock *x_clock_reset;
- t_clock *x_clock_wait;
- double x_val;
- double x_min;
- double x_max;
- double x_k;
- int x_lin0_log1;
- char x_buf[IEMGUI_MAX_NUM_LEN];
- int x_numwidth;
- int x_log_height;
-} t_my_numbox;
-
-typedef struct _vdial
-{
- t_iemgui x_gui;
- int x_on;
- int x_on_old;
- int x_change;
- int x_number;
- t_atom x_at[2];
-} t_vdial;
-
-#define t_vradio t_vdial
-#define t_hradio t_hdial
-
-extern int sys_noloadbang;
-extern int iemgui_color_hex[];
-extern int iemgui_vu_db2i[];
-extern int iemgui_vu_col[];
-extern char *iemgui_vu_scale_str[];
-
-EXTERN int iemgui_clip_size(int size);
-EXTERN int iemgui_clip_font(int size);
-EXTERN int iemgui_modulo_color(int col);
-EXTERN t_symbol *iemgui_unique2dollarzero(t_symbol *s, int unique_num, int and_unique_flag);
-EXTERN t_symbol *iemgui_sym2dollararg(t_symbol *s, int nth_arg, int tail_len);
-EXTERN t_symbol *iemgui_dollarzero2unique(t_symbol *s, int unique_num);
-EXTERN t_symbol *iemgui_dollararg2sym(t_symbol *s, int nth_arg, int tail_len, int pargc, t_atom *pargv);
-EXTERN int iemgui_is_dollarzero(t_symbol *s);
-EXTERN int iemgui_is_dollararg(t_symbol *s, int *tail_len);
-EXTERN void iemgui_fetch_unique(t_iemgui *iemgui);
-EXTERN void iemgui_fetch_parent_args(t_iemgui *iemgui, int *pargc, t_atom **pargv);
-EXTERN void iemgui_verify_snd_ne_rcv(t_iemgui *iemgui);
-EXTERN void iemgui_all_unique2dollarzero(t_iemgui *iemgui, t_symbol **srlsym);
-EXTERN void iemgui_all_sym2dollararg(t_iemgui *iemgui, t_symbol **srlsym);
-EXTERN void iemgui_all_dollarzero2unique(t_iemgui *iemgui, t_symbol **srlsym);
-EXTERN t_symbol *iemgui_new_dogetname(t_iemgui *iemgui, int indx, t_atom *argv);
-EXTERN void iemgui_new_getnames(t_iemgui *iemgui, int indx, t_atom *argv);
-EXTERN void iemgui_all_dollararg2sym(t_iemgui *iemgui, t_symbol **srlsym);
-EXTERN void iemgui_first_dollararg2sym(t_iemgui *iemgui, t_symbol **srlsym);
-EXTERN void iemgui_all_col2save(t_iemgui *iemgui, int *bflcol);
-EXTERN void iemgui_all_colfromload(t_iemgui *iemgui, int *bflcol);
-EXTERN int iemgui_compatible_col(int i);
-EXTERN void iemgui_all_dollar2raute(t_symbol **srlsym);
-EXTERN void iemgui_all_raute2dollar(t_symbol **srlsym);
-EXTERN void iemgui_send(void *x, t_iemgui *iemgui, t_symbol *s);
-EXTERN void iemgui_receive(void *x, t_iemgui *iemgui, t_symbol *s);
-EXTERN void iemgui_label(void *x, t_iemgui *iemgui, t_symbol *s);
-EXTERN void iemgui_label_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av);
-EXTERN void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av);
-EXTERN void iemgui_size(void *x, t_iemgui *iemgui);
-EXTERN void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av);
-EXTERN void iemgui_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av);
-EXTERN void iemgui_color(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av);
-EXTERN int iemgui_list(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av);
-EXTERN void iemgui_displace(t_gobj *z, t_glist *glist, int dx, int dy);
-EXTERN void iemgui_select(t_gobj *z, t_glist *glist, int selected);
-EXTERN void iemgui_delete(t_gobj *z, t_glist *glist);
-EXTERN void iemgui_vis(t_gobj *z, t_glist *glist, int vis);
-EXTERN void iemgui_save(t_iemgui *iemgui, t_symbol **srl, int *bflcol);
-EXTERN void iemgui_properties(t_iemgui *iemgui, t_symbol **srl);
-EXTERN int iemgui_dialog(t_iemgui *iemgui, t_symbol **srl, int argc, t_atom *argv);
-
-EXTERN int canvas_getdollarzero(void);
-EXTERN void canvas_getargs(int *argcp, t_atom **argvp);
-EXTERN void iem_inttosymargs(t_iem_init_symargs *symargp, int n);
-EXTERN int iem_symargstoint(t_iem_init_symargs *symargp);
-EXTERN void iem_inttofstyle(t_iem_fstyle_flags *fstylep, int n);
-EXTERN int iem_fstyletoint(t_iem_fstyle_flags *fstylep);
diff --git a/apps/plugins/pdbox/PDa/src/g_array.c b/apps/plugins/pdbox/PDa/src/g_array.c
index f259ac8dcb..3e2225637a 100644
--- a/apps/plugins/pdbox/PDa/src/g_array.c
+++ b/apps/plugins/pdbox/PDa/src/g_array.c
@@ -1364,1371 +1364,3 @@ void g_array_setup(void)
class_setsavefn(garray_class, garray_save);
}
-
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h> /* for read/write to files */
-#include "m_pd.h"
-#include "g_canvas.h"
-#include <math.h>
-
-/* see also the "plot" object in g_scalar.c which deals with graphing
-arrays which are fields in scalars. Someday we should unify the
-two, but how? */
-
- /* aux routine to bash leading '#' to '$' for dialogs in u_main.tk
- which can't send symbols starting with '$' (because the Pd message
- interpreter would change them!) */
-
-static t_symbol *sharptodollar(t_symbol *s)
-{
- if (*s->s_name == '#')
- {
- char buf[MAXPDSTRING];
- strncpy(buf, s->s_name, MAXPDSTRING);
- buf[MAXPDSTRING-1] = 0;
- buf[0] = '$';
- return (gensym(buf));
- }
- else return (s);
-}
-
-/* --------- "pure" arrays with scalars for elements. --------------- */
-
-/* Pure arrays have no a priori graphical capabilities.
-They are instantiated by "garrays" below or can be elements of other
-scalars (g_scalar.c); their graphical behavior is defined accordingly. */
-
-t_array *array_new(t_symbol *templatesym, t_gpointer *parent)
-{
- t_array *x = (t_array *)getbytes(sizeof (*x));
- t_template *template;
- t_gpointer *gp;
- template = template_findbyname(templatesym);
- x->a_templatesym = templatesym;
- x->a_n = 1;
- x->a_elemsize = sizeof(t_word) * template->t_n;
- x->a_vec = (char *)getbytes(x->a_elemsize);
- /* note here we blithely copy a gpointer instead of "setting" a
- new one; this gpointer isn't accounted for and needn't be since
- we'll be deleted before the thing pointed to gets deleted anyway;
- see array_free. */
- x->a_gp = *parent;
- x->a_stub = gstub_new(0, x);
- word_init((t_word *)(x->a_vec), template, parent);
- return (x);
-}
-
-void array_resize(t_array *x, t_template *template, int n)
-{
- int elemsize, oldn;
- t_gpointer *gp;
-
- if (n < 1)
- n = 1;
- oldn = x->a_n;
- elemsize = sizeof(t_word) * template->t_n;
-
- x->a_vec = (char *)resizebytes(x->a_vec, oldn * elemsize,
- n * elemsize);
- x->a_n = n;
- if (n > oldn)
- {
- char *cp = x->a_vec + elemsize * oldn;
- int i = n - oldn;
- for (; i--; cp += elemsize)
- {
- t_word *wp = (t_word *)cp;
- word_init(wp, template, &x->a_gp);
- }
- }
-}
-
-void word_free(t_word *wp, t_template *template);
-
-void array_free(t_array *x)
-{
- int i;
- t_template *scalartemplate = template_findbyname(x->a_templatesym);
- /* we don't unset our gpointer here since it was never "set." */
- /* gpointer_unset(&x->a_gp); */
- gstub_cutoff(x->a_stub);
- for (i = 0; i < x->a_n; i++)
- {
- t_word *wp = (t_word *)(x->a_vec + x->a_elemsize * i);
- word_free(wp, scalartemplate);
- }
- freebytes(x->a_vec, x->a_elemsize * x->a_n);
- freebytes(x, sizeof *x);
-}
-
-/* --------------------- graphical arrays (garrays) ------------------- */
-
-t_class *garray_class;
-static int gcount = 0;
-
-struct _garray
-{
- t_gobj x_gobj;
- t_glist *x_glist;
- t_array x_array; /* actual array; note only 4 fields used as below */
- t_symbol *x_name;
- t_symbol *x_realname; /* name with "$" expanded */
- t_float x_firstx; /* X value of first item */
- t_float x_xinc; /* X increment */
- char x_usedindsp; /* true if some DSP routine is using this */
- char x_saveit; /* true if we should save this with parent */
-};
-
- /* macros to get into the "array" structure */
-#define x_n x_array.a_n
-#define x_elemsize x_array.a_elemsize
-#define x_vec x_array.a_vec
-#define x_templatesym x_array.a_templatesym
-
-t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *templatesym,
- t_floatarg f, t_floatarg saveit)
-{
- int n = f, i;
- int zz, nwords;
- t_garray *x;
- t_pd *x2;
- t_template *template;
- char *str;
- if (s == &s_)
- {
- char buf[40];
- sprintf(buf, "array%d", ++gcount);
- s = gensym(buf);
- templatesym = &s_float;
- n = 100;
- }
- else if (!strncmp((str = s->s_name), "array", 5)
- && (zz = atoi(str + 5)) > gcount) gcount = zz;
- template = template_findbyname(templatesym);
- if (!template)
- {
- error("array: couldn't find template %s", templatesym->s_name);
- return (0);
- }
- nwords = template->t_n;
- for (i = 0; i < nwords; i++)
- {
- /* we can't have array or list elements yet because what scalar
- can act as their "parent"??? */
- if (template->t_vec[i].ds_type == DT_ARRAY
- || template->t_vec[i].ds_type == DT_LIST)
- {
- error("array: template %s can't have sublists or arrays",
- templatesym->s_name);
- return (0);
- }
- }
- x = (t_garray *)pd_new(garray_class);
-
- if (n <= 0) n = 100;
- x->x_n = n;
- x->x_elemsize = nwords * sizeof(t_word);
- x->x_vec = getbytes(x->x_n * x->x_elemsize);
- memset(x->x_vec, 0, x->x_n * x->x_elemsize);
- /* LATER should check that malloc */
- x->x_name = s;
- x->x_realname = canvas_realizedollar(gl, s);
- pd_bind(&x->x_gobj.g_pd, x->x_realname);
- x->x_templatesym = templatesym;
- x->x_firstx = 0;
- x->x_xinc = 1; /* LATER make methods to set this... */
- glist_add(gl, &x->x_gobj);
- x->x_glist = gl;
- x->x_usedindsp = 0;
- x->x_saveit = (saveit != 0);
- if (x2 = pd_findbyclass(gensym("#A"), garray_class))
- pd_unbind(x2, gensym("#A"));
-
- pd_bind(&x->x_gobj.g_pd, gensym("#A"));
-
- return (x);
-}
-
- /* called from array menu item to create a new one */
-void canvas_menuarray(t_glist *canvas)
-{
- t_glist *x = (t_glist *)canvas;
- char cmdbuf[200];
- sprintf(cmdbuf, "pdtk_array_dialog %%s array%d 100 1 1\n",
- ++gcount);
- gfxstub_new(&x->gl_pd, x, cmdbuf);
-}
-
- /* called from graph_dialog to set properties */
-void garray_properties(t_garray *x)
-{
- char cmdbuf[200];
- gfxstub_deleteforkey(x);
- /* create dialog window. LATER fix this to escape '$'
- properly; right now we just detect a leading '$' and escape
- it. There should be a systematic way of doing this. */
- if (x->x_name->s_name[0] == '$')
- sprintf(cmdbuf, "pdtk_array_dialog %%s \\%s %d %d 0\n",
- x->x_name->s_name, x->x_n, x->x_saveit);
- else sprintf(cmdbuf, "pdtk_array_dialog %%s %s %d %d 0\n",
- x->x_name->s_name, x->x_n, x->x_saveit);
- gfxstub_new(&x->x_gobj.g_pd, x, cmdbuf);
-}
-
- /* this is called back from the dialog window to create a garray.
- The otherflag requests that we find an existing graph to put it in. */
-void glist_arraydialog(t_glist *parent, t_symbol *name, t_floatarg size,
- t_floatarg saveit, t_floatarg otherflag)
-{
- t_glist *gl;
- t_garray *a;
- if (size < 1)
- size = 1;
- if (otherflag == 0 || (!(gl = glist_findgraph(parent))))
- gl = glist_addglist(parent, &s_, 0, 1,
- (size > 1 ? size-1 : size), -1, 0, 0, 0, 0);
- a = graph_array(gl, sharptodollar(name), &s_float, size, saveit);
-}
-
- /* this is called from the properties dialog window for an existing array */
-void garray_arraydialog(t_garray *x, t_symbol *name, t_floatarg fsize,
- t_floatarg saveit, t_floatarg deleteit)
-{
- if (deleteit != 0)
- {
- glist_delete(x->x_glist, &x->x_gobj);
- }
- else
- {
- int size;
- t_symbol *argname = sharptodollar(name);
- if (argname != x->x_name)
- {
- x->x_name = argname;
- pd_unbind(&x->x_gobj.g_pd, x->x_realname);
- x->x_realname = canvas_realizedollar(x->x_glist, argname);
- pd_bind(&x->x_gobj.g_pd, x->x_realname);
- }
- size = fsize;
- if (size < 1)
- size = 1;
- if (size != x->x_n)
- garray_resize(x, size);
- garray_setsaveit(x, (saveit != 0));
- garray_redraw(x);
- }
-}
-
-static void garray_free(t_garray *x)
-{
- t_pd *x2;
- gfxstub_deleteforkey(x);
- pd_unbind(&x->x_gobj.g_pd, x->x_realname);
- /* LATER find a way to get #A unbound earlier (at end of load?) */
- while (x2 = pd_findbyclass(gensym("#A"), garray_class))
- pd_unbind(x2, gensym("#A"));
- freebytes(x->x_vec, x->x_n * x->x_elemsize);
-}
-
-/* ------------- code used by both array and plot widget functions ---- */
-
- /* routine to get screen coordinates of a point in an array */
-void array_getcoordinate(t_glist *glist,
- char *elem, int xonset, int yonset, int wonset, int indx,
- float basex, float basey, float xinc,
- float *xp, float *yp, float *wp)
-{
- float xval, yval, ypix, wpix;
- if (xonset >= 0)
- xval = fixtof(*(t_sample *)(elem + xonset));
- else xval = indx * xinc;
- if (yonset >= 0)
- yval = fixtof(*(t_sample *)(elem + yonset));
- else yval = 0;
- ypix = glist_ytopixels(glist, basey + yval);
- if (wonset >= 0)
- {
- /* found "w" field which controls linewidth. */
- float wval = *(float *)(elem + wonset);
- wpix = glist_ytopixels(glist, basey + yval + wval) - ypix;
- if (wpix < 0)
- wpix = -wpix;
- }
- else wpix = 1;
- *xp = glist_xtopixels(glist, basex + xval);
- *yp = ypix;
- *wp = wpix;
-}
-
-static float array_motion_xcumulative;
-static float array_motion_ycumulative;
-static t_symbol *array_motion_xfield;
-static t_symbol *array_motion_yfield;
-static t_glist *array_motion_glist;
-static t_gobj *array_motion_gobj;
-static t_word *array_motion_wp;
-static t_template *array_motion_template;
-static int array_motion_npoints;
-static int array_motion_elemsize;
-static int array_motion_altkey;
-static float array_motion_initx;
-static float array_motion_xperpix;
-static float array_motion_yperpix;
-static int array_motion_lastx;
-static int array_motion_fatten;
-
- /* LATER protect against the template changing or the scalar disappearing
- probably by attaching a gpointer here ... */
-
-static void array_motion(void *z, t_floatarg dx, t_floatarg dy)
-{
- array_motion_xcumulative += dx * array_motion_xperpix;
- array_motion_ycumulative += dy * array_motion_yperpix;
- if (*array_motion_xfield->s_name)
- {
- /* it's an x, y plot; can drag many points at once */
- int i;
- char *charword = (char *)array_motion_wp;
- for (i = 0; i < array_motion_npoints; i++)
- {
- t_word *thisword = (t_word *)(charword + i * array_motion_elemsize);
- if (*array_motion_xfield->s_name)
- {
- float xwas = template_getfloat(array_motion_template,
- array_motion_xfield, thisword, 1);
- template_setfloat(array_motion_template,
- array_motion_xfield, thisword, xwas + dx, 1);
- }
- if (*array_motion_yfield->s_name)
- {
- float ywas = template_getfloat(array_motion_template,
- array_motion_yfield, thisword, 1);
- if (array_motion_fatten)
- {
- if (i == 0)
- {
- float newy = ywas + dy * array_motion_yperpix;
- if (newy < 0)
- newy = 0;
- template_setfloat(array_motion_template,
- array_motion_yfield, thisword, newy, 1);
- }
- }
- else
- {
- template_setfloat(array_motion_template,
- array_motion_yfield, thisword,
- ywas + dy * array_motion_yperpix, 1);
- }
- }
- }
- }
- else
- {
- /* a y-only plot. */
- int thisx = array_motion_initx +
- array_motion_xcumulative, x2;
- int increment, i, nchange;
- char *charword = (char *)array_motion_wp;
- float newy = array_motion_ycumulative,
- oldy = template_getfloat(
- array_motion_template, array_motion_yfield,
- (t_word *)(charword + array_motion_elemsize * array_motion_lastx), 1);
- float ydiff = newy - oldy;
- if (thisx < 0) thisx = 0;
- else if (thisx >= array_motion_npoints)
- thisx = array_motion_npoints - 1;
- increment = (thisx > array_motion_lastx ? -1 : 1);
- nchange = 1 + increment * (array_motion_lastx - thisx);
-
- for (i = 0, x2 = thisx; i < nchange; i++, x2 += increment)
- {
- template_setfloat(array_motion_template,
- array_motion_yfield,
- (t_word *)(charword + array_motion_elemsize * x2),
- newy, 1);
- if (nchange > 1)
- newy -= ydiff * (1./(nchange - 1));
- }
- array_motion_lastx = thisx;
- }
- glist_redrawitem(array_motion_glist, array_motion_gobj);
-}
-
-int array_doclick(t_array *array, t_glist *glist, t_gobj *gobj,
- t_symbol *elemtemplatesym,
- float linewidth, float xloc, float xinc, float yloc,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_canvas *elemtemplatecanvas;
- t_template *elemtemplate;
- int elemsize, yonset, wonset, xonset, i;
-
- if (!array_getfields(elemtemplatesym, &elemtemplatecanvas,
- &elemtemplate, &elemsize, &xonset, &yonset, &wonset))
- {
- float best = 100;
- int incr;
- /* if it has more than 2000 points, just check 300 of them. */
- if (array->a_n < 2000)
- incr = 1;
- else incr = array->a_n / 300;
- for (i = 0; i < array->a_n; i += incr)
- {
- float pxpix, pypix, pwpix, dx, dy;
- array_getcoordinate(glist, (char *)(array->a_vec) + i * elemsize,
- xonset, yonset, wonset, i, xloc, yloc, xinc,
- &pxpix, &pypix, &pwpix);
- if (pwpix < 4)
- pwpix = 4;
- dx = pxpix - xpix;
- if (dx < 0) dx = -dx;
- if (dx > 8)
- continue;
- dy = pypix - ypix;
- if (dy < 0) dy = -dy;
- if (dx + dy < best)
- best = dx + dy;
- if (wonset >= 0)
- {
- dy = (pypix + pwpix) - ypix;
- if (dy < 0) dy = -dy;
- if (dx + dy < best)
- best = dx + dy;
- dy = (pypix - pwpix) - ypix;
- if (dy < 0) dy = -dy;
- if (dx + dy < best)
- best = dx + dy;
- }
- }
- if (best > 8)
- return (0);
- best += 0.001; /* add truncation error margin */
- for (i = 0; i < array->a_n; i += incr)
- {
- float pxpix, pypix, pwpix, dx, dy, dy2, dy3;
- array_getcoordinate(glist, (char *)(array->a_vec) + i * elemsize,
- xonset, yonset, wonset, i, xloc, yloc, xinc,
- &pxpix, &pypix, &pwpix);
- if (pwpix < 4)
- pwpix = 4;
- dx = pxpix - xpix;
- if (dx < 0) dx = -dx;
- dy = pypix - ypix;
- if (dy < 0) dy = -dy;
- if (wonset >= 0)
- {
- dy2 = (pypix + pwpix) - ypix;
- if (dy2 < 0) dy2 = -dy2;
- dy3 = (pypix - pwpix) - ypix;
- if (dy3 < 0) dy3 = -dy3;
- if (yonset <= 0)
- dy = 100;
- }
- else dy2 = dy3 = 100;
- if (dx + dy <= best || dx + dy2 <= best || dx + dy3 <= best)
- {
- if (dy < dy2 && dy < dy3)
- array_motion_fatten = 0;
- else if (dy2 < dy3)
- array_motion_fatten = -1;
- else array_motion_fatten = 1;
- if (doit)
- {
- char *elem = (char *)array->a_vec;
- array_motion_elemsize = elemsize;
- array_motion_glist = glist;
- array_motion_gobj = gobj;
- array_motion_template = elemtemplate;
- array_motion_xperpix = glist_dpixtodx(glist, 1);
- array_motion_yperpix = glist_dpixtody(glist, 1);
- if (alt && xpix < pxpix) /* delete a point */
- {
- if (array->a_n <= 1)
- return (0);
- memmove((char *)(array->a_vec) + elemsize * i,
- (char *)(array->a_vec) + elemsize * (i+1),
- (array->a_n - 1 - i) * elemsize);
- array_resize(array, elemtemplate, array->a_n - 1);
- glist_redrawitem(array_motion_glist, array_motion_gobj);
- return (0);
- }
- else if (alt)
- {
- /* add a point (after the clicked-on one) */
- array_resize(array, elemtemplate, array->a_n + 1);
- elem = (char *)array->a_vec;
- memmove(elem + elemsize * (i+1),
- elem + elemsize * i,
- (array->a_n - i - 1) * elemsize);
- i++;
- }
- if (xonset >= 0)
- {
- array_motion_xfield = gensym("x");
- array_motion_xcumulative =
- *(float *)((elem + elemsize * i) + xonset);
- array_motion_wp = (t_word *)(elem + i * elemsize);
- array_motion_npoints = array->a_n - i;
- }
- else
- {
- array_motion_xfield = &s_;
- array_motion_xcumulative = 0;
- array_motion_wp = (t_word *)elem;
- array_motion_npoints = array->a_n;
-
- array_motion_initx = i;
- array_motion_lastx = i;
- array_motion_xperpix *= (xinc == 0 ? 1 : 1./xinc);
- }
- if (array_motion_fatten)
- {
- array_motion_yfield = gensym("w");
- array_motion_ycumulative =
- *(float *)((elem + elemsize * i) + wonset);
- array_motion_yperpix *= array_motion_fatten;
- }
- else if (yonset >= 0)
- {
- array_motion_yfield = gensym("y");
- array_motion_ycumulative =
- *(float *)((elem + elemsize * i) + yonset);
- }
- else
- {
- array_motion_yfield = &s_;
- array_motion_ycumulative = 0;
- }
- glist_grab(glist, 0, array_motion, 0, xpix, ypix);
- }
- if (alt)
- {
- if (xpix < pxpix)
- return (CURSOR_EDITMODE_DISCONNECT);
- else return (CURSOR_RUNMODE_ADDPOINT);
- }
- else return (array_motion_fatten ?
- CURSOR_RUNMODE_THICKEN : CURSOR_RUNMODE_CLICKME);
- }
- }
- }
- return (0);
-}
-
-/* -------------------- widget behavior for garray ------------ */
-
-static void garray_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_garray *x = (t_garray *)z;
- float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
- t_canvas *elemtemplatecanvas;
- t_template *elemtemplate;
- int elemsize, yonset, wonset, xonset, i;
-
- if (!array_getfields(x->x_templatesym, &elemtemplatecanvas,
- &elemtemplate, &elemsize, &xonset, &yonset, &wonset))
- {
- int incr;
- /* if it has more than 2000 points, just check 300 of them. */
- if (x->x_array.a_n < 2000)
- incr = 1;
- else incr = x->x_array.a_n / 300;
- for (i = 0; i < x->x_array.a_n; i += incr)
- {
- float pxpix, pypix, pwpix, dx, dy;
- array_getcoordinate(glist, (char *)(x->x_array.a_vec) +
- i * elemsize,
- xonset, yonset, wonset, i, 0, 0, 1,
- &pxpix, &pypix, &pwpix);
- if (pwpix < 2)
- pwpix = 2;
- if (pxpix < x1)
- x1 = pxpix;
- if (pxpix > x2)
- x2 = pxpix;
- if (pypix - pwpix < y1)
- y1 = pypix - pwpix;
- if (pypix + pwpix > y2)
- y2 = pypix + pwpix;
- }
- }
- *xp1 = x1;
- *yp1 = y1;
- *xp2 = x2;
- *yp2 = y2;
-}
-
-static void garray_displace(t_gobj *z, t_glist *glist, int dx, int dy)
-{
- /* refuse */
-}
-
-static void garray_select(t_gobj *z, t_glist *glist, int state)
-{
- t_garray *x = (t_garray *)z;
- /* fill in later */
-}
-
-static void garray_activate(t_gobj *z, t_glist *glist, int state)
-{
-}
-
-static void garray_delete(t_gobj *z, t_glist *glist)
-{
- /* nothing to do */
-}
-
-static void garray_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_garray *x = (t_garray *)z;
- if (vis)
- {
- int i, xonset, yonset, type;
- t_symbol *arraytype;
- t_template *template = template_findbyname(x->x_templatesym);
- if (!template)
- return;
- if (!template_find_field(template, gensym("y"), &yonset, &type,
- &arraytype) || type != DT_FLOAT)
- {
- error("%s: needs floating-point 'y' field",
- x->x_templatesym->s_name);
- sys_vgui(".x%x.c create text 50 50 -text foo\
- -tags .x%x.a%x\n",
- glist_getcanvas(glist), glist_getcanvas(glist), x);
- }
- else if (!template_find_field(template, gensym("x"), &xonset, &type,
- &arraytype) || type != DT_FLOAT)
- {
- float firsty, xcum = x->x_firstx;
- int lastpixel = -1, ndrawn = 0;
- float yval = 0, xpix;
- int ixpix = 0;
- sys_vgui(".x%x.c create line \\\n", glist_getcanvas(glist));
- for (i = 0; i < x->x_n; i++)
- {
- yval = fixtof(*(t_sample *)(x->x_vec +
- template->t_n * i * sizeof (t_word) + yonset));
- xpix = glist_xtopixels(glist, xcum);
- ixpix = xpix + 0.5;
- if (ixpix != lastpixel)
- {
- sys_vgui("%d %f \\\n", ixpix,
- glist_ytopixels(glist, yval));
- ndrawn++;
- }
- lastpixel = ixpix;
- if (ndrawn >= 1000) break;
- xcum += x->x_xinc;
- }
- /* TK will complain if there aren't at least 2 points... */
- if (ndrawn == 0) sys_vgui("0 0 0 0 \\\n");
- else if (ndrawn == 1) sys_vgui("%d %f \\\n", ixpix,
- glist_ytopixels(glist, yval));
- sys_vgui("-tags .x%x.a%x\n", glist_getcanvas(glist), x);
- firsty = fixtof(*(t_sample *)(x->x_vec + yonset));
- sys_vgui(".x%x.c create text %f %f -text {%s} -anchor e\
- -font -*-courier-bold--normal--%d-* -tags .x%x.a%x\n",
- glist_getcanvas(glist),
- glist_xtopixels(glist, x->x_firstx) - 5.,
- glist_ytopixels(glist, firsty),
- x->x_name->s_name, glist_getfont(glist),
- glist_getcanvas(glist), x);
- }
- else
- {
- post("x, y arrays not yet supported");
- }
- }
- else
- {
- sys_vgui(".x%x.c delete .x%x.a%x\n",
- glist_getcanvas(glist), glist_getcanvas(glist), x);
- }
-}
-
-static int garray_click(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_garray *x = (t_garray *)z;
- return (array_doclick(&x->x_array, glist, z, x->x_templatesym, 1, 0, 1, 0,
- xpix, ypix, shift, alt, dbl, doit));
-}
-
-#define ARRAYWRITECHUNKSIZE 1000
-
-static void garray_save(t_gobj *z, t_binbuf *b)
-{
- t_garray *x = (t_garray *)z;
- binbuf_addv(b, "sssisi;", gensym("#X"), gensym("array"),
- x->x_name, x->x_n, x->x_templatesym, x->x_saveit);
- fprintf(stderr,"array save\n");
- if (x->x_saveit)
- {
- int n = x->x_n, n2 = 0;
- if (x->x_templatesym != &s_float)
- {
- pd_error(x, "sorry, you can only save 'float' arrays now");
- return;
- }
- if (n > 200000)
- post("warning: I'm saving an array with %d points!\n", n);
- while (n2 < n)
- {
- int chunk = n - n2, i;
- if (chunk > ARRAYWRITECHUNKSIZE)
- chunk = ARRAYWRITECHUNKSIZE;
- binbuf_addv(b, "si", gensym("#A"), n2);
- for (i = 0; i < chunk; i++)
- binbuf_addv(b, "f", fixtof(((t_sample *)(x->x_vec))[n2+i]));
- binbuf_addv(b, ";");
- n2 += chunk;
- }
- }
-}
-
-t_widgetbehavior garray_widgetbehavior =
-{
- garray_getrect,
- garray_displace,
- garray_select,
- garray_activate,
- garray_delete,
- garray_vis,
- garray_click
-};
-
-/* ----------------------- public functions -------------------- */
-
-void garray_usedindsp(t_garray *x)
-{
- x->x_usedindsp = 1;
-}
-
-void garray_redraw(t_garray *x)
-{
- if (glist_isvisible(x->x_glist))
- {
- garray_vis(&x->x_gobj, x->x_glist, 0);
- garray_vis(&x->x_gobj, x->x_glist, 1);
- }
-}
-
- /* This functiopn gets the template of an array; if we can't figure
- out what template an array's elements belong to we're in grave trouble
- when it's time to free or resize it. */
-t_template *garray_template(t_garray *x)
-{
- t_template *template = template_findbyname(x->x_templatesym);
- if (!template)
- bug("garray_template");
- return (template);
-}
-
-int garray_npoints(t_garray *x) /* get the length */
-{
- return (x->x_n);
-}
-
-char *garray_vec(t_garray *x) /* get the contents */
-{
- return ((char *)(x->x_vec));
-}
-
- /* routine that checks if we're just an array of floats and if
- so returns the goods */
-
-int garray_getfloatarray(t_garray *x, int *size, t_sample **vec)
-{
- t_template *template = garray_template(x);
- int yonset, type;
- t_symbol *arraytype;
- if (!template_find_field(template, gensym("y"), &yonset,
- &type, &arraytype) || type != DT_FLOAT)
- error("%s: needs floating-point 'y' field",
- x->x_templatesym->s_name);
- else if (template->t_n != 1)
- error("%s: has more than one field", x->x_templatesym->s_name);
- else
- {
- *size = garray_npoints(x);
- *vec = (t_sample *)garray_vec(x);
- return (1);
- }
- return (0);
-}
-
- /* get any floating-point field of any element of an array */
-float garray_get(t_garray *x, t_symbol *s, t_int indx)
-{
- t_template *template = garray_template(x);
- int yonset, type;
- t_symbol *arraytype;
- if (!template_find_field(template, gensym("y"), &yonset,
- &type, &arraytype) || type != DT_FLOAT)
- {
- error("%s: needs floating-point '%s' field", x->x_templatesym->s_name,
- s->s_name);
- return (0);
- }
- if (indx < 0) indx = 0;
- else if (indx >= x->x_n) indx = x->x_n - 1;
- return (*(float *)((x->x_vec + sizeof(t_word) * indx) + yonset));
-}
-
- /* set the "saveit" flag */
-void garray_setsaveit(t_garray *x, int saveit)
-{
- if (x->x_saveit && !saveit)
- post("warning: array %s: clearing save-in-patch flag",
- x->x_name->s_name);
- x->x_saveit = saveit;
-}
-
-/*------------------- Pd messages ------------------------ */
-static void garray_const(t_garray *x, t_floatarg g)
-{
- t_template *template = garray_template(x);
- int yonset, type, i;
- t_symbol *arraytype;
- if (!template_find_field(template, gensym("y"), &yonset,
- &type, &arraytype) || type != DT_FLOAT)
- error("%s: needs floating-point 'y' field",
- x->x_templatesym->s_name);
- else for (i = 0; i < x->x_n; i++)
- *(float *)(((char *)x->x_vec + sizeof(t_word) * i) + yonset) = g;
- garray_redraw(x);
-}
-
- /* sum of Fourier components; called from routines below */
-static void garray_dofo(t_garray *x, int npoints, float dcval,
- int nsin, t_float *vsin, int sineflag)
-{
- t_template *template = garray_template(x);
- int yonset, type, i, j;
- t_symbol *arraytype;
- double phase, phaseincr, fj;
- if (npoints == 0)
- npoints = 512; /* dunno what a good default would be... */
- if (npoints != (1 << ilog2(npoints)))
- post("%s: rounnding to %d points", x->x_templatesym->s_name,
- (npoints = (1<<ilog2(npoints))));
- garray_resize(x, npoints + 3);
- phaseincr = 2. * 3.14159 / npoints;
- if (!template_find_field(template, gensym("y"), &yonset,
- &type, &arraytype) || type != DT_FLOAT)
- {
- error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
- return;
- }
- for (i = 0, phase = -phaseincr; i < x->x_n; i++, phase += phaseincr )
- {
- double sum = dcval;
- if (sineflag)
- for (j = 0, fj = phase; j < nsin; j++, fj += phase)
- sum += vsin[j] * sin(fj);
- else
- for (j = 0, fj = 0; j < nsin; j++, fj += phase)
- sum += vsin[j] * cos(fj);
- *(float *)((x->x_vec + sizeof(t_word) * i) + yonset) = sum;
- }
- garray_redraw(x);
-}
-
-static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_template *template = garray_template(x);
-
- t_float *svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
- int npoints, i;
- if (argc < 2)
- {
- error("sinesum: %s: need number of points and partial strengths",
- x->x_templatesym->s_name);
- return;
- }
-
- npoints = atom_getfloatarg(0, argc, argv);
- argv++, argc--;
-
- svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
- if (!svec) return;
-
- for (i = 0; i < argc; i++)
- svec[i] = atom_getfloatarg(i, argc, argv);
- garray_dofo(x, npoints, 0, argc, svec, 1);
- t_freebytes(svec, sizeof(t_float) * argc);
-}
-
-static void garray_cosinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_template *template = garray_template(x);
-
- t_float *svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
- int npoints, i;
- if (argc < 2)
- {
- error("sinesum: %s: need number of points and partial strengths",
- x->x_templatesym->s_name);
- return;
- }
-
- npoints = atom_getfloatarg(0, argc, argv);
- argv++, argc--;
-
- svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
- if (!svec) return;
-
- for (i = 0; i < argc; i++)
- svec[i] = atom_getfloatarg(i, argc, argv);
- garray_dofo(x, npoints, 0, argc, svec, 0);
- t_freebytes(svec, sizeof(t_float) * argc);
-}
-
-static void garray_normalize(t_garray *x, t_float f)
-{
- t_template *template = garray_template(x);
- int yonset, type, npoints, i;
- double maxv, renormer;
- t_symbol *arraytype;
-
- if (f <= 0)
- f = 1;
-
- if (!template_find_field(template, gensym("y"), &yonset,
- &type, &arraytype) || type != DT_FLOAT)
- {
- error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
- return;
- }
- for (i = 0, maxv = 0; i < x->x_n; i++)
- {
- double v = *(float *)((x->x_vec + sizeof(t_word) * i) + yonset);
- if (v > maxv)
- maxv = v;
- if (-v > maxv)
- maxv = -v;
- }
- if (maxv >= 0)
- {
- renormer = f / maxv;
- for (i = 0; i < x->x_n; i++)
- {
- *(float *)((x->x_vec + sizeof(t_word) * i) + yonset)
- *= renormer;
- }
- }
- garray_redraw(x);
-}
-
- /* list -- the first value is an index; subsequent values are put in
- the "y" slot of the array. This generalizes Max's "table", sort of. */
-static void garray_list(t_garray *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_template *template = garray_template(x);
- int yonset, type, i;
- t_symbol *arraytype;
- if (!template_find_field(template, gensym("y"), &yonset,
- &type, &arraytype) || type != DT_FLOAT)
- error("%s: needs floating-point 'y' field",
- x->x_templatesym->s_name);
- else if (argc < 2) return;
- else
- {
- int firstindex = atom_getfloat(argv);
- argc--;
- argv++;
- /* drop negative x values */
- if (firstindex < 0)
- {
- argc += firstindex;
- argv -= firstindex;
- firstindex = 0;
- if (argc <= 0) return;
- }
- if (argc + firstindex > x->x_n)
- {
- argc = x->x_n - firstindex;
- if (argc <= 0) return;
- }
- for (i = 0; i < argc; i++)
- *(t_sample *)((x->x_vec + sizeof(t_word) * (i + firstindex)) + yonset) =
- ftofix(atom_getfloat(argv + i));
- }
- garray_redraw(x);
-}
-
- /* forward a "bounds" message to the owning graph */
-static void garray_bounds(t_garray *x, t_floatarg x1, t_floatarg y1,
- t_floatarg x2, t_floatarg y2)
-{
- vmess(&x->x_glist->gl_pd, gensym("bounds"), "ffff", x1, y1, x2, y2);
-}
-
- /* same for "xticks", etc */
-static void garray_xticks(t_garray *x,
- t_floatarg point, t_floatarg inc, t_floatarg f)
-{
- vmess(&x->x_glist->gl_pd, gensym("xticks"), "fff", point, inc, f);
-}
-
-static void garray_yticks(t_garray *x,
- t_floatarg point, t_floatarg inc, t_floatarg f)
-{
- vmess(&x->x_glist->gl_pd, gensym("yticks"), "fff", point, inc, f);
-}
-
-static void garray_xlabel(t_garray *x, t_symbol *s, int argc, t_atom *argv)
-{
- typedmess(&x->x_glist->gl_pd, s, argc, argv);
-}
-
-static void garray_ylabel(t_garray *x, t_symbol *s, int argc, t_atom *argv)
-{
- typedmess(&x->x_glist->gl_pd, s, argc, argv);
-}
- /* change the name of a garray. */
-static void garray_rename(t_garray *x, t_symbol *s)
-{
- pd_unbind(&x->x_gobj.g_pd, x->x_realname);
- pd_bind(&x->x_gobj.g_pd, x->x_realname = x->x_name = s);
- garray_redraw(x);
-}
-
-static void garray_read(t_garray *x, t_symbol *filename)
-{
- int nelem = x->x_n, filedesc;
- FILE *fd;
- char buf[MAXPDSTRING], *bufptr;
- t_template *template = garray_template(x);
- int yonset, type, i;
- t_symbol *arraytype;
- if (!template_find_field(template, gensym("y"), &yonset,
- &type, &arraytype) || type != DT_FLOAT)
- {
- error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
- return;
- }
- if ((filedesc = open_via_path(
- canvas_getdir(glist_getcanvas(x->x_glist))->s_name,
- filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0
- || !(fd = fdopen(filedesc, "r")))
- {
- error("%s: can't open", filename->s_name);
- return;
- }
- for (i = 0; i < nelem; i++)
- {
- if (!fscanf(fd, "%f", (float *)((x->x_vec + sizeof(t_word) * i) +
- yonset)))
- {
- post("%s: read %d elements into table of size %d",
- filename->s_name, i, nelem);
- break;
- }
- }
- while (i < nelem)
- *(float *)((x->x_vec + sizeof(t_word) * i) + yonset) = 0, i++;
- fclose(fd);
- garray_redraw(x);
-}
-
- /* this should be renamed and moved... */
-int garray_ambigendian(void)
-{
- unsigned short s = 1;
- unsigned char c = *(char *)(&s);
- return (c==0);
-}
-
-#define BINREADMODE "rb"
-#define BINWRITEMODE "wb"
-
-static void garray_read16(t_garray *x, t_symbol *filename,
- t_symbol *endian, t_floatarg fskip)
-{
- int skip = fskip, filedesc;
- int i, nelem;
- t_sample *vec;
- FILE *fd;
- char buf[MAXPDSTRING], *bufptr;
- short s;
- int cpubig = garray_ambigendian(), swap = 0;
- char c = endian->s_name[0];
- if (c == 'b')
- {
- if (!cpubig) swap = 1;
- }
- else if (c == 'l')
- {
- if (cpubig) swap = 1;
- }
- else if (c)
- {
- error("array_read16: endianness is 'l' (low byte first ala INTEL)");
- post("... or 'b' (high byte first ala MIPS,DEC,PPC)");
- }
- if (!garray_getfloatarray(x, &nelem, &vec))
- {
- error("%s: not a float array", x->x_templatesym->s_name);
- return;
- }
- if ((filedesc = open_via_path(
- canvas_getdir(glist_getcanvas(x->x_glist))->s_name,
- filename->s_name, "", buf, &bufptr, MAXPDSTRING, 1)) < 0
- || !(fd = fdopen(filedesc, BINREADMODE)))
- {
- error("%s: can't open", filename->s_name);
- return;
- }
- if (skip)
- {
- long pos = fseek(fd, (long)skip, SEEK_SET);
- if (pos < 0)
- {
- error("%s: can't seek to byte %d", buf, skip);
- fclose(fd);
- return;
- }
- }
-
- for (i = 0; i < nelem; i++)
- {
- if (fread(&s, sizeof(s), 1, fd) < 1)
- {
- post("%s: read %d elements into table of size %d",
- filename->s_name, i, nelem);
- break;
- }
- if (swap) s = ((s & 0xff) << 8) | ((s & 0xff00) >> 8);
- vec[i] = s * (1./32768.);
- }
- while (i < nelem) vec[i++] = 0;
- fclose(fd);
- garray_redraw(x);
-}
-
-static void garray_write(t_garray *x, t_symbol *filename)
-{
- FILE *fd;
- char buf[MAXPDSTRING];
- t_template *template = garray_template(x);
- int yonset, type, i;
- t_symbol *arraytype;
- if (!template_find_field(template, gensym("y"), &yonset,
- &type, &arraytype) || type != DT_FLOAT)
- {
- error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
- return;
- }
- canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name,
- buf, MAXPDSTRING);
- sys_bashfilename(buf, buf);
- if (!(fd = fopen(buf, "w")))
- {
- error("%s: can't create", buf);
- return;
- }
- for (i = 0; i < x->x_n; i++)
- {
- if (fprintf(fd, "%g\n",
- *(float *)((x->x_vec + sizeof(t_word) * i) + yonset)) < 1)
- {
- post("%s: write error", filename->s_name);
- break;
- }
- }
- fclose(fd);
-}
-
-static unsigned char waveheader[] = {
-0x52, 0x49, 0x46, 0x46,
-0x00, 0x00, 0x00, 0x00,
-0x57, 0x41, 0x56, 0x45,
-0x66, 0x6d, 0x74, 0x20,
-
-0x10, 0x00, 0x00, 0x00,
-0x01, 0x00, 0x01, 0x00,
-0x44, 0xac, 0x00, 0x00,
-0x88, 0x58, 0x01, 0x00,
-
-0x02, 0x00, 0x10, 0x00,
-0x64, 0x61, 0x74, 0x61,
-0x00, 0x00, 0x00, 0x00,
-};
-
- /* wave format only so far */
-static void garray_write16(t_garray *x, t_symbol *filename, t_symbol *format)
-{
- t_template *template = garray_template(x);
- int yonset, type, i;
- t_symbol *arraytype;
- FILE *fd;
- int aiff = (format == gensym("aiff"));
- char filenamebuf[MAXPDSTRING], buf2[MAXPDSTRING];
- int swap = garray_ambigendian(); /* wave is only little endian */
- int intbuf;
- strncpy(filenamebuf, filename->s_name, MAXPDSTRING-10);
- filenamebuf[MAXPDSTRING-10] = 0;
- if (sizeof(int) != 4) post("write16: only works on 32-bit machines");
- if (aiff)
- {
- if (strcmp(filenamebuf + strlen(filenamebuf)-5, ".aiff"))
- strcat(filenamebuf, ".aiff");
- }
- else
- {
- if (strcmp(filenamebuf + strlen(filenamebuf)-4, ".wav"))
- strcat(filenamebuf, ".wav");
- }
- if (!template_find_field(template, gensym("y"), &yonset,
- &type, &arraytype) || type != DT_FLOAT)
- {
- error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
- return;
- }
- canvas_makefilename(glist_getcanvas(x->x_glist), filenamebuf,
- buf2, MAXPDSTRING);
- sys_bashfilename(buf2, buf2);
- if (!(fd = fopen(buf2, BINWRITEMODE)))
- {
- error("%s: can't create", buf2);
- return;
- }
- intbuf = 2 * x->x_n + 36;
- if (swap)
- {
- unsigned char *foo = (unsigned char *)&intbuf, xxx;
- xxx = foo[0]; foo[0] = foo[3]; foo[3] = xxx;
- xxx = foo[1]; foo[1] = foo[2]; foo[2] = xxx;
- }
- memcpy((void *)(waveheader + 4), (void *)(&intbuf), 4);
- intbuf = 2 * x->x_n;
- if (swap)
- {
- unsigned char *foo = (unsigned char *)&intbuf, xxx;
- xxx = foo[0]; foo[0] = foo[3]; foo[3] = xxx;
- xxx = foo[1]; foo[1] = foo[2]; foo[2] = xxx;
- }
- memcpy((void *)(waveheader + 40), (void *)(&intbuf), 4);
- if (fwrite(waveheader, sizeof(waveheader), 1, fd) < 1)
- {
- post("%s: write error", buf2);
- goto closeit;
- }
- for (i = 0; i < x->x_n; i++)
- {
- float f = 32767. * *(float *)((x->x_vec + sizeof(t_word) * i) + yonset);
- short sh;
- if (f < -32768) f = -32768;
- else if (f > 32767) f = 32767;
- sh = f;
- if (swap)
- {
- unsigned char *foo = (unsigned char *)&sh, xxx;
- xxx = foo[0]; foo[0] = foo[1]; foo[1] = xxx;
- }
- if (fwrite(&sh, sizeof(sh), 1, fd) < 1)
- {
- post("%s: write error", buf2);
- goto closeit;
- }
- }
-closeit:
- fclose(fd);
-}
-
-void garray_resize(t_garray *x, t_floatarg f)
-{
- int was = x->x_n, elemsize;
- t_glist *gl;
- int dspwas;
- int n = f;
- char *nvec;
-
- if (n < 1) n = 1;
- elemsize = template_findbyname(x->x_templatesym)->t_n * sizeof(t_word);
- nvec = t_resizebytes(x->x_vec, was * elemsize, n * elemsize);
- if (!nvec)
- {
- pd_error(x, "array resize failed: out of memory");
- return;
- }
- x->x_vec = nvec;
- /* LATER should check t_resizebytes result */
- if (n > was)
- memset(x->x_vec + was*elemsize,
- 0, (n - was) * elemsize);
- x->x_n = n;
-
- /* if this is the only array in the graph,
- reset the graph's coordinates */
- gl = x->x_glist;
- if (gl->gl_list == &x->x_gobj && !x->x_gobj.g_next)
- {
- vmess(&gl->gl_pd, gensym("bounds"), "ffff",
- 0., gl->gl_y1, (double)(n > 1 ? n-1 : 1), gl->gl_y2);
- /* close any dialogs that might have the wrong info now... */
- gfxstub_deleteforkey(gl);
- }
- else garray_redraw(x);
- if (x->x_usedindsp) canvas_update_dsp();
-}
-
-static void garray_print(t_garray *x)
-{
- post("garray %s: template %s, length %d",
- x->x_name->s_name, x->x_templatesym->s_name, x->x_n);
-}
-
-void g_array_setup(void)
-{
- garray_class = class_new(gensym("array"), 0, (t_method)garray_free,
- sizeof(t_garray), CLASS_GOBJ, 0);
- class_setwidget(garray_class, &garray_widgetbehavior);
- class_addmethod(garray_class, (t_method)garray_const, gensym("const"),
- A_DEFFLOAT, A_NULL);
- class_addlist(garray_class, garray_list);
- class_addmethod(garray_class, (t_method)garray_bounds, gensym("bounds"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
- class_addmethod(garray_class, (t_method)garray_xticks, gensym("xticks"),
- A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(garray_class, (t_method)garray_xlabel, gensym("xlabel"),
- A_GIMME, 0);
- class_addmethod(garray_class, (t_method)garray_yticks, gensym("yticks"),
- A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(garray_class, (t_method)garray_ylabel, gensym("ylabel"),
- A_GIMME, 0);
- class_addmethod(garray_class, (t_method)garray_rename, gensym("rename"),
- A_SYMBOL, 0);
- class_addmethod(garray_class, (t_method)garray_read, gensym("read"),
- A_SYMBOL, A_NULL);
- class_addmethod(garray_class, (t_method)garray_read16, gensym("read16"),
- A_SYMBOL, A_DEFFLOAT, A_DEFSYM, A_NULL);
- class_addmethod(garray_class, (t_method)garray_write, gensym("write"),
- A_SYMBOL, A_NULL);
- class_addmethod(garray_class, (t_method)garray_write16, gensym("write16"),
- A_SYMBOL, A_DEFSYM, A_NULL);
- class_addmethod(garray_class, (t_method)garray_resize, gensym("resize"),
- A_FLOAT, A_NULL);
- class_addmethod(garray_class, (t_method)garray_print, gensym("print"),
- A_NULL);
- class_addmethod(garray_class, (t_method)garray_sinesum, gensym("sinesum"),
- A_GIMME, 0);
- class_addmethod(garray_class, (t_method)garray_cosinesum,
- gensym("cosinesum"), A_GIMME, 0);
- class_addmethod(garray_class, (t_method)garray_normalize,
- gensym("normalize"), A_DEFFLOAT, 0);
- class_addmethod(garray_class, (t_method)garray_arraydialog,
- gensym("arraydialog"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
- class_setsavefn(garray_class, garray_save);
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/src/g_bang.c b/apps/plugins/pdbox/PDa/src/g_bang.c
index c676bf8675..6556f7019a 100644
--- a/apps/plugins/pdbox/PDa/src/g_bang.c
+++ b/apps/plugins/pdbox/PDa/src/g_bang.c
@@ -552,557 +552,4 @@ void g_bang_setup(void)
class_setsavefn(bng_class, bng_save);
class_setpropertiesfn(bng_class, bng_properties);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-#ifdef MSW
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-
-/* --------------- bng gui-bang ------------------------- */
-
-t_widgetbehavior bng_widgetbehavior;
-static t_class *bng_class;
-
-/* widget helper functions */
-
-
-void bng_draw_update(t_bng *x, t_glist *glist)
-{
- if(glist_isvisible(glist))
- {
- sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", glist_getcanvas(glist), x,
- x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
- }
-}
-
-void bng_draw_new(t_bng *x, t_glist *glist)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
- canvas, xpos, ypos,
- xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
- x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create oval %d %d %d %d -fill #%6.6x -tags %xBUT\n",
- canvas, xpos+1, ypos+1,
- xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1,
- x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
- canvas, xpos+x->x_gui.x_ldx,
- ypos+x->x_gui.x_ldy,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
- x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas, xpos,
- ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
- ypos + x->x_gui.x_h, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas, xpos, ypos,
- xpos + IOWIDTH, ypos+1, x, 0);
-}
-
-void bng_draw_move(t_bng *x, t_glist *glist)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
- canvas, x, xpos, ypos,
- xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
- sys_vgui(".x%x.c coords %xBUT %d %d %d %d\n",
- canvas, x, xpos+1,ypos+1,
- xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1);
- sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", canvas, x,
- x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
- canvas, x, 0, xpos,
- ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
- ypos + x->x_gui.x_h);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
- canvas, x, 0, xpos, ypos,
- xpos + IOWIDTH, ypos+1);
-}
-
-void bng_draw_erase(t_bng* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
- sys_vgui(".x%x.c delete %xBUT\n", canvas, x);
- sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-void bng_draw_config(t_bng* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
- sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", canvas, x,
- x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
-}
-
-void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas, xpos,
- ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
- ypos + x->x_gui.x_h, x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas, xpos, ypos,
- xpos + IOWIDTH, ypos+1, x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-void bng_draw_select(t_bng* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- if(x->x_gui.x_fsf.x_selected)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- }
- else
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
- sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
- }
-}
-
-void bng_draw(t_bng *x, t_glist *glist, int mode)
-{
- if(mode == IEM_GUI_DRAW_MODE_UPDATE)
- bng_draw_update(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_MOVE)
- bng_draw_move(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_NEW)
- bng_draw_new(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_SELECT)
- bng_draw_select(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_ERASE)
- bng_draw_erase(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
- bng_draw_config(x, glist);
- else if(mode >= IEM_GUI_DRAW_MODE_IO)
- bng_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
-}
-
-/* ------------------------ bng widgetbehaviour----------------------------- */
-
-static void bng_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_bng *x = (t_bng *)z;
-
- *xp1 = text_xpix(&x->x_gui.x_obj, glist);
- *yp1 = text_ypix(&x->x_gui.x_obj, glist);
- *xp2 = *xp1 + x->x_gui.x_w;
- *yp2 = *yp1 + x->x_gui.x_h;
-}
-
-static void bng_save(t_gobj *z, t_binbuf *b)
-{
- t_bng *x = (t_bng *)z;
- int bflcol[3];
- t_symbol *srl[3];
-
- iemgui_save(&x->x_gui, srl, bflcol);
- binbuf_addv(b, "ssiisiiiisssiiiiiii", gensym("#X"),gensym("obj"),
- (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
- gensym("bng"), x->x_gui.x_w,
- x->x_flashtime_hold, x->x_flashtime_break,
- iem_symargstoint(&x->x_gui.x_isa),
- srl[0], srl[1], srl[2],
- x->x_gui.x_ldx, x->x_gui.x_ldy,
- iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
- bflcol[0], bflcol[1], bflcol[2]);
- binbuf_addv(b, ";");
-}
-
-void bng_check_minmax(t_bng *x, int ftbreak, int fthold)
-{
- if(ftbreak > fthold)
- {
- int h;
-
- h = ftbreak;
- ftbreak = fthold;
- fthold = h;
- }
- if(ftbreak < IEM_BNG_MINBREAKFLASHTIME)
- ftbreak = IEM_BNG_MINBREAKFLASHTIME;
- if(fthold < IEM_BNG_MINHOLDFLASHTIME)
- fthold = IEM_BNG_MINHOLDFLASHTIME;
- x->x_flashtime_break = ftbreak;
- x->x_flashtime_hold = fthold;
-}
-
-static void bng_properties(t_gobj *z, t_glist *owner)
-{
- t_bng *x = (t_bng *)z;
- char buf[800];
- t_symbol *srl[3];
-
- iemgui_properties(&x->x_gui, srl);
- sprintf(buf, "pdtk_iemgui_dialog %%s BANG \
- ----------dimensions(pix):----------- %d %d size: 0 0 empty \
- --------flash-time(ms)(ms):--------- %d intrrpt: %d hold: %d \
- %d empty empty %d %d empty %d \
- %s %s \
- %s %d %d \
- %d %d \
- %d %d %d\n",
- x->x_gui.x_w, IEM_GUI_MINSIZE,
- x->x_flashtime_break, x->x_flashtime_hold, 2,/*min_max_schedule+clip*/
- -1, x->x_gui.x_isa.x_loadinit, -1, -1,/*no linlog, no multi*/
- srl[0]->s_name, srl[1]->s_name,
- srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
- x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
- 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
- gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
-}
-
-static void bng_set(t_bng *x)
-{
- if(x->x_flashed)
- {
- x->x_flashed = 0;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- clock_delay(x->x_clock_brk, x->x_flashtime_break);
- x->x_flashed = 1;
- }
- else
- {
- x->x_flashed = 1;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
- clock_delay(x->x_clock_hld, x->x_flashtime_hold);
-}
-
-static void bng_bout1(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/
-{
- if(!x->x_gui.x_fsf.x_put_in2out)
- {
- x->x_gui.x_isa.x_locked = 1;
- clock_delay(x->x_clock_lck, 2);
- }
- outlet_bang(x->x_gui.x_obj.ob_outlet);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing && x->x_gui.x_fsf.x_put_in2out)
- pd_bang(x->x_gui.x_snd->s_thing);
-}
-
-static void bng_bout2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
-{
- if(!x->x_gui.x_fsf.x_put_in2out)
- {
- x->x_gui.x_isa.x_locked = 1;
- clock_delay(x->x_clock_lck, 2);
- }
- outlet_bang(x->x_gui.x_obj.ob_outlet);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_bang(x->x_gui.x_snd->s_thing);
-}
-
-static void bng_bang(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/
-{
- if(!x->x_gui.x_isa.x_locked)
- {
- bng_set(x);
- bng_bout1(x);
- }
-}
-
-static void bng_bang2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
-{
- if(!x->x_gui.x_isa.x_locked)
- {
- bng_set(x);
- bng_bout2(x);
- }
-}
-
-static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *srl[3];
- int a = (int)atom_getintarg(0, argc, argv);
- int fthold = (int)atom_getintarg(2, argc, argv);
- int ftbreak = (int)atom_getintarg(3, argc, argv);
- int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
-
- x->x_gui.x_w = iemgui_clip_size(a);
- x->x_gui.x_h = x->x_gui.x_w;
- bng_check_minmax(x, ftbreak, fthold);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
-}
-
-static void bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
-{
- bng_set(x);
- bng_bout2(x);
-}
-
-static int bng_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- if(doit)
- bng_click((t_bng *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
- return (1);
-}
-
-static void bng_float(t_bng *x, t_floatarg f)
-{bng_bang2(x);}
-
-static void bng_symbol(t_bng *x, t_symbol *s)
-{bng_bang2(x);}
-
-static void bng_pointer(t_bng *x, t_gpointer *gp)
-{bng_bang2(x);}
-
-static void bng_list(t_bng *x, t_symbol *s, int ac, t_atom *av)
-{
- bng_bang2(x);
-}
-
-static void bng_anything(t_bng *x, t_symbol *s, int argc, t_atom *argv)
-{bng_bang2(x);}
-
-static void bng_loadbang(t_bng *x)
-{
- if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
- {
- bng_set(x);
- bng_bout2(x);
- }
-}
-
-static void bng_size(t_bng *x, t_symbol *s, int ac, t_atom *av)
-{
- x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
- x->x_gui.x_h = x->x_gui.x_w;
- iemgui_size((void *)x, &x->x_gui);
-}
-
-static void bng_delta(t_bng *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
-
-static void bng_pos(t_bng *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void bng_flashtime(t_bng *x, t_symbol *s, int ac, t_atom *av)
-{
- bng_check_minmax(x, (int)atom_getintarg(0, ac, av),
- (int)atom_getintarg(1, ac, av));
-}
-
-static void bng_color(t_bng *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
-
-static void bng_send(t_bng *x, t_symbol *s)
-{iemgui_send(x, &x->x_gui, s);}
-
-static void bng_receive(t_bng *x, t_symbol *s)
-{iemgui_receive(x, &x->x_gui, s);}
-
-static void bng_label(t_bng *x, t_symbol *s)
-{iemgui_label((void *)x, &x->x_gui, s);}
-
-static void bng_label_pos(t_bng *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void bng_label_font(t_bng *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
-
-static void bng_init(t_bng *x, t_floatarg f)
-{
- x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
-}
-
-static void bng_tick_hld(t_bng *x)
-{
- x->x_flashed = 0;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
-}
-
-static void bng_tick_brk(t_bng *x)
-{
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
-}
-
-static void bng_tick_lck(t_bng *x)
-{
- x->x_gui.x_isa.x_locked = 0;
-}
-
-static void *bng_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_bng *x = (t_bng *)pd_new(bng_class);
- int bflcol[]={-262144, -1, -1};
- int a=IEM_GUI_DEFAULTSIZE;
- int ldx=0, ldy=-6;
- int fs=8;
- int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME,
- fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
- char str[144];
-
- iem_inttosymargs(&x->x_gui.x_isa, 0);
- iem_inttofstyle(&x->x_gui.x_fsf, 0);
-
- if((argc == 14)&&IS_A_FLOAT(argv,0)
- &&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
- &&IS_A_FLOAT(argv,3)
- &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
- &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
- &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
- &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
- &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)
- &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13))
- {
-
- a = (int)atom_getintarg(0, argc, argv);
- fthold = (int)atom_getintarg(1, argc, argv);
- ftbreak = (int)atom_getintarg(2, argc, argv);
- iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(3, argc, argv));
- iemgui_new_getnames(&x->x_gui, 4, argv);
- ldx = (int)atom_getintarg(7, argc, argv);
- ldy = (int)atom_getintarg(8, argc, argv);
- iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
- fs = (int)atom_getintarg(10, argc, argv);
- bflcol[0] = (int)atom_getintarg(11, argc, argv);
- bflcol[1] = (int)atom_getintarg(12, argc, argv);
- bflcol[2] = (int)atom_getintarg(13, argc, argv);
- }
- else iemgui_new_getnames(&x->x_gui, 4, 0);
-
- x->x_gui.x_draw = (t_iemfunptr)bng_draw;
-
- x->x_gui.x_fsf.x_snd_able = 1;
- x->x_gui.x_fsf.x_rcv_able = 1;
- x->x_flashed = 0;
- x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
- if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
- x->x_gui.x_fsf.x_snd_able = 0;
- if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
- x->x_gui.x_fsf.x_rcv_able = 0;
- if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
- else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
- else { x->x_gui.x_fsf.x_font_style = 0;
- strcpy(x->x_gui.x_font, "courier"); }
-
- if (x->x_gui.x_fsf.x_rcv_able)
- pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- x->x_gui.x_ldx = ldx;
- x->x_gui.x_ldy = ldy;
-
- if(fs < 4)
- fs = 4;
- x->x_gui.x_fontsize = fs;
- x->x_gui.x_w = iemgui_clip_size(a);
- x->x_gui.x_h = x->x_gui.x_w;
- bng_check_minmax(x, ftbreak, fthold);
- iemgui_all_colfromload(&x->x_gui, bflcol);
- x->x_gui.x_isa.x_locked = 0;
- iemgui_verify_snd_ne_rcv(&x->x_gui);
- x->x_clock_hld = clock_new(x, (t_method)bng_tick_hld);
- x->x_clock_brk = clock_new(x, (t_method)bng_tick_brk);
- x->x_clock_lck = clock_new(x, (t_method)bng_tick_lck);
- outlet_new(&x->x_gui.x_obj, &s_bang);
- return (x);
-}
-
-static void bng_ff(t_bng *x)
-{
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- clock_free(x->x_clock_lck);
- clock_free(x->x_clock_brk);
- clock_free(x->x_clock_hld);
- gfxstub_deleteforkey(x);
-}
-
-void g_bang_setup(void)
-{
- bng_class = class_new(gensym("bng"), (t_newmethod)bng_new,
- (t_method)bng_ff, sizeof(t_bng), 0, A_GIMME, 0);
- class_addbang(bng_class, bng_bang);
- class_addfloat(bng_class, bng_float);
- class_addsymbol(bng_class, bng_symbol);
- class_addpointer(bng_class, bng_pointer);
- class_addlist(bng_class, bng_list);
- class_addanything(bng_class, bng_anything);
- class_addmethod(bng_class, (t_method)bng_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(bng_class, (t_method)bng_dialog, gensym("dialog"),
- A_GIMME, 0);
- class_addmethod(bng_class, (t_method)bng_loadbang, gensym("loadbang"), 0);
- class_addmethod(bng_class, (t_method)bng_size, gensym("size"), A_GIMME, 0);
- class_addmethod(bng_class, (t_method)bng_delta, gensym("delta"), A_GIMME, 0);
- class_addmethod(bng_class, (t_method)bng_pos, gensym("pos"), A_GIMME, 0);
- class_addmethod(bng_class, (t_method)bng_flashtime, gensym("flashtime"), A_GIMME, 0);
- class_addmethod(bng_class, (t_method)bng_color, gensym("color"), A_GIMME, 0);
- class_addmethod(bng_class, (t_method)bng_send, gensym("send"), A_DEFSYM, 0);
- class_addmethod(bng_class, (t_method)bng_receive, gensym("receive"), A_DEFSYM, 0);
- class_addmethod(bng_class, (t_method)bng_label, gensym("label"), A_DEFSYM, 0);
- class_addmethod(bng_class, (t_method)bng_label_pos, gensym("label_pos"), A_GIMME, 0);
- class_addmethod(bng_class, (t_method)bng_label_font, gensym("label_font"), A_GIMME, 0);
- class_addmethod(bng_class, (t_method)bng_init, gensym("init"), A_FLOAT, 0);
- bng_widgetbehavior.w_getrectfn = bng_getrect;
- bng_widgetbehavior.w_displacefn = iemgui_displace;
- bng_widgetbehavior.w_selectfn = iemgui_select;
- bng_widgetbehavior.w_activatefn = NULL;
- bng_widgetbehavior.w_deletefn = iemgui_delete;
- bng_widgetbehavior.w_visfn = iemgui_vis;
- bng_widgetbehavior.w_clickfn = bng_newclick;
- class_setwidget(bng_class, &bng_widgetbehavior);
- class_sethelpsymbol(bng_class, gensym("bng"));
- class_setsavefn(bng_class, bng_save);
- class_setpropertiesfn(bng_class, bng_properties);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_canvas.c b/apps/plugins/pdbox/PDa/src/g_canvas.c
index f4ef8b14aa..f8b8dda0cf 100644
--- a/apps/plugins/pdbox/PDa/src/g_canvas.c
+++ b/apps/plugins/pdbox/PDa/src/g_canvas.c
@@ -1474,1479 +1474,4 @@ void g_canvas_setup(void)
g_editor_setup();
g_readwrite_setup();
}
-/* Copyright (c) 1997-2001 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* this file defines the "glist" class, also known as "canvas" (the two used
-to be different but are now unified except for some fossilized names.) */
-
-/* changes by Thomas Musil IEM KUG Graz Austria 2001 */
-
-/* bug-fix: canvas_menuclose(): by Krzysztof Czaja */
-/* bug-fix: table_new(): I reversed the y-bounds */
-
-/* IOhannes :
- * changed the canvas_restore, so that it might accept $args as well
- * (like "pd $0_test")
- * so you can make multiple & distinguishable templates
- * 1511:forum::für::umläute:2001
- * changes marked with IOhannes
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "m_pd.h"
-#include "m_imp.h"
-#include "s_stuff.h"
-#include "g_canvas.h"
-#include <string.h>
-#include "g_all_guis.h"
-
-struct _canvasenvironment
-{
- t_symbol *ce_dir; /* directory patch lives in */
- int ce_argc; /* number of "$" arguments */
- t_atom *ce_argv; /* array of "$" arguments */
- int ce_dollarzero; /* value of "$0" */
-};
-
-#define GLIST_DEFCANVASWIDTH 240
-#define GLIST_DEFCANVASHEIGHT 300
-
-#ifdef MACOSX
-#define GLIST_DEFCANVASYLOC 22
-#else
-#define GLIST_DEFCANVASYLOC 0
-#endif
-
-/* ---------------------- variables --------------------------- */
-
-extern t_pd *newest;
-t_class *canvas_class;
-static int canvas_dspstate; /* whether DSP is on or off */
-t_canvas *canvas_editing; /* last canvas to start text edting */
-t_canvas *canvas_whichfind; /* last canvas we did a find in */
-t_canvas *canvas_list; /* list of all root canvases */
-
-/* ------------------ forward function declarations --------------- */
-static void canvas_start_dsp(void);
-static void canvas_stop_dsp(void);
-static void canvas_drawlines(t_canvas *x);
-static void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2);
-static void canvas_reflecttitle(t_canvas *x);
-static void canvas_addtolist(t_canvas *x);
-static void canvas_takeofflist(t_canvas *x);
-static void canvas_pop(t_canvas *x, t_floatarg fvis);
-void canvas_create_editor(t_glist *x, int createit);
-
-/* --------- functions to handle the canvas environment ----------- */
-
-static t_symbol *canvas_newfilename = &s_;
-static t_symbol *canvas_newdirectory = &s_;
-static int canvas_newargc;
-static t_atom *canvas_newargv;
-
-static void glist_doupdatewindowlist(t_glist *gl, char *sbuf)
-{
- t_gobj *g;
- if (!gl->gl_owner)
- {
- /* this is a canvas; if we have a window, put on "windows" list */
- t_canvas *canvas = (t_canvas *)gl;
- if (canvas->gl_havewindow)
- {
- if (strlen(sbuf) + strlen(gl->gl_name->s_name) + 100 <= 1024)
- {
- char tbuf[1024];
- sprintf(tbuf, "{%s .x%x} ", gl->gl_name->s_name, (t_int)canvas);
- strcat(sbuf, tbuf);
- }
- }
- }
- for (g = gl->gl_list; g; g = g->g_next)
- {
- if (pd_class(&g->g_pd) == canvas_class)
- glist_doupdatewindowlist((t_glist *)g, sbuf);
- }
- return;
-}
-
- /* maintain the list of visible toplevels for the GUI's "windows" menu */
-void canvas_updatewindowlist( void)
-{
- t_canvas *x;
- char sbuf[1024];
- strcpy(sbuf, "set menu_windowlist {");
- /* find all root canvases */
- for (x = canvas_list; x; x = x->gl_next)
- glist_doupdatewindowlist(x, sbuf);
- /* next line updates the window menu state before -postcommand tries it */
- strcat(sbuf, "}\npdtk_fixwindowmenu\n");
- sys_gui(sbuf);
-}
-
- /* add a glist the list of "root" canvases (toplevels without parents.) */
-static void canvas_addtolist(t_canvas *x)
-{
- x->gl_next = canvas_list;
- canvas_list = x;
-}
-
-static void canvas_takeofflist(t_canvas *x)
-{
- /* take it off the window list */
- if (x == canvas_list) canvas_list = x->gl_next;
- else
- {
- t_canvas *z;
- for (z = canvas_list; z->gl_next != x; z = z->gl_next)
- ;
- z->gl_next = x->gl_next;
- }
-}
-
-
-void canvas_setargs(int argc, t_atom *argv)
-{
- /* if there's an old one lying around free it here. This
- happens if an abstraction is loaded but never gets as far
- as calling canvas_new(). */
- if (canvas_newargv)
- freebytes(canvas_newargv, canvas_newargc * sizeof(t_atom));
- canvas_newargc = argc;
- canvas_newargv = copybytes(argv, argc * sizeof(t_atom));
-}
-
-void glob_setfilename(void *dummy, t_symbol *filesym, t_symbol *dirsym)
-{
- canvas_newfilename = filesym;
- canvas_newdirectory = dirsym;
-}
-
-t_canvas *canvas_getcurrent(void)
-{
- return ((t_canvas *)pd_findbyclass(&s__X, canvas_class));
-}
-
-void canvas_setcurrent(t_canvas *x)
-{
- pd_pushsym(&x->gl_pd);
-}
-
-void canvas_unsetcurrent(t_canvas *x)
-{
- pd_popsym(&x->gl_pd);
-}
-
-t_canvasenvironment *canvas_getenv(t_canvas *x)
-{
- if (!x) bug("canvas_getenv");
- while (!x->gl_env)
- if (!(x = x->gl_owner))
- bug("t_canvasenvironment", x);
- return (x->gl_env);
-}
-
-int canvas_getdollarzero( void)
-{
- t_canvas *x = canvas_getcurrent();
- t_canvasenvironment *env = (x ? canvas_getenv(x) : 0);
- if (env)
- return (env->ce_dollarzero);
- else return (0);
-}
-
-void canvas_getargs(int *argcp, t_atom **argvp)
-{
- t_canvasenvironment *e = canvas_getenv(canvas_getcurrent());
- *argcp = e->ce_argc;
- *argvp = e->ce_argv;
-}
-
-t_symbol *canvas_realizedollar(t_canvas *x, t_symbol *s)
-{
- t_symbol *ret;
- char *name = s->s_name;
- if (*name == '$' && name[1] >= '0' && name[1] <= '9')
- {
- t_canvasenvironment *env = canvas_getenv(x);
- canvas_setcurrent(x);
- ret = binbuf_realizedollsym(gensym(name+1),
- env->ce_argc, env->ce_argv, 1);
- canvas_unsetcurrent(x);
- }
- else ret = s;
- return (ret);
-}
-
-t_symbol *canvas_getcurrentdir(void)
-{
- t_canvasenvironment *e = canvas_getenv(canvas_getcurrent());
- return (e->ce_dir);
-}
-
-t_symbol *canvas_getdir(t_canvas *x)
-{
- t_canvasenvironment *e = canvas_getenv(x);
- return (e->ce_dir);
-}
-
-void canvas_makefilename(t_canvas *x, char *file, char *result, int resultsize)
-{
- char *dir = canvas_getenv(x)->ce_dir->s_name;
- if (file[0] == '/' || (file[0] && file[1] == ':') || !*dir)
- {
- strncpy(result, file, resultsize);
- result[resultsize-1] = 0;
- }
- else
- {
- int nleft;
- strncpy(result, dir, resultsize);
- result[resultsize-1] = 0;
- nleft = resultsize - strlen(result) - 1;
- if (nleft <= 0) return;
- strcat(result, "/");
- strncat(result, file, nleft);
- result[resultsize-1] = 0;
- }
-}
-
-void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir)
-{
- if (strcmp(x->gl_name->s_name, "Pd"))
- pd_unbind(&x->gl_pd, canvas_makebindsym(x->gl_name));
- x->gl_name = s;
- if (strcmp(x->gl_name->s_name, "Pd"))
- pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
- if (glist_isvisible(x))
- canvas_reflecttitle(x);
- if (dir && dir != &s_)
- {
- t_canvasenvironment *e = canvas_getenv(x);
- e->ce_dir = dir;
- }
-}
-
-/* --------------- traversing the set of lines in a canvas ----------- */
-
-int canvas_getindex(t_canvas *x, t_gobj *y)
-{
- t_gobj *y2;
- int indexno;
- for (indexno = 0, y2 = x->gl_list; y2 && y2 != y; y2 = y2->g_next)
- indexno++;
- return (indexno);
-}
-
-void linetraverser_start(t_linetraverser *t, t_canvas *x)
-{
- t->tr_ob = 0;
- t->tr_x = x;
- t->tr_nextoc = 0;
- t->tr_nextoutno = t->tr_nout = 0;
-}
-
-t_outconnect *linetraverser_next(t_linetraverser *t)
-{
- t_outconnect *rval = t->tr_nextoc;
- int outno;
- while (!rval)
- {
- outno = t->tr_nextoutno;
- while (outno == t->tr_nout)
- {
- t_gobj *y;
- t_object *ob = 0;
- if (!t->tr_ob) y = t->tr_x->gl_list;
- else y = t->tr_ob->ob_g.g_next;
- for (; y; y = y->g_next)
- if (ob = pd_checkobject(&y->g_pd)) break;
- if (!ob) return (0);
- t->tr_ob = ob;
- t->tr_nout = obj_noutlets(ob);
- outno = 0;
- if (glist_isvisible(t->tr_x))
- gobj_getrect(y, t->tr_x,
- &t->tr_x11, &t->tr_y11, &t->tr_x12, &t->tr_y12);
- else t->tr_x11 = t->tr_y11 = t->tr_x12 = t->tr_y12 = 0;
- }
- t->tr_nextoutno = outno + 1;
- rval = obj_starttraverseoutlet(t->tr_ob, &t->tr_outlet, outno);
- t->tr_outno = outno;
- }
- t->tr_nextoc = obj_nexttraverseoutlet(rval, &t->tr_ob2,
- &t->tr_inlet, &t->tr_inno);
- t->tr_nin = obj_ninlets(t->tr_ob2);
- if (!t->tr_nin) bug("drawline");
- if (glist_isvisible(t->tr_x))
- {
- int inplus = (t->tr_nin == 1 ? 1 : t->tr_nin - 1);
- int outplus = (t->tr_nout == 1 ? 1 : t->tr_nout - 1);
- gobj_getrect(&t->tr_ob2->ob_g, t->tr_x,
- &t->tr_x21, &t->tr_y21, &t->tr_x22, &t->tr_y22);
- t->tr_lx1 = t->tr_x11 +
- ((t->tr_x12 - t->tr_x11 - IOWIDTH) * t->tr_outno) /
- outplus + IOMIDDLE;
- t->tr_ly1 = t->tr_y12;
- t->tr_lx2 = t->tr_x21 +
- ((t->tr_x22 - t->tr_x21 - IOWIDTH) * t->tr_inno)/inplus +
- IOMIDDLE;
- t->tr_ly2 = t->tr_y21;
- }
- else
- {
- t->tr_x21 = t->tr_y21 = t->tr_x22 = t->tr_y22 = 0;
- t->tr_lx1 = t->tr_ly1 = t->tr_lx2 = t->tr_ly2 = 0;
- }
-
- return (rval);
-}
-
-void linetraverser_skipobject(t_linetraverser *t)
-{
- t->tr_nextoc = 0;
- t->tr_nextoutno = t->tr_nout;
-}
-
-/* -------------------- the canvas object -------------------------- */
-int glist_valid = 10000;
-
-void glist_init(t_glist *x)
-{
- /* zero out everyone except "pd" field */
- memset(((char *)x) + sizeof(x->gl_pd), 0, sizeof(*x) - sizeof(x->gl_pd));
- x->gl_stub = gstub_new(x, 0);
- x->gl_valid = ++glist_valid;
- x->gl_xlabel = (t_symbol **)t_getbytes(0);
- x->gl_ylabel = (t_symbol **)t_getbytes(0);
-}
-
- /* make a new glist. It will either be a "root" canvas or else
- its parent will be a "text" object in another window... we don't
- know which yet. */
-t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
-{
- t_canvas *x = (t_canvas *)pd_new(canvas_class);
- t_canvas *owner = canvas_getcurrent();
- t_symbol *s = &s_;
- int vis = 0, width = GLIST_DEFCANVASWIDTH, height = GLIST_DEFCANVASHEIGHT;
- int xloc = 0, yloc = GLIST_DEFCANVASYLOC;
- int font = (owner ? owner->gl_font : sys_defaultfont);
- glist_init(x);
- x->gl_obj.te_type = T_OBJECT;
- if (!owner)
- canvas_addtolist(x);
- /* post("canvas %x, owner %x", x, owner); */
-
- if (argc == 5) /* toplevel: x, y, w, h, font */
- {
- xloc = atom_getintarg(0, argc, argv);
- yloc = atom_getintarg(1, argc, argv);
- width = atom_getintarg(2, argc, argv);
- height = atom_getintarg(3, argc, argv);
- font = atom_getintarg(4, argc, argv);
- }
- else if (argc == 6) /* subwindow: x, y, w, h, name, vis */
- {
- xloc = atom_getintarg(0, argc, argv);
- yloc = atom_getintarg(1, argc, argv);
- width = atom_getintarg(2, argc, argv);
- height = atom_getintarg(3, argc, argv);
- s = atom_getsymbolarg(4, argc, argv);
- vis = atom_getintarg(5, argc, argv);
- }
- /* (otherwise assume we're being created from the menu.) */
- if (canvas_newdirectory->s_name[0])
- {
- static int dollarzero = 1000;
- t_canvasenvironment *env = x->gl_env =
- (t_canvasenvironment *)getbytes(sizeof(*x->gl_env));
- env->ce_dir = canvas_newdirectory;
- env->ce_argc = canvas_newargc;
- env->ce_argv = canvas_newargv;
- env->ce_dollarzero = dollarzero++;
- canvas_newdirectory = &s_;
- canvas_newargc = 0;
- canvas_newargv = 0;
- }
- else x->gl_env = 0;
-
- if (yloc < GLIST_DEFCANVASYLOC)
- yloc = GLIST_DEFCANVASYLOC;
- if (xloc < 0)
- xloc = 0;
- x->gl_x1 = 0;
- x->gl_y1 = 0;
- x->gl_x2 = 1;
- x->gl_y2 = 1;
- canvas_setbounds(x, xloc, yloc, xloc + width, yloc + height);
- x->gl_owner = owner;
- x->gl_name = (*s->s_name ? s :
- (canvas_newfilename ? canvas_newfilename : gensym("Pd")));
- if (strcmp(x->gl_name->s_name, "Pd"))
- pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
- x->gl_loading = 1;
- x->gl_willvis = vis;
- x->gl_edit = !strncmp(x->gl_name->s_name, "Untitled", 8);
- x->gl_font = sys_nearestfontsize(font);
- pd_pushsym(&x->gl_pd);
- return(x);
-}
-
-void canvas_setgraph(t_glist *x, int flag);
-
-static void canvas_coords(t_glist *x, t_symbol *s, int argc, t_atom *argv)
-{
- x->gl_x1 = atom_getfloatarg(0, argc, argv);
- x->gl_y1 = atom_getfloatarg(1, argc, argv);
- x->gl_x2 = atom_getfloatarg(2, argc, argv);
- x->gl_y2 = atom_getfloatarg(3, argc, argv);
- x->gl_pixwidth = atom_getintarg(4, argc, argv);
- x->gl_pixheight = atom_getintarg(5, argc, argv);
- canvas_setgraph(x, atom_getintarg(6, argc, argv));
-}
-
- /* make a new glist and add it to this glist. It will appear as
- a "graph", not a text object. */
-t_glist *glist_addglist(t_glist *g, t_symbol *sym,
- float x1, float y1, float x2, float y2,
- float px1, float py1, float px2, float py2)
-{
- static int gcount = 0;
- int zz;
- int menu = 0;
- char *str;
- t_glist *x = (t_glist *)pd_new(canvas_class);
- glist_init(x);
- x->gl_obj.te_type = T_OBJECT;
- if (!*sym->s_name)
- {
- char buf[40];
- sprintf(buf, "graph%d", ++gcount);
- sym = gensym(buf);
- menu = 1;
- }
- else if (!strncmp((str = sym->s_name), "graph", 5)
- && (zz = atoi(str + 5)) > gcount)
- gcount = zz;
- /* in 0.34 and earlier, the pixel rectangle and the y bounds were
- reversed; this would behave the same, except that the dialog window
- would be confusing. The "correct" way is to have "py1" be the value
- that is higher on the screen. */
- if (py2 < py1)
- {
- float zz;
- zz = y2;
- y2 = y1;
- y1 = zz;
- zz = py2;
- py2 = py1;
- py1 = zz;
- }
- if (x1 == x2 || y1 == y2)
- x1 = 0, x2 = 100, y1 = 1, y2 = -1;
- if (px1 >= px2 || py1 >= py2)
- px1 = 100, py1 = 20, px2 = 100 + GLIST_DEFGRAPHWIDTH,
- py2 = 20 + GLIST_DEFGRAPHHEIGHT;
- x->gl_name = sym;
- x->gl_x1 = x1;
- x->gl_x2 = x2;
- x->gl_y1 = y1;
- x->gl_y2 = y2;
- x->gl_obj.te_xpix = px1;
- x->gl_obj.te_ypix = py1;
- x->gl_pixwidth = px2 - px1;
- x->gl_pixheight = py2 - py1;
- x->gl_font = (canvas_getcurrent() ?
- canvas_getcurrent()->gl_font : sys_defaultfont);
- x->gl_screenx1 = x->gl_screeny1 = 0;
- x->gl_screenx2 = 240;
- x->gl_screeny2 = 300;
- if (strcmp(x->gl_name->s_name, "Pd"))
- pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
- x->gl_owner = g;
- x->gl_stretch = 1;
- x->gl_isgraph = 1;
- x->gl_obj.te_binbuf = binbuf_new();
- binbuf_addv(x->gl_obj.te_binbuf, "s", gensym("graph"));
- if (!menu)
- pd_pushsym(&x->gl_pd);
- glist_add(g, &x->gl_gobj);
- if (glist_isvisible(g))
- canvas_create_editor(x, 1);
- return (x);
-}
-
- /* call glist_addglist from a Pd message */
-void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *sym = atom_getsymbolarg(0, argc, argv);
- float x1 = atom_getfloatarg(1, argc, argv);
- float y1 = atom_getfloatarg(2, argc, argv);
- float x2 = atom_getfloatarg(3, argc, argv);
- float y2 = atom_getfloatarg(4, argc, argv);
- float px1 = atom_getfloatarg(5, argc, argv);
- float py1 = atom_getfloatarg(6, argc, argv);
- float px2 = atom_getfloatarg(7, argc, argv);
- float py2 = atom_getfloatarg(8, argc, argv);
- glist_addglist(g, sym, x1, y1, x2, y2, px1, py1, px2, py2);
-}
-
- /* return true if the glist should appear as a graph on parent;
- otherwise it appears as a text box. */
-int glist_isgraph(t_glist *x)
-{
- return (x->gl_isgraph);
-}
-
- /* This is sent from the GUI to inform a toplevel that its window has been
- moved or resized. */
-static void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2)
-{
- int heightwas = y2 - y1;
- int heightchange = y2 - y1 - (x->gl_screeny2 - x->gl_screeny1);
- x->gl_screenx1 = x1;
- x->gl_screeny1 = y1;
- x->gl_screenx2 = x2;
- x->gl_screeny2 = y2;
- /* post("set bounds %d %d %d %d", x1, y1, x2, y2); */
- if (!glist_isgraph(x) && (x->gl_y2 < x->gl_y1))
- {
- /* if it's flipped so that y grows upward,
- fix so that zero is bottom edge and redraw. This is
- only appropriate if we're a regular "text" object on the
- parent. */
- float diff = x->gl_y1 - x->gl_y2;
- t_gobj *y;
- x->gl_y1 = heightwas * diff;
- x->gl_y2 = x->gl_y1 - diff;
- /* and move text objects accordingly; they should stick
- to the bottom, not the top. */
- for (y = x->gl_list; y; y = y->g_next)
- if (pd_checkobject(&y->g_pd))
- gobj_displace(y, x, 0, heightchange);
- canvas_redraw(x);
- }
-}
-
-t_symbol *canvas_makebindsym(t_symbol *s)
-{
- char buf[MAXPDSTRING];
- strcpy(buf, "pd-");
- strcat(buf, s->s_name);
- return (gensym(buf));
-}
-
-void canvas_reflecttitle(t_canvas *x)
-{
- char namebuf[MAXPDSTRING];
- t_canvasenvironment *env = canvas_getenv(x);
- if (env->ce_argc)
- {
- int i;
- strcpy(namebuf, " (");
- for (i = 0; i < env->ce_argc; i++)
- {
- if (strlen(namebuf) > MAXPDSTRING/2 - 5)
- break;
- if (i != 0)
- strcat(namebuf, " ");
- atom_string(&env->ce_argv[i], namebuf + strlen(namebuf),
- MAXPDSTRING/2);
- }
- strcat(namebuf, ")");
- }
- else namebuf[0] = 0;
- sys_vgui("wm title .x%x {%s%c%s - %s}\n",
- x, x->gl_name->s_name, (x->gl_dirty? '*' : ' '), namebuf,
- canvas_getdir(x)->s_name);
-}
-
-void canvas_dirty(t_canvas *x, t_int n)
-{
- t_canvas *x2 = canvas_getrootfor(x);
- if ((unsigned)n != x2->gl_dirty)
- {
- x2->gl_dirty = n;
- canvas_reflecttitle(x2);
- }
-}
-
- /* the window becomes "mapped" (visible and not miniaturized) or
- "unmapped" (either miniaturized or just plain gone.) This should be
- called from the GUI after the fact to "notify" us that we're mapped. */
-void canvas_map(t_canvas *x, t_floatarg f)
-{
- int flag = (f != 0);
- t_gobj *y;
- if (flag)
- {
- if (!glist_isvisible(x))
- {
- t_selection *sel;
- if (!x->gl_havewindow)
- {
- bug("canvas_map");
- canvas_vis(x, 1);
- }
- for (y = x->gl_list; y; y = y->g_next)
- gobj_vis(y, x, 1);
- for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next)
- gobj_select(sel->sel_what, x, 1);
- x->gl_mapped = 1;
- canvas_drawlines(x);
- /* simulate a mouse up so u_main will calculate scrollbars...
- ugly! */
- sys_vgui("pdtk_canvas_mouseup .x%x.c 0 0 0\n", x);
- }
- }
- else
- {
- if (glist_isvisible(x))
- {
- /* just clear out the whole canvas... */
- sys_vgui(".x%x.c delete all\n", x);
- /* alternatively, we could have erased them one by one...
- for (y = x->gl_list; y; y = y->g_next)
- gobj_vis(y, x, 0);
- ... but we should go through and erase the lines as well
- if we do it that way. */
- x->gl_mapped = 0;
- }
- }
-}
-
-void canvas_redraw(t_canvas *x)
-{
- if (glist_isvisible(x))
- {
- canvas_map(x, 0);
- canvas_map(x, 1);
- }
-}
-
-/* ---- editors -- perhaps this and "vis" should go to g_editor.c ------- */
-
-static t_editor *editor_new(t_glist *owner)
-{
- char buf[40];
- t_editor *x = (t_editor *)getbytes(sizeof(*x));
- x->e_connectbuf = binbuf_new();
- x->e_deleted = binbuf_new();
- x->e_glist = owner;
- sprintf(buf, ".x%x", (t_int)owner);
- x->e_guiconnect = guiconnect_new(&owner->gl_pd, gensym(buf));
- return (x);
-}
-
-static void editor_free(t_editor *x, t_glist *y)
-{
- glist_noselect(y);
- guiconnect_notarget(x->e_guiconnect, 1000);
- binbuf_free(x->e_connectbuf);
- binbuf_free(x->e_deleted);
- freebytes((void *)x, sizeof(*x));
-}
-
- /* recursively create or destroy all editors of a glist and its
- sub-glists, as long as they aren't toplevels. */
-void canvas_create_editor(t_glist *x, int createit)
-{
- t_gobj *y;
- t_object *ob;
- if (createit)
- {
- if (x->gl_editor)
- bug("canvas_create_editor");
- else
- {
- x->gl_editor = editor_new(x);
- for (y = x->gl_list; y; y = y->g_next)
- if (ob = pd_checkobject(&y->g_pd))
- rtext_new(x, ob);
- }
- }
- else
- {
- if (!x->gl_editor)
- bug("canvas_create_editor");
- else
- {
- for (y = x->gl_list; y; y = y->g_next)
- if (ob = pd_checkobject(&y->g_pd))
- rtext_free(glist_findrtext(x, ob));
- editor_free(x->gl_editor, x);
- x->gl_editor = 0;
- }
- }
- for (y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == canvas_class &&
- ((t_canvas *)y)->gl_isgraph)
- canvas_create_editor((t_canvas *)y, createit);
-}
-
- /* we call this when we want the window to become visible, mapped, and
- in front of all windows; or with "f" zero, when we want to get rid of
- the window. */
-void canvas_vis(t_canvas *x, t_floatarg f)
-{
- char buf[30];
- int flag = (f != 0);
- if (flag)
- {
- /* test if we're already visible and toplevel */
- if (glist_isvisible(x) && !x->gl_isgraph)
- { /* just put us in front */
-#ifdef MSW
- canvas_vis(x, 0);
- canvas_vis(x, 1);
-#else
- sys_vgui("raise .x%x\n", x);
- sys_vgui("focus .x%x.c\n", x);
- sys_vgui("wm deiconify .x%x\n", x);
-#endif
- }
- else
- {
- canvas_create_editor(x, 1);
- sys_vgui("pdtk_canvas_new .x%x %d %d +%d+%d %d\n", x,
- (int)(x->gl_screenx2 - x->gl_screenx1),
- (int)(x->gl_screeny2 - x->gl_screeny1),
- (int)(x->gl_screenx1), (int)(x->gl_screeny1),
- x->gl_edit);
- canvas_reflecttitle(x);
- x->gl_havewindow = 1;
- canvas_updatewindowlist();
- }
- }
- else /* make invisible */
- {
- int i;
- t_canvas *x2;
- if (!x->gl_havewindow)
- {
- /* bug workaround -- a graph in a visible patch gets "invised"
- when the patch is closed, and must lose the editor here. It's
- probably not the natural place to do this. Other cases like
- subpatches fall here too but don'd need the editor freed, so
- we check if it exists. */
- if (x->gl_editor)
- canvas_create_editor(x, 0);
- return;
- }
- glist_noselect(x);
- if (glist_isvisible(x))
- canvas_map(x, 0);
- canvas_create_editor(x, 0);
- sys_vgui("destroy .x%x\n", x);
- for (i = 1, x2 = x; x2; x2 = x2->gl_next, i++)
- ;
- sys_vgui(".mbar.find delete %d\n", i);
- /* if we're a graph on our parent, and if the parent exists
- and is visible, show ourselves on parent. */
- if (glist_isgraph(x) && x->gl_owner)
- {
- t_glist *gl2 = x->gl_owner;
- canvas_create_editor(x, 1);
- if (glist_isvisible(gl2))
- gobj_vis(&x->gl_gobj, gl2, 0);
- x->gl_havewindow = 0;
- if (glist_isvisible(gl2))
- gobj_vis(&x->gl_gobj, gl2, 1);
- }
- else x->gl_havewindow = 0;
- canvas_updatewindowlist();
- }
-}
-
- /* we call this on a non-toplevel glist to "open" it into its
- own window. */
-void glist_menu_open(t_glist *x)
-{
- if (glist_isvisible(x) && !glist_istoplevel(x))
- {
- t_glist *gl2 = x->gl_owner;
- if (!gl2)
- bug("canvas_vis"); /* shouldn't happen but don't get too upset. */
- else
- {
- /* erase ourself in parent window */
- gobj_vis(&x->gl_gobj, gl2, 0);
- /* get rid of our editor (and subeditors) */
- canvas_create_editor(x, 0);
- x->gl_havewindow = 1;
- /* redraw ourself in parent window (blanked out this time) */
- gobj_vis(&x->gl_gobj, gl2, 1);
- }
- }
- canvas_vis(x, 1);
-}
-
-int glist_isvisible(t_glist *x)
-{
- return ((!x->gl_loading) && glist_getcanvas(x)->gl_mapped);
-}
-
-int glist_istoplevel(t_glist *x)
-{
- /* we consider a graph "toplevel" if it has its own window
- or if it appears as a box in its parent window so that we
- don't draw the actual contents there. */
- return (x->gl_havewindow || !x->gl_isgraph);
-}
-
-int glist_getfont(t_glist *x)
-{
- return (glist_getcanvas(x)->gl_font);
-}
-
-void canvas_free(t_canvas *x)
-{
- t_gobj *y;
- int dspstate = canvas_suspend_dsp();
- canvas_noundo(x);
- if (canvas_editing == x)
- canvas_editing = 0;
- if (canvas_whichfind == x)
- canvas_whichfind = 0;
- glist_noselect(x);
- while (y = x->gl_list)
- glist_delete(x, y);
- canvas_vis(x, 0);
-
- if (strcmp(x->gl_name->s_name, "Pd"))
- pd_unbind(&x->gl_pd, canvas_makebindsym(x->gl_name));
- if (x->gl_env)
- {
- freebytes(x->gl_env->ce_argv, x->gl_env->ce_argc * sizeof(t_atom));
- freebytes(x->gl_env, sizeof(*x->gl_env));
- }
- canvas_resume_dsp(dspstate);
- glist_cleanup(x);
- gfxstub_deleteforkey(x); /* probably unnecessary */
- if (!x->gl_owner)
- canvas_takeofflist(x);
-}
-
-/* ----------------- lines ---------- */
-
-static void canvas_drawlines(t_canvas *x)
-{
- t_linetraverser t;
- t_outconnect *oc;
- {
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n",
- glist_getcanvas(x),
- t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2,
- (outlet_getsymbol(t.tr_outlet) == &s_signal ? 2:1),
- oc);
- }
-}
-
-void canvas_fixlinesfor(t_canvas *x, t_text *text)
-{
- t_linetraverser t;
- t_outconnect *oc;
-
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- {
- if (t.tr_ob == text || t.tr_ob2 == text)
- {
- sys_vgui(".x%x.c coords l%x %d %d %d %d\n",
- glist_getcanvas(x), oc,
- t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2);
- }
- }
-}
-
- /* kill all lines for the object */
-void canvas_deletelinesfor(t_canvas *x, t_text *text)
-{
- t_linetraverser t;
- t_outconnect *oc;
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- {
- if (t.tr_ob == text || t.tr_ob2 == text)
- {
- if (x->gl_editor)
- {
- sys_vgui(".x%x.c delete l%x\n",
- glist_getcanvas(x), oc);
- }
- obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
- }
- }
-}
-
- /* kill all lines for one inlet or outlet */
-void canvas_deletelinesforio(t_canvas *x, t_text *text,
- t_inlet *inp, t_outlet *outp)
-{
- t_linetraverser t;
- t_outconnect *oc;
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- {
- if ((t.tr_ob == text && t.tr_outlet == outp) ||
- (t.tr_ob2 == text && t.tr_inlet == inp))
- {
- if (x->gl_editor)
- {
- sys_vgui(".x%x.c delete l%x\n",
- glist_getcanvas(x), oc);
- }
- obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
- }
- }
-}
-
-static void canvas_pop(t_canvas *x, t_floatarg fvis)
-{
- if (fvis != 0)
- canvas_vis(x, 1);
- pd_popsym(&x->gl_pd);
- canvas_resortinlets(x);
- canvas_resortoutlets(x);
- x->gl_loading = 0;
-}
-
-void canvas_objfor(t_glist *gl, t_text *x, int argc, t_atom *argv);
-
-
-void canvas_restore(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
-{ /* IOhannes */
- t_pd *z;
- /* this should be unnecessary, but sometimes the canvas's name gets
- out of sync with the owning box's argument; this fixes that */
- if (argc > 3)
- {
- t_atom *ap=argv+3;
- if (ap->a_type == A_SYMBOL)
- {
- char *buf=ap->a_w.w_symbol->s_name, *bufp;
- if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9')
- {
- for (bufp = buf+2; *bufp; bufp++)
- if (*bufp < '0' || *bufp > '9')
- {
- SETDOLLSYM(ap, gensym(buf+1));
- goto didit;
- }
- SETDOLLAR(ap, atoi(buf+1));
- didit: ;
- }
- }
-
- if (ap->a_type == A_DOLLSYM)
- {
- t_canvasenvironment *e = canvas_getenv(canvas_getcurrent());
- canvas_rename(x, binbuf_realizedollsym(ap->a_w.w_symbol,
- e->ce_argc, e->ce_argv, 1), 0);
- }
- else if (ap->a_type == A_SYMBOL)
- canvas_rename(x, argv[3].a_w.w_symbol, 0);
- }
- canvas_pop(x, x->gl_willvis);
-
- if (!(z = gensym("#X")->s_thing)) error("canvas_restore: out of context");
- else if (*z != canvas_class) error("canvas_restore: wasn't a canvas");
- else
- {
- t_canvas *x2 = (t_canvas *)z;
- x->gl_owner = x2;
- canvas_objfor(x2, &x->gl_obj, argc, argv);
- }
-}
-
-static void canvas_loadbangabstractions(t_canvas *x)
-{
- t_gobj *y;
- t_symbol *s = gensym("loadbang");
- for (y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == canvas_class)
- {
- if (canvas_isabstraction((t_canvas *)y))
- canvas_loadbang((t_canvas *)y);
- else
- canvas_loadbangabstractions((t_canvas *)y);
- }
-}
-
-void canvas_loadbangsubpatches(t_canvas *x)
-{
- t_gobj *y;
- t_symbol *s = gensym("loadbang");
- for (y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == canvas_class)
- {
- if (!canvas_isabstraction((t_canvas *)y))
- canvas_loadbangsubpatches((t_canvas *)y);
- }
- for (y = x->gl_list; y; y = y->g_next)
- if ((pd_class(&y->g_pd) != canvas_class) &&
- zgetfn(&y->g_pd, s))
- pd_vmess(&y->g_pd, s, "");
-}
-
-void canvas_loadbang(t_canvas *x)
-{
- t_gobj *y;
- canvas_loadbangabstractions(x);
- canvas_loadbangsubpatches(x);
-}
-
- /* When you ask a canvas its size the result is 2 pixels more than what
- you gave it to open it; perhaps there's a 1-pixel border all around it
- or something. Anyway, we just add the 2 pixels back here; seems we
- have to do this for linux but not MSW; not sure about MacOS. */
-
-#ifdef MSW
-#define HORIZBORDER 0
-#define VERTBORDER 0
-#else
-#define HORIZBORDER 2
-#define VERTBORDER 2
-#endif
-
-static void canvas_relocate(t_canvas *x, t_symbol *canvasgeom,
- t_symbol *topgeom)
-{
- int cxpix, cypix, cw, ch, txpix, typix, tw, th;
- if (sscanf(canvasgeom->s_name, "%dx%d+%d+%d", &cw, &ch, &cxpix, &cypix)
- < 4 ||
- sscanf(topgeom->s_name, "%dx%d+%d+%d", &tw, &th, &txpix, &typix) < 4)
- bug("canvas_relocate");
- /* for some reason this is initially called with cw=ch=1 so
- we just suppress that here. */
- if (cw > 5 && ch > 5)
- canvas_setbounds(x, txpix, typix,
- txpix + cw - HORIZBORDER, typix + ch - VERTBORDER);
-}
-
-void canvas_popabstraction(t_canvas *x)
-{
- newest = &x->gl_pd;
- pd_popsym(&x->gl_pd);
- x->gl_loading = 0;
- canvas_resortinlets(x);
- canvas_resortoutlets(x);
-}
-
-void canvas_logerror(t_object *y)
-{
-#ifdef LATER
- canvas_vis(x, 1);
- if (!glist_isselected(x, &y->ob_g))
- glist_select(x, &y->ob_g);
-#endif
-}
-
-/* -------------------------- subcanvases ---------------------- */
-
-static void *subcanvas_new(t_symbol *s)
-{
- t_atom a[6];
- t_canvas *x, *z = canvas_getcurrent();
- if (!*s->s_name) s = gensym("/SUBPATCH/");
- SETFLOAT(a, 0);
- SETFLOAT(a+1, GLIST_DEFCANVASYLOC);
- SETFLOAT(a+2, GLIST_DEFCANVASWIDTH);
- SETFLOAT(a+3, GLIST_DEFCANVASHEIGHT);
- SETSYMBOL(a+4, s);
- SETFLOAT(a+5, 1);
- x = canvas_new(0, 0, 6, a);
- x->gl_owner = z;
- canvas_pop(x, 1);
- return (x);
-}
-
-static void canvas_click(t_canvas *x,
- t_floatarg xpos, t_floatarg ypos,
- t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
-{
- canvas_vis(x, 1);
-}
-
-
- /* find out from subcanvas contents how much to fatten the box */
-void canvas_fattensub(t_canvas *x,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_gobj *y;
- *xp2 += 50; /* fake for now */
- *yp2 += 50;
-}
-
-static void canvas_rename_method(t_canvas *x, t_symbol *s, int ac, t_atom *av)
-{
- if (ac && av->a_type == A_SYMBOL)
- canvas_rename(x, av->a_w.w_symbol, 0);
- else canvas_rename(x, gensym("Pd"), 0);
-}
-
-/* ------------------ table ---------------------------*/
-
-static int tabcount = 0;
-
-static void *table_new(t_symbol *s, t_floatarg f)
-{
- t_atom a[9];
- t_glist *gl;
- t_canvas *x, *z = canvas_getcurrent();
- if (s == &s_)
- {
- char tabname[255];
- t_symbol *t = gensym("table");
- sprintf(tabname, "%s%d", t->s_name, tabcount++);
- s = gensym(tabname);
- }
- if (f <= 1)
- f = 100;
- SETFLOAT(a, 0);
- SETFLOAT(a+1, GLIST_DEFCANVASYLOC);
- SETFLOAT(a+2, 600);
- SETFLOAT(a+3, 400);
- SETSYMBOL(a+4, s);
- SETFLOAT(a+5, 0);
- x = canvas_new(0, 0, 6, a);
-
- x->gl_owner = z;
-
- /* create a graph for the table */
- gl = glist_addglist((t_glist*)x, &s_, 0, -1, (f > 1 ? f-1 : 1), 1,
- 50, 350, 550, 50);
-
- graph_array(gl, s, &s_float, f, 0);
-
- canvas_pop(x, 0);
-
- return (x);
-}
-
- /* return true if the "canvas" object is an abstraction (so we don't
- save its contents, fogr example.) */
-int canvas_isabstraction(t_canvas *x)
-{
- return (x->gl_env != 0);
-}
-
- /* return true if the "canvas" object is a "table". */
-int canvas_istable(t_canvas *x)
-{
- t_atom *argv = (x->gl_obj.te_binbuf? binbuf_getvec(x->gl_obj.te_binbuf):0);
- int argc = (x->gl_obj.te_binbuf? binbuf_getnatom(x->gl_obj.te_binbuf) : 0);
- int istable = (argc && argv[0].a_type == A_SYMBOL &&
- argv[0].a_w.w_symbol == gensym("table"));
- return (istable);
-}
-
- /* return true if the "canvas" object should be treated as a text
- object. This is true for abstractions but also for "table"s... */
-int canvas_showtext(t_canvas *x)
-{
- t_atom *argv = (x->gl_obj.te_binbuf? binbuf_getvec(x->gl_obj.te_binbuf):0);
- int argc = (x->gl_obj.te_binbuf? binbuf_getnatom(x->gl_obj.te_binbuf) : 0);
- int isarray = (argc && argv[0].a_type == A_SYMBOL &&
- argv[0].a_w.w_symbol == gensym("graph"));
- return (!isarray);
-}
-
-static void canvas_dodsp(t_canvas *x, int toplevel, t_signal **sp);
-static void canvas_dsp(t_canvas *x, t_signal **sp)
-{
- canvas_dodsp(x, 0, sp);
-}
-
- /* get the document containing this canvas */
-t_canvas *canvas_getrootfor(t_canvas *x)
-{
- if ((!x->gl_owner) || canvas_isabstraction(x))
- return (x);
- else return (canvas_getrootfor(x->gl_owner));
-}
-
-/* ------------------------- DSP chain handling ------------------------- */
-
-EXTERN_STRUCT _dspcontext;
-#define t_dspcontext struct _dspcontext
-
-void ugen_start(void);
-void ugen_stop(void);
-
-t_dspcontext *ugen_start_graph(int toplevel, t_signal **sp,
- int ninlets, int noutlets);
-void ugen_add(t_dspcontext *dc, t_object *x);
-void ugen_connect(t_dspcontext *dc, t_object *x1, int outno,
- t_object *x2, int inno);
-void ugen_done_graph(t_dspcontext *dc);
-
- /* schedule one canvas for DSP. This is called below for all "root"
- canvases, but is also called from the "dsp" method for sub-
- canvases, which are treated almost like any other tilde object. */
-
-static void canvas_dodsp(t_canvas *x, int toplevel, t_signal **sp)
-{
- t_linetraverser t;
- t_outconnect *oc;
- t_gobj *y;
- t_object *ob;
- t_symbol *dspsym = gensym("dsp");
- t_dspcontext *dc;
-
- /* create a new "DSP graph" object to use in sorting this canvas.
- If we aren't toplevel, there are already other dspcontexts around. */
-
- dc = ugen_start_graph(toplevel, sp,
- obj_nsiginlets(&x->gl_obj),
- obj_nsigoutlets(&x->gl_obj));
-
- /* find all the "dsp" boxes and add them to the graph */
-
- for (y = x->gl_list; y; y = y->g_next)
- if ((ob = pd_checkobject(&y->g_pd)) && zgetfn(&y->g_pd, dspsym))
- ugen_add(dc, ob);
-
- /* ... and all dsp interconnections */
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- if (obj_issignaloutlet(t.tr_ob, t.tr_outno))
- ugen_connect(dc, t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
-
- /* finally, sort them and add them to the DSP chain */
- ugen_done_graph(dc);
-}
-
- /* this routine starts DSP for all root canvases. */
-static void canvas_start_dsp(void)
-{
- t_canvas *x;
- if (canvas_dspstate) ugen_stop();
- else sys_gui("pdtk_pd_dsp ON\n");
- ugen_start();
-
- for (x = canvas_list; x; x = x->gl_next)
- canvas_dodsp(x, 1, 0);
-
- canvas_dspstate = 1;
-}
-
-static void canvas_stop_dsp(void)
-{
- if (canvas_dspstate)
- {
- ugen_stop();
- sys_gui("pdtk_pd_dsp OFF\n");
- canvas_dspstate = 0;
- }
-}
-
- /* DSP can be suspended before, and resumed after, operations which
- might affect the DSP chain. For example, we suspend before loading and
- resume afterward, so that DSP doesn't get resorted for every DSP object
- int the patch. */
-
-int canvas_suspend_dsp(void)
-{
- int rval = canvas_dspstate;
- if (rval) canvas_stop_dsp();
- return (rval);
-}
-
-void canvas_resume_dsp(int oldstate)
-{
- if (oldstate) canvas_start_dsp();
-}
-
- /* this is equivalent to suspending and resuming in one step. */
-void canvas_update_dsp(void)
-{
- if (canvas_dspstate) canvas_start_dsp();
-}
-
-void glob_dsp(void *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- int newstate;
- if (argc)
- {
- newstate = atom_getintarg(0, argc, argv);
- if (newstate && !canvas_dspstate)
- {
- sys_set_audio_state(1);
- canvas_start_dsp();
- }
- else if (!newstate && canvas_dspstate)
- {
- canvas_stop_dsp();
- sys_set_audio_state(0);
- }
- }
- else post("dsp state %d", canvas_dspstate);
-}
-
- /* LATER replace this with a queueing scheme */
-void glist_redrawitem(t_glist *owner, t_gobj *gobj)
-{
- if (glist_isvisible(owner))
- {
- gobj_vis(gobj, owner, 0);
- gobj_vis(gobj, owner, 1);
- }
-}
-
- /* redraw all "scalars" (do this if a drawing command is changed.)
- LATER we'll use the "template" information to select which ones we
- redraw. */
-static void glist_redrawall(t_glist *gl)
-{
- t_gobj *g;
- int vis = glist_isvisible(gl);
- for (g = gl->gl_list; g; g = g->g_next)
- {
- t_class *cl;
- if (vis && g->g_pd == scalar_class)
- glist_redrawitem(gl, g);
- else if (g->g_pd == canvas_class)
- glist_redrawall((t_glist *)g);
- }
-}
-
- /* public interface for above */
-void canvas_redrawallfortemplate(t_canvas *templatecanvas)
-{
- t_canvas *x;
- /* find all root canvases */
- for (x = canvas_list; x; x = x->gl_next)
- glist_redrawall(x);
-}
-
-/* ------------------------------- setup routine ------------------------ */
-
- /* why are some of these "glist" and others "canvas"? */
-extern void glist_text(t_glist *x, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_obj(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_bng(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_toggle(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_vslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_hslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_vdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
- /* old version... */
-extern void canvas_hdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_hdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
- /* new version: */
-extern void canvas_hradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_vradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_vumeter(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_mycnv(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_numbox(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_floatatom(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void canvas_symbolatom(t_glist *gl, t_symbol *s, int argc, t_atom *argv);
-extern void glist_scalar(t_glist *canvas, t_symbol *s, int argc, t_atom *argv);
-
-void g_graph_setup(void);
-void g_editor_setup(void);
-void g_readwrite_setup(void);
-extern void graph_properties(t_gobj *z, t_glist *owner);
-
-void g_canvas_setup(void)
-{
- /* we prevent the user from typing "canvas" in an object box
- by sending 0 for a creator function. */
- canvas_class = class_new(gensym("canvas"), 0,
- (t_method)canvas_free, sizeof(t_canvas), CLASS_NOINLET, 0);
- /* here is the real creator function, invoked in patch files
- by sending the "canvas" message to #N, which is bound
- to pd_camvasmaker. */
- class_addmethod(pd_canvasmaker, (t_method)canvas_new, gensym("canvas"),
- A_GIMME, 0);
- class_addmethod(canvas_class, (t_method)canvas_restore,
- gensym("restore"), A_GIMME, 0);
- class_addmethod(canvas_class, (t_method)canvas_coords,
- gensym("coords"), A_GIMME, 0);
-
-/* -------------------------- objects ----------------------------- */
- class_addmethod(canvas_class, (t_method)canvas_obj,
- gensym("obj"), A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_msg,
- gensym("msg"), A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_floatatom,
- gensym("floatatom"), A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_symbolatom,
- gensym("symbolatom"), A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)glist_text,
- gensym("text"), A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)glist_glist, gensym("graph"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)glist_scalar,
- gensym("scalar"), A_GIMME, A_NULL);
-
- /* -------------- Thomas Musil's GUI objects ------------ */
- class_addmethod(canvas_class, (t_method)canvas_bng, gensym("bng"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_toggle, gensym("toggle"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_vslider, gensym("vslider"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_hslider, gensym("hslider"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_hdial, gensym("hdial"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_vdial, gensym("vdial"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_hradio, gensym("hradio"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_vradio, gensym("vradio"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_vumeter, gensym("vumeter"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_mycnv, gensym("mycnv"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_numbox, gensym("numbox"),
- A_GIMME, A_NULL);
-
-/* ------------------------ gui stuff --------------------------- */
- class_addmethod(canvas_class, (t_method)canvas_pop, gensym("pop"),
- A_DEFFLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_loadbang,
- gensym("loadbang"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_relocate,
- gensym("relocate"), A_SYMBOL, A_SYMBOL, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_vis,
- gensym("vis"), A_FLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)glist_menu_open,
- gensym("menu-open"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_map,
- gensym("map"), A_FLOAT, A_NULL);
- class_setpropertiesfn(canvas_class, graph_properties);
-
-/* ---------------------- list handling ------------------------ */
- class_addmethod(canvas_class, (t_method)glist_clear, gensym("clear"),
- A_NULL);
-
-/* ----- subcanvases, which you get by typing "pd" in a box ---- */
- class_addcreator((t_newmethod)subcanvas_new, gensym("pd"), A_DEFSYMBOL, 0);
- class_addcreator((t_newmethod)subcanvas_new, gensym("page"), A_DEFSYMBOL, 0);
-
- class_addmethod(canvas_class, (t_method)canvas_click,
- gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(canvas_class, (t_method)canvas_dsp, gensym("dsp"), 0);
- class_addmethod(canvas_class, (t_method)canvas_rename_method,
- gensym("rename"), A_GIMME, 0);
-
-/*---------------------------- tables -- GG ------------------- */
-
- class_addcreator((t_newmethod)table_new, gensym("table"),
- A_DEFSYM, A_DEFFLOAT, 0);
-
-/* -------------- setups from other files for canvas_class ---------------- */
- g_graph_setup();
- g_editor_setup();
- g_readwrite_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_canvas.h b/apps/plugins/pdbox/PDa/src/g_canvas.h
index 54ab985feb..9fc580da08 100644
--- a/apps/plugins/pdbox/PDa/src/g_canvas.h
+++ b/apps/plugins/pdbox/PDa/src/g_canvas.h
@@ -600,605 +600,4 @@ EXTERN t_symbol *iemgui_dollar2raute(t_symbol *s);
#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
}
#endif
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* this file defines the structure for "glists" and related structures and
-functions. "Glists" and "canvases" and "graphs" used to be different
-structures until being unified in version 0.35.
-
-A glist occupies its own window if the "gl_havewindow" flag is set. Its
-appearance on its "parent" or "owner" (if it has one) is as a graph if
-"gl_isgraph" is set, and otherwise as a text box.
-
-A glist is "root" if it has no owner, i.e., a document window. In this
-case "gl_havewindow" is always set.
-
-We maintain a list of root windows, so that we can traverse the whole
-collection of everything in a Pd process.
-
-If a glist has a window it may still not be "mapped." Miniaturized
-windows aren't mapped, for example, but a window is also not mapped
-immediately upon creation. In either case gl_havewindow is true but
-gl_mapped is false.
-
-Closing a non-root window makes it invisible; closing a root destroys it.
-
-A glist that's just a text object on its parent is always "toplevel." An
-embedded glist can switch back and forth to appear as a toplevel by double-
-clicking on it. Single-clicking a text box makes the toplevel become visible
-and raises the window it's in.
-
-If a glist shows up as a graph on its parent, the graph is blanked while the
-glist has its own window, even if miniaturized.
-
-*/
-
-/* NOTE: this file describes Pd implementation details which may change
-in future releases. The public (stable) API is in m_pd.h. */
-
-#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
-extern "C" {
-#endif
-
-/* --------------------- geometry ---------------------------- */
-#define IOWIDTH 7 /* width of an inlet/outlet in pixels */
-#define IOMIDDLE ((IOWIDTH-1)/2)
-#define GLIST_DEFGRAPHWIDTH 200
-#define GLIST_DEFGRAPHHEIGHT 140
-/* ----------------------- data ------------------------------- */
-
-typedef struct _updateheader
-{
- struct _updateheader *upd_next;
- unsigned int upd_array:1; /* true if array, false if glist */
- unsigned int upd_queued:1; /* true if we're queued */
-} t_updateheader;
-
- /* types to support glists grabbing mouse motion or keys from parent */
-typedef void (*t_glistmotionfn)(void *z, t_floatarg dx, t_floatarg dy);
-typedef void (*t_glistkeyfn)(void *z, t_floatarg key);
-
-EXTERN_STRUCT _rtext;
-#define t_rtext struct _rtext
-EXTERN_STRUCT _gtemplate;
-#define t_gtemplate struct _gtemplate
-
-EXTERN_STRUCT _guiconnect;
-#define t_guiconnect struct _guiconnect
-
-EXTERN_STRUCT _tscalar;
-#define t_tscalar struct _tscalar
-
-EXTERN_STRUCT _canvasenvironment;
-#define t_canvasenvironment struct _canvasenvironment
-
-typedef struct _selection
-{
- t_gobj *sel_what;
- struct _selection *sel_next;
-} t_selection;
-
- /* this structure is instantiated whenever a glist becomes visible. */
-typedef struct _editor
-{
- t_updateheader e_upd; /* update header structure */
- t_selection *e_updlist; /* list of objects to update */
- t_rtext *e_rtext; /* text responder linked list */
- t_selection *e_selection; /* head of the selection list */
- t_rtext *e_textedfor; /* the rtext if any that we are editing */
- t_gobj *e_grab; /* object being "dragged" */
- t_glistmotionfn e_motionfn; /* ... motion callback */
- t_glistkeyfn e_keyfn; /* ... keypress callback */
- t_binbuf *e_connectbuf; /* connections to deleted objects */
- t_binbuf *e_deleted; /* last stuff we deleted */
- t_guiconnect *e_guiconnect; /* GUI connection for filtering messages */
- struct _glist *e_glist; /* glist which owns this */
- int e_xwas; /* xpos on last mousedown or motion event */
- int e_ywas; /* ypos, similarly */
- int e_selectline_index1; /* indices for the selected line if any */
- int e_selectline_outno; /* (only valid if e_selectedline is set) */
- int e_selectline_index2;
- int e_selectline_inno;
- t_outconnect *e_selectline_tag;
- unsigned int e_onmotion: 3; /* action to take on motion */
- unsigned int e_lastmoved: 1; /* one if mouse has moved since click */
- unsigned int e_textdirty: 1; /* one if e_textedfor has changed */
- unsigned int e_selectedline: 1; /* one if a line is selected */
-} t_editor;
-
-#define MA_NONE 0 /* e_onmotion: do nothing on mouse motion */
-#define MA_MOVE 1 /* drag the selection around */
-#define MA_CONNECT 2 /* make a connection */
-#define MA_REGION 3 /* selection region */
-#define MA_PASSOUT 4 /* send on to e_grab */
-#define MA_DRAGTEXT 5 /* drag in text editor to alter selection */
-
-/* editor structure for "garrays". We don't bother to delete and regenerate
-this structure when the "garray" becomes invisible or visible, although we
-could do so if the structure gets big (like the "editor" above.) */
-
-typedef struct _arrayvis
-{
- t_updateheader av_upd; /* update header structure */
- t_garray *av_garray; /* owning structure */
-} t_arrayvis;
-
-/* the t_tick structure describes where to draw x and y "ticks" for a glist */
-
-typedef struct _tick /* where to put ticks on x or y axes */
-{
- float k_point; /* one point to draw a big tick at */
- float k_inc; /* x or y increment per little tick */
- int k_lperb; /* little ticks per big; 0 if no ticks to draw */
-} t_tick;
-
-/* the t_glist structure, which describes a list of elements that live on an
-area of a window.
-
-*/
-
-struct _glist
-{
- t_object gl_obj; /* header in case we're a glist */
- t_gobj *gl_list; /* the actual data */
- struct _gstub *gl_stub; /* safe pointer handler */
- int gl_valid; /* incremented when pointers might be stale */
- struct _glist *gl_owner; /* parent glist, supercanvas, or 0 if none */
- int gl_pixwidth; /* width in pixels (on parent, if a graph) */
- int gl_pixheight;
- float gl_x1; /* bounding rectangle in our own coordinates */
- float gl_y1;
- float gl_x2;
- float gl_y2;
- int gl_screenx1; /* screen coordinates when toplevel */
- int gl_screeny1;
- int gl_screenx2;
- int gl_screeny2;
- t_tick gl_xtick; /* ticks marking X values */
- int gl_nxlabels; /* number of X coordinate labels */
- t_symbol **gl_xlabel; /* ... an array to hold them */
- float gl_xlabely; /* ... and their Y coordinates */
- t_tick gl_ytick; /* same as above for Y ticks and labels */
- int gl_nylabels;
- t_symbol **gl_ylabel;
- float gl_ylabelx;
- t_editor *gl_editor; /* editor structure when visible */
- t_symbol *gl_name; /* symbol bound here */
- int gl_font; /* nominal font size in points, e.g., 10 */
- struct _glist *gl_next; /* link in list of toplevels */
- t_canvasenvironment *gl_env; /* root canvases and abstractions only */
- unsigned int gl_havewindow:1; /* true if we own a window */
- unsigned int gl_mapped:1; /* true if, moreover, it's "mapped" */
- unsigned int gl_dirty:1; /* (root canvas only:) patch has changed */
- unsigned int gl_loading:1; /* am now loading from file */
- unsigned int gl_willvis:1; /* make me visible after loading */
- unsigned int gl_edit:1; /* edit mode */
- unsigned int gl_isdeleting:1; /* we're inside glist_delete -- hack! */
- unsigned int gl_stretch:1; /* stretch contents on resize */
- unsigned int gl_isgraph:1; /* show as graph on parent */
-};
-
-#define gl_gobj gl_obj.te_g
-#define gl_pd gl_gobj.g_pd
-
-/* a data structure to describe a field in a pure datum */
-
-#define DT_FLOAT 0
-#define DT_SYMBOL 1
-#define DT_LIST 2
-#define DT_ARRAY 3
-
-typedef struct _dataslot
-{
- int ds_type;
- t_symbol *ds_name;
- t_symbol *ds_arraytemplate; /* filled in for arrays only */
-} t_dataslot;
-
-
-/* T.Grill - changed t_pd member to t_pdobj to avoid name clashed */
-typedef struct _template
-{
- t_pd t_pdobj; /* header */
- struct _gtemplate *t_list; /* list of "struct"/gtemplate objects */
- t_symbol *t_sym; /* name */
- int t_n; /* number of dataslots (fields) */
- t_dataslot *t_vec; /* array of dataslots */
-} t_template;
-
-struct _array
-{
- int a_n; /* number of elements */
- int a_elemsize; /* size in bytes; LATER get this from template */
- char *a_vec; /* array of elements */
- t_symbol *a_templatesym; /* template for elements */
- int a_valid; /* protection against stale pointers into array */
- t_gpointer a_gp; /* pointer to scalar or array element we're in */
- t_gstub *a_stub;
-};
-
- /* structure for traversing all the connections in a glist */
-typedef struct _linetraverser
-{
- t_canvas *tr_x;
- t_object *tr_ob;
- int tr_nout;
- int tr_outno;
- t_object *tr_ob2;
- t_outlet *tr_outlet;
- t_inlet *tr_inlet;
- int tr_nin;
- int tr_inno;
- int tr_x11, tr_y11, tr_x12, tr_y12;
- int tr_x21, tr_y21, tr_x22, tr_y22;
- int tr_lx1, tr_ly1, tr_lx2, tr_ly2;
- t_outconnect *tr_nextoc;
- int tr_nextoutno;
-} t_linetraverser;
-
-/* function types used to define graphical behavior for gobjs, a bit like X
-widgets. We don't use Pd methods because Pd's typechecking can't specify the
-types of pointer arguments. Also it's more convenient this way, since
-every "patchable" object can just get the "text" behaviors. */
-
- /* Call this to get a gobj's bounding rectangle in pixels */
-typedef void (*t_getrectfn)(t_gobj *x, struct _glist *glist,
- int *x1, int *y1, int *x2, int *y2);
- /* and this to displace a gobj: */
-typedef void (*t_displacefn)(t_gobj *x, struct _glist *glist, int dx, int dy);
- /* change color to show selection: */
-typedef void (*t_selectfn)(t_gobj *x, struct _glist *glist, int state);
- /* change appearance to show activation/deactivation: */
-typedef void (*t_activatefn)(t_gobj *x, struct _glist *glist, int state);
- /* warn a gobj it's about to be deleted */
-typedef void (*t_deletefn)(t_gobj *x, struct _glist *glist);
- /* making visible or invisible */
-typedef void (*t_visfn)(t_gobj *x, struct _glist *glist, int flag);
- /* field a mouse click (when not in "edit" mode) */
-typedef int (*t_clickfn)(t_gobj *x, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit);
- /* ... and later, resizing; getting/setting font or color... */
-
-struct _widgetbehavior
-{
- t_getrectfn w_getrectfn;
- t_displacefn w_displacefn;
- t_selectfn w_selectfn;
- t_activatefn w_activatefn;
- t_deletefn w_deletefn;
- t_visfn w_visfn;
- t_clickfn w_clickfn;
-};
-
-/* -------- behaviors for scalars defined by objects in template --------- */
-/* these are set by "drawing commands" in g_template.c which add appearance to
-scalars, which live in some other window. If the scalar is just included
-in a canvas the "parent" is a misnomer. There is also a text scalar object
-which really does draw the scalar on the parent window; see g_scalar.c. */
-
-/* note how the click function wants the whole scalar, not the "data", so
-doesn't work on array elements... LATER reconsider this */
-
- /* bounding rectangle: */
-typedef void (*t_parentgetrectfn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int *x1, int *y1, int *x2, int *y2);
- /* displace it */
-typedef void (*t_parentdisplacefn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int dx, int dy);
- /* change color to show selection */
-typedef void (*t_parentselectfn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int state);
- /* change appearance to show activation/deactivation: */
-typedef void (*t_parentactivatefn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int state);
- /* making visible or invisible */
-typedef void (*t_parentvisfn)(t_gobj *x, struct _glist *glist,
- t_word *data, t_template *tmpl, float basex, float basey,
- int flag);
- /* field a mouse click */
-typedef int (*t_parentclickfn)(t_gobj *x, struct _glist *glist,
- t_scalar *sc, t_template *tmpl, float basex, float basey,
- int xpix, int ypix, int shift, int alt, int dbl, int doit);
-
-struct _parentwidgetbehavior
-{
- t_parentgetrectfn w_parentgetrectfn;
- t_parentdisplacefn w_parentdisplacefn;
- t_parentselectfn w_parentselectfn;
- t_parentactivatefn w_parentactivatefn;
- t_parentvisfn w_parentvisfn;
- t_parentclickfn w_parentclickfn;
-};
-
- /* cursor definitions; used as return value for t_parentclickfn */
-#define CURSOR_RUNMODE_NOTHING 0
-#define CURSOR_RUNMODE_CLICKME 1
-#define CURSOR_RUNMODE_THICKEN 2
-#define CURSOR_RUNMODE_ADDPOINT 3
-#define CURSOR_EDITMODE_NOTHING 4
-#define CURSOR_EDITMODE_CONNECT 5
-#define CURSOR_EDITMODE_DISCONNECT 6
-EXTERN void canvas_setcursor(t_glist *x, unsigned int cursornum);
-
-extern t_canvas *canvas_editing; /* last canvas to start text edting */
-extern t_canvas *canvas_whichfind; /* last canvas we did a find in */
-extern t_canvas *canvas_list; /* list of all root canvases */
-extern t_class *vinlet_class, *voutlet_class;
-extern int glist_valid; /* incremented when pointers might be stale */
-
-/* ------------------- functions on any gobj ----------------------------- */
-EXTERN void gobj_getrect(t_gobj *x, t_glist *owner, int *x1, int *y1,
- int *x2, int *y2);
-EXTERN void gobj_displace(t_gobj *x, t_glist *owner, int dx, int dy);
-EXTERN void gobj_select(t_gobj *x, t_glist *owner, int state);
-EXTERN void gobj_activate(t_gobj *x, t_glist *owner, int state);
-EXTERN void gobj_delete(t_gobj *x, t_glist *owner);
-EXTERN void gobj_vis(t_gobj *x, t_glist *glist, int flag);
-EXTERN int gobj_click(t_gobj *x, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit);
-EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
-EXTERN void gobj_properties(t_gobj *x, struct _glist *glist);
-EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
-
-/* -------------------- functions on glists --------------------- */
-EXTERN t_glist *glist_new( void);
-EXTERN void glist_init(t_glist *x);
-EXTERN void glist_add(t_glist *x, t_gobj *g);
-EXTERN void glist_cleanup(t_glist *x);
-EXTERN void glist_free(t_glist *x);
-
-EXTERN void glist_clear(t_glist *x);
-EXTERN t_canvas *glist_getcanvas(t_glist *x);
-EXTERN int glist_isselected(t_glist *x, t_gobj *y);
-EXTERN void glist_select(t_glist *x, t_gobj *y);
-EXTERN void glist_deselect(t_glist *x, t_gobj *y);
-EXTERN void glist_noselect(t_glist *x);
-EXTERN void glist_selectall(t_glist *x);
-EXTERN void glist_delete(t_glist *x, t_gobj *y);
-EXTERN void glist_retext(t_glist *x, t_text *y);
-EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
- t_glistkeyfn keyfn, int xpos, int ypos);
-EXTERN int glist_isvisible(t_glist *x);
-EXTERN int glist_istoplevel(t_glist *x);
-EXTERN t_glist *glist_findgraph(t_glist *x);
-EXTERN int glist_getfont(t_glist *x);
-EXTERN void glist_sort(t_glist *canvas);
-EXTERN void glist_read(t_glist *x, t_symbol *filename, t_symbol *format);
-EXTERN void glist_mergefile(t_glist *x, t_symbol *filename, t_symbol *format);
-
-EXTERN float glist_pixelstox(t_glist *x, float xpix);
-EXTERN float glist_pixelstoy(t_glist *x, float ypix);
-EXTERN float glist_xtopixels(t_glist *x, float xval);
-EXTERN float glist_ytopixels(t_glist *x, float yval);
-EXTERN float glist_dpixtodx(t_glist *x, float dxpix);
-EXTERN float glist_dpixtody(t_glist *x, float dypix);
-
-EXTERN void glist_redrawitem(t_glist *owner, t_gobj *gobj);
-EXTERN void glist_getnextxy(t_glist *gl, int *xval, int *yval);
-EXTERN void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv);
-EXTERN t_glist *glist_addglist(t_glist *g, t_symbol *sym,
- float x1, float y1, float x2, float y2,
- float px1, float py1, float px2, float py2);
-EXTERN void glist_arraydialog(t_glist *parent, t_symbol *name,
- t_floatarg size, t_floatarg saveit, t_floatarg newgraph);
-EXTERN t_binbuf *glist_writetobinbuf(t_glist *x, int wholething);
-EXTERN int glist_isgraph(t_glist *x);
-EXTERN void glist_redraw(t_glist *x);
-EXTERN void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
- char *tag, int x1, int y1, int x2, int y2);
-EXTERN void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag);
-EXTERN void canvas_create_editor(t_glist *x, int createit);
-void canvas_deletelinesforio(t_canvas *x, t_text *text,
- t_inlet *inp, t_outlet *outp);
-
-
-/* -------------------- functions on texts ------------------------- */
-EXTERN void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize);
-EXTERN void text_drawborder(t_text *x, t_glist *glist, char *tag,
- int width, int height, int firsttime);
-EXTERN void text_eraseborder(t_text *x, t_glist *glist, char *tag);
-EXTERN int text_xcoord(t_text *x, t_glist *glist);
-EXTERN int text_ycoord(t_text *x, t_glist *glist);
-EXTERN int text_xpix(t_text *x, t_glist *glist);
-EXTERN int text_ypix(t_text *x, t_glist *glist);
-EXTERN int text_shouldvis(t_text *x, t_glist *glist);
-
-/* -------------------- functions on rtexts ------------------------- */
-#define RTEXT_DOWN 1
-#define RTEXT_DRAG 2
-#define RTEXT_DBL 3
-#define RTEXT_SHIFT 4
-
-EXTERN t_rtext *rtext_new(t_glist *glist, t_text *who);
-EXTERN t_rtext *glist_findrtext(t_glist *gl, t_text *who);
-EXTERN void rtext_draw(t_rtext *x);
-EXTERN void rtext_erase(t_rtext *x);
-EXTERN t_rtext *rtext_remove(t_rtext *first, t_rtext *x);
-EXTERN int rtext_height(t_rtext *x);
-EXTERN void rtext_displace(t_rtext *x, int dx, int dy);
-EXTERN void rtext_select(t_rtext *x, int state);
-EXTERN void rtext_activate(t_rtext *x, int state);
-EXTERN void rtext_free(t_rtext *x);
-EXTERN void rtext_key(t_rtext *x, int n, t_symbol *s);
-EXTERN void rtext_mouse(t_rtext *x, int xval, int yval, int flag);
-EXTERN void rtext_retext(t_rtext *x);
-EXTERN int rtext_width(t_rtext *x);
-EXTERN int rtext_height(t_rtext *x);
-EXTERN char *rtext_gettag(t_rtext *x);
-EXTERN void rtext_gettext(t_rtext *x, char **buf, int *bufsize);
-
-/* -------------------- functions on canvases ------------------------ */
-EXTERN t_class *canvas_class;
-
-EXTERN t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv);
-EXTERN t_symbol *canvas_makebindsym(t_symbol *s);
-EXTERN void canvas_vistext(t_canvas *x, t_text *y);
-EXTERN void canvas_fixlinesfor(t_canvas *x, t_text *text);
-EXTERN void canvas_deletelinesfor(t_canvas *x, t_text *text);
-EXTERN void canvas_stowconnections(t_canvas *x);
-EXTERN void canvas_restoreconnections(t_canvas *x);
-EXTERN void canvas_redraw(t_canvas *x);
-
-EXTERN t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *sym);
-EXTERN void canvas_rminlet(t_canvas *x, t_inlet *ip);
-EXTERN t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *sym);
-EXTERN void canvas_rmoutlet(t_canvas *x, t_outlet *op);
-EXTERN void canvas_redrawallfortemplate(t_canvas *tmpl);
-EXTERN void canvas_zapallfortemplate(t_canvas *tmpl);
-EXTERN void canvas_setusedastemplate(t_canvas *x);
-EXTERN t_canvas *canvas_getcurrent(void);
-EXTERN void canvas_setcurrent(t_canvas *x);
-EXTERN void canvas_unsetcurrent(t_canvas *x);
-EXTERN t_symbol *canvas_realizedollar(t_canvas *x, t_symbol *s);
-EXTERN t_canvas *canvas_getrootfor(t_canvas *x);
-EXTERN void canvas_dirty(t_canvas *x, t_int n);
-EXTERN int canvas_getfont(t_canvas *x);
-typedef int (*t_canvasapply)(t_canvas *x, t_int x1, t_int x2, t_int x3);
-
-EXTERN t_int *canvas_recurapply(t_canvas *x, t_canvasapply *fn,
- t_int x1, t_int x2, t_int x3);
-
-EXTERN void canvas_resortinlets(t_canvas *x);
-EXTERN void canvas_resortoutlets(t_canvas *x);
-EXTERN void canvas_free(t_canvas *x);
-EXTERN void canvas_updatewindowlist( void);
-EXTERN void canvas_editmode(t_canvas *x, t_floatarg yesplease);
-EXTERN int canvas_isabstraction(t_canvas *x);
-EXTERN int canvas_istable(t_canvas *x);
-EXTERN int canvas_showtext(t_canvas *x);
-EXTERN void canvas_vis(t_canvas *x, t_floatarg f);
-EXTERN t_canvasenvironment *canvas_getenv(t_canvas *x);
-EXTERN void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir);
-EXTERN void canvas_loadbang(t_canvas *x);
-EXTERN int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos,
- int *x1p, int *y1p, int *x2p, int *y2p);
-EXTERN int canvas_setdeleting(t_canvas *x, int flag);
-
-typedef void (*t_undofn)(t_canvas *canvas, void *buf,
- int action); /* a function that does UNDO/REDO */
-#define UNDO_FREE 0 /* free current undo/redo buffer */
-#define UNDO_UNDO 1 /* undo */
-#define UNDO_REDO 2 /* redo */
-EXTERN void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
- const char *name);
-EXTERN void canvas_noundo(t_canvas *x);
-EXTERN int canvas_getindex(t_canvas *x, t_gobj *y);
-
-/* T.Grill - made public for dynamic object creation */
-/* in g_editor.c */
-EXTERN void canvas_connect(t_canvas *x,
- t_floatarg fwhoout, t_floatarg foutno,t_floatarg fwhoin, t_floatarg finno);
-EXTERN void canvas_disconnect(t_canvas *x,
- float index1, float outno, float index2, float inno);
-EXTERN int canvas_isconnected (t_canvas *x,
- t_text *ob1, int n1, t_text *ob2, int n2);
-EXTERN void canvas_selectinrect(t_canvas *x, int lox, int loy, int hix, int hiy);
-
-
-/* ---- functions on canvasses as objects --------------------- */
-
-EXTERN void canvas_fattenforscalars(t_canvas *x,
- int *x1, int *y1, int *x2, int *y2);
-EXTERN void canvas_visforscalars(t_canvas *x, t_glist *glist, int vis);
-EXTERN int canvas_clicksub(t_canvas *x, int xpix, int ypix, int shift,
- int alt, int dbl, int doit);
-EXTERN t_glist *canvas_getglistonsuper(void);
-
-EXTERN void linetraverser_start(t_linetraverser *t, t_canvas *x);
-EXTERN t_outconnect *linetraverser_next(t_linetraverser *t);
-EXTERN void linetraverser_skipobject(t_linetraverser *t);
-
-/* --------------------- functions on tscalars --------------------- */
-
-EXTERN void tscalar_getrect(t_tscalar *x, t_glist *owner,
- int *xp1, int *yp1, int *xp2, int *yp2);
-EXTERN void tscalar_vis(t_tscalar *x, t_glist *owner, int flag);
-EXTERN int tscalar_click(t_tscalar *x, int xpix, int ypix, int shift,
- int alt, int dbl, int doit);
-
-/* --------- functions on garrays (graphical arrays) -------------------- */
-
-EXTERN t_template *garray_template(t_garray *x);
-
-/* -------------------- arrays --------------------- */
-EXTERN t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *tmpl,
- t_floatarg f, t_floatarg saveit);
-EXTERN t_array *array_new(t_symbol *templatesym, t_gpointer *parent);
-EXTERN void array_resize(t_array *x, t_template *tmpl, int n);
-EXTERN void array_free(t_array *x);
-
-/* --------------------- gpointers and stubs ---------------- */
-EXTERN t_gstub *gstub_new(t_glist *gl, t_array *a);
-EXTERN void gstub_cutoff(t_gstub *gs);
-EXTERN void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x);
-
-/* --------------------- scalars ------------------------- */
-EXTERN void word_init(t_word *wp, t_template *tmpl, t_gpointer *gp);
-EXTERN void word_restore(t_word *wp, t_template *tmpl,
- int argc, t_atom *argv);
-EXTERN t_scalar *scalar_new(t_glist *owner,
- t_symbol *templatesym);
-EXTERN void scalar_getbasexy(t_scalar *x, float *basex, float *basey);
-
-/* ------helper routines for "garrays" and "plots" -------------- */
-EXTERN int array_doclick(t_array *array, t_glist *glist, t_gobj *gobj,
- t_symbol *elemtemplatesym,
- float linewidth, float xloc, float xinc, float yloc,
- int xpix, int ypix, int shift, int alt, int dbl, int doit);
-
-EXTERN void array_getcoordinate(t_glist *glist,
- char *elem, int xonset, int yonset, int wonset, int indx,
- float basex, float basey, float xinc,
- float *xp, float *yp, float *wp);
-
-EXTERN int array_getfields(t_symbol *elemtemplatesym,
- t_canvas **elemtemplatecanvasp,
- t_template **elemtemplatep, int *elemsizep,
- int *xonsetp, int *yonsetp, int *wonsetp);
-
-/* --------------------- templates ------------------------- */
-EXTERN t_template *template_new(t_symbol *sym, int argc, t_atom *argv);
-EXTERN void template_free(t_template *x);
-EXTERN int template_match(t_template *x1, t_template *x2);
-EXTERN int template_find_field(t_template *x, t_symbol *name, int *p_onset,
- int *p_type, t_symbol **p_arraytype);
-EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname, t_word *wp,
- int loud);
-EXTERN void template_setfloat(t_template *x, t_symbol *fieldname, t_word *wp,
- t_float f, int loud);
-EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
- t_word *wp, int loud);
-EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
- t_word *wp, t_symbol *s, int loud);
-
-EXTERN t_template *gtemplate_get(t_gtemplate *x);
-EXTERN t_template *template_findbyname(t_symbol *s);
-EXTERN t_canvas *template_findcanvas(t_template *tmpl);
-
-EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname,
- t_word *wp, int loud);
-EXTERN void template_setfloat(t_template *x, t_symbol *fieldname,
- t_word *wp, t_float f, int loud);
-EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
- t_word *wp, int loud);
-EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
- t_word *wp, t_symbol *s, int loud);
-
-/* ----------------------- guiconnects, g_guiconnect.c --------- */
-EXTERN t_guiconnect *guiconnect_new(t_pd *who, t_symbol *sym);
-EXTERN void guiconnect_notarget(t_guiconnect *x, double timedelay);
-
-/* ------------- IEMGUI routines used in other g_ files ---------------- */
-EXTERN t_symbol *iemgui_raute2dollar(t_symbol *s);
-EXTERN t_symbol *iemgui_dollar2raute(t_symbol *s);
-
-#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
-}
-#endif
diff --git a/apps/plugins/pdbox/PDa/src/g_editor.c b/apps/plugins/pdbox/PDa/src/g_editor.c
index a1dea79df1..1190739e1a 100644
--- a/apps/plugins/pdbox/PDa/src/g_editor.c
+++ b/apps/plugins/pdbox/PDa/src/g_editor.c
@@ -2272,2277 +2272,4 @@ void g_editor_setup(void)
/* -------------- copy buffer ------------------ */
copy_binbuf = binbuf_new();
}
-/* Copyright (c) 1997-2001 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "m_pd.h"
-#include "m_imp.h"
-#include "s_stuff.h"
-#include "g_canvas.h"
-#include <string.h>
-
-void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename,
- int selectem);
-
-void open_via_helppath(const char *name, const char *dir);
-char *class_gethelpdir(t_class *c);
-
-/* ------------------ forward declarations --------------- */
-static void canvas_doclear(t_canvas *x);
-static void glist_setlastxy(t_glist *gl, int xval, int yval);
-static void glist_donewloadbangs(t_glist *x);
-static t_binbuf *canvas_docopy(t_canvas *x);
-static void canvas_dopaste(t_canvas *x, t_binbuf *b);
-static void canvas_paste(t_canvas *x);
-static void canvas_clearline(t_canvas *x);
-static t_binbuf *copy_binbuf;
-
-/* ---------------- generic widget behavior ------------------------- */
-
-void gobj_getrect(t_gobj *x, t_glist *glist, int *x1, int *y1,
- int *x2, int *y2)
-{
- if (x->g_pd->c_wb && x->g_pd->c_wb->w_getrectfn)
- (*x->g_pd->c_wb->w_getrectfn)(x, glist, x1, y1, x2, y2);
-}
-void gobj_displace(t_gobj *x, t_glist *glist, int dx, int dy)
-{
- if (x->g_pd->c_wb && x->g_pd->c_wb->w_displacefn)
- (*x->g_pd->c_wb->w_displacefn)(x, glist, dx, dy);
-}
-
-void gobj_select(t_gobj *x, t_glist *glist, int state)
-{
- if (x->g_pd->c_wb && x->g_pd->c_wb->w_selectfn)
- (*x->g_pd->c_wb->w_selectfn)(x, glist, state);
-}
-
-void gobj_activate(t_gobj *x, t_glist *glist, int state)
-{
- if (x->g_pd->c_wb && x->g_pd->c_wb->w_activatefn)
- (*x->g_pd->c_wb->w_activatefn)(x, glist, state);
-}
-
-void gobj_delete(t_gobj *x, t_glist *glist)
-{
- if (x->g_pd->c_wb && x->g_pd->c_wb->w_deletefn)
- (*x->g_pd->c_wb->w_deletefn)(x, glist);
-}
-
-void gobj_vis(t_gobj *x, struct _glist *glist, int flag)
-{
- if (x->g_pd->c_wb && x->g_pd->c_wb->w_visfn)
- (*x->g_pd->c_wb->w_visfn)(x, glist, flag);
-}
-
-int gobj_click(t_gobj *x, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- if (x->g_pd->c_wb && x->g_pd->c_wb->w_clickfn)
- return ((*x->g_pd->c_wb->w_clickfn)(x,
- glist, xpix, ypix, shift, alt, dbl, doit));
- else return (0);
-}
-
-/* ------------------------ managing the selection ----------------- */
-
-void glist_selectline(t_glist *x, t_outconnect *oc, int index1,
- int outno, int index2, int inno)
-{
- if (x->gl_editor)
- {
- glist_noselect(x);
- x->gl_editor->e_selectedline = 1;
- x->gl_editor->e_selectline_index1 = index1;
- x->gl_editor->e_selectline_outno = outno;
- x->gl_editor->e_selectline_index2 = index2;
- x->gl_editor->e_selectline_inno = inno;
- x->gl_editor->e_selectline_tag = oc;
- sys_vgui(".x%x.c itemconfigure l%x -fill blue\n",
- x, x->gl_editor->e_selectline_tag);
- }
-}
-
-void glist_deselectline(t_glist *x)
-{
- if (x->gl_editor)
- {
- x->gl_editor->e_selectedline = 0;
- sys_vgui(".x%x.c itemconfigure l%x -fill black\n",
- x, x->gl_editor->e_selectline_tag);
- }
-}
-
-int glist_isselected(t_glist *x, t_gobj *y)
-{
- if (x->gl_editor)
- {
- t_selection *sel;
- for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next)
- if (sel->sel_what == y) return (1);
- }
- return (0);
-}
-
- /* call this for unselected objects only */
-void glist_select(t_glist *x, t_gobj *y)
-{
- if (x->gl_editor)
- {
- t_selection *sel = (t_selection *)getbytes(sizeof(*sel));
- if (x->gl_editor->e_selectedline)
- glist_deselectline(x);
- /* LATER #ifdef out the following check */
- if (glist_isselected(x, y)) bug("glist_select");
- sel->sel_next = x->gl_editor->e_selection;
- sel->sel_what = y;
- x->gl_editor->e_selection = sel;
- gobj_select(y, x, 1);
- }
-}
-
- /* call this for selected objects only */
-void glist_deselect(t_glist *x, t_gobj *y)
-{
- int fixdsp = 0;
- static int reenter = 0;
- if (reenter) return;
- reenter = 1;
- if (x->gl_editor)
- {
- t_selection *sel, *sel2;
- t_rtext *z = 0;
- if (!glist_isselected(x, y)) bug("glist_deselect");
- if (x->gl_editor->e_textedfor)
- {
- t_rtext *fuddy = glist_findrtext(x, (t_text *)y);
- if (x->gl_editor->e_textedfor == fuddy)
- {
- if (x->gl_editor->e_textdirty)
- {
- z = fuddy;
- canvas_stowconnections(glist_getcanvas(x));
- }
- gobj_activate(y, x, 0);
- }
- if (zgetfn(&y->g_pd, gensym("dsp")))
- fixdsp = 1;
- }
- if ((sel = x->gl_editor->e_selection)->sel_what == y)
- {
- x->gl_editor->e_selection = x->gl_editor->e_selection->sel_next;
- gobj_select(sel->sel_what, x, 0);
- freebytes(sel, sizeof(*sel));
- }
- else
- {
- for (sel = x->gl_editor->e_selection; sel2 = sel->sel_next;
- sel = sel2)
- {
- if (sel2->sel_what == y)
- {
- sel->sel_next = sel2->sel_next;
- gobj_select(sel2->sel_what, x, 0);
- freebytes(sel2, sizeof(*sel2));
- break;
- }
- }
- }
- if (z)
- {
- char *buf;
- int bufsize;
-
- rtext_gettext(z, &buf, &bufsize);
- text_setto((t_text *)y, x, buf, bufsize);
- canvas_fixlinesfor(glist_getcanvas(x), (t_text *)y);
- x->gl_editor->e_textedfor = 0;
- }
- if (fixdsp)
- canvas_update_dsp();
- }
- reenter = 0;
-}
-
-void glist_noselect(t_glist *x)
-{
- if (x->gl_editor)
- {
- while (x->gl_editor->e_selection)
- glist_deselect(x, x->gl_editor->e_selection->sel_what);
- if (x->gl_editor->e_selectedline)
- glist_deselectline(x);
- }
-}
-
-void glist_selectall(t_glist *x)
-{
- if (x->gl_editor)
- {
- glist_noselect(x);
- if (x->gl_list)
- {
- t_selection *sel = (t_selection *)getbytes(sizeof(*sel));
- t_gobj *y = x->gl_list;
- x->gl_editor->e_selection = sel;
- sel->sel_what = y;
- gobj_select(y, x, 1);
- while (y = y->g_next)
- {
- t_selection *sel2 = (t_selection *)getbytes(sizeof(*sel2));
- sel->sel_next = sel2;
- sel = sel2;
- sel->sel_what = y;
- gobj_select(y, x, 1);
- }
- sel->sel_next = 0;
- }
- }
-}
-
- /* get the index of a gobj in a glist. If y is zero, return the
- total number of objects. */
-int glist_getindex(t_glist *x, t_gobj *y)
-{
- t_gobj *y2;
- int indx;
-
- for (y2 = x->gl_list, indx = 0; y2 && y2 != y; y2 = y2->g_next)
- indx++;
- return (indx);
-}
-
- /* get the index of the object, among selected items, if "selected"
- is set; otherwise, among unselected ones. If y is zero, just
- counts the selected or unselected objects. */
-int glist_selectionindex(t_glist *x, t_gobj *y, int selected)
-{
- t_gobj *y2;
- int indx;
-
- for (y2 = x->gl_list, indx = 0; y2 && y2 != y; y2 = y2->g_next)
- if (selected == glist_isselected(x, y2))
- indx++;
- return (indx);
-}
-
-static t_gobj *glist_nth(t_glist *x, int n)
-{
- t_gobj *y;
- int indx;
- for (y = x->gl_list, indx = 0; y; y = y->g_next, indx++)
- if (indx == n)
- return (y);
- return (0);
-}
-
-/* ------------------- support for undo/redo -------------------------- */
-
-static t_undofn canvas_undo_fn; /* current undo function if any */
-static int canvas_undo_whatnext; /* whether we can now UNDO or REDO */
-static void *canvas_undo_buf; /* data private to the undo function */
-static t_canvas *canvas_undo_canvas; /* which canvas we can undo on */
-static const char *canvas_undo_name;
-
-void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
- const char *name)
-{
- int hadone = 0;
- /* blow away the old undo information. In one special case the
- old undo info is re-used; if so we shouldn't free it here. */
- if (canvas_undo_fn && canvas_undo_buf && (buf != canvas_undo_buf))
- {
- (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_FREE);
- hadone = 1;
- }
- canvas_undo_canvas = x;
- canvas_undo_fn = undofn;
- canvas_undo_buf = buf;
- canvas_undo_whatnext = UNDO_UNDO;
- canvas_undo_name = name;
- if (x && glist_isvisible(x) && glist_istoplevel(x))
- /* enable undo in menu */
- sys_vgui("pdtk_undomenu .x%x %s no\n", x, name);
- else if (hadone)
- sys_vgui("pdtk_undomenu nobody no no\n");
-}
-
- /* clear undo if it happens to be for the canvas x.
- (but if x is 0, clear it regardless of who owns it.) */
-void canvas_noundo(t_canvas *x)
-{
- if (!x || (x == canvas_undo_canvas))
- canvas_setundo(0, 0, 0, "foo");
-}
-
-static void canvas_undo(t_canvas *x)
-{
- if (x != canvas_undo_canvas)
- bug("canvas_undo 1");
- else if (canvas_undo_whatnext != UNDO_UNDO)
- bug("canvas_undo 2");
- else
- {
- /* post("undo"); */
- (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_UNDO);
- /* enable redo in menu */
- if (glist_isvisible(x) && glist_istoplevel(x))
- sys_vgui("pdtk_undomenu .x%x no %s\n", x, canvas_undo_name);
- canvas_undo_whatnext = UNDO_REDO;
- }
-}
-
-static void canvas_redo(t_canvas *x)
-{
- if (x != canvas_undo_canvas)
- bug("canvas_undo 1");
- else if (canvas_undo_whatnext != UNDO_REDO)
- bug("canvas_undo 2");
- else
- {
- /* post("redo"); */
- (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_REDO);
- /* enable undo in menu */
- if (glist_isvisible(x) && glist_istoplevel(x))
- sys_vgui("pdtk_undomenu .x%x %s no\n", x, canvas_undo_name);
- canvas_undo_whatnext = UNDO_UNDO;
- }
-}
-
-/* ------- specific undo methods: 1. connect and disconnect -------- */
-
-typedef struct _undo_connect
-{
- int u_index1;
- int u_outletno;
- int u_index2;
- int u_inletno;
-} t_undo_connect;
-
-static void *canvas_undo_set_disconnect(t_canvas *x,
- int index1, int outno, int index2, int inno)
-{
- t_undo_connect *buf = (t_undo_connect *)getbytes(sizeof(*buf));
- buf->u_index1 = index1;
- buf->u_outletno = outno;
- buf->u_index2 = index2;
- buf->u_inletno = inno;
- return (buf);
-}
-
-void canvas_disconnect(t_canvas *x,
- float index1, float outno, float index2, float inno)
-{
- t_linetraverser t;
- t_outconnect *oc;
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- {
- int srcno = canvas_getindex(x, &t.tr_ob->ob_g);
- int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g);
- if (srcno == index1 && t.tr_outno == outno &&
- sinkno == index2 && t.tr_inno == inno)
- {
- sys_vgui(".x%x.c delete l%x\n", x, oc);
- obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
- break;
- }
- }
-}
-
-static void canvas_undo_disconnect(t_canvas *x, void *z, int action)
-{
- t_undo_connect *buf = z;
- if (action == UNDO_UNDO)
- {
- canvas_connect(x, buf->u_index1, buf->u_outletno,
- buf->u_index2, buf->u_inletno);
- }
- else if (action == UNDO_REDO)
- {
- canvas_disconnect(x, buf->u_index1, buf->u_outletno,
- buf->u_index2, buf->u_inletno);
- }
- else if (action == UNDO_FREE)
- t_freebytes(buf, sizeof(*buf));
-}
-
- /* connect just calls disconnect actions backward... */
-static void *canvas_undo_set_connect(t_canvas *x,
- int index1, int outno, int index2, int inno)
-{
- return (canvas_undo_set_disconnect(x, index1, outno, index2, inno));
-}
-
-static void canvas_undo_connect(t_canvas *x, void *z, int action)
-{
- int myaction;
- if (action == UNDO_UNDO)
- myaction = UNDO_REDO;
- else if (action == UNDO_REDO)
- myaction = UNDO_UNDO;
- else myaction = action;
- canvas_undo_disconnect(x, z, myaction);
-}
-
-/* ---------- ... 2. cut, clear, and typing into objects: -------- */
-
-#define UCUT_CUT 1 /* operation was a cut */
-#define UCUT_CLEAR 2 /* .. a clear */
-#define UCUT_TEXT 3 /* text typed into a box */
-
-typedef struct _undo_cut
-{
- t_binbuf *u_objectbuf; /* the object cleared or typed into */
- t_binbuf *u_reconnectbuf; /* connections into and out of object */
- t_binbuf *u_redotextbuf; /* buffer to paste back for redo if TEXT */
- int u_mode; /* from flags above */
-} t_undo_cut;
-
-static void *canvas_undo_set_cut(t_canvas *x, int mode)
-{
- t_undo_cut *buf;
- t_gobj *y;
- t_linetraverser t;
- t_outconnect *oc;
- int nnotsel= glist_selectionindex(x, 0, 0);
- buf = (t_undo_cut *)getbytes(sizeof(*buf));
- buf->u_mode = mode;
- buf->u_redotextbuf = 0;
-
- /* store connections into/out of the selection */
- buf->u_reconnectbuf = binbuf_new();
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- {
- int issel1 = glist_isselected(x, &t.tr_ob->ob_g);
- int issel2 = glist_isselected(x, &t.tr_ob2->ob_g);
- if (issel1 != issel2)
- {
- binbuf_addv(buf->u_reconnectbuf, "ssiiii;",
- gensym("#X"), gensym("connect"),
- (issel1 ? nnotsel : 0)
- + glist_selectionindex(x, &t.tr_ob->ob_g, issel1),
- t.tr_outno,
- (issel2 ? nnotsel : 0) +
- glist_selectionindex(x, &t.tr_ob2->ob_g, issel2),
- t.tr_inno);
- }
- }
- if (mode == UCUT_TEXT)
- {
- buf->u_objectbuf = canvas_docopy(x);
- }
- else if (mode == UCUT_CUT)
- {
- buf->u_objectbuf = 0;
- }
- else if (mode == UCUT_CLEAR)
- {
- buf->u_objectbuf = canvas_docopy(x);
- }
- return (buf);
-}
-
-static void canvas_undo_cut(t_canvas *x, void *z, int action)
-{
- t_undo_cut *buf = z;
- int mode = buf->u_mode;
- if (action == UNDO_UNDO)
- {
- if (mode == UCUT_CUT)
- canvas_dopaste(x, copy_binbuf);
- else if (mode == UCUT_CLEAR)
- canvas_dopaste(x, buf->u_objectbuf);
- else if (mode == UCUT_TEXT)
- {
- t_gobj *y1, *y2;
- glist_noselect(x);
- for (y1 = x->gl_list; y2 = y1->g_next; y1 = y2)
- ;
- if (y1)
- {
- if (!buf->u_redotextbuf)
- {
- glist_noselect(x);
- glist_select(x, y1);
- buf->u_redotextbuf = canvas_docopy(x);
- glist_noselect(x);
- }
- glist_delete(x, y1);
- }
- canvas_dopaste(x, buf->u_objectbuf);
- }
- pd_bind(&x->gl_pd, gensym("#X"));
- binbuf_eval(buf->u_reconnectbuf, 0, 0, 0);
- pd_unbind(&x->gl_pd, gensym("#X"));
- }
- else if (action == UNDO_REDO)
- {
- if (mode == UCUT_CUT || mode == UCUT_CLEAR)
- canvas_doclear(x);
- else if (mode == UCUT_TEXT)
- {
- t_gobj *y1, *y2;
- for (y1 = x->gl_list; y2 = y1->g_next; y1 = y2)
- ;
- if (y1)
- glist_delete(x, y1);
- canvas_dopaste(x, buf->u_redotextbuf);
- pd_bind(&x->gl_pd, gensym("#X"));
- binbuf_eval(buf->u_reconnectbuf, 0, 0, 0);
- pd_unbind(&x->gl_pd, gensym("#X"));
- }
- }
- else if (action == UNDO_FREE)
- {
- if (buf->u_objectbuf)
- binbuf_free(buf->u_objectbuf);
- if (buf->u_reconnectbuf)
- binbuf_free(buf->u_reconnectbuf);
- if (buf->u_redotextbuf)
- binbuf_free(buf->u_redotextbuf);
- t_freebytes(buf, sizeof(*buf));
- }
-}
-
-/* --------- 3. motion, including "tidy up" and stretching ----------- */
-
-typedef struct _undo_move_elem
-{
- int e_index;
- int e_xpix;
- int e_ypix;
-} t_undo_move_elem;
-
-typedef struct _undo_move
-{
- t_undo_move_elem *u_vec;
- int u_n;
-} t_undo_move;
-
-static int canvas_undo_already_set_move;
-
-static void *canvas_undo_set_move(t_canvas *x, int selected)
-{
- int x1, y1, x2, y2, i, indx;
- t_gobj *y;
- t_undo_move *buf = (t_undo_move *)getbytes(sizeof(*buf));
- buf->u_n = selected ? glist_selectionindex(x, 0, 1) : glist_getindex(x, 0);
- buf->u_vec = (t_undo_move_elem *)getbytes(sizeof(*buf->u_vec) *
- (selected ? glist_selectionindex(x, 0, 1) : glist_getindex(x, 0)));
- if (selected)
- {
- for (y = x->gl_list, i = indx = 0; y; y = y->g_next, indx++)
- if (glist_isselected(x, y))
- {
- gobj_getrect(y, x, &x1, &y1, &x2, &y2);
- buf->u_vec[i].e_index = indx;
- buf->u_vec[i].e_xpix = x1;
- buf->u_vec[i].e_ypix = y1;
- i++;
- }
- }
- else
- {
- for (y = x->gl_list, indx = 0; y; y = y->g_next, indx++)
- {
- gobj_getrect(y, x, &x1, &y1, &x2, &y2);
- buf->u_vec[indx].e_index = indx;
- buf->u_vec[indx].e_xpix = x1;
- buf->u_vec[indx].e_ypix = y1;
- }
- }
- canvas_undo_already_set_move = 1;
- return (buf);
-}
-
-static void canvas_undo_move(t_canvas *x, void *z, int action)
-{
- t_undo_move *buf = z;
- if (action == UNDO_UNDO || action == UNDO_REDO)
- {
- int i;
- for (i = 0; i < buf->u_n; i++)
- {
- int x1, y1, x2, y2, newx, newy;
- t_gobj *y;
- newx = buf->u_vec[i].e_xpix;
- newy = buf->u_vec[i].e_ypix;
- y = glist_nth(x, buf->u_vec[i].e_index);
- if (y)
- {
- gobj_getrect(y, x, &x1, &y1, &x2, &y2);
- gobj_displace(y, x, newx-x1, newy - y1);
- buf->u_vec[i].e_xpix = x1;
- buf->u_vec[i].e_ypix = y1;
- }
- }
- }
- else if (action == UNDO_FREE)
- {
- t_freebytes(buf->u_vec, buf->u_n * sizeof(*buf->u_vec));
- t_freebytes(buf, sizeof(*buf));
- }
-}
-
-/* --------- 4. paste (also duplicate) ----------- */
-
-typedef struct _undo_paste
-{
- int u_index; /* index of first object pasted */
-} t_undo_paste;
-
-static void *canvas_undo_set_paste(t_canvas *x)
-{
- t_undo_paste *buf = (t_undo_paste *)getbytes(sizeof(*buf));
- buf->u_index = glist_getindex(x, 0);
- return (buf);
-}
-
-static void canvas_undo_paste(t_canvas *x, void *z, int action)
-{
- t_undo_paste *buf = z;
- if (action == UNDO_UNDO)
- {
- t_gobj *y;
- glist_noselect(x);
- for (y = glist_nth(x, buf->u_index); y; y = y->g_next)
- glist_select(x, y);
- canvas_doclear(x);
- }
- else if (action == UNDO_REDO)
- {
- t_selection *sel;
- canvas_dopaste(x, copy_binbuf);
- /* if it was "duplicate" have to re-enact the displacement. */
- if (canvas_undo_name && canvas_undo_name[0] == 'd')
- for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next)
- gobj_displace(sel->sel_what, x, 10, 10);
- }
-else if (action == UNDO_FREE)
- t_freebytes(buf, sizeof(*buf));
-}
-
- /* recursively check for abstractions to reload as result of a save.
- Don't reload the one we just saved ("except") though. */
- /* LATER try to do the same trick for externs. */
-static void glist_doreload(t_glist *gl, t_symbol *name, t_symbol *dir,
- t_gobj *except)
-{
- t_gobj *g;
- int i, nobj = glist_getindex(gl, 0); /* number of objects */
- for (g = gl->gl_list, i = 0; g && i < nobj; i++)
- {
- if (g != except && pd_class(&g->g_pd) == canvas_class &&
- canvas_isabstraction((t_canvas *)g) &&
- ((t_canvas *)g)->gl_name == name &&
- canvas_getdir((t_canvas *)g) == dir)
- {
- /* we're going to remake the object, so "g" will go stale.
- Get its index here, and afterward restore g. Also, the
- replacement will be at teh end of the list, so we don't
- do g = g->g_next in this case. */
- int j = glist_getindex(gl, g);
- if (!gl->gl_havewindow)
- canvas_vis(glist_getcanvas(gl), 1);
- glist_noselect(gl);
- glist_select(gl, g);
- canvas_setundo(gl, canvas_undo_cut,
- canvas_undo_set_cut(gl, UCUT_CLEAR), "clear");
- canvas_doclear(gl);
- canvas_undo(gl);
- glist_noselect(gl);
- g = glist_nth(gl, j);
- }
- else
- {
- if (g != except && pd_class(&g->g_pd) == canvas_class)
- glist_doreload((t_canvas *)g, name, dir, except);
- g = g->g_next;
- }
- }
-}
-
- /* call canvas_doreload on everyone */
-void canvas_reload(t_symbol *name, t_symbol *dir, t_gobj *except)
-{
- t_canvas *x;
- /* find all root canvases */
- for (x = canvas_list; x; x = x->gl_next)
- glist_doreload(x, name, dir, except);
-}
-
-/* ------------------------ event handling ------------------------ */
-
-#define CURSOR_RUNMODE_NOTHING 0
-#define CURSOR_RUNMODE_CLICKME 1
-#define CURSOR_RUNMODE_THICKEN 2
-#define CURSOR_RUNMODE_ADDPOINT 3
-#define CURSOR_EDITMODE_NOTHING 4
-#define CURSOR_EDITMODE_CONNECT 5
-#define CURSOR_EDITMODE_DISCONNECT 6
-
-static char *cursorlist[] = {
-#ifdef MSW
- "right_ptr", /* CURSOR_RUNMODE_NOTHING */
-#else
- "left_ptr", /* CURSOR_RUNMODE_NOTHING */
-#endif
- "arrow", /* CURSOR_RUNMODE_CLICKME */
- "sb_v_double_arrow", /* CURSOR_RUNMODE_THICKEN */
- "plus", /* CURSOR_RUNMODE_ADDPOINT */
- "hand2", /* CURSOR_EDITMODE_NOTHING */
- "circle", /* CURSOR_EDITMODE_CONNECT */
- "X_cursor" /* CURSOR_EDITMODE_DISCONNECT */
-};
-
-void canvas_setcursor(t_canvas *x, unsigned int cursornum)
-{
- static t_canvas *xwas;
- static unsigned int cursorwas;
- if (cursornum >= sizeof(cursorlist)/sizeof *cursorlist)
- {
- bug("canvas_setcursor");
- return;
- }
- if (xwas != x || cursorwas != cursornum)
- {
- sys_vgui(".x%x configure -cursor %s\n", x, cursorlist[cursornum]);
- xwas = x;
- cursorwas = cursornum;
- }
-}
-
- /* check if a point lies in a gobj. */
-int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos,
- int *x1p, int *y1p, int *x2p, int *y2p)
-{
- int x1, y1, x2, y2;
- t_text *ob;
- if ((ob = pd_checkobject(&y->g_pd)) &&
- !text_shouldvis(ob, x))
- return (0);
- gobj_getrect(y, x, &x1, &y1, &x2, &y2);
- if (xpos >= x1 && xpos <= x2 && ypos >= y1 && ypos <= y2)
- {
- *x1p = x1;
- *y1p = y1;
- *x2p = x2;
- *y2p = y2;
- return (1);
- }
- else return (0);
-}
-
- /* find the last gobj, if any, containing the point. */
-static t_gobj *canvas_findhitbox(t_canvas *x, int xpos, int ypos,
- int *x1p, int *y1p, int *x2p, int *y2p)
-{
- t_gobj *y, *rval = 0;
- for (y = x->gl_list; y; y = y->g_next)
- {
- if (canvas_hitbox(x, y, xpos, ypos, x1p, y1p, x2p, y2p))
- rval = y;
- }
- return (rval);
-}
-
- /* right-clicking on a canvas object pops up a menu. */
-static void canvas_rightclick(t_canvas *x, int xpos, int ypos, t_gobj *y)
-{
- int canprop, canopen;
- canprop = (!y || (y && class_getpropertiesfn(pd_class(&y->g_pd))));
- canopen = (y && zgetfn(&y->g_pd, gensym("menu-open")));
- sys_vgui("pdtk_canvas_popup .x%x %d %d %d %d\n",
- x, xpos, ypos, canprop, canopen);
-}
-
- /* tell GUI to create a properties dialog on the canvas. We tell
- the user the negative of the "pixel" y scale to make it appear to grow
- naturally upward, whereas pixels grow downward. */
-static void canvas_properties(t_glist *x)
-{
- char graphbuf[200];
- sprintf(graphbuf, "pdtk_canvas_dialog %%s %g %g %g %g \n",
- glist_dpixtodx(x, 1), -glist_dpixtody(x, 1),
- (float)glist_isgraph(x), (float)x->gl_stretch);
- gfxstub_new(&x->gl_pd, x, graphbuf);
-}
-
-
-void canvas_setgraph(t_glist *x, int flag)
-{
- if (!flag && glist_isgraph(x))
- {
- if (x->gl_owner && !x->gl_loading && glist_isvisible(x->gl_owner))
- gobj_vis(&x->gl_gobj, x->gl_owner, 0);
- x->gl_isgraph = 0;
- if (x->gl_owner && !x->gl_loading && glist_isvisible(x->gl_owner))
- {
- gobj_vis(&x->gl_gobj, x->gl_owner, 1);
- canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
- }
- }
- else if (flag && !glist_isgraph(x))
- {
- if (x->gl_pixwidth <= 0)
- x->gl_pixwidth = GLIST_DEFGRAPHWIDTH;
-
- if (x->gl_pixheight <= 0)
- x->gl_pixheight = GLIST_DEFGRAPHHEIGHT;
-
- if (x->gl_owner && !x->gl_loading && glist_isvisible(x->gl_owner))
- gobj_vis(&x->gl_gobj, x->gl_owner, 0);
- x->gl_isgraph = 1;
- /* if (x->gl_owner && glist_isvisible(x->gl_owner))
- canvas_vis(x, 1); */
- if (x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner))
- canvas_create_editor(x, 1);
- if (x->gl_owner && !x->gl_loading && glist_isvisible(x->gl_owner))
- {
- gobj_vis(&x->gl_gobj, x->gl_owner, 1);
- canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
- }
- }
-}
-
- /* called from the gui when "OK" is selected on the canvas properties
- dialog. Again we negate "y" scale. */
-static void canvas_donecanvasdialog(t_glist *x, t_floatarg xperpix,
- t_floatarg yperpix, t_floatarg fgraphme)
-{
- int graphme = (fgraphme != 0), redraw = 0;
- yperpix = -yperpix;
- if (xperpix == 0)
- xperpix = 1;
- if (yperpix == 0)
- yperpix = 1;
- canvas_setgraph(x, graphme);
- if (!x->gl_isgraph && (xperpix != glist_dpixtodx(x, 1)))
- {
- if (xperpix > 0)
- {
- x->gl_x1 = 0;
- x->gl_x2 = xperpix;
- }
- else
- {
- x->gl_x1 = -xperpix * (x->gl_screenx2 - x->gl_screenx1);
- x->gl_x2 = x->gl_x1 + xperpix;
- }
- redraw = 1;
- }
- if (!x->gl_isgraph && (yperpix != glist_dpixtody(x, 1)))
- {
- if (yperpix > 0)
- {
- x->gl_y1 = 0;
- x->gl_y2 = yperpix;
- }
- else
- {
- x->gl_y1 = -yperpix * (x->gl_screeny2 - x->gl_screeny1);
- x->gl_y2 = x->gl_y1 + yperpix;
- }
- redraw = 1;
- }
- if (redraw)
- canvas_redraw(x);
-}
-
- /* called from the gui when a popup menu comes back with "properties,"
- "open," or "help." */
-static void canvas_done_popup(t_canvas *x, float which, float xpos, float ypos)
-{
- char pathbuf[MAXPDSTRING], namebuf[MAXPDSTRING];
- t_gobj *y;
- for (y = x->gl_list; y; y = y->g_next)
- {
- int x1, y1, x2, y2;
- if (canvas_hitbox(x, y, xpos, ypos, &x1, &y1, &x2, &y2))
- {
- if (which == 0) /* properties */
- {
- if (!class_getpropertiesfn(pd_class(&y->g_pd)))
- continue;
- (*class_getpropertiesfn(pd_class(&y->g_pd)))(y, x);
- return;
- }
- else if (which == 1) /* open */
- {
- if (!zgetfn(&y->g_pd, gensym("menu-open")))
- continue;
- vmess(&y->g_pd, gensym("menu-open"), "");
- return;
- }
- else /* help */
- {
- char *dir;
- if (pd_class(&y->g_pd) == canvas_class &&
- canvas_isabstraction((t_canvas *)y))
- {
- t_object *ob = (t_object *)y;
- int ac = binbuf_getnatom(ob->te_binbuf);
- t_atom *av = binbuf_getvec(ob->te_binbuf);
- if (ac < 1)
- return;
- atom_string(av, namebuf, MAXPDSTRING);
- dir = canvas_getdir((t_canvas *)y)->s_name;
- }
- else
- {
- strcpy(namebuf, class_gethelpname(pd_class(&y->g_pd)));
- dir = class_gethelpdir(pd_class(&y->g_pd));
- }
- if (strcmp(namebuf + strlen(namebuf) - 3, ".pd"))
- strcat(namebuf, ".pd");
- open_via_helppath(namebuf, dir);
- return;
- }
- }
- }
- if (which == 0)
- canvas_properties(x);
- else if (which == 2)
- {
- strcpy(pathbuf, sys_libdir->s_name);
- strcat(pathbuf, "/doc/5.reference/0.INTRO.txt");
- sys_vgui("menu_opentext %s\n", pathbuf);
- }
-}
-
-#define NOMOD 0
-#define SHIFTMOD 1
-#define CTRLMOD 2
-#define ALTMOD 4
-#define RIGHTCLICK 8
-
-/* on one-button-mouse machines, you can use double click to
- mean right click (which gets the popup menu.) Do this for Mac. */
-#ifdef MACOSX
-#define SIMULATERIGHTCLICK
-#endif
-
-#ifdef SIMULATERIGHTCLICK
-static double canvas_upclicktime;
-static int canvas_upx, canvas_upy;
-#define DCLICKINTERVAL 0.25
-#endif
-
- /* mouse click */
-void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
- int mod, int doit)
-{
- t_gobj *y;
- int shiftmod, runmode, altmod, rightclick;
- int x1, y1, x2, y2, clickreturned = 0;
-
- if (!x->gl_editor)
- {
- bug("editor");
- return;
- }
-
- shiftmod = (mod & SHIFTMOD);
- runmode = ((mod & CTRLMOD) || (!x->gl_edit));
- altmod = (mod & ALTMOD);
- rightclick = (mod & RIGHTCLICK);
-
- canvas_undo_already_set_move = 0;
-
- /* if keyboard was grabbed, notify grabber and cancel the grab */
- if (doit && x->gl_editor->e_grab && x->gl_editor->e_keyfn)
- {
- (* x->gl_editor->e_keyfn) (x->gl_editor->e_grab, 0);
- glist_grab(x, 0, 0, 0, 0, 0);
- }
-
-#ifdef SIMULATERIGHTCLICK
- if (doit && !runmode && xpos == canvas_upx && ypos == canvas_upy &&
- sys_getrealtime() - canvas_upclicktime < DCLICKINTERVAL)
- rightclick = 1;
-#endif
-
- x->gl_editor->e_lastmoved = 0;
- if (doit)
- {
- x->gl_editor->e_grab = 0;
- x->gl_editor->e_onmotion = MA_NONE;
- }
- /* post("click %d %d %d %d", xpos, ypos, which, mod); */
-
- if (x->gl_editor->e_onmotion != MA_NONE)
- return;
-
- x->gl_editor->e_xwas = xpos;
- x->gl_editor->e_ywas = ypos;
-
- if (runmode && !rightclick)
- {
- for (y = x->gl_list; y; y = y->g_next)
- {
- /* check if the object wants to be clicked */
- if (canvas_hitbox(x, y, xpos, ypos, &x1, &y1, &x2, &y2)
- && (clickreturned = gobj_click(y, x, xpos, ypos,
- shiftmod, altmod, 0, doit)))
- break;
- }
- if (!doit)
- {
- if (y)
- canvas_setcursor(x, clickreturned);
- else canvas_setcursor(x, CURSOR_RUNMODE_NOTHING);
- }
- return;
- }
- /* if not a runmode left click, fall here. */
- if (y = canvas_findhitbox(x, xpos, ypos, &x1, &y1, &x2, &y2))
- {
- t_object *ob = pd_checkobject(&y->g_pd);
- /* check you're in the rectangle */
- ob = pd_checkobject(&y->g_pd);
- if (rightclick)
- canvas_rightclick(x, xpos, ypos, y);
- else if (shiftmod)
- {
- if (doit)
- {
- t_rtext *rt;
- if (ob && (rt = x->gl_editor->e_textedfor) &&
- rt == glist_findrtext(x, ob))
- {
- rtext_mouse(rt, xpos - x1, ypos - y1, RTEXT_SHIFT);
- x->gl_editor->e_onmotion = MA_DRAGTEXT;
- x->gl_editor->e_xwas = x1;
- x->gl_editor->e_ywas = y1;
- }
- else
- {
- if (glist_isselected(x, y))
- glist_deselect(x, y);
- else glist_select(x, y);
- }
- }
- }
- else
- {
- /* look for an outlet */
- int noutlet;
- if (ob && (noutlet = obj_noutlets(ob)) && ypos >= y2-4)
- {
- int width = x2 - x1;
- int nout1 = (noutlet > 1 ? noutlet - 1 : 1);
- int closest = ((xpos-x1) * (nout1) + width/2)/width;
- int hotspot = x1 +
- (width - IOWIDTH) * closest / (nout1);
- if (closest < noutlet &&
- xpos >= (hotspot-1) && xpos <= hotspot + (IOWIDTH+1))
- {
- if (doit)
- {
- int issignal = obj_issignaloutlet(ob, closest);
- x->gl_editor->e_onmotion = MA_CONNECT;
- x->gl_editor->e_xwas = xpos;
- x->gl_editor->e_ywas = ypos;
- sys_vgui(
- ".x%x.c create line %d %d %d %d -width %d -tags x\n",
- x, xpos, ypos, xpos, ypos,
- (issignal ? 2 : 1));
- }
- else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT);
- }
- else if (doit)
- goto nooutletafterall;
- }
- /* not in an outlet; select and move */
- else if (doit)
- {
- t_rtext *rt;
- /* check if the box is being text edited */
- nooutletafterall:
- if (ob && (rt = x->gl_editor->e_textedfor) &&
- rt == glist_findrtext(x, ob))
- {
- rtext_mouse(rt, xpos - x1, ypos - y1, RTEXT_DOWN);
- x->gl_editor->e_onmotion = MA_DRAGTEXT;
- x->gl_editor->e_xwas = x1;
- x->gl_editor->e_ywas = y1;
- }
- else
- {
- /* otherwise select and drag to displace */
- if (!glist_isselected(x, y))
- {
- glist_noselect(x);
- glist_select(x, y);
- }
- x->gl_editor->e_onmotion = MA_MOVE;
- }
- }
- else canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
- }
- return;
- }
- /* if right click doesn't hit any boxes, call rightclick
- routine anyway */
- if (rightclick)
- canvas_rightclick(x, xpos, ypos, 0);
-
- /* if not an editing action, and if we didn't hit a
- box, set cursor and return */
- if (runmode || rightclick)
- {
- canvas_setcursor(x, CURSOR_RUNMODE_NOTHING);
- return;
- }
- /* having failed to find a box, we try lines now. */
- if (!runmode && !altmod && !shiftmod)
- {
- t_linetraverser t;
- t_outconnect *oc;
- float fx = xpos, fy = ypos;
- t_glist *glist2 = glist_getcanvas(x);
- linetraverser_start(&t, glist2);
- while (oc = linetraverser_next(&t))
- {
- float lx1 = t.tr_lx1, ly1 = t.tr_ly1,
- lx2 = t.tr_lx2, ly2 = t.tr_ly2;
- float area = (lx2 - lx1) * (fy - ly1) -
- (ly2 - ly1) * (fx - lx1);
- float dsquare = (lx2-lx1) * (lx2-lx1) + (ly2-ly1) * (ly2-ly1);
- if (area * area >= 50 * dsquare) continue;
- if ((lx2-lx1) * (fx-lx1) + (ly2-ly1) * (fy-ly1) < 0) continue;
- if ((lx2-lx1) * (lx2-fx) + (ly2-ly1) * (ly2-fy) < 0) continue;
- if (doit)
- {
- glist_selectline(glist2, oc,
- canvas_getindex(glist2, &t.tr_ob->ob_g), t.tr_outno,
- canvas_getindex(glist2, &t.tr_ob2->ob_g), t.tr_inno);
- }
- canvas_setcursor(x, CURSOR_EDITMODE_DISCONNECT);
- return;
- }
- }
- canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
- if (doit)
- {
- if (!shiftmod) glist_noselect(x);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags x\n",
- x, xpos, ypos, xpos, ypos);
- x->gl_editor->e_xwas = xpos;
- x->gl_editor->e_ywas = ypos;
- x->gl_editor->e_onmotion = MA_REGION;
- }
-}
-
-void canvas_mousedown(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
- t_floatarg which, t_floatarg mod)
-{
- canvas_doclick(x, xpos, ypos, which, mod, 1);
-}
-
-int canvas_isconnected (t_canvas *x, t_text *ob1, int n1,
- t_text *ob2, int n2)
-{
- t_linetraverser t;
- t_outconnect *oc;
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- if (t.tr_ob == ob1 && t.tr_outno == n1 &&
- t.tr_ob2 == ob2 && t.tr_inno == n2)
- return (1);
- return (0);
-}
-
-void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit)
-{
- int x11, y11, x12, y12;
- t_gobj *y1;
- int x21, y21, x22, y22;
- t_gobj *y2;
- int xwas = x->gl_editor->e_xwas,
- ywas = x->gl_editor->e_ywas;
- if (doit) sys_vgui(".x%x.c delete x\n", x);
- else sys_vgui(".x%x.c coords x %d %d %d %d\n",
- x, x->gl_editor->e_xwas,
- x->gl_editor->e_ywas, xpos, ypos);
-
- if ((y1 = canvas_findhitbox(x, xwas, ywas, &x11, &y11, &x12, &y12))
- && (y2 = canvas_findhitbox(x, xpos, ypos, &x21, &y21, &x22, &y22)))
- {
- t_object *ob1 = pd_checkobject(&y1->g_pd);
- t_object *ob2 = pd_checkobject(&y2->g_pd);
- int noutlet1, ninlet2;
- if (ob1 && ob2 && ob1 != ob2 &&
- (noutlet1 = obj_noutlets(ob1))
- && (ninlet2 = obj_ninlets(ob2)))
- {
- int width1 = x12 - x11, closest1, hotspot1;
- int width2 = x22 - x21, closest2, hotspot2;
- int lx1, lx2, ly1, ly2;
- t_outconnect *oc;
-
- if (noutlet1 > 1)
- {
- closest1 = ((xwas-x11) * (noutlet1-1) + width1/2)/width1;
- hotspot1 = x11 +
- (width1 - IOWIDTH) * closest1 / (noutlet1-1);
- }
- else closest1 = 0, hotspot1 = x11;
-
- if (ninlet2 > 1)
- {
- closest2 = ((xpos-x21) * (ninlet2-1) + width2/2)/width2;
- hotspot2 = x21 +
- (width2 - IOWIDTH) * closest2 / (ninlet2-1);
- }
- else closest2 = 0, hotspot2 = x21;
-
- if (closest1 >= noutlet1)
- closest1 = noutlet1 - 1;
- if (closest2 >= ninlet2)
- closest2 = ninlet2 - 1;
-
- if (canvas_isconnected (x, ob1, closest1, ob2, closest2))
- {
- canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
- return;
- }
- if (obj_issignaloutlet(ob1, closest1) &&
- !obj_issignalinlet(ob2, closest2))
- {
- if (doit)
- error("can't connect signal outlet to control inlet");
- canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
- return;
- }
- if (doit)
- {
- oc = obj_connect(ob1, closest1, ob2, closest2);
- lx1 = x11 + (noutlet1 > 1 ?
- ((x12-x11-IOWIDTH) * closest1)/(noutlet1-1) : 0)
- + IOMIDDLE;
- ly1 = y12;
- lx2 = x21 + (ninlet2 > 1 ?
- ((x22-x21-IOWIDTH) * closest2)/(ninlet2-1) : 0)
- + IOMIDDLE;
- ly2 = y21;
- sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n",
- glist_getcanvas(x),
- lx1, ly1, lx2, ly2,
- (obj_issignaloutlet(ob1, closest1) ? 2 : 1), oc);
- canvas_setundo(x, canvas_undo_connect,
- canvas_undo_set_connect(x,
- canvas_getindex(x, &ob1->ob_g), closest1,
- canvas_getindex(x, &ob2->ob_g), closest2),
- "connect");
- }
- else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT);
- return;
- }
- }
- canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
-}
-
-void canvas_selectinrect(t_canvas *x, int lox, int loy, int hix, int hiy)
-{
- t_gobj *y;
- for (y = x->gl_list; y; y = y->g_next)
- {
- int x1, y1, x2, y2;
- gobj_getrect(y, x, &x1, &y1, &x2, &y2);
- if (hix >= x1 && lox <= x2 && hiy >= y1 && loy <= y2
- && !glist_isselected(x, y))
- glist_select(x, y);
- }
-}
-
-static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
-{
- if (doit)
- {
- int lox, loy, hix, hiy;
- if (x->gl_editor->e_xwas < xpos)
- lox = x->gl_editor->e_xwas, hix = xpos;
- else hix = x->gl_editor->e_xwas, lox = xpos;
- if (x->gl_editor->e_ywas < ypos)
- loy = x->gl_editor->e_ywas, hiy = ypos;
- else hiy = x->gl_editor->e_ywas, loy = ypos;
- canvas_selectinrect(x, lox, loy, hix, hiy);
- sys_vgui(".x%x.c delete x\n", x);
- x->gl_editor->e_onmotion = 0;
- }
- else sys_vgui(".x%x.c coords x %d %d %d %d\n",
- x, x->gl_editor->e_xwas,
- x->gl_editor->e_ywas, xpos, ypos);
-}
-
-void canvas_mouseup(t_canvas *x,
- t_floatarg fxpos, t_floatarg fypos, t_floatarg fwhich)
-{
- t_gobj *y;
-
- int xpos = fxpos, ypos = fypos, which = fwhich;
-
- if (!x->gl_editor)
- {
- bug("editor");
- return;
- }
-
-#ifdef SIMULATERIGHTCLICK
- canvas_upclicktime = sys_getrealtime();
- canvas_upx = xpos;
- canvas_upy = ypos;
-#endif
-
- if (x->gl_editor->e_onmotion == MA_CONNECT)
- canvas_doconnect(x, xpos, ypos, which, 1);
- else if (x->gl_editor->e_onmotion == MA_REGION)
- canvas_doregion(x, xpos, ypos, 1);
- else if (x->gl_editor->e_onmotion == MA_MOVE)
- {
- /* after motion, if there's only one item selected, activate it */
- if (x->gl_editor->e_selection &&
- !(x->gl_editor->e_selection->sel_next))
- gobj_activate(x->gl_editor->e_selection->sel_what,
- x, 1);
- }
- else if (x->gl_editor->e_onmotion == MA_PASSOUT)
- x->gl_editor->e_onmotion = 0;
- x->gl_editor->e_onmotion = MA_NONE;
-
-
-#if 1
- /* GG misused the (unused) dbl parameter to tell if mouseup */
-
- for (y = x->gl_list; y; y = y->g_next) {
- int x1, y1, x2, y2, clickreturned = 0;
-
- /* check if the object wants to be clicked */
- if (canvas_hitbox(x, y, xpos, ypos, &x1, &y1, &x2, &y2)
- && (clickreturned = gobj_click(y, x, xpos, ypos,
- 0, 0, 1, 0)))
- break;
- }
-#endif
-
-
-}
-
- /* displace the selection by (dx, dy) pixels */
-static void canvas_displaceselection(t_canvas *x, int dx, int dy)
-{
- t_selection *y;
- int resortin = 0, resortout = 0;
- if (!canvas_undo_already_set_move)
- {
- canvas_setundo(x, canvas_undo_move, canvas_undo_set_move(x, 1),
- "motion");
- canvas_undo_already_set_move = 1;
- }
- for (y = x->gl_editor->e_selection; y; y = y->sel_next)
- {
- t_class *cl = pd_class(&y->sel_what->g_pd);
- gobj_displace(y->sel_what, x, dx, dy);
- if (cl == vinlet_class) resortin = 1;
- else if (cl == voutlet_class) resortout = 1;
- }
- if (resortin) canvas_resortinlets(x);
- if (resortout) canvas_resortoutlets(x);
- canvas_dirty(x, 1);
-}
-
- /* this routine is called whenever a key is pressed or released. "x"
- may be zero if there's no current canvas. The first argument is true or
- fals for down/up; the second one is either a symbolic key name (e.g.,
- "Right" or an Ascii key number. */
-void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
-{
- static t_symbol *keynumsym, *keyupsym, *keynamesym;
- int keynum, fflag;
- t_symbol *gotkeysym;
-
- int down, shift;
-
- if (ac < 3)
- return;
- if (!x->gl_editor)
- {
- bug("editor");
- return;
- }
- canvas_undo_already_set_move = 0;
- down = (atom_getfloat(av) != 0); /* nonzero if it's a key down */
- shift = (atom_getfloat(av+2) != 0); /* nonzero if shift-ed */
- if (av[1].a_type == A_SYMBOL)
- gotkeysym = av[1].a_w.w_symbol;
- else if (av[1].a_type == A_FLOAT)
- {
- char buf[3];
- sprintf(buf, "%c", (int)(av[1].a_w.w_float));
- gotkeysym = gensym(buf);
- }
- else gotkeysym = gensym("?");
- fflag = (av[0].a_type == A_FLOAT ? av[0].a_w.w_float : 0);
- keynum = (av[1].a_type == A_FLOAT ? av[1].a_w.w_float : 0);
- if (keynum == '\\' || keynum == '{' || keynum == '}')
- {
- post("%c: dropped", (int)keynum);
- return;
- }
- if (keynum == '\r') keynum = '\n';
- if (av[1].a_type == A_SYMBOL &&
- !strcmp(av[1].a_w.w_symbol->s_name, "Return"))
- keynum = '\n';
- if (!keynumsym)
- {
- keynumsym = gensym("#key");
- keyupsym = gensym("#keyup");
- keynamesym = gensym("#keyname");
- }
-#ifdef MACOSX
- if (keynum == 30)
- keynum = 0, gotkeysym = gensym("Up");
- else if (keynum == 31)
- keynum = 0, gotkeysym = gensym("Down");
- else if (keynum == 28)
- keynum = 0, gotkeysym = gensym("Left");
- else if (keynum == 29)
- keynum = 0, gotkeysym = gensym("Right");
-#endif
- if (keynumsym->s_thing && down)
- pd_float(keynumsym->s_thing, (float)keynum);
- if (keyupsym->s_thing && !down)
- pd_float(keyupsym->s_thing, (float)keynum);
- if (keynamesym->s_thing)
- {
- t_atom at[2];
- at[0] = av[0];
- SETFLOAT(at, down);
- SETSYMBOL(at+1, gotkeysym);
- pd_list(keynamesym->s_thing, 0, 2, at);
- }
- if (!x->gl_editor) /* if that 'invis'ed the window, we'd better stop. */
- return;
- if (x && down)
- {
- /* if an object has "grabbed" keys just send them on */
- if (x->gl_editor->e_grab
- && x->gl_editor->e_keyfn && keynum)
- (* x->gl_editor->e_keyfn)
- (x->gl_editor->e_grab, (float)keynum);
- /* if a text editor is open send it on */
- else if (x->gl_editor->e_textedfor)
- {
- if (!x->gl_editor->e_textdirty)
- {
- canvas_setundo(x, canvas_undo_cut,
- canvas_undo_set_cut(x, UCUT_TEXT), "typing");
- }
- rtext_key(x->gl_editor->e_textedfor,
- (int)keynum, gotkeysym);
- if (x->gl_editor->e_textdirty)
- canvas_dirty(x, 1);
- }
- /* check for backspace or clear */
- else if (keynum == 8 || keynum == 127)
- {
- if (x->gl_editor->e_selectedline)
- canvas_clearline(x);
- else if (x->gl_editor->e_selection)
- {
- canvas_setundo(x, canvas_undo_cut,
- canvas_undo_set_cut(x, UCUT_CLEAR), "clear");
- canvas_doclear(x);
- }
- }
- /* check for arrow keys */
- else if (!strcmp(gotkeysym->s_name, "Up"))
- canvas_displaceselection(x, 0, shift ? -10 : -1);
- else if (!strcmp(gotkeysym->s_name, "Down"))
- canvas_displaceselection(x, 0, shift ? 10 : 1);
- else if (!strcmp(gotkeysym->s_name, "Left"))
- canvas_displaceselection(x, shift ? -10 : -1, 0);
- else if (!strcmp(gotkeysym->s_name, "Right"))
- canvas_displaceselection(x, shift ? 10 : 1, 0);
- }
-}
-
-void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
- t_floatarg fmod)
-{
- /* post("motion %d %d", xpos, ypos); */
- int mod = fmod;
- if (!x->gl_editor)
- {
- bug("editor");
- return;
- }
- glist_setlastxy(x, xpos, ypos);
- if (x->gl_editor->e_onmotion == MA_MOVE)
- {
- canvas_displaceselection(x,
- xpos - x->gl_editor->e_xwas, ypos - x->gl_editor->e_ywas);
- x->gl_editor->e_xwas = xpos;
- x->gl_editor->e_ywas = ypos;
- }
- else if (x->gl_editor->e_onmotion == MA_REGION)
- canvas_doregion(x, xpos, ypos, 0);
- else if (x->gl_editor->e_onmotion == MA_CONNECT)
- canvas_doconnect(x, xpos, ypos, 0, 0);
- else if (x->gl_editor->e_onmotion == MA_PASSOUT)
- {
- if (!x->gl_editor->e_motionfn)
- bug("e_motionfn");
- (*x->gl_editor->e_motionfn)(&x->gl_editor->e_grab->g_pd,
- xpos - x->gl_editor->e_xwas,
- ypos - x->gl_editor->e_ywas);
- x->gl_editor->e_xwas = xpos;
- x->gl_editor->e_ywas = ypos;
- }
- else if (x->gl_editor->e_onmotion == MA_DRAGTEXT)
- {
- t_rtext *rt = x->gl_editor->e_textedfor;
- if (rt)
- rtext_mouse(rt, xpos - x->gl_editor->e_xwas,
- ypos - x->gl_editor->e_ywas, RTEXT_DRAG);
- }
- else canvas_doclick(x, xpos, ypos, 0, mod, 0);
-
- x->gl_editor->e_lastmoved = 1;
-}
-
-void canvas_startmotion(t_canvas *x)
-{
- int xval, yval;
- if (!x->gl_editor) return;
- glist_getnextxy(x, &xval, &yval);
- if (xval == 0 && yval == 0) return;
- x->gl_editor->e_onmotion = MA_MOVE;
- x->gl_editor->e_xwas = xval;
- x->gl_editor->e_ywas = yval;
-}
-
-/* ----------------------------- window stuff ----------------------- */
-
-void canvas_print(t_canvas *x, t_symbol *s)
-{
- if (*s->s_name) sys_vgui(".x%x.c postscript -file %s\n", x, s->s_name);
- else sys_vgui(".x%x.c postscript -file x.ps\n", x);
-}
-
-void canvas_menuclose(t_canvas *x, t_floatarg force)
-{
- if (x->gl_owner)
- canvas_vis(x, 0);
- else if ((force != 0) || (!x->gl_dirty))
- pd_free(&x->gl_pd);
- else sys_vgui("pdtk_check {This window has been modified. Close anyway?}\
- {.x%x menuclose 1;\n}\n", x);
-}
-
- /* put up a dialog which may call canvas_font back to do the work */
-static void canvas_menufont(t_canvas *x)
-{
- char buf[80];
- t_canvas *x2 = canvas_getrootfor(x);
- gfxstub_deleteforkey(x2);
- sprintf(buf, "pdtk_canvas_dofont %%s %d\n", x2->gl_font);
- gfxstub_new(&x2->gl_pd, &x2->gl_pd, buf);
-}
-
-static int canvas_find_index1, canvas_find_index2;
-static t_binbuf *canvas_findbuf;
-int binbuf_match(t_binbuf *inbuf, t_binbuf *searchbuf);
-
- /* find an atom or string of atoms */
-static int canvas_dofind(t_canvas *x, int *myindex1p)
-{
- t_gobj *y;
- int myindex1 = *myindex1p, myindex2;
- if (myindex1 >= canvas_find_index1)
- {
- for (y = x->gl_list, myindex2 = 0; y;
- y = y->g_next, myindex2++)
- {
- t_object *ob = 0;
- if (ob = pd_checkobject(&y->g_pd))
- {
- if (binbuf_match(ob->ob_binbuf, canvas_findbuf))
- {
- if (myindex1 > canvas_find_index1 ||
- myindex1 == canvas_find_index1 &&
- myindex2 > canvas_find_index2)
- {
- canvas_find_index1 = myindex1;
- canvas_find_index2 = myindex2;
- glist_noselect(x);
- canvas_vis(x, 1);
- canvas_editmode(x, 1.);
- glist_select(x, y);
- return (1);
- }
- }
- }
- }
- }
- for (y = x->gl_list, myindex2 = 0; y; y = y->g_next, myindex2++)
- {
- if (pd_class(&y->g_pd) == canvas_class)
- {
- (*myindex1p)++;
- if (canvas_dofind((t_canvas *)y, myindex1p))
- return (1);
- }
- }
- return (0);
-}
-
-static void canvas_find(t_canvas *x, t_symbol *s, int ac, t_atom *av)
-{
- int myindex1 = 0, i;
- for (i = 0; i < ac; i++)
- {
- if (av[i].a_type == A_SYMBOL)
- {
- if (!strcmp(av[i].a_w.w_symbol->s_name, "_semi_"))
- SETSEMI(&av[i]);
- else if (!strcmp(av[i].a_w.w_symbol->s_name, "_comma_"))
- SETCOMMA(&av[i]);
- }
- }
- if (!canvas_findbuf)
- canvas_findbuf = binbuf_new();
- binbuf_clear(canvas_findbuf);
- binbuf_add(canvas_findbuf, ac, av);
- canvas_find_index1 = 0;
- canvas_find_index2 = -1;
- canvas_whichfind = x;
- if (!canvas_dofind(x, &myindex1))
- {
- binbuf_print(canvas_findbuf);
- post("... couldn't find");
- }
-}
-
-static void canvas_find_again(t_canvas *x)
-{
- int myindex1 = 0;
- if (!canvas_findbuf || !canvas_whichfind)
- return;
- if (!canvas_dofind(canvas_whichfind, &myindex1))
- {
- binbuf_print(canvas_findbuf);
- post("... couldn't find");
- }
-}
-
-static void canvas_find_parent(t_canvas *x)
-{
- if (x->gl_owner)
- canvas_vis(glist_getcanvas(x->gl_owner), 1);
-}
-
-static int glist_dofinderror(t_glist *gl, void *error_object)
-{
- t_gobj *g;
- for (g = gl->gl_list; g; g = g->g_next)
- {
- if ((void *)g == error_object)
- {
- /* got it... now show it. */
- glist_noselect(gl);
- canvas_vis(glist_getcanvas(gl), 1);
- canvas_editmode(glist_getcanvas(gl), 1.);
- glist_select(gl, g);
- return (1);
- }
- else if (g->g_pd == canvas_class)
- {
- if (glist_dofinderror((t_canvas *)g, error_object))
- return (1);
- }
- }
- return (0);
-}
-
-void canvas_finderror(void *error_object)
-{
- t_canvas *x;
- /* find all root canvases */
- for (x = canvas_list; x; x = x->gl_next)
- {
- if (glist_dofinderror(x, error_object))
- return;
- }
- post("... sorry, I couldn't find the source of that error.");
-}
-
-void canvas_stowconnections(t_canvas *x)
-{
- t_gobj *selhead = 0, *seltail = 0, *nonhead = 0, *nontail = 0, *y, *y2;
- t_linetraverser t;
- t_outconnect *oc;
- if (!x->gl_editor) return;
- /* split list to "selected" and "unselected" parts */
- for (y = x->gl_list; y; y = y2)
- {
- y2 = y->g_next;
- if (glist_isselected(x, y))
- {
- if (seltail)
- {
- seltail->g_next = y;
- seltail = y;
- y->g_next = 0;
- }
- else
- {
- selhead = seltail = y;
- seltail->g_next = 0;
- }
- }
- else
- {
- if (nontail)
- {
- nontail->g_next = y;
- nontail = y;
- y->g_next = 0;
- }
- else
- {
- nonhead = nontail = y;
- nontail->g_next = 0;
- }
- }
- }
- /* move the selected part to the end */
- if (!nonhead) x->gl_list = selhead;
- else x->gl_list = nonhead, nontail->g_next = selhead;
-
- /* add connections to binbuf */
- binbuf_clear(x->gl_editor->e_connectbuf);
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- {
- int s1 = glist_isselected(x, &t.tr_ob->ob_g);
- int s2 = glist_isselected(x, &t.tr_ob2->ob_g);
- if (s1 != s2)
- binbuf_addv(x->gl_editor->e_connectbuf, "ssiiii;",
- gensym("#X"), gensym("connect"),
- glist_getindex(x, &t.tr_ob->ob_g), t.tr_outno,
- glist_getindex(x, &t.tr_ob2->ob_g), t.tr_inno);
- }
-}
-
-void canvas_restoreconnections(t_canvas *x)
-{
- pd_bind(&x->gl_pd, gensym("#X"));
- binbuf_eval(x->gl_editor->e_connectbuf, 0, 0, 0);
- pd_unbind(&x->gl_pd, gensym("#X"));
-}
-
-static t_binbuf *canvas_docopy(t_canvas *x)
-{
- t_gobj *y;
- t_linetraverser t;
- t_outconnect *oc;
- t_binbuf *b = binbuf_new();
- for (y = x->gl_list; y; y = y->g_next)
- {
- if (glist_isselected(x, y))
- gobj_save(y, b);
- }
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- {
- if (glist_isselected(x, &t.tr_ob->ob_g)
- && glist_isselected(x, &t.tr_ob2->ob_g))
- {
- binbuf_addv(b, "ssiiii;", gensym("#X"), gensym("connect"),
- glist_selectionindex(x, &t.tr_ob->ob_g, 1), t.tr_outno,
- glist_selectionindex(x, &t.tr_ob2->ob_g, 1), t.tr_inno);
- }
- }
- return (b);
-}
-
-static void canvas_copy(t_canvas *x)
-{
- if (!x->gl_editor || !x->gl_editor->e_selection)
- return;
- binbuf_free(copy_binbuf);
- copy_binbuf = canvas_docopy(x);
-}
-
-static void canvas_clearline(t_canvas *x)
-{
- if (x->gl_editor->e_selectedline)
- {
- canvas_disconnect(x, x->gl_editor->e_selectline_index1,
- x->gl_editor->e_selectline_outno,
- x->gl_editor->e_selectline_index2,
- x->gl_editor->e_selectline_inno);
- canvas_setundo(x, canvas_undo_disconnect,
- canvas_undo_set_disconnect(x,
- x->gl_editor->e_selectline_index1,
- x->gl_editor->e_selectline_outno,
- x->gl_editor->e_selectline_index2,
- x->gl_editor->e_selectline_inno),
- "disconnect");
- }
-}
-
-extern t_pd *newest;
-static void canvas_doclear(t_canvas *x)
-{
- t_gobj *y, *y2;
- int dspstate;
-
- dspstate = canvas_suspend_dsp();
- if (x->gl_editor->e_selectedline)
- {
- canvas_disconnect(x, x->gl_editor->e_selectline_index1,
- x->gl_editor->e_selectline_outno,
- x->gl_editor->e_selectline_index2,
- x->gl_editor->e_selectline_inno);
- canvas_setundo(x, canvas_undo_disconnect,
- canvas_undo_set_disconnect(x,
- x->gl_editor->e_selectline_index1,
- x->gl_editor->e_selectline_outno,
- x->gl_editor->e_selectline_index2,
- x->gl_editor->e_selectline_inno),
- "disconnect");
- }
- /* if text is selected, deselecting it might remake the
- object. So we deselect it and hunt for a "new" object on
- the glist to reselect. */
- if (x->gl_editor->e_textedfor)
- {
- newest = 0;
- glist_noselect(x);
- if (newest)
- {
- for (y = x->gl_list; y; y = y->g_next)
- if (&y->g_pd == newest) glist_select(x, y);
- }
- }
- while (1) /* this is pretty wierd... should rewrite it */
- {
- for (y = x->gl_list; y; y = y2)
- {
- y2 = y->g_next;
- if (glist_isselected(x, y))
- {
- glist_delete(x, y);
-#if 0
- if (y2) post("cut 5 %x %x", y2, y2->g_next);
- else post("cut 6");
-#endif
- goto next;
- }
- }
- goto restore;
- next: ;
- }
-restore:
- canvas_resume_dsp(dspstate);
- canvas_dirty(x, 1);
-}
-
-static void canvas_cut(t_canvas *x)
-{
- if (x->gl_editor && x->gl_editor->e_selectedline)
- canvas_clearline(x);
- else if (x->gl_editor && x->gl_editor->e_selection)
- {
- canvas_setundo(x, canvas_undo_cut,
- canvas_undo_set_cut(x, UCUT_CUT), "cut");
- canvas_copy(x);
- canvas_doclear(x);
- }
-}
-
-static int paste_onset;
-static t_canvas *paste_canvas;
-
-static void glist_donewloadbangs(t_glist *x)
-{
- if (x->gl_editor)
- {
- t_selection *sel;
- for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next)
- if (pd_class(&sel->sel_what->g_pd) == canvas_class)
- canvas_loadbang((t_canvas *)(&sel->sel_what->g_pd));
- }
-}
-
-static void canvas_dopaste(t_canvas *x, t_binbuf *b)
-{
- t_gobj *newgobj, *last, *g2;
- int dspstate = canvas_suspend_dsp(), nbox, count;
-
- canvas_editmode(x, 1.);
- glist_noselect(x);
- for (g2 = x->gl_list, nbox = 0; g2; g2 = g2->g_next) nbox++;
-
- paste_onset = nbox;
- paste_canvas = x;
-
- pd_bind(&x->gl_pd, gensym("#X"));
- binbuf_eval(b, 0, 0, 0);
- pd_unbind(&x->gl_pd, gensym("#X"));
- for (g2 = x->gl_list, count = 0; g2; g2 = g2->g_next, count++)
- if (count >= nbox)
- glist_select(x, g2);
- paste_canvas = 0;
- canvas_resume_dsp(dspstate);
- canvas_dirty(x, 1);
- glist_donewloadbangs(x);
-}
-
-static void canvas_paste(t_canvas *x)
-{
- canvas_setundo(x, canvas_undo_paste, canvas_undo_set_paste(x), "paste");
- canvas_dopaste(x, copy_binbuf);
-}
-
-static void canvas_duplicate(t_canvas *x)
-{
- if (x->gl_editor->e_onmotion == MA_NONE)
- {
- t_selection *y;
- canvas_copy(x);
- canvas_setundo(x, canvas_undo_paste, canvas_undo_set_paste(x),
- "duplicate");
- canvas_dopaste(x, copy_binbuf);
- for (y = x->gl_editor->e_selection; y; y = y->sel_next)
- gobj_displace(y->sel_what, x,
- 10, 10);
- canvas_dirty(x, 1);
- }
-}
-
-static void canvas_selectall(t_canvas *x)
-{
- t_gobj *y;
- if (!x->gl_edit)
- canvas_editmode(x, 1);
- for (y = x->gl_list; y; y = y->g_next)
- {
- if (!glist_isselected(x, y))
- glist_select(x, y);
- }
-}
-
-void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
- t_floatarg fwhoin, t_floatarg finno)
-{
- int whoout = fwhoout, outno = foutno, whoin = fwhoin, inno = finno;
- t_gobj *src = 0, *sink = 0;
- t_object *objsrc, *objsink;
- t_outconnect *oc;
- int nin = whoin, nout = whoout;
- if (paste_canvas == x) whoout += paste_onset, whoin += paste_onset;
- for (src = x->gl_list; whoout; src = src->g_next, whoout--)
- if (!src->g_next) goto bad; /* bug fix thanks to Hannes */
- for (sink = x->gl_list; whoin; sink = sink->g_next, whoin--)
- if (!sink->g_next) goto bad;
- if (!(objsrc = pd_checkobject(&src->g_pd)) ||
- !(objsink = pd_checkobject(&sink->g_pd)))
- goto bad;
- if (!(oc = obj_connect(objsrc, outno, objsink, inno))) goto bad;
- if (glist_isvisible(x))
- {
- sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n",
- glist_getcanvas(x), 0, 0, 0, 0,
- (obj_issignaloutlet(objsrc, outno) ? 2 : 1),oc);
- canvas_fixlinesfor(x, objsrc);
- }
- return;
-
-bad:
- post("%s %d %d %d %d (%s->%s) connection failed",
- x->gl_name->s_name, nout, outno, nin, inno,
- (src? class_getname(pd_class(&src->g_pd)) : "???"),
- (sink? class_getname(pd_class(&sink->g_pd)) : "???"));
-}
-
-#define XTOLERANCE 4
-#define YTOLERANCE 3
-#define NHIST 15
-
- /* LATER might have to speed this up */
-static void canvas_tidy(t_canvas *x)
-{
- t_gobj *y, *y2, *y3;
- int ax1, ay1, ax2, ay2, bx1, by1, bx2, by2;
- int histogram[NHIST], *ip, i, besthist, bestdist;
- /* if nobody is selected, this means do it to all boxes;
- othewise just the selection */
- int all = (x->gl_editor ? (x->gl_editor->e_selection == 0) : 1);
-
- canvas_setundo(x, canvas_undo_move, canvas_undo_set_move(x, !all),
- "motion");
-
- /* tidy horizontally */
- for (y = x->gl_list; y; y = y->g_next)
- if (all || glist_isselected(x, y))
- {
- gobj_getrect(y, x, &ax1, &ay1, &ax2, &ay2);
-
- for (y2 = x->gl_list; y2; y2 = y2->g_next)
- if (all || glist_isselected(x, y2))
- {
- gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2);
- if (by1 <= ay1 + YTOLERANCE && by1 >= ay1 - YTOLERANCE &&
- bx1 < ax1)
- goto nothorizhead;
- }
-
- for (y2 = x->gl_list; y2; y2 = y2->g_next)
- if (all || glist_isselected(x, y2))
- {
- gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2);
- if (by1 <= ay1 + YTOLERANCE && by1 >= ay1 - YTOLERANCE
- && by1 != ay1)
- gobj_displace(y2, x, 0, ay1-by1);
- }
- nothorizhead: ;
- }
- /* tidy vertically. First guess the user's favorite vertical spacing */
- for (i = NHIST, ip = histogram; i--; ip++) *ip = 0;
- for (y = x->gl_list; y; y = y->g_next)
- if (all || glist_isselected(x, y))
- {
- gobj_getrect(y, x, &ax1, &ay1, &ax2, &ay2);
- for (y2 = x->gl_list; y2; y2 = y2->g_next)
- if (all || glist_isselected(x, y2))
- {
- gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2);
- if (bx1 <= ax1 + XTOLERANCE && bx1 >= ax1 - XTOLERANCE)
- {
- int distance = by1-ay2;
- if (distance >= 0 && distance < NHIST)
- histogram[distance]++;
- }
- }
- }
- for (i = 1, besthist = 0, bestdist = 4, ip = histogram + 1;
- i < (NHIST-1); i++, ip++)
- {
- int hit = ip[-1] + 2 * ip[0] + ip[1];
- if (hit > besthist)
- {
- besthist = hit;
- bestdist = i;
- }
- }
- post("best vertical distance %d", bestdist);
- for (y = x->gl_list; y; y = y->g_next)
- if (all || glist_isselected(x, y))
- {
- int keep = 1;
- gobj_getrect(y, x, &ax1, &ay1, &ax2, &ay2);
- for (y2 = x->gl_list; y2; y2 = y2->g_next)
- if (all || glist_isselected(x, y2))
- {
- gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2);
- if (bx1 <= ax1 + XTOLERANCE && bx1 >= ax1 - XTOLERANCE &&
- ay1 >= by2 - 10 && ay1 < by2 + NHIST)
- goto nothead;
- }
- while (keep)
- {
- keep = 0;
- for (y2 = x->gl_list; y2; y2 = y2->g_next)
- if (all || glist_isselected(x, y2))
- {
- gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2);
- if (bx1 <= ax1 + XTOLERANCE && bx1 >= ax1 - XTOLERANCE &&
- by1 > ay1 && by1 < ay2 + NHIST)
- {
- int vmove = ay2 + bestdist - by1;
- gobj_displace(y2, x, ax1-bx1, vmove);
- ay1 = by1 + vmove;
- ay2 = by2 + vmove;
- keep = 1;
- break;
- }
- }
- }
- nothead: ;
- }
- canvas_dirty(x, 1);
-}
-
-static void canvas_texteditor(t_canvas *x)
-{
- t_rtext *foo;
- char *buf;
- int bufsize;
- if (foo = x->gl_editor->e_textedfor)
- rtext_gettext(foo, &buf, &bufsize);
- else buf = "", bufsize = 0;
- sys_vgui("pdtk_pd_texteditor {%.*s}\n", bufsize, buf);
-
-}
-
-void glob_key(void *dummy, t_symbol *s, int ac, t_atom *av)
-{
- /* canvas_editing can be zero; canvas_key checks for that */
- canvas_key(canvas_editing, s, ac, av);
-}
-
-void canvas_editmode(t_canvas *x, t_floatarg fyesplease)
-{
- int yesplease = fyesplease;
- if (yesplease && x->gl_edit)
- return;
- x->gl_edit = !x->gl_edit;
- if (x->gl_edit && glist_isvisible(x) && glist_istoplevel(x))
- canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
- else
- {
- glist_noselect(x);
- if (glist_isvisible(x) && glist_istoplevel(x))
- canvas_setcursor(x, CURSOR_RUNMODE_NOTHING);
- }
- sys_vgui("pdtk_canvas_editval .x%x %d\n",
- glist_getcanvas(x), x->gl_edit);
-}
-
- /* called by canvas_font below */
-static void canvas_dofont(t_canvas *x, t_floatarg font, t_floatarg xresize,
- t_floatarg yresize)
-{
- t_gobj *y;
- x->gl_font = font;
- if (xresize != 1 || yresize != 1)
- {
- canvas_setundo(x, canvas_undo_move, canvas_undo_set_move(x, 0),
- "motion");
- for (y = x->gl_list; y; y = y->g_next)
- {
- int x1, x2, y1, y2, nx1, ny1;
- gobj_getrect(y, x, &x1, &y1, &x2, &y2);
- nx1 = x1 * xresize + 0.5;
- ny1 = y1 * yresize + 0.5;
- gobj_displace(y, x, nx1-x1, ny1-y1);
- }
- }
- if (glist_isvisible(x))
- glist_redraw(x);
- for (y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == canvas_class
- && !canvas_isabstraction((t_canvas *)y))
- canvas_dofont((t_canvas *)y, font, xresize, yresize);
-}
-
- /* canvas_menufont calls up a TK dialog which calls this back */
-static void canvas_font(t_canvas *x, t_floatarg font, t_floatarg resize,
- t_floatarg whichresize)
-{
- float realresize, realresx = 1, realresy = 1;
- t_canvas *x2 = canvas_getrootfor(x);
- if (!resize) realresize = 1;
- else
- {
- if (resize < 20) resize = 20;
- if (resize > 500) resize = 500;
- realresize = resize * 0.01;
- }
- if (whichresize != 3) realresx = realresize;
- if (whichresize != 2) realresy = realresize;
- canvas_dofont(x2, font, realresx, realresy);
- sys_defaultfont = font;
-}
-
-static t_glist *canvas_last_glist;
-static int canvas_last_glist_x, canvas_last_glist_y;
-
-void glist_getnextxy(t_glist *gl, int *xpix, int *ypix)
-{
- if (canvas_last_glist == gl)
- *xpix = canvas_last_glist_x, *ypix = canvas_last_glist_y;
- else *xpix = *ypix = 40;
-}
-
-static void glist_setlastxy(t_glist *gl, int xval, int yval)
-{
- canvas_last_glist = gl;
- canvas_last_glist_x = xval;
- canvas_last_glist_y = yval;
-}
-
-
-void g_editor_setup(void)
-{
-/* ------------------------ events ---------------------------------- */
- class_addmethod(canvas_class, (t_method)canvas_mousedown, gensym("mouse"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_mouseup, gensym("mouseup"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_key, gensym("key"),
- A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_motion, gensym("motion"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
-
-/* ------------------------ menu actions ---------------------------- */
- class_addmethod(canvas_class, (t_method)canvas_menuclose,
- gensym("menuclose"), A_DEFFLOAT, 0);
- class_addmethod(canvas_class, (t_method)canvas_cut,
- gensym("cut"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_copy,
- gensym("copy"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_paste,
- gensym("paste"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_duplicate,
- gensym("duplicate"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_selectall,
- gensym("selectall"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_undo,
- gensym("undo"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_redo,
- gensym("redo"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_tidy,
- gensym("tidy"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_texteditor,
- gensym("texteditor"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_editmode,
- gensym("editmode"), A_DEFFLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_print,
- gensym("print"), A_SYMBOL, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_menufont,
- gensym("menufont"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_font,
- gensym("font"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_find,
- gensym("find"), A_GIMME, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_find_again,
- gensym("findagain"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_find_parent,
- gensym("findparent"), A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_done_popup,
- gensym("done-popup"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_donecanvasdialog,
- gensym("donecanvasdialog"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)glist_arraydialog,
- gensym("arraydialog"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
-
-/* -------------- connect method used in reading files ------------------ */
- class_addmethod(canvas_class, (t_method)canvas_connect,
- gensym("connect"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
-
- class_addmethod(canvas_class, (t_method)canvas_disconnect,
- gensym("disconnect"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
-/* -------------- copy buffer ------------------ */
- copy_binbuf = binbuf_new();
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_graph.c b/apps/plugins/pdbox/PDa/src/g_graph.c
index 6a64900213..c81bac10b8 100644
--- a/apps/plugins/pdbox/PDa/src/g_graph.c
+++ b/apps/plugins/pdbox/PDa/src/g_graph.c
@@ -1110,1115 +1110,4 @@ void g_graph_setup(void)
class_addmethod(canvas_class, (t_method)glist_sort,
gensym("sort"), A_NULL);
}
-/* Copyright (c) 1997-2001 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* This file deals with the behavior of glists as either "text objects" or
-"graphs" inside another glist. LATER move the inlet/outlet code of g_canvas.c
-to this file... */
-
-#include <stdlib.h>
-#include "m_pd.h"
-#include "t_tk.h"
-#include "g_canvas.h"
-#include <stdio.h>
-#include <string.h>
-
-/* ---------------------- forward definitions ----------------- */
-
-static void graph_vis(t_gobj *gr, t_glist *unused_glist, int vis);
-static void graph_graphrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2);
-static void graph_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2);
-
-/* -------------------- maintaining the list -------------------- */
-
-void glist_add(t_glist *x, t_gobj *y)
-{
- t_object *ob;
- y->g_next = 0;
- if (!x->gl_list) x->gl_list = y;
- else
- {
- t_gobj *y2;
- for (y2 = x->gl_list; y2->g_next; y2 = y2->g_next);
- y2->g_next = y;
- }
- if (x->gl_editor && (ob = pd_checkobject(&y->g_pd)))
- rtext_new(x, ob);
- if (glist_isvisible(x))
- gobj_vis(y, x, 1);
- if (class_isdrawcommand(y->g_pd))
- canvas_redrawallfortemplate(glist_getcanvas(x));
-}
-
- /* this is to protect against a hairy problem in which deleting
- a sub-canvas might delete an inlet on a box, after the box had
- been invisible-ized, so that we have to protect against redrawing it! */
-int canvas_setdeleting(t_canvas *x, int flag)
-{
- int ret = x->gl_isdeleting;
- x->gl_isdeleting = flag;
- return (ret);
-}
-
- /* delete an object from a glist and free it */
-void glist_delete(t_glist *x, t_gobj *y)
-{
- t_gobj *g;
- t_object *ob;
- t_gotfn chkdsp = zgetfn(&y->g_pd, gensym("dsp"));
- t_canvas *canvas = glist_getcanvas(x);
- int drawcommand = class_isdrawcommand(y->g_pd);
- int wasdeleting;
-
- wasdeleting = canvas_setdeleting(canvas, 1);
- if (x->gl_editor)
- {
- if (x->gl_editor->e_grab == y) x->gl_editor->e_grab = 0;
- if (glist_isselected(x, y)) glist_deselect(x, y);
-
- /* HACK -- we had phantom outlets not getting erased on the
- screen because the canvas_setdeleting() mechanism is too
- crude. LATER carefully set up rules for when the rtexts
- should exist, so that they stay around until all the
- steps of becoming invisible are done. In the meantime, just
- zap the inlets and outlets here... */
- if (pd_class(&y->g_pd) == canvas_class)
- {
- t_glist *gl = (t_glist *)y;
- if (gl->gl_isgraph)
- {
- char tag[80];
- sprintf(tag, "graph%x", (int)gl);
- glist_eraseiofor(x, &gl->gl_obj, tag);
- }
- else
- {
- text_eraseborder(&gl->gl_obj, x,
- rtext_gettag(glist_findrtext(x, &gl->gl_obj)));
- }
- }
- }
- gobj_delete(y, x);
- if (glist_isvisible(canvas))
- gobj_vis(y, x, 0);
- if (x->gl_editor && (ob = pd_checkobject(&y->g_pd)))
- rtext_new(x, ob);
- if (x->gl_list == y) x->gl_list = y->g_next;
- else for (g = x->gl_list; g; g = g->g_next)
- if (g->g_next == y)
- {
- g->g_next = y->g_next;
- break;
- }
- pd_free(&y->g_pd);
- if (chkdsp) canvas_update_dsp();
- if (drawcommand) canvas_redrawallfortemplate(canvas);
- canvas_setdeleting(canvas, wasdeleting);
- x->gl_valid = ++glist_valid;
-}
-
- /* remove every object from a glist. Experimental. */
-void glist_clear(t_glist *x)
-{
- t_gobj *y, *y2;
- int dspstate = canvas_suspend_dsp();
- while (y = x->gl_list)
- glist_delete(x, y);
- canvas_resume_dsp(dspstate);
-}
-
-void glist_retext(t_glist *glist, t_text *y)
-{
- t_canvas *c = glist_getcanvas(glist);
- /* check that we have built rtexts yet. LATER need a better test. */
- if (glist->gl_editor && glist->gl_editor->e_rtext)
- {
- t_rtext *rt = glist_findrtext(glist, y);
- if (rt)
- rtext_retext(rt);
- }
-}
-
-void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
- t_glistkeyfn keyfn, int xpos, int ypos)
-{
- t_glist *x2 = glist_getcanvas(x);
- if (motionfn)
- x2->gl_editor->e_onmotion = MA_PASSOUT;
- else x2->gl_editor->e_onmotion = 0;
- x2->gl_editor->e_grab = y;
- x2->gl_editor->e_motionfn = motionfn;
- x2->gl_editor->e_keyfn = keyfn;
- x2->gl_editor->e_xwas = xpos;
- x2->gl_editor->e_ywas = ypos;
-}
-
-t_canvas *glist_getcanvas(t_glist *x)
-{
- while (x->gl_owner && !x->gl_havewindow && x->gl_isgraph)
- x = x->gl_owner;
- return((t_canvas *)x);
-}
-
-static float gobj_getxforsort(t_gobj *g)
-{
- if (pd_class(&g->g_pd) == scalar_class)
- {
- float x1, y1;
- scalar_getbasexy((t_scalar *)g, &x1, &y1);
- return(x1);
- }
- else return (0);
-}
-
-static t_gobj *glist_merge(t_glist *x, t_gobj *g1, t_gobj *g2)
-{
- t_gobj *g = 0, *g9 = 0;
- float f1 = 0, f2 = 0;
- if (g1)
- f1 = gobj_getxforsort(g1);
- if (g2)
- f2 = gobj_getxforsort(g2);
- while (1)
- {
- if (g1)
- {
- if (g2)
- {
- if (f1 <= f2)
- goto put1;
- else goto put2;
- }
- else goto put1;
- }
- else if (g2)
- goto put2;
- else break;
- put1:
- if (g9)
- g9->g_next = g1, g9 = g1;
- else g9 = g = g1;
- if (g1 = g1->g_next)
- f1 = gobj_getxforsort(g1);
- g9->g_next = 0;
- continue;
- put2:
- if (g9)
- g9->g_next = g2, g9 = g2;
- else g9 = g = g2;
- if (g2 = g2->g_next)
- f2 = gobj_getxforsort(g2);
- g9->g_next = 0;
- continue;
- }
- return (g);
-}
-
-static t_gobj *glist_dosort(t_glist *x,
- t_gobj *g, int nitems)
-{
- if (nitems < 2)
- return (g);
- else
- {
- int n1 = nitems/2, n2 = nitems - n1, i;
- t_gobj *g2, *g3;
- for (g2 = g, i = n1-1; i--; g2 = g2->g_next)
- ;
- g3 = g2->g_next;
- g2->g_next = 0;
- g = glist_dosort(x, g, n1);
- g3 = glist_dosort(x, g3, n2);
- return (glist_merge(x, g, g3));
- }
-}
-
-void glist_sort(t_glist *x)
-{
- int nitems = 0, foo = 0;
- float lastx = -1e37;
- t_gobj *g;
- for (g = x->gl_list; g; g = g->g_next)
- {
- float x1 = gobj_getxforsort(g);
- if (x1 < lastx)
- foo = 1;
- lastx = x1;
- nitems++;
- }
- if (foo)
- x->gl_list = glist_dosort(x, x->gl_list, nitems);
-}
-
-void glist_cleanup(t_glist *x)
-{
- freebytes(x->gl_xlabel, x->gl_nxlabels * sizeof(*(x->gl_xlabel)));
- freebytes(x->gl_ylabel, x->gl_nylabels * sizeof(*(x->gl_ylabel)));
- gstub_cutoff(x->gl_stub);
-}
-
-void glist_free(t_glist *x)
-{
- glist_cleanup(x);
- freebytes(x, sizeof(*x));
-}
-
-/* --------------- inlets and outlets ----------- */
-
-
-t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *s)
-{
- t_inlet *ip = inlet_new(&x->gl_obj, who, s, 0);
- if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner))
- {
- gobj_vis(&x->gl_gobj, x->gl_owner, 0);
- gobj_vis(&x->gl_gobj, x->gl_owner, 1);
- canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
- }
- if (!x->gl_loading) canvas_resortinlets(x);
- return (ip);
-}
-
-void canvas_rminlet(t_canvas *x, t_inlet *ip)
-{
- t_canvas *owner = x->gl_owner;
- int redraw = (owner && glist_isvisible(owner) && (!owner->gl_isdeleting)
- && glist_istoplevel(owner));
-
- if (owner) canvas_deletelinesforio(owner, &x->gl_obj, ip, 0);
- if (redraw)
- gobj_vis(&x->gl_gobj, x->gl_owner, 0);
- inlet_free(ip);
- if (redraw)
- {
- gobj_vis(&x->gl_gobj, x->gl_owner, 1);
- canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
- }
-}
-
-extern t_inlet *vinlet_getit(t_pd *x);
-extern void obj_moveinletfirst(t_object *x, t_inlet *i);
-
-void canvas_resortinlets(t_canvas *x)
-{
- int ninlets = 0, i, j, xmax;
- t_gobj *y, **vec, **vp, **maxp;
-
- for (ninlets = 0, y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == vinlet_class) ninlets++;
-
- if (ninlets < 2) return;
-
- vec = (t_gobj **)getbytes(ninlets * sizeof(*vec));
-
- for (y = x->gl_list, vp = vec; y; y = y->g_next)
- if (pd_class(&y->g_pd) == vinlet_class) *vp++ = y;
-
- for (i = ninlets; i--;)
- {
- t_inlet *ip;
- for (vp = vec, xmax = -0x7fffffff, maxp = 0, j = ninlets;
- j--; vp++)
- {
- int x1, y1, x2, y2;
- t_gobj *g = *vp;
- if (!g) continue;
- gobj_getrect(g, x, &x1, &y1, &x2, &y2);
- if (x1 > xmax) xmax = x1, maxp = vp;
- }
- if (!maxp) break;
- y = *maxp;
- *maxp = 0;
- ip = vinlet_getit(&y->g_pd);
-
- obj_moveinletfirst(&x->gl_obj, ip);
- }
- freebytes(vec, ninlets * sizeof(*vec));
- if (x->gl_owner && glist_isvisible(x->gl_owner))
- canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
-}
-
-t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s)
-{
- t_outlet *op = outlet_new(&x->gl_obj, s);
- if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner))
- {
- gobj_vis(&x->gl_gobj, x->gl_owner, 0);
- gobj_vis(&x->gl_gobj, x->gl_owner, 1);
- canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
- }
- if (!x->gl_loading) canvas_resortoutlets(x);
- return (op);
-}
-
-void canvas_rmoutlet(t_canvas *x, t_outlet *op)
-{
- t_canvas *owner = x->gl_owner;
- int redraw = (owner && glist_isvisible(owner) && (!owner->gl_isdeleting)
- && glist_istoplevel(owner));
-
- if (owner) canvas_deletelinesforio(owner, &x->gl_obj, 0, op);
- if (redraw)
- gobj_vis(&x->gl_gobj, x->gl_owner, 0);
-
- outlet_free(op);
- if (redraw)
- {
- gobj_vis(&x->gl_gobj, x->gl_owner, 1);
- canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
- }
-}
-
-extern t_outlet *voutlet_getit(t_pd *x);
-extern void obj_moveoutletfirst(t_object *x, t_outlet *i);
-
-void canvas_resortoutlets(t_canvas *x)
-{
- int noutlets = 0, i, j, xmax;
- t_gobj *y, **vec, **vp, **maxp;
-
- for (noutlets = 0, y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == voutlet_class) noutlets++;
-
- if (noutlets < 2) return;
-
- vec = (t_gobj **)getbytes(noutlets * sizeof(*vec));
-
- for (y = x->gl_list, vp = vec; y; y = y->g_next)
- if (pd_class(&y->g_pd) == voutlet_class) *vp++ = y;
-
- for (i = noutlets; i--;)
- {
- t_outlet *ip;
- for (vp = vec, xmax = -0x7fffffff, maxp = 0, j = noutlets;
- j--; vp++)
- {
- int x1, y1, x2, y2;
- t_gobj *g = *vp;
- if (!g) continue;
- gobj_getrect(g, x, &x1, &y1, &x2, &y2);
- if (x1 > xmax) xmax = x1, maxp = vp;
- }
- if (!maxp) break;
- y = *maxp;
- *maxp = 0;
- ip = voutlet_getit(&y->g_pd);
-
- obj_moveoutletfirst(&x->gl_obj, ip);
- }
- freebytes(vec, noutlets * sizeof(*vec));
- if (x->gl_owner && glist_isvisible(x->gl_owner))
- canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
-}
-
-/* ----------calculating coordinates and controlling appearance --------- */
-
-
-static void graph_bounds(t_glist *x, t_floatarg x1, t_floatarg y1,
- t_floatarg x2, t_floatarg y2)
-{
- x->gl_x1 = x1;
- x->gl_x2 = x2;
- x->gl_y1 = y1;
- x->gl_y2 = y2;
- if (x->gl_x2 == x->gl_x1 ||
- x->gl_y2 == x->gl_y1)
- {
- error("graph: empty bounds rectangle");
- x1 = y1 = 0;
- x2 = y2 = 1;
- }
- glist_redraw(x);
-}
-
-static void graph_xticks(t_glist *x,
- t_floatarg point, t_floatarg inc, t_floatarg f)
-{
- x->gl_xtick.k_point = point;
- x->gl_xtick.k_inc = inc;
- x->gl_xtick.k_lperb = f;
- glist_redraw(x);
-}
-
-static void graph_yticks(t_glist *x,
- t_floatarg point, t_floatarg inc, t_floatarg f)
-{
- x->gl_ytick.k_point = point;
- x->gl_ytick.k_inc = inc;
- x->gl_ytick.k_lperb = f;
- glist_redraw(x);
-}
-
-static void graph_xlabel(t_glist *x, t_symbol *s, int argc, t_atom *argv)
-{
- int i;
- if (argc < 1) error("graph_xlabel: no y value given");
- else
- {
- x->gl_xlabely = atom_getfloat(argv);
- argv++; argc--;
- x->gl_xlabel = (t_symbol **)t_resizebytes(x->gl_xlabel,
- x->gl_nxlabels * sizeof (t_symbol *), argc * sizeof (t_symbol *));
- x->gl_nxlabels = argc;
- for (i = 0; i < argc; i++) x->gl_xlabel[i] = atom_gensym(&argv[i]);
- }
- glist_redraw(x);
-}
-
-static void graph_ylabel(t_glist *x, t_symbol *s, int argc, t_atom *argv)
-{
- int i;
- if (argc < 1) error("graph_ylabel: no x value given");
- else
- {
- x->gl_ylabelx = atom_getfloat(argv);
- argv++; argc--;
- x->gl_ylabel = (t_symbol **)t_resizebytes(x->gl_ylabel,
- x->gl_nylabels * sizeof (t_symbol *), argc * sizeof (t_symbol *));
- x->gl_nylabels = argc;
- for (i = 0; i < argc; i++) x->gl_ylabel[i] = atom_gensym(&argv[i]);
- }
- glist_redraw(x);
-}
-/****** routines to convert pixels to X or Y value and vice versa ******/
-
- /* convert an x pixel value to an x coordinate value */
-float glist_pixelstox(t_glist *x, float xpix)
-{
- /* if we appear as a text box on parent, our range in our
- coordinates (x1, etc.) specifies the coordinate range
- of a one-pixel square at top left of the window. */
- if (!x->gl_isgraph)
- return (x->gl_x1 + (x->gl_x2 - x->gl_x1) * xpix);
-
- /* if we're a graph when shown on parent, but own our own
- window right now, our range in our coordinates (x1, etc.) is spread
- over the visible window size, given by screenx1, etc. */
- else if (x->gl_isgraph && x->gl_havewindow)
- return (x->gl_x1 + (x->gl_x2 - x->gl_x1) *
- (xpix) / (x->gl_screenx2 - x->gl_screenx1));
-
- /* otherwise, we appear in a graph within a parent glist,
- so get our screen rectangle on parent and transform. */
- else
- {
- int x1, y1, x2, y2;
- if (!x->gl_owner)
- bug("glist_pixelstox");
- graph_graphrect(&x->gl_gobj, x->gl_owner, &x1, &y1, &x2, &y2);
- return (x->gl_x1 + (x->gl_x2 - x->gl_x1) *
- (xpix - x1) / (x2 - x1));
- }
-}
-
-float glist_pixelstoy(t_glist *x, float ypix)
-{
- if (!x->gl_isgraph)
- return (x->gl_y1 + (x->gl_y2 - x->gl_y1) * ypix);
- else if (x->gl_isgraph && x->gl_havewindow)
- return (x->gl_y1 + (x->gl_y2 - x->gl_y1) *
- (ypix) / (x->gl_screeny2 - x->gl_screeny1));
- else
- {
- int x1, y1, x2, y2;
- if (!x->gl_owner)
- bug("glist_pixelstox");
- graph_graphrect(&x->gl_gobj, x->gl_owner, &x1, &y1, &x2, &y2);
- return (x->gl_y1 + (x->gl_y2 - x->gl_y1) *
- (ypix - y1) / (y2 - y1));
- }
-}
-
- /* convert an x coordinate value to an x pixel location in window */
-float glist_xtopixels(t_glist *x, float xval)
-{
- if (!x->gl_isgraph)
- return ((xval - x->gl_x1) / (x->gl_x2 - x->gl_x1));
- else if (x->gl_isgraph && x->gl_havewindow)
- return (x->gl_screenx2 - x->gl_screenx1) *
- (xval - x->gl_x1) / (x->gl_x2 - x->gl_x1);
- else
- {
- int x1, y1, x2, y2;
- if (!x->gl_owner)
- bug("glist_pixelstox");
- graph_graphrect(&x->gl_gobj, x->gl_owner, &x1, &y1, &x2, &y2);
- return (x1 + (x2 - x1) * (xval - x->gl_x1) / (x->gl_x2 - x->gl_x1));
- }
-}
-
-float glist_ytopixels(t_glist *x, float yval)
-{
- if (!x->gl_isgraph)
- return ((yval - x->gl_y1) / (x->gl_y2 - x->gl_y1));
- else if (x->gl_isgraph && x->gl_havewindow)
- return (x->gl_screeny2 - x->gl_screeny1) *
- (yval - x->gl_y1) / (x->gl_y2 - x->gl_y1);
- else
- {
- int x1, y1, x2, y2;
- if (!x->gl_owner)
- bug("glist_pixelstox");
- graph_graphrect(&x->gl_gobj, x->gl_owner, &x1, &y1, &x2, &y2);
- return (y1 + (y2 - y1) * (yval - x->gl_y1) / (x->gl_y2 - x->gl_y1));
- }
-}
-
- /* convert an X screen distance to an X coordinate increment.
- This is terribly inefficient;
- but probably not a big enough CPU hog to warrant optimizing. */
-float glist_dpixtodx(t_glist *x, float dxpix)
-{
- return (dxpix * (glist_pixelstox(x, 1) - glist_pixelstox(x, 0)));
-}
-
-float glist_dpixtody(t_glist *x, float dypix)
-{
- return (dypix * (glist_pixelstoy(x, 1) - glist_pixelstoy(x, 0)));
-}
-
- /* get the window location in pixels of a "text" object. The
- object's x and y positions are in pixels when the glist they're
- in is toplevel. If it's not, we convert to pixels on the parent
- window. */
-int text_xpix(t_text *x, t_glist *glist)
-{
- if (glist->gl_havewindow || !glist->gl_isgraph)
- return (x->te_xpix);
- else return (glist_xtopixels(glist,
- glist->gl_x1 + (glist->gl_x2 - glist->gl_x1) *
- x->te_xpix / (glist->gl_screenx2 - glist->gl_screenx1)));
-}
-
-int text_ypix(t_text *x, t_glist *glist)
-{
- if (glist->gl_havewindow || !glist->gl_isgraph)
- return (x->te_ypix);
- else return (glist_ytopixels(glist,
- glist->gl_y1 + (glist->gl_y2 - glist->gl_y1) *
- x->te_ypix / (glist->gl_screeny2 - glist->gl_screeny1)));
-}
-
- /* redraw all the items in a glist. We construe this to mean
- redrawing in its own window and on parent, as needed in each case.
- This is too conservative -- for instance, when you draw an "open"
- rectangle on the parent, you shouldn't have to redraw the window! */
-void glist_redraw(t_glist *x)
-{
- if (glist_isvisible(x))
- {
- /* LATER fix the graph_vis() code to handle both cases */
- if (glist_istoplevel(x))
- {
- t_gobj *g;
- t_linetraverser t;
- t_outconnect *oc;
- for (g = x->gl_list; g; g = g->g_next)
- {
- gobj_vis(g, x, 0);
- gobj_vis(g, x, 1);
- }
- /* redraw all the lines */
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- sys_vgui(".x%x.c coords l%x %d %d %d %d\n",
- glist_getcanvas(x), oc,
- t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2);
- }
- if (x->gl_owner)
- {
- graph_vis(&x->gl_gobj, x->gl_owner, 0);
- graph_vis(&x->gl_gobj, x->gl_owner, 1);
- }
- }
-}
-
-/* --------------------------- widget behavior ------------------- */
-
-extern t_widgetbehavior text_widgetbehavior;
-
- /* Note that some code in here would also be useful for drawing
- graph decorations in toplevels... */
-static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
-{
- t_glist *x = (t_glist *)gr;
- char tag[50];
- t_gobj *g;
- int x1, y1, x2, y2;
- /* ordinary subpatches: just act like a text object */
- if (!x->gl_isgraph)
- {
- text_widgetbehavior.w_visfn(gr, parent_glist, vis);
- return;
- }
-
- if (vis && canvas_showtext(x))
- rtext_draw(glist_findrtext(parent_glist, &x->gl_obj));
- graph_getrect(gr, parent_glist, &x1, &y1, &x2, &y2);
- if (!vis)
- rtext_erase(glist_findrtext(parent_glist, &x->gl_obj));
-
- sprintf(tag, "graph%x", (int)x);
- if (vis)
- glist_drawiofor(parent_glist, &x->gl_obj, 1,
- tag, x1, y1, x2, y2);
- else glist_eraseiofor(parent_glist, &x->gl_obj, tag);
- /* if we look like a graph but have been moved to a toplevel,
- just show the bounding rectangle */
- if (x->gl_havewindow)
- {
- if (vis)
- {
- sys_vgui(".x%x.c create polygon\
- %d %d %d %d %d %d %d %d %d %d -tags %s -fill #c0c0c0\n",
- glist_getcanvas(x->gl_owner),
- x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag);
- }
- else
- {
- sys_vgui(".x%x.c delete %s\n",
- glist_getcanvas(x->gl_owner), tag);
- }
- return;
- }
- /* otherwise draw (or erase) us as a graph inside another glist. */
- if (vis)
- {
- int i;
- float f;
-
- /* draw a rectangle around the graph */
- sys_vgui(".x%x.c create line\
- %d %d %d %d %d %d %d %d %d %d -tags %s\n",
- glist_getcanvas(x->gl_owner),
- x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag);
-
- /* draw ticks on horizontal borders. If lperb field is
- zero, this is disabled. */
- if (x->gl_xtick.k_lperb)
- {
- float upix, lpix;
- if (y2 < y1)
- upix = y1, lpix = y2;
- else upix = y2, lpix = y1;
- for (i = 0, f = x->gl_xtick.k_point;
- f < 0.99 * x->gl_x2 + 0.01*x->gl_x1; i++,
- f += x->gl_xtick.k_inc)
- {
- int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4);
- sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
- glist_getcanvas(x->gl_owner),
- (int)glist_xtopixels(x, f), (int)upix,
- (int)glist_xtopixels(x, f), (int)upix - tickpix, tag);
- sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
- glist_getcanvas(x->gl_owner),
- (int)glist_xtopixels(x, f), (int)lpix,
- (int)glist_xtopixels(x, f), (int)lpix + tickpix, tag);
- }
- for (i = 1, f = x->gl_xtick.k_point - x->gl_xtick.k_inc;
- f > 0.99 * x->gl_x1 + 0.01*x->gl_x2;
- i++, f -= x->gl_xtick.k_inc)
- {
- int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4);
- sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
- glist_getcanvas(x->gl_owner),
- (int)glist_xtopixels(x, f), (int)upix,
- (int)glist_xtopixels(x, f), (int)upix - tickpix, tag);
- sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
- glist_getcanvas(x->gl_owner),
- (int)glist_xtopixels(x, f), (int)lpix,
- (int)glist_xtopixels(x, f), (int)lpix + tickpix, tag);
- }
- }
-
- /* draw ticks in vertical borders*/
- if (x->gl_ytick.k_lperb)
- {
- float ubound, lbound;
- if (x->gl_y2 < x->gl_y1)
- ubound = x->gl_y1, lbound = x->gl_y2;
- else ubound = x->gl_y2, lbound = x->gl_y1;
- for (i = 0, f = x->gl_ytick.k_point;
- f < 0.99 * ubound + 0.01 * lbound;
- i++, f += x->gl_ytick.k_inc)
- {
- int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4);
- sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
- glist_getcanvas(x->gl_owner),
- x1, (int)glist_ytopixels(x, f),
- x1 + tickpix, (int)glist_ytopixels(x, f), tag);
- sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
- glist_getcanvas(x->gl_owner),
- x2, (int)glist_ytopixels(x, f),
- x2 - tickpix, (int)glist_ytopixels(x, f), tag);
- }
- for (i = 1, f = x->gl_ytick.k_point - x->gl_ytick.k_inc;
- f > 0.99 * lbound + 0.01 * ubound;
- i++, f -= x->gl_ytick.k_inc)
- {
- int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4);
- sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
- glist_getcanvas(x->gl_owner),
- x1, (int)glist_ytopixels(x, f),
- x1 + tickpix, (int)glist_ytopixels(x, f), tag);
- sys_vgui(".x%x.c create line %d %d %d %d -tags %s\n",
- glist_getcanvas(x->gl_owner),
- x2, (int)glist_ytopixels(x, f),
- x2 - tickpix, (int)glist_ytopixels(x, f), tag);
- }
- }
- /* draw x labels */
- for (i = 0; i < x->gl_nxlabels; i++)
- sys_vgui(".x%x.c create text\
- %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
- glist_getcanvas(x),
- (int)glist_xtopixels(x, atof(x->gl_xlabel[i]->s_name)),
- (int)glist_ytopixels(x, x->gl_xlabely), x->gl_xlabel[i]->s_name,
- glist_getfont(x), tag);
-
- /* draw y labels */
- for (i = 0; i < x->gl_nylabels; i++)
- sys_vgui(".x%x.c create text\
- %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
- glist_getcanvas(x),
- (int)glist_xtopixels(x, x->gl_ylabelx),
- (int)glist_ytopixels(x, atof(x->gl_ylabel[i]->s_name)),
- x->gl_ylabel[i]->s_name,
- glist_getfont(x), tag);
-
- /* draw contents of graph as glist */
- for (g = x->gl_list; g; g = g->g_next)
- gobj_vis(g, x, 1);
- }
- else
- {
- sys_vgui(".x%x.c delete %s\n",
- glist_getcanvas(x->gl_owner), tag);
- for (g = x->gl_list; g; g = g->g_next)
- gobj_vis(g, x, 0);
- }
-}
-
- /* get the graph's rectangle, not counting extra swelling for controls
- to keep them inside the graph. This is the "logical" pixel size. */
-
-static void graph_graphrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_glist *x = (t_glist *)z;
- int x1 = text_xpix(&x->gl_obj, glist);
- int y1 = text_ypix(&x->gl_obj, glist);
- int x2, y2;
-#if 0 /* this used to adjust graph size when it was in another graph;
- now we just preserve the size. */
- /* same logic here as in text_xpix(): */
- if (glist->gl_havewindow)
- {
- x2 = x1 + x->gl_pixwidth;
- y2 = y1 + x->gl_pixheight;
- }
- else
- {
- x2 = glist_xtopixels(glist,
- glist->gl_x1 + (glist->gl_x2 - glist->gl_x1) *
- (x->gl_obj.te_xpix + x->gl_pixwidth) /
- (glist->gl_screenx2 - glist->gl_screenx1));
- y2 = glist_ytopixels(glist,
- glist->gl_y1 + (glist->gl_y2 - glist->gl_y1) *
- (x->gl_obj.te_ypix + x->gl_pixheight) /
- (glist->gl_screeny2 - glist->gl_screeny1));
- }
-#endif
- x2 = x1 + x->gl_pixwidth;
- y2 = y1 + x->gl_pixheight;
-
- *xp1 = x1;
- *yp1 = y1;
- *xp2 = x2;
- *yp2 = y2;
-}
-
- /* get the rectangle, enlarged to contain all the "contents" --
- meaning their formal bounds rectangles. */
-static void graph_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- int x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
- t_glist *x = (t_glist *)z;
- if (x->gl_isgraph)
- {
- int hadwindow;
- t_gobj *g;
- t_text *ob;
- int x21, y21, x22, y22;
-
- graph_graphrect(z, glist, &x1, &y1, &x2, &y2);
- if (canvas_showtext(x))
- {
- text_widgetbehavior.w_getrectfn(z, glist, &x21, &y21, &x22, &y22);
- if (x22 > x2)
- x2 = x22;
- if (y22 > y2)
- y2 = y22;
- }
- /* lie about whether we have our own window to affect gobj_getrect
- calls below. (LATER add argument to gobj_getrect()?) */
- hadwindow = x->gl_havewindow;
- x->gl_havewindow = 0;
- for (g = x->gl_list; g; g = g->g_next)
- if ((!(ob = pd_checkobject(&g->g_pd))) || text_shouldvis(ob, x))
- {
- /* don't do this for arrays, just let them hang outsize the
- box. */
- if (pd_class(&g->g_pd) == garray_class)
- continue;
- gobj_getrect(g, x, &x21, &y21, &x22, &y22);
- if (x22 > x2)
- x2 = x22;
- if (y22 > y2)
- y2 = y22;
- }
- x->gl_havewindow = hadwindow;
- }
- else text_widgetbehavior.w_getrectfn(z, glist, &x1, &y1, &x2, &y2);
- *xp1 = x1;
- *yp1 = y1;
- *xp2 = x2;
- *yp2 = y2;
-}
-
-static void graph_displace(t_gobj *z, t_glist *glist, int dx, int dy)
-{
- t_glist *x = (t_glist *)z;
- if (!x->gl_isgraph)
- text_widgetbehavior.w_displacefn(z, glist, dx, dy);
- else
- {
- x->gl_obj.te_xpix += dx;
- x->gl_obj.te_ypix += dy;
- glist_redraw(x);
- canvas_fixlinesfor(glist_getcanvas(glist), &x->gl_obj);
- }
-}
-
-static void graph_select(t_gobj *z, t_glist *glist, int state)
-{
- t_glist *x = (t_glist *)z;
- if (!x->gl_isgraph)
- text_widgetbehavior.w_selectfn(z, glist, state);
- else
- {
- t_rtext *y = glist_findrtext(glist, &x->gl_obj);
- if (canvas_showtext(x))
- rtext_select(y, state);
- sys_vgui(".x%x.c itemconfigure %sR -fill %s\n", glist,
- rtext_gettag(y), (state? "blue" : "black"));
- sys_vgui(".x%x.c itemconfigure graph%x -fill %s\n",
- glist_getcanvas(glist), z, (state? "blue" : "black"));
- }
-}
-
-static void graph_activate(t_gobj *z, t_glist *glist, int state)
-{
- t_glist *x = (t_glist *)z;
- if (canvas_showtext(x))
- text_widgetbehavior.w_activatefn(z, glist, state);
-}
-
-#if 0
-static void graph_delete(t_gobj *z, t_glist *glist)
-{
- t_glist *x = (t_glist *)z;
- if (!x->gl_isgraph)
- text_widgetbehavior.w_deletefn(z, glist);
- else
- {
- t_gobj *y;
- while (y = x->gl_list) glist_delete(x, y);
-#if 0 /* I think this was just wrong. */
- if (glist_isvisible(x))
- sys_vgui(".x%x.c delete graph%x\n", glist_getcanvas(glist), x);
-#endif
- }
-}
-#endif
-
-static void graph_delete(t_gobj *z, t_glist *glist)
-{
- t_glist *x = (t_glist *)z;
- t_gobj *y;
- text_widgetbehavior.w_deletefn(z, glist);
- while (y = x->gl_list)
- glist_delete(x, y);
-}
-
-static float graph_lastxpix, graph_lastypix;
-
-static void graph_motion(void *z, t_floatarg dx, t_floatarg dy)
-{
- t_glist *x = (t_glist *)z;
- float newxpix = graph_lastxpix + dx, newypix = graph_lastypix + dy;
- t_garray *a = (t_garray *)(x->gl_list);
- int oldx = 0.5 + glist_pixelstox(x, graph_lastxpix);
- int newx = 0.5 + glist_pixelstox(x, newxpix);
- t_sample *vec;
- int nelem, i;
- float oldy = glist_pixelstoy(x, graph_lastypix);
- float newy = glist_pixelstoy(x, newypix);
- graph_lastxpix = newxpix;
- graph_lastypix = newypix;
- /* verify that the array is OK */
- if (!a || pd_class((t_pd *)a) != garray_class)
- return;
- if (!garray_getfloatarray(a, &nelem, &vec))
- return;
- if (oldx < 0) oldx = 0;
- if (oldx >= nelem)
- oldx = nelem - 1;
- if (newx < 0) newx = 0;
- if (newx >= nelem)
- newx = nelem - 1;
- if (oldx < newx - 1)
- {
- for (i = oldx + 1; i <= newx; i++)
- vec[i] = newy + (oldy - newy) *
- ((float)(newx - i))/(float)(newx - oldx);
- }
- else if (oldx > newx + 1)
- {
- for (i = oldx - 1; i >= newx; i--)
- vec[i] = newy + (oldy - newy) *
- ((float)(newx - i))/(float)(newx - oldx);
- }
- else vec[newx] = newy;
- garray_redraw(a);
-}
-
-static int graph_click(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_glist *x = (t_glist *)z;
- t_gobj *y;
- int clickreturned = 0;
- if (!x->gl_isgraph)
- return (text_widgetbehavior.w_clickfn(z, glist,
- xpix, ypix, shift, alt, dbl, doit));
- else if (x->gl_havewindow)
- return (0);
- else
- {
- for (y = x->gl_list; y; y = y->g_next)
- {
- int x1, y1, x2, y2;
- /* check if the object wants to be clicked */
- if (canvas_hitbox(x, y, xpix, ypix, &x1, &y1, &x2, &y2)
- && (clickreturned = gobj_click(y, x, xpix, ypix,
- shift, alt, 0, doit)))
- break;
- }
- if (!doit)
- {
- if (y)
- canvas_setcursor(glist_getcanvas(x), clickreturned);
- else canvas_setcursor(glist_getcanvas(x), CURSOR_RUNMODE_NOTHING);
- }
- return (clickreturned);
- }
-}
-
-void garray_properties(t_garray *x);
-
-t_widgetbehavior graph_widgetbehavior =
-{
- graph_getrect,
- graph_displace,
- graph_select,
- graph_activate,
- graph_delete,
- graph_vis,
- graph_click,
-};
-
-void graph_properties(t_gobj *z, t_glist *owner)
-{
- t_glist *x = (t_glist *)z;
- {
- t_gobj *y;
- char graphbuf[200];
- sprintf(graphbuf, "pdtk_graph_dialog %%s %g %g %g %g %d %d\n",
- x->gl_x1, x->gl_y1, x->gl_x2, x->gl_y2,
- x->gl_pixwidth, x->gl_pixheight);
- gfxstub_new(&x->gl_pd, x, graphbuf);
-
- for (y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == garray_class)
- garray_properties((t_garray *)y);
- }
-}
-
- /* find the graph most recently added to this glist;
- if none exists, return 0. */
-
-t_glist *glist_findgraph(t_glist *x)
-{
- t_gobj *y = 0, *z;
- for (z = x->gl_list; z; z = z->g_next)
- if (pd_class(&z->g_pd) == canvas_class && ((t_glist *)z)->gl_isgraph)
- y = z;
- return ((t_glist *)y);
-}
-
- /* message back from dialog GUI to set parameters. Args are:
- 1-4: bounds in our coordinates; 5-6: size in parent */
-static void graph_dialog(t_glist *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_float x1 = atom_getfloatarg(0, argc, argv);
- t_float y1 = atom_getfloatarg(1, argc, argv);
- t_float x2 = atom_getfloatarg(2, argc, argv);
- t_float y2 = atom_getfloatarg(3, argc, argv);
- t_float xpix = atom_getfloatarg(4, argc, argv);
- t_float ypix = atom_getfloatarg(5, argc, argv);
- if (x1 != x->gl_x1 || x2 != x->gl_x2 ||
- y1 != x->gl_y1 || y2 != x->gl_y2)
- graph_bounds(x, x1, y1, x2, y2);
- if (xpix != x->gl_pixwidth || ypix != x->gl_pixheight)
- {
- x->gl_pixwidth = xpix;
- x->gl_pixheight = ypix;
- glist_redraw(x);
- if (x->gl_owner)
- canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
- }
-}
-
-extern void canvas_menuarray(t_glist *canvas);
-
-void g_graph_setup(void)
-{
- class_setwidget(canvas_class, &graph_widgetbehavior);
- class_addmethod(canvas_class, (t_method)graph_bounds, gensym("bounds"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(canvas_class, (t_method)graph_xticks, gensym("xticks"),
- A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(canvas_class, (t_method)graph_xlabel, gensym("xlabel"),
- A_GIMME, 0);
- class_addmethod(canvas_class, (t_method)graph_yticks, gensym("yticks"),
- A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(canvas_class, (t_method)graph_ylabel, gensym("ylabel"),
- A_GIMME, 0);
- class_addmethod(canvas_class, (t_method)graph_array, gensym("array"),
- A_SYMBOL, A_FLOAT, A_SYMBOL, A_DEFFLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_menuarray,
- gensym("menuarray"), A_NULL);
- class_addmethod(canvas_class, (t_method)graph_dialog, gensym("dialog"),
- A_GIMME, 0);
- class_addmethod(canvas_class, (t_method)glist_arraydialog,
- gensym("arraydialog"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
- class_addmethod(canvas_class, (t_method)glist_sort,
- gensym("sort"), A_NULL);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_guiconnect.c b/apps/plugins/pdbox/PDa/src/g_guiconnect.c
index c1673827fe..f8356acfa8 100644
--- a/apps/plugins/pdbox/PDa/src/g_guiconnect.c
+++ b/apps/plugins/pdbox/PDa/src/g_guiconnect.c
@@ -92,97 +92,4 @@ void g_guiconnect_setup(void)
class_addmethod(guiconnect_class, (t_method)guiconnect_signoff,
gensym("signoff"), 0);
}
-/* Copyright (c) 1997-2000 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* a thing to forward messages from the GUI, dealing with race conditions
-in which the "target" gets deleted while the GUI is sending it something.
-*/
-
-#include "m_pd.h"
-#include "g_canvas.h"
-
-struct _guiconnect
-{
- t_object x_obj;
- t_pd *x_who;
- t_symbol *x_sym;
- t_clock *x_clock;
-};
-static t_class *guiconnect_class;
-
-t_guiconnect *guiconnect_new(t_pd *who, t_symbol *sym)
-{
- t_guiconnect *x = (t_guiconnect *)pd_new(guiconnect_class);
- x->x_who = who;
- x->x_sym = sym;
- pd_bind(&x->x_obj.ob_pd, sym);
- return (x);
-}
-
- /* cleanup routine; delete any resources we have */
-static void guiconnect_free(t_guiconnect *x)
-{
- if (x->x_sym)
- pd_unbind(&x->x_obj.ob_pd, x->x_sym);
- if (x->x_clock)
- clock_free(x->x_clock);
-}
-
- /* this is called when the clock times out to indicate the GUI should
- be gone by now. */
-static void guiconnect_tick(t_guiconnect *x)
-{
- pd_free(&x->x_obj.ob_pd);
-}
-
- /* the target calls this to disconnect. If the gui has "signed off"
- we're ready to delete the object; otherwise we wait either for signoff
- or for a timeout. */
-void guiconnect_notarget(t_guiconnect *x, double timedelay)
-{
- if (!x->x_sym)
- pd_free(&x->x_obj.ob_pd);
- else
- {
- x->x_who = 0;
- if (timedelay > 0)
- {
- x->x_clock = clock_new(x, (t_method)guiconnect_tick);
- clock_delay(x->x_clock, timedelay);
- }
- }
-}
-
- /* the GUI calls this to send messages to the target. */
-static void guiconnect_anything(t_guiconnect *x,
- t_symbol *s, int ac, t_atom *av)
-{
- if (x->x_who)
- typedmess(x->x_who, s, ac, av);
-}
-
- /* the GUI calls this when it disappears. (If there's any chance the
- GUI will fail to do this, the "target", when it signs off, should specify
- a timeout after which the guiconnect will disappear.) */
-static void guiconnect_signoff(t_guiconnect *x)
-{
- if (!x->x_who)
- pd_free(&x->x_obj.ob_pd);
- else
- {
- pd_unbind(&x->x_obj.ob_pd, x->x_sym);
- x->x_sym = 0;
- }
-}
-
-void g_guiconnect_setup(void)
-{
- guiconnect_class = class_new(gensym("guiconnect"), 0,
- (t_method)guiconnect_free, sizeof(t_guiconnect), CLASS_PD, 0);
- class_addanything(guiconnect_class, guiconnect_anything);
- class_addmethod(guiconnect_class, (t_method)guiconnect_signoff,
- gensym("signoff"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_hdial.c b/apps/plugins/pdbox/PDa/src/g_hdial.c
index 447e984244..eb88f22e2d 100644
--- a/apps/plugins/pdbox/PDa/src/g_hdial.c
+++ b/apps/plugins/pdbox/PDa/src/g_hdial.c
@@ -733,738 +733,4 @@ void g_hradio_setup(void)
class_setwidget(hradio_old_class, &hradio_widgetbehavior);
class_sethelpsymbol(hradio_old_class, gensym("hradio"));
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
-
-/* name change to hradio by MSP and changed to
-put out a "float" as in sliders, toggles, etc. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-#ifdef MSW
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-/* ------------- hdl gui-horicontal dial ---------------------- */
-
-t_widgetbehavior hradio_widgetbehavior;
-static t_class *hradio_class, *hradio_old_class;
-
-/* widget helper functions */
-
-void hradio_draw_update(t_hradio *x, t_glist *glist)
-{
- if(glist_isvisible(glist))
- {
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xBUT%d -fill #%6.6x -outline #%6.6x\n",
- canvas, x, x->x_on_old,
- x->x_gui.x_bcol, x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xBUT%d -fill #%6.6x -outline #%6.6x\n",
- canvas, x, x->x_on,
- x->x_gui.x_fcol, x->x_gui.x_fcol);
- }
-}
-
-void hradio_draw_new(t_hradio *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4;
- int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx;
- int yy21=yy11+s4, yy22=yy12-s4;
- int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4;
- int xx22=xx11b+dx-s4;
-
-
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE%d\n",
- canvas, xx11, yy11, xx11+dx, yy12,
- x->x_gui.x_bcol, x, i);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xBUT%d\n",
- canvas, xx21, yy21, xx22, yy22,
- (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
- (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, i);
- xx11 += dx;
- xx21 += dx;
- xx22 += dx;
- }
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
- canvas, xx11b+x->x_gui.x_ldx, yy11+x->x_gui.x_ldy,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
- x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_lcol, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas, xx11b, yy12-1, xx11b + IOWIDTH, yy12, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas, xx11b, yy11, xx11b + IOWIDTH, yy11+1, x, 0);
-
-}
-
-void hradio_draw_move(t_hradio *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4;
- int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx;
- int yy21=yy11+s4, yy22=yy12-s4;
- int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4;
- int xx22=xx11b+dx-s4;
-
- xx11 = xx11b;
- xx21=xx11b+s4;
- xx22=xx11b+dx-s4;
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c coords %xBASE%d %d %d %d %d\n",
- canvas, x, i, xx11, yy11, xx11+dx, yy12);
- sys_vgui(".x%x.c coords %xBUT%d %d %d %d %d\n",
- canvas, x, i, xx21, yy21, xx22, yy22);
- xx11 += dx;
- xx21 += dx;
- xx22 += dx;
- }
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- canvas, x, xx11b+x->x_gui.x_ldx, yy11+x->x_gui.x_ldy);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
- canvas, x, 0, xx11b, yy12-1, xx11b + IOWIDTH, yy12);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
- canvas, x, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1);
-}
-
-void hradio_draw_erase(t_hradio* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i;
-
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c delete %xBASE%d\n", canvas, x, i);
- sys_vgui(".x%x.c delete %xBUT%d\n", canvas, x, i);
- }
- sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-void hradio_draw_config(t_hradio* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i;
-
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE%d -fill #%6.6x\n", canvas, x, i,
- x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xBUT%d -fill #%6.6x -outline #%6.6x\n", canvas, x, i,
- (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
- (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol);
- }
-}
-
-void hradio_draw_io(t_hradio* x, t_glist* glist, int old_snd_rcv_flags)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
-
- if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas,
- xpos, ypos + x->x_gui.x_w-1,
- xpos + IOWIDTH, ypos + x->x_gui.x_w,
- x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas,
- xpos, ypos,
- xpos + IOWIDTH, ypos+1, x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-void hradio_draw_select(t_hradio* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i;
-
- if(x->x_gui.x_fsf.x_selected)
- {
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE%d -outline #%6.6x\n", canvas, x, i,
- IEM_GUI_COLOR_SELECTED);
- }
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- }
- else
- {
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE%d -outline #%6.6x\n", canvas, x, i,
- IEM_GUI_COLOR_NORMAL);
- }
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x,
- x->x_gui.x_lcol);
- }
-}
-
-void hradio_draw(t_hradio *x, t_glist *glist, int mode)
-{
- if(mode == IEM_GUI_DRAW_MODE_UPDATE)
- hradio_draw_update(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_MOVE)
- hradio_draw_move(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_NEW)
- hradio_draw_new(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_SELECT)
- hradio_draw_select(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_ERASE)
- hradio_draw_erase(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
- hradio_draw_config(x, glist);
- else if(mode >= IEM_GUI_DRAW_MODE_IO)
- hradio_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
-}
-
-/* ------------------------ hdl widgetbehaviour----------------------------- */
-
-static void hradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_hradio *x = (t_hradio *)z;
-
- *xp1 = text_xpix(&x->x_gui.x_obj, glist);
- *yp1 = text_ypix(&x->x_gui.x_obj, glist);
- *xp2 = *xp1 + x->x_gui.x_w*x->x_number;
- *yp2 = *yp1 + x->x_gui.x_h;
-}
-
-static void hradio_save(t_gobj *z, t_binbuf *b)
-{
- t_hradio *x = (t_hradio *)z;
- int bflcol[3];
- t_symbol *srl[3];
-
- iemgui_save(&x->x_gui, srl, bflcol);
- binbuf_addv(b, "ssiisiiiisssiiiiiiii", gensym("#X"),gensym("obj"),
- (t_int)text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist),
- (t_int)text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist),
- (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class ?
- gensym("hdl") : gensym("hradio")),
- x->x_gui.x_w,
- x->x_change, iem_symargstoint(&x->x_gui.x_isa), x->x_number,
- srl[0], srl[1], srl[2],
- x->x_gui.x_ldx, x->x_gui.x_ldy,
- iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
- bflcol[0], bflcol[1], bflcol[2], x->x_on);
- binbuf_addv(b, ";");
-}
-
-static void hradio_properties(t_gobj *z, t_glist *owner)
-{
- t_hradio *x = (t_hradio *)z;
- char buf[800];
- t_symbol *srl[3];
- int hchange=-1;
-
- iemgui_properties(&x->x_gui, srl);
- if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class)
- hchange = x->x_change;
- sprintf(buf, "pdtk_iemgui_dialog %%s hradio \
- ----------dimensions(pix):----------- %d %d size: 0 0 empty \
- empty 0.0 empty 0.0 empty %d \
- %d new-only new&old %d %d number: %d \
- %s %s \
- %s %d %d \
- %d %d \
- %d %d %d\n",
- x->x_gui.x_w, IEM_GUI_MINSIZE,
- 0,/*no_schedule*/
- hchange, x->x_gui.x_isa.x_loadinit, -1, x->x_number,
- srl[0]->s_name, srl[1]->s_name,
- srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
- x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
- 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
- gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
-}
-
-static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *srl[3];
- int a = (int)atom_getintarg(0, argc, argv);
- int chg = (int)atom_getintarg(4, argc, argv);
- int num = (int)atom_getintarg(6, argc, argv);
- int sr_flags;
-
- if(chg != 0) chg = 1;
- x->x_change = chg;
- sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
- x->x_gui.x_w = iemgui_clip_size(a);
- x->x_gui.x_h = x->x_gui.x_w;
- if(x->x_number != num)
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
- x->x_number = num;
- if(x->x_on >= x->x_number)
- {
- x->x_on = x->x_number - 1;
- x->x_on_old = x->x_on;
- }
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
- }
- else
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
- }
-
-}
-
-static void hradio_set(t_hradio *x, t_floatarg f)
-{
- int i=(int)f;
- int old=x->x_on_old;
-
- if(i < 0)
- i = 0;
- if(i >= x->x_number)
- i = x->x_number-1;
- if(x->x_on != x->x_on_old)
- {
- old = x->x_on_old;
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- x->x_on_old = old;
- }
- else
- {
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
-}
-
-static void hradio_bang(t_hradio *x)
-{
- /* compatibility with earlier "hdial" behavior */
- if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class)
- {
- if((x->x_change)&&(x->x_on != x->x_on_old))
- {
- SETFLOAT(x->x_at, (float)x->x_on_old);
- SETFLOAT(x->x_at+1, 0.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- x->x_on_old = x->x_on;
- SETFLOAT(x->x_at, (float)x->x_on);
- SETFLOAT(x->x_at+1, 1.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- else
- {
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_on);
- }
-}
-static void hradio_fout(t_hradio *x, t_floatarg f)
-{
- int i=(int)f;
-
- if(i < 0)
- i = 0;
- if(i >= x->x_number)
- i = x->x_number-1;
-
- if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class)
- {
- if((x->x_change)&&(i != x->x_on_old))
- {
- SETFLOAT(x->x_at, (float)x->x_on_old);
- SETFLOAT(x->x_at+1, 0.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- if(x->x_on != x->x_on_old)
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- x->x_on_old = x->x_on;
- SETFLOAT(x->x_at, (float)x->x_on);
- SETFLOAT(x->x_at+1, 1.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- else
- {
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_on);
- }
-}
-
-static void hradio_float(t_hradio *x, t_floatarg f)
-{
- int i=(int)f;
-
- if(i < 0)
- i = 0;
- if(i >= x->x_number)
- i = x->x_number-1;
-
- if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class)
- {
- /* compatibility with earlier "vdial" behavior */
- if((x->x_change)&&(i != x->x_on_old))
- {
- if(x->x_gui.x_fsf.x_put_in2out)
- {
- SETFLOAT(x->x_at, (float)x->x_on_old);
- SETFLOAT(x->x_at+1, 0.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- }
- if(x->x_on != x->x_on_old)
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- x->x_on_old = x->x_on;
- if(x->x_gui.x_fsf.x_put_in2out)
- {
- SETFLOAT(x->x_at, (float)x->x_on);
- SETFLOAT(x->x_at+1, 1.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- }
- else
- {
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- if (x->x_gui.x_fsf.x_put_in2out)
- {
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_on);
- }
- }
-}
-
-static void hradio_click(t_hradio *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
-{
- int xx = (int)xpos - (int)text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
-
- hradio_fout(x, (float)(xx / x->x_gui.x_w));
-}
-
-static int hradio_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- if(doit)
- hradio_click((t_hradio *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
- return (1);
-}
-
-static void hradio_loadbang(t_hradio *x)
-{
- if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
- hradio_bang(x);
-}
-
-static void hradio_number(t_hradio *x, t_floatarg num)
-{
- int n=(int)num;
-
- if(n < 1)
- n = 1;
- if(n > IEM_RADIO_MAX)
- n = IEM_RADIO_MAX;
- if(n != x->x_number)
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
- x->x_number = n;
- if(x->x_on >= x->x_number)
- x->x_on = x->x_number - 1;
- x->x_on_old = x->x_on;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
- }
-}
-
-static void hradio_size(t_hradio *x, t_symbol *s, int ac, t_atom *av)
-{
- x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
- x->x_gui.x_h = x->x_gui.x_w;
- iemgui_size((void *)x, &x->x_gui);
-}
-
-static void hradio_delta(t_hradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
-
-static void hradio_pos(t_hradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void hradio_color(t_hradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
-
-static void hradio_send(t_hradio *x, t_symbol *s)
-{iemgui_send(x, &x->x_gui, s);}
-
-static void hradio_receive(t_hradio *x, t_symbol *s)
-{iemgui_receive(x, &x->x_gui, s);}
-
-static void hradio_label(t_hradio *x, t_symbol *s)
-{iemgui_label((void *)x, &x->x_gui, s);}
-
-static void hradio_label_pos(t_hradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void hradio_label_font(t_hradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
-
-static void hradio_init(t_hradio *x, t_floatarg f)
-{
- x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
-}
-
-static void hradio_double_change(t_hradio *x)
-{x->x_change = 1;}
-
-static void hradio_single_change(t_hradio *x)
-{x->x_change = 0;}
-
-static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old)
-{
- t_hradio *x = (t_hradio *)pd_new(old? hradio_old_class : hradio_class);
- int bflcol[]={-262144, -1, -1};
- int a=IEM_GUI_DEFAULTSIZE, on=0, f=0;
- int ldx=0, ldy=-6, chg=1, num=8;
- int fs=8;
- int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
- char str[144];
-
- iem_inttosymargs(&x->x_gui.x_isa, 0);
- iem_inttofstyle(&x->x_gui.x_fsf, 0);
-
- if((argc == 15)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
- &&IS_A_FLOAT(argv,3)
- &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
- &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
- &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
- &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
- &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)
- &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)&&IS_A_FLOAT(argv,14))
- {
- a = (int)atom_getintarg(0, argc, argv);
- chg = (int)atom_getintarg(1, argc, argv);
- iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv));
- num = (int)atom_getintarg(3, argc, argv);
- iemgui_new_getnames(&x->x_gui, 4, argv);
- ldx = (int)atom_getintarg(7, argc, argv);
- ldy = (int)atom_getintarg(8, argc, argv);
- iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
- fs = (int)atom_getintarg(10, argc, argv);
- bflcol[0] = (int)atom_getintarg(11, argc, argv);
- bflcol[1] = (int)atom_getintarg(12, argc, argv);
- bflcol[2] = (int)atom_getintarg(13, argc, argv);
- on = (int)atom_getintarg(14, argc, argv);
- }
- else iemgui_new_getnames(&x->x_gui, 4, 0);
- x->x_gui.x_draw = (t_iemfunptr)hradio_draw;
- x->x_gui.x_fsf.x_snd_able = 1;
- x->x_gui.x_fsf.x_rcv_able = 1;
- x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
- if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
- x->x_gui.x_fsf.x_snd_able = 0;
- if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
- x->x_gui.x_fsf.x_rcv_able = 0;
- if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
- else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
- else { x->x_gui.x_fsf.x_font_style = 0;
- strcpy(x->x_gui.x_font, "courier"); }
- if(num < 1)
- num = 1;
- if(num > IEM_RADIO_MAX)
- num = IEM_RADIO_MAX;
- x->x_number = num;
- if(on < 0)
- on = 0;
- if(on >= x->x_number)
- on = x->x_number - 1;
- if(x->x_gui.x_isa.x_loadinit)
- x->x_on = on;
- else
- x->x_on = 0;
- x->x_on_old = x->x_on;
- x->x_change = (chg==0)?0:1;
- if (x->x_gui.x_fsf.x_rcv_able)
- pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- x->x_gui.x_ldx = ldx;
- x->x_gui.x_ldy = ldy;
- if(fs < 4)
- fs = 4;
- x->x_gui.x_fontsize = fs;
- x->x_gui.x_w = iemgui_clip_size(a);
- x->x_gui.x_h = x->x_gui.x_w;
- iemgui_verify_snd_ne_rcv(&x->x_gui);
- iemgui_all_colfromload(&x->x_gui, bflcol);
- outlet_new(&x->x_gui.x_obj, &s_list);
- return (x);
-}
-
-static void *hradio_new(t_symbol *s, int argc, t_atom *argv)
-{
- return (hradio_donew(s, argc, argv, 0));
-}
-
-static void *hdial_new(t_symbol *s, int argc, t_atom *argv)
-{
- return (hradio_donew(s, argc, argv, 1));
-}
-
-static void hradio_ff(t_hradio *x)
-{
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- gfxstub_deleteforkey(x);
-}
-
-void g_hradio_setup(void)
-{
- hradio_class = class_new(gensym("hradio"), (t_newmethod)hradio_new,
- (t_method)hradio_ff, sizeof(t_hradio), 0, A_GIMME, 0);
- class_addbang(hradio_class, hradio_bang);
- class_addfloat(hradio_class, hradio_float);
- class_addmethod(hradio_class, (t_method)hradio_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(hradio_class, (t_method)hradio_dialog, gensym("dialog"),
- A_GIMME, 0);
- class_addmethod(hradio_class, (t_method)hradio_loadbang,
- gensym("loadbang"), 0);
- class_addmethod(hradio_class, (t_method)hradio_set,
- gensym("set"), A_FLOAT, 0);
- class_addmethod(hradio_class, (t_method)hradio_size,
- gensym("size"), A_GIMME, 0);
- class_addmethod(hradio_class, (t_method)hradio_delta,
- gensym("delta"), A_GIMME, 0);
- class_addmethod(hradio_class, (t_method)hradio_pos,
- gensym("pos"), A_GIMME, 0);
- class_addmethod(hradio_class, (t_method)hradio_color,
- gensym("color"), A_GIMME, 0);
- class_addmethod(hradio_class, (t_method)hradio_send,
- gensym("send"), A_DEFSYM, 0);
- class_addmethod(hradio_class, (t_method)hradio_receive,
- gensym("receive"), A_DEFSYM, 0);
- class_addmethod(hradio_class, (t_method)hradio_label,
- gensym("label"), A_DEFSYM, 0);
- class_addmethod(hradio_class, (t_method)hradio_label_pos,
- gensym("label_pos"), A_GIMME, 0);
- class_addmethod(hradio_class, (t_method)hradio_label_font,
- gensym("label_font"), A_GIMME, 0);
- class_addmethod(hradio_class, (t_method)hradio_init,
- gensym("init"), A_FLOAT, 0);
- class_addmethod(hradio_class, (t_method)hradio_number,
- gensym("number"), A_FLOAT, 0);
- class_addmethod(hradio_class, (t_method)hradio_single_change,
- gensym("single_change"), 0);
- class_addmethod(hradio_class, (t_method)hradio_double_change,
- gensym("double_change"), 0);
- hradio_widgetbehavior.w_getrectfn = hradio_getrect;
- hradio_widgetbehavior.w_displacefn = iemgui_displace;
- hradio_widgetbehavior.w_selectfn = iemgui_select;
- hradio_widgetbehavior.w_activatefn = NULL;
- hradio_widgetbehavior.w_deletefn = iemgui_delete;
- hradio_widgetbehavior.w_visfn = iemgui_vis;
- hradio_widgetbehavior.w_clickfn = hradio_newclick;
- class_setwidget(hradio_class, &hradio_widgetbehavior);
- class_sethelpsymbol(hradio_class, gensym("hradio"));
- class_setsavefn(hradio_class, hradio_save);
- class_setpropertiesfn(hradio_class, hradio_properties);
-
- /*obsolete version (0.34-0.35) */
- hradio_old_class = class_new(gensym("hdl"), (t_newmethod)hdial_new,
- (t_method)hradio_ff, sizeof(t_hradio), 0, A_GIMME, 0);
- class_addcreator((t_newmethod)hradio_new, gensym("rdb"), A_GIMME, 0);
- class_addcreator((t_newmethod)hradio_new, gensym("radiobut"), A_GIMME, 0);
- class_addcreator((t_newmethod)hradio_new, gensym("radiobutton"),
- A_GIMME, 0);
- class_addbang(hradio_old_class, hradio_bang);
- class_addfloat(hradio_old_class, hradio_float);
- class_addmethod(hradio_old_class, (t_method)hradio_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_dialog, gensym("dialog"),
- A_GIMME, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_loadbang,
- gensym("loadbang"), 0);
- class_addmethod(hradio_old_class, (t_method)hradio_set,
- gensym("set"), A_FLOAT, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_size,
- gensym("size"), A_GIMME, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_delta,
- gensym("delta"), A_GIMME, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_pos,
- gensym("pos"), A_GIMME, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_color,
- gensym("color"), A_GIMME, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_send,
- gensym("send"), A_DEFSYM, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_receive,
- gensym("receive"), A_DEFSYM, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_label,
- gensym("label"), A_DEFSYM, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_label_pos,
- gensym("label_pos"), A_GIMME, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_label_font,
- gensym("label_font"), A_GIMME, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_init,
- gensym("init"), A_FLOAT, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_number,
- gensym("number"), A_FLOAT, 0);
- class_addmethod(hradio_old_class, (t_method)hradio_single_change,
- gensym("single_change"), 0);
- class_addmethod(hradio_old_class, (t_method)hradio_double_change,
- gensym("double_change"), 0);
- class_setwidget(hradio_old_class, &hradio_widgetbehavior);
- class_sethelpsymbol(hradio_old_class, gensym("hradio"));
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_hslider.c b/apps/plugins/pdbox/PDa/src/g_hslider.c
index 77cd05c127..c5d660c5d7 100644
--- a/apps/plugins/pdbox/PDa/src/g_hslider.c
+++ b/apps/plugins/pdbox/PDa/src/g_hslider.c
@@ -652,657 +652,4 @@ void g_hslider_setup(void)
class_setsavefn(hslider_class, hslider_save);
class_setpropertiesfn(hslider_class, hslider_properties);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-#ifdef MSW
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-
-/* ------------ hsl gui-horicontal slider ----------------------- */
-
-t_widgetbehavior hslider_widgetbehavior;
-static t_class *hslider_class;
-
-/* widget helper functions */
-
-static void hslider_draw_update(t_hslider *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
-
- if (glist_isvisible(glist))
- {
- int r = text_xpix(&x->x_gui.x_obj, glist) + (x->x_val + 50)/100;
- sys_vgui(".x%x.c coords %xKNOB %d %d %d %d\n",
- canvas, x, r, ypos+1,
- r, ypos + x->x_gui.x_h);
- if(x->x_val == x->x_center)
- {
- if(!x->x_thick)
- {
- sys_vgui(".x%x.c itemconfigure %xKNOB -width 7\n", canvas, x);
- x->x_thick = 1;
- }
- }
- else
- {
- if(x->x_thick)
- {
- sys_vgui(".x%x.c itemconfigure %xKNOB -width 3\n", canvas, x);
- x->x_thick = 0;
- }
- }
- }
-}
-
-static void hslider_draw_new(t_hslider *x, t_glist *glist)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- int r = xpos + (x->x_val + 50)/100;
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
- canvas, xpos-3, ypos,
- xpos + x->x_gui.x_w+2, ypos + x->x_gui.x_h,
- x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %xKNOB\n",
- canvas, r, ypos+1, r,
- ypos + x->x_gui.x_h, x->x_gui.x_fcol, x);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
- canvas, xpos+x->x_gui.x_ldx,
- ypos+x->x_gui.x_ldy,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
- x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas, xpos-3, ypos + x->x_gui.x_h-1,
- xpos+4, ypos + x->x_gui.x_h, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas, xpos-3, ypos,
- xpos+4, ypos+1, x, 0);
-}
-
-static void hslider_draw_move(t_hslider *x, t_glist *glist)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- int r = xpos + (x->x_val + 50)/100;
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
- canvas, x,
- xpos-3, ypos,
- xpos + x->x_gui.x_w+2, ypos + x->x_gui.x_h);
- sys_vgui(".x%x.c coords %xKNOB %d %d %d %d\n",
- canvas, x, r, ypos+1,
- r, ypos + x->x_gui.x_h);
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
- canvas, x, 0,
- xpos-3, ypos + x->x_gui.x_h-1,
- xpos+4, ypos + x->x_gui.x_h);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
- canvas, x, 0,
- xpos-3, ypos,
- xpos+4, ypos+1);
-}
-
-static void hslider_draw_erase(t_hslider* x,t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
- sys_vgui(".x%x.c delete %xKNOB\n", canvas, x);
- sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-static void hslider_draw_config(t_hslider* x,t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
- sys_vgui(".x%x.c itemconfigure %xKNOB -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol);
- sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
-}
-
-static void hslider_draw_io(t_hslider* x,t_glist* glist, int old_snd_rcv_flags)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas, xpos-3, ypos + x->x_gui.x_h-1,
- xpos+4, ypos + x->x_gui.x_h, x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas, xpos-3, ypos,
- xpos+4, ypos+1, x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-static void hslider_draw_select(t_hslider* x,t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- if(x->x_gui.x_fsf.x_selected)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- }
- else
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
- }
-}
-
-void hslider_draw(t_hslider *x, t_glist *glist, int mode)
-{
- if(mode == IEM_GUI_DRAW_MODE_UPDATE)
- hslider_draw_update(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_MOVE)
- hslider_draw_move(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_NEW)
- hslider_draw_new(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_SELECT)
- hslider_draw_select(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_ERASE)
- hslider_draw_erase(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
- hslider_draw_config(x, glist);
- else if(mode >= IEM_GUI_DRAW_MODE_IO)
- hslider_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
-}
-
-/* ------------------------ hsl widgetbehaviour----------------------------- */
-
-
-static void hslider_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_hslider* x = (t_hslider*)z;
-
- *xp1 = text_xpix(&x->x_gui.x_obj, glist) - 3;
- *yp1 = text_ypix(&x->x_gui.x_obj, glist);
- *xp2 = *xp1 + x->x_gui.x_w + 5;
- *yp2 = *yp1 + x->x_gui.x_h;
-}
-
-static void hslider_save(t_gobj *z, t_binbuf *b)
-{
- t_hslider *x = (t_hslider *)z;
- int bflcol[3];
- t_symbol *srl[3];
-
- iemgui_save(&x->x_gui, srl, bflcol);
- binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"),
- (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
- gensym("hsl"), x->x_gui.x_w, x->x_gui.x_h,
- (float)x->x_min, (float)x->x_max,
- x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa),
- srl[0], srl[1], srl[2],
- x->x_gui.x_ldx, x->x_gui.x_ldy,
- iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
- bflcol[0], bflcol[1], bflcol[2],
- x->x_val, x->x_steady);
- binbuf_addv(b, ";");
-}
-
-void hslider_check_width(t_hslider *x, int w)
-{
- if(w < IEM_SL_MINSIZE)
- w = IEM_SL_MINSIZE;
- x->x_gui.x_w = w;
- x->x_center = (x->x_gui.x_w-1)*50;
- if(x->x_val > (x->x_gui.x_w*100 - 100))
- {
- x->x_pos = x->x_gui.x_w*100 - 100;
- x->x_val = x->x_pos;
- }
- if(x->x_lin0_log1)
- x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_w - 1);
- else
- x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1);
-}
-
-void hslider_check_minmax(t_hslider *x, double min, double max)
-{
- if(x->x_lin0_log1)
- {
- if((min == 0.0)&&(max == 0.0))
- max = 1.0;
- if(max > 0.0)
- {
- if(min <= 0.0)
- min = 0.01*max;
- }
- else
- {
- if(min > 0.0)
- max = 0.01*min;
- }
- }
- x->x_min = min;
- x->x_max = max;
- if(x->x_min > x->x_max) /* bugfix */
- x->x_gui.x_isa.x_reverse = 1;
- else
- x->x_gui.x_isa.x_reverse = 0;
- if(x->x_lin0_log1)
- x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_w - 1);
- else
- x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1);
-}
-
-static void hslider_properties(t_gobj *z, t_glist *owner)
-{
- t_hslider *x = (t_hslider *)z;
- char buf[800];
- t_symbol *srl[3];
-
- iemgui_properties(&x->x_gui, srl);
- sprintf(buf, "pdtk_iemgui_dialog %%s HSLIDER \
- --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
- -----------output-range:----------- %g left: %g right: %g \
- %d lin log %d %d empty %d \
- %s %s \
- %s %d %d \
- %d %d \
- %d %d %d\n",
- x->x_gui.x_w, IEM_SL_MINSIZE, x->x_gui.x_h, IEM_GUI_MINSIZE,
- x->x_min, x->x_max, 0.0,/*no_schedule*/
- x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/
- srl[0]->s_name, srl[1]->s_name,
- srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
- x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
- 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
- gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
-}
-
-static void hslider_set(t_hslider *x, t_floatarg f) /* bugfix */
-{
- double g;
-
- if(x->x_gui.x_isa.x_reverse) /* bugfix */
- {
- if(f > x->x_min)
- f = x->x_min;
- if(f < x->x_max)
- f = x->x_max;
- }
- else
- {
- if(f > x->x_max)
- f = x->x_max;
- if(f < x->x_min)
- f = x->x_min;
- }
- if(x->x_lin0_log1)
- g = log(f/x->x_min)/x->x_k;
- else
- g = (f - x->x_min) / x->x_k;
- x->x_val = (int)(100.0*g + 0.49999);
- x->x_pos = x->x_val;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
-}
-
-static void hslider_bang(t_hslider *x)
-{
- double out;
-
- if(x->x_lin0_log1)
- out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
- else
- out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
- if((out < 1.0e-10)&&(out > -1.0e-10))
- out = 0.0;
- outlet_float(x->x_gui.x_obj.ob_outlet, out);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, out);
-}
-
-static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *srl[3];
- int w = (int)atom_getintarg(0, argc, argv);
- int h = (int)atom_getintarg(1, argc, argv);
- double min = (double)atom_getfloatarg(2, argc, argv);
- double max = (double)atom_getfloatarg(3, argc, argv);
- int lilo = (int)atom_getintarg(4, argc, argv);
- int steady = (int)atom_getintarg(17, argc, argv);
- int sr_flags;
-
- if(lilo != 0) lilo = 1;
- x->x_lin0_log1 = lilo;
- if(steady)
- x->x_steady = 1;
- else
- x->x_steady = 0;
- sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
- x->x_gui.x_h = iemgui_clip_size(h);
- hslider_check_width(x, w);
- hslider_check_minmax(x, min, max);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
-}
-
-static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy)
-{
- int old = x->x_val;
-
- if(x->x_gui.x_fsf.x_finemoved)
- x->x_pos += (int)dx;
- else
- x->x_pos += 100*(int)dx;
- x->x_val = x->x_pos;
- if(x->x_val > (100*x->x_gui.x_w - 100))
- {
- x->x_val = 100*x->x_gui.x_w - 100;
- x->x_pos += 50;
- x->x_pos -= x->x_pos%100;
- }
- if(x->x_val < 0)
- {
- x->x_val = 0;
- x->x_pos -= 50;
- x->x_pos -= x->x_pos%100;
- }
- if(old != x->x_val)
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- hslider_bang(x);
- }
-}
-
-static void hslider_click(t_hslider *x, t_floatarg xpos, t_floatarg ypos,
- t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
-{
- if(!x->x_steady)
- x->x_val = (int)(100.0 * (xpos - text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)));
- if(x->x_val > (100*x->x_gui.x_w - 100))
- x->x_val = 100*x->x_gui.x_w - 100;
- if(x->x_val < 0)
- x->x_val = 0;
- x->x_pos = x->x_val;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- hslider_bang(x);
- glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, (t_glistmotionfn)hslider_motion,
- 0, xpos, ypos);
-}
-
-static int hslider_newclick(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_hslider* x = (t_hslider *)z;
-
- if(doit)
- {
- hslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift,
- 0, (t_floatarg)alt);
- if(shift)
- x->x_gui.x_fsf.x_finemoved = 1;
- else
- x->x_gui.x_fsf.x_finemoved = 0;
- }
- return (1);
-}
-
-static void hslider_size(t_hslider *x, t_symbol *s, int ac, t_atom *av)
-{
- hslider_check_width(x, (int)atom_getintarg(0, ac, av));
- if(ac > 1)
- x->x_gui.x_h = iemgui_clip_size((int)atom_getintarg(1, ac, av));
- iemgui_size((void *)x, &x->x_gui);
-}
-
-static void hslider_delta(t_hslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
-
-static void hslider_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void hslider_range(t_hslider *x, t_symbol *s, int ac, t_atom *av)
-{
- hslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
- (double)atom_getfloatarg(1, ac, av));
-}
-
-static void hslider_color(t_hslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
-
-static void hslider_send(t_hslider *x, t_symbol *s)
-{iemgui_send(x, &x->x_gui, s);}
-
-static void hslider_receive(t_hslider *x, t_symbol *s)
-{iemgui_receive(x, &x->x_gui, s);}
-
-static void hslider_label(t_hslider *x, t_symbol *s)
-{iemgui_label((void *)x, &x->x_gui, s);}
-
-static void hslider_label_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void hslider_label_font(t_hslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
-
-static void hslider_log(t_hslider *x)
-{
- x->x_lin0_log1 = 1;
- hslider_check_minmax(x, x->x_min, x->x_max);
-}
-
-static void hslider_lin(t_hslider *x)
-{
- x->x_lin0_log1 = 0;
- x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1);
-}
-
-static void hslider_init(t_hslider *x, t_floatarg f)
-{
- x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
-}
-
-static void hslider_steady(t_hslider *x, t_floatarg f)
-{
- x->x_steady = (f==0.0)?0:1;
-}
-
-static void hslider_float(t_hslider *x, t_floatarg f)
-{
- double out;
-
- hslider_set(x, f);
- if(x->x_lin0_log1)
- out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
- else
- out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
- if((out < 1.0e-10)&&(out > -1.0e-10))
- out = 0.0;
- if(x->x_gui.x_fsf.x_put_in2out)
- {
- outlet_float(x->x_gui.x_obj.ob_outlet, out);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, out);
- }
-}
-
-static void hslider_loadbang(t_hslider *x)
-{
- if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- hslider_bang(x);
- }
-}
-
-static void *hslider_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_hslider *x = (t_hslider *)pd_new(hslider_class);
- int bflcol[]={-262144, -1, -1};
- int w=IEM_SL_DEFAULTSIZE, h=IEM_GUI_DEFAULTSIZE;
- int lilo=0, ldx=-2, ldy=-6, f=0, v=0, steady=1;
- int fs=8;
- double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1);
- char str[144];
-
- iem_inttosymargs(&x->x_gui.x_isa, 0);
- iem_inttofstyle(&x->x_gui.x_fsf, 0);
-
- if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
- &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
- &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
- &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
- &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
- &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
- &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
- &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
- &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16))
- {
- w = (int)atom_getintarg(0, argc, argv);
- h = (int)atom_getintarg(1, argc, argv);
- min = (double)atom_getfloatarg(2, argc, argv);
- max = (double)atom_getfloatarg(3, argc, argv);
- lilo = (int)atom_getintarg(4, argc, argv);
- iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv));
- iemgui_new_getnames(&x->x_gui, 6, argv);
- ldx = (int)atom_getintarg(9, argc, argv);
- ldy = (int)atom_getintarg(10, argc, argv);
- iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv));
- fs = (int)atom_getintarg(12, argc, argv);
- bflcol[0] = (int)atom_getintarg(13, argc, argv);
- bflcol[1] = (int)atom_getintarg(14, argc, argv);
- bflcol[2] = (int)atom_getintarg(15, argc, argv);
- v = (int)atom_getintarg(16, argc, argv);
- }
- else iemgui_new_getnames(&x->x_gui, 6, 0);
- if((argc == 18)&&IS_A_FLOAT(argv,17))
- steady = (int)atom_getintarg(17, argc, argv);
-
- x->x_gui.x_draw = (t_iemfunptr)hslider_draw;
-
- x->x_gui.x_fsf.x_snd_able = 1;
- x->x_gui.x_fsf.x_rcv_able = 1;
-
- x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
- if(x->x_gui.x_isa.x_loadinit)
- x->x_val = v;
- else
- x->x_val = 0;
- x->x_pos = x->x_val;
- if(lilo != 0) lilo = 1;
- x->x_lin0_log1 = lilo;
- if(steady != 0) steady = 1;
- x->x_steady = steady;
- if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
- x->x_gui.x_fsf.x_snd_able = 0;
- if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
- x->x_gui.x_fsf.x_rcv_able = 0;
- if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
- else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
- else { x->x_gui.x_fsf.x_font_style = 0;
- strcpy(x->x_gui.x_font, "courier"); }
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- x->x_gui.x_ldx = ldx;
- x->x_gui.x_ldy = ldy;
- if(fs < 4)
- fs = 4;
- x->x_gui.x_fontsize = fs;
- x->x_gui.x_h = iemgui_clip_size(h);
- hslider_check_width(x, w);
- hslider_check_minmax(x, min, max);
- iemgui_all_colfromload(&x->x_gui, bflcol);
- x->x_thick = 0;
- iemgui_verify_snd_ne_rcv(&x->x_gui);
- outlet_new(&x->x_gui.x_obj, &s_float);
- return (x);
-}
-
-static void hslider_free(t_hslider *x)
-{
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- gfxstub_deleteforkey(x);
-}
-
-void g_hslider_setup(void)
-{
- hslider_class = class_new(gensym("hsl"), (t_newmethod)hslider_new,
- (t_method)hslider_free, sizeof(t_hslider), 0, A_GIMME, 0);
-#ifndef GGEE_HSLIDER_COMPATIBLE
- class_addcreator((t_newmethod)hslider_new, gensym("hslider"), A_GIMME, 0);
-#endif
- class_addbang(hslider_class,hslider_bang);
- class_addfloat(hslider_class,hslider_float);
- class_addmethod(hslider_class, (t_method)hslider_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(hslider_class, (t_method)hslider_motion, gensym("motion"),
- A_FLOAT, A_FLOAT, 0);
- class_addmethod(hslider_class, (t_method)hslider_dialog, gensym("dialog"), A_GIMME, 0);
- class_addmethod(hslider_class, (t_method)hslider_loadbang, gensym("loadbang"), 0);
- class_addmethod(hslider_class, (t_method)hslider_set, gensym("set"), A_FLOAT, 0);
- class_addmethod(hslider_class, (t_method)hslider_size, gensym("size"), A_GIMME, 0);
- class_addmethod(hslider_class, (t_method)hslider_delta, gensym("delta"), A_GIMME, 0);
- class_addmethod(hslider_class, (t_method)hslider_pos, gensym("pos"), A_GIMME, 0);
- class_addmethod(hslider_class, (t_method)hslider_range, gensym("range"), A_GIMME, 0);
- class_addmethod(hslider_class, (t_method)hslider_color, gensym("color"), A_GIMME, 0);
- class_addmethod(hslider_class, (t_method)hslider_send, gensym("send"), A_DEFSYM, 0);
- class_addmethod(hslider_class, (t_method)hslider_receive, gensym("receive"), A_DEFSYM, 0);
- class_addmethod(hslider_class, (t_method)hslider_label, gensym("label"), A_DEFSYM, 0);
- class_addmethod(hslider_class, (t_method)hslider_label_pos, gensym("label_pos"), A_GIMME, 0);
- class_addmethod(hslider_class, (t_method)hslider_label_font, gensym("label_font"), A_GIMME, 0);
- class_addmethod(hslider_class, (t_method)hslider_log, gensym("log"), 0);
- class_addmethod(hslider_class, (t_method)hslider_lin, gensym("lin"), 0);
- class_addmethod(hslider_class, (t_method)hslider_init, gensym("init"), A_FLOAT, 0);
- class_addmethod(hslider_class, (t_method)hslider_steady, gensym("steady"), A_FLOAT, 0);
- hslider_widgetbehavior.w_getrectfn = hslider_getrect;
- hslider_widgetbehavior.w_displacefn = iemgui_displace;
- hslider_widgetbehavior.w_selectfn = iemgui_select;
- hslider_widgetbehavior.w_activatefn = NULL;
- hslider_widgetbehavior.w_deletefn = iemgui_delete;
- hslider_widgetbehavior.w_visfn = iemgui_vis;
- hslider_widgetbehavior.w_clickfn = hslider_newclick;
- class_setwidget(hslider_class, &hslider_widgetbehavior);
- class_sethelpsymbol(hslider_class, gensym("hslider"));
- class_setsavefn(hslider_class, hslider_save);
- class_setpropertiesfn(hslider_class, hslider_properties);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_io.c b/apps/plugins/pdbox/PDa/src/g_io.c
index 39788d2adb..db69543a87 100644
--- a/apps/plugins/pdbox/PDa/src/g_io.c
+++ b/apps/plugins/pdbox/PDa/src/g_io.c
@@ -610,615 +610,4 @@ void g_io_setup(void)
vinlet_setup();
voutlet_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* graphical inlets and outlets, both for control and signals. */
-
-/* This code is highly inefficient; messages actually have to be forwarded
-by inlets and outlets. The outlet is in even worse shape than the inlet;
-in order to avoid having a "signal" method in the class, the oulet actually
-sprouts an inlet, which forwards the message to the "outlet" object, which
-sends it on to the outlet proper. Another way to do it would be to have
-separate classes for "signal" and "control" outlets, but this would complicate
-life elsewhere. */
-
-
-/* hacked to run subpatches with different samplerates
- *
- * mfg.gfd.uil
- * IOhannes
- *
- * edited lines are marked with "IOhannes"
- *
- */
-
-#include "m_pd.h"
-#include "g_canvas.h"
-#include <string.h>
-void signal_setborrowed(t_signal *sig, t_signal *sig2);
-void signal_makereusable(t_signal *sig);
-
-/* ------------------------- vinlet -------------------------- */
-t_class *vinlet_class;
-
-typedef struct _vinlet
-{
- t_object x_obj;
- t_canvas *x_canvas;
- t_inlet *x_inlet;
- int x_bufsize;
- t_float *x_buf; /* signal buffer; zero if not a signal */
- t_float *x_endbuf;
- t_float *x_fill;
- t_float *x_read;
- int x_hop;
- /* if not reblocking, the next slot communicates the parent's inlet
- signal from the prolog to the DSP routine: */
- t_signal *x_directsignal;
-
- t_resample x_updown; /* IOhannes */
-} t_vinlet;
-
-static void *vinlet_new(t_symbol *s)
-{
- t_vinlet *x = (t_vinlet *)pd_new(vinlet_class);
- x->x_canvas = canvas_getcurrent();
- x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, 0);
- x->x_bufsize = 0;
- x->x_buf = 0;
- outlet_new(&x->x_obj, 0);
- return (x);
-}
-
-static void vinlet_bang(t_vinlet *x)
-{
- outlet_bang(x->x_obj.ob_outlet);
-}
-
-static void vinlet_pointer(t_vinlet *x, t_gpointer *gp)
-{
- outlet_pointer(x->x_obj.ob_outlet, gp);
-}
-
-static void vinlet_float(t_vinlet *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, f);
-}
-
-static void vinlet_symbol(t_vinlet *x, t_symbol *s)
-{
- outlet_symbol(x->x_obj.ob_outlet, s);
-}
-
-static void vinlet_list(t_vinlet *x, t_symbol *s, int argc, t_atom *argv)
-{
- outlet_list(x->x_obj.ob_outlet, s, argc, argv);
-}
-
-static void vinlet_anything(t_vinlet *x, t_symbol *s, int argc, t_atom *argv)
-{
- outlet_anything(x->x_obj.ob_outlet, s, argc, argv);
-}
-
-static void vinlet_free(t_vinlet *x)
-{
- canvas_rminlet(x->x_canvas, x->x_inlet);
- resample_free(&x->x_updown);
-}
-
-t_inlet *vinlet_getit(t_pd *x)
-{
- if (pd_class(x) != vinlet_class) bug("vinlet_getit");
- return (((t_vinlet *)x)->x_inlet);
-}
-
-/* ------------------------- signal inlet -------------------------- */
-int vinlet_issignal(t_vinlet *x)
-{
- return (x->x_buf != 0);
-}
-
-static int tot;
-
-t_int *vinlet_perform(t_int *w)
-{
- t_vinlet *x = (t_vinlet *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
- t_float *in = x->x_read;
-#if 0
- if (tot < 5) post("-in %x out %x n %d", in, out, n);
- if (tot < 5) post("-buf %x endbuf %x", x->x_buf, x->x_endbuf);
- if (tot < 5) post("in[0] %f in[1] %f in[2] %f", in[0], in[1], in[2]);
-#endif
- while (n--) *out++ = *in++;
- if (in == x->x_endbuf) in = x->x_buf;
- x->x_read = in;
- return (w+4);
-}
-
-static void vinlet_dsp(t_vinlet *x, t_signal **sp)
-{
- t_signal *outsig;
- /* no buffer means we're not a signal inlet */
- if (!x->x_buf)
- return;
- outsig = sp[0];
- if (x->x_directsignal)
- {
- signal_setborrowed(sp[0], x->x_directsignal);
- }
- else
- {
- dsp_add(vinlet_perform, 3, x, outsig->s_vec, outsig->s_n);
- x->x_read = x->x_buf;
- }
-}
-
- /* prolog code: loads buffer from parent patch */
-t_int *vinlet_doprolog(t_int *w)
-{
- t_vinlet *x = (t_vinlet *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- int n = (int)(w[3]);
- t_float *out = x->x_fill;
- if (out == x->x_endbuf)
- {
- t_float *f1 = x->x_buf, *f2 = x->x_buf + x->x_hop;
- int nshift = x->x_bufsize - x->x_hop;
- out -= x->x_hop;
- while (nshift--) *f1++ = *f2++;
- }
-#if 0
- if (tot < 5) post("in %x out %x n %x", in, out, n), tot++;
- if (tot < 5) post("in[0] %f in[1] %f in[2] %f", in[0], in[1], in[2]);
-#endif
-
- while (n--) *out++ = *in++;
- x->x_fill = out;
- return (w+4);
-}
-int inlet_getsignalindex(t_inlet *x);
-
- /* set up prolog DSP code */
-void vinlet_dspprolog(t_vinlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency, int downsample, int upsample/* IOhannes */, int reblock,
- int switched)
-{
- t_signal *insig, *outsig;
- x->x_updown.downsample = downsample;
- x->x_updown.upsample = upsample;
-
- /* if the "reblock" flag is set, arrange to copy data in from the
- parent. */
- if (reblock)
- {
- int parentvecsize, bufsize, oldbufsize, prologphase;
- int re_parentvecsize; /* resampled parentvectorsize: IOhannes */
- /* this should never happen: */
- if (!x->x_buf) return;
-
- /* the prolog code counts from 0 to period-1; the
- phase is backed up by one so that AFTER the prolog code
- runs, the "x_fill" phase is in sync with the "x_read" phase. */
- prologphase = (phase - 1) & (period - 1);
- if (parentsigs)
- {
- insig = parentsigs[inlet_getsignalindex(x->x_inlet)];
- parentvecsize = insig->s_n;
- re_parentvecsize = parentvecsize * upsample / downsample;
- }
- else
- {
- insig = 0;
- parentvecsize = 1;
- re_parentvecsize = 1;
- }
-
- bufsize = re_parentvecsize;
- if (bufsize < myvecsize) bufsize = myvecsize;
- if (bufsize != (oldbufsize = x->x_bufsize))
- {
- t_float *buf = x->x_buf;
- t_freebytes(buf, oldbufsize * sizeof(*buf));
- buf = (t_float *)t_getbytes(bufsize * sizeof(*buf));
- memset((char *)buf, 0, bufsize * sizeof(*buf));
- x->x_bufsize = bufsize;
- x->x_endbuf = buf + bufsize;
- x->x_buf = buf;
- }
- if (parentsigs)
- {
- /* IOhannes { */
- x->x_hop = period * re_parentvecsize;
-
- x->x_fill = x->x_endbuf -
- (x->x_hop - prologphase * re_parentvecsize);
-
- if (upsample * downsample == 1)
- dsp_add(vinlet_doprolog, 3, x, insig->s_vec, re_parentvecsize);
- else {
- resamplefrom_dsp(&x->x_updown, insig->s_vec, parentvecsize, re_parentvecsize, x->x_updown.method);
- dsp_add(vinlet_doprolog, 3, x, x->x_updown.s_vec, re_parentvecsize);
- }
-
- /* } IOhannes */
- /* if the input signal's reference count is zero, we have
- to free it here because we didn't in ugen_doit(). */
- if (!insig->s_refcount)
- signal_makereusable(insig);
- }
- else memset((char *)(x->x_buf), 0, bufsize * sizeof(*x->x_buf));
- x->x_directsignal = 0;
- }
- else
- {
- /* no reblocking; in this case our output signal is "borrowed"
- and merely needs to be pointed to the real one. */
- x->x_directsignal = parentsigs[inlet_getsignalindex(x->x_inlet)];
- }
-}
-
-//static void *vinlet_newsig(void)
-static void *vinlet_newsig(t_symbol *s)
-{
- t_vinlet *x = (t_vinlet *)pd_new(vinlet_class);
- x->x_canvas = canvas_getcurrent();
- x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, &s_signal);
- x->x_endbuf = x->x_buf = (t_float *)getbytes(0);
- x->x_bufsize = 0;
- x->x_directsignal = 0;
- outlet_new(&x->x_obj, &s_signal);
-
- resample_init(&x->x_updown);
-
- /* this should be though over:
- * it might prove hard to provide consistency between labeled up- & downsampling methods
- * maybe indeces would be better...
- *
- * up till now we provide several upsampling methods and 1 single downsampling method (no filtering !)
- */
- if (s == gensym("hold"))x->x_updown.method=1; /* up: sample and hold */
- else if (s == gensym("lin"))x->x_updown.method=2; /* up: linear interpolation */
- else x->x_updown.method=0; /* up: zero-padding */
-
- return (x);
-}
-
-static void vinlet_setup(void)
-{
- vinlet_class = class_new(gensym("inlet"), (t_newmethod)vinlet_new,
- (t_method)vinlet_free, sizeof(t_vinlet), CLASS_NOINLET, A_DEFSYM, 0);
- class_addcreator((t_newmethod)vinlet_newsig, gensym("inlet~"), A_DEFSYM, 0);
- class_addbang(vinlet_class, vinlet_bang);
- class_addpointer(vinlet_class, vinlet_pointer);
- class_addfloat(vinlet_class, vinlet_float);
- class_addsymbol(vinlet_class, vinlet_symbol);
- class_addlist(vinlet_class, vinlet_list);
- class_addanything(vinlet_class, vinlet_anything);
- class_addmethod(vinlet_class, (t_method)vinlet_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(vinlet_class, gensym("pd"));
-}
-
-/* ------------------------- voutlet -------------------------- */
-
-t_class *voutlet_class;
-
-typedef struct _voutlet
-{
- t_object x_obj;
- t_canvas *x_canvas;
- t_outlet *x_parentoutlet;
- int x_bufsize;
- t_sample *x_buf; /* signal buffer; zero if not a signal */
- t_sample *x_endbuf;
- t_sample *x_empty; /* next to read out of buffer in epilog code */
- t_sample *x_write; /* next to write in to buffer */
- int x_hop; /* hopsize */
- /* vice versa from the inlet, if we don't block, this holds the
- parent's outlet signal, valid between the prolog and the dsp setup
- routines. */
- t_signal *x_directsignal;
- /* and here's a flag indicating that we aren't blocked but have to
- do a copy (because we're switched). */
- char x_justcopyout;
- t_resample x_updown; /* IOhannes */
-} t_voutlet;
-
-static void *voutlet_new(t_symbol *s)
-{
- t_voutlet *x = (t_voutlet *)pd_new(voutlet_class);
- x->x_canvas = canvas_getcurrent();
- x->x_parentoutlet = canvas_addoutlet(x->x_canvas, &x->x_obj.ob_pd, 0);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, 0, 0);
- x->x_bufsize = 0;
- x->x_buf = 0;
- return (x);
-}
-
-static void voutlet_bang(t_voutlet *x)
-{
- outlet_bang(x->x_parentoutlet);
-}
-
-static void voutlet_pointer(t_voutlet *x, t_gpointer *gp)
-{
- outlet_pointer(x->x_parentoutlet, gp);
-}
-
-static void voutlet_float(t_voutlet *x, t_float f)
-{
- outlet_float(x->x_parentoutlet, f);
-}
-
-static void voutlet_symbol(t_voutlet *x, t_symbol *s)
-{
- outlet_symbol(x->x_parentoutlet, s);
-}
-
-static void voutlet_list(t_voutlet *x, t_symbol *s, int argc, t_atom *argv)
-{
- outlet_list(x->x_parentoutlet, s, argc, argv);
-}
-
-static void voutlet_anything(t_voutlet *x, t_symbol *s, int argc, t_atom *argv)
-{
- outlet_anything(x->x_parentoutlet, s, argc, argv);
-}
-
-static void voutlet_free(t_voutlet *x)
-{
- canvas_rmoutlet(x->x_canvas, x->x_parentoutlet);
- resample_free(&x->x_updown);
-}
-
-t_outlet *voutlet_getit(t_pd *x)
-{
- if (pd_class(x) != voutlet_class) bug("voutlet_getit");
- return (((t_voutlet *)x)->x_parentoutlet);
-}
-
-/* ------------------------- signal outlet -------------------------- */
-
-int voutlet_issignal(t_voutlet *x)
-{
- return (x->x_buf != 0);
-}
-
- /* LATER optimize for non-overlapped case where the "+=" isn't needed */
-t_int *voutlet_perform(t_int *w)
-{
- t_voutlet *x = (t_voutlet *)(w[1]);
- t_sample *in = (t_sample *)(w[2]);
- int n = (int)(w[3]);
- t_sample *out = x->x_write, *outwas = out;
-#if 0
- if (tot < 5) post("-in %x out %x n %d", in, out, n);
- if (tot < 5) post("-buf %x endbuf %x", x->x_buf, x->x_endbuf);
-#endif
- while (n--)
- {
- *out++ += *in++;
- if (out == x->x_endbuf) out = x->x_buf;
- }
- outwas += x->x_hop;
- if (outwas >= x->x_endbuf) outwas = x->x_buf;
- x->x_write = outwas;
- return (w+4);
-}
-
- /* epilog code for blocking: write buffer to parent patch */
-static t_int *voutlet_doepilog(t_int *w)
-{
- t_voutlet *x = (t_voutlet *)(w[1]);
- t_sample *out = (t_sample *)(w[2]); /* IOhannes */
-
- int n = (int)(w[3]);
- t_sample *in = x->x_empty;
- if (x->x_updown.downsample != x->x_updown.upsample) out = x->x_updown.s_vec; /* IOhannes */
-
-#if 0
- if (tot < 5) post("outlet in %x out %x n %x", in, out, n), tot++;
-#endif
- for (; n--; in++) *out++ = *in, *in = 0;
- if (in == x->x_endbuf) in = x->x_buf;
- x->x_empty = in;
- return (w+4);
-}
-
-/* IOhannes { */
-static t_int *voutlet_doepilog_resampling(t_int *w)
-{
- t_voutlet *x = (t_voutlet *)(w[1]);
- // t_float *dummy = (t_float *)(w[2]);
- int n = (int)(w[2]);
- t_sample *in = x->x_empty;
- t_sample *out = x->x_updown.s_vec; /* IOhannes */
-
-#if 0
- if (tot < 5) post("outlet in %x out %x n %x", in, out, n), tot++;
-#endif
- for (; n--; in++) *out++ = *in, *in = 0;
- if (in == x->x_endbuf) in = x->x_buf;
- x->x_empty = in;
- return (w+3);
-}
-/* } IOhannes */
-int outlet_getsignalindex(t_outlet *x);
-
- /* prolog for outlets -- store pointer to the outlet on the
- parent, which, if "reblock" is false, will want to refer
- back to whatever we see on our input during the "dsp" method
- called later. */
-void voutlet_dspprolog(t_voutlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock,
- int switched)
-{
- x->x_updown.downsample=downsample; x->x_updown.upsample=upsample; /* IOhannes */
- x->x_justcopyout = (switched && !reblock);
- if (reblock)
- {
- x->x_directsignal = 0;
- }
- else
- {
- if (!parentsigs) bug("voutlet_dspprolog");
- x->x_directsignal =
- parentsigs[outlet_getsignalindex(x->x_parentoutlet)];
- }
-}
-
-static void voutlet_dsp(t_voutlet *x, t_signal **sp)
-{
- t_signal *insig;
- if (!x->x_buf) return;
- insig = sp[0];
- if (x->x_justcopyout)
- dsp_add_copy(insig->s_vec, x->x_directsignal->s_vec, insig->s_n);
- else if (x->x_directsignal)
- {
- /* if we're just going to make the signal available on the
- parent patch, hand it off to the parent signal. */
- /* this is done elsewhere--> sp[0]->s_refcount++; */
- signal_setborrowed(x->x_directsignal, sp[0]);
- }
- else
- dsp_add(voutlet_perform, 3, x, insig->s_vec, insig->s_n);
-}
-
- /* set up epilog DSP code. If we're reblocking, this is the
- time to copy the samples out to the containing object's outlets.
- If we aren't reblocking, there's nothing to do here. */
-void voutlet_dspepilog(t_voutlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock,
- int switched)
-{
- if (!x->x_buf) return; /* this shouldn't be necesssary... */
- x->x_updown.downsample=downsample; x->x_updown.upsample=upsample; /* IOhannes */
- if (reblock)
- {
- t_signal *insig, *outsig;
- int parentvecsize, bufsize, oldbufsize;
- int re_parentvecsize; /* IOhannes */
- int bigperiod, epilogphase, blockphase;
- if (parentsigs)
- {
- outsig = parentsigs[outlet_getsignalindex(x->x_parentoutlet)];
- parentvecsize = outsig->s_n;
- re_parentvecsize = parentvecsize * upsample / downsample;
- }
- else
- {
- outsig = 0;
- parentvecsize = 1;
- re_parentvecsize = 1;
- }
- // bigperiod = (downsample * myvecsize)/(upsample * parentvecsize); /* IOhannes */
- bigperiod = myvecsize/re_parentvecsize; /* IOhannes */
- if (!bigperiod) bigperiod = 1;
- epilogphase = phase & (bigperiod - 1);
- blockphase = (phase + period - 1) & (bigperiod - 1) & (- period);
- // bufsize = parentvecsize * upsample; /* IOhannes */
- bufsize = re_parentvecsize; /* IOhannes */
- if (bufsize < myvecsize) bufsize = myvecsize;
- if (bufsize != (oldbufsize = x->x_bufsize))
- {
- t_sample *buf = x->x_buf;
- t_freebytes(buf, oldbufsize * sizeof(*buf));
- buf = (t_sample *)t_getbytes(bufsize * sizeof(*buf));
- memset((char *)buf, 0, bufsize * sizeof(*buf));
- x->x_bufsize = bufsize;
- x->x_endbuf = buf + bufsize;
- x->x_buf = buf;
- }
- /* IOhannes: { */
- if (re_parentvecsize * period > bufsize) bug("voutlet_dspepilog");
- x->x_write = x->x_buf + re_parentvecsize * blockphase;
- if (x->x_write == x->x_endbuf) x->x_write = x->x_buf;
- if (period == 1 && frequency > 1)
- x->x_hop = re_parentvecsize / frequency;
- else x->x_hop = period * re_parentvecsize;
- /* } IOhannes */
- /* post("phase %d, block %d, parent %d", phase & 63,
- parentvecsize * blockphase, parentvecsize * epilogphase); */
- if (parentsigs)
- {
- /* set epilog pointer and schedule it */
- /* IOhannes { */
- x->x_empty = x->x_buf + re_parentvecsize * epilogphase;
- if (upsample * downsample == 1)
- dsp_add(voutlet_doepilog, 3, x, outsig->s_vec, re_parentvecsize);
- else {
- dsp_add(voutlet_doepilog_resampling, 2, x, re_parentvecsize);
- resampleto_dsp(&x->x_updown, outsig->s_vec, re_parentvecsize, parentvecsize, x->x_updown.method);
- }
- /* } IOhannes */
- }
- }
- /* if we aren't blocked but we are switched, the epilog code just
- copies zeros to the output. In this case the blocking code actually
- jumps over the epilog if the block is running. */
- else if (switched)
- {
- if (parentsigs)
- {
- t_signal *outsig =
- parentsigs[outlet_getsignalindex(x->x_parentoutlet)];
- dsp_add_zero(outsig->s_vec, outsig->s_n);
- }
- }
-}
-
-static void *voutlet_newsig(t_symbol *s)
-{
- t_voutlet *x = (t_voutlet *)pd_new(voutlet_class);
- x->x_canvas = canvas_getcurrent();
- x->x_parentoutlet = canvas_addoutlet(x->x_canvas,
- &x->x_obj.ob_pd, &s_signal);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- x->x_endbuf = x->x_buf = (t_sample *)getbytes(0);
- x->x_bufsize = 0;
-
- resample_init(&x->x_updown);
-
- /* this should be though over:
- * it might prove hard to provide consistency between labeled up- & downsampling methods
- * maybe indeces would be better...
- *
- * up till now we provide several upsampling methods and 1 single downsampling method (no filtering !)
- */
- if (s == gensym("hold"))x->x_updown.method=1; /* up: sample and hold */
- else if (s == gensym("lin"))x->x_updown.method=2; /* up: linear interpolation */
- else if (s == gensym("linear"))x->x_updown.method=2; /* up: linear interpolation */
- else x->x_updown.method=0; /* up: zero-padding; down: ignore samples inbetween */
-
- return (x);
-}
-
-
-static void voutlet_setup(void)
-{
- voutlet_class = class_new(gensym("outlet"), (t_newmethod)voutlet_new,
- (t_method)voutlet_free, sizeof(t_voutlet), CLASS_NOINLET, A_DEFSYM, 0);
- class_addcreator((t_newmethod)voutlet_newsig, gensym("outlet~"), A_DEFSYM, 0);
- class_addbang(voutlet_class, voutlet_bang);
- class_addpointer(voutlet_class, voutlet_pointer);
- class_addfloat(voutlet_class, (t_method)voutlet_float);
- class_addsymbol(voutlet_class, voutlet_symbol);
- class_addlist(voutlet_class, voutlet_list);
- class_addanything(voutlet_class, voutlet_anything);
- class_addmethod(voutlet_class, (t_method)voutlet_dsp, gensym("dsp"), 0);
- class_sethelpsymbol(voutlet_class, gensym("pd"));
-}
-
-
-/* ---------------------------- overall setup ----------------------------- */
-
-void g_io_setup(void)
-{
- vinlet_setup();
- voutlet_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_mycanvas.c b/apps/plugins/pdbox/PDa/src/g_mycanvas.c
index 24dfbb246b..92615e912f 100644
--- a/apps/plugins/pdbox/PDa/src/g_mycanvas.c
+++ b/apps/plugins/pdbox/PDa/src/g_mycanvas.c
@@ -383,388 +383,4 @@ void g_mycanvas_setup(void)
class_setsavefn(my_canvas_class, my_canvas_save);
class_setpropertiesfn(my_canvas_class, my_canvas_properties);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-#ifdef MSW
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-/* ---------- cnv my gui-canvas for a window ---------------- */
-
-t_widgetbehavior my_canvas_widgetbehavior;
-static t_class *my_canvas_class;
-
-/* widget helper functions */
-
-void my_canvas_draw_new(t_my_canvas *x, t_glist *glist)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xRECT\n",
- canvas, xpos, ypos,
- xpos + x->x_vis_w, ypos + x->x_vis_h,
- x->x_gui.x_bcol, x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -outline #%6.6x -tags %xBASE\n",
- canvas, xpos, ypos,
- xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
- x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
- canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
- x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
-}
-
-void my_canvas_draw_move(t_my_canvas *x, t_glist *glist)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c coords %xRECT %d %d %d %d\n",
- canvas, x, xpos, ypos, xpos + x->x_vis_w,
- ypos + x->x_vis_h);
- sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
- canvas, x, xpos, ypos,
- xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- canvas, x, xpos+x->x_gui.x_ldx,
- ypos+x->x_gui.x_ldy);
-}
-
-void my_canvas_draw_erase(t_my_canvas* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
- sys_vgui(".x%x.c delete %xRECT\n", canvas, x);
- sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
-}
-
-void my_canvas_draw_config(t_my_canvas* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xRECT -fill #%6.6x -outline #%6.6x\n", canvas, x,
- x->x_gui.x_bcol, x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
-}
-
-void my_canvas_draw_select(t_my_canvas* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- if(x->x_gui.x_fsf.x_selected)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- }
- else
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, x->x_gui.x_bcol);
- }
-}
-
-void my_canvas_draw(t_my_canvas *x, t_glist *glist, int mode)
-{
- if(mode == IEM_GUI_DRAW_MODE_MOVE)
- my_canvas_draw_move(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_NEW)
- my_canvas_draw_new(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_SELECT)
- my_canvas_draw_select(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_ERASE)
- my_canvas_draw_erase(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
- my_canvas_draw_config(x, glist);
-}
-
-/* ------------------------ cnv widgetbehaviour----------------------------- */
-
-static void my_canvas_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_my_canvas *x = (t_my_canvas *)z;
-
- *xp1 = text_xpix(&x->x_gui.x_obj, glist);
- *yp1 = text_ypix(&x->x_gui.x_obj, glist);
- *xp2 = *xp1 + x->x_gui.x_w;
- *yp2 = *yp1 + x->x_gui.x_h;
-}
-
-static void my_canvas_save(t_gobj *z, t_binbuf *b)
-{
- t_my_canvas *x = (t_my_canvas *)z;
- int bflcol[3];
- t_symbol *srl[3];
-
- iemgui_save(&x->x_gui, srl, bflcol);
- binbuf_addv(b, "ssiisiiisssiiiiiii", gensym("#X"),gensym("obj"),
- (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
- gensym("cnv"), x->x_gui.x_w, x->x_vis_w, x->x_vis_h,
- srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy,
- iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
- bflcol[0], bflcol[2], iem_symargstoint(&x->x_gui.x_isa));
- binbuf_addv(b, ";");
-}
-
-static void my_canvas_properties(t_gobj *z, t_glist *owner)
-{
- t_my_canvas *x = (t_my_canvas *)z;
- char buf[800];
- t_symbol *srl[3];
-
- iemgui_properties(&x->x_gui, srl);
- sprintf(buf, "pdtk_iemgui_dialog %%s MY_CANVAS \
- ------selectable_dimensions(pix):------ %d %d size: 0.0 0.0 empty \
- ------visible_rectangle(pix)(pix):------ %d width: %d height: %d \
- %d empty empty %d %d empty %d \
- %s %s \
- %s %d %d \
- %d %d \
- %d %d %d\n",
- x->x_gui.x_w, 1,
- x->x_vis_w, x->x_vis_h, 0,/*no_schedule*/
- -1, -1, -1, -1,/*no linlog, no init, no multi*/
- srl[0]->s_name, srl[1]->s_name,
- srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
- x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
- 0xffffff & x->x_gui.x_bcol, -1/*no frontcolor*/, 0xffffff & x->x_gui.x_lcol);
- gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
-}
-
-static void my_canvas_get_pos(t_my_canvas *x)
-{
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- {
- x->x_at[0].a_w.w_float = text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
- x->x_at[1].a_w.w_float = text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
-}
-
-static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *srl[3];
- int a = (int)atom_getintarg(0, argc, argv);
- int w = (int)atom_getintarg(2, argc, argv);
- int h = (int)atom_getintarg(3, argc, argv);
- int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
-
- x->x_gui.x_isa.x_loadinit = 0;
- if(a < 1)
- a = 1;
- x->x_gui.x_w = a;
- x->x_gui.x_h = x->x_gui.x_w;
- if(w < 1)
- w = 1;
- x->x_vis_w = w;
- if(h < 1)
- h = 1;
- x->x_vis_h = h;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
-}
-
-static void my_canvas_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
-{
- int i = (int)atom_getintarg(0, ac, av);
-
- if(i < 1)
- i = 1;
- x->x_gui.x_w = i;
- x->x_gui.x_h = i;
- iemgui_size((void *)x, &x->x_gui);
-}
-
-static void my_canvas_delta(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
-
-static void my_canvas_pos(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void my_canvas_vis_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
-{
- int i;
-
- i = (int)atom_getintarg(0, ac, av);
- if(i < 1)
- i = 1;
- x->x_vis_w = i;
- if(ac > 1)
- {
- i = (int)atom_getintarg(1, ac, av);
- if(i < 1)
- i = 1;
- }
- x->x_vis_h = i;
- if(glist_isvisible(x->x_gui.x_glist))
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
-}
-
-static void my_canvas_color(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
-
-static void my_canvas_send(t_my_canvas *x, t_symbol *s)
-{iemgui_send(x, &x->x_gui, s);}
-
-static void my_canvas_receive(t_my_canvas *x, t_symbol *s)
-{iemgui_receive(x, &x->x_gui, s);}
-
-static void my_canvas_label(t_my_canvas *x, t_symbol *s)
-{iemgui_label((void *)x, &x->x_gui, s);}
-
-static void my_canvas_label_pos(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void my_canvas_label_font(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
-
-static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_my_canvas *x = (t_my_canvas *)pd_new(my_canvas_class);
- int bflcol[]={-233017, -1, -66577};
- int a=IEM_GUI_DEFAULTSIZE, w=100, h=60;
- int ldx=20, ldy=12, f=2, i=0;
- int fs=14;
- char str[144];
-
- iem_inttosymargs(&x->x_gui.x_isa, 0);
- iem_inttofstyle(&x->x_gui.x_fsf, 0);
-
- if(((argc >= 10)&&(argc <= 13))
- &&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2))
- {
- a = (int)atom_getintarg(0, argc, argv);
- w = (int)atom_getintarg(1, argc, argv);
- h = (int)atom_getintarg(2, argc, argv);
- }
- if((argc >= 12)&&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))&&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4)))
- {
- i = 2;
- iemgui_new_getnames(&x->x_gui, 3, argv);
- }
- else if((argc == 11)&&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3)))
- {
- i = 1;
- iemgui_new_getnames(&x->x_gui, 3, argv);
- }
- else iemgui_new_getnames(&x->x_gui, 3, 0);
-
- if(((argc >= 10)&&(argc <= 13))
- &&(IS_A_SYMBOL(argv,i+3)||IS_A_FLOAT(argv,i+3))&&IS_A_FLOAT(argv,i+4)
- &&IS_A_FLOAT(argv,i+5)&&IS_A_FLOAT(argv,i+6)
- &&IS_A_FLOAT(argv,i+7)&&IS_A_FLOAT(argv,i+8)
- &&IS_A_FLOAT(argv,i+9))
- {
- /* disastrously, the "label" sits in a different part of the
- message. So we have to track its location separately (in
- the slot x_labelbindex) and initialize it specially here. */
- iemgui_new_dogetname(&x->x_gui, i+3, argv);
- x->x_gui.x_labelbindex = i+4;
- ldx = (int)atom_getintarg(i+4, argc, argv);
- ldy = (int)atom_getintarg(i+5, argc, argv);
- iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(i+6, argc, argv));
- fs = (int)atom_getintarg(i+7, argc, argv);
- bflcol[0] = (int)atom_getintarg(i+8, argc, argv);
- bflcol[2] = (int)atom_getintarg(i+9, argc, argv);
- }
- if((argc == 13)&&IS_A_FLOAT(argv,i+10))
- {
- iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(i+10, argc, argv));
- }
- x->x_gui.x_draw = (t_iemfunptr)my_canvas_draw;
- x->x_gui.x_fsf.x_snd_able = 1;
- x->x_gui.x_fsf.x_rcv_able = 1;
- x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
- if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
- x->x_gui.x_fsf.x_snd_able = 0;
- if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
- x->x_gui.x_fsf.x_rcv_able = 0;
- if(a < 1)
- a = 1;
- x->x_gui.x_w = a;
- x->x_gui.x_h = x->x_gui.x_w;
- if(w < 1)
- w = 1;
- x->x_vis_w = w;
- if(h < 1)
- h = 1;
- x->x_vis_h = h;
- if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
- else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
- else { x->x_gui.x_fsf.x_font_style = 0;
- strcpy(x->x_gui.x_font, "courier"); }
- if (x->x_gui.x_fsf.x_rcv_able)
- pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- x->x_gui.x_ldx = ldx;
- x->x_gui.x_ldy = ldy;
- if(fs < 4)
- fs = 4;
- x->x_gui.x_fontsize = fs;
- iemgui_all_colfromload(&x->x_gui, bflcol);
- x->x_at[0].a_type = A_FLOAT;
- x->x_at[1].a_type = A_FLOAT;
- iemgui_verify_snd_ne_rcv(&x->x_gui);
- return (x);
-}
-
-static void my_canvas_ff(t_my_canvas *x)
-{
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- gfxstub_deleteforkey(x);
-}
-
-void g_mycanvas_setup(void)
-{
- my_canvas_class = class_new(gensym("cnv"), (t_newmethod)my_canvas_new,
- (t_method)my_canvas_ff, sizeof(t_my_canvas), CLASS_NOINLET, A_GIMME, 0);
- class_addcreator((t_newmethod)my_canvas_new, gensym("my_canvas"), A_GIMME, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_dialog, gensym("dialog"), A_GIMME, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_size, gensym("size"), A_GIMME, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_delta, gensym("delta"), A_GIMME, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_pos, gensym("pos"), A_GIMME, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_vis_size, gensym("vis_size"), A_GIMME, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_color, gensym("color"), A_GIMME, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_send, gensym("send"), A_DEFSYM, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_receive, gensym("receive"), A_DEFSYM, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_label, gensym("label"), A_DEFSYM, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_label_pos, gensym("label_pos"), A_GIMME, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_label_font, gensym("label_font"), A_GIMME, 0);
- class_addmethod(my_canvas_class, (t_method)my_canvas_get_pos, gensym("get_pos"), 0);
- my_canvas_widgetbehavior.w_getrectfn = my_canvas_getrect;
- my_canvas_widgetbehavior.w_displacefn = iemgui_displace;
- my_canvas_widgetbehavior.w_selectfn = iemgui_select;
- my_canvas_widgetbehavior.w_activatefn = NULL;
- my_canvas_widgetbehavior.w_deletefn = iemgui_delete;
- my_canvas_widgetbehavior.w_visfn = iemgui_vis;
- my_canvas_widgetbehavior.w_clickfn = NULL;
- class_setwidget(my_canvas_class, &my_canvas_widgetbehavior);
- class_sethelpsymbol(my_canvas_class, gensym("my_canvas"));
- class_setsavefn(my_canvas_class, my_canvas_save);
- class_setpropertiesfn(my_canvas_class, my_canvas_properties);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_numbox.c b/apps/plugins/pdbox/PDa/src/g_numbox.c
index e7421204d3..1c4dbb5e48 100644
--- a/apps/plugins/pdbox/PDa/src/g_numbox.c
+++ b/apps/plugins/pdbox/PDa/src/g_numbox.c
@@ -905,910 +905,4 @@ void g_numbox_setup(void)
class_setsavefn(my_numbox_class, my_numbox_save);
class_setpropertiesfn(my_numbox_class, my_numbox_properties);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* my_numbox.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-#ifdef MSW
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-/*------------------ global varaibles -------------------------*/
-
-
-/*------------------ global functions -------------------------*/
-
-static void my_numbox_key(void *z, t_floatarg fkey);
-
-/* ------------ nmx gui-my number box ----------------------- */
-
-t_widgetbehavior my_numbox_widgetbehavior;
-static t_class *my_numbox_class;
-
-/* widget helper functions */
-
-static void my_numbox_tick_reset(t_my_numbox *x)
-{
- if(x->x_gui.x_fsf.x_change)
- {
- x->x_gui.x_fsf.x_change = 0;
- glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
-}
-
-static void my_numbox_tick_wait(t_my_numbox *x)
-{
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
-}
-
-void my_numbox_clip(t_my_numbox *x)
-{
- if(x->x_val < x->x_min)
- x->x_val = x->x_min;
- if(x->x_val > x->x_max)
- x->x_val = x->x_max;
-}
-
-void my_numbox_calc_fontwidth(t_my_numbox *x)
-{
- int w, f=31;
-
- if(x->x_gui.x_fsf.x_font_style == 1)
- f = 27;
- else if(x->x_gui.x_fsf.x_font_style == 2)
- f = 25;
-
- w = x->x_gui.x_fontsize * f * x->x_gui.x_w;
- w /= 36;
- x->x_numwidth = w + (x->x_gui.x_h / 2) + 4;
-}
-
-void my_numbox_ftoa(t_my_numbox *x)
-{
- double f=x->x_val;
- int bufsize, is_exp=0, i, idecimal;
-
- sprintf(x->x_buf, "%g", f);
- bufsize = strlen(x->x_buf);
- if(bufsize >= 5)/* if it is in exponential mode */
- {
- i = bufsize - 4;
- if((x->x_buf[i] == 'e') || (x->x_buf[i] == 'E'))
- is_exp = 1;
- }
- if(bufsize > x->x_gui.x_w)/* if to reduce */
- {
- if(is_exp)
- {
- if(x->x_gui.x_w <= 5)
- {
- x->x_buf[0] = (f < 0.0 ? '-' : '+');
- x->x_buf[1] = 0;
- }
- i = bufsize - 4;
- for(idecimal=0; idecimal < i; idecimal++)
- if(x->x_buf[idecimal] == '.')
- break;
- if(idecimal > (x->x_gui.x_w - 4))
- {
- x->x_buf[0] = (f < 0.0 ? '-' : '+');
- x->x_buf[1] = 0;
- }
- else
- {
- int new_exp_index=x->x_gui.x_w-4, old_exp_index=bufsize-4;
-
- for(i=0; i < 4; i++, new_exp_index++, old_exp_index++)
- x->x_buf[new_exp_index] = x->x_buf[old_exp_index];
- x->x_buf[x->x_gui.x_w] = 0;
- }
-
- }
- else
- {
- for(idecimal=0; idecimal < bufsize; idecimal++)
- if(x->x_buf[idecimal] == '.')
- break;
- if(idecimal > x->x_gui.x_w)
- {
- x->x_buf[0] = (f < 0.0 ? '-' : '+');
- x->x_buf[1] = 0;
- }
- else
- x->x_buf[x->x_gui.x_w] = 0;
- }
- }
-}
-
-static void my_numbox_draw_update(t_my_numbox *x, t_glist *glist)
-{
- if (glist_isvisible(glist))
- {
- if(x->x_gui.x_fsf.x_change)
- {
- if(x->x_buf[0])
- {
- char *cp=x->x_buf;
- int sl = strlen(x->x_buf);
-
- x->x_buf[sl] = '>';
- x->x_buf[sl+1] = 0;
- if(sl >= x->x_gui.x_w)
- cp += sl - x->x_gui.x_w + 1;
- sys_vgui(
- ".x%x.c itemconfigure %xNUMBER -fill #%6.6x -text {%s} \n",
- glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, cp);
- x->x_buf[sl] = 0;
- }
- else
- {
- my_numbox_ftoa(x);
- sys_vgui(
- ".x%x.c itemconfigure %xNUMBER -fill #%6.6x -text {%s} \n",
- glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, x->x_buf);
- x->x_buf[0] = 0;
- }
- }
- else
- {
- my_numbox_ftoa(x);
- sys_vgui(
- ".x%x.c itemconfigure %xNUMBER -fill #%6.6x -text {%s} \n",
- glist_getcanvas(glist), x,
- x->x_gui.x_fsf.x_selected?
- IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol,
- x->x_buf);
- x->x_buf[0] = 0;
- }
- }
-}
-
-static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist)
-{
- int half=x->x_gui.x_h/2, d=1+x->x_gui.x_h/34;
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(
-".x%x.c create polygon %d %d %d %d %d %d %d %d %d %d -outline #%6.6x \
--fill #%6.6x -tags %xBASE1\n",
- canvas, xpos, ypos,
- xpos + x->x_numwidth-4, ypos,
- xpos + x->x_numwidth, ypos+4,
- xpos + x->x_numwidth, ypos + x->x_gui.x_h,
- xpos, ypos + x->x_gui.x_h,
- IEM_GUI_COLOR_NORMAL, x->x_gui.x_bcol, x);
- sys_vgui(
- ".x%x.c create line %d %d %d %d %d %d -fill #%6.6x -tags %xBASE2\n",
- canvas, xpos, ypos,
- xpos + half, ypos + half,
- xpos, ypos + x->x_gui.x_h,
- x->x_gui.x_fcol, x);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
- canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
- x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
- my_numbox_ftoa(x);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xNUMBER\n",
- canvas, xpos+half+2, ypos+half+d,
- x->x_buf, x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_fcol, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas,
- xpos, ypos + x->x_gui.x_h-1,
- xpos+IOWIDTH, ypos + x->x_gui.x_h,
- x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas,
- xpos, ypos,
- xpos+IOWIDTH, ypos+1,
- x, 0);
-}
-
-static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist)
-{
- int half = x->x_gui.x_h/2, d=1+x->x_gui.x_h/34;
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c coords %xBASE1 %d %d %d %d %d %d %d %d %d %d\n",
- canvas, x, xpos, ypos,
- xpos + x->x_numwidth-4, ypos,
- xpos + x->x_numwidth, ypos+4,
- xpos + x->x_numwidth, ypos + x->x_gui.x_h,
- xpos, ypos + x->x_gui.x_h);
- sys_vgui(".x%x.c coords %xBASE2 %d %d %d %d %d %d\n",
- canvas, x, xpos, ypos,
- xpos + half, ypos + half,
- xpos, ypos + x->x_gui.x_h);
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
- sys_vgui(".x%x.c coords %xNUMBER %d %d\n",
- canvas, x, xpos+half+2, ypos+half+d);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
- canvas, x, 0,
- xpos, ypos + x->x_gui.x_h-1,
- xpos+IOWIDTH, ypos + x->x_gui.x_h);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
- canvas, x, 0,
- xpos, ypos,
- xpos+IOWIDTH, ypos+1);
-}
-
-static void my_numbox_draw_erase(t_my_numbox* x,t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c delete %xBASE1\n", canvas, x);
- sys_vgui(".x%x.c delete %xBASE2\n", canvas, x);
- sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
- sys_vgui(".x%x.c delete %xNUMBER\n", canvas, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
- sys_vgui(".x%x.c itemconfigure %xNUMBER -font {%s %d bold} -fill #%6.6x \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol);
- sys_vgui(".x%x.c itemconfigure %xBASE1 -fill #%6.6x\n", canvas,
- x, x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xBASE2 -fill #%6.6x\n", canvas,
- x, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol);
-}
-
-static void my_numbox_draw_io(t_my_numbox* x,t_glist* glist, int old_snd_rcv_flags)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas,
- xpos, ypos + x->x_gui.x_h-1,
- xpos+IOWIDTH, ypos + x->x_gui.x_h,
- x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas,
- xpos, ypos,
- xpos+IOWIDTH, ypos+1,
- x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- if(x->x_gui.x_fsf.x_selected)
- {
- if(x->x_gui.x_fsf.x_change)
- {
- x->x_gui.x_fsf.x_change = 0;
- clock_unset(x->x_clock_reset);
- x->x_buf[0] = 0;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
- sys_vgui(".x%x.c itemconfigure %xBASE1 -outline #%6.6x\n",
- canvas, x, IEM_GUI_COLOR_SELECTED);
- sys_vgui(".x%x.c itemconfigure %xBASE2 -fill #%6.6x\n",
- canvas, x, IEM_GUI_COLOR_SELECTED);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n",
- canvas, x, IEM_GUI_COLOR_SELECTED);
- sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x\n",
- canvas, x, IEM_GUI_COLOR_SELECTED);
- }
- else
- {
- sys_vgui(".x%x.c itemconfigure %xBASE1 -outline #%6.6x\n",
- canvas, x, IEM_GUI_COLOR_NORMAL);
- sys_vgui(".x%x.c itemconfigure %xBASE2 -fill #%6.6x\n",
- canvas, x, x->x_gui.x_fcol);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n",
- canvas, x, x->x_gui.x_lcol);
- sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x\n",
- canvas, x, x->x_gui.x_fcol);
- }
-}
-
-void my_numbox_draw(t_my_numbox *x, t_glist *glist, int mode)
-{
- if(mode == IEM_GUI_DRAW_MODE_UPDATE)
- my_numbox_draw_update(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_MOVE)
- my_numbox_draw_move(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_NEW)
- my_numbox_draw_new(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_SELECT)
- my_numbox_draw_select(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_ERASE)
- my_numbox_draw_erase(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
- my_numbox_draw_config(x, glist);
- else if(mode >= IEM_GUI_DRAW_MODE_IO)
- my_numbox_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
-}
-
-/* ------------------------ nbx widgetbehaviour----------------------------- */
-
-
-static void my_numbox_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_my_numbox* x = (t_my_numbox*)z;
-
- *xp1 = text_xpix(&x->x_gui.x_obj, glist);
- *yp1 = text_ypix(&x->x_gui.x_obj, glist);
- *xp2 = *xp1 + x->x_numwidth;
- *yp2 = *yp1 + x->x_gui.x_h;
-}
-
-static void my_numbox_save(t_gobj *z, t_binbuf *b)
-{
- t_my_numbox *x = (t_my_numbox *)z;
- int bflcol[3];
- t_symbol *srl[3];
-
- iemgui_save(&x->x_gui, srl, bflcol);
- if(x->x_gui.x_fsf.x_change)
- {
- x->x_gui.x_fsf.x_change = 0;
- clock_unset(x->x_clock_reset);
- glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
-
- }
- binbuf_addv(b, "ssiisiiffiisssiiiiiiifi", gensym("#X"),gensym("obj"),
- (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
- gensym("nbx"), x->x_gui.x_w, x->x_gui.x_h,
- (float)x->x_min, (float)x->x_max,
- x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa),
- srl[0], srl[1], srl[2],
- x->x_gui.x_ldx, x->x_gui.x_ldy,
- iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
- bflcol[0], bflcol[1], bflcol[2],
- x->x_val, x->x_log_height);
- binbuf_addv(b, ";");
-}
-
-int my_numbox_check_minmax(t_my_numbox *x, double min, double max)
-{
- int ret=0;
-
- if(x->x_lin0_log1)
- {
- if((min == 0.0)&&(max == 0.0))
- max = 1.0;
- if(max > 0.0)
- {
- if(min <= 0.0)
- min = 0.01*max;
- }
- else
- {
- if(min > 0.0)
- max = 0.01*min;
- }
- }
- x->x_min = min;
- x->x_max = max;
- if(x->x_val < x->x_min)
- {
- x->x_val = x->x_min;
- ret = 1;
- }
- if(x->x_val > x->x_max)
- {
- x->x_val = x->x_max;
- ret = 1;
- }
- if(x->x_lin0_log1)
- x->x_k = exp(log(x->x_max/x->x_min)/(double)(x->x_log_height));
- else
- x->x_k = 1.0;
- return(ret);
-}
-
-static void my_numbox_properties(t_gobj *z, t_glist *owner)
-{
- t_my_numbox *x = (t_my_numbox *)z;
- char buf[800];
- t_symbol *srl[3];
-
- iemgui_properties(&x->x_gui, srl);
- if(x->x_gui.x_fsf.x_change)
- {
- x->x_gui.x_fsf.x_change = 0;
- clock_unset(x->x_clock_reset);
- glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
- sprintf(buf, "pdtk_iemgui_dialog %%s NUMBERBOX \
- -------dimensions(digits)(pix):------- %d %d width: %d %d height: \
- -----------output-range:----------- %g min: %g max: %d \
- %d lin log %d %d log-height: %d \
- %s %s \
- %s %d %d \
- %d %d \
- %d %d %d\n",
- x->x_gui.x_w, 1, x->x_gui.x_h, 8,
- x->x_min, x->x_max, 0,/*no_schedule*/
- x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, -1,
- x->x_log_height, /*no multi, but iem-characteristic*/
- srl[0]->s_name, srl[1]->s_name,
- srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
- x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
- 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol,
- 0xffffff & x->x_gui.x_lcol);
- gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
-}
-
-static void my_numbox_bang(t_my_numbox *x)
-{
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_val);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_val);
-}
-
-static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc,
- t_atom *argv)
-{
- t_symbol *srl[3];
- int w = (int)atom_getintarg(0, argc, argv);
- int h = (int)atom_getintarg(1, argc, argv);
- double min = (double)atom_getfloatarg(2, argc, argv);
- double max = (double)atom_getfloatarg(3, argc, argv);
- int lilo = (int)atom_getintarg(4, argc, argv);
- int log_height = (int)atom_getintarg(6, argc, argv);
- int sr_flags;
-
- if(lilo != 0) lilo = 1;
- x->x_lin0_log1 = lilo;
- sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
- if(w < 1)
- w = 1;
- x->x_gui.x_w = w;
- if(h < 8)
- h = 8;
- x->x_gui.x_h = h;
- if(log_height < 10)
- log_height = 10;
- x->x_log_height = log_height;
- my_numbox_calc_fontwidth(x);
- /*if(my_numbox_check_minmax(x, min, max))
- my_numbox_bang(x);*/
- my_numbox_check_minmax(x, min, max);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
-}
-
-static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy)
-{
- double k2=1.0;
-
- if(x->x_gui.x_fsf.x_finemoved)
- k2 = 0.01;
- if(x->x_lin0_log1)
- x->x_val *= pow(x->x_k, -k2*dy);
- else
- x->x_val -= k2*dy;
- my_numbox_clip(x);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- my_numbox_bang(x);
- clock_unset(x->x_clock_reset);
-}
-
-static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos,
- t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
-{
- glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
- (t_glistmotionfn)my_numbox_motion, my_numbox_key, xpos, ypos);
-}
-
-static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_my_numbox* x = (t_my_numbox *)z;
-
- if(doit)
- {
- my_numbox_click( x, (t_floatarg)xpix, (t_floatarg)ypix,
- (t_floatarg)shift, 0, (t_floatarg)alt);
- if(shift)
- x->x_gui.x_fsf.x_finemoved = 1;
- else
- x->x_gui.x_fsf.x_finemoved = 0;
- if(!x->x_gui.x_fsf.x_change)
- {
- clock_delay(x->x_clock_wait, 50);
- x->x_gui.x_fsf.x_change = 1;
- clock_delay(x->x_clock_reset, 3000);
- /* glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.ob_g,
- 0, my_numbox_key, 0, 0); */
-
- x->x_buf[0] = 0;
- }
- else
- {
- x->x_gui.x_fsf.x_change = 0;
- clock_unset(x->x_clock_reset);
- glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0);
- x->x_buf[0] = 0;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
- }
- return (1);
-}
-
-static void my_numbox_set(t_my_numbox *x, t_floatarg f)
-{
- x->x_val = f;
- my_numbox_clip(x);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
-}
-
-static void my_numbox_log_height(t_my_numbox *x, t_floatarg lh)
-{
- if(lh < 10.0)
- lh = 10.0;
- x->x_log_height = (int)lh;
- if(x->x_lin0_log1)
- x->x_k = exp(log(x->x_max/x->x_min)/(double)(x->x_log_height));
- else
- x->x_k = 1.0;
-
-}
-
-static void my_numbox_float(t_my_numbox *x, t_floatarg f)
-{
- my_numbox_set(x, f);
- if(x->x_gui.x_fsf.x_put_in2out)
- my_numbox_bang(x);
-}
-
-static void my_numbox_size(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
-{
- int h, w;
-
- w = (int)atom_getintarg(0, ac, av);
- if(w < 1)
- w = 1;
- x->x_gui.x_w = w;
- if(ac > 1)
- {
- h = (int)atom_getintarg(1, ac, av);
- if(h < 8)
- h = 8;
- x->x_gui.x_h = h;
- }
- my_numbox_calc_fontwidth(x);
- iemgui_size((void *)x, &x->x_gui);
-}
-
-static void my_numbox_delta(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
-
-static void my_numbox_pos(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void my_numbox_range(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
-{
- if(my_numbox_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
- (double)atom_getfloatarg(1, ac, av)))
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- /*my_numbox_bang(x);*/
- }
-}
-
-static void my_numbox_color(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
-
-static void my_numbox_send(t_my_numbox *x, t_symbol *s)
-{iemgui_send(x, &x->x_gui, s);}
-
-static void my_numbox_receive(t_my_numbox *x, t_symbol *s)
-{iemgui_receive(x, &x->x_gui, s);}
-
-static void my_numbox_label(t_my_numbox *x, t_symbol *s)
-{iemgui_label((void *)x, &x->x_gui, s);}
-
-static void my_numbox_label_pos(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void my_numbox_label_font(t_my_numbox *x,
- t_symbol *s, int ac, t_atom *av)
-{
- int f = (int)atom_getintarg(1, ac, av);
-
- if(f < 4)
- f = 4;
- x->x_gui.x_fontsize = f;
- f = (int)atom_getintarg(0, ac, av);
- if((f < 0) || (f > 2))
- f = 0;
- x->x_gui.x_fsf.x_font_style = f;
- my_numbox_calc_fontwidth(x);
- iemgui_label_font((void *)x, &x->x_gui, s, ac, av);
-}
-
-static void my_numbox_log(t_my_numbox *x)
-{
- x->x_lin0_log1 = 1;
- if(my_numbox_check_minmax(x, x->x_min, x->x_max))
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- /*my_numbox_bang(x);*/
- }
-}
-
-static void my_numbox_lin(t_my_numbox *x)
-{
- x->x_lin0_log1 = 0;
-}
-
-static void my_numbox_init(t_my_numbox *x, t_floatarg f)
-{
- x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
-}
-
-static void my_numbox_loadbang(t_my_numbox *x)
-{
- if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- my_numbox_bang(x);
- }
-}
-
-static void my_numbox_key(void *z, t_floatarg fkey)
-{
- t_my_numbox *x = z;
- char c=fkey;
- char buf[3];
- buf[1] = 0;
-
- if (c == 0)
- {
- x->x_gui.x_fsf.x_change = 0;
- clock_unset(x->x_clock_reset);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- return;
- }
- if(((c>='0')&&(c<='9'))||(c=='.')||(c=='-')||
- (c=='e')||(c=='+')||(c=='E'))
- {
- if(strlen(x->x_buf) < (IEMGUI_MAX_NUM_LEN-2))
- {
- buf[0] = c;
- strcat(x->x_buf, buf);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
- }
- else if((c=='\b')||(c==127))
- {
- int sl=strlen(x->x_buf)-1;
-
- if(sl < 0)
- sl = 0;
- x->x_buf[sl] = 0;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
- else if((c=='\n')||(c==13))
- {
- x->x_val = atof(x->x_buf);
- x->x_buf[0] = 0;
- x->x_gui.x_fsf.x_change = 0;
- clock_unset(x->x_clock_reset);
- my_numbox_clip(x);
- my_numbox_bang(x);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
- clock_delay(x->x_clock_reset, 3000);
-}
-
-static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
-{
- if (IS_A_FLOAT(av,0))
- {
- my_numbox_set(x, atom_getfloatarg(0, ac, av));
- my_numbox_bang(x);
- }
-}
-
-static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_my_numbox *x = (t_my_numbox *)pd_new(my_numbox_class);
- int bflcol[]={-262144, -1, -1};
- int w=5, h=14;
- int lilo=0, f=0, ldx=0, ldy=-6;
- int fs=10;
- int log_height=256;
- double min=-1.0e+37, max=1.0e+37,v=0.0;
- char str[144];
-
- if((argc >= 17)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
- &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
- &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
- &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
- &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
- &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
- &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
- &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
- &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16))
- {
- w = (int)atom_getintarg(0, argc, argv);
- h = (int)atom_getintarg(1, argc, argv);
- min = (double)atom_getfloatarg(2, argc, argv);
- max = (double)atom_getfloatarg(3, argc, argv);
- lilo = (int)atom_getintarg(4, argc, argv);
- iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv));
- iemgui_new_getnames(&x->x_gui, 6, argv);
- ldx = (int)atom_getintarg(9, argc, argv);
- ldy = (int)atom_getintarg(10, argc, argv);
- iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv));
- fs = (int)atom_getintarg(12, argc, argv);
- bflcol[0] = (int)atom_getintarg(13, argc, argv);
- bflcol[1] = (int)atom_getintarg(14, argc, argv);
- bflcol[2] = (int)atom_getintarg(15, argc, argv);
- v = atom_getfloatarg(16, argc, argv);
- }
- else iemgui_new_getnames(&x->x_gui, 6, 0);
- if((argc == 18)&&IS_A_FLOAT(argv,17))
- {
- log_height = (int)atom_getintarg(17, argc, argv);
- }
- x->x_gui.x_draw = (t_iemfunptr)my_numbox_draw;
- x->x_gui.x_fsf.x_snd_able = 1;
- x->x_gui.x_fsf.x_rcv_able = 1;
- x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
- if(x->x_gui.x_isa.x_loadinit)
- x->x_val = v;
- else
- x->x_val = 0.0;
- if(lilo != 0) lilo = 1;
- x->x_lin0_log1 = lilo;
- if(log_height < 10)
- log_height = 10;
- x->x_log_height = log_height;
- if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
- x->x_gui.x_fsf.x_snd_able = 0;
- if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
- x->x_gui.x_fsf.x_rcv_able = 0;
- if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
- else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
- else { x->x_gui.x_fsf.x_font_style = 0;
- strcpy(x->x_gui.x_font, "courier"); }
- if (x->x_gui.x_fsf.x_rcv_able)
- pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- x->x_gui.x_ldx = ldx;
- x->x_gui.x_ldy = ldy;
- if(fs < 4)
- fs = 4;
- x->x_gui.x_fontsize = fs;
- if(w < 1)
- w = 1;
- x->x_gui.x_w = w;
- if(h < 8)
- h = 8;
- x->x_gui.x_h = h;
- x->x_buf[0] = 0;
- my_numbox_calc_fontwidth(x);
- my_numbox_check_minmax(x, min, max);
- iemgui_all_colfromload(&x->x_gui, bflcol);
- iemgui_verify_snd_ne_rcv(&x->x_gui);
- x->x_clock_reset = clock_new(x, (t_method)my_numbox_tick_reset);
- x->x_clock_wait = clock_new(x, (t_method)my_numbox_tick_wait);
- x->x_gui.x_fsf.x_change = 0;
- outlet_new(&x->x_gui.x_obj, &s_float);
- return (x);
-}
-
-static void my_numbox_free(t_my_numbox *x)
-{
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- clock_free(x->x_clock_reset);
- clock_free(x->x_clock_wait);
- gfxstub_deleteforkey(x);
-}
-
-void g_numbox_setup(void)
-{
- my_numbox_class = class_new(gensym("nbx"), (t_newmethod)my_numbox_new,
- (t_method)my_numbox_free, sizeof(t_my_numbox), 0, A_GIMME, 0);
- class_addcreator((t_newmethod)my_numbox_new, gensym("my_numbox"),
- A_GIMME, 0);
- class_addbang(my_numbox_class,my_numbox_bang);
- class_addfloat(my_numbox_class,my_numbox_float);
- class_addlist(my_numbox_class, my_numbox_list);
- class_addmethod(my_numbox_class, (t_method)my_numbox_click,
- gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_motion,
- gensym("motion"), A_FLOAT, A_FLOAT, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_dialog,
- gensym("dialog"), A_GIMME, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_loadbang,
- gensym("loadbang"), 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_set,
- gensym("set"), A_FLOAT, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_size,
- gensym("size"), A_GIMME, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_delta,
- gensym("delta"), A_GIMME, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_pos,
- gensym("pos"), A_GIMME, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_range,
- gensym("range"), A_GIMME, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_color,
- gensym("color"), A_GIMME, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_send,
- gensym("send"), A_DEFSYM, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_receive,
- gensym("receive"), A_DEFSYM, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_label,
- gensym("label"), A_DEFSYM, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_label_pos,
- gensym("label_pos"), A_GIMME, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_label_font,
- gensym("label_font"), A_GIMME, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_log,
- gensym("log"), 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_lin,
- gensym("lin"), 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_init,
- gensym("init"), A_FLOAT, 0);
- class_addmethod(my_numbox_class, (t_method)my_numbox_log_height,
- gensym("log_height"), A_FLOAT, 0);
- my_numbox_widgetbehavior.w_getrectfn = my_numbox_getrect;
- my_numbox_widgetbehavior.w_displacefn = iemgui_displace;
- my_numbox_widgetbehavior.w_selectfn = iemgui_select;
- my_numbox_widgetbehavior.w_activatefn = NULL;
- my_numbox_widgetbehavior.w_deletefn = iemgui_delete;
- my_numbox_widgetbehavior.w_visfn = iemgui_vis;
- my_numbox_widgetbehavior.w_clickfn = my_numbox_newclick;
- class_setwidget(my_numbox_class, &my_numbox_widgetbehavior);
- class_sethelpsymbol(my_numbox_class, gensym("numbox2"));
- class_setsavefn(my_numbox_class, my_numbox_save);
- class_setpropertiesfn(my_numbox_class, my_numbox_properties);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_readwrite.c b/apps/plugins/pdbox/PDa/src/g_readwrite.c
index a25b60c443..55759dbf1a 100644
--- a/apps/plugins/pdbox/PDa/src/g_readwrite.c
+++ b/apps/plugins/pdbox/PDa/src/g_readwrite.c
@@ -721,726 +721,4 @@ void g_readwrite_setup(void)
class_addmethod(canvas_class, (t_method)canvas_menusaveas,
gensym("menusaveas"), 0);
}
-/* Copyright (c) 1997-2002 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* this file reads and writes the "data" portions of a canvas to a file.
-See also canvas_saveto(), etc., in g_editor.c. The data portion is a
-collection of "scalar" objects. Routines here can save collections of
-scalars into a file and reload them; also, support is included here for
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include <string.h>
-
- /* the following routines read "scalars" from a file into a canvas. */
-
-static int canvas_scanbinbuf(int natoms, t_atom *vec, int *p_indexout,
- int *p_next)
-{
- int i, j;
- int indexwas = *p_next;
- *p_indexout = indexwas;
- if (indexwas >= natoms)
- return (0);
- for (i = indexwas; i < natoms && vec[i].a_type != A_SEMI; i++)
- ;
- if (i >= natoms)
- *p_next = i;
- else *p_next = i + 1;
- return (i - indexwas);
-}
-
-int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
- int *p_nextmsg, int selectit);
-
-static void canvas_readerror(int natoms, t_atom *vec, int message,
- int nline, char *s)
-{
- error(s);
- startpost("line was:");
- postatom(nline, vec + message);
- endpost();
-}
-
- /* fill in the contents of the scalar into the vector w. */
-
-static void glist_readatoms(t_glist *x, int natoms, t_atom *vec,
- int *p_nextmsg, t_symbol *templatesym, t_word *w, int argc, t_atom *argv)
-{
- int message, nline, n, i;
-
- t_template *template = template_findbyname(templatesym);
- if (!template)
- {
- error("%s: no such template", templatesym->s_name);
- *p_nextmsg = natoms;
- return;
- }
- word_restore(w, template, argc, argv);
- n = template->t_n;
- for (i = 0; i < n; i++)
- {
- if (template->t_vec[i].ds_type == DT_ARRAY)
- {
- int j;
- t_array *a = w[i].w_array;
- int elemsize = a->a_elemsize, nitems = 0;
- t_symbol *arraytemplatesym = template->t_vec[i].ds_arraytemplate;
- t_template *arraytemplate =
- template_findbyname(arraytemplatesym);
- if (!arraytemplate)
- {
- error("%s: no such template", arraytemplatesym->s_name);
- }
- else while (1)
- {
- t_word *element;
- int nline = canvas_scanbinbuf(natoms, vec, &message, p_nextmsg);
- /* empty line terminates array */
- if (!nline)
- break;
- array_resize(a, arraytemplate, nitems + 1);
- element = (t_word *)(((char *)a->a_vec) +
- nitems * elemsize);
- glist_readatoms(x, natoms, vec, p_nextmsg, arraytemplatesym,
- element, nline, vec + message);
- nitems++;
- }
- }
- else if (template->t_vec[i].ds_type == DT_LIST)
- {
- while (1)
- {
- if (!glist_readscalar(w->w_list, natoms, vec,
- p_nextmsg, 0))
- break;
- }
- }
- }
-}
-
-int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
- int *p_nextmsg, int selectit)
-{
- int message, i, j, nline;
- t_template *template;
- t_symbol *templatesym;
- t_scalar *sc;
- int nextmsg = *p_nextmsg;
- int wasvis = glist_isvisible(x);
-
- if (nextmsg >= natoms || vec[nextmsg].a_type != A_SYMBOL)
- {
- if (nextmsg < natoms)
- post("stopping early: type %d", vec[nextmsg].a_type);
- *p_nextmsg = natoms;
- return (0);
- }
- templatesym = canvas_makebindsym(vec[nextmsg].a_w.w_symbol);
- *p_nextmsg = nextmsg + 1;
-
- if (!(template = template_findbyname(templatesym)))
- {
- error("canvas_read: %s: no such template", templatesym->s_name);
- *p_nextmsg = natoms;
- return (0);
- }
- sc = scalar_new(x, templatesym);
- if (!sc)
- {
- error("couldn't create scalar \"%s\"", templatesym->s_name);
- *p_nextmsg = natoms;
- return (0);
- }
- if (wasvis)
- {
- /* temporarily lie about vis flag while this is built */
- glist_getcanvas(x)->gl_mapped = 0;
- }
- glist_add(x, &sc->sc_gobj);
-
- nline = canvas_scanbinbuf(natoms, vec, &message, p_nextmsg);
- glist_readatoms(x, natoms, vec, p_nextmsg, templatesym, sc->sc_vec,
- nline, vec + message);
- if (wasvis)
- {
- /* reset vis flag as before */
- glist_getcanvas(x)->gl_mapped = 1;
- gobj_vis(&sc->sc_gobj, x, 1);
- }
- if (selectit)
- {
- glist_select(x, &sc->sc_gobj);
- }
- return (1);
-}
-
-void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem)
-{
- t_canvas *canvas = glist_getcanvas(x);
- int cr = 0, natoms, nline, message, nextmsg = 0, i, j, nitems;
- t_atom *vec;
- t_gobj *gobj;
-
- natoms = binbuf_getnatom(b);
- vec = binbuf_getvec(b);
-
-
- /* check for file type */
- nline = canvas_scanbinbuf(natoms, vec, &message, &nextmsg);
- if (nline != 1 && vec[message].a_type != A_SYMBOL &&
- strcmp(vec[message].a_w.w_symbol->s_name, "data"))
- {
- pd_error(x, "%s: file apparently of wrong type", filename);
- binbuf_free(b);
- return;
- }
- /* read in templates and check for consistency */
- while (1)
- {
- t_template *newtemplate, *existtemplate;
- t_symbol *templatesym;
- t_atom *templateargs = getbytes(0);
- int ntemplateargs = 0, newnargs;
- nline = canvas_scanbinbuf(natoms, vec, &message, &nextmsg);
- if (nline < 2)
- break;
- else if (nline > 2)
- canvas_readerror(natoms, vec, message, nline,
- "extra items ignored");
- else if (vec[message].a_type != A_SYMBOL ||
- strcmp(vec[message].a_w.w_symbol->s_name, "template") ||
- vec[message + 1].a_type != A_SYMBOL)
- {
- canvas_readerror(natoms, vec, message, nline,
- "bad template header");
- continue;
- }
- templatesym = canvas_makebindsym(vec[message + 1].a_w.w_symbol);
- while (1)
- {
- nline = canvas_scanbinbuf(natoms, vec, &message, &nextmsg);
- if (nline != 2 && nline != 3)
- break;
- newnargs = ntemplateargs + nline;
- templateargs = (t_atom *)t_resizebytes(templateargs,
- sizeof(*templateargs) * ntemplateargs,
- sizeof(*templateargs) * newnargs);
- templateargs[ntemplateargs] = vec[message];
- templateargs[ntemplateargs + 1] = vec[message + 1];
- if (nline == 3)
- templateargs[ntemplateargs + 2] = vec[message + 2];
- ntemplateargs = newnargs;
- }
- newtemplate = template_new(templatesym, ntemplateargs, templateargs);
- t_freebytes(templateargs, sizeof (*templateargs) * ntemplateargs);
- if (!(existtemplate = template_findbyname(templatesym)))
- {
- error("%s: template not found in current patch",
- templatesym->s_name);
- template_free(newtemplate);
- return;
- }
- if (!template_match(existtemplate, newtemplate))
- {
- error("%s: template doesn't match current one",
- templatesym->s_name);
- template_free(newtemplate);
- return;
- }
- template_free(newtemplate);
- }
- while (nextmsg < natoms)
- {
- glist_readscalar(x, natoms, vec, &nextmsg, selectem);
- }
-}
-
-static void glist_doread(t_glist *x, t_symbol *filename, t_symbol *format,
- int clearme)
-{
- t_binbuf *b = binbuf_new();
- t_canvas *canvas = glist_getcanvas(x);
- int wasvis = glist_isvisible(canvas);
- int cr = 0, natoms, nline, message, nextmsg = 0, i, j;
- t_atom *vec;
-
- if (!strcmp(format->s_name, "cr"))
- cr = 1;
- else if (*format->s_name)
- error("qlist_read: unknown flag: %s", format->s_name);
-
- if (binbuf_read_via_path(b, filename->s_name,
- canvas_getdir(canvas)->s_name, cr))
- {
- pd_error(x, "read failed");
- binbuf_free(b);
- return;
- }
- if (wasvis)
- canvas_vis(canvas, 0);
- if (clearme)
- glist_clear(x);
- glist_readfrombinbuf(x, b, filename->s_name, 0);
- if (wasvis)
- canvas_vis(canvas, 1);
- binbuf_free(b);
-}
-
-void glist_read(t_glist *x, t_symbol *filename, t_symbol *format)
-{
- glist_doread(x, filename, format, 1);
-}
-
-void glist_mergefile(t_glist *x, t_symbol *filename, t_symbol *format)
-{
- glist_doread(x, filename, format, 0);
-}
-
- /* read text from a "properties" window, called from a gfxstub set
- up in scalar_properties(). We try to restore the object; if successful
- we delete the scalar and put the new thing in its place on the list. */
-void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b)
-{
- int ntotal, nnew, scindex;
- t_gobj *y, *y2 = 0, *newone, *oldone = 0;
- for (y = x->gl_list, ntotal = 0, scindex = -1; y; y = y->g_next)
- {
- if (y == &sc->sc_gobj)
- scindex = ntotal, oldone = y;
- ntotal++;
- }
-
- if (scindex == -1)
- bug("data_properties: scalar disappeared");
- glist_readfrombinbuf(x, b, "properties dialog", 0);
- newone = 0;
- if (scindex >= 0)
- {
- /* take the new object off the list */
- if (ntotal)
- {
- for (y = x->gl_list, nnew = 1; y2 = y->g_next;
- y = y2, nnew++)
- if (nnew == ntotal)
- {
- newone = y2;
- y->g_next = y2->g_next;
- break;
- }
- }
- else newone = x->gl_list, x->gl_list = newone->g_next;
- }
- if (!newone)
- error("couldn't update properties (perhaps a format problem?)");
- else if (!oldone)
- bug("data_properties: couldn't find old element");
- else
- {
- glist_delete(x, oldone);
- if (scindex > 0)
- {
- for (y = x->gl_list, nnew = 1; y;
- y = y->g_next, nnew++)
- if (nnew == scindex || !y->g_next)
- {
- newone->g_next = y->g_next;
- y->g_next = newone;
- goto didit;
- }
- bug("data_properties: can't reinsert");
- }
- else newone->g_next = x->gl_list, x->gl_list = newone;
- }
-didit:
- ;
-}
-
- /* ----------- routines to write data to a binbuf ----------- */
-
-void canvas_doaddtemplate(t_symbol *templatesym,
- int *p_ntemplates, t_symbol ***p_templatevec)
-{
- int n = *p_ntemplates, i;
- t_symbol **templatevec = *p_templatevec;
- for (i = 0; i < n; i++)
- if (templatevec[i] == templatesym)
- return;
- templatevec = (t_symbol **)t_resizebytes(templatevec,
- n * sizeof(*templatevec), (n+1) * sizeof(*templatevec));
- templatevec[n] = templatesym;
- *p_templatevec = templatevec;
- *p_ntemplates = n+1;
-}
-
-static void glist_writelist(t_gobj *y, t_binbuf *b);
-
-void canvas_writescalar(t_symbol *templatesym, t_word *w, t_binbuf *b,
- int amarrayelement)
-{
- t_dataslot *ds;
- t_template *template = template_findbyname(templatesym);
- t_atom *a = (t_atom *)t_getbytes(0);
- int i, n = template->t_n, natom = 0;
- if (!amarrayelement)
- {
- t_atom templatename;
- SETSYMBOL(&templatename, gensym(templatesym->s_name + 3));
- binbuf_add(b, 1, &templatename);
- }
- if (!template)
- bug("canvas_writescalar");
- /* write the atoms (floats and symbols) */
- for (i = 0; i < n; i++)
- {
- if (template->t_vec[i].ds_type == DT_FLOAT ||
- template->t_vec[i].ds_type == DT_SYMBOL)
- {
- a = (t_atom *)t_resizebytes(a,
- natom * sizeof(*a), (natom + 1) * sizeof (*a));
- if (template->t_vec[i].ds_type == DT_FLOAT)
- SETFLOAT(a + natom, w[i].w_float);
- else SETSYMBOL(a + natom, w[i].w_symbol);
- natom++;
- }
- }
- /* array elements have to have at least something */
- if (natom == 0 && amarrayelement)
- SETSYMBOL(a + natom, &s_bang), natom++;
- binbuf_add(b, natom, a);
- binbuf_addsemi(b);
- t_freebytes(a, natom * sizeof(*a));
- for (i = 0; i < n; i++)
- {
- if (template->t_vec[i].ds_type == DT_ARRAY)
- {
- int j;
- t_array *a = w[i].w_array;
- int elemsize = a->a_elemsize, nitems = a->a_n;
- t_symbol *arraytemplatesym = template->t_vec[i].ds_arraytemplate;
- for (j = 0; j < nitems; j++)
- canvas_writescalar(arraytemplatesym,
- (t_word *)(((char *)a->a_vec) + elemsize * j), b, 1);
- binbuf_addsemi(b);
- }
- else if (template->t_vec[i].ds_type == DT_LIST)
- {
- glist_writelist(w->w_list->gl_list, b);
- binbuf_addsemi(b);
- }
- }
-}
-static void glist_writelist(t_gobj *y, t_binbuf *b)
-{
- for (; y; y = y->g_next)
- {
- if (pd_class(&y->g_pd) == scalar_class)
- {
- canvas_writescalar(((t_scalar *)y)->sc_template,
- ((t_scalar *)y)->sc_vec, b, 0);
- }
- }
-}
-
- /* ------------ routines to write out templates for data ------- */
-
-static void canvas_addtemplatesforlist(t_gobj *y,
- int *p_ntemplates, t_symbol ***p_templatevec);
-
-static void canvas_addtemplatesforscalar(t_symbol *templatesym,
- t_word *w, int *p_ntemplates, t_symbol ***p_templatevec)
-{
- t_dataslot *ds;
- int i;
- t_template *template = template_findbyname(templatesym);
- canvas_doaddtemplate(templatesym, p_ntemplates, p_templatevec);
- if (!template)
- bug("canvas_addtemplatesforscalar");
- else for (ds = template->t_vec, i = template->t_n; i--; ds++, w++)
- {
- if (ds->ds_type == DT_ARRAY)
- {
- int j;
- t_array *a = w->w_array;
- int elemsize = a->a_elemsize, nitems = a->a_n;
- t_symbol *arraytemplatesym = ds->ds_arraytemplate;
- canvas_doaddtemplate(arraytemplatesym, p_ntemplates, p_templatevec);
- for (j = 0; j < nitems; j++)
- canvas_addtemplatesforscalar(arraytemplatesym,
- (t_word *)(((char *)a->a_vec) + elemsize * j),
- p_ntemplates, p_templatevec);
- }
- else if (ds->ds_type == DT_LIST)
- canvas_addtemplatesforlist(w->w_list->gl_list,
- p_ntemplates, p_templatevec);
- }
-}
-
-static void canvas_addtemplatesforlist(t_gobj *y,
- int *p_ntemplates, t_symbol ***p_templatevec)
-{
- for (; y; y = y->g_next)
- {
- if (pd_class(&y->g_pd) == scalar_class)
- {
- canvas_addtemplatesforscalar(((t_scalar *)y)->sc_template,
- ((t_scalar *)y)->sc_vec, p_ntemplates, p_templatevec);
- }
- }
-}
-
- /* write all "scalars" in a glist to a binbuf. */
-t_binbuf *glist_writetobinbuf(t_glist *x, int wholething)
-{
- int i;
- t_symbol **templatevec = getbytes(0);
- int ntemplates = 0;
- t_gobj *y;
- t_binbuf *b = binbuf_new();
-
- for (y = x->gl_list; y; y = y->g_next)
- {
- if ((pd_class(&y->g_pd) == scalar_class) &&
- (wholething || glist_isselected(x, y)))
- {
- canvas_addtemplatesforscalar(((t_scalar *)y)->sc_template,
- ((t_scalar *)y)->sc_vec, &ntemplates, &templatevec);
- }
- }
- binbuf_addv(b, "s;", gensym("data"));
- for (i = 0; i < ntemplates; i++)
- {
- t_template *template = template_findbyname(templatevec[i]);
- int j, m = template->t_n;
- /* drop "pd-" prefix from template symbol to print it: */
- binbuf_addv(b, "ss;", gensym("template"),
- gensym(templatevec[i]->s_name + 3));
- for (j = 0; j < m; j++)
- {
- t_symbol *type;
- switch (template->t_vec[j].ds_type)
- {
- case DT_FLOAT: type = &s_float; break;
- case DT_SYMBOL: type = &s_symbol; break;
- case DT_ARRAY: type = gensym("array"); break;
- case DT_LIST: type = &s_list; break;
- default: type = &s_float; bug("canvas_write");
- }
- if (template->t_vec[j].ds_type == DT_ARRAY)
- binbuf_addv(b, "sss;", type, template->t_vec[j].ds_name,
- gensym(template->t_vec[j].ds_arraytemplate->s_name + 3));
- else binbuf_addv(b, "ss;", type, template->t_vec[j].ds_name);
- }
- binbuf_addsemi(b);
- }
- binbuf_addsemi(b);
- /* now write out the objects themselves */
- for (y = x->gl_list; y; y = y->g_next)
- {
- if ((pd_class(&y->g_pd) == scalar_class) &&
- (wholething || glist_isselected(x, y)))
- {
- canvas_writescalar(((t_scalar *)y)->sc_template,
- ((t_scalar *)y)->sc_vec, b, 0);
- }
- }
- return (b);
-}
-
-static void glist_write(t_glist *x, t_symbol *filename, t_symbol *format)
-{
- int cr = 0, i;
- t_binbuf *b;
- char buf[MAXPDSTRING];
- t_symbol **templatevec = getbytes(0);
- int ntemplates = 0;
- t_gobj *y;
- t_canvas *canvas = glist_getcanvas(x);
- canvas_makefilename(canvas, filename->s_name, buf, MAXPDSTRING);
- if (!strcmp(format->s_name, "cr"))
- cr = 1;
- else if (*format->s_name)
- error("qlist_read: unknown flag: %s", format->s_name);
-
- b = glist_writetobinbuf(x, 1);
- if (b)
- {
- if (binbuf_write(b, buf, "", cr))
- error("%s: write failed", filename->s_name);
- binbuf_free(b);
- }
-}
-
-/* ------ routines to save and restore canvases (patches) recursively. ----*/
-
- /* save to a binbuf, called recursively; cf. canvas_savetofile() which
- saves the document, and is only called on root canvases. */
-static void canvas_saveto(t_canvas *x, t_binbuf *b)
-{
- t_gobj *y;
- t_linetraverser t;
- t_outconnect *oc;
- /* subpatch */
- if (x->gl_owner && !x->gl_env)
- {
- binbuf_addv(b, "ssiiiisi;", gensym("#N"), gensym("canvas"),
- (t_int)(x->gl_screenx1),
- (t_int)(x->gl_screeny1),
- (t_int)(x->gl_screenx2 - x->gl_screenx1),
- (t_int)(x->gl_screeny2 - x->gl_screeny1),
- (*x->gl_name->s_name ? x->gl_name: gensym("(subpatch)")),
- x->gl_mapped);
- }
- /* root or abstraction */
- else binbuf_addv(b, "ssiiiii;", gensym("#N"), gensym("canvas"),
- (t_int)(x->gl_screenx1),
- (t_int)(x->gl_screeny1),
- (t_int)(x->gl_screenx2 - x->gl_screenx1),
- (t_int)(x->gl_screeny2 - x->gl_screeny1),
- x->gl_font);
-
- for (y = x->gl_list; y; y = y->g_next)
- gobj_save(y, b);
-
- linetraverser_start(&t, x);
- while (oc = linetraverser_next(&t))
- {
- int srcno = canvas_getindex(x, &t.tr_ob->ob_g);
- int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g);
- binbuf_addv(b, "ssiiii;", gensym("#X"), gensym("connect"),
- srcno, t.tr_outno, sinkno, t.tr_inno);
- }
- /* unless everything is the default (as in ordinary subpatches)
- print out a "coords" message to set up the coordinate systems */
- if (x->gl_isgraph || x->gl_x1 || x->gl_y1 ||
- x->gl_x2 != 1 || x->gl_y2 != 1 || x->gl_pixwidth || x->gl_pixheight)
- binbuf_addv(b, "ssfffffff;", gensym("#X"), gensym("coords"),
- x->gl_x1, x->gl_y1,
- x->gl_x2, x->gl_y2,
- (float)x->gl_pixwidth, (float)x->gl_pixheight,
- (float)x->gl_isgraph);
-}
-
- /* call this recursively to collect all the template names for
- a canvas or for the selection. */
-static void canvas_collecttemplatesfor(t_canvas *x, int *ntemplatesp,
- t_symbol ***templatevecp, int wholething)
-{
- t_gobj *y;
-
- for (y = x->gl_list; y; y = y->g_next)
- {
- if ((pd_class(&y->g_pd) == scalar_class) &&
- (wholething || glist_isselected(x, y)))
- canvas_addtemplatesforscalar(((t_scalar *)y)->sc_template,
- ((t_scalar *)y)->sc_vec, ntemplatesp, templatevecp);
- else if ((pd_class(&y->g_pd) == canvas_class) &&
- (wholething || glist_isselected(x, y)))
- canvas_collecttemplatesfor((t_canvas *)y,
- ntemplatesp, templatevecp, 1);
- }
-}
-
- /* save the templates needed by a canvas to a binbuf. */
-static void canvas_savetemplatesto(t_canvas *x, t_binbuf *b, int wholething)
-{
- t_symbol **templatevec = getbytes(0);
- int i, ntemplates = 0;
- t_gobj *y;
- canvas_collecttemplatesfor(x, &ntemplates, &templatevec, wholething);
- for (i = 0; i < ntemplates; i++)
- {
- t_template *template = template_findbyname(templatevec[i]);
- int j, m = template->t_n;
- if (!template)
- {
- bug("canvas_savetemplatesto");
- continue;
- }
- /* drop "pd-" prefix from template symbol to print */
- binbuf_addv(b, "sss", &s__N, gensym("struct"),
- gensym(templatevec[i]->s_name + 3));
- for (j = 0; j < m; j++)
- {
- t_symbol *type;
- switch (template->t_vec[j].ds_type)
- {
- case DT_FLOAT: type = &s_float; break;
- case DT_SYMBOL: type = &s_symbol; break;
- case DT_ARRAY: type = gensym("array"); break;
- case DT_LIST: type = &s_list; break;
- default: type = &s_float; bug("canvas_write");
- }
- if (template->t_vec[j].ds_type == DT_ARRAY)
- binbuf_addv(b, "sss", type, template->t_vec[j].ds_name,
- gensym(template->t_vec[j].ds_arraytemplate->s_name + 3));
- else binbuf_addv(b, "ss", type, template->t_vec[j].ds_name);
- }
- binbuf_addsemi(b);
- }
-}
-
-void canvas_reload(t_symbol *name, t_symbol *dir, t_gobj *except);
-
- /* save a "root" canvas to a file; cf. canvas_saveto() which saves the
- body (and which is called recursively.) */
-static void canvas_savetofile(t_canvas *x, t_symbol *filename, t_symbol *dir)
-{
- t_binbuf *b = binbuf_new();
- canvas_savetemplatesto(x, b, 1);
- canvas_saveto(x, b);
- if (binbuf_write(b, filename->s_name, dir->s_name, 0)) sys_ouch();
- else
- {
- /* if not an abstraction, reset title bar and directory */
- if (!x->gl_owner)
- canvas_rename(x, filename, dir);
- post("saved to: %s/%s", dir->s_name, filename->s_name);
- canvas_dirty(x, 0);
- canvas_reload(filename, dir, &x->gl_gobj);
- }
- binbuf_free(b);
-}
-
-static void canvas_menusaveas(t_canvas *x)
-{
- t_canvas *x2 = canvas_getrootfor(x);
- sys_vgui("pdtk_canvas_saveas .x%x \"%s\" \"%s\"\n", x2,
- x2->gl_name->s_name, canvas_getdir(x2)->s_name);
-}
-
-static void canvas_menusave(t_canvas *x)
-{
- t_canvas *x2 = canvas_getrootfor(x);
- char *name = x2->gl_name->s_name;
- if (*name && strncmp(name, "Untitled", 8)
- && (strlen(name) < 4 || strcmp(name + strlen(name)-4, ".pat")))
- canvas_savetofile(x2, x2->gl_name, canvas_getdir(x2));
- else canvas_menusaveas(x2);
-}
-
-
-void g_readwrite_setup(void)
-{
- class_addmethod(canvas_class, (t_method)glist_write,
- gensym("write"), A_SYMBOL, A_DEFSYM, A_NULL);
- class_addmethod(canvas_class, (t_method)glist_read,
- gensym("read"), A_SYMBOL, A_DEFSYM, A_NULL);
- class_addmethod(canvas_class, (t_method)glist_mergefile,
- gensym("mergefile"), A_SYMBOL, A_DEFSYM, A_NULL);
- class_addmethod(canvas_class, (t_method)canvas_savetofile,
- gensym("savetofile"), A_SYMBOL, A_SYMBOL, 0);
- class_addmethod(canvas_class, (t_method)canvas_saveto,
- gensym("saveto"), A_CANT, 0);
-/* ------------------ from the menu ------------------------- */
- class_addmethod(canvas_class, (t_method)canvas_menusave,
- gensym("menusave"), 0);
- class_addmethod(canvas_class, (t_method)canvas_menusaveas,
- gensym("menusaveas"), 0);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_rtext.c b/apps/plugins/pdbox/PDa/src/g_rtext.c
index 8ffc8f415b..05c31a9ea7 100644
--- a/apps/plugins/pdbox/PDa/src/g_rtext.c
+++ b/apps/plugins/pdbox/PDa/src/g_rtext.c
@@ -484,489 +484,4 @@ void rtext_mouse(t_rtext *x, int xval, int yval, int flag)
}
rtext_senditup(x, SEND_UPDATE, &w, &h, &indx);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* changes by Thomas Musil IEM KUG Graz Austria 2001 */
-/* have to insert gui-objects into editor-list */
-/* all changes are labeled with iemlib */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "s_stuff.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-
-#define LMARGIN 1
-#define RMARGIN 1
-#define TMARGIN 2
-#define BMARGIN 2
-
-#define SEND_FIRST 1
-#define SEND_UPDATE 2
-#define SEND_CHECK 0
-
-struct _rtext
-{
- char *x_buf;
- int x_bufsize;
- int x_selstart;
- int x_selend;
- int x_active;
- int x_dragfrom;
- int x_height;
- int x_drawnwidth;
- int x_drawnheight;
- t_text *x_text;
- t_glist *x_glist;
- char x_tag[50];
- struct _rtext *x_next;
-};
-
-t_rtext *rtext_new(t_glist *glist, t_text *who)
-{
- t_rtext *x = (t_rtext *)getbytes(sizeof *x);
- int w = 0, h = 0, indx;
- x->x_height = -1;
- x->x_text = who;
- x->x_glist = glist;
- x->x_next = glist->gl_editor->e_rtext;
- x->x_selstart = x->x_selend = x->x_active =
- x->x_drawnwidth = x->x_drawnheight = 0;
- binbuf_gettext(who->te_binbuf, &x->x_buf, &x->x_bufsize);
- glist->gl_editor->e_rtext = x;
- sprintf(x->x_tag, ".x%x.t%x", (t_int)glist_getcanvas(x->x_glist),
- (t_int)x);
- return (x);
-}
-
-static t_rtext *rtext_entered;
-void rtext_free(t_rtext *x)
-{
- if (x->x_glist->gl_editor->e_textedfor == x)
- x->x_glist->gl_editor->e_textedfor = 0;
- if (x->x_glist->gl_editor->e_rtext == x)
- x->x_glist->gl_editor->e_rtext = x->x_next;
- else
- {
- t_rtext *e2;
- for (e2 = x->x_glist->gl_editor->e_rtext; e2; e2 = e2->x_next)
- if (e2->x_next == x)
- {
- e2->x_next = x->x_next;
- break;
- }
- }
- if (rtext_entered == x) rtext_entered = 0;
- freebytes(x->x_buf, x->x_bufsize);
- freebytes(x, sizeof *x);
-}
-
-char *rtext_gettag(t_rtext *x)
-{
- return (x->x_tag);
-}
-
-void rtext_gettext(t_rtext *x, char **buf, int *bufsize)
-{
- *buf = x->x_buf;
- *bufsize = x->x_bufsize;
-}
-
-
-/* LATER deal with tcl-significant characters */
-
-static int firstone(char *s, int c, int n)
-{
- char *s2 = s + n;
- int i = 0;
- while (s != s2)
- {
- if (*s == c) return (i);
- i++;
- s++;
- }
- return (-1);
-}
-
-static int lastone(char *s, int c, int n)
-{
- char *s2 = s + n;
- while (s2 != s)
- {
- s2--;
- n--;
- if (*s2 == c) return (n);
- }
- return (-1);
-}
-
- /* the following routine computes line breaks and carries out
- some action which could be:
- SEND_FIRST - draw the box for the first time
- SEND_UPDATE - redraw the updated box
- otherwise - don't draw, just calculate.
- Called with *widthp and *heightpas coordinates of
- a test point, the routine reports the index of the character found
- there in *indexp. *widthp and *heightp are set to the width and height
- of the entire text in pixels.
- */
-
- /* LATER get this and sys_vgui to work together properly,
- breaking up messages as needed. As of now, there's
- a limit of 1950 characters, imposed by sys_vgui(). */
-#define UPBUFSIZE 4000
-#define BOXWIDTH 60
-
-/* Older (pre-8.3.4) TCL versions handle text selection differently; this
-flag is set from the GUI if this happens. LATER take this out: early 2006? */
-
-extern int sys_oldtclversion;
-
-static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
- int *indexp)
-{
- float dispx, dispy;
- char tempbuf[UPBUFSIZE], *tp = tempbuf, *bp = x->x_buf;
- int outchars, inchars = x->x_bufsize, nlines = 0, ncolumns = 0,
- pixwide, pixhigh;
- int font = glist_getfont(x->x_glist);
- int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font);
- int findx = (*widthp + (fontwidth/2)) / fontwidth,
- findy = *heightp / fontheight;
- int reportedindex = 0;
- t_canvas *canvas = glist_getcanvas(x->x_glist);
- int widthspec = x->x_text->te_width;
- int widthlimit = (widthspec ? widthspec : BOXWIDTH);
- while (inchars)
- {
- int maxindex = (inchars > widthlimit ? widthlimit : inchars);
- int eatchar = 1;
- int foundit = firstone(bp, '\n', maxindex);
- if (foundit < 0)
- {
- if (inchars > widthlimit)
- {
- foundit = lastone(bp, ' ', maxindex);
- if (foundit < 0)
- {
- foundit = maxindex;
- eatchar = 0;
- }
- }
- else
- {
- foundit = inchars;
- eatchar = 0;
- }
- }
- if (nlines == findy)
- {
- int actualx = (findx < 0 ? 0 :
- (findx > foundit ? foundit : findx));
- *indexp = (bp - x->x_buf) + actualx;
- reportedindex = 1;
- }
- strncpy(tp, bp, foundit);
- tp += foundit;
- bp += (foundit + eatchar);
- inchars -= (foundit + eatchar);
- if (inchars) *tp++ = '\n';
- if (foundit > ncolumns) ncolumns = foundit;
- nlines++;
- }
- outchars = tp - tempbuf;
- if (outchars > 1950) outchars = 1950;
- if (!reportedindex)
- *indexp = outchars;
- dispx = text_xpix(x->x_text, x->x_glist);
- dispy = text_ypix(x->x_text, x->x_glist);
- if (nlines < 1) nlines = 1;
- if (!widthspec)
- {
- while (ncolumns < 3)
- {
- tempbuf[outchars++] = ' ';
- ncolumns++;
- }
- }
- else ncolumns = widthspec;
- pixwide = ncolumns * fontwidth + (LMARGIN + RMARGIN);
- pixhigh = nlines * fontheight + (TMARGIN + BMARGIN);
-
- if (action == SEND_FIRST)
- sys_vgui("pdtk_text_new .x%x.c %s %f %f {%.*s} %d %s\n",
- canvas, x->x_tag,
- dispx + LMARGIN, dispy + TMARGIN,
- outchars, tempbuf, sys_hostfontsize(font),
- (glist_isselected(x->x_glist,
- &x->x_glist->gl_gobj)? "blue" : "black"));
- else if (action == SEND_UPDATE)
- {
- sys_vgui("pdtk_text_set .x%x.c %s {%.*s}\n",
- canvas, x->x_tag, outchars, tempbuf);
- if (pixwide != x->x_drawnwidth || pixhigh != x->x_drawnheight)
- text_drawborder(x->x_text, x->x_glist, x->x_tag,
- pixwide, pixhigh, 0);
- if (x->x_active)
- {
- if (x->x_selend > x->x_selstart)
- {
- sys_vgui(".x%x.c select from %s %d\n", canvas,
- x->x_tag, x->x_selstart);
- sys_vgui(".x%x.c select to %s %d\n", canvas,
- x->x_tag, x->x_selend + (sys_oldtclversion ? 0 : -1));
- sys_vgui(".x%x.c focus \"\"\n", canvas);
- }
- else
- {
- sys_vgui(".x%x.c select clear\n", canvas);
- sys_vgui(".x%x.c icursor %s %d\n", canvas, x->x_tag,
- x->x_selstart);
- sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag);
- }
- }
- }
- x->x_drawnwidth = pixwide;
- x->x_drawnheight = pixhigh;
-
- *widthp = pixwide;
- *heightp = pixhigh;
-}
-
-void rtext_retext(t_rtext *x)
-{
- int w = 0, h = 0, indx;
- t_text *text = x->x_text;
- t_freebytes(x->x_buf, x->x_bufsize);
- binbuf_gettext(text->te_binbuf, &x->x_buf, &x->x_bufsize);
- /* special case: for number boxes, try to pare the number down
- to the specified width of the box. */
- if (text->te_width > 0 && text->te_type == T_ATOM &&
- x->x_bufsize > text->te_width)
- {
- t_atom *atomp = binbuf_getvec(text->te_binbuf);
- int natom = binbuf_getnatom(text->te_binbuf);
- int bufsize = x->x_bufsize;
- if (natom == 1 && atomp->a_type == A_FLOAT)
- {
- /* try to reduce size by dropping decimal digits */
- int wantreduce = bufsize - text->te_width;
- char *decimal = 0, *nextchar, *ebuf = x->x_buf + bufsize,
- *s1, *s2;
- int ndecimals;
- for (decimal = x->x_buf; decimal < ebuf; decimal++)
- if (*decimal == '.')
- break;
- if (decimal >= ebuf)
- goto giveup;
- for (nextchar = decimal + 1; nextchar < ebuf; nextchar++)
- if (*nextchar < '0' || *nextchar > '9')
- break;
- if (nextchar - decimal - 1 < wantreduce)
- goto giveup;
- for (s1 = nextchar - wantreduce, s2 = s1 + wantreduce;
- s2 < ebuf; s1++, s2++)
- *s1 = *s2;
- t_resizebytes(x->x_buf, bufsize, text->te_width);
- bufsize = text->te_width;
- goto done;
- giveup:
- /* give up and bash it to "+" or "-" */
- x->x_buf[0] = (atomp->a_w.w_float < 0 ? '-' : '+');
- t_resizebytes(x->x_buf, bufsize, 1);
- bufsize = 1;
- }
- else if (bufsize > text->te_width)
- {
- x->x_buf[text->te_width - 1] = '>';
- t_resizebytes(x->x_buf, bufsize, text->te_width);
- bufsize = text->te_width;
- }
- done:
- x->x_bufsize = bufsize;
- }
- rtext_senditup(x, SEND_UPDATE, &w, &h, &indx);
-}
-
-/* find the rtext that goes with a text item */
-t_rtext *glist_findrtext(t_glist *gl, t_text *who)
-{
- t_rtext *x = gl->gl_editor->e_rtext;
- while (x && x->x_text != who) x = x->x_next;
- if (!x) bug("glist_findrtext");
- return (x);
-}
-
-int rtext_width(t_rtext *x)
-{
- int w = 0, h = 0, indx;
- rtext_senditup(x, SEND_CHECK, &w, &h, &indx);
- return (w);
-}
-
-int rtext_height(t_rtext *x)
-{
- int w = 0, h = 0, indx;
- rtext_senditup(x, SEND_CHECK, &w, &h, &indx);
- return (h);
-}
-
-void rtext_draw(t_rtext *x)
-{
- int w = 0, h = 0, indx;
- rtext_senditup(x, SEND_FIRST, &w, &h, &indx);
-}
-
-void rtext_erase(t_rtext *x)
-{
- sys_vgui(".x%x.c delete %s\n", glist_getcanvas(x->x_glist), x->x_tag);
-}
-
-void rtext_displace(t_rtext *x, int dx, int dy)
-{
- sys_vgui(".x%x.c move %s %d %d\n", glist_getcanvas(x->x_glist),
- x->x_tag, dx, dy);
-}
-
-void rtext_select(t_rtext *x, int state)
-{
- t_glist *glist = x->x_glist;
- t_canvas *canvas = glist_getcanvas(glist);
- sys_vgui(".x%x.c itemconfigure %s -fill %s\n", canvas,
- x->x_tag, (state? "blue" : "black"));
- canvas_editing = canvas;
-}
-
-void rtext_activate(t_rtext *x, int state)
-{
- int w = 0, h = 0, indx;
- t_glist *glist = x->x_glist;
- t_canvas *canvas = glist_getcanvas(glist);
- if (state)
- {
- sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag);
- glist->gl_editor->e_textedfor = x;
- glist->gl_editor->e_textdirty = 0;
- x->x_dragfrom = x->x_selstart = 0;
- x->x_selend = x->x_bufsize;
- x->x_active = 1;
- }
- else
- {
- sys_vgui("selection clear .x%x.c\n", canvas);
- sys_vgui(".x%x.c focus \"\"\n", canvas);
- if (glist->gl_editor->e_textedfor == x)
- glist->gl_editor->e_textedfor = 0;
- x->x_active = 0;
- }
- rtext_senditup(x, SEND_UPDATE, &w, &h, &indx);
-}
-
-void rtext_key(t_rtext *x, int keynum, t_symbol *keysym)
-{
- int w = 0, h = 0, indx, i, newsize, ndel;
- char *s1, *s2;
- if (keynum)
- {
- int n = keynum;
- if (n == '\r') n = '\n';
- if (n == '\b') /* backspace */
- {
- /* LATER delete the box if all text is selected...
- this causes reentrancy problems now. */
- /* if ((!x->x_selstart) && (x->x_selend == x->x_bufsize))
- {
- ....
- } */
- if (x->x_selstart && (x->x_selstart == x->x_selend))
- x->x_selstart--;
- }
- else if (n == 127) /* delete */
- {
- if (x->x_selend < x->x_bufsize && (x->x_selstart == x->x_selend))
- x->x_selend++;
- }
-
- ndel = x->x_selend - x->x_selstart;
- for (i = x->x_selend; i < x->x_bufsize; i++)
- x->x_buf[i- ndel] = x->x_buf[i];
- newsize = x->x_bufsize - ndel;
- x->x_buf = resizebytes(x->x_buf, x->x_bufsize, newsize);
- x->x_bufsize = newsize;
-
- if (n == '\n' || isprint(n))
- {
- newsize = x->x_bufsize+1;
- x->x_buf = resizebytes(x->x_buf, x->x_bufsize, newsize);
- for (i = x->x_bufsize; i > x->x_selstart; i--)
- x->x_buf[i] = x->x_buf[i-1];
- x->x_buf[x->x_selstart] = n;
- x->x_bufsize = newsize;
- x->x_selstart = x->x_selstart + 1;
- }
- x->x_selend = x->x_selstart;
- x->x_glist->gl_editor->e_textdirty = 1;
- }
- else if (!strcmp(keysym->s_name, "Right"))
- {
- if (x->x_selend == x->x_selstart && x->x_selstart < x->x_bufsize)
- x->x_selend = x->x_selstart = x->x_selstart + 1;
- else
- x->x_selstart = x->x_selend;
- }
- else if (!strcmp(keysym->s_name, "Left"))
- {
- if (x->x_selend == x->x_selstart && x->x_selstart > 0)
- x->x_selend = x->x_selstart = x->x_selstart - 1;
- else
- x->x_selend = x->x_selstart;
- }
- /* this should be improved... life's too short */
- else if (!strcmp(keysym->s_name, "Up"))
- {
- if (x->x_selstart)
- x->x_selstart--;
- while (x->x_selstart > 0 && x->x_buf[x->x_selstart] != '\n')
- x->x_selstart--;
- x->x_selend = x->x_selstart;
- }
- else if (!strcmp(keysym->s_name, "Down"))
- {
- while (x->x_selend < x->x_bufsize &&
- x->x_buf[x->x_selend] != '\n')
- x->x_selend++;
- if (x->x_selend < x->x_bufsize)
- x->x_selend++;
- x->x_selstart = x->x_selend;
- }
- rtext_senditup(x, SEND_UPDATE, &w, &h, &indx);
-}
-
-void rtext_mouse(t_rtext *x, int xval, int yval, int flag)
-{
- int w = xval, h = yval, indx;
- rtext_senditup(x, SEND_CHECK, &w, &h, &indx);
- if (flag == RTEXT_DOWN)
- {
- x->x_dragfrom = x->x_selstart = x->x_selend = indx;
- }
- else if (flag == RTEXT_SHIFT)
- {
- if (indx * 2 > x->x_selstart + x->x_selend)
- x->x_dragfrom = x->x_selstart, x->x_selend = indx;
- else
- x->x_dragfrom = x->x_selend, x->x_selstart = indx;
- }
- else if (flag == RTEXT_DRAG)
- {
- x->x_selstart = (x->x_dragfrom < indx ? x->x_dragfrom : indx);
- x->x_selend = (x->x_dragfrom > indx ? x->x_dragfrom : indx);
- }
- rtext_senditup(x, SEND_UPDATE, &w, &h, &indx);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_scalar.c b/apps/plugins/pdbox/PDa/src/g_scalar.c
index b3c6d824fc..329003e63e 100644
--- a/apps/plugins/pdbox/PDa/src/g_scalar.c
+++ b/apps/plugins/pdbox/PDa/src/g_scalar.c
@@ -399,404 +399,4 @@ void g_scalar_setup(void)
class_setsavefn(scalar_class, scalar_save);
class_setpropertiesfn(scalar_class, scalar_properties);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* This file defines the "scalar" object, which is not a text object, just a
-"gobj". Scalars have templates which describe their structures, which
-can contain numbers, sublists, and arrays.
-
-Also, the "tscalar" object, an ordinary text object that owns a single "scalar"
-and draws it on the parent. This is intended as a way that abstractions can
-control their appearances by adding stuff to draw.
-*/
-
-/* IOhannes :
- * changed the canvas_restore, so that it might accept $args as well (like "pd $0_test")
- * so you can make multiple & distinguishable templates
- * 1511:forum::für::umläute:2001
- * changes marked with IOhannes
- * added Krzysztof Czajas fix to avoid crashing...
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h> /* for read/write to files */
-#include "m_pd.h"
-#include "g_canvas.h"
-
-t_class *scalar_class;
-
-void word_init(t_word *wp, t_template *template, t_gpointer *gp)
-{
- int i, nitems = template->t_n;
- t_dataslot *datatypes = template->t_vec;
- for (i = 0; i < nitems; i++, datatypes++, wp++)
- {
- int type = datatypes->ds_type;
- if (type == DT_FLOAT)
- wp->w_float = 0;
- else if (type == DT_SYMBOL)
- wp->w_symbol = &s_symbol;
- else if (type == DT_ARRAY)
- {
- wp->w_array = array_new(datatypes->ds_arraytemplate, gp);
- }
- else if (type == DT_LIST)
- {
- /* LATER test this and get it to work */
- wp->w_list = canvas_new(0, 0, 0, 0);
- }
- }
-}
-
-void word_restore(t_word *wp, t_template *template,
- int argc, t_atom *argv)
-{
- int i, nitems = template->t_n;
- t_dataslot *datatypes = template->t_vec;
- for (i = 0; i < nitems; i++, datatypes++, wp++)
- {
- int type = datatypes->ds_type;
- if (type == DT_FLOAT)
- {
- float f;
- if (argc)
- {
- f = atom_getfloat(argv);
- argv++, argc--;
- }
- else f = 0;
- wp->w_float = f;
- }
- else if (type == DT_SYMBOL)
- {
- t_symbol *s;
- if (argc)
- {
- s = atom_getsymbol(argv);
- argv++, argc--;
- }
- else s = &s_;
- wp->w_symbol = s;
- }
- }
- if (argc)
- post("warning: word_restore: extra arguments");
-}
-
-void word_free(t_word *wp, t_template *template)
-{
- int i;
- t_dataslot *dt;
- for (dt = template->t_vec, i = 0; i < template->t_n; i++, dt++)
- {
- if (dt->ds_type == DT_ARRAY)
- array_free(wp[i].w_array);
- else if (dt->ds_type == DT_LIST)
- canvas_free(wp[i].w_list);
- }
-}
-
- /* make a new scalar and add to the glist. We create a "gp" here which
- will be used for array items to point back here. This gp doesn't do
- reference counting or "validation" updates though; the parent won't go away
- without the contained arrays going away too. The "gp" is copied out
- by value in the word_init() routine so we can throw our copy away. */
-
-t_scalar *scalar_new(t_glist *owner, t_symbol *templatesym)
-{
- t_scalar *x;
- t_template *template;
- t_gpointer gp;
- gpointer_init(&gp);
- template = template_findbyname(templatesym);
- if (!template)
- {
- error("scalar: couldn't find template %s", templatesym->s_name);
- return (0);
- }
- x = (t_scalar *)getbytes(sizeof(t_scalar) +
- (template->t_n - 1) * sizeof(*x->sc_vec));
- x->sc_gobj.g_pd = scalar_class;
- x->sc_template = templatesym;
- gpointer_setglist(&gp, owner, x);
- word_init(x->sc_vec, template, &gp);
- return (x);
-}
-
- /* Pd method to create a new scalar, add it to a glist, and initialize
- it from the message arguments. */
-
-int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
- int *p_nextmsg, int selectit);
-
-void glist_scalar(t_glist *glist,
- t_symbol *classname, t_int argc, t_atom *argv)
-{
- t_symbol *templatesym =
- canvas_makebindsym(atom_getsymbolarg(0, argc, argv));
- t_binbuf *b;
- int natoms, nextmsg = 0;
- t_atom *vec;
- if (!template_findbyname(templatesym))
- {
- pd_error(glist, "%s: no such template",
- atom_getsymbolarg(0, argc, argv)->s_name);
- return;
- }
-
- b = binbuf_new();
- binbuf_restore(b, argc, argv);
- natoms = binbuf_getnatom(b);
- vec = binbuf_getvec(b);
-
- glist_readscalar(glist, natoms, vec, &nextmsg, 0);
- binbuf_free(b);
-}
-
-/* -------------------- widget behavior for scalar ------------ */
-void scalar_getbasexy(t_scalar *x, float *basex, float *basey)
-{
- t_template *template = template_findbyname(x->sc_template);
- *basex = template_getfloat(template, gensym("x"), x->sc_vec, 0);
- *basey = template_getfloat(template, gensym("y"), x->sc_vec, 0);
-}
-
-static void scalar_getrect(t_gobj *z, t_glist *owner,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_scalar *x = (t_scalar *)z;
- int hit = 0;
- t_template *template = template_findbyname(x->sc_template);
- t_canvas *templatecanvas = template_findcanvas(template);
- int x1 = 0x7fffffff, x2 = -0x7fffffff, y1 = 0x7fffffff, y2 = -0x7fffffff;
- t_gobj *y;
- float basex, basey;
- scalar_getbasexy(x, &basex, &basey);
- /* if someone deleted the template canvas, we're just a point */
- if (!templatecanvas)
- {
- x1 = x2 = glist_xtopixels(owner, basex);
- y1 = y2 = glist_ytopixels(owner, basey);
- }
- else
- {
- int hit = 0;
- x1 = y1 = 0x7fffffff;
- x2 = y2 = -0x7fffffff;
- for (y = templatecanvas->gl_list; y; y = y->g_next)
- {
- t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
- int nx1, ny1, nx2, ny2;
- if (!wb) continue;
- (*wb->w_parentgetrectfn)(y, owner,
- x->sc_vec, template, basex, basey,
- &nx1, &ny1, &nx2, &ny2);
- if (hit)
- {
- if (nx1 < x1) x1 = nx1;
- if (ny1 < y1) y1 = ny1;
- if (nx2 > x2) x2 = nx2;
- if (ny2 > y2) y2 = ny2;
- }
- else x1 = nx1, y1 = ny1, x2 = nx2, y2 = ny2, hit = 1;
- }
- if (!hit) x1 = y1 = x2 = y2 = 0;
- }
- /* post("scalar x1 %d y1 %d x2 %d y2 %d", x1, y1, x2, y2); */
- *xp1 = x1;
- *yp1 = y1;
- *xp2 = x2;
- *yp2 = y2;
-}
-
-static void scalar_select(t_gobj *z, t_glist *owner, int state)
-{
- t_scalar *x = (t_scalar *)z;
- /* post("scalar_select %d", state); */
- /* later */
- if (state)
- {
- int x1, y1, x2, y2;
- scalar_getrect(z, owner, &x1, &y1, &x2, &y2);
- x1--; x2++; y1--; y2++;
- sys_vgui(".x%x.c create line %d %d %d %d %d %d %d %d %d %d \
- -width 0 -fill blue -tags select%x\n",
- glist_getcanvas(owner), x1, y1, x1, y2, x2, y2, x2, y1, x1, y1,
- x);
- }
- else sys_vgui(".x%x.c delete select%x\n", glist_getcanvas(owner), x);
-}
-
-static void scalar_displace(t_gobj *z, t_glist *glist, int dx, int dy)
-{
- t_scalar *x = (t_scalar *)z;
- t_symbol *templatesym = x->sc_template;
- t_template *template = template_findbyname(templatesym);
- t_symbol *zz;
- int xonset, yonset, xtype, ytype, gotx, goty;
- if (!template)
- {
- error("scalar: couldn't find template %s", templatesym->s_name);
- return;
- }
- gotx = template_find_field(template, gensym("x"), &xonset, &xtype, &zz);
- if (gotx && (xtype != DT_FLOAT))
- gotx = 0;
- goty = template_find_field(template, gensym("y"), &yonset, &ytype, &zz);
- if (goty && (ytype != DT_FLOAT))
- goty = 0;
- if (gotx)
- *(t_float *)(((char *)(x->sc_vec)) + xonset) +=
- dx * (glist_pixelstox(glist, 1) - glist_pixelstox(glist, 0));
- if (goty)
- *(t_float *)(((char *)(x->sc_vec)) + yonset) +=
- dy * (glist_pixelstoy(glist, 1) - glist_pixelstoy(glist, 0));
- glist_redrawitem(glist, z);
- if (glist_isselected(glist, z))
- {
- scalar_select(z, glist, 0);
- scalar_select(z, glist, 1);
- }
-}
-
-static void scalar_activate(t_gobj *z, t_glist *owner, int state)
-{
- /* post("scalar_activate %d", state); */
- /* later */
-}
-
-static void scalar_delete(t_gobj *z, t_glist *glist)
-{
- /* nothing to do */
-}
-
-static void scalar_vis(t_gobj *z, t_glist *owner, int vis)
-{
- t_scalar *x = (t_scalar *)z;
- t_template *template = template_findbyname(x->sc_template);
- t_canvas *templatecanvas = template_findcanvas(template);
- t_gobj *y;
- float basex, basey;
- scalar_getbasexy(x, &basex, &basey);
- /* if we don't know how to draw it, make a small rectangle */
- if (!templatecanvas)
- {
- if (vis)
- {
- int x1 = glist_xtopixels(owner, basex);
- int y1 = glist_ytopixels(owner, basey);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags scalar%x\n",
- glist_getcanvas(owner), x1-1, y1-1, x1+1, y1+1, x);
- }
- else sys_vgui(".x%x.c delete scalar%x\n", glist_getcanvas(owner), x);
- return;
- }
-
- for (y = templatecanvas->gl_list; y; y = y->g_next)
- {
- t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
- if (!wb) continue;
- (*wb->w_parentvisfn)(y, owner, x->sc_vec, template, basex, basey, vis);
- }
-}
-
-static int scalar_click(t_gobj *z, struct _glist *owner,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_scalar *x = (t_scalar *)z;
- int hit = 0;
- t_template *template = template_findbyname(x->sc_template);
- t_canvas *templatecanvas = template_findcanvas(template);
- t_gobj *y;
- float basex, basey;
- scalar_getbasexy(x, &basex, &basey);
- for (y = templatecanvas->gl_list; y; y = y->g_next)
- {
- t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
- if (!wb) continue;
- if (hit = (*wb->w_parentclickfn)(y, owner,
- x, template, basex, basey,
- xpix, ypix, shift, alt, dbl, doit))
- return (hit);
- }
- return (0);
-}
-
-void canvas_writescalar(t_symbol *templatesym, t_word *w, t_binbuf *b,
- int amarrayelement);
-
-static void scalar_save(t_gobj *z, t_binbuf *b)
-{
- t_scalar *x = (t_scalar *)z;
- t_binbuf *b2 = binbuf_new();
- t_atom a, *argv;
- int i, argc;
- canvas_writescalar(x->sc_template, x->sc_vec, b2, 0);
- binbuf_addv(b, "ss", &s__X, gensym("scalar"));
- binbuf_addbinbuf(b, b2);
- binbuf_addsemi(b);
- binbuf_free(b2);
-}
-
-static void scalar_properties(t_gobj *z, struct _glist *owner)
-{
- t_scalar *x = (t_scalar *)z;
- char *buf, buf2[80];
- int bufsize;
- t_binbuf *b;
- glist_noselect(owner);
- glist_select(owner, z);
- b = glist_writetobinbuf(owner, 0);
- binbuf_gettext(b, &buf, &bufsize);
- binbuf_free(b);
- buf = t_resizebytes(buf, bufsize, bufsize+1);
- buf[bufsize] = 0;
- sprintf(buf2, "pdtk_data_dialog %%s {");
- gfxstub_new((t_pd *)owner, x, buf2);
- sys_gui(buf);
- sys_gui("}\n");
- t_freebytes(buf, bufsize+1);
-}
-
-static t_widgetbehavior scalar_widgetbehavior =
-{
- scalar_getrect,
- scalar_displace,
- scalar_select,
- scalar_activate,
- scalar_delete,
- scalar_vis,
- scalar_click,
-};
-
-static void scalar_free(t_scalar *x)
-{
- int i;
- t_dataslot *datatypes, *dt;
- t_symbol *templatesym = x->sc_template;
- t_template *template = template_findbyname(templatesym);
- if (!template)
- {
- error("scalar: couldn't find template %s", templatesym->s_name);
- return;
- }
- word_free(x->sc_vec, template);
- gfxstub_deleteforkey(x);
- /* the "size" field in the class is zero, so Pd doesn't try to free
- us automatically (see pd_free()) */
- freebytes(x, sizeof(t_scalar) + (template->t_n - 1) * sizeof(*x->sc_vec));
-}
-
-/* ----------------- setup function ------------------- */
-void g_scalar_setup(void)
-{
- scalar_class = class_new(gensym("scalar"), 0, (t_method)scalar_free, 0,
- CLASS_GOBJ, 0);
- class_setwidget(scalar_class, &scalar_widgetbehavior);
- class_setsavefn(scalar_class, scalar_save);
- class_setpropertiesfn(scalar_class, scalar_properties);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_template.c b/apps/plugins/pdbox/PDa/src/g_template.c
index c65613a0d6..9e62c0f1d2 100644
--- a/apps/plugins/pdbox/PDa/src/g_template.c
+++ b/apps/plugins/pdbox/PDa/src/g_template.c
@@ -1677,1682 +1677,4 @@ void g_template_setup(void)
drawnumber_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "m_pd.h"
-#include "s_stuff.h" /* for sys_hostfontsize */
-#include "g_canvas.h"
-
-/*
-This file contains text objects you would put in a canvas to define a
-template. Templates describe objects of type "array" (g_array.c) and
-"scalar" (g_scalar.c).
-*/
-
-/* T.Grill - changed the _template.t_pd member to t_pdobj to avoid name clashes
-with the t_pd type */
-
- /* the structure of a "struct" object (also the obsolete "gtemplate"
- you get when using the name "template" in a box.) */
-
-struct _gtemplate
-{
- t_object x_obj;
- t_template *x_template;
- t_canvas *x_owner;
- t_symbol *x_sym;
- struct _gtemplate *x_next;
- int x_argc;
- t_atom *x_argv;
-};
-
-/* ---------------- forward definitions ---------------- */
-
-static void template_conformarray(t_template *tfrom, t_template *tto,
- int *conformaction, t_array *a);
-static void template_conformglist(t_template *tfrom, t_template *tto,
- t_glist *glist, int *conformaction);
-
-/* ---------------------- storage ------------------------- */
-
-static t_class *gtemplate_class;
-static t_class *template_class;
-
-/* there's a pre-defined "float" template. LATER should we bind this
-to a symbol such as "pd-float"??? */
-
-static t_dataslot template_float_vec =
-{
- DT_FLOAT,
- &s_y,
- &s_
-};
-
-static t_template template_float =
-{
- 0, /* class -- fill in in setup routine */
- 0, /* list of "struct"/t_gtemplate objects */
- &s_float, /* name */
- 1, /* number of items */
- &template_float_vec
-};
-
- /* return true if two dataslot definitions match */
-static int dataslot_matches(t_dataslot *ds1, t_dataslot *ds2,
- int nametoo)
-{
- return ((!nametoo || ds1->ds_name == ds2->ds_name) &&
- ds1->ds_type == ds2->ds_type &&
- (ds1->ds_type != DT_ARRAY ||
- ds1->ds_arraytemplate == ds2->ds_arraytemplate));
-}
-
-/* -- templates, the active ingredient in gtemplates defined below. ------- */
-
-t_template *template_new(t_symbol *templatesym, int argc, t_atom *argv)
-{
- t_template *x = (t_template *)pd_new(template_class);
- x->t_n = 0;
- x->t_vec = (t_dataslot *)t_getbytes(0);
- while (argc > 0)
- {
- int newtype, oldn, newn;
- t_symbol *newname, *newarraytemplate = &s_, *newtypesym;
- if (argc < 2 || argv[0].a_type != A_SYMBOL ||
- argv[1].a_type != A_SYMBOL)
- goto bad;
- newtypesym = argv[0].a_w.w_symbol;
- newname = argv[1].a_w.w_symbol;
- if (newtypesym == &s_float)
- newtype = DT_FLOAT;
- else if (newtypesym == &s_symbol)
- newtype = DT_SYMBOL;
- else if (newtypesym == &s_list)
- newtype = DT_LIST;
- else if (newtypesym == gensym("array"))
- {
- if (argc < 3 || argv[2].a_type != A_SYMBOL)
- {
- pd_error(x, "array lacks element template or name");
- goto bad;
- }
- newarraytemplate = canvas_makebindsym(argv[2].a_w.w_symbol);
- newtype = DT_ARRAY;
- argc--;
- argv++;
- }
- else
- {
- pd_error(x, "%s: no such type", newtypesym->s_name);
- return (0);
- }
- newn = (oldn = x->t_n) + 1;
- x->t_vec = (t_dataslot *)t_resizebytes(x->t_vec,
- oldn * sizeof(*x->t_vec), newn * sizeof(*x->t_vec));
- x->t_n = newn;
- x->t_vec[oldn].ds_type = newtype;
- x->t_vec[oldn].ds_name = newname;
- x->t_vec[oldn].ds_arraytemplate = newarraytemplate;
- bad:
- argc -= 2; argv += 2;
- }
- if (templatesym->s_name)
- {
- x->t_sym = templatesym;
- pd_bind(&x->t_pdobj, x->t_sym);
- }
- else x->t_sym = templatesym;
- return (x);
-}
-
-int template_size(t_template *x)
-{
- return (x->t_n * sizeof(t_word));
-}
-
-int template_find_field(t_template *x, t_symbol *name, int *p_onset,
- int *p_type, t_symbol **p_arraytype)
-{
- t_template *t;
- int i, n;
- if (!x)
- {
- bug("template_find_field");
- return (0);
- }
- n = x->t_n;
- for (i = 0; i < n; i++)
- if (x->t_vec[i].ds_name == name)
- {
- *p_onset = i * sizeof(t_word);
- *p_type = x->t_vec[i].ds_type;
- *p_arraytype = x->t_vec[i].ds_arraytemplate;
- return (1);
- }
- return (0);
-}
-
-t_float template_getfloat(t_template *x, t_symbol *fieldname, t_word *wp,
- int loud)
-{
- int onset, type;
- t_symbol *arraytype;
- t_sample val = 0;
- if (template_find_field(x, fieldname, &onset, &type, &arraytype))
- {
- if (type == DT_FLOAT)
- val = *(t_sample *)(((char *)wp) + onset);
- else if (loud) error("%s.%s: not a number",
- x->t_sym->s_name, fieldname->s_name);
- }
- else if (loud) error("%s.%s: no such field",
- x->t_sym->s_name, fieldname->s_name);
- return (fixtof(val));
-}
-
-void template_setfloat(t_template *x, t_symbol *fieldname, t_word *wp,
- t_float f, int loud)
-{
- int onset, type;
- t_symbol *arraytype;
- if (template_find_field(x, fieldname, &onset, &type, &arraytype))
- {
- if (type == DT_FLOAT)
- *(t_sample *)(((char *)wp) + onset) = ftofix(f);
- else if (loud) error("%s.%s: not a number",
- x->t_sym->s_name, fieldname->s_name);
- }
- else if (loud) error("%s.%s: no such field",
- x->t_sym->s_name, fieldname->s_name);
-}
-
-t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname, t_word *wp,
- int loud)
-{
- int onset, type;
- t_symbol *arraytype;
- t_symbol *val = &s_;
- if (template_find_field(x, fieldname, &onset, &type, &arraytype))
- {
- if (type == DT_SYMBOL)
- val = *(t_symbol **)(((char *)wp) + onset);
- else if (loud) error("%s.%s: not a symbol",
- x->t_sym->s_name, fieldname->s_name);
- }
- else if (loud) error("%s.%s: no such field",
- x->t_sym->s_name, fieldname->s_name);
- return (val);
-}
-
-void template_setsymbol(t_template *x, t_symbol *fieldname, t_word *wp,
- t_symbol *s, int loud)
-{
- int onset, type;
- t_symbol *arraytype;
- if (template_find_field(x, fieldname, &onset, &type, &arraytype))
- {
- if (type == DT_SYMBOL)
- *(t_symbol **)(((char *)wp) + onset) = s;
- else if (loud) error("%s.%s: not a symbol",
- x->t_sym->s_name, fieldname->s_name);
- }
- else if (loud) error("%s.%s: no such field",
- x->t_sym->s_name, fieldname->s_name);
-}
-
- /* stringent check to see if a "saved" template, x2, matches the current
- one (x1). It's OK if x1 has additional scalar elements but not (yet)
- arrays or lists. This is used for reading in "data files". */
-int template_match(t_template *x1, t_template *x2)
-{
- int i;
- if (x1->t_n < x2->t_n)
- return (0);
- for (i = x2->t_n; i < x1->t_n; i++)
- {
- if (x1->t_vec[i].ds_type == DT_ARRAY ||
- x1->t_vec[i].ds_type == DT_LIST)
- return (0);
- }
- if (x2->t_n > x1->t_n)
- post("add elements...");
- for (i = 0; i < x2->t_n; i++)
- if (!dataslot_matches(&x1->t_vec[i], &x2->t_vec[i], 1))
- return (0);
- return (1);
-}
-
-/* --------------- CONFORMING TO CHANGES IN A TEMPLATE ------------ */
-
-/* the following routines handle updating scalars to agree with changes
-in their template. The old template is assumed to be the "installed" one
-so we can delete old items; but making new ones we have to avoid scalar_new
-which would make an old one whereas we will want a new one (but whose array
-elements might still be old ones.
- LATER deal with graphics updates too... */
-
- /* conform the word vector of a scalar to the new template */
-static void template_conformwords(t_template *tfrom, t_template *tto,
- int *conformaction, t_word *wfrom, t_word *wto)
-{
- int nfrom = tfrom->t_n, nto = tto->t_n, i;
- for (i = 0; i < nto; i++)
- {
- if (conformaction[i] >= 0)
- {
- /* we swap the two, in case it's an array or list, so that
- when "wfrom" is deleted the old one gets cleaned up. */
- t_word wwas = wto[i];
- wto[i] = wfrom[conformaction[i]];
- wfrom[conformaction[i]] = wwas;
- }
- }
-}
-
- /* conform a scalar, recursively conforming sublists and arrays */
-static t_scalar *template_conformscalar(t_template *tfrom, t_template *tto,
- int *conformaction, t_glist *glist, t_scalar *scfrom)
-{
- t_scalar *x;
- t_gpointer gp;
- int nto = tto->t_n, nfrom = tfrom->t_n, i;
- t_template *scalartemplate;
- /* post("conform scalar"); */
- /* possibly replace the scalar */
- if (scfrom->sc_template == tfrom->t_sym)
- {
- /* see scalar_new() for comment about the gpointer. */
- gpointer_init(&gp);
- x = (t_scalar *)getbytes(sizeof(t_scalar) +
- (tto->t_n - 1) * sizeof(*x->sc_vec));
- x->sc_gobj.g_pd = scalar_class;
- x->sc_template = tfrom->t_sym;
- gpointer_setglist(&gp, glist, x);
- /* Here we initialize to the new template, but array and list
- elements will still belong to old template. */
- word_init(x->sc_vec, tto, &gp);
-
- template_conformwords(tfrom, tto, conformaction,
- scfrom->sc_vec, x->sc_vec);
-
- /* replace the old one with the new one in the list */
- if (glist->gl_list == &scfrom->sc_gobj)
- {
- glist->gl_list = &x->sc_gobj;
- x->sc_gobj.g_next = scfrom->sc_gobj.g_next;
- }
- else
- {
- t_gobj *y, *y2;
- for (y = glist->gl_list; y2 = y->g_next; y = y2)
- if (y2 == &scfrom->sc_gobj)
- {
- x->sc_gobj.g_next = y2->g_next;
- y->g_next = &x->sc_gobj;
- goto nobug;
- }
- bug("template_conformscalar");
- nobug: ;
- }
- /* burn the old one */
- pd_free(&scfrom->sc_gobj.g_pd);
- }
- else x = scfrom;
- scalartemplate = template_findbyname(x->sc_template);
- /* convert all array elements and sublists */
- for (i = 0; i < scalartemplate->t_n; i++)
- {
- t_dataslot *ds = scalartemplate->t_vec + i;
- if (ds->ds_type == DT_LIST)
- {
- t_glist *gl2 = x->sc_vec[i].w_list;
- template_conformglist(tfrom, tto, gl2, conformaction);
- }
- else if (ds->ds_type == DT_ARRAY)
- {
- template_conformarray(tfrom, tto, conformaction,
- x->sc_vec[i].w_array);
- }
- }
- return (x);
-}
-
- /* conform an array, recursively conforming sublists and arrays */
-static void template_conformarray(t_template *tfrom, t_template *tto,
- int *conformaction, t_array *a)
-{
- int i;
- if (a->a_templatesym == tfrom->t_sym)
- {
- /* the array elements must all be conformed */
- int oldelemsize = sizeof(t_word) * tfrom->t_n,
- newelemsize = sizeof(t_word) * tto->t_n;
- char *newarray = getbytes(sizeof(t_word) * tto->t_n * a->a_n);
- char *oldarray = a->a_vec;
- if (a->a_elemsize != oldelemsize)
- bug("template_conformarray");
- for (i = 0; i < a->a_n; i++)
- {
- t_word *wp = (t_word *)(newarray + newelemsize * i);
- word_init(wp, tto, &a->a_gp);
- template_conformwords(tfrom, tto, conformaction,
- (t_word *)(oldarray + oldelemsize * i), wp);
- }
- }
- bug("template_conformarray: this part not written");
- /* go through item by item conforming subarrays and sublists... */
-}
-
- /* this routine searches for every scalar in the glist that belongs
- to the "from" template and makes it belong to the "to" template. Descend
- glists recursively.
- We don't handle redrawing here; this is to be filled in LATER... */
-
-static void template_conformglist(t_template *tfrom, t_template *tto,
- t_glist *glist, int *conformaction)
-{
- t_gobj *g;
- /* post("conform glist %s", glist->gl_name->s_name); */
- for (g = glist->gl_list; g; g = g->g_next)
- {
- if (pd_class(&g->g_pd) == scalar_class)
- g = &template_conformscalar(tfrom, tto, conformaction,
- glist, (t_scalar *)g)->sc_gobj;
- else if (pd_class(&g->g_pd) == canvas_class)
- template_conformglist(tfrom, tto, (t_glist *)g, conformaction);
- }
-}
-
- /* globally conform all scalars from one template to another */
-void template_conform(t_template *tfrom, t_template *tto)
-{
- int nto = tto->t_n, nfrom = tfrom->t_n, i, j,
- *conformaction = (int *)getbytes(sizeof(int) * nto),
- *conformedfrom = (int *)getbytes(sizeof(int) * nfrom), doit = 0;
- for (i = 0; i < nto; i++)
- conformaction[i] = -1;
- for (i = 0; i < nfrom; i++)
- conformedfrom[i] = 0;
- for (i = 0; i < nto; i++)
- {
- t_dataslot *dataslot = &tto->t_vec[i];
- for (j = 0; j < nfrom; j++)
- {
- t_dataslot *dataslot2 = &tfrom->t_vec[j];
- if (dataslot_matches(dataslot, dataslot2, 1))
- {
- conformaction[i] = j;
- conformedfrom[j] = 1;
- }
- }
- }
- for (i = 0; i < nto; i++)
- if (conformaction[i] < 0)
- {
- t_dataslot *dataslot = &tto->t_vec[i];
- for (j = 0; j < nfrom; j++)
- if (!conformedfrom[j] &&
- dataslot_matches(dataslot, &tfrom->t_vec[j], 1))
- {
- conformaction[i] = j;
- conformedfrom[j] = 1;
- }
- }
- if (nto != nfrom)
- doit = 1;
- else for (i = 0; i < nto; i++)
- if (conformaction[i] != i)
- doit = 1;
-
- if (doit)
- {
- t_glist *gl;
- /* post("conforming template '%s' to new structure",
- tfrom->t_sym->s_name);
- for (i = 0; i < nto; i++)
- post("... %d", conformaction[i]); */
- for (gl = canvas_list; gl; gl = gl->gl_next)
- template_conformglist(tfrom, tto, gl, conformaction);
- }
- freebytes(conformaction, sizeof(int) * nto);
- freebytes(conformedfrom, sizeof(int) * nfrom);
-}
-
-t_template *template_findbyname(t_symbol *s)
-{
- int i;
- if (s == &s_float)
- return (&template_float);
- else return ((t_template *)pd_findbyclass(s, template_class));
-}
-
-t_canvas *template_findcanvas(t_template *template)
-{
- t_gtemplate *gt;
- if (!template)
- bug("template_findcanvas");
- if (!(gt = template->t_list))
- return (0);
- return (gt->x_owner);
- /* return ((t_canvas *)pd_findbyclass(template->t_sym, canvas_class)); */
-}
-
- /* call this when reading a patch from a file to declare what templates
- we'll need. If there's already a template, check if it matches.
- If it doesn't it's still OK as long as there are no "struct" (gtemplate)
- objects hanging from it; we just conform everyone to the new template.
- If there are still struct objects belonging to the other template, we're
- in trouble. LATER we'll figure out how to conform the new patch's objects
- to the pre-existing struct. */
-static void *template_usetemplate(void *dummy, t_symbol *s,
- int argc, t_atom *argv)
-{
- t_template *x;
- t_symbol *templatesym =
- canvas_makebindsym(atom_getsymbolarg(0, argc, argv));
- if (!argc)
- return (0);
- argc--; argv++;
- /* check if there's already a template by this name. */
- if ((x = (t_template *)pd_findbyclass(templatesym, template_class)))
- {
- t_template *y = template_new(&s_, argc, argv);
- /* If the new template is the same as the old one,
- there's nothing to do. */
- if (!template_match(x, y))
- {
- /* Are there "struct" objects upholding this template? */
- if (x->t_list)
- {
- /* don't know what to do here! */
- error("%s: template mismatch",
- templatesym->s_name);
- }
- else
- {
- /* conform everyone to the new template */
- template_conform(x, y);
- pd_free(&x->t_pdobj);
- template_new(templatesym, argc, argv);
- }
- }
- pd_free(&y->t_pdobj);
- }
- /* otherwise, just make one. */
- else template_new(templatesym, argc, argv);
- return (0);
-}
-
- /* here we assume someone has already cleaned up all instances of this. */
-void template_free(t_template *x)
-{
- if (*x->t_sym->s_name)
- pd_unbind(&x->t_pdobj, x->t_sym);
- t_freebytes(x->t_vec, x->t_n * sizeof(*x->t_vec));
-}
-
-static void template_setup(void)
-{
- template_class = class_new(gensym("template"), 0, (t_method)template_free,
- sizeof(t_template), CLASS_PD, 0);
- class_addmethod(pd_canvasmaker, (t_method)template_usetemplate,
- gensym("struct"), A_GIMME, 0);
-
-}
-
-/* ---------------- gtemplates. One per canvas. ----------- */
-
-/* this is a "text" object that searches for, and if necessary creates,
-a "template" (above). Other objects in the canvas then can give drawing
-instructions for the template. The template doesn't go away when the
-gtemplate is deleted, so that you can replace it with
-another one to add new fields, for example. */
-
-static void *gtemplate_donew(t_symbol *sym, int argc, t_atom *argv)
-{
- t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class);
- t_template *t = template_findbyname(sym);
- int i;
- t_symbol *sx = gensym("x");
- x->x_owner = canvas_getcurrent();
- x->x_next = 0;
- x->x_sym = sym;
- x->x_argc = argc;
- x->x_argv = (t_atom *)getbytes(argc * sizeof(t_atom));
- for (i = 0; i < argc; i++)
- x->x_argv[i] = argv[i];
-
- /* already have a template by this name? */
- if (t)
- {
- x->x_template = t;
- /* if it's already got a "struct" or "gtemplate" object we
- just tack this one to the end of the list and leave it
- there. */
- if (t->t_list)
- {
- t_gtemplate *x2, *x3;
- for (x2 = x->x_template->t_list; x3 = x2->x_next; x2 = x3)
- ;
- x2->x_next = x;
- post("template %s: warning: already exists.", sym->s_name);
- }
- else
- {
- /* if there's none, we just replace the template with
- our own and conform it. */
- t_template *y = template_new(&s_, argc, argv);
- /* Unless the new template is different from the old one,
- there's nothing to do. */
- if (!template_match(t, y))
- {
- /* conform everyone to the new template */
- template_conform(t, y);
- pd_free(&t->t_pdobj);
- t = template_new(sym, argc, argv);
- }
- pd_free(&y->t_pdobj);
- t->t_list = x;
- }
- }
- else
- {
- /* otherwise make a new one and we're the only struct on it. */
- x->x_template = t = template_new(sym, argc, argv);
- t->t_list = x;
- }
- return (x);
-}
-
-static void *gtemplate_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class);
- t_symbol *sym = atom_getsymbolarg(0, argc, argv);
- if (argc >= 1)
- argc--; argv++;
- return (gtemplate_donew(canvas_makebindsym(sym), argc, argv));
-}
-
- /* old version (0.34) -- delete 2003 or so */
-static void *gtemplate_new_old(t_symbol *s, int argc, t_atom *argv)
-{
- t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class);
- t_symbol *sym = canvas_makebindsym(canvas_getcurrent()->gl_name);
- static int warned;
- if (!warned)
- {
- post("warning -- 'template' (%s) is obsolete; replace with 'struct'",
- sym->s_name);
- warned = 1;
- }
- return (gtemplate_donew(sym, argc, argv));
-}
-
-t_template *gtemplate_get(t_gtemplate *x)
-{
- return (x->x_template);
-}
-
-static void gtemplate_free(t_gtemplate *x)
-{
- /* get off the template's list */
- t_template *t = x->x_template;
- if (x == t->t_list)
- {
- if (x->x_next)
- {
- /* if we were first on the list, and there are others on
- the list, make a new template corresponding to the new
- first-on-list and replace teh existing template with it. */
- t_template *z = template_new(&s_, x->x_argc, x->x_argv);
- template_conform(t, z);
- pd_free(&t->t_pdobj);
- pd_free(&z->t_pdobj);
- z = template_new(x->x_sym, x->x_argc, x->x_argv);
- z->t_list = x->x_next;
- }
- else t->t_list = 0;
- }
- else
- {
- t_gtemplate *x2, *x3;
- for (x2 = t->t_list; x3 = x2->x_next; x2 = x3)
- {
- if (x == x3)
- {
- x2->x_next = x3->x_next;
- break;
- }
- }
- }
- freebytes(x->x_argv, sizeof(t_atom) * x->x_argc);
-}
-
-static void gtemplate_setup(void)
-{
- gtemplate_class = class_new(gensym("struct"),
- (t_newmethod)gtemplate_new, (t_method)gtemplate_free,
- sizeof(t_gtemplate), CLASS_NOINLET, A_GIMME, 0);
- class_addcreator((t_newmethod)gtemplate_new_old, gensym("template"),
- A_GIMME, 0);
-}
-
-/* --------------- FIELD DESCRIPTORS ---------------------- */
-
-/* a field descriptor can hold a constant or a variable; if a variable,
-it's the name of a field in the template we belong to. LATER, we might
-want to cache the offset of the field so we don't have to search for it
-every single time we draw the object.
-*/
-
-typedef struct _fielddesc
-{
- char fd_type; /* LATER consider removing this? */
- char fd_var;
- union
- {
- t_float fd_float; /* the field is a constant float */
- t_symbol *fd_symbol; /* the field is a constant symbol */
- t_symbol *fd_varsym; /* the field is variable and this is the name */
- } fd_un;
-} t_fielddesc;
-
-#define FIELDDESC_SETFLOAT(x, f) \
- ((x)->fd_type = A_FLOAT, (x)->fd_var = 0, (x)->fd_un.fd_float = (f))
-#define FIELDDESC_SETSYMBOL(x, s) \
- ((x)->fd_type = A_SYMBOL, (x)->fd_var = 0, (x)->fd_un.fd_symbol = (s))
-#define FIELDDESC_SETVAR(x, s, type) \
- ((x)->fd_type = type, (x)->fd_var = 1, (x)->fd_un.fd_varsym = (s))
-
-#define CLOSED 1
-#define BEZ 2
-#define A_ARRAY 55 /* LATER decide whether to enshrine this in m_pd.h */
-
-static void fielddesc_setfloatarg(t_fielddesc *fd, int argc, t_atom *argv)
-{
- if (argc <= 0) FIELDDESC_SETFLOAT(fd, 0);
- else if (argv->a_type == A_SYMBOL)
- FIELDDESC_SETVAR(fd, argv->a_w.w_symbol, A_FLOAT);
- else FIELDDESC_SETFLOAT(fd, argv->a_w.w_float);
-}
-
-static void fielddesc_setarrayarg(t_fielddesc *fd, int argc, t_atom *argv)
-{
- if (argc <= 0) FIELDDESC_SETFLOAT(fd, 0);
- else if (argv->a_type == A_SYMBOL)
- FIELDDESC_SETVAR(fd, argv->a_w.w_symbol, A_ARRAY);
- else FIELDDESC_SETFLOAT(fd, argv->a_w.w_float);
-}
-
-static t_float fielddesc_getfloat(t_fielddesc *f, t_template *template,
- t_word *wp, int loud)
-{
- if (f->fd_type == A_FLOAT)
- {
- if (f->fd_var)
- return (template_getfloat(template, f->fd_un.fd_varsym, wp, loud));
- else return (f->fd_un.fd_float);
- }
- else
- {
- if (loud)
- error("symbolic data field used as number");
- return (0);
- }
-}
-
-static t_symbol *fielddesc_getsymbol(t_fielddesc *f, t_template *template,
- t_word *wp, int loud)
-{
- if (f->fd_type == A_SYMBOL)
- {
- if (f->fd_var)
- return(template_getsymbol(template, f->fd_un.fd_varsym, wp, loud));
- else return (f->fd_un.fd_symbol);
- }
- else
- {
- if (loud)
- error("numeric data field used as symbol");
- return (&s_);
- }
-}
-
-/* ---------------- curves and polygons (joined segments) ---------------- */
-
-/*
-curves belong to templates and describe how the data in the template are to
-be drawn. The coordinates of the curve (and other display features) can
-be attached to fields in the template.
-*/
-
-t_class *curve_class;
-
-typedef struct _curve
-{
- t_object x_obj;
- int x_flags; /* CLOSED and/or BEZ */
- t_fielddesc x_fillcolor;
- t_fielddesc x_outlinecolor;
- t_fielddesc x_width;
- int x_npoints;
- t_fielddesc *x_vec;
-} t_curve;
-
-static void *curve_new(t_symbol *classsym, t_int argc, t_atom *argv)
-{
- t_curve *x = (t_curve *)pd_new(curve_class);
- char *classname = classsym->s_name;
- int flags = 0;
- int nxy, i;
- t_fielddesc *fd;
- if (classname[0] == 'f')
- {
- classname += 6;
- flags |= CLOSED;
- if (argc) fielddesc_setfloatarg(&x->x_fillcolor, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_outlinecolor, 0);
- }
- else classname += 4;
- if (classname[0] == 'c') flags |= BEZ;
- x->x_flags = flags;
- if (argc) fielddesc_setfloatarg(&x->x_outlinecolor, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_outlinecolor, 0);
- if (argc) fielddesc_setfloatarg(&x->x_width, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_width, 1);
- if (argc < 0) argc = 0;
- nxy = (argc + (argc & 1));
- x->x_npoints = (nxy>>1);
- x->x_vec = (t_fielddesc *)t_getbytes(nxy * sizeof(t_fielddesc));
- for (i = 0, fd = x->x_vec; i < argc; i++, fd++, argv++)
- fielddesc_setfloatarg(fd, 1, argv);
- if (argc & 1) FIELDDESC_SETFLOAT(fd, 0);
-
- return (x);
-}
-
-/* -------------------- widget behavior for curve ------------ */
-
-static void curve_getrect(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_curve *x = (t_curve *)z;
- int i, n = x->x_npoints;
- t_fielddesc *f = x->x_vec;
- int x1 = 0x7fffffff, x2 = -0x7fffffff, y1 = 0x7fffffff, y2 = -0x7fffffff;
- for (i = 0, f = x->x_vec; i < n; i++, f += 2)
- {
- int xloc = glist_xtopixels(glist,
- basex + fielddesc_getfloat(f, template, data, 0));
- int yloc = glist_ytopixels(glist,
- basey + fielddesc_getfloat(f+1, template, data, 0));
- if (xloc < x1) x1 = xloc;
- if (xloc > x2) x2 = xloc;
- if (yloc < y1) y1 = yloc;
- if (yloc > y2) y2 = yloc;
- }
- *xp1 = x1;
- *yp1 = y1;
- *xp2 = x2;
- *yp2 = y2;
-}
-
-static void curve_displace(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int dx, int dy)
-{
- /* refuse */
-}
-
-static void curve_select(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int state)
-{
- /* fill in later */
-}
-
-static void curve_activate(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int state)
-{
- /* fill in later */
-}
-
-static int rangecolor(int n) /* 0 to 9 in 5 steps */
-{
- int n2 = n/2; /* 0 to 4 */
- int ret = (n2 << 6); /* 0 to 256 in 5 steps */
- if (ret > 255) ret = 255;
- return (ret);
-}
-
-static void numbertocolor(int n, char *s)
-{
- int red, blue, green;
- if (n < 0) n = 0;
- red = n / 100;
- blue = ((n / 10) % 10);
- green = n % 10;
- sprintf(s, "#%2.2x%2.2x%2.2x", rangecolor(red), rangecolor(blue),
- rangecolor(green));
-}
-
-static void curve_vis(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int vis)
-{
- t_curve *x = (t_curve *)z;
- int i, n = x->x_npoints;
- t_fielddesc *f = x->x_vec;
-
- if (vis)
- {
- if (n > 1)
- {
- int flags = x->x_flags, closed = (flags & CLOSED);
- float width = fielddesc_getfloat(&x->x_width, template, data, 1);
- char outline[20], fill[20];
- if (width < 1) width = 1;
- numbertocolor(
- fielddesc_getfloat(&x->x_outlinecolor, template, data, 1),
- outline);
- if (flags & CLOSED)
- {
- numbertocolor(
- fielddesc_getfloat(&x->x_fillcolor, template, data, 1),
- fill);
- sys_vgui(".x%x.c create polygon\\\n",
- glist_getcanvas(glist));
- }
- else sys_vgui(".x%x.c create line\\\n",
- glist_getcanvas(glist));
- for (i = 0, f = x->x_vec; i < n; i++, f += 2)
- {
- float xloc = glist_xtopixels(glist,
- basex + fielddesc_getfloat(f, template, data, 1));
- float yloc = glist_ytopixels(glist,
- basey + fielddesc_getfloat(f+1, template, data, 1));
- sys_vgui("%d %d\\\n", (int)xloc, (int)yloc);
- }
- sys_vgui("-width %f\\\n",
- fielddesc_getfloat(&x->x_width, template, data, 1));
- if (flags & CLOSED) sys_vgui("-fill %s -outline %s\\\n",
- fill, outline);
- else sys_vgui("-fill %s\\\n", outline);
- if (flags & BEZ) sys_vgui("-smooth 1\\\n");
- sys_vgui("-tags curve%x\n", data);
- }
- else post("warning: curves need at least two points to be graphed");
- }
- else
- {
- if (n > 1) sys_vgui(".x%x.c delete curve%x\n",
- glist_getcanvas(glist), data);
- }
-}
-
-static int curve_motion_field;
-static float curve_motion_xcumulative;
-static float curve_motion_xbase;
-static float curve_motion_xper;
-static float curve_motion_ycumulative;
-static float curve_motion_ybase;
-static float curve_motion_yper;
-static t_glist *curve_motion_glist;
-static t_gobj *curve_motion_gobj;
-static t_word *curve_motion_wp;
-static t_template *curve_motion_template;
-
- /* LATER protect against the template changing or the scalar disappearing
- probably by attaching a gpointer here ... */
-
-static void curve_motion(void *z, t_floatarg dx, t_floatarg dy)
-{
- t_curve *x = (t_curve *)z;
- t_fielddesc *f = x->x_vec + curve_motion_field;
- curve_motion_xcumulative += dx;
- curve_motion_ycumulative += dy;
- if (f->fd_var)
- {
- template_setfloat(curve_motion_template,
- f->fd_un.fd_varsym,
- curve_motion_wp,
- curve_motion_xbase + curve_motion_xcumulative * curve_motion_xper,
- 1);
- }
- if ((f+1)->fd_var)
- {
- template_setfloat(curve_motion_template,
- (f+1)->fd_un.fd_varsym,
- curve_motion_wp,
- curve_motion_ybase + curve_motion_ycumulative * curve_motion_yper,
- 1);
- }
- glist_redrawitem(curve_motion_glist, curve_motion_gobj);
-}
-
-static int curve_click(t_gobj *z, t_glist *glist,
- t_scalar *sc, t_template *template, float basex, float basey,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_curve *x = (t_curve *)z;
- int i, n = x->x_npoints;
- int bestn = -1;
- int besterror = 0x7fffffff;
- t_fielddesc *f = x->x_vec;
- t_word *data = sc->sc_vec;
- for (i = 0, f = x->x_vec; i < n; i++, f += 2)
- {
- int xloc = glist_xtopixels(glist,
- basex + fielddesc_getfloat(f, template, data, 0));
- int yloc = glist_ytopixels(glist,
- basey + fielddesc_getfloat(f+1, template, data, 0));
- int xerr = xloc - xpix, yerr = yloc - ypix;
- if (!f->fd_var && !(f+1)->fd_var)
- continue;
- if (xerr < 0)
- xerr = -xerr;
- if (yerr < 0)
- yerr = -yerr;
- if (yerr > xerr)
- xerr = yerr;
- if (xerr < besterror)
- {
- besterror = xerr;
- bestn = i;
- curve_motion_xbase = fielddesc_getfloat(f, template, data, 0);
- curve_motion_ybase = fielddesc_getfloat(f+1, template, data, 0);
- }
- }
- if (besterror > 10)
- return (0);
- if (doit)
- {
- curve_motion_xper = glist_pixelstox(glist, 1)
- - glist_pixelstox(glist, 0);
- curve_motion_yper = glist_pixelstoy(glist, 1)
- - glist_pixelstoy(glist, 0);
- curve_motion_xcumulative = curve_motion_ycumulative = 0;
- curve_motion_glist = glist;
- curve_motion_gobj = &sc->sc_gobj;
- curve_motion_wp = data;
- curve_motion_field = 2*bestn;
- curve_motion_template = template;
- glist_grab(glist, z, curve_motion, 0, xpix, ypix);
- }
- return (1);
-}
-
-t_parentwidgetbehavior curve_widgetbehavior =
-{
- curve_getrect,
- curve_displace,
- curve_select,
- curve_activate,
- curve_vis,
- curve_click,
-};
-
-static void curve_free(t_curve *x)
-{
- t_freebytes(x->x_vec, 2 * x->x_npoints * sizeof(*x->x_vec));
-}
-
-static void curve_setup(void)
-{
- curve_class = class_new(gensym("drawpolygon"), (t_newmethod)curve_new,
- (t_method)curve_free, sizeof(t_curve), CLASS_NOINLET, A_GIMME, 0);
- class_setdrawcommand(curve_class);
- class_addcreator((t_newmethod)curve_new, gensym("drawcurve"),
- A_GIMME, 0);
- class_addcreator((t_newmethod)curve_new, gensym("filledpolygon"),
- A_GIMME, 0);
- class_addcreator((t_newmethod)curve_new, gensym("filledcurve"),
- A_GIMME, 0);
- class_setparentwidget(curve_class, &curve_widgetbehavior);
-}
-
-/* --------- plots for showing arrays --------------- */
-
-t_class *plot_class;
-
-typedef struct _plot
-{
- t_object x_obj;
- int x_flags;
- t_fielddesc x_outlinecolor;
- t_fielddesc x_width;
- t_fielddesc x_xloc;
- t_fielddesc x_yloc;
- t_fielddesc x_xinc;
- t_fielddesc x_data;
-} t_plot;
-
-static void *plot_new(t_symbol *classsym, t_int argc, t_atom *argv)
-{
- t_plot *x = (t_plot *)pd_new(plot_class);
- int flags = 0;
- int nxy, i;
- t_fielddesc *fd;
- t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
- if (!strcmp(firstarg->s_name, "curve"))
- {
- flags |= BEZ;
- argc--, argv++;
- }
- if (argc) fielddesc_setarrayarg(&x->x_data, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_data, 1);
- if (argc) fielddesc_setfloatarg(&x->x_outlinecolor, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_outlinecolor, 0);
- if (argc) fielddesc_setfloatarg(&x->x_width, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_width, 1);
- if (argc) fielddesc_setfloatarg(&x->x_xloc, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_xloc, 1);
- if (argc) fielddesc_setfloatarg(&x->x_yloc, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_yloc, 1);
- if (argc) fielddesc_setfloatarg(&x->x_xinc, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_xinc, 1);
- x->x_flags = flags;
- return (x);
-}
-
-/* -------------------- widget behavior for plot ------------ */
-
-
- /* get everything we'll need from the owner template of the array being
- plotted. Not used for garrays, but see below */
-static int plot_readownertemplate(t_plot *x,
- t_word *data, t_template *ownertemplate,
- t_symbol **elemtemplatesymp, t_array **arrayp,
- float *linewidthp, float *xlocp, float *xincp, float *ylocp)
-{
- int arrayonset, type;
- t_symbol *elemtemplatesym;
- t_array *array;
-
- /* find the data and verify it's an array */
- if (x->x_data.fd_type != A_ARRAY || !x->x_data.fd_var)
- {
- error("plot: needs an array field");
- return (-1);
- }
- if (!template_find_field(ownertemplate, x->x_data.fd_un.fd_varsym,
- &arrayonset, &type, &elemtemplatesym))
- {
- error("plot: %s: no such field", x->x_data.fd_un.fd_varsym->s_name);
- return (-1);
- }
- if (type != DT_ARRAY)
- {
- error("plot: %s: not an array", x->x_data.fd_un.fd_varsym->s_name);
- return (-1);
- }
- array = *(t_array **)(((char *)data) + arrayonset);
- *linewidthp = fielddesc_getfloat(&x->x_width, ownertemplate, data, 1);
- *xlocp = fielddesc_getfloat(&x->x_xloc, ownertemplate, data, 1);
- *xincp = fielddesc_getfloat(&x->x_xinc, ownertemplate, data, 1);
- *ylocp = fielddesc_getfloat(&x->x_yloc, ownertemplate, data, 1);
- *elemtemplatesymp = elemtemplatesym;
- *arrayp = array;
- return (0);
-}
-
- /* get everything else you could possibly need about a plot,
- either for plot's own purposes or for plotting a "garray" */
-int array_getfields(t_symbol *elemtemplatesym,
- t_canvas **elemtemplatecanvasp,
- t_template **elemtemplatep, int *elemsizep,
- int *xonsetp, int *yonsetp, int *wonsetp)
-{
- int arrayonset, elemsize, yonset, wonset, xonset, type;
- t_template *elemtemplate;
- t_symbol *dummy;
- t_canvas *elemtemplatecanvas = 0;
-
- /* the "float" template is special in not having to have a canvas;
- template_findbyname is hardwired to return a predefined
- template. */
-
- if (!(elemtemplate = template_findbyname(elemtemplatesym)))
- {
- error("plot: %s: no such template", elemtemplatesym->s_name);
- return (-1);
- }
- if (!((elemtemplatesym == &s_float) ||
- (elemtemplatecanvas = template_findcanvas(elemtemplate))))
- {
- error("plot: %s: no canvas for this template", elemtemplatesym->s_name);
- return (-1);
- }
- elemsize = elemtemplate->t_n * sizeof(t_word);
- if (!template_find_field(elemtemplate, gensym("y"), &yonset, &type, &dummy)
- || type != DT_FLOAT)
- yonset = -1;
- if (!template_find_field(elemtemplate, gensym("x"), &xonset, &type, &dummy)
- || type != DT_FLOAT)
- xonset = -1;
- if (!template_find_field(elemtemplate, gensym("w"), &wonset, &type, &dummy)
- || type != DT_FLOAT)
- wonset = -1;
-
- /* fill in slots for return values */
- *elemtemplatecanvasp = elemtemplatecanvas;
- *elemtemplatep = elemtemplate;
- *elemsizep = elemsize;
- *xonsetp = xonset;
- *yonsetp = yonset;
- *wonsetp = wonset;
- return (0);
-}
-
-static void plot_getrect(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_plot *x = (t_plot *)z;
- int elemsize, yonset, wonset, xonset;
- t_canvas *elemtemplatecanvas;
- t_template *elemtemplate;
- t_symbol *elemtemplatesym;
- float linewidth, xloc, xinc, yloc;
- t_array *array;
- float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
- int i;
- float xpix, ypix, wpix;
-
- if (!plot_readownertemplate(x, data, template,
- &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc) &&
- !array_getfields(elemtemplatesym, &elemtemplatecanvas,
- &elemtemplate, &elemsize, &xonset, &yonset, &wonset))
- {
- for (i = 0; i < array->a_n; i++)
- {
- array_getcoordinate(glist, (char *)(array->a_vec) + i * elemsize,
- xonset, yonset, wonset, i, basex + xloc, basey + yloc, xinc,
- &xpix, &ypix, &wpix);
- if (xpix < x1)
- x1 = xpix;
- if (xpix > x2)
- x2 = xpix;
- if (ypix - wpix < y1)
- y1 = ypix - wpix;
- if (ypix + wpix > y2)
- y2 = ypix + wpix;
- }
- }
-
- *xp1 = x1;
- *yp1 = y1;
- *xp2 = x2;
- *yp2 = y2;
-}
-
-static void plot_displace(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int dx, int dy)
-{
- /* not yet */
-}
-
-static void plot_select(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int state)
-{
- /* not yet */
-}
-
-static void plot_activate(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int state)
-{
- /* not yet */
-}
-
-static void plot_vis(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int vis)
-{
- t_plot *x = (t_plot *)z;
- int elemsize, yonset, wonset, xonset;
- t_canvas *elemtemplatecanvas;
- t_template *elemtemplate;
- t_symbol *elemtemplatesym;
- float linewidth, xloc, xinc, yloc;
- t_array *array;
- int nelem;
- char *elem;
- if (plot_readownertemplate(x, data, template,
- &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc) ||
- array_getfields(elemtemplatesym, &elemtemplatecanvas,
- &elemtemplate, &elemsize, &xonset, &yonset, &wonset))
- return;
- nelem = array->a_n;
- elem = (char *)array->a_vec;
- if (vis)
- {
- char outline[20];
- int lastpixel = -1, ndrawn = 0;
- float xsum, yval = 0, wval = 0, xpix;
- int ixpix = 0, i;
-
- /* draw the trace */
- numbertocolor(fielddesc_getfloat(&x->x_outlinecolor, template, data, 1),
- outline);
- if (wonset >= 0)
- {
- /* found "w" field which controls linewidth. The trace is
- a filled polygon with 2n points. */
- sys_vgui(".x%x.c create polygon \\\n",
- glist_getcanvas(glist));
-
- for (i = 0, xsum = xloc; i < nelem; i++)
- {
- float usexloc;
- if (xonset >= 0)
- usexloc = xloc + *(float *)((elem + elemsize * i) + xonset);
- else usexloc = xsum, xsum += xinc;
- if (yonset >= 0)
- yval = *(float *)((elem + elemsize * i) + yonset);
- else yval = 0;
- wval = *(float *)((elem + elemsize * i) + wonset);
- xpix = glist_xtopixels(glist, basex + usexloc);
- ixpix = xpix + 0.5;
- if (xonset >= 0 || ixpix != lastpixel)
- {
- sys_vgui("%d %f \\\n", ixpix,
- glist_ytopixels(glist,
- basey + yloc + yval - wval));
- ndrawn++;
- }
- lastpixel = ixpix;
- if (ndrawn >= 1000) goto ouch;
- }
- lastpixel = -1;
- for (i = nelem-1; i >= 0; i--)
- {
- float usexloc;
- if (xonset >= 0)
- usexloc = xloc + *(float *)((elem + elemsize * i) + xonset);
- else xsum -= xinc, usexloc = xsum;
- if (yonset >= 0)
- yval = *(float *)((elem + elemsize * i) + yonset);
- else yval = 0;
- wval = *(float *)((elem + elemsize * i) + wonset);
- xpix = glist_xtopixels(glist, basex + usexloc);
- ixpix = xpix + 0.5;
- if (xonset >= 0 || ixpix != lastpixel)
- {
- sys_vgui("%d %f \\\n", ixpix, glist_ytopixels(glist,
- basey + yloc + yval + wval));
- ndrawn++;
- }
- lastpixel = ixpix;
- if (ndrawn >= 1000) goto ouch;
- }
- /* TK will complain if there aren't at least 3 points. There
- should be at least two already. */
- if (ndrawn < 4)
- {
- sys_vgui("%d %f \\\n", ixpix + 10, glist_ytopixels(glist,
- basey + yloc + yval + wval));
- sys_vgui("%d %f \\\n", ixpix + 10, glist_ytopixels(glist,
- basey + yloc + yval - wval));
- }
- ouch:
- sys_vgui(" -width 1 -fill %s -outline %s\\\n", outline, outline);
- if (x->x_flags & BEZ) sys_vgui("-smooth 1\\\n");
-
- sys_vgui("-tags plot%x\n", data);
- }
- else if (linewidth > 0)
- {
- /* no "w" field. If the linewidth is positive, draw a
- segmented line with the requested width; otherwise don't
- draw the trace at all. */
- sys_vgui(".x%x.c create line \\\n", glist_getcanvas(glist));
-
- for (xsum = xloc, i = 0; i < nelem; i++)
- {
- float usexloc;
- if (xonset >= 0)
- usexloc = xloc + *(float *)((elem + elemsize * i) + xonset);
- else usexloc = xsum, xsum += xinc;
- if (yonset >= 0)
- yval = *(float *)((elem + elemsize * i) + yonset);
- else yval = 0;
- xpix = glist_xtopixels(glist, basex + usexloc);
- ixpix = xpix + 0.5;
- if (xonset >= 0 || ixpix != lastpixel)
- {
- sys_vgui("%d %f \\\n", ixpix,
- glist_ytopixels(glist, basey + yloc + yval));
- ndrawn++;
- }
- lastpixel = ixpix;
- if (ndrawn >= 1000) break;
- }
- /* TK will complain if there aren't at least 2 points... */
- if (ndrawn == 0) sys_vgui("0 0 0 0 \\\n");
- else if (ndrawn == 1) sys_vgui("%d %f \\\n", ixpix + 10,
- glist_ytopixels(glist, basey + yloc + yval));
-
- sys_vgui("-width %f\\\n", linewidth);
- sys_vgui("-fill %s\\\n", outline);
- if (x->x_flags & BEZ) sys_vgui("-smooth 1\\\n");
-
- sys_vgui("-tags plot%x\n", data);
- }
- /* We're done with the outline; now draw all the points.
- This code is inefficient since the template has to be
- searched for drawing instructions for every last point. */
-
- for (xsum = xloc, i = 0; i < nelem; i++)
- {
- float usexloc, useyloc;
- t_gobj *y;
- if (xonset >= 0)
- usexloc = basex + xloc +
- *(float *)((elem + elemsize * i) + xonset);
- else usexloc = basex + xsum, xsum += xinc;
- if (yonset >= 0)
- yval = *(float *)((elem + elemsize * i) + yonset);
- else yval = 0;
- useyloc = basey + yloc + yval;
- for (y = elemtemplatecanvas->gl_list; y; y = y->g_next)
- {
- t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
- if (!wb) continue;
- (*wb->w_parentvisfn)(y, glist,
- (t_word *)(elem + elemsize * i),
- elemtemplate, usexloc, useyloc, vis);
- }
- }
- }
- else
- {
- /* un-draw the individual points */
- int i;
- for (i = 0; i < nelem; i++)
- {
- t_gobj *y;
- for (y = elemtemplatecanvas->gl_list; y; y = y->g_next)
- {
- t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
- if (!wb) continue;
- (*wb->w_parentvisfn)(y, glist,
- (t_word *)(elem + elemsize * i), elemtemplate,
- 0, 0, 0);
- }
- }
- /* and then the trace */
- sys_vgui(".x%x.c delete plot%x\n",
- glist_getcanvas(glist), data);
- }
-}
-
-
-static int plot_click(t_gobj *z, t_glist *glist,
- t_scalar *sc, t_template *template, float basex, float basey,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_plot *x = (t_plot *)z;
- t_symbol *elemtemplatesym;
- float linewidth, xloc, xinc, yloc;
- t_array *array;
- t_word *data = sc->sc_vec;
-
- if (!plot_readownertemplate(x, data, template,
- &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc))
- {
- return (array_doclick(array, glist, &sc->sc_gobj,
- elemtemplatesym,
- linewidth, basex + xloc, xinc, basey + yloc,
- xpix, ypix, shift, alt, dbl, doit));
- }
- else return (0);
-}
-
-t_parentwidgetbehavior plot_widgetbehavior =
-{
- plot_getrect,
- plot_displace,
- plot_select,
- plot_activate,
- plot_vis,
- plot_click,
-};
-
-static void plot_setup(void)
-{
- plot_class = class_new(gensym("plot"), (t_newmethod)plot_new, 0,
- sizeof(t_plot), CLASS_NOINLET, A_GIMME, 0);
- class_setdrawcommand(plot_class);
- class_setparentwidget(plot_class, &plot_widgetbehavior);
-}
-
-/* ---------------- drawnumber: draw a number ---------------- */
-
-/*
- drawnumbers draw numeric fields at controllable locations, with
- controllable color and label .
- invocation: (drawnumber|drawsymbol) variable x y color label
-*/
-
-t_class *drawnumber_class;
-
-#define DRAW_SYMBOL 1
-
-typedef struct _drawnumber
-{
- t_object x_obj;
- t_fielddesc x_value;
- t_fielddesc x_xloc;
- t_fielddesc x_yloc;
- t_fielddesc x_color;
- t_symbol *x_label;
- int x_flags;
-} t_drawnumber;
-
-static void *drawnumber_new(t_symbol *classsym, t_int argc, t_atom *argv)
-{
- t_drawnumber *x = (t_drawnumber *)pd_new(drawnumber_class);
- char *classname = classsym->s_name;
- int flags = 0;
- if (classname[4] == 's')
- flags |= DRAW_SYMBOL;
- x->x_flags = flags;
- if (argc) fielddesc_setfloatarg(&x->x_value, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_value, 0);
- if (argc) fielddesc_setfloatarg(&x->x_xloc, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_xloc, 0);
- if (argc) fielddesc_setfloatarg(&x->x_yloc, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_yloc, 0);
- if (argc) fielddesc_setfloatarg(&x->x_color, argc--, argv++);
- else FIELDDESC_SETFLOAT(&x->x_color, 1);
- if (argc)
- x->x_label = atom_getsymbolarg(0, argc, argv);
- else x->x_label = &s_;
-
- return (x);
-}
-
-/* -------------------- widget behavior for drawnumber ------------ */
-
-#define DRAWNUMBER_BUFSIZE 80
-static void drawnumber_sprintf(t_drawnumber *x, char *buf, t_atom *ap)
-{
- int nchars;
- strncpy(buf, x->x_label->s_name, DRAWNUMBER_BUFSIZE);
- buf[DRAWNUMBER_BUFSIZE - 1] = 0;
- nchars = strlen(buf);
- atom_string(ap, buf + nchars, DRAWNUMBER_BUFSIZE - nchars);
-}
-
-static void drawnumber_getrect(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_drawnumber *x = (t_drawnumber *)z;
- t_atom at;
- int xloc = glist_xtopixels(glist,
- basex + fielddesc_getfloat(&x->x_xloc, template, data, 0));
- int yloc = glist_ytopixels(glist,
- basey + fielddesc_getfloat(&x->x_yloc, template, data, 0));
- int font = glist_getfont(glist);
- int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font);
- char buf[DRAWNUMBER_BUFSIZE];
- if (x->x_flags & DRAW_SYMBOL)
- SETSYMBOL(&at, fielddesc_getsymbol(&x->x_value, template, data, 0));
- else SETFLOAT(&at, fielddesc_getfloat(&x->x_value, template, data, 0));
- drawnumber_sprintf(x, buf, &at);
- *xp1 = xloc;
- *yp1 = yloc;
- *xp2 = xloc + fontwidth * strlen(buf);
- *yp2 = yloc + fontheight;
-}
-
-static void drawnumber_displace(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int dx, int dy)
-{
- /* refuse */
-}
-
-static void drawnumber_select(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int state)
-{
- post("drawnumber_select %d", state);
- /* fill in later */
-}
-
-static void drawnumber_activate(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int state)
-{
- post("drawnumber_activate %d", state);
-}
-
-static void drawnumber_vis(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey,
- int vis)
-{
- t_drawnumber *x = (t_drawnumber *)z;
-
- if (vis)
- {
- t_atom at;
- int xloc = glist_xtopixels(glist,
- basex + fielddesc_getfloat(&x->x_xloc, template, data, 0));
- int yloc = glist_ytopixels(glist,
- basey + fielddesc_getfloat(&x->x_yloc, template, data, 0));
- char colorstring[20], buf[DRAWNUMBER_BUFSIZE];
- numbertocolor(fielddesc_getfloat(&x->x_color, template, data, 1),
- colorstring);
- if (x->x_flags & DRAW_SYMBOL)
- SETSYMBOL(&at, fielddesc_getsymbol(&x->x_value, template, data, 0));
- else SETFLOAT(&at, fielddesc_getfloat(&x->x_value, template, data, 0));
- drawnumber_sprintf(x, buf, &at);
- sys_vgui(".x%x.c create text %d %d -anchor nw -fill %s -text {%s}",
- glist_getcanvas(glist), xloc, yloc, colorstring, buf);
- sys_vgui(" -font -*-courier-bold--normal--%d-*",
- sys_hostfontsize(glist_getfont(glist)));
- sys_vgui(" -tags drawnumber%x\n", data);
- }
- else sys_vgui(".x%x.c delete drawnumber%x\n", glist_getcanvas(glist), data);
-}
-
-static float drawnumber_motion_ycumulative;
-static t_glist *drawnumber_motion_glist;
-static t_gobj *drawnumber_motion_gobj;
-static t_word *drawnumber_motion_wp;
-static t_template *drawnumber_motion_template;
-
- /* LATER protect against the template changing or the scalar disappearing
- probably by attaching a gpointer here ... */
-
-static void drawnumber_motion(void *z, t_floatarg dx, t_floatarg dy)
-{
- t_drawnumber *x = (t_drawnumber *)z;
- t_fielddesc *f = &x->x_value;
- drawnumber_motion_ycumulative -= dy;
- template_setfloat(drawnumber_motion_template,
- f->fd_un.fd_varsym,
- drawnumber_motion_wp,
- drawnumber_motion_ycumulative,
- 1);
- glist_redrawitem(drawnumber_motion_glist, drawnumber_motion_gobj);
-}
-
-static int drawnumber_click(t_gobj *z, t_glist *glist,
- t_scalar *sc, t_template *template, float basex, float basey,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_drawnumber *x = (t_drawnumber *)z;
- int x1, y1, x2, y2;
- t_word *data = sc->sc_vec;
- drawnumber_getrect(z, glist,
- sc->sc_vec, template, basex, basey,
- &x1, &y1, &x2, &y2);
- if (xpix >= x1 && xpix <= x2 && ypix >= y1 && ypix <= y2
- && x->x_value.fd_var)
- {
- if (doit)
- {
- drawnumber_motion_glist = glist;
- drawnumber_motion_gobj = &sc->sc_gobj;
- drawnumber_motion_wp = data;
- drawnumber_motion_template = template;
- drawnumber_motion_ycumulative =
- fielddesc_getfloat(&x->x_value, template, data, 0);
- glist_grab(glist, z, drawnumber_motion, 0, xpix, ypix);
- }
- return (1);
- }
- else return (0);
-}
-
-t_parentwidgetbehavior drawnumber_widgetbehavior =
-{
- drawnumber_getrect,
- drawnumber_displace,
- drawnumber_select,
- drawnumber_activate,
- drawnumber_vis,
- drawnumber_click,
-};
-
-static void drawnumber_free(t_drawnumber *x)
-{
-}
-
-static void drawnumber_setup(void)
-{
- drawnumber_class = class_new(gensym("drawnumber"),
- (t_newmethod)drawnumber_new, (t_method)drawnumber_free,
- sizeof(t_drawnumber), CLASS_NOINLET, A_GIMME, 0);
- class_setdrawcommand(drawnumber_class);
- class_addcreator((t_newmethod)drawnumber_new, gensym("drawsymbol"),
- A_GIMME, 0);
- class_setparentwidget(drawnumber_class, &drawnumber_widgetbehavior);
-}
-
-/* ---------------------- setup function ---------------------------- */
-
-void g_template_setup(void)
-{
- template_setup();
- gtemplate_setup();
- template_float.t_pdobj = template_class;
- curve_setup();
- plot_setup();
- drawnumber_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_text.c b/apps/plugins/pdbox/PDa/src/g_text.c
index 8cf1fe2834..f1fbb7f719 100644
--- a/apps/plugins/pdbox/PDa/src/g_text.c
+++ b/apps/plugins/pdbox/PDa/src/g_text.c
@@ -1313,1320 +1313,3 @@ void g_text_setup(void)
class_setpropertiesfn(gatom_class, gatom_properties);
}
-
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* changes by Thomas Musil IEM KUG Graz Austria 2001 */
-/* the methods for calling the gui-objects from menu are implemented */
-/* all changes are labeled with iemlib */
-
-#include <stdlib.h>
-#include "m_pd.h"
-#include "m_imp.h"
-#include "s_stuff.h"
-#include "t_tk.h"
-#include "g_canvas.h"
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-static t_class *text_class;
-static t_class *message_class;
-static t_class *gatom_class;
-static void text_vis(t_gobj *z, t_glist *glist, int vis);
-static void text_displace(t_gobj *z, t_glist *glist,
- int dx, int dy);
-static void text_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2);
-
-void canvas_startmotion(t_canvas *x);
-t_widgetbehavior text_widgetbehavior;
-
-/* ----------------- the "text" object. ------------------ */
-
- /* add a "text" object (comment) to a glist. While this one goes for any glist,
- the other 3 below are for canvases only. (why?) This is called
- without args if invoked from the GUI; otherwise at least x and y
- are provided. */
-
-void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- t_text *x = (t_text *)pd_new(text_class);
- t_atom at;
- x->te_width = 0; /* don't know it yet. */
- x->te_type = T_TEXT;
- x->te_binbuf = binbuf_new();
- if (argc > 1)
- {
- x->te_xpix = atom_getfloatarg(0, argc, argv);
- x->te_ypix = atom_getfloatarg(1, argc, argv);
- if (argc > 2) binbuf_restore(x->te_binbuf, argc-2, argv+2);
- else
- {
- SETSYMBOL(&at, gensym("comment"));
- binbuf_restore(x->te_binbuf, 1, &at);
- }
- glist_add(gl, &x->te_g);
- }
- else
- {
- int xpix, ypix;
- pd_vmess((t_pd *)glist_getcanvas(gl), gensym("editmode"), "i", 1);
- SETSYMBOL(&at, gensym("comment"));
- glist_noselect(gl);
- glist_getnextxy(gl, &xpix, &ypix);
- x->te_xpix = glist_pixelstox(gl, xpix-3);
- x->te_ypix = glist_pixelstoy(gl, ypix-3);
- binbuf_restore(x->te_binbuf, 1, &at);
- glist_add(gl, &x->te_g);
- glist_noselect(gl);
- glist_select(gl, &x->te_g);
- /* it would be nice to "activate" here, but then the second,
- "put-me-down" click changes the text selection, which is quite
- irritating, so I took this back out. It's OK in messages
- and objects though since there's no text in them at menu
- creation. */
- /* gobj_activate(&x->te_g, gl, 1); */
- canvas_startmotion(glist_getcanvas(gl));
- }
-}
-
-/* ----------------- the "object" object. ------------------ */
-
-extern t_pd *newest;
-void canvas_getargs(int *argcp, t_atom **argvp);
-
-static void canvas_objtext(t_glist *gl, int xpix, int ypix, int selected,
- t_binbuf *b)
-{
- t_text *x;
- int argc;
- t_atom *argv;
- newest = 0;
- canvas_setcurrent((t_canvas *)gl);
- canvas_getargs(&argc, &argv);
- binbuf_eval(b, &pd_objectmaker, argc, argv);
- if (binbuf_getnatom(b))
- {
- if (!newest)
- {
- binbuf_print(b);
- post("... couldn't create");
- x = 0;
- }
- else if (!(x = pd_checkobject(newest)))
- {
- binbuf_print(b);
- post("... didn't return a patchable object");
- }
- }
- else x = 0;
- if (!x)
- {
-
- /* LATER make the color reflect this */
- x = (t_text *)pd_new(text_class);
- }
- x->te_binbuf = b;
- x->te_xpix = xpix;
- x->te_ypix = ypix;
- x->te_width = 0;
- x->te_type = T_OBJECT;
- glist_add(gl, &x->te_g);
- if (selected)
- {
- /* this is called if we've been created from the menu. */
- glist_select(gl, &x->te_g);
- gobj_activate(&x->te_g, gl, 1);
- }
- if (pd_class(&x->ob_pd) == vinlet_class)
- canvas_resortinlets(glist_getcanvas(gl));
- if (pd_class(&x->ob_pd) == voutlet_class)
- canvas_resortoutlets(glist_getcanvas(gl));
- canvas_unsetcurrent((t_canvas *)gl);
-}
-
- /* object creation routine. These are called without any arguments if
- they're invoked from the
- gui; when pasting or restoring from a file, we get at least x and y. */
-
-void canvas_obj(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- t_text *x;
- if (argc >= 2)
- {
- t_binbuf *b = binbuf_new();
- binbuf_restore(b, argc-2, argv+2);
- canvas_objtext(gl, atom_getintarg(0, argc, argv),
- atom_getintarg(1, argc, argv), 0, b);
- }
- else
- {
- t_binbuf *b = binbuf_new();
- int xpix, ypix;
- pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
- glist_noselect(gl);
- glist_getnextxy(gl, &xpix, &ypix);
- canvas_objtext(gl, xpix, ypix, 1, b);
- canvas_startmotion(glist_getcanvas(gl));
- }
-}
-
-/* make an object box for an object that's already there. */
-
-/* iemlib */
-void canvas_iemguis(t_glist *gl, t_symbol *guiobjname)
-{
- t_atom at;
- t_binbuf *b = binbuf_new();
- int xpix, ypix;
-
- pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
- glist_noselect(gl);
- SETSYMBOL(&at, guiobjname);
- binbuf_restore(b, 1, &at);
- glist_getnextxy(gl, &xpix, &ypix);
- canvas_objtext(gl, xpix, ypix, 1, b);
- canvas_startmotion(glist_getcanvas(gl));
-}
-
-void canvas_bng(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("bng"));
-}
-
-void canvas_toggle(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("tgl"));
-}
-
-void canvas_vslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("vsl"));
-}
-
-void canvas_hslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("hsl"));
-}
-
-void canvas_hdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("hdl"));
-}
-
-void canvas_vdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("vdl"));
-}
-
-void canvas_hradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("hradio"));
-}
-
-void canvas_vradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("vradio"));
-}
-
-void canvas_vumeter(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("vu"));
-}
-
-void canvas_mycnv(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("cnv"));
-}
-
-void canvas_numbox(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_iemguis(gl, gensym("nbx"));
-}
-
-/* iemlib */
-
-void canvas_objfor(t_glist *gl, t_text *x, int argc, t_atom *argv)
-{
- x->te_width = 0; /* don't know it yet. */
- x->te_type = T_OBJECT;
- x->te_binbuf = binbuf_new();
- x->te_xpix = atom_getfloatarg(0, argc, argv);
- x->te_ypix = atom_getfloatarg(1, argc, argv);
- if (argc > 2) binbuf_restore(x->te_binbuf, argc-2, argv+2);
- glist_add(gl, &x->te_g);
-}
-
-/* ---------------------- the "message" text item ------------------------ */
-
-typedef struct _messresponder
-{
- t_pd mr_pd;
- t_outlet *mr_outlet;
-} t_messresponder;
-
-typedef struct _message
-{
- t_text m_text;
- t_messresponder m_messresponder;
- t_glist *m_glist;
- t_clock *m_clock;
-} t_message;
-
-static t_class *message_class, *messresponder_class;
-
-static void messresponder_bang(t_messresponder *x)
-{
- outlet_bang(x->mr_outlet);
-}
-
-static void messresponder_float(t_messresponder *x, t_float f)
-{
- outlet_float(x->mr_outlet, f);
-}
-
-static void messresponder_symbol(t_messresponder *x, t_symbol *s)
-{
- outlet_symbol(x->mr_outlet, s);
-}
-
-static void messresponder_list(t_messresponder *x,
- t_symbol *s, int argc, t_atom *argv)
-{
- outlet_list(x->mr_outlet, s, argc, argv);
-}
-
-static void messresponder_anything(t_messresponder *x,
- t_symbol *s, int argc, t_atom *argv)
-{
- outlet_anything(x->mr_outlet, s, argc, argv);
-}
-
-static void message_bang(t_message *x)
-{
- binbuf_eval(x->m_text.te_binbuf, &x->m_messresponder.mr_pd, 0, 0);
-}
-
-static void message_float(t_message *x, t_float f)
-{
- t_atom at;
- SETFLOAT(&at, f);
- binbuf_eval(x->m_text.te_binbuf, &x->m_messresponder.mr_pd, 1, &at);
-}
-
-static void message_symbol(t_message *x, t_symbol *s)
-{
- t_atom at;
- SETSYMBOL(&at, s);
- binbuf_eval(x->m_text.te_binbuf, &x->m_messresponder.mr_pd, 1, &at);
-}
-
-static void message_list(t_message *x, t_symbol *s, int argc, t_atom *argv)
-{
- binbuf_eval(x->m_text.te_binbuf, &x->m_messresponder.mr_pd, argc, argv);
-}
-
-static void message_set(t_message *x, t_symbol *s, int argc, t_atom *argv)
-{
- binbuf_clear(x->m_text.te_binbuf);
- binbuf_add(x->m_text.te_binbuf, argc, argv);
- glist_retext(x->m_glist, &x->m_text);
-}
-
-static void message_add2(t_message *x, t_symbol *s, int argc, t_atom *argv)
-{
- binbuf_add(x->m_text.te_binbuf, argc, argv);
- glist_retext(x->m_glist, &x->m_text);
-}
-
-static void message_add(t_message *x, t_symbol *s, int argc, t_atom *argv)
-{
- binbuf_add(x->m_text.te_binbuf, argc, argv);
- binbuf_addsemi(x->m_text.te_binbuf);
- glist_retext(x->m_glist, &x->m_text);
-}
-
-static void message_click(t_message *x,
- t_floatarg xpos, t_floatarg ypos, t_floatarg shift,
- t_floatarg ctrl, t_floatarg alt)
-{
- message_float(x, 0);
- if (glist_isvisible(x->m_glist))
- {
- t_rtext *y = glist_findrtext(x->m_glist, &x->m_text);
- sys_vgui(".x%x.c itemconfigure %sR -width 5\n",
- glist_getcanvas(x->m_glist), rtext_gettag(y));
- clock_delay(x->m_clock, 120);
- }
-}
-
-static void message_tick(t_message *x)
-{
- if (glist_isvisible(x->m_glist))
- {
- t_rtext *y = glist_findrtext(x->m_glist, &x->m_text);
- sys_vgui(".x%x.c itemconfigure %sR -width 1\n",
- glist_getcanvas(x->m_glist), rtext_gettag(y));
- }
-}
-
-static void message_free(t_message *x)
-{
- clock_free(x->m_clock);
-}
-
-void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- t_message *x = (t_message *)pd_new(message_class);
- x->m_messresponder.mr_pd = messresponder_class;
- x->m_messresponder.mr_outlet = outlet_new(&x->m_text, &s_float);
- x->m_text.te_width = 0; /* don't know it yet. */
- x->m_text.te_type = T_MESSAGE;
- x->m_text.te_binbuf = binbuf_new();
- x->m_glist = gl;
- x->m_clock = clock_new(x, (t_method)message_tick);
- if (argc > 1)
- {
- x->m_text.te_xpix = atom_getfloatarg(0, argc, argv);
- x->m_text.te_ypix = atom_getfloatarg(1, argc, argv);
- if (argc > 2) binbuf_restore(x->m_text.te_binbuf, argc-2, argv+2);
- glist_add(gl, &x->m_text.te_g);
- }
- else
- {
- int xpix, ypix;
- pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
- glist_noselect(gl);
- glist_getnextxy(gl, &xpix, &ypix);
- x->m_text.te_xpix = xpix-3;
- x->m_text.te_ypix = ypix-3;
- glist_add(gl, &x->m_text.te_g);
- glist_noselect(gl);
- glist_select(gl, &x->m_text.te_g);
- gobj_activate(&x->m_text.te_g, gl, 1);
- canvas_startmotion(glist_getcanvas(gl));
- }
-}
-
-/* ---------------------- the "atom" text item ------------------------ */
-
-#define ATOMBUFSIZE 40
-#define ATOM_LABELLEFT 0
-#define ATOM_LABELRIGHT 1
-#define ATOM_LABELUP 2
-#define ATOM_LABELDOWN 3
-
-typedef struct _gatom
-{
- t_text a_text;
- t_atom a_atom; /* this holds the value and the type */
- t_glist *a_glist; /* owning glist */
- t_float a_toggle; /* value to toggle to */
- t_float a_draghi; /* high end of drag range */
- t_float a_draglo; /* low end of drag range */
- t_symbol *a_label; /* symbol to show as label next to box */
- t_symbol *a_symfrom; /* "receive" name -- bind ourselvs to this */
- t_symbol *a_symto; /* "send" name -- send to this on output */
- char a_buf[ATOMBUFSIZE];/* string buffer for typing */
- char a_shift; /* was shift key down when dragging started? */
- char a_wherelabel; /* 0-3 for left, right, above, below */
- t_symbol *a_expanded_to; /* a_symto after $0, $1, ... expansion */
-} t_gatom;
-
- /* prepend "-" as necessary to avoid empty strings, so we can
- use them in Pd messages. A more complete solution would be
- to introduce some quoting mechanism; but then we'd be much more
- complicated. */
-static t_symbol *gatom_escapit(t_symbol *s)
-{
- if (!*s->s_name)
- return (gensym("-"));
- else if (*s->s_name == '-')
- {
- char shmo[100];
- shmo[0] = '-';
- strncpy(shmo+1, s->s_name, 99);
- shmo[99] = 0;
- return (gensym(shmo));
- }
- else return (iemgui_dollar2raute(s));
-}
-
- /* undo previous operation: strip leading "-" if found. */
-static t_symbol *gatom_unescapit(t_symbol *s)
-{
- if (*s->s_name == '-')
- return (gensym(s->s_name+1));
- else return (iemgui_raute2dollar(s));
-}
-
-#if 0 /* ??? */
- /* expand leading $0, $1, etc. in the symbol */
-static t_symbol *gatom_realizedollar(t_gatom *x, t_symbol *s)
-{
- return (canvas_realizedollar(x->a_glist, s));
-}
-#endif
-
-static void gatom_retext(t_gatom *x, int senditup)
-{
- binbuf_clear(x->a_text.te_binbuf);
- binbuf_add(x->a_text.te_binbuf, 1, &x->a_atom);
- if (senditup)
- glist_retext(x->a_glist, &x->a_text);
-}
-
-static void gatom_set(t_gatom *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_atom oldatom = x->a_atom;
- int senditup = 0;
- if (!argc) return;
- if (x->a_atom.a_type == A_FLOAT)
- x->a_atom.a_w.w_float = atom_getfloat(argv),
- senditup = (x->a_atom.a_w.w_float != oldatom.a_w.w_float);
- else if (x->a_atom.a_type == A_SYMBOL)
- x->a_atom.a_w.w_symbol = atom_getsymbol(argv),
- senditup = (x->a_atom.a_w.w_symbol != oldatom.a_w.w_symbol);
- gatom_retext(x, senditup);
- x->a_buf[0] = 0;
-}
-
-static void gatom_bang(t_gatom *x)
-{
- if (x->a_atom.a_type == A_FLOAT)
- {
- if (x->a_text.te_outlet)
- outlet_float(x->a_text.te_outlet, x->a_atom.a_w.w_float);
- if (*x->a_expanded_to->s_name && x->a_expanded_to->s_thing)
- {
- if (x->a_symto == x->a_symfrom)
- pd_error(x,
- "%s: atom with same send/receive name (infinite loop)",
- x->a_symto->s_name);
- else pd_float(x->a_expanded_to->s_thing, x->a_atom.a_w.w_float);
- }
- }
- else if (x->a_atom.a_type == A_SYMBOL)
- {
- if (x->a_text.te_outlet)
- outlet_symbol(x->a_text.te_outlet, x->a_atom.a_w.w_symbol);
- if (*x->a_symto->s_name && x->a_expanded_to->s_thing)
- {
- if (x->a_symto == x->a_symfrom)
- pd_error(x,
- "%s: atom with same send/receive name (infinite loop)",
- x->a_symto->s_name);
- else pd_symbol(x->a_expanded_to->s_thing, x->a_atom.a_w.w_symbol);
- }
- }
-}
-
-static void gatom_float(t_gatom *x, t_float f)
-{
- t_atom at;
- SETFLOAT(&at, f);
- gatom_set(x, 0, 1, &at);
- gatom_bang(x);
-}
-
-static void gatom_clipfloat(t_gatom *x, t_float f)
-{
- if (x->a_draglo != 0 || x->a_draghi != 0)
- {
- if (f < x->a_draglo)
- f = x->a_draglo;
- if (f > x->a_draghi)
- f = x->a_draghi;
- }
- gatom_float(x, f);
-}
-
-static void gatom_symbol(t_gatom *x, t_symbol *s)
-{
- t_atom at;
- SETSYMBOL(&at, s);
- gatom_set(x, 0, 1, &at);
- gatom_bang(x);
-}
-
-static void gatom_motion(void *z, t_floatarg dx, t_floatarg dy)
-{
- t_gatom *x = (t_gatom *)z;
- if (dy == 0) return;
- if (x->a_atom.a_type == A_FLOAT)
- {
- if (x->a_shift)
- {
- double nval = x->a_atom.a_w.w_float - 0.01 * dy;
- double trunc = 0.01 * (floor(100. * nval + 0.5));
- if (trunc < nval + 0.0001 && trunc > nval - 0.0001) nval = trunc;
- gatom_clipfloat(x, nval);
- }
- else
- {
- double nval = x->a_atom.a_w.w_float - dy;
- double trunc = 0.01 * (floor(100. * nval + 0.5));
- if (trunc < nval + 0.0001 && trunc > nval - 0.0001) nval = trunc;
- trunc = floor(nval + 0.5);
- if (trunc < nval + 0.001 && trunc > nval - 0.001) nval = trunc;
- gatom_clipfloat(x, nval);
- }
- }
-}
-
-static void gatom_key(void *z, t_floatarg f)
-{
- t_gatom *x = (t_gatom *)z;
- int c = f;
- int len = strlen(x->a_buf);
- t_atom at;
- char sbuf[ATOMBUFSIZE + 4];
- if (c == 0)
- {
- /* we're being notified that no more keys will come for this grab */
- if (x->a_buf[0])
- gatom_retext(x, 1);
- return;
- }
- else if (c == ' ') return;
- else if (c == '\b')
- {
- if (len > 0)
- x->a_buf[len-1] = 0;
- goto redraw;
- }
- else if (c == '\n')
- {
- if (x->a_atom.a_type == A_FLOAT)
- x->a_atom.a_w.w_float = atof(x->a_buf);
- else if (x->a_atom.a_type == A_SYMBOL)
- x->a_atom.a_w.w_symbol = gensym(x->a_buf);
- else bug("gatom_key");
- gatom_bang(x);
- gatom_retext(x, 1);
- x->a_buf[0] = 0;
- }
- else if (len < (ATOMBUFSIZE-1))
- {
- /* for numbers, only let reasonable characters through */
- if ((x->a_atom.a_type == A_SYMBOL) ||
- (c >= '0' && c <= '9' || c == '.' || c == '-'
- || c == 'e' || c == 'E'))
- {
- x->a_buf[len] = c;
- x->a_buf[len+1] = 0;
- goto redraw;
- }
- }
- return;
-redraw:
- /* LATER figure out how to avoid creating all these symbols! */
- sprintf(sbuf, "%s...", x->a_buf);
- SETSYMBOL(&at, gensym(sbuf));
- binbuf_clear(x->a_text.te_binbuf);
- binbuf_add(x->a_text.te_binbuf, 1, &at);
- glist_retext(x->a_glist, &x->a_text);
-}
-
-static void gatom_click(t_gatom *x,
- t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
- t_floatarg alt)
-{
- if (x->a_text.te_width == 1)
- {
- if (x->a_atom.a_type == A_FLOAT)
- gatom_float(x, (x->a_atom.a_w.w_float == 0));
- }
- else
- {
- if (alt)
- {
- if (x->a_atom.a_type != A_FLOAT) return;
- if (x->a_atom.a_w.w_float != 0)
- {
- x->a_toggle = x->a_atom.a_w.w_float;
- gatom_float(x, 0);
- return;
- }
- else gatom_float(x, x->a_toggle);
- }
- x->a_shift = shift;
- x->a_buf[0] = 0;
- glist_grab(x->a_glist, &x->a_text.te_g, gatom_motion, gatom_key,
- xpos, ypos);
- }
-}
-
- /* message back from dialog window */
-static void gatom_param(t_gatom *x, t_symbol *sel, int argc, t_atom *argv)
-{
- t_float width = atom_getfloatarg(0, argc, argv);
- t_float draglo = atom_getfloatarg(1, argc, argv);
- t_float draghi = atom_getfloatarg(2, argc, argv);
- t_symbol *label = gatom_unescapit(atom_getsymbolarg(3, argc, argv));
- t_float wherelabel = atom_getfloatarg(4, argc, argv);
- t_symbol *symfrom = gatom_unescapit(atom_getsymbolarg(5, argc, argv));
- t_symbol *symto = gatom_unescapit(atom_getsymbolarg(6, argc, argv));
-
- gobj_vis(&x->a_text.te_g, x->a_glist, 0);
- if (!*symfrom->s_name && *x->a_symfrom->s_name)
- inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0);
- else if (*symfrom->s_name && !*x->a_symfrom->s_name && x->a_text.te_inlet)
- {
- canvas_deletelinesforio(x->a_glist, &x->a_text,
- x->a_text.te_inlet, 0);
- inlet_free(x->a_text.te_inlet);
- }
- if (!*symto->s_name && *x->a_symto->s_name)
- outlet_new(&x->a_text, 0);
- else if (*symto->s_name && !*x->a_symto->s_name && x->a_text.te_outlet)
- {
- canvas_deletelinesforio(x->a_glist, &x->a_text,
- 0, x->a_text.te_outlet);
- outlet_free(x->a_text.te_outlet);
- }
- if (draglo >= draghi)
- draglo = draghi = 0;
- x->a_draglo = draglo;
- x->a_draghi = draghi;
- if (width < 0)
- width = 4;
- else if (width > 80)
- width = 80;
- x->a_text.te_width = width;
- x->a_wherelabel = ((int)wherelabel & 3);
- x->a_label = label;
- if (*x->a_symfrom->s_name)
- pd_unbind(&x->a_text.te_pd,
- canvas_realizedollar(x->a_glist, x->a_symfrom));
- x->a_symfrom = symfrom;
- if (*x->a_symfrom->s_name)
- pd_bind(&x->a_text.te_pd,
- canvas_realizedollar(x->a_glist, x->a_symfrom));
- x->a_symto = symto;
- x->a_expanded_to = canvas_realizedollar(x->a_glist, x->a_symto);
- gobj_vis(&x->a_text.te_g, x->a_glist, 1);
-
- /* glist_retext(x->a_glist, &x->a_text); */
-}
-
- /* ---------------- gatom-specific widget functions --------------- */
-static void gatom_getwherelabel(t_gatom *x, t_glist *glist, int *xp, int *yp)
-{
- int x1, y1, x2, y2, width, height;
- text_getrect(&x->a_text.te_g, glist, &x1, &y1, &x2, &y2);
- width = x2 - x1;
- height = y2 - y1;
- if (x->a_wherelabel == ATOM_LABELLEFT)
- {
- *xp = x1 - 3 -
- strlen(canvas_realizedollar(x->a_glist, x->a_label)->s_name) *
- sys_fontwidth(glist_getfont(glist));
- *yp = y1 + 2;
- }
- else if (x->a_wherelabel == ATOM_LABELRIGHT)
- {
- *xp = x2 + 2;
- *yp = y1 + 2;
- }
- else if (x->a_wherelabel == ATOM_LABELUP)
- {
- *xp = x1 - 1;
- *yp = y1 - 1 - sys_fontheight(glist_getfont(glist));;
- }
- else
- {
- *xp = x1 - 1;
- *yp = y2 + 3;
- }
-}
-
-static void gatom_displace(t_gobj *z, t_glist *glist,
- int dx, int dy)
-{
- t_gatom *x = (t_gatom*)z;
- text_displace(z, glist, dx, dy);
- sys_vgui(".x%x.c move %x.l %d %d\n", glist_getcanvas(glist),
- x, dx, dy);
-}
-
-static void gatom_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_gatom *x = (t_gatom*)z;
- text_vis(z, glist, vis);
- if (*x->a_label->s_name)
- {
- if (vis)
- {
- int x1, y1;
- gatom_getwherelabel(x, glist, &x1, &y1);
- sys_vgui("pdtk_text_new .x%x.c %x.l %f %f {%s} %d %s\n",
- glist_getcanvas(glist), x,
- (double)x1, (double)y1,
- canvas_realizedollar(x->a_glist, x->a_label)->s_name,
- sys_hostfontsize(glist_getfont(glist)),
- "black");
- }
- else sys_vgui(".x%x.c delete %x.l\n", glist_getcanvas(glist), x);
- }
-}
-
-void canvas_atom(t_glist *gl, t_atomtype type,
- t_symbol *s, int argc, t_atom *argv)
-{
- t_gatom *x = (t_gatom *)pd_new(gatom_class);
- t_atom at;
- x->a_text.te_width = 0; /* don't know it yet. */
- x->a_text.te_type = T_ATOM;
- x->a_text.te_binbuf = binbuf_new();
- x->a_glist = gl;
- x->a_atom.a_type = type;
- x->a_toggle = 1;
- x->a_draglo = 0;
- x->a_draghi = 0;
- x->a_wherelabel = 0;
- x->a_label = &s_;
- x->a_symfrom = &s_;
- x->a_symto = x->a_expanded_to = &s_;
- if (type == A_FLOAT)
- {
- x->a_atom.a_w.w_float = 0;
- x->a_text.te_width = 5;
- SETFLOAT(&at, 0);
- }
- else
- {
- x->a_atom.a_w.w_symbol = &s_symbol;
- x->a_text.te_width = 10;
- SETSYMBOL(&at, &s_symbol);
- }
- binbuf_add(x->a_text.te_binbuf, 1, &at);
- if (argc > 1)
- /* create from file. x, y, width, low-range, high-range, flags,
- label, receive-name, send-name */
- {
- x->a_text.te_xpix = atom_getfloatarg(0, argc, argv);
- x->a_text.te_ypix = atom_getfloatarg(1, argc, argv);
- x->a_text.te_width = atom_getintarg(2, argc, argv);
- /* sanity check because some very old patches have trash in this
- field... remove this in 2003 or so: */
- if (x->a_text.te_width < 0 || x->a_text.te_width > 500)
- x->a_text.te_width = 4;
- x->a_draglo = atom_getfloatarg(3, argc, argv);
- x->a_draghi = atom_getfloatarg(4, argc, argv);
- x->a_wherelabel = (((int)atom_getfloatarg(5, argc, argv)) & 3);
- x->a_label = gatom_unescapit(atom_getsymbolarg(6, argc, argv));
- x->a_symfrom = gatom_unescapit(atom_getsymbolarg(7, argc, argv));
- if (*x->a_symfrom->s_name)
- pd_bind(&x->a_text.te_pd,
- canvas_realizedollar(x->a_glist, x->a_symfrom));
-
- x->a_symto = gatom_unescapit(atom_getsymbolarg(8, argc, argv));
- x->a_expanded_to = canvas_realizedollar(x->a_glist, x->a_symto);
- if (x->a_symto == &s_)
- outlet_new(&x->a_text,
- x->a_atom.a_type == A_FLOAT ? &s_float: &s_symbol);
- if (x->a_symfrom == &s_)
- inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0);
- glist_add(gl, &x->a_text.te_g);
- }
- else
- {
- int xpix, ypix;
- outlet_new(&x->a_text,
- x->a_atom.a_type == A_FLOAT ? &s_float: &s_symbol);
- inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0);
- pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
- glist_noselect(gl);
- glist_getnextxy(gl, &xpix, &ypix);
- x->a_text.te_xpix = xpix;
- x->a_text.te_ypix = ypix;
- glist_add(gl, &x->a_text.te_g);
- glist_noselect(gl);
- glist_select(gl, &x->a_text.te_g);
- canvas_startmotion(glist_getcanvas(gl));
- }
-}
-
-void canvas_floatatom(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_atom(gl, A_FLOAT, s, argc, argv);
-}
-
-void canvas_symbolatom(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
-{
- canvas_atom(gl, A_SYMBOL, s, argc, argv);
-}
-
-static void gatom_free(t_gatom *x)
-{
- if (*x->a_symfrom->s_name)
- pd_unbind(&x->a_text.te_pd,
- canvas_realizedollar(x->a_glist, x->a_symfrom));
- gfxstub_deleteforkey(x);
-}
-
-static void gatom_properties(t_gobj *z, t_glist *owner)
-{
- t_gatom *x = (t_gatom *)z;
- char buf[200];
- sprintf(buf, "pdtk_gatom_dialog %%s %d %g %g %d %s %s %s\n",
- x->a_text.te_width, x->a_draglo, x->a_draghi,
- x->a_wherelabel, gatom_escapit(x->a_label)->s_name,
- gatom_escapit(x->a_symfrom)->s_name,
- gatom_escapit(x->a_symto)->s_name);
- gfxstub_new(&x->a_text.te_pd, x, buf);
-}
-
-
-/* -------------------- widget behavior for text objects ------------ */
-
-static void text_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_text *x = (t_text *)z;
- int width, height, iscomment = (x->te_type == T_TEXT);
- float x1, y1, x2, y2;
-
- /* for number boxes, we know width and height a priori, and should
- report them here so that graphs can get swelled to fit. */
-
- if (x->te_type == T_ATOM && x->te_width > 0)
- {
- int font = glist_getfont(glist);
- int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font);
- width = (x->te_width > 0 ? x->te_width : 6) * fontwidth + 2;
- height = fontheight + 1; /* borrowed from TMARGIN, etc, in g_rtext.c */
- }
- /* if we're invisible we don't know our size so we just lie about
- it. This is called on invisible boxes to establish order of inlets
- and possibly other reasons.
- To find out if the box is visible we can't just check the "vis"
- flag because we might be within the vis() routine and not have set
- that yet. So we check directly whether the "rtext" list has been
- built. LATER reconsider when "vis" flag should be on and off? */
-
- else if (glist->gl_editor && glist->gl_editor->e_rtext)
- {
- t_rtext *y = glist_findrtext(glist, x);
- width = rtext_width(y);
- height = rtext_height(y) - (iscomment << 1);
- }
- else width = height = 10;
- x1 = text_xpix(x, glist);
- y1 = text_ypix(x, glist);
- x2 = x1 + width;
- y2 = y1 + height;
- y1 += iscomment;
- *xp1 = x1;
- *yp1 = y1;
- *xp2 = x2;
- *yp2 = y2;
-}
-
-static void text_displace(t_gobj *z, t_glist *glist,
- int dx, int dy)
-{
- t_text *x = (t_text *)z;
- x->te_xpix += dx;
- x->te_ypix += dy;
- if (glist_isvisible(glist))
- {
- t_rtext *y = glist_findrtext(glist, x);
- rtext_displace(y, dx, dy);
- text_drawborder(x, glist, rtext_gettag(y),
- rtext_width(y), rtext_height(y), 0);
- canvas_fixlinesfor(glist_getcanvas(glist), x);
- }
-}
-
-static void text_select(t_gobj *z, t_glist *glist, int state)
-{
- t_text *x = (t_text *)z;
- t_rtext *y = glist_findrtext(glist, x);
- rtext_select(y, state);
- if (glist_isvisible(glist) && text_shouldvis(x, glist))
- sys_vgui(".x%x.c itemconfigure %sR -fill %s\n", glist,
- rtext_gettag(y), (state? "blue" : "black"));
-}
-
-static void text_activate(t_gobj *z, t_glist *glist, int state)
-{
- t_text *x = (t_text *)z;
- t_rtext *y = glist_findrtext(glist, x);
- if (z->g_pd != gatom_class) rtext_activate(y, state);
-}
-
-static void text_delete(t_gobj *z, t_glist *glist)
-{
- t_text *x = (t_text *)z;
- canvas_deletelinesfor(glist, x);
-}
-
- /* return true if the text box should be drawn.
- We don't show object boxes inside graphs. */
-int text_shouldvis(t_text *x, t_glist *glist)
-{
- return (glist->gl_havewindow ||
- (x->te_pd != canvas_class && x->te_pd->c_wb != &text_widgetbehavior) ||
- (x->te_pd == canvas_class && (((t_glist *)x)->gl_isgraph)));
-}
-
-static void text_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_text *x = (t_text *)z;
- if (vis)
- {
- if (text_shouldvis(x, glist))
- {
- t_rtext *y = glist_findrtext(glist, x);
- if (x->te_type == T_ATOM)
- glist_retext(glist, x);
- text_drawborder(x, glist, rtext_gettag(y),
- rtext_width(y), rtext_height(y), 1);
- rtext_draw(y);
- }
- }
- else
- {
- t_rtext *y = glist_findrtext(glist, x);
- if (text_shouldvis(x, glist))
- {
- text_eraseborder(x, glist, rtext_gettag(y));
- rtext_erase(y);
- }
- }
-}
-
-static int text_click(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_text *x = (t_text *)z;
- if (x->te_type == T_OBJECT)
- {
- t_symbol *clicksym = gensym("click");
- if (zgetfn(&x->te_pd, clicksym))
- {
- if (doit)
- pd_vmess(&x->te_pd, clicksym, "fffff",
- (double)xpix, (double)ypix,
- (double)shift, 0, (double)alt);
- return (1);
- }
- else return (0);
- }
- else if (x->te_type == T_ATOM)
- {
- if (doit)
- gatom_click((t_gatom *)x, (t_floatarg)xpix, (t_floatarg)ypix,
- (t_floatarg)shift, 0, (t_floatarg)alt);
- return (1);
- }
- else if (x->te_type == T_MESSAGE)
- {
- if (doit)
- message_click((t_message *)x, (t_floatarg)xpix, (t_floatarg)ypix,
- (t_floatarg)shift, 0, (t_floatarg)alt);
- return (1);
- }
- else return (0);
-}
-
-void text_save(t_gobj *z, t_binbuf *b)
-{
- t_text *x = (t_text *)z;
- if (x->te_type == T_OBJECT)
- {
- /* if we have a "saveto" method, and if we don't happen to be
- a canvas that's an abstraction, the saveto method does the work */
- if (zgetfn(&x->te_pd, gensym("saveto")) &&
- !((pd_class(&x->te_pd) == canvas_class) &&
- (canvas_isabstraction((t_canvas *)x)
- || canvas_istable((t_canvas *)x))))
- {
- mess1(&x->te_pd, gensym("saveto"), b);
- binbuf_addv(b, "ssii", gensym("#X"), gensym("restore"),
- (t_int)x->te_xpix, (t_int)x->te_ypix);
- }
- else /* otherwise just save the text */
- {
- binbuf_addv(b, "ssii", gensym("#X"), gensym("obj"),
- (t_int)x->te_xpix, (t_int)x->te_ypix);
- }
- binbuf_addbinbuf(b, x->te_binbuf);
- binbuf_addv(b, ";");
- }
- else if (x->te_type == T_MESSAGE)
- {
- binbuf_addv(b, "ssii", gensym("#X"), gensym("msg"),
- (t_int)x->te_xpix, (t_int)x->te_ypix);
- binbuf_addbinbuf(b, x->te_binbuf);
- binbuf_addv(b, ";");
- }
- else if (x->te_type == T_ATOM)
- {
- t_atomtype t = ((t_gatom *)x)->a_atom.a_type;
- t_symbol *sel = (t == A_SYMBOL ? gensym("symbolatom") :
- (t == A_FLOAT ? gensym("floatatom") : gensym("intatom")));
- t_symbol *label = gatom_escapit(((t_gatom *)x)->a_label);
- t_symbol *symfrom = gatom_escapit(((t_gatom *)x)->a_symfrom);
- t_symbol *symto = gatom_escapit(((t_gatom *)x)->a_symto);
- binbuf_addv(b, "ssiiifffsss", gensym("#X"), sel,
- (t_int)x->te_xpix, (t_int)x->te_ypix, (t_int)x->te_width,
- (double)((t_gatom *)x)->a_draglo,
- (double)((t_gatom *)x)->a_draghi,
- (double)((t_gatom *)x)->a_wherelabel,
- label, symfrom, symto);
- binbuf_addv(b, ";");
- }
- else
- {
- binbuf_addv(b, "ssii", gensym("#X"), gensym("text"),
- (t_int)x->te_xpix, (t_int)x->te_ypix);
- binbuf_addbinbuf(b, x->te_binbuf);
- binbuf_addv(b, ";");
- }
-}
-
- /* this one is for everyone but "gatoms"; it's imposed in m_class.c */
-t_widgetbehavior text_widgetbehavior =
-{
- text_getrect,
- text_displace,
- text_select,
- text_activate,
- text_delete,
- text_vis,
- text_click,
-};
-
-static t_widgetbehavior gatom_widgetbehavior =
-{
- text_getrect,
- gatom_displace,
- text_select,
- text_activate,
- text_delete,
- gatom_vis,
- text_click,
-};
-
-/* -------------------- the "text" class ------------ */
-
-#ifdef MACOSX
-#define EXTRAPIX 2
-#else
-#define EXTRAPIX 1
-#endif
-
- /* draw inlets and outlets for a text object or for a graph. */
-void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
- char *tag, int x1, int y1, int x2, int y2)
-{
- int n = obj_noutlets(ob), nplus = (n == 1 ? 1 : n-1), i;
- int width = x2 - x1;
- for (i = 0; i < n; i++)
- {
- int onset = x1 + (width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %so%d\n",
- glist_getcanvas(glist),
- onset, y2 - 1,
- onset + IOWIDTH, y2,
- tag, i);
- else
- sys_vgui(".x%x.c coords %so%d %d %d %d %d\n",
- glist_getcanvas(glist), tag, i,
- onset, y2 - 1,
- onset + IOWIDTH, y2);
- }
- n = obj_ninlets(ob);
- nplus = (n == 1 ? 1 : n-1);
- for (i = 0; i < n; i++)
- {
- int onset = x1 + (width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %si%d\n",
- glist_getcanvas(glist),
- onset, y1,
- onset + IOWIDTH, y1 + EXTRAPIX,
- tag, i);
- else
- sys_vgui(".x%x.c coords %si%d %d %d %d %d\n",
- glist_getcanvas(glist), tag, i,
- onset, y1,
- onset + IOWIDTH, y1 + EXTRAPIX);
- }
-}
-
-void text_drawborder(t_text *x, t_glist *glist,
- char *tag, int width2, int height2, int firsttime)
-{
- t_object *ob;
- int x1, y1, x2, y2, width, height;
- text_getrect(&x->te_g, glist, &x1, &y1, &x2, &y2);
- width = x2 - x1;
- height = y2 - y1;
- if (x->te_type == T_OBJECT)
- {
- if (firsttime)
- sys_vgui(".x%x.c create line\
- %d %d %d %d %d %d %d %d %d %d -tags %sR\n",
- glist_getcanvas(glist),
- x1, y1, x2, y1, x2, y2, x1, y2, x1, y1, tag);
- else
- sys_vgui(".x%x.c coords %sR\
- %d %d %d %d %d %d %d %d %d %d\n",
- glist_getcanvas(glist), tag,
- x1, y1, x2, y1, x2, y2, x1, y2, x1, y1);
- }
- else if (x->te_type == T_MESSAGE)
- {
- if (firsttime)
- sys_vgui(".x%x.c create line\
- %d %d %d %d %d %d %d %d %d %d %d %d %d %d -tags %sR\n",
- glist_getcanvas(glist),
- x1, y1, x2+4, y1, x2, y1+4, x2, y2-4, x2+4, y2,
- x1, y2, x1, y1,
- tag);
- else
- sys_vgui(".x%x.c coords %sR\
- %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
- glist_getcanvas(glist), tag,
- x1, y1, x2+4, y1, x2, y1+4, x2, y2-4, x2+4, y2,
- x1, y2, x1, y1);
- }
- else if (x->te_type == T_ATOM)
- {
- if (firsttime)
- sys_vgui(".x%x.c create line\
- %d %d %d %d %d %d %d %d %d %d %d %d -tags %sR\n",
- glist_getcanvas(glist),
- x1, y1, x2-4, y1, x2, y1+4, x2, y2, x1, y2, x1, y1,
- tag);
- else
- sys_vgui(".x%x.c coords %sR\
- %d %d %d %d %d %d %d %d %d %d %d %d\n",
- glist_getcanvas(glist), tag,
- x1, y1, x2-4, y1, x2, y1+4, x2, y2, x1, y2, x1, y1);
- }
- /* draw inlets/outlets */
-
- if (ob = pd_checkobject(&x->te_pd))
- glist_drawiofor(glist, ob, firsttime, tag, x1, y1, x2, y2);
-}
-
-void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag)
-{
- int i, n;
- n = obj_noutlets(ob);
- for (i = 0; i < n; i++)
- sys_vgui(".x%x.c delete %so%d\n",
- glist_getcanvas(glist), tag, i);
- n = obj_ninlets(ob);
- for (i = 0; i < n; i++)
- sys_vgui(".x%x.c delete %si%d\n",
- glist_getcanvas(glist), tag, i);
-}
-
-void text_eraseborder(t_text *x, t_glist *glist, char *tag)
-{
- if (x->te_type == T_TEXT) return;
- sys_vgui(".x%x.c delete %sR\n",
- glist_getcanvas(glist), tag);
- glist_eraseiofor(glist, x, tag);
-}
-
- /* change text; if T_OBJECT, remake it. LATER we'll have an undo buffer
- which should be filled in here before making the change. */
-
-void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize)
-{
- if (x->te_type == T_OBJECT)
- {
- t_binbuf *b = binbuf_new();
- int natom1, natom2;
- t_atom *vec1, *vec2;
- binbuf_text(b, buf, bufsize);
- natom1 = binbuf_getnatom(x->te_binbuf);
- vec1 = binbuf_getvec(x->te_binbuf);
- natom2 = binbuf_getnatom(b);
- vec2 = binbuf_getvec(b);
- /* special case: if pd args change just pass the message on. */
- if (natom1 >= 1 && natom2 >= 1 && vec1[0].a_type == A_SYMBOL
- && !strcmp(vec1[0].a_w.w_symbol->s_name, "pd") &&
- vec2[0].a_type == A_SYMBOL
- && !strcmp(vec2[0].a_w.w_symbol->s_name, "pd"))
- {
- typedmess(&x->te_pd, gensym("rename"), natom2-1, vec2+1);
- binbuf_free(x->te_binbuf);
- x->te_binbuf = b;
- }
- else /* normally, just destroy the old one and make a new one. */
- {
- int xwas = x->te_xpix, ywas = x->te_ypix;
- glist_delete(glist, &x->te_g);
- canvas_objtext(glist, xwas, ywas, 0, b);
- /* if it's an abstraction loadbang it here */
- if (newest && pd_class(newest) == canvas_class)
- canvas_loadbang((t_canvas *)newest);
- canvas_restoreconnections(glist_getcanvas(glist));
- }
- /* if we made a new "pd" or changed a window name,
- update window list */
- if (natom2 >= 1 && vec2[0].a_type == A_SYMBOL
- && !strcmp(vec2[0].a_w.w_symbol->s_name, "pd"))
- canvas_updatewindowlist();
- }
- else binbuf_text(x->te_binbuf, buf, bufsize);
-}
-
-void g_text_setup(void)
-{
- text_class = class_new(gensym("text"), 0, 0, sizeof(t_text),
- CLASS_NOINLET | CLASS_PATCHABLE, 0);
-
- message_class = class_new(gensym("message"), 0, (t_method)message_free,
- sizeof(t_message), CLASS_PATCHABLE, 0);
- class_addbang(message_class, message_bang);
- class_addfloat(message_class, message_float);
- class_addsymbol(message_class, message_symbol);
- class_addlist(message_class, message_list);
- class_addanything(message_class, message_list);
-
- class_addmethod(message_class, (t_method)message_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(message_class, (t_method)message_set, gensym("set"),
- A_GIMME, 0);
- class_addmethod(message_class, (t_method)message_add, gensym("add"),
- A_GIMME, 0);
- class_addmethod(message_class, (t_method)message_add2, gensym("add2"),
- A_GIMME, 0);
-
- messresponder_class = class_new(gensym("messresponder"), 0, 0,
- sizeof(t_text), CLASS_PD, 0);
- class_addbang(messresponder_class, messresponder_bang);
- class_addfloat(messresponder_class, (t_method) messresponder_float);
- class_addsymbol(messresponder_class, messresponder_symbol);
- class_addlist(messresponder_class, messresponder_list);
- class_addanything(messresponder_class, messresponder_anything);
-
- gatom_class = class_new(gensym("gatom"), 0, (t_method)gatom_free,
- sizeof(t_gatom), CLASS_NOINLET | CLASS_PATCHABLE, 0);
- class_addbang(gatom_class, gatom_bang);
- class_addfloat(gatom_class, gatom_float);
- class_addsymbol(gatom_class, gatom_symbol);
- class_addmethod(gatom_class, (t_method)gatom_set, gensym("set"),
- A_GIMME, 0);
- class_addmethod(gatom_class, (t_method)gatom_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(gatom_class, (t_method)gatom_param, gensym("param"),
- A_GIMME, 0);
- class_setwidget(gatom_class, &gatom_widgetbehavior);
- class_setpropertiesfn(gatom_class, gatom_properties);
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/src/g_toggle.c b/apps/plugins/pdbox/PDa/src/g_toggle.c
index b6bb9f3daf..5a3401ffa8 100644
--- a/apps/plugins/pdbox/PDa/src/g_toggle.c
+++ b/apps/plugins/pdbox/PDa/src/g_toggle.c
@@ -472,477 +472,4 @@ void g_toggle_setup(void)
class_setsavefn(toggle_class, toggle_save);
class_setpropertiesfn(toggle_class, toggle_properties);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-#ifdef MSW
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-/* --------------- tgl gui-toggle ------------------------- */
-
-t_widgetbehavior toggle_widgetbehavior;
-static t_class *toggle_class;
-
-/* widget helper functions */
-void toggle_draw_update(t_toggle *x, t_glist *glist)
-{
- if(glist_isvisible(glist))
- {
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xX1 -fill #%6.6x\n", canvas, x,
- (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x,
- (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol);
- }
-}
-
-void toggle_draw_new(t_toggle *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist);
-
- if(x->x_gui.x_w >= 30)
- w = 2;
- if(x->x_gui.x_w >= 60)
- w = 3;
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
- canvas, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h,
- x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xX1\n",
- canvas, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w, w,
- (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xX2\n",
- canvas, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w, w,
- (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
- canvas, xx+x->x_gui.x_ldx,
- yy+x->x_gui.x_ldy,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
- x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas, xx, yy, xx + IOWIDTH, yy+1, x, 0);
-}
-
-void toggle_draw_move(t_toggle *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist);
-
- if(x->x_gui.x_w >= 30)
- w = 2;
-
- if(x->x_gui.x_w >= 60)
- w = 3;
- sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
- canvas, x, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h);
- sys_vgui(".x%x.c itemconfigure %xX1 -width %d\n", canvas, x, w);
- sys_vgui(".x%x.c coords %xX1 %d %d %d %d\n",
- canvas, x, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w);
- sys_vgui(".x%x.c itemconfigure %xX2 -width %d\n", canvas, x, w);
- sys_vgui(".x%x.c coords %xX2 %d %d %d %d\n",
- canvas, x, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w);
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- canvas, x, xx+x->x_gui.x_ldx, yy+x->x_gui.x_ldy);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
- canvas, x, 0, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
- canvas, x, 0, xx, yy, xx + IOWIDTH, yy+1);
-}
-
-void toggle_draw_erase(t_toggle* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
- sys_vgui(".x%x.c delete %xX1\n", canvas, x);
- sys_vgui(".x%x.c delete %xX2\n", canvas, x);
- sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-void toggle_draw_config(t_toggle* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
- sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x,
- x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xX1 -fill #%6.6x\n", canvas, x,
- x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x,
- x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol);
-}
-
-void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas, xpos,
- ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
- ypos + x->x_gui.x_h, x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas, xpos, ypos,
- xpos + IOWIDTH, ypos+1, x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-void toggle_draw_select(t_toggle* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- if(x->x_gui.x_fsf.x_selected)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- }
- else
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
- }
-}
-
-void toggle_draw(t_toggle *x, t_glist *glist, int mode)
-{
- if(mode == IEM_GUI_DRAW_MODE_UPDATE)
- toggle_draw_update(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_MOVE)
- toggle_draw_move(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_NEW)
- toggle_draw_new(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_SELECT)
- toggle_draw_select(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_ERASE)
- toggle_draw_erase(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
- toggle_draw_config(x, glist);
- else if(mode >= IEM_GUI_DRAW_MODE_IO)
- toggle_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
-}
-
-/* ------------------------ tgl widgetbehaviour----------------------------- */
-
-static void toggle_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_toggle *x = (t_toggle *)z;
-
- *xp1 = text_xpix(&x->x_gui.x_obj, glist);
- *yp1 = text_ypix(&x->x_gui.x_obj, glist);
- *xp2 = *xp1 + x->x_gui.x_w;
- *yp2 = *yp1 + x->x_gui.x_h;
-}
-
-static void toggle_save(t_gobj *z, t_binbuf *b)
-{
- t_toggle *x = (t_toggle *)z;
- int bflcol[3];
- t_symbol *srl[3];
-
- iemgui_save(&x->x_gui, srl, bflcol);
- binbuf_addv(b, "ssiisiisssiiiiiiiff", gensym("#X"),gensym("obj"),
- (t_int)x->x_gui.x_obj.te_xpix,
- (t_int)x->x_gui.x_obj.te_ypix,
- gensym("tgl"), x->x_gui.x_w,
- iem_symargstoint(&x->x_gui.x_isa),
- srl[0], srl[1], srl[2],
- x->x_gui.x_ldx, x->x_gui.x_ldy,
- iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
- bflcol[0], bflcol[1], bflcol[2], x->x_on, x->x_nonzero);
- binbuf_addv(b, ";");
-}
-
-static void toggle_properties(t_gobj *z, t_glist *owner)
-{
- t_toggle *x = (t_toggle *)z;
- char buf[800];
- t_symbol *srl[3];
-
- iemgui_properties(&x->x_gui, srl);
- sprintf(buf, "pdtk_iemgui_dialog %%s TOGGLE \
- ----------dimensions(pix):----------- %d %d size: 0 0 empty \
- -----------non-zero-value:----------- %g value: 0.0 empty %g \
- -1 lin log %d %d empty %d \
- %s %s \
- %s %d %d \
- %d %d \
- %d %d %d\n",
- x->x_gui.x_w, IEM_GUI_MINSIZE,
- x->x_nonzero, 1.0,/*non_zero-schedule*/
- x->x_gui.x_isa.x_loadinit, -1, -1,/*no multi*/
- srl[0]->s_name, srl[1]->s_name,
- srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
- x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
- 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
- gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
-}
-
-static void toggle_bang(t_toggle *x)
-{
- x->x_on = (x->x_on==0.0)?x->x_nonzero:0.0;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_on);
-}
-
-static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *srl[3];
- int a = (int)atom_getintarg(0, argc, argv);
- float nonzero = (float)atom_getfloatarg(2, argc, argv);
- int sr_flags;
-
- if(nonzero == 0.0)
- nonzero = 1.0;
- x->x_nonzero = nonzero;
- if(x->x_on != 0.0)
- x->x_on = x->x_nonzero;
- sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
- x->x_gui.x_w = iemgui_clip_size(a);
- x->x_gui.x_h = x->x_gui.x_w;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
-}
-
-static void toggle_click(t_toggle *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
-{toggle_bang(x);}
-
-static int toggle_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- if(doit)
- toggle_click((t_toggle *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
- return (1);
-}
-
-static void toggle_set(t_toggle *x, t_floatarg f)
-{
- x->x_on = f;
- if(f != 0.0)
- x->x_nonzero = f;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
-}
-
-static void toggle_float(t_toggle *x, t_floatarg f)
-{
- toggle_set(x, f);
- if(x->x_gui.x_fsf.x_put_in2out)
- {
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_on);
- }
-}
-
-static void toggle_fout(t_toggle *x, t_floatarg f)
-{
- toggle_set(x, f);
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_on);
-}
-
-static void toggle_loadbang(t_toggle *x)
-{
- if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
- toggle_fout(x, (float)x->x_on);
-}
-
-static void toggle_size(t_toggle *x, t_symbol *s, int ac, t_atom *av)
-{
- x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
- x->x_gui.x_h = x->x_gui.x_w;
- iemgui_size((void *)x, &x->x_gui);
-}
-
-static void toggle_delta(t_toggle *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
-
-static void toggle_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void toggle_color(t_toggle *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
-
-static void toggle_send(t_toggle *x, t_symbol *s)
-{iemgui_send(x, &x->x_gui, s);}
-
-static void toggle_receive(t_toggle *x, t_symbol *s)
-{iemgui_receive(x, &x->x_gui, s);}
-
-static void toggle_label(t_toggle *x, t_symbol *s)
-{iemgui_label((void *)x, &x->x_gui, s);}
-
-static void toggle_label_font(t_toggle *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
-
-static void toggle_label_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void toggle_init(t_toggle *x, t_floatarg f)
-{
- x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
-}
-
-static void toggle_nonzero(t_toggle *x, t_floatarg f)
-{
- if(f != 0.0)
- x->x_nonzero = f;
-}
-
-static void *toggle_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_toggle *x = (t_toggle *)pd_new(toggle_class);
- int bflcol[]={-262144, -1, -1};
- int a=IEM_GUI_DEFAULTSIZE, f=0;
- int ldx=0, ldy=-6;
- int fs=8;
- float on=0.0, nonzero=1.0;
- char str[144];
-
- iem_inttosymargs(&x->x_gui.x_isa, 0);
- iem_inttofstyle(&x->x_gui.x_fsf, 0);
-
- if(((argc == 13)||(argc == 14))&&IS_A_FLOAT(argv,0)
- &&IS_A_FLOAT(argv,1)
- &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
- &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
- &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
- &&IS_A_FLOAT(argv,5)&&IS_A_FLOAT(argv,6)
- &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)
- &&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12))
- {
- a = (int)atom_getintarg(0, argc, argv);
- iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(1, argc, argv));
- iemgui_new_getnames(&x->x_gui, 2, argv);
- ldx = (int)atom_getintarg(5, argc, argv);
- ldy = (int)atom_getintarg(6, argc, argv);
- iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(7, argc, argv));
- fs = (int)atom_getintarg(8, argc, argv);
- bflcol[0] = (int)atom_getintarg(9, argc, argv);
- bflcol[1] = (int)atom_getintarg(10, argc, argv);
- bflcol[2] = (int)atom_getintarg(11, argc, argv);
- on = (float)atom_getfloatarg(12, argc, argv);
- }
- else iemgui_new_getnames(&x->x_gui, 2, 0);
- if((argc == 14)&&IS_A_FLOAT(argv,13))
- nonzero = (float)atom_getfloatarg(13, argc, argv);
- x->x_gui.x_draw = (t_iemfunptr)toggle_draw;
-
- x->x_gui.x_fsf.x_snd_able = 1;
- x->x_gui.x_fsf.x_rcv_able = 1;
- x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
- if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
- x->x_gui.x_fsf.x_snd_able = 0;
- if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
- x->x_gui.x_fsf.x_rcv_able = 0;
- if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
- else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
- else { x->x_gui.x_fsf.x_font_style = 0;
- strcpy(x->x_gui.x_font, "courier"); }
- x->x_nonzero = (nonzero!=0.0)?nonzero:1.0;
- if(x->x_gui.x_isa.x_loadinit)
- x->x_on = (on!=0.0)?nonzero:0.0;
- else
- x->x_on = 0.0;
- if (x->x_gui.x_fsf.x_rcv_able)
- pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- x->x_gui.x_ldx = ldx;
- x->x_gui.x_ldy = ldy;
-
- if(fs < 4)
- fs = 4;
- x->x_gui.x_fontsize = fs;
- x->x_gui.x_w = iemgui_clip_size(a);
- x->x_gui.x_h = x->x_gui.x_w;
- iemgui_all_colfromload(&x->x_gui, bflcol);
- iemgui_verify_snd_ne_rcv(&x->x_gui);
- outlet_new(&x->x_gui.x_obj, &s_float);
- return (x);
-}
-
-static void toggle_ff(t_toggle *x)
-{
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- gfxstub_deleteforkey(x);
-}
-
-void g_toggle_setup(void)
-{
- toggle_class = class_new(gensym("tgl"), (t_newmethod)toggle_new,
- (t_method)toggle_ff, sizeof(t_toggle), 0, A_GIMME, 0);
- class_addcreator((t_newmethod)toggle_new, gensym("toggle"), A_GIMME, 0);
- class_addbang(toggle_class, toggle_bang);
- class_addfloat(toggle_class, toggle_float);
- class_addmethod(toggle_class, (t_method)toggle_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(toggle_class, (t_method)toggle_dialog, gensym("dialog"),
- A_GIMME, 0);
- class_addmethod(toggle_class, (t_method)toggle_loadbang, gensym("loadbang"), 0);
- class_addmethod(toggle_class, (t_method)toggle_set, gensym("set"), A_FLOAT, 0);
- class_addmethod(toggle_class, (t_method)toggle_size, gensym("size"), A_GIMME, 0);
- class_addmethod(toggle_class, (t_method)toggle_delta, gensym("delta"), A_GIMME, 0);
- class_addmethod(toggle_class, (t_method)toggle_pos, gensym("pos"), A_GIMME, 0);
- class_addmethod(toggle_class, (t_method)toggle_color, gensym("color"), A_GIMME, 0);
- class_addmethod(toggle_class, (t_method)toggle_send, gensym("send"), A_DEFSYM, 0);
- class_addmethod(toggle_class, (t_method)toggle_receive, gensym("receive"), A_DEFSYM, 0);
- class_addmethod(toggle_class, (t_method)toggle_label, gensym("label"), A_DEFSYM, 0);
- class_addmethod(toggle_class, (t_method)toggle_label_pos, gensym("label_pos"), A_GIMME, 0);
- class_addmethod(toggle_class, (t_method)toggle_label_font, gensym("label_font"), A_GIMME, 0);
- class_addmethod(toggle_class, (t_method)toggle_init, gensym("init"), A_FLOAT, 0);
- class_addmethod(toggle_class, (t_method)toggle_nonzero, gensym("nonzero"), A_FLOAT, 0);
- toggle_widgetbehavior.w_getrectfn = toggle_getrect;
- toggle_widgetbehavior.w_displacefn = iemgui_displace;
- toggle_widgetbehavior.w_selectfn = iemgui_select;
- toggle_widgetbehavior.w_activatefn = NULL;
- toggle_widgetbehavior.w_deletefn = iemgui_delete;
- toggle_widgetbehavior.w_visfn = iemgui_vis;
- toggle_widgetbehavior.w_clickfn = toggle_newclick;
- class_setwidget(toggle_class, &toggle_widgetbehavior);
- class_sethelpsymbol(toggle_class, gensym("toggle"));
- class_setsavefn(toggle_class, toggle_save);
- class_setpropertiesfn(toggle_class, toggle_properties);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_traversal.c b/apps/plugins/pdbox/PDa/src/g_traversal.c
index 2a34f5c1e6..0e2c6855b4 100644
--- a/apps/plugins/pdbox/PDa/src/g_traversal.c
+++ b/apps/plugins/pdbox/PDa/src/g_traversal.c
@@ -1082,1087 +1082,4 @@ void g_traversal_setup(void)
append_setup();
sublist_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* This file defines Text objects which traverse data contained in scalars
-and arrays:
-
-pointer - point to an object belonging to a template
-get - get numeric fields
-set - change numeric fields
-element - get an array element
-getsize - get the size of an array
-setsize - change the size of an array
-append - add an element to a list
-sublist - get a pointer into a list which is an element of another scalar
-
-*/
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h> /* for read/write to files */
-#include "m_pd.h"
-#include "g_canvas.h"
-
-/* ------------- gstubs and gpointers - safe pointing --------------- */
-
-/* create a gstub which is "owned" by a glist (gl) or an array ("a"). */
-
-t_gstub *gstub_new(t_glist *gl, t_array *a)
-{
- t_gstub *gs = t_getbytes(sizeof(*gs));
- if (gl)
- {
- gs->gs_which = GP_GLIST;
- gs->gs_un.gs_glist = gl;
- }
- else
- {
- gs->gs_which = GP_ARRAY;
- gs->gs_un.gs_array = a;
- }
- gs->gs_refcount = 0;
- return (gs);
-}
-
-/* when a "gpointer" is set to point to this stub (so we can later chase
-down the owner) we increase a reference count. The following routine is called
-whenever a gpointer is unset from pointing here. If the owner is
-gone and the refcount goes to zero, we can free the gstub safely. */
-
-static void gstub_dis(t_gstub *gs)
-{
- int refcount = --gs->gs_refcount;
- if ((!refcount) && gs->gs_which == GP_NONE)
- t_freebytes(gs, sizeof (*gs));
- else if (refcount < 0) bug("gstub_dis");
-}
-
-/* this routing is called by the owner to inform the gstub that it is
-being deleted. If no gpointers are pointing here, we can free the gstub;
-otherwise we wait for the last gstub_dis() to free it. */
-
-void gstub_cutoff(t_gstub *gs)
-{
- gs->gs_which = GP_NONE;
- if (gs->gs_refcount < 0) bug("gstub_cutoff");
- if (!gs->gs_refcount) t_freebytes(gs, sizeof (*gs));
-}
-
-/* call this to verify that a pointer is fresh, i.e., that it either
-points to real data or to the head of a list, and that in either case
-the object hasn't disappeared since this pointer was generated.
-Unless "headok" is set, the routine also fails for the head of a list. */
-
-int gpointer_check(const t_gpointer *gp, int headok)
-{
- t_gstub *gs = gp->gp_stub;
- if (!gs) return (0);
- if (gs->gs_which == GP_ARRAY)
- {
- if (gs->gs_un.gs_array->a_valid != gp->gp_valid) return (0);
- else return (1);
- }
- else if (gs->gs_which == GP_GLIST)
- {
- if (!headok && !gp->gp_un.gp_scalar) return (0);
- else if (gs->gs_un.gs_glist->gl_valid != gp->gp_valid) return (0);
- else return (1);
- }
- else return (0);
-}
-
-/* call this if you know the pointer is fresh but don't know if we're pointing
-to the head of a list or to real data. Any pointer is known to be fresh
-when it appears as the argument of a message, but if your "pointer" method
-or inlet stores it and you use it later, call gpointer_check above. */
-
-/* LATER reconsider the above... I no longer think it's true! */
-
-static int gpointer_ishead(const t_gpointer *gp)
-{
- return ((gp->gp_stub->gs_which == GP_GLIST) && !gp->gp_un.gp_scalar);
-}
-
-/* get the template for the object pointer to. Assumes we've already checked
-freshness. Returns 0 if head of list. */
-
-static t_symbol *gpointer_gettemplatesym(const t_gpointer *gp)
-{
- t_gstub *gs = gp->gp_stub;
- if (gs->gs_which == GP_GLIST)
- {
- t_scalar *sc = gp->gp_un.gp_scalar;
- if (sc)
- return (sc->sc_template);
- else return (0);
- }
- else
- {
- t_array *a = gs->gs_un.gs_array;
- return (a->a_templatesym);
- }
-}
-
- /* copy a pointer to another, assuming the first one is fresh and
- the second one hasn't yet been initialized. */
-void gpointer_copy(const t_gpointer *gpfrom, t_gpointer *gpto)
-{
- *gpto = *gpfrom;
- if (gpto->gp_stub)
- gpto->gp_stub->gs_refcount++;
- else bug("gpointer_copy");
-}
-
-void gpointer_unset(t_gpointer *gp)
-{
- t_gstub *gs;
- if (gs = gp->gp_stub)
- {
- gstub_dis(gs);
- gp->gp_stub = 0;
- }
-}
-
-void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x)
-{
- t_gstub *gs;
- if (gs = gp->gp_stub) gstub_dis(gs);
- gp->gp_stub = gs = glist->gl_stub;
- gp->gp_valid = glist->gl_valid;
- gp->gp_un.gp_scalar = x;
- gs->gs_refcount++;
-}
-
-static void gpointer_setarray(t_gpointer *gp, t_array *array, t_word *w)
-{
- t_gstub *gs;
- if (gs = gp->gp_stub) gstub_dis(gs);
- gp->gp_stub = gs = array->a_stub;
- gp->gp_valid = array->a_valid;
- gp->gp_un.gp_w = w;
- gs->gs_refcount++;
-}
-
-void gpointer_init(t_gpointer *gp)
-{
- gp->gp_stub = 0;
- gp->gp_valid = 0;
- gp->gp_un.gp_scalar = 0;
-}
-
-/* ---------------------- pointers ----------------------------- */
-
-static t_class *ptrobj_class;
-
-typedef struct
-{
- t_symbol *to_type;
- t_outlet *to_outlet;
-} t_typedout;
-
-typedef struct _ptrobj
-{
- t_object x_obj;
- t_gpointer x_gp;
- t_typedout *x_typedout;
- int x_ntypedout;
- t_outlet *x_otherout;
- t_outlet *x_bangout;
-} t_ptrobj;
-
-static void *ptrobj_new(t_symbol *classname, int argc, t_atom *argv)
-{
- t_ptrobj *x = (t_ptrobj *)pd_new(ptrobj_class);
- t_typedout *to;
- int n;
- gpointer_init(&x->x_gp);
- x->x_typedout = to = (t_typedout *)getbytes(argc * sizeof (*to));
- x->x_ntypedout = n = argc;
- for (; n--; to++)
- {
- to->to_outlet = outlet_new(&x->x_obj, &s_pointer);
- to->to_type = canvas_makebindsym(atom_getsymbol(argv++));
- }
- x->x_otherout = outlet_new(&x->x_obj, &s_pointer);
- x->x_bangout = outlet_new(&x->x_obj, &s_bang);
- pointerinlet_new(&x->x_obj, &x->x_gp);
- return (x);
-}
-
-static void ptrobj_traverse(t_ptrobj *x, t_symbol *s)
-{
- t_glist *glist = (t_glist *)pd_findbyclass(s, canvas_class);
- if (glist) gpointer_setglist(&x->x_gp, glist, 0);
- else pd_error(x, "pointer: list '%s' not found", s->s_name);
-}
-
-static void ptrobj_vnext(t_ptrobj *x, float f)
-{
- t_gobj *gobj;
- t_gpointer *gp = &x->x_gp;
- t_gstub *gs = gp->gp_stub;
- t_glist *glist;
- int wantselected = (f != 0);
-
- if (!gs)
- {
- pd_error(x, "ptrobj_next: no current pointer");
- return;
- }
- if (gs->gs_which != GP_GLIST)
- {
- pd_error(x, "ptrobj_next: lists only, not arrays");
- return;
- }
- glist = gs->gs_un.gs_glist;
- if (glist->gl_valid != gp->gp_valid)
- {
- pd_error(x, "ptrobj_next: stale pointer");
- return;
- }
- if (wantselected && !glist_isvisible(glist))
- {
- pd_error(x,
- "ptrobj_vnext: next-selected only works for a visible window");
- return;
- }
- gobj = &gp->gp_un.gp_scalar->sc_gobj;
-
- if (!gobj) gobj = glist->gl_list;
- else gobj = gobj->g_next;
- while (gobj && ((pd_class(&gobj->g_pd) != scalar_class) ||
- (wantselected && !glist_isselected(glist, gobj))))
- gobj = gobj->g_next;
-
- if (gobj)
- {
- t_typedout *to;
- int n;
- t_scalar *sc = (t_scalar *)gobj;
- t_symbol *templatesym = sc->sc_template;
-
- gp->gp_un.gp_scalar = sc;
- for (n = x->x_ntypedout, to = x->x_typedout; n--; to++)
- {
- if (to->to_type == templatesym)
- {
- outlet_pointer(to->to_outlet, &x->x_gp);
- return;
- }
- }
- outlet_pointer(x->x_otherout, &x->x_gp);
- }
- else
- {
- gpointer_unset(gp);
- outlet_bang(x->x_bangout);
- }
-}
-
-static void ptrobj_next(t_ptrobj *x)
-{
- ptrobj_vnext(x, 0);
-}
-
-static void ptrobj_sendwindow(t_ptrobj *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_scalar *sc;
- t_symbol *templatesym;
- int n;
- t_typedout *to;
- t_glist *glist;
- t_pd *canvas;
- t_gstub *gs;
- if (!gpointer_check(&x->x_gp, 1))
- {
- pd_error(x, "ptrobj_bang: empty pointer");
- return;
- }
- gs = x->x_gp.gp_stub;
- if (gs->gs_which == GP_GLIST)
- glist = gs->gs_un.gs_glist;
- else
- {
- t_array *owner_array = gs->gs_un.gs_array;
- while (owner_array->a_gp.gp_stub->gs_which == GP_ARRAY)
- owner_array = owner_array->a_gp.gp_stub->gs_un.gs_array;
- glist = owner_array->a_gp.gp_stub->gs_un.gs_glist;
- }
- canvas = (t_pd *)glist_getcanvas(glist);
- if (argc && argv->a_type == A_SYMBOL)
- pd_typedmess(canvas, argv->a_w.w_symbol, argc-1, argv+1);
- else pd_error(x, "send-window: no message?");
-}
-
-static void ptrobj_bang(t_ptrobj *x)
-{
- t_symbol *templatesym;
- int n;
- t_typedout *to;
- if (!gpointer_check(&x->x_gp, 1))
- {
- pd_error(x, "ptrobj_bang: empty pointer");
- return;
- }
- templatesym = gpointer_gettemplatesym(&x->x_gp);
- for (n = x->x_ntypedout, to = x->x_typedout; n--; to++)
- {
- if (to->to_type == templatesym)
- {
- outlet_pointer(to->to_outlet, &x->x_gp);
- return;
- }
- }
- outlet_pointer(x->x_otherout, &x->x_gp);
-}
-
-
-static void ptrobj_pointer(t_ptrobj *x, t_gpointer *gp)
-{
- gpointer_unset(&x->x_gp);
- gpointer_copy(gp, &x->x_gp);
- ptrobj_bang(x);
-}
-
-static void ptrobj_free(t_ptrobj *x)
-{
- freebytes(x->x_typedout, x->x_ntypedout * sizeof (*x->x_typedout));
- gpointer_unset(&x->x_gp);
-}
-
-static void ptrobj_setup(void)
-{
- ptrobj_class = class_new(gensym("pointer"), (t_newmethod)ptrobj_new,
- (t_method)ptrobj_free, sizeof(t_ptrobj), 0, A_GIMME, 0);
- class_addmethod(ptrobj_class, (t_method)ptrobj_traverse, gensym("traverse"),
- A_SYMBOL, 0);
- class_addmethod(ptrobj_class, (t_method)ptrobj_next, gensym("next"), 0);
- class_addmethod(ptrobj_class, (t_method)ptrobj_vnext, gensym("vnext"),
- A_DEFFLOAT, 0);
- class_addmethod(ptrobj_class, (t_method)ptrobj_sendwindow,
- gensym("send-window"), A_GIMME, 0);
- class_addpointer(ptrobj_class, ptrobj_pointer);
- class_addbang(ptrobj_class, ptrobj_bang);
-}
-
-/* ---------------------- get ----------------------------- */
-
-static t_class *get_class;
-
-typedef struct _getvariable
-{
- t_symbol *gv_sym;
- t_outlet *gv_outlet;
-} t_getvariable;
-
-typedef struct _get
-{
- t_object x_obj;
- t_symbol *x_templatesym;
- int x_nout;
- t_getvariable *x_variables;
-} t_get;
-
-static void *get_new(t_symbol *why, int argc, t_atom *argv)
-{
- t_get *x = (t_get *)pd_new(get_class);
- int i;
- t_getvariable *sp;
- x->x_templatesym = canvas_makebindsym(atom_getsymbolarg(0, argc, argv));
- if (argc) argc--, argv++;
- x->x_variables
- = (t_getvariable *)getbytes(argc * sizeof (*x->x_variables));
- x->x_nout = argc;
- for (i = 0, sp = x->x_variables; i < argc; i++, sp++)
- {
- sp->gv_sym = atom_getsymbolarg(i, argc, argv);
- sp->gv_outlet = outlet_new(&x->x_obj, 0);
- /* LATER connect with the template and set the outlet's type
- correctly. We can't yet guarantee that the template is there
- before we hit this routine. */
- }
- return (x);
-}
-static void get_pointer(t_get *x, t_gpointer *gp)
-{
- int nitems = x->x_nout, i;
- t_symbol *templatesym = x->x_templatesym;
- t_template *template = template_findbyname(templatesym);
- t_gstub *gs = gp->gp_stub;
- t_word *vec;
- t_getvariable *vp;
- if (!template)
- {
- pd_error(x, "get: couldn't find template %s", templatesym->s_name);
- return;
- }
- if (gpointer_ishead(gp))
- {
- pd_error(x, "get: empty pointer");
- return;
- }
- if (gs->gs_which == GP_ARRAY) vec = gp->gp_un.gp_w;
- else vec = gp->gp_un.gp_scalar->sc_vec;
- for (i = nitems - 1, vp = x->x_variables + i; i >= 0; i--, vp--)
- {
- float f = template_getfloat(template, vp->gv_sym, vec, 1);
- outlet_float(vp->gv_outlet, f);
- /* LATER deal with other types. */
- }
-}
-
-static void get_free(t_get *x)
-{
- freebytes(x->x_variables, x->x_nout * sizeof (*x->x_variables));
-}
-
-static void get_setup(void)
-{
- get_class = class_new(gensym("get"), (t_newmethod)get_new,
- (t_method)get_free, sizeof(t_get), 0, A_GIMME, 0);
- class_addpointer(get_class, get_pointer);
-}
-
-/* ---------------------- set ----------------------------- */
-
-static t_class *set_class;
-
-typedef struct _setvariable
-{
- t_symbol *gv_sym;
- t_float gv_f; /* LATER take other types */
-} t_setvariable;
-
-typedef struct _set
-{
- t_object x_obj;
- t_gpointer x_gp;
- t_symbol *x_templatesym;
- int x_nin;
- t_setvariable *x_variables;
-} t_set;
-
-static void *set_new(t_symbol *why, int argc, t_atom *argv)
-{
- t_set *x = (t_set *)pd_new(set_class);
- int i;
- t_setvariable *sp;
- x->x_templatesym = canvas_makebindsym(atom_getsymbolarg(0, argc, argv));
- if (argc) argc--, argv++;
- x->x_variables
- = (t_setvariable *)getbytes(argc * sizeof (*x->x_variables));
- x->x_nin = argc;
- if (argc)
- {
- for (i = 0, sp = x->x_variables; i < argc; i++, sp++)
- {
- sp->gv_sym = atom_getsymbolarg(i, argc, argv);
- sp->gv_f = 0;
- if (i) floatinlet_new(&x->x_obj, &sp->gv_f);
- /* LATER figure out type as in "get" object. */
- }
- }
- pointerinlet_new(&x->x_obj, &x->x_gp);
- gpointer_init(&x->x_gp);
- return (x);
-}
-
-static void set_float(t_set *x, t_float f)
-{
- int nitems = x->x_nin, i;
- t_symbol *templatesym = x->x_templatesym;
- t_template *template = template_findbyname(templatesym);
- t_setvariable *vp;
- t_gpointer *gp = &x->x_gp;
- t_gstub *gs = gp->gp_stub;
- t_word *vec;
- if (!template)
- {
- pd_error(x, "set: couldn't find template %s", templatesym->s_name);
- return;
- }
- if (!gpointer_check(gp, 0))
- {
- pd_error(x, "set: empty pointer");
- return;
- }
- if (gpointer_gettemplatesym(gp) != x->x_templatesym)
- {
- pd_error(x, "set %s: got wrong template (%s)",
- x->x_templatesym->s_name, gpointer_gettemplatesym(gp)->s_name);
- return;
- }
- if (!nitems) return;
- x->x_variables[0].gv_f = f;
- if (gs->gs_which == GP_ARRAY) vec = gp->gp_un.gp_w;
- else vec = gp->gp_un.gp_scalar->sc_vec;
- for (i = 0, vp = x->x_variables; i < nitems; i++, vp++)
- {
- template_setfloat(template, vp->gv_sym, vec, vp->gv_f, 1);
- /* LATER deal with other types ala get_pointer. */
- }
- if (gs->gs_which == GP_GLIST)
- glist_redrawitem(gs->gs_un.gs_glist, (t_gobj *)(gp->gp_un.gp_scalar));
- else
- {
- t_array *owner_array = gs->gs_un.gs_array;
- while (owner_array->a_gp.gp_stub->gs_which == GP_ARRAY)
- owner_array = owner_array->a_gp.gp_stub->gs_un.gs_array;
- glist_redrawitem(owner_array->a_gp.gp_stub->gs_un.gs_glist,
- (t_gobj *)(owner_array->a_gp.gp_un.gp_scalar));
- }
-}
-
-static void set_free(t_set *x)
-{
- freebytes(x->x_variables, x->x_nin * sizeof (*x->x_variables));
- gpointer_unset(&x->x_gp);
-}
-
-static void set_setup(void)
-{
- set_class = class_new(gensym("set"), (t_newmethod)set_new,
- (t_method)set_free, sizeof(t_set), 0, A_GIMME, 0);
- class_addfloat(set_class, set_float);
-}
-
-/* ---------------------- elem ----------------------------- */
-
-static t_class *elem_class;
-
-typedef struct _elem
-{
- t_object x_obj;
- t_symbol *x_templatesym;
- t_symbol *x_fieldsym;
- t_gpointer x_gp;
- t_gpointer x_gparent;
-} t_elem;
-
-static void *elem_new(t_symbol *templatesym, t_symbol *fieldsym)
-{
- t_elem *x = (t_elem *)pd_new(elem_class);
- x->x_templatesym = canvas_makebindsym(templatesym);
- x->x_fieldsym = fieldsym;
- gpointer_init(&x->x_gp);
- gpointer_init(&x->x_gparent);
- pointerinlet_new(&x->x_obj, &x->x_gparent);
- outlet_new(&x->x_obj, &s_pointer);
- return (x);
-}
-
-static void elem_float(t_elem *x, t_float f)
-{
- int indx = f, nitems, onset;
- t_symbol *templatesym = x->x_templatesym, *fieldsym = x->x_fieldsym,
- *elemtemplatesym;
- t_template *template = template_findbyname(templatesym);
- t_template *elemtemplate;
- t_gpointer *gparent = &x->x_gparent;
- t_word *w;
- t_array *array;
- int elemsize, type;
-
- if (!gpointer_check(gparent, 0))
- {
- pd_error(x, "element: empty pointer");
- return;
- }
- if (gpointer_gettemplatesym(gparent) != x->x_templatesym)
- {
- pd_error(x, "element %s: got wrong template (%s)",
- x->x_templatesym->s_name, gpointer_gettemplatesym(gparent)->s_name);
- return;
- }
- if (gparent->gp_stub->gs_which == GP_ARRAY) w = gparent->gp_un.gp_w;
- else w = gparent->gp_un.gp_scalar->sc_vec;
- if (!template)
- {
- pd_error(x, "element: couldn't find template %s", templatesym->s_name);
- return;
- }
- if (!template_find_field(template, fieldsym,
- &onset, &type, &elemtemplatesym))
- {
- pd_error(x, "element: couldn't find array field %s", fieldsym->s_name);
- return;
- }
- if (type != DT_ARRAY)
- {
- pd_error(x, "element: field %s not of type array", fieldsym->s_name);
- return;
- }
- if (!(elemtemplate = template_findbyname(elemtemplatesym)))
- {
- pd_error(x, "element: couldn't find field template %s",
- elemtemplatesym->s_name);
- return;
- }
-
- elemsize = elemtemplate->t_n * sizeof(t_word);
-
- array = *(t_array **)(((char *)w) + onset);
-
- nitems = array->a_n;
- if (indx < 0) indx = 0;
- if (indx >= nitems) indx = nitems-1;
-
- gpointer_setarray(&x->x_gp, array,
- (t_word *)((char *)(array->a_vec) + indx * elemsize));
- outlet_pointer(x->x_obj.ob_outlet, &x->x_gp);
-}
-
-static void elem_free(t_elem *x, t_gpointer *gp)
-{
- gpointer_unset(&x->x_gp);
- gpointer_unset(&x->x_gparent);
-}
-
-static void elem_setup(void)
-{
- elem_class = class_new(gensym("element"), (t_newmethod)elem_new,
- (t_method)elem_free, sizeof(t_elem), 0, A_DEFSYM, A_DEFSYM, 0);
- class_addfloat(elem_class, elem_float);
-}
-
-/* ---------------------- getsize ----------------------------- */
-
-static t_class *getsize_class;
-
-typedef struct _getsize
-{
- t_object x_obj;
- t_symbol *x_templatesym;
- t_symbol *x_fieldsym;
-} t_getsize;
-
-static void *getsize_new(t_symbol *templatesym, t_symbol *fieldsym)
-{
- t_getsize *x = (t_getsize *)pd_new(getsize_class);
- x->x_templatesym = canvas_makebindsym(templatesym);
- x->x_fieldsym = fieldsym;
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-static void getsize_pointer(t_getsize *x, t_gpointer *gp)
-{
- int nitems, onset, type;
- t_symbol *templatesym = x->x_templatesym, *fieldsym = x->x_fieldsym,
- *elemtemplatesym;
- t_template *template = template_findbyname(templatesym);
- t_word *w;
- t_array *array;
- int elemsize;
- t_gstub *gs = gp->gp_stub;
- if (!template)
- {
- pd_error(x, "getsize: couldn't find template %s", templatesym->s_name);
- return;
- }
- if (!template_find_field(template, fieldsym,
- &onset, &type, &elemtemplatesym))
- {
- pd_error(x, "getsize: couldn't find array field %s", fieldsym->s_name);
- return;
- }
- if (type != DT_ARRAY)
- {
- pd_error(x, "getsize: field %s not of type array", fieldsym->s_name);
- return;
- }
- if (gpointer_ishead(gp))
- {
- pd_error(x, "getsize: empty pointer");
- return;
- }
- if (gpointer_gettemplatesym(gp) != x->x_templatesym)
- {
- pd_error(x, "getsize %s: got wrong template (%s)",
- x->x_templatesym->s_name, gpointer_gettemplatesym(gp)->s_name);
- return;
- }
- if (gs->gs_which == GP_ARRAY) w = gp->gp_un.gp_w;
- else w = gp->gp_un.gp_scalar->sc_vec;
-
- array = *(t_array **)(((char *)w) + onset);
- outlet_float(x->x_obj.ob_outlet, (float)(array->a_n));
-}
-
-static void getsize_setup(void)
-{
- getsize_class = class_new(gensym("getsize"), (t_newmethod)getsize_new, 0,
- sizeof(t_getsize), 0, A_DEFSYM, A_DEFSYM, 0);
- class_addpointer(getsize_class, getsize_pointer);
-}
-
-/* ---------------------- setsize ----------------------------- */
-
-static t_class *setsize_class;
-
-typedef struct _setsize
-{
- t_object x_obj;
- t_symbol *x_templatesym;
- t_symbol *x_fieldsym;
- t_gpointer x_gp;
-} t_setsize;
-
-static void *setsize_new(t_symbol *templatesym, t_symbol *fieldsym,
- t_floatarg newsize)
-{
- t_setsize *x = (t_setsize *)pd_new(setsize_class);
- x->x_templatesym = canvas_makebindsym(templatesym);
- x->x_fieldsym = fieldsym;
- gpointer_init(&x->x_gp);
-
- pointerinlet_new(&x->x_obj, &x->x_gp);
- return (x);
-}
-
-static void setsize_float(t_setsize *x, t_float f)
-{
- int nitems, onset, type;
- t_symbol *templatesym = x->x_templatesym, *fieldsym = x->x_fieldsym,
- *elemtemplatesym;
- t_template *template = template_findbyname(templatesym);
- t_template *elemtemplate;
- t_word *w;
- t_atom at;
- t_array *array;
- int elemsize;
- int newsize = f;
- t_gpointer *gp = &x->x_gp;
- t_gstub *gs = gp->gp_stub;
- if (!gpointer_check(&x->x_gp, 0))
- {
- pd_error(x, "setsize: empty pointer");
- return;
- }
- if (gpointer_gettemplatesym(&x->x_gp) != x->x_templatesym)
- {
- pd_error(x, "setsize %s: got wrong template (%s)",
- x->x_templatesym->s_name,
- gpointer_gettemplatesym(&x->x_gp)->s_name);
- return;
- }
- if (gs->gs_which == GP_ARRAY) w = gp->gp_un.gp_w;
- else w = gp->gp_un.gp_scalar->sc_vec;
-
- if (!template)
- {
- pd_error(x,"setsize: couldn't find template %s", templatesym->s_name);
- return;
- }
- if (!template_find_field(template, fieldsym,
- &onset, &type, &elemtemplatesym))
- {
- pd_error(x,"setsize: couldn't find array field %s", fieldsym->s_name);
- return;
- }
- if (type != DT_ARRAY)
- {
- pd_error(x,"setsize: field %s not of type array", fieldsym->s_name);
- return;
- }
-
- if (!(elemtemplate = template_findbyname(elemtemplatesym)))
- {
- pd_error(x,"element: couldn't find field template %s",
- elemtemplatesym->s_name);
- return;
- }
-
- elemsize = elemtemplate->t_n * sizeof(t_word);
-
- array = *(t_array **)(((char *)w) + onset);
-
- if (elemsize != array->a_elemsize) bug("setsize_gpointer");
-
- nitems = array->a_n;
- if (newsize < 1) newsize = 1;
- if (newsize == nitems) return;
-
- /* erase the array before resizing it. If we belong to a
- scalar it's easy, but if we belong to an element of another
- array we have to search back until we get to a scalar to erase.
- When graphics updates become queueable this may fall apart... */
-
-
- if (gs->gs_which == GP_GLIST)
- {
- if (glist_isvisible(gs->gs_un.gs_glist))
- gobj_vis((t_gobj *)(gp->gp_un.gp_scalar), gs->gs_un.gs_glist, 0);
- }
- else
- {
- t_array *owner_array = gs->gs_un.gs_array;
- while (owner_array->a_gp.gp_stub->gs_which == GP_ARRAY)
- owner_array = owner_array->a_gp.gp_stub->gs_un.gs_array;
- if (glist_isvisible(owner_array->a_gp.gp_stub->gs_un.gs_glist))
- gobj_vis((t_gobj *)(owner_array->a_gp.gp_un.gp_scalar),
- owner_array->a_gp.gp_stub->gs_un.gs_glist, 0);
- }
- /* now do the resizing and, if growing, initialize new scalars */
- array->a_vec = (char *)resizebytes(array->a_vec,
- elemsize * nitems, elemsize * newsize);
- array->a_n = newsize;
- if (newsize > nitems)
- {
- char *newelem = ((char *)array->a_vec) + nitems * elemsize;
- int i = 0, nnew = newsize - nitems;
-
- while (nnew--)
- {
- word_init((t_word *)newelem, elemtemplate, gp);
- newelem += elemsize;
- /* post("new %x %x, ntypes %d", newelem, *(int *)newelem, ntypes); */
- }
- }
-
- /* redraw again. */
- if (gs->gs_which == GP_GLIST)
- {
- if (glist_isvisible(gs->gs_un.gs_glist))
- gobj_vis((t_gobj *)(gp->gp_un.gp_scalar), gs->gs_un.gs_glist, 1);
- }
- else
- {
- t_array *owner_array = gs->gs_un.gs_array;
- while (owner_array->a_gp.gp_stub->gs_which == GP_ARRAY)
- owner_array = owner_array->a_gp.gp_stub->gs_un.gs_array;
- if (glist_isvisible(owner_array->a_gp.gp_stub->gs_un.gs_glist))
- gobj_vis((t_gobj *)(owner_array->a_gp.gp_un.gp_scalar),
- owner_array->a_gp.gp_stub->gs_un.gs_glist, 1);
- }
-}
-
-
-static void setsize_free(t_setsize *x)
-{
- gpointer_unset(&x->x_gp);
-}
-
-static void setsize_setup(void)
-{
- setsize_class = class_new(gensym("setsize"), (t_newmethod)setsize_new,
- (t_method)setsize_free, sizeof(t_setsize), 0,
- A_DEFSYM, A_DEFSYM, A_DEFFLOAT, 0);
- class_addfloat(setsize_class, setsize_float);
-}
-
-/* ---------------------- append ----------------------------- */
-
-static t_class *append_class;
-
-typedef struct _appendvariable
-{
- t_symbol *gv_sym;
- t_float gv_f;
-} t_appendvariable;
-
-typedef struct _append
-{
- t_object x_obj;
- t_gpointer x_gp;
- t_symbol *x_templatesym;
- int x_nin;
- t_appendvariable *x_variables;
-} t_append;
-
-static void *append_new(t_symbol *why, int argc, t_atom *argv)
-{
- t_append *x = (t_append *)pd_new(append_class);
- int i;
- t_appendvariable *sp;
- x->x_templatesym = canvas_makebindsym(atom_getsymbolarg(0, argc, argv));
- if (argc) argc--, argv++;
- x->x_variables
- = (t_appendvariable *)getbytes(argc * sizeof (*x->x_variables));
- x->x_nin = argc;
- if (argc)
- {
- for (i = 0, sp = x->x_variables; i < argc; i++, sp++)
- {
- sp->gv_sym = atom_getsymbolarg(i, argc, argv);
- sp->gv_f = 0;
- if (i) floatinlet_new(&x->x_obj, &sp->gv_f);
- }
- }
- pointerinlet_new(&x->x_obj, &x->x_gp);
- outlet_new(&x->x_obj, &s_pointer);
- gpointer_init(&x->x_gp);
- return (x);
-}
-
-static void append_float(t_append *x, t_float f)
-{
- int nitems = x->x_nin, i;
- t_symbol *templatesym = x->x_templatesym;
- t_template *template = template_findbyname(templatesym);
- t_appendvariable *vp;
- t_gpointer *gp = &x->x_gp;
- t_gstub *gs = gp->gp_stub;
- t_word *vec;
- t_scalar *sc, *oldsc;
- t_glist *glist;
- if (!template)
- {
- pd_error(x, "append: couldn't find template %s", templatesym->s_name);
- return;
- }
- if (!gs)
- {
- pd_error(x, "append: no current pointer");
- return;
- }
- if (gs->gs_which != GP_GLIST)
- {
- pd_error(x, "append: lists only, not arrays");
- return;
- }
- glist = gs->gs_un.gs_glist;
- if (glist->gl_valid != gp->gp_valid)
- {
- pd_error(x, "append: stale pointer");
- return;
- }
- if (!nitems) return;
- x->x_variables[0].gv_f = f;
-
- sc = scalar_new(glist, templatesym);
- if (!sc)
- {
- pd_error(x, "%s: couldn't create scalar", templatesym->s_name);
- return;
- }
- oldsc = gp->gp_un.gp_scalar;
-
- if (oldsc)
- {
- sc->sc_gobj.g_next = oldsc->sc_gobj.g_next;
- oldsc->sc_gobj.g_next = &sc->sc_gobj;
- }
- else
- {
- sc->sc_gobj.g_next = glist->gl_list;
- glist->gl_list = &sc->sc_gobj;
- }
- if (glist_isvisible(glist_getcanvas(glist)))
- gobj_vis(&sc->sc_gobj, glist, 1);
-
- gp->gp_un.gp_scalar = sc;
- vec = sc->sc_vec;
- for (i = 0, vp = x->x_variables; i < nitems; i++, vp++)
- {
- template_setfloat(template, vp->gv_sym, vec, vp->gv_f, 1);
- }
-
- glist_redrawitem(glist, (t_gobj *)sc);
-
- outlet_pointer(x->x_obj.ob_outlet, gp);
-}
-
-static void append_free(t_append *x)
-{
- freebytes(x->x_variables, x->x_nin * sizeof (*x->x_variables));
- gpointer_unset(&x->x_gp);
-}
-
-static void append_setup(void)
-{
- append_class = class_new(gensym("append"), (t_newmethod)append_new,
- (t_method)append_free, sizeof(t_append), 0, A_GIMME, 0);
- class_addfloat(append_class, append_float);
-}
-
-/* ---------------------- sublist ----------------------------- */
-
-static t_class *sublist_class;
-
-typedef struct _sublist
-{
- t_object x_obj;
- t_symbol *x_templatesym;
- t_symbol *x_fieldsym;
- t_gpointer x_gp;
-} t_sublist;
-
-static void *sublist_new(t_symbol *templatesym, t_symbol *fieldsym)
-{
- t_sublist *x = (t_sublist *)pd_new(sublist_class);
- x->x_templatesym = canvas_makebindsym(templatesym);
- x->x_fieldsym = fieldsym;
- gpointer_init(&x->x_gp);
- outlet_new(&x->x_obj, &s_pointer);
- return (x);
-}
-
-static void sublist_pointer(t_sublist *x, t_gpointer *gp)
-{
- t_symbol *templatesym = x->x_templatesym, *dummy;
- t_template *template = template_findbyname(templatesym);
- t_gstub *gs = gp->gp_stub;
- t_word *vec;
- t_getvariable *vp;
- int onset, type;
- t_word *w;
-
- if (!template)
- {
- pd_error(x, "sublist: couldn't find template %s", templatesym->s_name);
- return;
- }
- if (gpointer_ishead(gp))
- {
- pd_error(x, "sublist: empty pointer");
- return;
- }
- if (!template_find_field(template, x->x_fieldsym,
- &onset, &type, &dummy))
- {
- pd_error(x, "sublist: couldn't find field %s", x->x_fieldsym->s_name);
- return;
- }
- if (type != DT_LIST)
- {
- pd_error(x, "sublist: field %s not of type list", x->x_fieldsym->s_name);
- return;
- }
- if (gs->gs_which == GP_ARRAY) w = gp->gp_un.gp_w;
- else w = gp->gp_un.gp_scalar->sc_vec;
-
- gpointer_setglist(&x->x_gp, *(t_glist **)(((char *)w) + onset), 0);
-
- outlet_pointer(x->x_obj.ob_outlet, &x->x_gp);
-}
-
-static void sublist_free(t_sublist *x, t_gpointer *gp)
-{
- gpointer_unset(&x->x_gp);
-}
-
-static void sublist_setup(void)
-{
- sublist_class = class_new(gensym("sublist"), (t_newmethod)sublist_new,
- (t_method)sublist_free, sizeof(t_sublist), 0, A_DEFSYM, A_DEFSYM, 0);
- class_addpointer(sublist_class, sublist_pointer);
-}
-
-/* ----------------- setup function ------------------- */
-
-void g_traversal_setup(void)
-{
- ptrobj_setup();
- get_setup();
- set_setup();
- elem_setup();
- getsize_setup();
- setsize_setup();
- append_setup();
- sublist_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_vdial.c b/apps/plugins/pdbox/PDa/src/g_vdial.c
index 08b1338daf..47ac3d19bb 100644
--- a/apps/plugins/pdbox/PDa/src/g_vdial.c
+++ b/apps/plugins/pdbox/PDa/src/g_vdial.c
@@ -714,719 +714,4 @@ void g_vradio_setup(void)
class_setwidget(vradio_old_class, &vradio_widgetbehavior);
class_sethelpsymbol(vradio_old_class, gensym("vradio"));
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* vdial.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-
-/* name change to vradio by MSP (it's a radio button really) and changed to
-put out a "float" as in sliders, toggles, etc. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-/*------------------ global variables -------------------------*/
-
-
-/*------------------ global functions -------------------------*/
-
-
-
-
-/* ------------- vdl gui-vertical radio button ---------------------- */
-
-t_widgetbehavior vradio_widgetbehavior;
-static t_class *vradio_class, *vradio_old_class;
-
-/* widget helper functions */
-
-void vradio_draw_update(t_vradio *x, t_glist *glist)
-{
- if(glist_isvisible(glist))
- {
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xBUT%d -fill #%6.6x -outline #%6.6x\n",
- canvas, x, x->x_on_old,
- x->x_gui.x_bcol, x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xBUT%d -fill #%6.6x -outline #%6.6x\n",
- canvas, x, x->x_on,
- x->x_gui.x_fcol, x->x_gui.x_fcol);
- }
-}
-
-void vradio_draw_new(t_vradio *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4;
- int yy11b=text_ypix(&x->x_gui.x_obj, glist);
- int yy11=yy11b, yy12=yy11+dy;
- int yy21=yy11+s4, yy22=yy12-s4;
- int xx11=text_xpix(&x->x_gui.x_obj, glist), xx12=xx11+dy;
- int xx21=xx11+s4, xx22=xx12-s4;
-
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE%d\n",
- canvas, xx11, yy11, xx12, yy12,
- x->x_gui.x_bcol, x, i);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xBUT%d\n",
- canvas, xx21, yy21, xx22, yy22,
- (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
- (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, i);
- yy11 += dy;
- yy12 += dy;
- yy21 += dy;
- yy22 += dy;
- }
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
- canvas, xx11+x->x_gui.x_ldx, yy11b+x->x_gui.x_ldy,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
- x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_lcol, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas, xx11, yy11-1, xx11 + IOWIDTH, yy11, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas, xx11, yy11b, xx11 + IOWIDTH, yy11b+1, x, 0);
-}
-
-void vradio_draw_move(t_vradio *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4;
- int yy11b=text_ypix(&x->x_gui.x_obj, glist);
- int yy11=yy11b, yy12=yy11+dy;
- int yy21=yy11+s4, yy22=yy12-s4;
- int xx11=text_xpix(&x->x_gui.x_obj, glist), xx12=xx11+dy;
- int xx21=xx11+s4, xx22=xx12-s4;
-
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c coords %xBASE%d %d %d %d %d\n",
- canvas, x, i, xx11, yy11, xx12, yy12);
- sys_vgui(".x%x.c coords %xBUT%d %d %d %d %d\n",
- canvas, x, i, xx21, yy21, xx22, yy22);
- yy11 += dy;
- yy12 += dy;
- yy21 += dy;
- yy22 += dy;
- }
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- canvas, x, xx11+x->x_gui.x_ldx, yy11b+x->x_gui.x_ldy);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
- canvas, x, 0, xx11, yy11-1, xx11 + IOWIDTH, yy11);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
- canvas, x, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1);
-}
-
-void vradio_draw_erase(t_vradio* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i;
-
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c delete %xBASE%d\n", canvas, x, i);
- sys_vgui(".x%x.c delete %xBUT%d\n", canvas, x, i);
- }
- sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-void vradio_draw_config(t_vradio* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i;
-
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE%d -fill #%6.6x\n", canvas, x, i,
- x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xBUT%d -fill #%6.6x -outline #%6.6x\n", canvas, x, i,
- (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
- (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol);
- }
-}
-
-void vradio_draw_io(t_vradio* x, t_glist* glist, int old_snd_rcv_flags)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
-
- if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas, xpos,
- ypos+(x->x_number*x->x_gui.x_h)-1,
- xpos+ IOWIDTH,
- ypos+(x->x_number*x->x_gui.x_h), x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas, xpos, ypos,
- xpos+ IOWIDTH, ypos+1,
- x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-void vradio_draw_select(t_vradio* x, t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- int n=x->x_number, i;
-
- if(x->x_gui.x_fsf.x_selected)
- {
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE%d -outline #%6.6x\n", canvas, x, i,
- IEM_GUI_COLOR_SELECTED);
- }
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- }
- else
- {
- for(i=0; i<n; i++)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE%d -outline #%6.6x\n", canvas, x, i,
- IEM_GUI_COLOR_NORMAL);
- }
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x,
- x->x_gui.x_lcol);
- }
-}
-
-void vradio_draw(t_vradio *x, t_glist *glist, int mode)
-{
- if(mode == IEM_GUI_DRAW_MODE_UPDATE)
- vradio_draw_update(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_MOVE)
- vradio_draw_move(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_NEW)
- vradio_draw_new(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_SELECT)
- vradio_draw_select(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_ERASE)
- vradio_draw_erase(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
- vradio_draw_config(x, glist);
- else if(mode >= IEM_GUI_DRAW_MODE_IO)
- vradio_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
-}
-
-/* ------------------------ vdl widgetbehaviour----------------------------- */
-
-static void vradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_vradio *x = (t_vradio *)z;
-
- *xp1 = text_xpix(&x->x_gui.x_obj, glist);
- *yp1 = text_ypix(&x->x_gui.x_obj, glist);
- *xp2 = *xp1 + x->x_gui.x_w;
- *yp2 = *yp1 + x->x_gui.x_h*x->x_number;
-}
-static void vradio_save(t_gobj *z, t_binbuf *b)
-{
- t_vradio *x = (t_vradio *)z;
- int bflcol[3];
- t_symbol *srl[3];
-
- iemgui_save(&x->x_gui, srl, bflcol);
- binbuf_addv(b, "ssiisiiiisssiiiiiiii", gensym("#X"),gensym("obj"),
- (t_int)x->x_gui.x_obj.te_xpix,
- (t_int)x->x_gui.x_obj.te_ypix,
- (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class ?
- gensym("vdl") : gensym("vradio")),
- x->x_gui.x_w,
- x->x_change, iem_symargstoint(&x->x_gui.x_isa), x->x_number,
- srl[0], srl[1], srl[2],
- x->x_gui.x_ldx, x->x_gui.x_ldy,
- iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
- bflcol[0], bflcol[1], bflcol[2], x->x_on);
- binbuf_addv(b, ";");
-}
-
-static void vradio_properties(t_gobj *z, t_glist *owner)
-{
- t_vradio *x = (t_vradio *)z;
- char buf[800];
- t_symbol *srl[3];
- int hchange=-1;
-
- iemgui_properties(&x->x_gui, srl);
- if(pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
- hchange = x->x_change;
- sprintf(buf, "pdtk_iemgui_dialog %%s vradio \
- ----------dimensions(pix):----------- %d %d size: 0 0 empty \
- empty 0.0 empty 0.0 empty %d \
- %d new-only new&old %d %d number: %d \
- %s %s \
- %s %d %d \
- %d %d \
- %d %d %d\n",
- x->x_gui.x_w, IEM_GUI_MINSIZE,
- 0,/*no_schedule*/
- hchange, x->x_gui.x_isa.x_loadinit, -1, x->x_number,
- srl[0]->s_name, srl[1]->s_name,
- srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
- x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
- 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
- gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
-}
-
-static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *srl[3];
- int a = (int)atom_getintarg(0, argc, argv);
- int chg = (int)atom_getintarg(4, argc, argv);
- int num = (int)atom_getintarg(6, argc, argv);
- int sr_flags;
-
- if(chg != 0) chg = 1;
- x->x_change = chg;
- sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
- x->x_gui.x_w = iemgui_clip_size(a);
- x->x_gui.x_h = x->x_gui.x_w;
- if(x->x_number != num)
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
- x->x_number = num;
- if(x->x_on >= x->x_number)
- {
- x->x_on = x->x_number - 1;
- x->x_on_old = x->x_on;
- }
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
- }
- else
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
- }
-}
-
-static void vradio_set(t_vradio *x, t_floatarg f)
-{
- int i=(int)f;
- int old;
-
- if(i < 0)
- i = 0;
- if(i >= x->x_number)
- i = x->x_number-1;
- if(x->x_on != x->x_on_old)
- {
- old = x->x_on_old;
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- x->x_on_old = old;
- }
- else
- {
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- }
-}
-
-static void vradio_bang(t_vradio *x)
-{
- /* compatibility with earlier "vdial" behavior */
- if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
- {
- if((x->x_change)&&(x->x_on != x->x_on_old))
- {
- SETFLOAT(x->x_at, (float)x->x_on_old);
- SETFLOAT(x->x_at+1, 0.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- x->x_on_old = x->x_on;
- SETFLOAT(x->x_at, (float)x->x_on);
- SETFLOAT(x->x_at+1, 1.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- else
- {
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_on);
- }
-}
-
-static void vradio_fout(t_vradio *x, t_floatarg f)
-{
- int i=(int)f;
-
- if(i < 0)
- i = 0;
- if(i >= x->x_number)
- i = x->x_number-1;
-
- if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
- {
- /* compatibility with earlier "vdial" behavior */
- if((x->x_change)&&(i != x->x_on_old))
- {
- SETFLOAT(x->x_at, (float)x->x_on_old);
- SETFLOAT(x->x_at+1, 0.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- if(x->x_on != x->x_on_old)
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- x->x_on_old = x->x_on;
- SETFLOAT(x->x_at, (float)x->x_on);
- SETFLOAT(x->x_at+1, 1.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- else
- {
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
- if (x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_on);
- }
-}
-
-static void vradio_float(t_vradio *x, t_floatarg f)
-{
- int i=(int)f;
-
- if(i < 0)
- i = 0;
- if(i >= x->x_number)
- i = x->x_number-1;
-
- if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
- {
- /* compatibility with earlier "vdial" behavior */
- if((x->x_change)&&(i != x->x_on_old))
- {
- if(x->x_gui.x_fsf.x_put_in2out)
- {
- SETFLOAT(x->x_at, (float)x->x_on_old);
- SETFLOAT(x->x_at+1, 0.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- }
- if(x->x_on != x->x_on_old)
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- x->x_on_old = x->x_on;
- if(x->x_gui.x_fsf.x_put_in2out)
- {
- SETFLOAT(x->x_at, (float)x->x_on);
- SETFLOAT(x->x_at+1, 1.0);
- outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
- }
- }
- else
- {
- x->x_on_old = x->x_on;
- x->x_on = i;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- if (x->x_gui.x_fsf.x_put_in2out)
- {
- outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, x->x_on);
- }
- }
-}
-
-static void vradio_click(t_vradio *x, t_floatarg xpos, t_floatarg ypos,
- t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
-{
- int yy = (int)ypos - text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
-
- vradio_fout(x, (float)(yy / x->x_gui.x_h));
-}
-
-static int vradio_newclick(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- if(doit)
- vradio_click((t_vradio *)z, (t_floatarg)xpix, (t_floatarg)ypix,
- (t_floatarg)shift, 0, (t_floatarg)alt);
- return (1);
-}
-
-static void vradio_loadbang(t_vradio *x)
-{
- if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
- vradio_bang(x);
-}
-
-static void vradio_number(t_vradio *x, t_floatarg num)
-{
- int n=(int)num;
-
- if(n < 1)
- n = 1;
- if(n > IEM_RADIO_MAX)
- n = IEM_RADIO_MAX;
- if(n != x->x_number)
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
- x->x_number = n;
- if(x->x_on >= x->x_number)
- x->x_on = x->x_number - 1;
- x->x_on_old = x->x_on;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
- }
-}
-
-static void vradio_size(t_vradio *x, t_symbol *s, int ac, t_atom *av)
-{
- x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
- x->x_gui.x_h = x->x_gui.x_w;
- iemgui_size((void *)x, &x->x_gui);
-}
-
-static void vradio_delta(t_vradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
-
-static void vradio_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void vradio_color(t_vradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
-
-static void vradio_send(t_vradio *x, t_symbol *s)
-{iemgui_send(x, &x->x_gui, s);}
-
-static void vradio_receive(t_vradio *x, t_symbol *s)
-{iemgui_receive(x, &x->x_gui, s);}
-
-static void vradio_label(t_vradio *x, t_symbol *s)
-{iemgui_label((void *)x, &x->x_gui, s);}
-
-static void vradio_label_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void vradio_label_font(t_vradio *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
-
-static void vradio_init(t_vradio *x, t_floatarg f)
-{
- x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
-}
-
-static void vradio_double_change(t_vradio *x)
-{x->x_change = 1;}
-
-static void vradio_single_change(t_vradio *x)
-{x->x_change = 0;}
-
-static void *vradio_donew(t_symbol *s, int argc, t_atom *argv, int old)
-{
- t_vradio *x = (t_vradio *)pd_new(old? vradio_old_class : vradio_class);
- int bflcol[]={-262144, -1, -1};
- int a=IEM_GUI_DEFAULTSIZE, on=0, f=0;
- int ldx=0, ldy=-6, chg=1, num=8;
- int fs=8;
- int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
- char str[144];
-
- if((argc == 15)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
- &&IS_A_FLOAT(argv,3)
- &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
- &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
- &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
- &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
- &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)
- &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)&&IS_A_FLOAT(argv,14))
- {
- a = (int)atom_getintarg(0, argc, argv);
- chg = (int)atom_getintarg(1, argc, argv);
- iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv));
- num = (int)atom_getintarg(3, argc, argv);
- iemgui_new_getnames(&x->x_gui, 4, argv);
- ldx = (int)atom_getintarg(7, argc, argv);
- ldy = (int)atom_getintarg(8, argc, argv);
- iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
- fs = (int)atom_getintarg(10, argc, argv);
- bflcol[0] = (int)atom_getintarg(11, argc, argv);
- bflcol[1] = (int)atom_getintarg(12, argc, argv);
- bflcol[2] = (int)atom_getintarg(13, argc, argv);
- on = (int)atom_getintarg(14, argc, argv);
- }
- else iemgui_new_getnames(&x->x_gui, 4, 0);
- x->x_gui.x_draw = (t_iemfunptr)vradio_draw;
- x->x_gui.x_fsf.x_snd_able = 1;
- x->x_gui.x_fsf.x_rcv_able = 1;
- x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
- if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
- x->x_gui.x_fsf.x_snd_able = 0;
- if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
- x->x_gui.x_fsf.x_rcv_able = 0;
- if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
- else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
- else { x->x_gui.x_fsf.x_font_style = 0;
- strcpy(x->x_gui.x_font, "courier"); }
- if(num < 1)
- num = 1;
- if(num > IEM_RADIO_MAX)
- num = IEM_RADIO_MAX;
- x->x_number = num;
- if(on < 0)
- on = 0;
- if(on >= x->x_number)
- on = x->x_number - 1;
- if(x->x_gui.x_isa.x_loadinit)
- x->x_on = on;
- else
- x->x_on = 0;
- x->x_on_old = x->x_on;
- x->x_change = (chg==0)?0:1;
- if (x->x_gui.x_fsf.x_rcv_able)
- pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- x->x_gui.x_ldx = ldx;
- x->x_gui.x_ldy = ldy;
- if(fs < 4)
- fs = 4;
- x->x_gui.x_fontsize = fs;
- x->x_gui.x_w = iemgui_clip_size(a);
- x->x_gui.x_h = x->x_gui.x_w;
- iemgui_verify_snd_ne_rcv(&x->x_gui);
- iemgui_all_colfromload(&x->x_gui, bflcol);
- outlet_new(&x->x_gui.x_obj, &s_list);
- return (x);
-}
-
-static void *vradio_new(t_symbol *s, int argc, t_atom *argv)
-{
- return (vradio_donew(s, argc, argv, 0));
-}
-
-static void *vdial_new(t_symbol *s, int argc, t_atom *argv)
-{
- return (vradio_donew(s, argc, argv, 1));
-}
-
-static void vradio_ff(t_vradio *x)
-{
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- gfxstub_deleteforkey(x);
-}
-
-void g_vradio_setup(void)
-{
- vradio_class = class_new(gensym("vradio"), (t_newmethod)vradio_new,
- (t_method)vradio_ff, sizeof(t_vradio), 0, A_GIMME, 0);
- class_addbang(vradio_class, vradio_bang);
- class_addfloat(vradio_class, vradio_float);
- class_addmethod(vradio_class, (t_method)vradio_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(vradio_class, (t_method)vradio_dialog, gensym("dialog"),
- A_GIMME, 0);
- class_addmethod(vradio_class, (t_method)vradio_loadbang,
- gensym("loadbang"), 0);
- class_addmethod(vradio_class, (t_method)vradio_set,
- gensym("set"), A_FLOAT, 0);
- class_addmethod(vradio_class, (t_method)vradio_size,
- gensym("size"), A_GIMME, 0);
- class_addmethod(vradio_class, (t_method)vradio_delta,
- gensym("delta"), A_GIMME, 0);
- class_addmethod(vradio_class, (t_method)vradio_pos,
- gensym("pos"), A_GIMME, 0);
- class_addmethod(vradio_class, (t_method)vradio_color,
- gensym("color"), A_GIMME, 0);
- class_addmethod(vradio_class, (t_method)vradio_send,
- gensym("send"), A_DEFSYM, 0);
- class_addmethod(vradio_class, (t_method)vradio_receive,
- gensym("receive"), A_DEFSYM, 0);
- class_addmethod(vradio_class, (t_method)vradio_label,
- gensym("label"), A_DEFSYM, 0);
- class_addmethod(vradio_class, (t_method)vradio_label_pos,
- gensym("label_pos"), A_GIMME, 0);
- class_addmethod(vradio_class, (t_method)vradio_label_font,
- gensym("label_font"), A_GIMME, 0);
- class_addmethod(vradio_class, (t_method)vradio_init,
- gensym("init"), A_FLOAT, 0);
- class_addmethod(vradio_class, (t_method)vradio_number,
- gensym("number"), A_FLOAT, 0);
- class_addmethod(vradio_class, (t_method)vradio_single_change,
- gensym("single_change"), 0);
- class_addmethod(vradio_class, (t_method)vradio_double_change,
- gensym("double_change"), 0);
- vradio_widgetbehavior.w_getrectfn = vradio_getrect;
- vradio_widgetbehavior.w_displacefn = iemgui_displace;
- vradio_widgetbehavior.w_selectfn = iemgui_select;
- vradio_widgetbehavior.w_activatefn = NULL;
- vradio_widgetbehavior.w_deletefn = iemgui_delete;
- vradio_widgetbehavior.w_visfn = iemgui_vis;
- vradio_widgetbehavior.w_clickfn = vradio_newclick;
- class_setwidget(vradio_class, &vradio_widgetbehavior);
- class_sethelpsymbol(vradio_class, gensym("vradio"));
- class_setsavefn(vradio_class, vradio_save);
- class_setpropertiesfn(vradio_class, vradio_properties);
-
- /* obsolete version (0.34-0.35) */
- vradio_old_class = class_new(gensym("vdl"), (t_newmethod)vdial_new,
- (t_method)vradio_ff, sizeof(t_vradio), 0, A_GIMME, 0);
- class_addbang(vradio_old_class, vradio_bang);
- class_addfloat(vradio_old_class, vradio_float);
- class_addmethod(vradio_old_class, (t_method)vradio_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_dialog, gensym("dialog"),
- A_GIMME, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_loadbang, gensym("loadbang"), 0);
- class_addmethod(vradio_old_class, (t_method)vradio_set, gensym("set"), A_FLOAT, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_size, gensym("size"), A_GIMME, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_delta, gensym("delta"), A_GIMME, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_pos, gensym("pos"), A_GIMME, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_color, gensym("color"), A_GIMME, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_send, gensym("send"), A_DEFSYM, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_receive, gensym("receive"), A_DEFSYM, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_label, gensym("label"), A_DEFSYM, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_label_pos, gensym("label_pos"), A_GIMME, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_label_font, gensym("label_font"), A_GIMME, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_init, gensym("init"), A_FLOAT, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_number, gensym("number"), A_FLOAT, 0);
- class_addmethod(vradio_old_class, (t_method)vradio_single_change, gensym("single_change"), 0);
- class_addmethod(vradio_old_class, (t_method)vradio_double_change, gensym("double_change"), 0);
- class_setwidget(vradio_old_class, &vradio_widgetbehavior);
- class_sethelpsymbol(vradio_old_class, gensym("vradio"));
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_vslider.c b/apps/plugins/pdbox/PDa/src/g_vslider.c
index 8e2e326f30..ee02236769 100644
--- a/apps/plugins/pdbox/PDa/src/g_vslider.c
+++ b/apps/plugins/pdbox/PDa/src/g_vslider.c
@@ -625,630 +625,4 @@ void g_vslider_setup(void)
class_setsavefn(vslider_class, vslider_save);
class_setpropertiesfn(vslider_class, vslider_properties);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-#ifdef MSW
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-
-/* ------------ vsl gui-vertical slider ----------------------- */
-
-t_widgetbehavior vslider_widgetbehavior;
-static t_class *vslider_class;
-
-/* widget helper functions */
-
-static void vslider_draw_update(t_vslider *x, t_glist *glist)
-{
- if (glist_isvisible(glist))
- {
- int r = text_ypix(&x->x_gui.x_obj, glist) + x->x_gui.x_h - (x->x_val + 50)/100;
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
-
- sys_vgui(".x%x.c coords %xKNOB %d %d %d %d\n",
- glist_getcanvas(glist), x, xpos+1, r,
- xpos + x->x_gui.x_w, r);
- }
-}
-
-static void vslider_draw_new(t_vslider *x, t_glist *glist)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100;
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
- canvas, xpos, ypos-2,
- xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+3,
- x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %xKNOB\n",
- canvas, xpos+1, r,
- xpos + x->x_gui.x_w, r, x->x_gui.x_fcol, x);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
- canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
- x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas,
- xpos, ypos + x->x_gui.x_h+2,
- xpos+7, ypos + x->x_gui.x_h+3,
- x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas,
- xpos, ypos-2,
- xpos+7, ypos-1,
- x, 0);
-}
-
-static void vslider_draw_move(t_vslider *x, t_glist *glist)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100;
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
- canvas, x,
- xpos, ypos-2,
- xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+3);
- sys_vgui(".x%x.c coords %xKNOB %d %d %d %d\n",
- canvas, x, xpos+1, r,
- xpos + x->x_gui.x_w, r);
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
- canvas, x, 0,
- xpos, ypos + x->x_gui.x_h+2,
- xpos+7, ypos + x->x_gui.x_h+3);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
- canvas, x, 0,
- xpos, ypos-2,
- xpos+7, ypos-1);
-}
-
-static void vslider_draw_erase(t_vslider* x,t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
- sys_vgui(".x%x.c delete %xKNOB\n", canvas, x);
- sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if(!x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-static void vslider_draw_config(t_vslider* x,t_glist* glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
- sys_vgui(".x%x.c itemconfigure %xKNOB -fill #%6.6x\n", canvas,
- x, x->x_gui.x_fcol);
- sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas,
- x, x->x_gui.x_bcol);
-}
-
-static void vslider_draw_io(t_vslider* x,t_glist* glist, int old_snd_rcv_flags)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas,
- xpos, ypos + x->x_gui.x_h+2,
- xpos+7, ypos + x->x_gui.x_h+3,
- x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas,
- xpos, ypos-2,
- xpos+7, ypos-1,
- x, 0);
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
-}
-
-static void vslider_draw_select(t_vslider *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- if(x->x_gui.x_fsf.x_selected)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- }
- else
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
- }
-}
-
-void vslider_draw(t_vslider *x, t_glist *glist, int mode)
-{
- if(mode == IEM_GUI_DRAW_MODE_UPDATE)
- vslider_draw_update(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_MOVE)
- vslider_draw_move(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_NEW)
- vslider_draw_new(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_SELECT)
- vslider_draw_select(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_ERASE)
- vslider_draw_erase(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
- vslider_draw_config(x, glist);
- else if(mode >= IEM_GUI_DRAW_MODE_IO)
- vslider_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
-}
-
-/* ------------------------ vsl widgetbehaviour----------------------------- */
-
-
-static void vslider_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_vslider* x = (t_vslider*)z;
-
- *xp1 = text_xpix(&x->x_gui.x_obj, glist);
- *yp1 = text_ypix(&x->x_gui.x_obj, glist) - 2;
- *xp2 = *xp1 + x->x_gui.x_w;
- *yp2 = *yp1 + x->x_gui.x_h + 5;
-}
-
-static void vslider_save(t_gobj *z, t_binbuf *b)
-{
- t_vslider *x = (t_vslider *)z;
- int bflcol[3];
- t_symbol *srl[3];
-
- iemgui_save(&x->x_gui, srl, bflcol);
- binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"),
- (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
- gensym("vsl"), x->x_gui.x_w, x->x_gui.x_h,
- (float)x->x_min, (float)x->x_max,
- x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa),
- srl[0], srl[1], srl[2],
- x->x_gui.x_ldx, x->x_gui.x_ldy,
- iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
- bflcol[0], bflcol[1], bflcol[2],
- x->x_val, x->x_steady);
- binbuf_addv(b, ";");
-}
-
-void vslider_check_height(t_vslider *x, int h)
-{
- if(h < IEM_SL_MINSIZE)
- h = IEM_SL_MINSIZE;
- x->x_gui.x_h = h;
- if(x->x_val > (x->x_gui.x_h*100 - 100))
- {
- x->x_pos = x->x_gui.x_h*100 - 100;
- x->x_val = x->x_pos;
- }
- if(x->x_lin0_log1)
- x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_h - 1);
- else
- x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1);
-}
-
-void vslider_check_minmax(t_vslider *x, double min, double max)
-{
- if(x->x_lin0_log1)
- {
- if((min == 0.0)&&(max == 0.0))
- max = 1.0;
- if(max > 0.0)
- {
- if(min <= 0.0)
- min = 0.01*max;
- }
- else
- {
- if(min > 0.0)
- max = 0.01*min;
- }
- }
- x->x_min = min;
- x->x_max = max;
- if(x->x_min > x->x_max) /* bugfix */
- x->x_gui.x_isa.x_reverse = 1;
- else
- x->x_gui.x_isa.x_reverse = 0;
- if(x->x_lin0_log1)
- x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_h - 1);
- else
- x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1);
-}
-
-static void vslider_properties(t_gobj *z, t_glist *owner)
-{
- t_vslider *x = (t_vslider *)z;
- char buf[800];
- t_symbol *srl[3];
-
- iemgui_properties(&x->x_gui, srl);
-
- sprintf(buf, "pdtk_iemgui_dialog %%s VSLIDER \
- --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
- -----------output-range:----------- %g bottom: %g top: %d \
- %d lin log %d %d empty %d \
- %s %s \
- %s %d %d \
- %d %d \
- %d %d %d\n",
- x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_SL_MINSIZE,
- x->x_min, x->x_max, 0,/*no_schedule*/
- x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/
- srl[0]->s_name, srl[1]->s_name,
- srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
- x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
- 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
- gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
-}
-
-static void vslider_bang(t_vslider *x)
-{
- double out;
-
- if(x->x_lin0_log1)
- out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
- else
- out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
- if((out < 1.0e-10)&&(out > -1.0e-10))
- out = 0.0;
-
- outlet_float(x->x_gui.x_obj.ob_outlet, out);
- if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
- pd_float(x->x_gui.x_snd->s_thing, out);
-}
-
-static void vslider_dialog(t_vslider *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *srl[3];
- int w = (int)atom_getintarg(0, argc, argv);
- int h = (int)atom_getintarg(1, argc, argv);
- double min = (double)atom_getfloatarg(2, argc, argv);
- double max = (double)atom_getfloatarg(3, argc, argv);
- int lilo = (int)atom_getintarg(4, argc, argv);
- int steady = (int)atom_getintarg(17, argc, argv);
- int sr_flags;
-
- if(lilo != 0) lilo = 1;
- x->x_lin0_log1 = lilo;
- if(steady)
- x->x_steady = 1;
- else
- x->x_steady = 0;
- sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
- x->x_gui.x_w = iemgui_clip_size(w);
- vslider_check_height(x, h);
- vslider_check_minmax(x, min, max);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
-}
-static void vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy)
-{
- int old = x->x_val;
-
- if(x->x_gui.x_fsf.x_finemoved)
- x->x_pos -= (int)dy;
- else
- x->x_pos -= 100*(int)dy;
- x->x_val = x->x_pos;
- if(x->x_val > (100*x->x_gui.x_h - 100))
- {
- x->x_val = 100*x->x_gui.x_h - 100;
- x->x_pos += 50;
- x->x_pos -= x->x_pos%100;
- }
- if(x->x_val < 0)
- {
- x->x_val = 0;
- x->x_pos -= 50;
- x->x_pos -= x->x_pos%100;
- }
- if(old != x->x_val)
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- vslider_bang(x);
- }
-}
-
-static void vslider_click(t_vslider *x, t_floatarg xpos, t_floatarg ypos,
- t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
-{
- if(!x->x_steady)
- x->x_val = (int)(100.0 * (x->x_gui.x_h + text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist) - ypos));
- if(x->x_val > (100*x->x_gui.x_h - 100))
- x->x_val = 100*x->x_gui.x_h - 100;
- if(x->x_val < 0)
- x->x_val = 0;
- x->x_pos = x->x_val;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- vslider_bang(x);
- glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
- (t_glistmotionfn)vslider_motion, 0, xpos, ypos);
-}
-
-static int vslider_newclick(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_vslider* x = (t_vslider *)z;
-
- if(doit)
- {
- vslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift,
- 0, (t_floatarg)alt);
- if(shift)
- x->x_gui.x_fsf.x_finemoved = 1;
- else
- x->x_gui.x_fsf.x_finemoved = 0;
- }
- return (1);
-}
-
-static void vslider_set(t_vslider *x, t_floatarg f)
-{
- double g;
-
- if(x->x_gui.x_isa.x_reverse) /* bugfix */
- {
- if(f > x->x_min)
- f = x->x_min;
- if(f < x->x_max)
- f = x->x_max;
- }
- else
- {
- if(f > x->x_max)
- f = x->x_max;
- if(f < x->x_min)
- f = x->x_min;
- }
- if(x->x_lin0_log1)
- g = log(f/x->x_min)/x->x_k;
- else
- g = (f - x->x_min) / x->x_k;
- x->x_val = (int)(100.0*g + 0.49999);
- x->x_pos = x->x_val;
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
-}
-
-static void vslider_float(t_vslider *x, t_floatarg f)
-{
- vslider_set(x, f);
- if(x->x_gui.x_fsf.x_put_in2out)
- vslider_bang(x);
-}
-
-static void vslider_size(t_vslider *x, t_symbol *s, int ac, t_atom *av)
-{
- x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
- if(ac > 1)
- vslider_check_height(x, (int)atom_getintarg(1, ac, av));
- iemgui_size((void *)x, &x->x_gui);
-}
-
-static void vslider_delta(t_vslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
-
-static void vslider_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void vslider_range(t_vslider *x, t_symbol *s, int ac, t_atom *av)
-{
- vslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
- (double)atom_getfloatarg(1, ac, av));
-}
-
-static void vslider_color(t_vslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
-
-static void vslider_send(t_vslider *x, t_symbol *s)
-{iemgui_send(x, &x->x_gui, s);}
-
-static void vslider_receive(t_vslider *x, t_symbol *s)
-{iemgui_receive(x, &x->x_gui, s);}
-
-static void vslider_label(t_vslider *x, t_symbol *s)
-{iemgui_label((void *)x, &x->x_gui, s);}
-
-static void vslider_label_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void vslider_label_font(t_vslider *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
-
-static void vslider_log(t_vslider *x)
-{
- x->x_lin0_log1 = 1;
- vslider_check_minmax(x, x->x_min, x->x_max);
-}
-
-static void vslider_lin(t_vslider *x)
-{
- x->x_lin0_log1 = 0;
- x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1);
-}
-
-static void vslider_init(t_vslider *x, t_floatarg f)
-{
- x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
-}
-
-static void vslider_steady(t_vslider *x, t_floatarg f)
-{
- x->x_steady = (f==0.0)?0:1;
-}
-
-static void vslider_loadbang(t_vslider *x)
-{
- if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- vslider_bang(x);
- }
-}
-
-static void *vslider_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_vslider *x = (t_vslider *)pd_new(vslider_class);
- int bflcol[]={-262144, -1, -1};
- int w=IEM_GUI_DEFAULTSIZE, h=IEM_SL_DEFAULTSIZE;
- int lilo=0, f=0, ldx=0, ldy=-8;
- int fs=8, v=0, steady=1;
- double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1);
- char str[144];
-
- iem_inttosymargs(&x->x_gui.x_isa, 0);
- iem_inttofstyle(&x->x_gui.x_fsf, 0);
-
- if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
- &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
- &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
- &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
- &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
- &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
- &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
- &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
- &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16))
- {
- w = (int)atom_getintarg(0, argc, argv);
- h = (int)atom_getintarg(1, argc, argv);
- min = (double)atom_getfloatarg(2, argc, argv);
- max = (double)atom_getfloatarg(3, argc, argv);
- lilo = (int)atom_getintarg(4, argc, argv);
- iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv));
- iemgui_new_getnames(&x->x_gui, 6, argv);
- ldx = (int)atom_getintarg(9, argc, argv);
- ldy = (int)atom_getintarg(10, argc, argv);
- iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv));
- fs = (int)atom_getintarg(12, argc, argv);
- bflcol[0] = (int)atom_getintarg(13, argc, argv);
- bflcol[1] = (int)atom_getintarg(14, argc, argv);
- bflcol[2] = (int)atom_getintarg(15, argc, argv);
- v = (int)atom_getintarg(16, argc, argv);
- }
- else iemgui_new_getnames(&x->x_gui, 6, 0);
- if((argc == 18)&&IS_A_FLOAT(argv,17))
- steady = (int)atom_getintarg(17, argc, argv);
- x->x_gui.x_draw = (t_iemfunptr)vslider_draw;
- x->x_gui.x_fsf.x_snd_able = 1;
- x->x_gui.x_fsf.x_rcv_able = 1;
- x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
- if(x->x_gui.x_isa.x_loadinit)
- x->x_val = v;
- else
- x->x_val = 0;
- x->x_pos = x->x_val;
- if(lilo != 0) lilo = 1;
- x->x_lin0_log1 = lilo;
- if(steady != 0) steady = 1;
- x->x_steady = steady;
- if(!strcmp(x->x_gui.x_snd->s_name, "empty")) x->x_gui.x_fsf.x_snd_able = 0;
- if(!strcmp(x->x_gui.x_rcv->s_name, "empty")) x->x_gui.x_fsf.x_rcv_able = 0;
- if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
- else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
- else { x->x_gui.x_fsf.x_font_style = 0;
- strcpy(x->x_gui.x_font, "courier"); }
- if(x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- x->x_gui.x_ldx = ldx;
- x->x_gui.x_ldy = ldy;
- if(fs < 4)
- fs = 4;
- x->x_gui.x_fontsize = fs;
- x->x_gui.x_w = iemgui_clip_size(w);
- vslider_check_height(x, h);
- vslider_check_minmax(x, min, max);
- iemgui_all_colfromload(&x->x_gui, bflcol);
- iemgui_verify_snd_ne_rcv(&x->x_gui);
- outlet_new(&x->x_gui.x_obj, &s_float);
- return (x);
-}
-
-static void vslider_free(t_vslider *x)
-{
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- gfxstub_deleteforkey(x);
-}
-
-void g_vslider_setup(void)
-{
- vslider_class = class_new(gensym("vsl"), (t_newmethod)vslider_new,
- (t_method)vslider_free, sizeof(t_vslider), 0, A_GIMME, 0);
- class_addcreator((t_newmethod)vslider_new, gensym("vslider"), A_GIMME, 0);
- class_addbang(vslider_class,vslider_bang);
- class_addfloat(vslider_class,vslider_float);
- class_addmethod(vslider_class, (t_method)vslider_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(vslider_class, (t_method)vslider_motion, gensym("motion"),
- A_FLOAT, A_FLOAT, 0);
- class_addmethod(vslider_class, (t_method)vslider_dialog, gensym("dialog"),
- A_GIMME, 0);
- class_addmethod(vslider_class, (t_method)vslider_loadbang, gensym("loadbang"), 0);
- class_addmethod(vslider_class, (t_method)vslider_set, gensym("set"), A_FLOAT, 0);
- class_addmethod(vslider_class, (t_method)vslider_size, gensym("size"), A_GIMME, 0);
- class_addmethod(vslider_class, (t_method)vslider_delta, gensym("delta"), A_GIMME, 0);
- class_addmethod(vslider_class, (t_method)vslider_pos, gensym("pos"), A_GIMME, 0);
- class_addmethod(vslider_class, (t_method)vslider_range, gensym("range"), A_GIMME, 0);
- class_addmethod(vslider_class, (t_method)vslider_color, gensym("color"), A_GIMME, 0);
- class_addmethod(vslider_class, (t_method)vslider_send, gensym("send"), A_DEFSYM, 0);
- class_addmethod(vslider_class, (t_method)vslider_receive, gensym("receive"), A_DEFSYM, 0);
- class_addmethod(vslider_class, (t_method)vslider_label, gensym("label"), A_DEFSYM, 0);
- class_addmethod(vslider_class, (t_method)vslider_label_pos, gensym("label_pos"), A_GIMME, 0);
- class_addmethod(vslider_class, (t_method)vslider_label_font, gensym("label_font"), A_GIMME, 0);
- class_addmethod(vslider_class, (t_method)vslider_log, gensym("log"), 0);
- class_addmethod(vslider_class, (t_method)vslider_lin, gensym("lin"), 0);
- class_addmethod(vslider_class, (t_method)vslider_init, gensym("init"), A_FLOAT, 0);
- class_addmethod(vslider_class, (t_method)vslider_steady, gensym("steady"), A_FLOAT, 0);
- vslider_widgetbehavior.w_getrectfn = vslider_getrect;
- vslider_widgetbehavior.w_displacefn = iemgui_displace;
- vslider_widgetbehavior.w_selectfn = iemgui_select;
- vslider_widgetbehavior.w_activatefn = NULL;
- vslider_widgetbehavior.w_deletefn = iemgui_delete;
- vslider_widgetbehavior.w_visfn = iemgui_vis;
- vslider_widgetbehavior.w_clickfn = vslider_newclick;
- class_setwidget(vslider_class, &vslider_widgetbehavior);
- class_sethelpsymbol(vslider_class, gensym("vslider"));
- class_setsavefn(vslider_class, vslider_save);
- class_setpropertiesfn(vslider_class, vslider_properties);
-}
diff --git a/apps/plugins/pdbox/PDa/src/g_vumeter.c b/apps/plugins/pdbox/PDa/src/g_vumeter.c
index c7b3f1f209..fb3a8fafa4 100644
--- a/apps/plugins/pdbox/PDa/src/g_vumeter.c
+++ b/apps/plugins/pdbox/PDa/src/g_vumeter.c
@@ -711,716 +711,4 @@ void g_vumeter_setup(void)
class_setsavefn(vu_class, vu_save);
class_setpropertiesfn(vu_class, vu_properties);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
-/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "m_pd.h"
-#include "g_canvas.h"
-#include "t_tk.h"
-#include "g_all_guis.h"
-#include <math.h>
-
-#ifdef MSW
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-/* ----- vu gui-peak- & rms- vu-meter-display ---------- */
-
-t_widgetbehavior vu_widgetbehavior;
-static t_class *vu_class;
-
-/* widget helper functions */
-
-static void vu_update_rms(t_vu *x, t_glist *glist)
-{
- if(glist_isvisible(glist))
- {
- int w4=x->x_gui.x_w/4, off=text_ypix(&x->x_gui.x_obj, glist)-1;
- int xpos=text_xpix(&x->x_gui.x_obj, glist), quad1=xpos+w4+1, quad3=xpos+x->x_gui.x_w-w4-1;
-
- sys_vgui(".x%x.c coords %xRCOVER %d %d %d %d\n",
- glist_getcanvas(glist), x, quad1, off, quad3,
- off + (x->x_led_size+1)*(IEM_VU_STEPS-x->x_rms));
- }
-}
-
-static void vu_update_peak(t_vu *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- if(glist_isvisible(glist))
- {
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
-
- if(x->x_peak)
- {
- int i=iemgui_vu_col[x->x_peak];
- int j=ypos + (x->x_led_size+1)*(IEM_VU_STEPS+1-x->x_peak)
- - (x->x_led_size+1)/2;
-
- sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n", canvas, x,
- xpos, j,
- xpos+x->x_gui.x_w+1, j);
- sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n", canvas, x,
- iemgui_color_hex[i]);
- }
- else
- {
- int mid=xpos+x->x_gui.x_w/2;
-
- sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n",
- canvas, x, x->x_gui.x_bcol);
- sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n",
- canvas, x, mid, ypos+20,
- mid, ypos+20);
- }
- }
-}
-
-static void vu_draw_new(t_vu *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- int w4=x->x_gui.x_w/4, mid=xpos+x->x_gui.x_w/2,
- quad1=xpos+w4+1;
- int quad3=xpos+x->x_gui.x_w-w4,
- end=xpos+x->x_gui.x_w+4;
- int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
- int led_col, yyy, i, k4=ypos-k3;
-
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
- canvas, xpos-1, ypos-2,
- xpos+x->x_gui.x_w+1,
- ypos+x->x_gui.x_h+2, x->x_gui.x_bcol, x);
- for(i=1; i<=IEM_VU_STEPS; i++)
- {
- led_col = iemgui_vu_col[i];
- yyy = k4 + k1*(k2-i);
- sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xRLED%d\n",
- canvas, quad1, yyy, quad3, yyy, x->x_led_size, iemgui_color_hex[led_col], x, i);
- if(((i+2)&3) && (x->x_scale))
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
- canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_lcol, x, i);
- }
- if(x->x_scale)
- {
- i=IEM_VU_STEPS+1;
- yyy = k4 + k1*(k2-i);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
- canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_lcol, x, i);
- }
- sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xRCOVER\n",
- canvas, quad1, ypos-1, quad3-1,
- ypos-1 + k1*IEM_VU_STEPS, x->x_gui.x_bcol, x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xPLED\n",
- canvas, mid, ypos+10,
- mid, ypos+10, x->x_led_size, x->x_gui.x_bcol, x);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
- canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
- x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- {
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas,
- xpos-1, ypos + x->x_gui.x_h+1,
- xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2,
- x, 0);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas,
- xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
- xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2,
- x, 1);
- }
- if(!x->x_gui.x_fsf.x_rcv_able)
- {
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas,
- xpos-1, ypos-2,
- xpos + IOWIDTH-1, ypos-1,
- x, 0);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas,
- xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
- xpos+x->x_gui.x_w+1, ypos-1,
- x, 1);
- }
-}
-
-
-static void vu_draw_move(t_vu *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
-
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- int w4=x->x_gui.x_w/4, quad1=xpos+w4+1;
- int quad3=xpos+x->x_gui.x_w-w4,
- end=xpos+x->x_gui.x_w+4;
- int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
- int yyy, i, k4=ypos-k3;
-
- sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
- canvas, x, xpos-1, ypos-2,
- xpos+x->x_gui.x_w+1,ypos+x->x_gui.x_h+2);
- for(i=1; i<=IEM_VU_STEPS; i++)
- {
- yyy = k4 + k1*(k2-i);
- sys_vgui(".x%x.c coords %xRLED%d %d %d %d %d\n",
- canvas, x, i, quad1, yyy, quad3, yyy);
- if(((i+2)&3) && (x->x_scale))
- sys_vgui(".x%x.c coords %xSCALE%d %d %d\n",
- canvas, x, i, end, yyy+k3);
- }
- if(x->x_scale)
- {
- i=IEM_VU_STEPS+1;
- yyy = k4 + k1*(k2-i);
- sys_vgui(".x%x.c coords %xSCALE%d %d %d\n",
- canvas, x, i, end, yyy+k3);
- }
- vu_update_peak(x, glist);
- vu_update_rms(x, glist);
- sys_vgui(".x%x.c coords %xLABEL %d %d\n",
- canvas, x, xpos+x->x_gui.x_ldx,
- ypos+x->x_gui.x_ldy);
- if(!x->x_gui.x_fsf.x_snd_able)
- {
- sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
- canvas, x, 0,
- xpos-1, ypos + x->x_gui.x_h+1,
- xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2);
- sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
- canvas, x, 1,
- xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
- xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2);
- }
- if(!x->x_gui.x_fsf.x_rcv_able)
- {
- sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
- canvas, x, 0,
- xpos-1, ypos-2,
- xpos + IOWIDTH-1, ypos-1);
- sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
- canvas, x, 1,
- xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
- xpos+x->x_gui.x_w+1, ypos-1);
- }
-}
-
-static void vu_draw_erase(t_vu* x,t_glist* glist)
-{
- int i;
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
- for(i=1; i<=IEM_VU_STEPS; i++)
- {
- sys_vgui(".x%x.c delete %xRLED%d\n", canvas, x, i);
- if(((i+2)&3) && (x->x_scale))
- sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
- }
- if(x->x_scale)
- {
- i=IEM_VU_STEPS+1;
- sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
- }
- sys_vgui(".x%x.c delete %xPLED\n", canvas, x);
- sys_vgui(".x%x.c delete %xRCOVER\n", canvas, x);
- sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
- if(!x->x_gui.x_fsf.x_snd_able)
- {
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 1);
- }
- if(!x->x_gui.x_fsf.x_rcv_able)
- {
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
- }
-}
-
-static void vu_draw_config(t_vu* x, t_glist* glist)
-{
- int i;
- t_canvas *canvas=glist_getcanvas(glist);
-
- sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
- for(i=1; i<=IEM_VU_STEPS; i++)
- {
- sys_vgui(".x%x.c itemconfigure %xRLED%d -width %d\n", canvas, x, i,
- x->x_led_size);
- if(((i+2)&3) && (x->x_scale))
- sys_vgui(".x%x.c itemconfigure %xSCALE%d -text {%s} -font {%s %d bold} -fill #%6.6x\n",
- canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol);
- }
- if(x->x_scale)
- {
- i=IEM_VU_STEPS+1;
- sys_vgui(".x%x.c itemconfigure %xSCALE%d -text {%s} -font {%s %d bold} -fill #%6.6x\n",
- canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol);
- }
- sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
- canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
- strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
-
- sys_vgui(".x%x.c itemconfigure %xRCOVER -fill #%6.6x -outline #%6.6x\n", canvas,
- x, x->x_gui.x_bcol, x->x_gui.x_bcol);
- sys_vgui(".x%x.c itemconfigure %xPLED -width %d\n", canvas, x,
- x->x_led_size);
-}
-
-static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags)
-{
- int xpos=text_xpix(&x->x_gui.x_obj, glist);
- int ypos=text_ypix(&x->x_gui.x_obj, glist);
- t_canvas *canvas=glist_getcanvas(glist);
-
- if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
- {
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas,
- xpos-1, ypos + x->x_gui.x_h+1,
- xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2,
- x, 0);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
- canvas,
- xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
- xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2,
- x, 1);
- }
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
- {
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
- sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 1);
- }
- if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
- {
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas,
- xpos-1, ypos-2,
- xpos + IOWIDTH-1, ypos-1,
- x, 0);
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
- canvas,
- xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
- xpos+x->x_gui.x_w+1, ypos-1,
- x, 1);
- }
- if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
- {
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
- sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
- }
-}
-
-static void vu_draw_select(t_vu* x,t_glist* glist)
-{
- int i;
- t_canvas *canvas=glist_getcanvas(glist);
-
- if(x->x_gui.x_fsf.x_selected)
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- for(i=1; i<=IEM_VU_STEPS; i++)
- {
- if(((i+2)&3) && (x->x_scale))
- sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
- canvas, x, i, IEM_GUI_COLOR_SELECTED);
- }
- if(x->x_scale)
- {
- i=IEM_VU_STEPS+1;
- sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
- canvas, x, i, IEM_GUI_COLOR_SELECTED);
- }
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
- }
- else
- {
- sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
- for(i=1; i<=IEM_VU_STEPS; i++)
- {
- if(((i+2)&3) && (x->x_scale))
- sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
- canvas, x, i, x->x_gui.x_lcol);
- }
- if(x->x_scale)
- {
- i=IEM_VU_STEPS+1;
- sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
- canvas, x, i, x->x_gui.x_lcol);
- }
- sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
- }
-}
-
-void vu_draw(t_vu *x, t_glist *glist, int mode)
-{
- if(mode == IEM_GUI_DRAW_MODE_MOVE)
- vu_draw_move(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_NEW)
- vu_draw_new(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_SELECT)
- vu_draw_select(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_ERASE)
- vu_draw_erase(x, glist);
- else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
- vu_draw_config(x, glist);
- else if(mode >= IEM_GUI_DRAW_MODE_IO)
- vu_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
-}
-
-/* ------------------------ vu widgetbehaviour----------------------------- */
-
-
-static void vu_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- t_vu* x = (t_vu*)z;
-
- *xp1 = text_xpix(&x->x_gui.x_obj, glist) - 1;
- *yp1 = text_ypix(&x->x_gui.x_obj, glist) - 2;
- *xp2 = *xp1 + x->x_gui.x_w + 2;
- *yp2 = *yp1 + x->x_gui.x_h + 4;
-}
-
-static void vu_save(t_gobj *z, t_binbuf *b)
-{
- t_vu *x = (t_vu *)z;
- int bflcol[3];
- t_symbol *srl[3];
-
- iemgui_save(&x->x_gui, srl, bflcol);
- binbuf_addv(b, "ssiisiissiiiiiiii", gensym("#X"),gensym("obj"),
- (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
- gensym("vu"), x->x_gui.x_w, x->x_gui.x_h,
- srl[1], srl[2],
- x->x_gui.x_ldx, x->x_gui.x_ldy,
- iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
- bflcol[0], bflcol[2], x->x_scale,
- iem_symargstoint(&x->x_gui.x_isa));
- binbuf_addv(b, ";");
-}
-
-void vu_check_height(t_vu *x, int h)
-{
- int n;
-
- n = h / IEM_VU_STEPS;
- if(n < IEM_VU_MINSIZE)
- n = IEM_VU_MINSIZE;
- x->x_led_size = n-1;
- x->x_gui.x_h = IEM_VU_STEPS * n;
-}
-
-static void vu_scale(t_vu *x, t_floatarg fscale)
-{
- int i, scale = (int)fscale;
-
- if(scale != 0) scale = 1;
- if(x->x_scale && !scale)
- {
- t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
-
- x->x_scale = (int)scale;
- if(glist_isvisible(x->x_gui.x_glist))
- {
- for(i=1; i<=IEM_VU_STEPS; i++)
- {
- if((i+2)&3)
- sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
- }
- i=IEM_VU_STEPS+1;
- sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
- }
- }
- if(!x->x_scale && scale)
- {
- int w4=x->x_gui.x_w/4, end=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)+x->x_gui.x_w+4;
- int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
- int yyy, k4=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist)-k3;
- t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
-
- x->x_scale = (int)scale;
- if(glist_isvisible(x->x_gui.x_glist))
- {
- for(i=1; i<=IEM_VU_STEPS; i++)
- {
- yyy = k4 + k1*(k2-i);
- if((i+2)&3)
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
- canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_lcol, x, i);
- }
- i=IEM_VU_STEPS+1;
- yyy = k4 + k1*(k2-i);
- sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
- -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
- canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
- x->x_gui.x_lcol, x, i);
- }
- }
-}
-
-static void vu_properties(t_gobj *z, t_glist *owner)
-{
- t_vu *x = (t_vu *)z;
- char buf[800];
- t_symbol *srl[3];
-
- iemgui_properties(&x->x_gui, srl);
- sprintf(buf, "pdtk_iemgui_dialog %%s VU-METER \
- --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
- empty 0.0 empty 0.0 empty %d \
- %d no_scale scale %d %d empty %d \
- %s %s \
- %s %d %d \
- %d %d \
- %d %d %d\n",
- x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_VU_STEPS*IEM_VU_MINSIZE,
- 0,/*no_schedule*/
- x->x_scale, -1, -1, -1,/*no linlog, no init, no multi*/
- "nosndno", srl[1]->s_name,/*no send*/
- srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
- x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
- 0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, 0xffffff & x->x_gui.x_lcol);
- gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
-}
-
-static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *srl[3];
- int w = (int)atom_getintarg(0, argc, argv);
- int h = (int)atom_getintarg(1, argc, argv);
- int scale = (int)atom_getintarg(4, argc, argv);
- int sr_flags;
-
- srl[0] = gensym("empty");
- sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
- x->x_gui.x_fsf.x_snd_able = 0;
- x->x_gui.x_isa.x_loadinit = 0;
- x->x_gui.x_w = iemgui_clip_size(w);
- vu_check_height(x, h);
- if(scale != 0)
- scale = 1;
- vu_scale(x, (float)scale);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
- canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
-}
-
-static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av)
-{
- x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
- if(ac > 1)
- vu_check_height(x, (int)atom_getintarg(1, ac, av));
- if(glist_isvisible(x->x_gui.x_glist))
- {
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
- (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
- canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
- }
-}
-
-static void vu_delta(t_vu *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
-
-static void vu_pos(t_vu *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void vu_color(t_vu *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
-
-static void vu_receive(t_vu *x, t_symbol *s)
-{iemgui_receive(x, &x->x_gui, s);}
-
-static void vu_label(t_vu *x, t_symbol *s)
-{iemgui_label((void *)x, &x->x_gui, s);}
-
-static void vu_label_pos(t_vu *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
-
-static void vu_label_font(t_vu *x, t_symbol *s, int ac, t_atom *av)
-{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
-
-static void vu_float(t_vu *x, t_floatarg rms)
-{
- int i;
-
- if(rms <= IEM_VU_MINDB)
- x->x_rms = 0;
- else if(rms >= IEM_VU_MAXDB)
- x->x_rms = IEM_VU_STEPS;
- else
- {
- int i = (int)(2.0*(rms + IEM_VU_OFFSET));
- x->x_rms = iemgui_vu_db2i[i];
- }
- i = (int)(100.0*rms + 10000.5);
- rms = 0.01*(float)(i - 10000);
- x->x_fr = rms;
- outlet_float(x->x_out_rms, rms);
- vu_update_rms(x, x->x_gui.x_glist);
-}
-
-static void vu_ft1(t_vu *x, t_floatarg peak)
-{
- int i;
-
- if(peak <= IEM_VU_MINDB)
- x->x_peak = 0;
- else if(peak >= IEM_VU_MAXDB)
- x->x_peak = IEM_VU_STEPS;
- else
- {
- int i = (int)(2.0*(peak + IEM_VU_OFFSET));
- x->x_peak = iemgui_vu_db2i[i];
- }
- i = (int)(100.0*peak + 10000.5);
- peak = 0.01*(float)(i - 10000);
- x->x_fp = peak;
- outlet_float(x->x_out_peak, peak);
- vu_update_peak(x, x->x_gui.x_glist);
-}
-
-static void vu_bang(t_vu *x)
-{
- outlet_float(x->x_out_peak, x->x_fp);
- outlet_float(x->x_out_rms, x->x_fr);
- vu_update_rms(x, x->x_gui.x_glist);
- vu_update_peak(x, x->x_gui.x_glist);
-}
-
-static void *vu_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_vu *x = (t_vu *)pd_new(vu_class);
- int bflcol[]={-66577, -1, -1};
- int w=IEM_GUI_DEFAULTSIZE, h=IEM_VU_STEPS*IEM_VU_DEFAULTSIZE;
- int ldx=-1, ldy=-8, f=0, fs=8, scale=1;
- int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
- char str[144];
-
- iem_inttosymargs(&x->x_gui.x_isa, 0);
- iem_inttofstyle(&x->x_gui.x_fsf, 0);
-
- if((argc >= 11)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
- &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
- &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
- &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
- &&IS_A_FLOAT(argv,6)&&IS_A_FLOAT(argv,7)
- &&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10))
- {
- w = (int)atom_getintarg(0, argc, argv);
- h = (int)atom_getintarg(1, argc, argv);
- iemgui_new_getnames(&x->x_gui, 1, argv);
- ldx = (int)atom_getintarg(4, argc, argv);
- ldy = (int)atom_getintarg(5, argc, argv);
- iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(6, argc, argv));
- fs = (int)atom_getintarg(7, argc, argv);
- bflcol[0] = (int)atom_getintarg(8, argc, argv);
- bflcol[2] = (int)atom_getintarg(9, argc, argv);
- scale = (int)atom_getintarg(10, argc, argv);
- }
- else iemgui_new_getnames(&x->x_gui, 1, 0);
- if((argc == 12)&&IS_A_FLOAT(argv,11))
- iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(11, argc, argv));
- x->x_gui.x_draw = (t_iemfunptr)vu_draw;
- x->x_gui.x_fsf.x_snd_able = 0;
- x->x_gui.x_fsf.x_rcv_able = 1;
- x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
- if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
- x->x_gui.x_fsf.x_rcv_able = 0;
- if (x->x_gui.x_fsf.x_font_style == 1)
- strcpy(x->x_gui.x_font, "helvetica");
- else if(x->x_gui.x_fsf.x_font_style == 2)
- strcpy(x->x_gui.x_font, "times");
- else { x->x_gui.x_fsf.x_font_style = 0;
- strcpy(x->x_gui.x_font, "courier"); }
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- x->x_gui.x_ldx = ldx;
- x->x_gui.x_ldy = ldy;
-
- if(fs < 4)
- fs = 4;
- x->x_gui.x_fontsize = fs;
- x->x_gui.x_w = iemgui_clip_size(w);
- vu_check_height(x, h);
- iemgui_all_colfromload(&x->x_gui, bflcol);
- if(scale != 0)
- scale = 1;
- x->x_scale = scale;
- x->x_peak = 0;
- x->x_rms = 0;
- x->x_fp = -101.0;
- x->x_fr = -101.0;
- iemgui_verify_snd_ne_rcv(&x->x_gui);
- inlet_new(&x->x_gui.x_obj, &x->x_gui.x_obj.ob_pd, &s_float, gensym("ft1"));
- x->x_out_rms = outlet_new(&x->x_gui.x_obj, &s_float);
- x->x_out_peak = outlet_new(&x->x_gui.x_obj, &s_float);
- return (x);
-}
-
-static void vu_free(t_vu *x)
-{
- if(x->x_gui.x_fsf.x_rcv_able)
- pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
- gfxstub_deleteforkey(x);
-}
-
-void g_vumeter_setup(void)
-{
- vu_class = class_new(gensym("vu"), (t_newmethod)vu_new, (t_method)vu_free,
- sizeof(t_vu), 0, A_GIMME, 0);
- class_addbang(vu_class,vu_bang);
- class_addfloat(vu_class,vu_float);
- class_addmethod(vu_class, (t_method)vu_ft1, gensym("ft1"), A_FLOAT, 0);
- class_addmethod(vu_class, (t_method)vu_dialog, gensym("dialog"),
- A_GIMME, 0);
- class_addmethod(vu_class, (t_method)vu_size, gensym("size"), A_GIMME, 0);
- class_addmethod(vu_class, (t_method)vu_scale, gensym("scale"), A_DEFFLOAT, 0);
- class_addmethod(vu_class, (t_method)vu_delta, gensym("delta"), A_GIMME, 0);
- class_addmethod(vu_class, (t_method)vu_pos, gensym("pos"), A_GIMME, 0);
- class_addmethod(vu_class, (t_method)vu_color, gensym("color"), A_GIMME, 0);
- class_addmethod(vu_class, (t_method)vu_receive, gensym("receive"), A_DEFSYM, 0);
- class_addmethod(vu_class, (t_method)vu_label, gensym("label"), A_DEFSYM, 0);
- class_addmethod(vu_class, (t_method)vu_label_pos, gensym("label_pos"), A_GIMME, 0);
- class_addmethod(vu_class, (t_method)vu_label_font, gensym("label_font"), A_GIMME, 0);
- vu_widgetbehavior.w_getrectfn = vu_getrect;
- vu_widgetbehavior.w_displacefn = iemgui_displace;
- vu_widgetbehavior.w_selectfn = iemgui_select;
- vu_widgetbehavior.w_activatefn = NULL;
- vu_widgetbehavior.w_deletefn = iemgui_delete;
- vu_widgetbehavior.w_visfn = iemgui_vis;
- vu_widgetbehavior.w_clickfn = NULL;
- class_setwidget(vu_class,&vu_widgetbehavior);
- class_sethelpsymbol(vu_class, gensym("vu"));
- class_setsavefn(vu_class, vu_save);
- class_setpropertiesfn(vu_class, vu_properties);
-}
diff --git a/apps/plugins/pdbox/PDa/src/m_atom.c b/apps/plugins/pdbox/PDa/src/m_atom.c
index a4b08ff2cb..f2ed3a0b65 100644
--- a/apps/plugins/pdbox/PDa/src/m_atom.c
+++ b/apps/plugins/pdbox/PDa/src/m_atom.c
@@ -127,132 +127,4 @@ void atom_string(t_atom *a, char *buf, unsigned int bufsize)
bug("atom_string");
}
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include "m_pd.h"
-#include <stdio.h>
-#include <string.h>
-
- /* convenience routines for checking and getting values of
- atoms. There's no "pointer" version since there's nothing
- safe to return if there's an error. */
-
-t_float atom_getfloat(t_atom *a)
-{
- if (a->a_type == A_FLOAT) return (a->a_w.w_float);
- else return (0);
-}
-
-t_int atom_getint(t_atom *a)
-{
- return (atom_getfloat(a));
-}
-
-t_symbol *atom_getsymbol(t_atom *a) /* LATER think about this more carefully */
-{
- char buf[30];
- if (a->a_type == A_SYMBOL) return (a->a_w.w_symbol);
- else return (&s_float);
-}
-
-t_symbol *atom_gensym(t_atom *a) /* this works better for graph labels */
-{
- char buf[30];
- if (a->a_type == A_SYMBOL) return (a->a_w.w_symbol);
- else if (a->a_type == A_FLOAT)
- sprintf(buf, "%g", a->a_w.w_float);
- else strcpy(buf, "???");
- return (gensym(buf));
-}
-
-t_float atom_getfloatarg(int which, int argc, t_atom *argv)
-{
- if (argc <= which) return (0);
- argv += which;
- if (argv->a_type == A_FLOAT) return (argv->a_w.w_float);
- else return (0);
-}
-
-t_int atom_getintarg(int which, int argc, t_atom *argv)
-{
- return (atom_getfloatarg(which, argc, argv));
-}
-
-t_symbol *atom_getsymbolarg(int which, int argc, t_atom *argv)
-{
- if (argc <= which) return (&s_);
- argv += which;
- if (argv->a_type == A_SYMBOL) return (argv->a_w.w_symbol);
- else return (&s_);
-}
-
-/* convert an atom into a string, in the reverse sense of binbuf_text (q.v.)
-* special attention is paid to symbols containing the special characters
-* ';', ',', '$', and '\'; these are quoted with a preceding '\', except that
-* the '$' only gets quoted at the beginning of the string.
-*/
-void atom_string(t_atom *a, char *buf, unsigned int bufsize)
-{
- char tbuf[30];
- switch(a->a_type)
- {
- case A_SEMI: strcpy(buf, ";"); break;
- case A_COMMA: strcpy(buf, ","); break;
- case A_POINTER:
- strcpy(buf, "(pointer)");
- break;
- case A_FLOAT:
- sprintf(tbuf, "%g", a->a_w.w_float);
- if (strlen(tbuf) < bufsize-1) strcpy(buf, tbuf);
- else if (a->a_w.w_float < 0) strcpy(buf, "-");
- else strcat(buf, "+");
- break;
- case A_SYMBOL:
- {
- char *sp;
- unsigned int len;
- int quote;
- for (sp = a->a_w.w_symbol->s_name, len = 0, quote = 0; *sp; sp++, len++)
- if (*sp == ';' || *sp == ',' || *sp == '\\' ||
- (*sp == '$' && sp == a->a_w.w_symbol->s_name && sp[1] >= '0'
- && sp[1] <= '9'))
- quote = 1;
- if (quote)
- {
- char *bp = buf, *ep = buf + (bufsize-2);
- sp = a->a_w.w_symbol->s_name;
- while (bp < ep && *sp)
- {
- if (*sp == ';' || *sp == ',' || *sp == '\\' ||
- (*sp == '$' && bp == buf && sp[1] >= '0' && sp[1] <= '9'))
- *bp++ = '\\';
- *bp++ = *sp++;
- }
- if (*sp) *bp++ = '*';
- *bp = 0;
- /* post("quote %s -> %s", a->a_w.w_symbol->s_name, buf); */
- }
- else
- {
- if (len < bufsize-1) strcpy(buf, a->a_w.w_symbol->s_name);
- else
- {
- strncpy(buf, a->a_w.w_symbol->s_name, bufsize - 2);
- strcpy(buf + (bufsize - 2), "*");
- }
- }
- }
- break;
- case A_DOLLAR:
- sprintf(buf, "$%d", a->a_w.w_index);
- break;
- case A_DOLLSYM:
- sprintf(buf, "$%s", a->a_w.w_symbol->s_name);
- break;
- default:
- bug("atom_string");
- }
-}
diff --git a/apps/plugins/pdbox/PDa/src/m_binbuf.c b/apps/plugins/pdbox/PDa/src/m_binbuf.c
index c215e399e6..03a560db7b 100644
--- a/apps/plugins/pdbox/PDa/src/m_binbuf.c
+++ b/apps/plugins/pdbox/PDa/src/m_binbuf.c
@@ -1217,1222 +1217,4 @@ void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir)
pd_doloadbang();
canvas_resume_dsp(dspstate);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-
-/* IOhannes :
- * changed the canvas_restore in "g_canvas.c", so that it might accept $args as well (like "pd $0_test")
- * so you can make multiple & distinguishable templates
- * 1511:forum::für::umläute:2001
- * change marked with IOhannes
- */
-
-#include <stdlib.h>
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <stdio.h>
-#ifdef UNIX
-#include <unistd.h>
-#endif
-#ifdef MSW
-#include <io.h>
-#endif
-#include <fcntl.h>
-#include <string.h>
-#include <stdarg.h>
-
-struct _binbuf
-{
- int b_n;
- t_atom *b_vec;
-};
-
-t_binbuf *binbuf_new(void)
-{
- t_binbuf *x = (t_binbuf *)t_getbytes(sizeof(*x));
- x->b_n = 0;
- x->b_vec = t_getbytes(0);
- return (x);
-}
-
-void binbuf_free(t_binbuf *x)
-{
- t_freebytes(x->b_vec, x->b_n * sizeof(*x->b_vec));
- t_freebytes(x, sizeof(*x));
-}
-
-t_binbuf *binbuf_duplicate(t_binbuf *y)
-{
- t_binbuf *x = (t_binbuf *)t_getbytes(sizeof(*x));
- x->b_n = y->b_n;
- x->b_vec = t_getbytes(x->b_n * sizeof(*x->b_vec));
- memcpy(x->b_vec, y->b_vec, x->b_n * sizeof(*x->b_vec));
- return (x);
-}
-
-void binbuf_clear(t_binbuf *x)
-{
- x->b_vec = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec), 0);
- x->b_n = 0;
-}
-
- /* convert text to a binbuf */
-void binbuf_text(t_binbuf *x, char *text, size_t size)
-{
- char buf[MAXPDSTRING+1], *bufp, *ebuf = buf+MAXPDSTRING;
- const char *textp = text, *etext = text+size;
- t_atom *ap;
- int nalloc = 16, natom = 0;
- t_freebytes(x->b_vec, x->b_n * sizeof(*x->b_vec));
- x->b_vec = t_getbytes(nalloc * sizeof(*x->b_vec));
- ap = x->b_vec;
- x->b_n = 0;
- while (1)
- {
- int type;
- /* skip leading space */
- while ((textp != etext) && (*textp == ' ' || *textp == '\n'
- || *textp == '\r' || *textp == '\t')) textp++;
- if (textp == etext) break;
- if (*textp == ';') SETSEMI(ap), textp++;
- else if (*textp == ',') SETCOMMA(ap), textp++;
- else
- {
- /* it's an atom other than a comma or semi */
- char c;
- int floatstate = 0, slash = 0, lastslash = 0,
- firstslash = (*textp == '\\');
- bufp = buf;
- do
- {
- c = *bufp = *textp++;
- lastslash = slash;
- slash = (c == '\\');
-
- if (floatstate >= 0)
- {
- int digit = (c >= '0' && c <= '9'),
- dot = (c == '.'), minus = (c == '-'),
- plusminus = (minus || (c == '+')),
- expon = (c == 'e' || c == 'E');
- if (floatstate == 0) /* beginning */
- {
- if (minus) floatstate = 1;
- else if (digit) floatstate = 2;
- else if (dot) floatstate = 3;
- else floatstate = -1;
- }
- else if (floatstate == 1) /* got minus */
- {
- if (digit) floatstate = 2;
- else if (dot) floatstate = 3;
- else floatstate = -1;
- }
- else if (floatstate == 2) /* got digits */
- {
- if (dot) floatstate = 4;
- else if (expon) floatstate = 6;
- else if (!digit) floatstate = -1;
- }
- else if (floatstate == 3) /* got '.' without digits */
- {
- if (digit) floatstate = 5;
- else floatstate = -1;
- }
- else if (floatstate == 4) /* got '.' after digits */
- {
- if (digit) floatstate = 5;
- else if (expon) floatstate = 6;
- else floatstate = -1;
- }
- else if (floatstate == 5) /* got digits after . */
- {
- if (expon) floatstate = 6;
- else if (!digit) floatstate = -1;
- }
- else if (floatstate == 6) /* got 'e' */
- {
- if (plusminus) floatstate = 7;
- else if (digit) floatstate = 8;
- else floatstate = -1;
- }
- else if (floatstate == 7) /* got plus or minus */
- {
- if (digit) floatstate = 8;
- else floatstate = -1;
- }
- else if (floatstate == 8) /* got digits */
- {
- if (!digit) floatstate = -1;
- }
- }
- if (!slash) bufp++;
- }
- while (textp != etext && bufp != ebuf &&
- (slash || (*textp != ' ' && *textp != '\n' && *textp != '\r'
- && *textp != '\t' &&*textp != ',' && *textp != ';')));
- *bufp = 0;
-#if 0
- post("buf %s", buf);
-#endif
- if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9' && !firstslash)
- {
- for (bufp = buf+2; *bufp; bufp++)
- if (*bufp < '0' || *bufp > '9')
- {
- SETDOLLSYM(ap, gensym(buf+1));
- goto didit;
- }
- SETDOLLAR(ap, atoi(buf+1));
- didit: ;
- }
- else
- {
- if (floatstate == 2 || floatstate == 4 || floatstate == 5 ||
- floatstate == 8)
- SETFLOAT(ap, atof(buf));
- else SETSYMBOL(ap, gensym(buf));
- }
- }
- ap++;
- natom++;
- if (natom == nalloc)
- {
- x->b_vec = t_resizebytes(x->b_vec, nalloc * sizeof(*x->b_vec),
- nalloc * (2*sizeof(*x->b_vec)));
- nalloc = nalloc * 2;
- ap = x->b_vec + natom;
- }
- if (textp == etext) break;
- }
- /* reallocate the vector to exactly the right size */
- x->b_vec = t_resizebytes(x->b_vec, nalloc * sizeof(*x->b_vec),
- natom * sizeof(*x->b_vec));
- x->b_n = natom;
-}
-
- /* convert a binbuf to text; no null termination. */
-void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp)
-{
- char *buf = getbytes(0), *newbuf;
- int length = 0;
- char string[MAXPDSTRING];
- t_atom *ap;
- int indx;
-
- for (ap = x->b_vec, indx = x->b_n; indx--; ap++)
- {
- int newlength;
- if ((ap->a_type == A_SEMI || ap->a_type == A_COMMA) &&
- length && buf[length-1] == ' ') length--;
- atom_string(ap, string, MAXPDSTRING);
- newlength = length + strlen(string) + 1;
- if (!(newbuf = resizebytes(buf, length, newlength))) break;
- buf = newbuf;
- strcpy(buf + length, string);
- length = newlength;
- if (ap->a_type == A_SEMI) buf[length-1] = '\n';
- else buf[length-1] = ' ';
- }
- if (length && buf[length-1] == ' ')
- {
- if (newbuf = t_resizebytes(buf, length, length-1))
- {
- buf = newbuf;
- length--;
- }
- }
- *bufp = buf;
- *lengthp = length;
-}
-
-/* LATER improve the out-of-space behavior below. Also fix this so that
-writing to file doesn't buffer everything together. */
-
-void binbuf_add(t_binbuf *x, int argc, t_atom *argv)
-{
- int newsize = x->b_n + argc, i;
- t_atom *ap;
- if (ap = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec),
- newsize * sizeof(*x->b_vec)))
- x->b_vec = ap;
- else
- {
- error("binbuf_addmessage: out of space");
- return;
- }
-#if 0
- startpost("binbuf_add: ");
- postatom(argc, argv);
- endpost();
-#endif
- for (ap = x->b_vec + x->b_n, i = argc; i--; ap++)
- *ap = *(argv++);
- x->b_n = newsize;
-}
-
-#define MAXADDMESSV 100
-void binbuf_addv(t_binbuf *x, char *fmt, ...)
-{
- va_list ap;
- t_atom arg[MAXADDMESSV], *at =arg;
- int nargs = 0;
- char *fp = fmt;
-
- va_start(ap, fmt);
- while (1)
- {
- if (nargs >= MAXADDMESSV)
- {
- error("binbuf_addmessv: only %d allowed", MAXADDMESSV);
- break;
- }
- switch(*fp++)
- {
- case 'i': SETFLOAT(at, va_arg(ap, t_int)); break;
- case 'f': SETFLOAT(at, va_arg(ap, double)); break;
- case 's': SETSYMBOL(at, va_arg(ap, t_symbol *)); break;
- case ';': SETSEMI(at); break;
- case ',': SETCOMMA(at); break;
- default: goto done;
- }
- at++;
- nargs++;
- }
-done:
- va_end(ap);
- binbuf_add(x, nargs, arg);
-}
-
-/* add a binbuf to another one for saving. Semicolons and commas go to
-symbols ";", "'",; the symbol ";" goes to "\;", etc. */
-
-void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y)
-{
- t_binbuf *z = binbuf_new();
- int i;
- t_atom *ap;
- binbuf_add(z, y->b_n, y->b_vec);
- for (i = 0, ap = z->b_vec; i < z->b_n; i++, ap++)
- {
- char tbuf[MAXPDSTRING];
- switch (ap->a_type)
- {
- case A_FLOAT:
- break;
- case A_SEMI:
- SETSYMBOL(ap, gensym(";"));
- break;
- case A_COMMA:
- SETSYMBOL(ap, gensym(","));
- break;
- case A_DOLLAR:
- sprintf(tbuf, "$%d", ap->a_w.w_index);
- SETSYMBOL(ap, gensym(tbuf));
- break;
- case A_DOLLSYM:
- sprintf(tbuf, "$%s", ap->a_w.w_symbol->s_name);
- SETSYMBOL(ap, gensym(tbuf));
- break;
- case A_SYMBOL:
- /* FIXME make this general */
- if (!strcmp(ap->a_w.w_symbol->s_name, ";"))
- SETSYMBOL(ap, gensym(";"));
- else if (!strcmp(ap->a_w.w_symbol->s_name, ","))
- SETSYMBOL(ap, gensym(","));
- break;
- default:
- bug("binbuf_addbinbuf");
- }
- }
-
- binbuf_add(x, z->b_n, z->b_vec);
-}
-
-void binbuf_addsemi(t_binbuf *x)
-{
- t_atom a;
- SETSEMI(&a);
- binbuf_add(x, 1, &a);
-}
-
-/* Supply atoms to a binbuf from a message, making the opposite changes
-from binbuf_addbinbuf. The symbol ";" goes to a semicolon, etc. */
-
-void binbuf_restore(t_binbuf *x, int argc, t_atom *argv)
-{
- int newsize = x->b_n + argc, i;
- t_atom *ap;
- if (ap = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec),
- newsize * sizeof(*x->b_vec)))
- x->b_vec = ap;
- else
- {
- error("binbuf_addmessage: out of space");
- return;
- }
-
- for (ap = x->b_vec + x->b_n, i = argc; i--; ap++)
- {
- if (argv->a_type == A_SYMBOL)
- {
- char *str = argv->a_w.w_symbol->s_name;
- if (!strcmp(str, ";")) SETSEMI(ap);
- else if (!strcmp(str, ",")) SETCOMMA(ap);
- else if (str[0] == '$' && str[1] >= '0' && str[1] <= '9')
- {
- int dollsym = 0;
- char *str2;
- for (str2 = str + 2; *str2; str2++)
- if (*str2 < '0' || *str2 > '9')
- dollsym = 1;
- if (dollsym)
- SETDOLLSYM(ap, gensym(str + 1));
- else
- {
- int dollar = 0;
- sscanf(argv->a_w.w_symbol->s_name + 1, "%d", &dollar);
- SETDOLLAR(ap, dollar);
- }
- }
- else *ap = *argv;
- argv++;
- }
- else *ap = *(argv++);
- }
- x->b_n = newsize;
-}
-
-
-#define MSTACKSIZE 2048
-
-void binbuf_print(t_binbuf *x)
-{
- int i, startedpost = 0, newline = 1;
- for (i = 0; i < x->b_n; i++)
- {
- if (newline)
- {
- if (startedpost) endpost();
- startpost("");
- startedpost = 1;
- }
- postatom(1, x->b_vec + i);
- if (x->b_vec[i].a_type == A_SEMI)
- newline = 1;
- else newline = 0;
- }
- if (startedpost) endpost();
-}
-
-int binbuf_getnatom(t_binbuf *x)
-{
- return (x->b_n);
-}
-
-t_atom *binbuf_getvec(t_binbuf *x)
-{
- return (x->b_vec);
-}
-
-int canvas_getdollarzero( void);
-
-t_symbol *binbuf_realizedollsym(t_symbol *s, int ac, t_atom *av, int tonew)
-{
- int argno = atol(s->s_name), lastnum;
- char buf[MAXPDSTRING], c, *sp;
- for (lastnum = 0, sp = s->s_name; ((c = *sp) && c >= '0' && c <= '9');
- sp++, lastnum++)
- if (!c || argno < 0 || argno > ac)
- {
- if (!tonew)
- return (0);
- else sprintf(buf, "$%d", argno);
- }
- else if (argno == 0)
- sprintf(buf, "%d", canvas_getdollarzero());
- else
- atom_string(av+(argno-1), buf, MAXPDSTRING/2-1);
- strncat(buf, sp, MAXPDSTRING/2-1);
- return (gensym(buf));
-}
-
-void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv)
-{
- static t_atom mstack[MSTACKSIZE], *msp = mstack, *ems = mstack+MSTACKSIZE;
- t_atom *stackwas = msp;
- t_atom *at = x->b_vec;
- int ac = x->b_n;
- int nargs;
- while (1)
- {
- t_pd *nexttarget;
- /* get a target. */
- while (!target)
- {
- t_symbol *s;
- while (ac && (at->a_type == A_SEMI || at->a_type == A_COMMA))
- ac--, at++;
- if (!ac) break;
- if (at->a_type == A_DOLLAR)
- {
- if (at->a_w.w_index <= 0 || at->a_w.w_index > argc)
- {
- error("$%d: not enough arguments supplied",
- at->a_w.w_index);
- goto cleanup;
- }
- else if (argv[at->a_w.w_index-1].a_type != A_SYMBOL)
- {
- error("$%d: symbol needed as message destination",
- at->a_w.w_index);
- goto cleanup;
- }
- else s = argv[at->a_w.w_index-1].a_w.w_symbol;
- }
- else if (at->a_type == A_DOLLSYM)
- {
- if (!(s = binbuf_realizedollsym(at->a_w.w_symbol,
- argc, argv, 0)))
- {
- error("$%s: not enough arguments supplied",
- at->a_w.w_symbol->s_name);
- goto cleanup;
- }
- }
- else s = atom_getsymbol(at);
- if (!(target = s->s_thing))
- {
- error("%s: no such object", s->s_name);
- cleanup:
- do at++, ac--;
- while (ac && at->a_type != A_SEMI);
- /* LATER eat args until semicolon and continue */
- continue;
- }
- else
- {
- at++, ac--;
- break;
- }
- }
- if (!ac) break;
- nargs = 0;
- nexttarget = target;
- while (1)
- {
- t_symbol *s9;
- if (!ac) goto gotmess;
- if (msp >= ems)
- {
- error("message stack overflow");
- goto broken;
- }
- switch (at->a_type)
- {
- case A_SEMI:
- /* semis and commas in new message just get bashed to
- a symbol. This is needed so you can pass them to "expr." */
- if (target == &pd_objectmaker)
- {
- SETSYMBOL(msp, gensym(";"));
- break;
- }
- else
- {
- nexttarget = 0;
- goto gotmess;
- }
- case A_COMMA:
- if (target == &pd_objectmaker)
- {
- SETSYMBOL(msp, gensym(","));
- break;
- }
- else goto gotmess;
- case A_FLOAT:
- case A_SYMBOL:
- *msp = *at;
- break;
- case A_DOLLAR:
- if (at->a_w.w_index > 0 && at->a_w.w_index <= argc)
- *msp = argv[at->a_w.w_index-1];
- else if (at->a_w.w_index == 0)
- SETFLOAT(msp, canvas_getdollarzero());
- else
- {
- if (target == &pd_objectmaker)
- SETFLOAT(msp, 0);
- else
- {
- error("$%d: argument number out of range",
- at->a_w.w_index);
- SETFLOAT(msp, 0);
- }
- }
- break;
- case A_DOLLSYM:
- s9 = binbuf_realizedollsym(at->a_w.w_symbol, argc, argv,
- target == &pd_objectmaker);
- if (!s9)
- goto broken;
- SETSYMBOL(msp, s9);
- break;
- default:
- bug("bad item in binbuf");
- goto broken;
- }
- msp++;
- ac--;
- at++;
- nargs++;
- }
- gotmess:
- if (nargs)
- {
- switch (stackwas->a_type)
- {
- case A_SYMBOL:
- typedmess(target, stackwas->a_w.w_symbol, nargs-1, stackwas+1);
- break;
- case A_FLOAT:
- if (nargs == 1) pd_float(target, stackwas->a_w.w_float);
- else pd_list(target, 0, nargs, stackwas);
- break;
- }
- }
- msp = stackwas;
- if (!ac) break;
- target = nexttarget;
- at++;
- ac--;
- }
-
- return;
-broken:
- msp = stackwas;
-}
-
-static int binbuf_doopen(char *s, int mode)
-{
- char namebuf[MAXPDSTRING];
-#ifdef MSW
- mode |= O_BINARY;
-#endif
- sys_bashfilename(s, namebuf);
- return (open(namebuf, mode));
-}
-
-static FILE *binbuf_dofopen(char *s, char *mode)
-{
- char namebuf[MAXPDSTRING];
- sys_bashfilename(s, namebuf);
- return (fopen(namebuf, mode));
-}
-int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag)
-{
- long length;
- int fd;
- int readret;
- char *buf;
- char namebuf[MAXPDSTRING];
-
- namebuf[0] = 0;
- if (*dirname)
- strcat(namebuf, dirname), strcat(namebuf, "/");
- strcat(namebuf, filename);
-
- if ((fd = binbuf_doopen(namebuf, 0)) < 0)
- {
- fprintf(stderr, "open: ");
- perror(namebuf);
- return (1);
- }
- if ((length = lseek(fd, 0, SEEK_END)) < 0 || lseek(fd, 0, SEEK_SET) < 0
- || !(buf = t_getbytes(length)))
- {
- fprintf(stderr, "lseek: ");
- perror(namebuf);
- close(fd);
- return(1);
- }
- if ((readret = read(fd, buf, length)) < length)
- {
- fprintf(stderr, "read (%d %ld) -> %d\n", fd, length, readret);
- perror(namebuf);
- close(fd);
- t_freebytes(buf, length);
- return(1);
- }
- /* optionally map carriage return to semicolon */
- if (crflag)
- {
- int i;
- for (i = 0; i < length; i++)
- if (buf[i] == '\n')
- buf[i] = ';';
- }
- binbuf_text(b, buf, length);
-
-#if 0
- startpost("binbuf_read "); postatom(b->b_n, b->b_vec); endpost();
-#endif
-
- t_freebytes(buf, length);
- close(fd);
- return (0);
-}
-
-int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname,
- int crflag)
-{
- int filedesc;
- char buf[MAXPDSTRING], *bufptr;
- if ((filedesc = open_via_path(
- dirname, filename, "", buf, &bufptr, MAXPDSTRING, 0)) < 0)
- {
- error("%s: can't open", filename);
- return (1);
- }
- else close (filedesc);
- if (binbuf_read(b, bufptr, buf, crflag))
- return (1);
- else return (0);
-}
-
-#define WBUFSIZE 4096
-static t_binbuf *binbuf_convert(t_binbuf *oldb, int maxtopd);
-
- /* write a binbuf to a text file. If "crflag" is set we suppress
- semicolons. */
-int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag)
-{
- FILE *f = 0;
- char sbuf[WBUFSIZE], fbuf[MAXPDSTRING], *bp = sbuf, *ep = sbuf + WBUFSIZE;
- t_atom *ap;
- int indx, deleteit = 0;
- int ncolumn = 0;
-
- fbuf[0] = 0;
- if (*dir)
- strcat(fbuf, dir), strcat(fbuf, "/");
- strcat(fbuf, filename);
- if (!strcmp(filename + strlen(filename) - 4, ".pat"))
- {
- x = binbuf_convert(x, 0);
- deleteit = 1;
- }
-
- if (!(f = binbuf_dofopen(fbuf, "w")))
- {
- fprintf(stderr, "open: ");
- sys_unixerror(fbuf);
- goto fail;
- }
- for (ap = x->b_vec, indx = x->b_n; indx--; ap++)
- {
- int length;
- /* estimate how many characters will be needed. Printing out
- symbols may need extra characters for inserting backslashes. */
- if (ap->a_type == A_SYMBOL || ap->a_type == A_DOLLSYM)
- length = 80 + strlen(ap->a_w.w_symbol->s_name);
- else length = 40;
- if (ep - bp < length)
- {
- if (fwrite(sbuf, bp-sbuf, 1, f) < 1)
- {
- sys_unixerror(fbuf);
- goto fail;
- }
- bp = sbuf;
- }
- if ((ap->a_type == A_SEMI || ap->a_type == A_COMMA) &&
- bp > sbuf && bp[-1] == ' ') bp--;
- if (!crflag || ap->a_type != A_SEMI)
- {
- atom_string(ap, bp, (ep-bp)-2);
- length = strlen(bp);
- bp += length;
- ncolumn += length;
- }
- if (ap->a_type == A_SEMI || (!crflag && ncolumn > 65))
- {
- *bp++ = '\n';
- ncolumn = 0;
- }
- else
- {
- *bp++ = ' ';
- ncolumn++;
- }
- }
- if (fwrite(sbuf, bp-sbuf, 1, f) < 1)
- {
- sys_unixerror(fbuf);
- goto fail;
- }
- if (deleteit)
- binbuf_free(x);
- fclose(f);
- return (0);
-fail:
- if (deleteit)
- binbuf_free(x);
- if (f)
- fclose(f);
- return (1);
-}
-
-/* The following routine attempts to convert from max to pd or back. The
-max to pd direction is working OK but you will need to make lots of
-abstractions for objects like "gate" which don't exist in Pd. conversion
-from Pd to Max hasn't been tested for patches with subpatches yet! */
-
-#define MAXSTACK 1000
-
-#define ISSYMBOL(a, b) ((a)->a_type == A_SYMBOL && \
- !strcmp((a)->a_w.w_symbol->s_name, (b)))
-
-static t_binbuf *binbuf_convert(t_binbuf *oldb, int maxtopd)
-{
- t_binbuf *newb = binbuf_new();
- t_atom *vec = oldb->b_vec;
- t_int n = oldb->b_n, nextindex, stackdepth = 0, stack[MAXSTACK],
- nobj = 0, i;
- t_atom outmess[MAXSTACK], *nextmess;
- if (!maxtopd)
- binbuf_addv(newb, "ss;", gensym("max"), gensym("v2"));
- for (nextindex = 0; nextindex < n; )
- {
- int endmess, natom;
- char *first, *second;
- for (endmess = nextindex; endmess < n && vec[endmess].a_type != A_SEMI;
- endmess++)
- ;
- if (endmess == n) break;
- if (endmess == nextindex || endmess == nextindex + 1
- || vec[nextindex].a_type != A_SYMBOL ||
- vec[nextindex+1].a_type != A_SYMBOL)
- {
- nextindex = endmess + 1;
- continue;
- }
- natom = endmess - nextindex;
- if (natom > MAXSTACK-10) natom = MAXSTACK-10;
- nextmess = vec + nextindex;
- first = nextmess->a_w.w_symbol->s_name;
- second = (nextmess+1)->a_w.w_symbol->s_name;
- if (maxtopd)
- {
- /* case 1: importing a ".pat" file into Pd. */
-
- /* dollar signs in file translate to symbols */
- for (i = 0; i < natom; i++)
- {
- if (nextmess[i].a_type == A_DOLLAR)
- {
- char buf[100];
- sprintf(buf, "$%d", nextmess[i].a_w.w_index);
- SETSYMBOL(nextmess+i, gensym(buf));
- }
- else if (nextmess[i].a_type == A_DOLLSYM)
- {
- char buf[100];
- sprintf(buf, "$%s", nextmess[i].a_w.w_symbol->s_name);
- SETSYMBOL(nextmess+i, gensym(buf));
- }
- }
- if (!strcmp(first, "#N"))
- {
- if (!strcmp(second, "vpatcher"))
- {
- if (stackdepth >= MAXSTACK)
- {
- post("too many embedded patches");
- return (newb);
- }
- stack[stackdepth] = nobj;
- stackdepth++;
- nobj = 0;
- binbuf_addv(newb, "ssfffff;",
- gensym("#N"), gensym("canvas"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- atom_getfloatarg(4, natom, nextmess) -
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(5, natom, nextmess) -
- atom_getfloatarg(3, natom, nextmess),
- (float)sys_defaultfont);
- }
- }
- if (!strcmp(first, "#P"))
- {
- /* drop initial "hidden" flag */
- if (!strcmp(second, "hidden"))
- {
- nextmess++;
- natom--;
- second = (nextmess+1)->a_w.w_symbol->s_name;
- }
- if (natom >= 7 && !strcmp(second, "newobj")
- && (ISSYMBOL(&nextmess[6], "patcher") ||
- ISSYMBOL(&nextmess[6], "p")))
- {
- binbuf_addv(newb, "ssffss;",
- gensym("#X"), gensym("restore"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- gensym("pd"), atom_getsymbolarg(7, natom, nextmess));
- if (stackdepth) stackdepth--;
- nobj = stack[stackdepth];
- nobj++;
- }
- else if (!strcmp(second, "newex") || !strcmp(second, "newobj"))
- {
- t_symbol *classname =
- atom_getsymbolarg(6, natom, nextmess);
- if (classname == gensym("trigger") ||
- classname == gensym("t"))
- {
- for (i = 7; i < natom; i++)
- if (nextmess[i].a_type == A_SYMBOL &&
- nextmess[i].a_w.w_symbol == gensym("i"))
- nextmess[i].a_w.w_symbol = gensym("f");
- }
- if (classname == gensym("table"))
- classname = gensym("TABLE");
- SETSYMBOL(outmess, gensym("#X"));
- SETSYMBOL(outmess + 1, gensym("obj"));
- outmess[2] = nextmess[2];
- outmess[3] = nextmess[3];
- SETSYMBOL(outmess+4, classname);
- for (i = 7; i < natom; i++)
- outmess[i-2] = nextmess[i];
- SETSEMI(outmess + natom - 2);
- binbuf_add(newb, natom - 1, outmess);
- nobj++;
- }
- else if (!strcmp(second, "message") ||
- !strcmp(second, "comment"))
- {
- SETSYMBOL(outmess, gensym("#X"));
- SETSYMBOL(outmess + 1, gensym(
- (strcmp(second, "message") ? "text" : "msg")));
- outmess[2] = nextmess[2];
- outmess[3] = nextmess[3];
- for (i = 6; i < natom; i++)
- outmess[i-2] = nextmess[i];
- SETSEMI(outmess + natom - 2);
- binbuf_add(newb, natom - 1, outmess);
- nobj++;
- }
- else if (!strcmp(second, "button"))
- {
- binbuf_addv(newb, "ssffs;",
- gensym("#X"), gensym("obj"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- gensym("bng"));
- nobj++;
- }
- else if (!strcmp(second, "number") || !strcmp(second, "flonum"))
- {
- binbuf_addv(newb, "ssff;",
- gensym("#X"), gensym("floatatom"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess));
- nobj++;
- }
- else if (!strcmp(second, "slider"))
- {
- float inc = atom_getfloatarg(7, natom, nextmess);
- if (inc <= 0)
- inc = 1;
- binbuf_addv(newb, "ssffsffffffsssfffffffff;",
- gensym("#X"), gensym("obj"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- gensym("vsl"),
- atom_getfloatarg(4, natom, nextmess),
- atom_getfloatarg(5, natom, nextmess),
- atom_getfloatarg(6, natom, nextmess),
- atom_getfloatarg(6, natom, nextmess)
- + (atom_getfloatarg(5, natom, nextmess) - 1) * inc,
- 0., 0.,
- gensym("empty"), gensym("empty"), gensym("empty"),
- 0., -8., 0., 8., -262144., -1., -1., 0., 1.);
- nobj++;
- }
- else if (!strcmp(second, "toggle"))
- {
- binbuf_addv(newb, "ssffs;",
- gensym("#X"), gensym("obj"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- gensym("tgl"));
- nobj++;
- }
- else if (!strcmp(second, "inlet"))
- {
- binbuf_addv(newb, "ssffs;",
- gensym("#X"), gensym("obj"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- gensym((natom > 5 ? "inlet~" : "inlet")));
- nobj++;
- }
- else if (!strcmp(second, "outlet"))
- {
- binbuf_addv(newb, "ssffs;",
- gensym("#X"), gensym("obj"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- gensym((natom > 5 ? "outlet~" : "outlet")));
- nobj++;
- }
- else if (!strcmp(second, "user"))
- {
- binbuf_addv(newb, "ssffs;",
- gensym("#X"), gensym("obj"),
- atom_getfloatarg(3, natom, nextmess),
- atom_getfloatarg(4, natom, nextmess),
- atom_getsymbolarg(2, natom, nextmess));
- nobj++;
- }
- else if (!strcmp(second, "connect")||
- !strcmp(second, "fasten"))
- {
- binbuf_addv(newb, "ssffff;",
- gensym("#X"), gensym("connect"),
- nobj - atom_getfloatarg(2, natom, nextmess) - 1,
- atom_getfloatarg(3, natom, nextmess),
- nobj - atom_getfloatarg(4, natom, nextmess) - 1,
- atom_getfloatarg(5, natom, nextmess));
- }
- }
- }
- else /* Pd to Max */
- {
- if (!strcmp(first, "#N"))
- {
- if (!strcmp(second, "canvas"))
- {
- if (stackdepth >= MAXSTACK)
- {
- post("too many embedded patches");
- return (newb);
- }
- stack[stackdepth] = nobj;
- stackdepth++;
- nobj = 0;
- binbuf_addv(newb, "ssffff;",
- gensym("#N"), gensym("vpatcher"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- atom_getfloatarg(4, natom, nextmess),
- atom_getfloatarg(5, natom, nextmess));
- }
- }
- if (!strcmp(first, "#X"))
- {
- if (natom >= 5 && !strcmp(second, "restore")
- && (ISSYMBOL (&nextmess[4], "pd")))
- {
- binbuf_addv(newb, "ss;", gensym("#P"), gensym("pop"));
- binbuf_addv(newb, "ssffffss;",
- gensym("#P"), gensym("newobj"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess), 50., 1.,
- gensym("patcher"),
- atom_getsymbolarg(5, natom, nextmess));
- if (stackdepth) stackdepth--;
- nobj = stack[stackdepth];
- nobj++;
- }
- else if (!strcmp(second, "obj"))
- {
- t_symbol *classname =
- atom_getsymbolarg(4, natom, nextmess);
- if (classname == gensym("inlet"))
- binbuf_addv(newb, "ssfff;", gensym("#P"),
- gensym("inlet"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- 15.);
- else if (classname == gensym("inlet~"))
- binbuf_addv(newb, "ssffff;", gensym("#P"),
- gensym("inlet"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- 15., 1.);
- else if (classname == gensym("outlet"))
- binbuf_addv(newb, "ssfff;", gensym("#P"),
- gensym("outlet"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- 15.);
- else if (classname == gensym("outlet~"))
- binbuf_addv(newb, "ssffff;", gensym("#P"),
- gensym("outlet"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- 15., 1.);
- else if (classname == gensym("bng"))
- binbuf_addv(newb, "ssffff;", gensym("#P"),
- gensym("button"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- atom_getfloatarg(5, natom, nextmess), 0.);
- else if (classname == gensym("tgl"))
- binbuf_addv(newb, "ssffff;", gensym("#P"),
- gensym("toggle"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- atom_getfloatarg(5, natom, nextmess), 0.);
- else if (classname == gensym("vsl"))
- binbuf_addv(newb, "ssffffff;", gensym("#P"),
- gensym("slider"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess),
- atom_getfloatarg(5, natom, nextmess),
- atom_getfloatarg(6, natom, nextmess),
- (atom_getfloatarg(8, natom, nextmess) -
- atom_getfloatarg(7, natom, nextmess)) /
- (atom_getfloatarg(6, natom, nextmess) == 1? 1 :
- atom_getfloatarg(6, natom, nextmess) - 1),
- atom_getfloatarg(7, natom, nextmess));
- else
- {
- SETSYMBOL(outmess, gensym("#P"));
- SETSYMBOL(outmess + 1, gensym("newex"));
- outmess[2] = nextmess[2];
- outmess[3] = nextmess[3];
- SETFLOAT(outmess + 4, 50);
- SETFLOAT(outmess + 5, 1);
- for (i = 4; i < natom; i++)
- outmess[i+2] = nextmess[i];
- SETSEMI(outmess + natom + 2);
- binbuf_add(newb, natom + 3, outmess);
- }
- nobj++;
-
- }
- else if (!strcmp(second, "msg") ||
- !strcmp(second, "text"))
- {
- SETSYMBOL(outmess, gensym("#P"));
- SETSYMBOL(outmess + 1, gensym(
- (strcmp(second, "msg") ? "comment" : "message")));
- outmess[2] = nextmess[2];
- outmess[3] = nextmess[3];
- SETFLOAT(outmess + 4, 50);
- SETFLOAT(outmess + 5, 1);
- for (i = 4; i < natom; i++)
- outmess[i+2] = nextmess[i];
- SETSEMI(outmess + natom + 2);
- binbuf_add(newb, natom + 3, outmess);
- nobj++;
- }
- else if (!strcmp(second, "floatatom"))
- {
- binbuf_addv(newb, "ssfff;",
- gensym("#P"), gensym("flonum"),
- atom_getfloatarg(2, natom, nextmess),
- atom_getfloatarg(3, natom, nextmess), 35);
- nobj++;
- }
- else if (!strcmp(second, "connect"))
- {
- binbuf_addv(newb, "ssffff;",
- gensym("#P"), gensym("connect"),
- nobj - atom_getfloatarg(2, natom, nextmess) - 1,
- atom_getfloatarg(3, natom, nextmess),
- nobj - atom_getfloatarg(4, natom, nextmess) - 1,
- atom_getfloatarg(5, natom, nextmess));
- }
- }
- }
- nextindex = endmess + 1;
- }
- if (!maxtopd)
- binbuf_addv(newb, "ss;", gensym("#P"), gensym("pop"));
-#if 0
- binbuf_write(newb, "import-result.pd", "/tmp", 0);
-#endif
- return (newb);
-}
-
- /* function to support searching */
-int binbuf_match(t_binbuf *inbuf, t_binbuf *searchbuf)
-{
- int indexin, nmatched;
- for (indexin = 0; indexin <= inbuf->b_n - searchbuf->b_n; indexin++)
- {
- for (nmatched = 0; nmatched < searchbuf->b_n; nmatched++)
- {
- t_atom *a1 = &inbuf->b_vec[indexin + nmatched],
- *a2 = &searchbuf->b_vec[nmatched];
- if (a1->a_type != a2->a_type ||
- a1->a_type == A_SYMBOL && a1->a_w.w_symbol != a2->a_w.w_symbol
- ||
- a1->a_type == A_FLOAT && a1->a_w.w_float != a2->a_w.w_float
- ||
- a1->a_type == A_DOLLAR && a1->a_w.w_index != a2->a_w.w_index
- ||
- a1->a_type == A_DOLLSYM && a1->a_w.w_symbol != a2->a_w.w_symbol)
- goto nomatch;
- }
- return (1);
- nomatch: ;
- }
- return (0);
-}
-
-void pd_doloadbang(void);
-
-/* LATER make this evaluate the file on-the-fly. */
-/* LATER figure out how to log errors */
-void binbuf_evalfile(t_symbol *name, t_symbol *dir)
-{
- t_binbuf *b = binbuf_new();
- int import = !strcmp(name->s_name + strlen(name->s_name) - 4, ".pat");
- /* set filename so that new canvases can pick them up */
- int dspstate = canvas_suspend_dsp();
- glob_setfilename(0, name, dir);
- if (binbuf_read(b, name->s_name, dir->s_name, 0))
- {
- perror(name->s_name);
- }
- else
- {
- if (import)
- {
- t_binbuf *newb = binbuf_convert(b, 1);
- binbuf_free(b);
- b = newb;
- }
- binbuf_eval(b, 0, 0, 0);
- }
- glob_setfilename(0, &s_, &s_); /* bug fix by Krzysztof Czaja */
- binbuf_free(b);
- canvas_resume_dsp(dspstate);
-}
-
-void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir)
-{
- t_pd *x = 0;
- /* even though binbuf_evalfile appears to take care of dspstate,
- we have to do it again here, because canvas_startdsp() assumes
- that all toplevel canvases are visible. LATER check if this
- is still necessary -- probably not. */
-
- int dspstate = canvas_suspend_dsp();
- binbuf_evalfile(name, dir);
- while ((x != s__X.s_thing) && (x = s__X.s_thing))
- vmess(x, gensym("pop"), "i", 1);
- pd_doloadbang();
- canvas_resume_dsp(dspstate);
-}
diff --git a/apps/plugins/pdbox/PDa/src/m_class.c b/apps/plugins/pdbox/PDa/src/m_class.c
index 0b6d4df885..66cb34d921 100644
--- a/apps/plugins/pdbox/PDa/src/m_class.c
+++ b/apps/plugins/pdbox/PDa/src/m_class.c
@@ -822,827 +822,4 @@ t_gotfn zgetfn(t_pd *x, t_symbol *s)
if (m->me_name == s) return(m->me_fun);
return(0);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#define PD_CLASS_DEF
-#include "m_pd.h"
-#include "m_imp.h"
-#include "s_stuff.h"
-#include <stdlib.h>
-#ifdef UNIX
-#include <unistd.h>
-#endif
-#ifdef MSW
-#include <io.h>
-#endif
-
-#include <stdarg.h>
-#include <string.h>
-
-static t_symbol *class_loadsym; /* name under which an extern is invoked */
-static void pd_defaultfloat(t_pd *x, t_float f);
-static void pd_defaultlist(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-t_pd pd_objectmaker; /* factory for creating "object" boxes */
-t_pd pd_canvasmaker; /* factory for creating canvases */
-
-static t_symbol *class_extern_dir = &s_;
-
-static void pd_defaultanything(t_pd *x, t_symbol *s, int argc, t_atom *argv)
-{
- pd_error(x, "%s: no method for '%s'", (*x)->c_name->s_name, s->s_name);
-}
-
-static void pd_defaultbang(t_pd *x)
-{
- if (*(*x)->c_listmethod != pd_defaultlist)
- (*(*x)->c_listmethod)(x, 0, 0, 0);
- else (*(*x)->c_anymethod)(x, &s_bang, 0, 0);
-}
-
-static void pd_defaultpointer(t_pd *x, t_gpointer *gp)
-{
- if (*(*x)->c_listmethod != pd_defaultlist)
- {
- t_atom at;
- SETPOINTER(&at, gp);
- (*(*x)->c_listmethod)(x, 0, 1, &at);
- }
- else
- {
- t_atom at;
- SETPOINTER(&at, gp);
- (*(*x)->c_anymethod)(x, &s_pointer, 1, &at);
- }
-}
-
-static void pd_defaultfloat(t_pd *x, t_float f)
-{
- if (*(*x)->c_listmethod != pd_defaultlist)
- {
- t_atom at;
- SETFLOAT(&at, f);
- (*(*x)->c_listmethod)(x, 0, 1, &at);
- }
- else
- {
- t_atom at;
- SETFLOAT(&at, f);
- (*(*x)->c_anymethod)(x, &s_float, 1, &at);
- }
-}
-
-static void pd_defaultsymbol(t_pd *x, t_symbol *s)
-{
- if (*(*x)->c_listmethod != pd_defaultlist)
- {
- t_atom at;
- SETSYMBOL(&at, s);
- (*(*x)->c_listmethod)(x, 0, 1, &at);
- }
- else
- {
- t_atom at;
- SETSYMBOL(&at, s);
- (*(*x)->c_anymethod)(x, &s_symbol, 1, &at);
- }
-}
-
-void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv);
-static void class_nosavefn(t_gobj *z, t_binbuf *b);
-
- /* handle "list" messages to Pds without explicit list methods defined. */
-static void pd_defaultlist(t_pd *x, t_symbol *s, int argc, t_atom *argv)
-{
- /* a list with one element which is a number can be handled by a
- "float" method if any is defined; same for "symbol", "pointer". */
- if (argc == 1)
- {
- if (argv->a_type == A_FLOAT &&
- *(*x)->c_floatmethod != pd_defaultfloat)
- {
- (*(*x)->c_floatmethod)(x, argv->a_w.w_float);
- return;
- }
- else if (argv->a_type == A_SYMBOL &&
- *(*x)->c_symbolmethod != pd_defaultsymbol)
- {
- (*(*x)->c_symbolmethod)(x, argv->a_w.w_symbol);
- return;
- }
- else if (argv->a_type == A_POINTER &&
- *(*x)->c_pointermethod != pd_defaultpointer)
- {
- (*(*x)->c_pointermethod)(x, argv->a_w.w_gpointer);
- return;
- }
- }
- /* Next try for an "anything" method */
- if ((*x)->c_anymethod != pd_defaultanything)
- (*(*x)->c_anymethod)(x, &s_list, argc, argv);
-
- /* if the object is patchable (i.e., can have proper inlets)
- send it on to obj_list which will unpack the list into the inlets */
- else if ((*x)->c_patchable)
- obj_list((t_object *)x, s, argc, argv);
- /* otherwise gove up and complain. */
- else pd_defaultanything(x, &s_list, argc, argv);
-}
-
- /* for now we assume that all "gobjs" are text unless explicitly
- overridden later by calling class_setbehavior(). I'm not sure
- how to deal with Pds that aren't gobjs; shouldn't there be a
- way to check that at run time? Perhaps the presence of a "newmethod"
- should be our cue, or perhaps the "tiny" flag. */
-
- /* another matter. This routine does two unrelated things: it creates
- a Pd class, but also adds a "new" method to create an instance of it.
- These are combined for historical reasons and for brevity in writing
- objects. To avoid adding a "new" method send a null function pointer.
- To add additional ones, use class_addcreator below. Some "classes", like
- "select", are actually two classes of the same name, one for the single-
- argument form, one for the multiple one; see select_setup() to find out
- how this is handled. */
-
-extern t_widgetbehavior text_widgetbehavior;
-extern void text_save(t_gobj *z, t_binbuf *b);
-
-t_class *class_new(t_symbol *s, t_newmethod newmethod, t_method freemethod,
- size_t size, int flags, t_atomtype type1, ...)
-{
- va_list ap;
- t_atomtype vec[MAXPDARG+1], *vp = vec;
- int count = 0;
- t_class *c;
- int typeflag = flags & CLASS_TYPEMASK;
- if (!typeflag) typeflag = CLASS_PATCHABLE;
- *vp = type1;
-
- va_start(ap, type1);
- while (*vp)
- {
- if (count == MAXPDARG)
- {
- error("class %s: sorry: only %d creation args allowed",
- s->s_name, MAXPDARG);
- break;
- }
- vp++;
- count++;
- *vp = va_arg(ap, t_atomtype);
- }
- va_end(ap);
- if (pd_objectmaker && newmethod)
- {
- /* add a "new" method by the name specified by the object */
- class_addmethod(pd_objectmaker, (t_method)newmethod, s,
- vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]);
- if (class_loadsym)
- {
- /* if we're loading an extern it might have been invoked by a
- longer file name; in this case, make this an admissible name
- too. */
- char *loadstring = class_loadsym->s_name,
- l1 = strlen(s->s_name), l2 = strlen(loadstring);
- if (l2 > l1 && !strcmp(s->s_name, loadstring + (l2 - l1)))
- class_addmethod(pd_objectmaker, (t_method)newmethod,
- class_loadsym,
- vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]);
- }
- }
- c = (t_class *)t_getbytes(sizeof(*c));
- c->c_name = c->c_helpname = s;
- c->c_size = size;
- c->c_methods = t_getbytes(0);
- c->c_nmethod = 0;
- c->c_freemethod = (t_method)freemethod;
- c->c_bangmethod = pd_defaultbang;
- c->c_pointermethod = pd_defaultpointer;
- c->c_floatmethod = pd_defaultfloat;
- c->c_symbolmethod = pd_defaultsymbol;
- c->c_listmethod = pd_defaultlist;
- c->c_anymethod = pd_defaultanything;
- c->c_wb = (typeflag == CLASS_PATCHABLE ? &text_widgetbehavior : 0);
- c->c_pwb = 0;
- c->c_firstin = ((flags & CLASS_NOINLET) == 0);
- c->c_patchable = (typeflag == CLASS_PATCHABLE);
- c->c_gobj = (typeflag >= CLASS_GOBJ);
- c->c_drawcommand = 0;
- c->c_floatsignalin = 0;
- c->c_externdir = class_extern_dir;
- c->c_savefn = (typeflag == CLASS_PATCHABLE ? text_save : class_nosavefn);
-#if 0
- post("class: %s", c->c_name->s_name);
-#endif
- return (c);
-}
-
- /* add a creation method, which is a function that returns a Pd object
- suitable for putting in an object box. We presume you've got a class it
- can belong to, but this won't be used until the newmethod is actually
- called back (and the new method explicitly takes care of this.) */
-
-void class_addcreator(t_newmethod newmethod, t_symbol *s,
- t_atomtype type1, ...)
-{
- va_list ap;
- t_atomtype vec[MAXPDARG+1], *vp = vec;
- int count = 0;
- *vp = type1;
-
- va_start(ap, type1);
- while (*vp)
- {
- if (count == MAXPDARG)
- {
- error("class %s: sorry: only %d creation args allowed",
- s->s_name, MAXPDARG);
- break;
- }
- vp++;
- count++;
- *vp = va_arg(ap, t_atomtype);
- }
- va_end(ap);
- class_addmethod(pd_objectmaker, (t_method)newmethod, s,
- vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]);
-}
-
-void class_addmethod(t_class *c, t_method fn, t_symbol *sel,
- t_atomtype arg1, ...)
-{
- va_list ap;
- t_methodentry *m;
- t_atomtype argtype = arg1;
- int nargs;
-
- va_start(ap, arg1);
- /* "signal" method specifies that we take audio signals but
- that we don't want automatic float to signal conversion. This
- is obsolete; you should now use the CLASS_MAINSIGNALIN macro. */
- if (sel == &s_signal)
- {
- if (c->c_floatsignalin)
- post("warning: signal method overrides class_mainsignalin");
- c->c_floatsignalin = -1;
- }
- /* check for special cases. "Pointer" is missing here so that
- pd_objectmaker's pointer method can be typechecked differently. */
- if (sel == &s_bang)
- {
- if (argtype) goto phooey;
- class_addbang(c, fn);
- }
- else if (sel == &s_float)
- {
- if (argtype != A_FLOAT || va_arg(ap, t_atomtype)) goto phooey;
- class_doaddfloat(c, fn);
- }
- else if (sel == &s_symbol)
- {
- if (argtype != A_SYMBOL || va_arg(ap, t_atomtype)) goto phooey;
- class_addsymbol(c, fn);
- }
- else if (sel == &s_list)
- {
- if (argtype != A_GIMME) goto phooey;
- class_addlist(c, fn);
- }
- else if (sel == &s_anything)
- {
- if (argtype != A_GIMME) goto phooey;
- class_addanything(c, fn);
- }
- else
- {
- c->c_methods = t_resizebytes(c->c_methods,
- c->c_nmethod * sizeof(*c->c_methods),
- (c->c_nmethod + 1) * sizeof(*c->c_methods));
- m = c->c_methods + c->c_nmethod;
- c->c_nmethod++;
- m->me_name = sel;
- m->me_fun = (t_gotfn)fn;
- nargs = 0;
- while (argtype != A_NULL && nargs < MAXPDARG)
- {
- m->me_arg[nargs++] = argtype;
- argtype = va_arg(ap, t_atomtype);
- }
- if (argtype != A_NULL)
- error("%s_%s: only 5 arguments are typecheckable; use A_GIMME",
- c->c_name->s_name, sel->s_name);
- va_end(ap);
- m->me_arg[nargs] = A_NULL;
- }
- return;
-phooey:
- bug("class_addmethod: %s_%s: bad argument types\n",
- c->c_name->s_name, sel->s_name);
-}
-
- /* Instead of these, see the "class_addfloat", etc., macros in m_pd.h */
-void class_addbang(t_class *c, t_method fn)
-{
- c->c_bangmethod = (t_bangmethod)fn;
-}
-
-void class_addpointer(t_class *c, t_method fn)
-{
- c->c_pointermethod = (t_pointermethod)fn;
-}
-
-void class_doaddfloat(t_class *c, t_method fn)
-{
- c->c_floatmethod = (t_floatmethod)fn;
-}
-
-void class_addsymbol(t_class *c, t_method fn)
-{
- c->c_symbolmethod = (t_symbolmethod)fn;
-}
-
-void class_addlist(t_class *c, t_method fn)
-{
- c->c_listmethod = (t_listmethod)fn;
-}
-
-void class_addanything(t_class *c, t_method fn)
-{
- c->c_anymethod = (t_anymethod)fn;
-}
-void class_setwidget(t_class *c, t_widgetbehavior *w)
-{
- c->c_wb = w;
-}
-
-void class_setparentwidget(t_class *c, t_parentwidgetbehavior *pw)
-{
- c->c_pwb = pw;
-}
-
-char *class_getname(t_class *c)
-{
- return (c->c_name->s_name);
-}
-
-char *class_gethelpname(t_class *c)
-{
- return (c->c_helpname->s_name);
-}
-
-void class_sethelpsymbol(t_class *c, t_symbol *s)
-{
- c->c_helpname = s;
-}
-
-t_parentwidgetbehavior *pd_getparentwidget(t_pd *x)
-{
- return ((*x)->c_pwb);
-}
-
-void class_setdrawcommand(t_class *c)
-{
- c->c_drawcommand = 1;
-}
-
-int class_isdrawcommand(t_class *c)
-{
- return (c->c_drawcommand);
-}
-
-static void pd_floatforsignal(t_pd *x, t_float f)
-{
- int offset = (*x)->c_floatsignalin;
- if (offset > 0)
- *(t_sample *)(((char *)x) + offset) = ftofix(f);
- else
- pd_error(x, "%s: float unexpected for signal input",
- (*x)->c_name->s_name);
-}
-
-void class_domainsignalin(t_class *c, int onset)
-{
- if (onset <= 0) onset = -1;
- else
- {
- if (c->c_floatmethod != pd_defaultfloat)
- post("warning: %s: float method overwritten", c->c_name->s_name);
- c->c_floatmethod = (t_floatmethod)pd_floatforsignal;
- }
- c->c_floatsignalin = onset;
-}
-
-void class_set_extern_dir(t_symbol *s)
-{
- class_extern_dir = s;
-}
-
-char *class_gethelpdir(t_class *c)
-{
- return (c->c_externdir->s_name);
-}
-
-static void class_nosavefn(t_gobj *z, t_binbuf *b)
-{
- bug("save function called but not defined");
-}
-
-void class_setsavefn(t_class *c, t_savefn f)
-{
- c->c_savefn = f;
-}
-
-t_savefn class_getsavefn(t_class *c)
-{
- return (c->c_savefn);
-}
-
-void class_setpropertiesfn(t_class *c, t_propertiesfn f)
-{
- c->c_propertiesfn = f;
-}
-
-t_propertiesfn class_getpropertiesfn(t_class *c)
-{
- return (c->c_propertiesfn);
-}
-
-/* ---------------- the symbol table ------------------------ */
-
-#define HASHSIZE 1024
-
-static t_symbol *symhash[HASHSIZE];
-
-t_symbol *dogensym(char *s, t_symbol *oldsym)
-{
- t_symbol **sym1, *sym2;
- unsigned int hash1 = 0, hash2 = 0;
- int length = 0;
- char *s2 = s;
- while (*s2)
- {
- hash1 += *s2;
- hash2 += hash1;
- length++;
- s2++;
- }
- sym1 = symhash + (hash2 & (HASHSIZE-1));
- while (sym2 = *sym1)
- {
- if (!strcmp(sym2->s_name, s)) return(sym2);
- sym1 = &sym2->s_next;
- }
- if (oldsym) sym2 = oldsym;
- else
- {
- sym2 = (t_symbol *)t_getbytes(sizeof(*sym2));
- sym2->s_name = t_getbytes(length+1);
- sym2->s_next = 0;
- sym2->s_thing = 0;
- strcpy(sym2->s_name, s);
- }
- *sym1 = sym2;
- return (sym2);
-}
-
-t_symbol *gensym(char *s)
-{
- return(dogensym(s, 0));
-}
-
-static t_symbol *addfileextent(t_symbol *s)
-{
- char namebuf[MAXPDSTRING], *str = s->s_name;
- int ln = strlen(str);
- if (!strcmp(str + ln - 3, ".pd")) return (s);
- strcpy(namebuf, str);
- strcpy(namebuf+ln, ".pd");
- return (gensym(namebuf));
-}
-
-static int tryingalready;
-
-void canvas_popabstraction(t_canvas *x);
-extern t_pd *newest;
-
-t_symbol* pathsearch(t_symbol *s,char* ext);
-int pd_setloadingabstraction(t_symbol *sym);
-
- /* this routine is called when a new "object" is requested whose class Pd
- doesn't know. Pd tries to load it as an extern, then as an abstraction. */
-void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- t_pd *current;
- t_symbol *dir = canvas_getcurrentdir();
- int fd;
- char dirbuf[MAXPDSTRING], *nameptr;
- if (tryingalready) return;
- newest = 0;
- class_loadsym = s;
- if (sys_load_lib(dir->s_name, s->s_name))
- {
- tryingalready = 1;
- typedmess(dummy, s, argc, argv);
- tryingalready = 0;
- return;
- }
- class_loadsym = 0;
- current = s__X.s_thing;
- if ((fd = open_via_path(dir->s_name, s->s_name, ".pd",
- dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 ||
- (fd = open_via_path(dir->s_name, s->s_name, ".pat",
- dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0)
- {
- close (fd);
- if (!pd_setloadingabstraction(s))
- {
- canvas_setargs(argc, argv); /* bug fix by Krzysztof Czaja */
- binbuf_evalfile(gensym(nameptr), gensym(dirbuf));
- if (s__X.s_thing != current)
- canvas_popabstraction((t_canvas *)(s__X.s_thing));
- canvas_setargs(0, 0);
- }
- else error("%s: can't load abstraction within itself\n", s->s_name);
- }
- else newest = 0;
-}
-
-t_symbol s_pointer = {"pointer", 0, 0};
-t_symbol s_float = {"float", 0, 0};
-t_symbol s_symbol = {"symbol", 0, 0};
-t_symbol s_bang = {"bang", 0, 0};
-t_symbol s_list = {"list", 0, 0};
-t_symbol s_anything = {"anything", 0, 0};
-t_symbol s_signal = {"signal", 0, 0};
-t_symbol s__N = {"#N", 0, 0};
-t_symbol s__X = {"#X", 0, 0};
-t_symbol s_x = {"x", 0, 0};
-t_symbol s_y = {"y", 0, 0};
-t_symbol s_ = {"", 0, 0};
-
-static t_symbol *symlist[] = { &s_pointer, &s_float, &s_symbol, &s_bang,
- &s_list, &s_anything, &s_signal, &s__N, &s__X, &s_x, &s_y, &s_};
-
-void mess_init(void)
-{
- t_symbol **sp;
- int i;
-
- if (pd_objectmaker) return;
- for (i = sizeof(symlist)/sizeof(*symlist), sp = symlist; i--; sp++)
- (void) dogensym((*sp)->s_name, *sp);
- pd_objectmaker = class_new(gensym("objectmaker"), 0, 0, sizeof(t_pd),
- CLASS_DEFAULT, A_NULL);
- pd_canvasmaker = class_new(gensym("classmaker"), 0, 0, sizeof(t_pd),
- CLASS_DEFAULT, A_NULL);
- pd_bind(&pd_canvasmaker, &s__N);
- class_addanything(pd_objectmaker, (t_method)new_anything);
-}
-
-t_pd *newest;
-
-/* This is externally available, but note that it might later disappear; the
-whole "newest" thing is a hack which needs to be redesigned. */
-t_pd *pd_newest(void)
-{
- return (newest);
-}
-
- /* horribly, we need prototypes for each of the artificial function
- calls in typedmess(), to keep the compiler quiet. */
-typedef t_pd *(*t_newgimme)(t_symbol *s, int argc, t_atom *argv);
-typedef void(*t_messgimme)(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-
-typedef t_pd *(*t_fun0)(
- t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
-typedef t_pd *(*t_fun1)(t_int i1,
- t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
-typedef t_pd *(*t_fun2)(t_int i1, t_int i2,
- t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
-typedef t_pd *(*t_fun3)(t_int i1, t_int i2, t_int i3,
- t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
-typedef t_pd *(*t_fun4)(t_int i1, t_int i2, t_int i3, t_int i4,
- t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
-typedef t_pd *(*t_fun5)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5,
- t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
-typedef t_pd *(*t_fun6)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5, t_int i6,
- t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5);
-
-void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_method *f;
- t_class *c = *x;
- t_methodentry *m;
- t_atomtype *wp, wanttype;
- int i;
- t_int ai[MAXPDARG+1], *ap = ai;
- t_floatarg ad[MAXPDARG+1], *dp = ad;
- int narg = 0;
- t_pd *bonzo;
-
- /* check for messages that are handled by fixed slots in the class
- structure. We don't catch "pointer" though so that sending "pointer"
- to pd_objectmaker doesn't require that we supply a pointer value. */
- if (s == &s_float)
- {
- if (!argc) (*c->c_floatmethod)(x, 0.);
- else if (argv->a_type == A_FLOAT)
- (*c->c_floatmethod)(x, argv->a_w.w_float);
- else goto badarg;
- return;
- }
- if (s == &s_bang)
- {
- (*c->c_bangmethod)(x);
- return;
- }
- if (s == &s_list)
- {
- (*c->c_listmethod)(x, s, argc, argv);
- return;
- }
- if (s == &s_symbol)
- {
- if (argc && argv->a_type == A_SYMBOL)
- (*c->c_symbolmethod)(x, argv->a_w.w_symbol);
- else
- (*c->c_symbolmethod)(x, &s_);
- return;
- }
- for (i = c->c_nmethod, m = c->c_methods; i--; m++)
- if (m->me_name == s)
- {
- wp = m->me_arg;
- if (*wp == A_GIMME)
- {
- if (x == &pd_objectmaker)
- newest = (*((t_newgimme)(m->me_fun)))(s, argc, argv);
- else (*((t_messgimme)(m->me_fun)))(x, s, argc, argv);
- return;
- }
- if (argc > MAXPDARG) argc = MAXPDARG;
- if (x != &pd_objectmaker) *(ap++) = (t_int)x, narg++;
- while (wanttype = *wp++)
- {
- switch (wanttype)
- {
- case A_POINTER:
- if (!argc) goto badarg;
- else
- {
- if (argv->a_type == A_POINTER)
- *ap = (t_int)(argv->a_w.w_gpointer);
- else goto badarg;
- argc--;
- argv++;
- }
- narg++;
- ap++;
- break;
- case A_FLOAT:
- if (!argc) goto badarg;
- case A_DEFFLOAT:
- if (!argc) *dp = 0;
- else
- {
- if (argv->a_type == A_FLOAT)
- *dp = argv->a_w.w_float;
- else goto badarg;
- argc--;
- argv++;
- }
- dp++;
- break;
- case A_SYMBOL:
- if (!argc) goto badarg;
- case A_DEFSYM:
- if (!argc) *ap = (t_int)(&s_);
- else
- {
- if (argv->a_type == A_SYMBOL)
- *ap = (t_int)(argv->a_w.w_symbol);
- /* if it's an unfilled "dollar" argument it appears
- as zero here; cheat and bash it to the null
- symbol. Unfortunately, this lets real zeros
- pass as symbols too, which seems wrong... */
- else if (x == &pd_objectmaker && argv->a_type == A_FLOAT
- && argv->a_w.w_float == 0)
- *ap = (t_int)(&s_);
- else goto badarg;
- argc--;
- argv++;
- }
- narg++;
- ap++;
- }
- }
- switch (narg)
- {
- case 0 : bonzo = (*(t_fun0)(m->me_fun))
- (ad[0], ad[1], ad[2], ad[3], ad[4]); break;
- case 1 : bonzo = (*(t_fun1)(m->me_fun))
- (ai[0], ad[0], ad[1], ad[2], ad[3], ad[4]); break;
- case 2 : bonzo = (*(t_fun2)(m->me_fun))
- (ai[0], ai[1], ad[0], ad[1], ad[2], ad[3], ad[4]); break;
- case 3 : bonzo = (*(t_fun3)(m->me_fun))
- (ai[0], ai[1], ai[2], ad[0], ad[1], ad[2], ad[3], ad[4]); break;
- case 4 : bonzo = (*(t_fun4)(m->me_fun))
- (ai[0], ai[1], ai[2], ai[3],
- ad[0], ad[1], ad[2], ad[3], ad[4]); break;
- case 5 : bonzo = (*(t_fun5)(m->me_fun))
- (ai[0], ai[1], ai[2], ai[3], ai[4],
- ad[0], ad[1], ad[2], ad[3], ad[4]); break;
- case 6 : bonzo = (*(t_fun6)(m->me_fun))
- (ai[0], ai[1], ai[2], ai[3], ai[4], ai[5],
- ad[0], ad[1], ad[2], ad[3], ad[4]); break;
- default: bonzo = 0;
- }
- if (x == &pd_objectmaker)
- newest = bonzo;
- return;
- }
- (*c->c_anymethod)(x, s, argc, argv);
- return;
-badarg:
- pd_error(x, "Bad arguments for message '%s' to object '%s'",
- s->s_name, c->c_name->s_name);
-}
-
-void pd_vmess(t_pd *x, t_symbol *sel, char *fmt, ...)
-{
- va_list ap;
- t_atom arg[MAXPDARG], *at =arg;
- int nargs = 0;
- char *fp = fmt;
-
- va_start(ap, fmt);
- while (1)
- {
- if (nargs > MAXPDARG)
- {
- pd_error(x, "pd_vmess: only %d allowed", MAXPDARG);
- break;
- }
- switch(*fp++)
- {
- case 'f': SETFLOAT(at, va_arg(ap, double)); break;
- case 's': SETSYMBOL(at, va_arg(ap, t_symbol *)); break;
- case 'i': SETFLOAT(at, va_arg(ap, t_int)); break;
- case 'p': SETPOINTER(at, va_arg(ap, t_gpointer *)); break;
- default: goto done;
- }
- at++;
- nargs++;
- }
-done:
- va_end(ap);
- typedmess(x, sel, nargs, arg);
-}
-
-void pd_forwardmess(t_pd *x, int argc, t_atom *argv)
-{
- if (argc)
- {
- t_atomtype t = argv->a_type;
- if (t == A_SYMBOL) pd_typedmess(x, argv->a_w.w_symbol, argc-1, argv+1);
- else if (t == A_POINTER)
- {
- if (argc == 1) pd_pointer(x, argv->a_w.w_gpointer);
- else pd_list(x, &s_list, argc, argv);
- }
- else if (t == A_FLOAT)
- {
- if (argc == 1) pd_float(x, argv->a_w.w_float);
- else pd_list(x, &s_list, argc, argv);
- }
- else bug("pd_forwardmess");
- }
-
-}
-
-void nullfn(void) {}
-
-t_gotfn getfn(t_pd *x, t_symbol *s)
-{
- t_class *c = *x;
- t_methodentry *m;
- int i;
-
- for (i = c->c_nmethod, m = c->c_methods; i--; m++)
- if (m->me_name == s) return(m->me_fun);
- pd_error(x, "%s: no method for message '%s'", c->c_name->s_name, s->s_name);
- return((t_gotfn)nullfn);
-}
-
-t_gotfn zgetfn(t_pd *x, t_symbol *s)
-{
- t_class *c = *x;
- t_methodentry *m;
- int i;
-
- for (i = c->c_nmethod, m = c->c_methods; i--; m++)
- if (m->me_name == s) return(m->me_fun);
- return(0);
-}
diff --git a/apps/plugins/pdbox/PDa/src/m_conf.c b/apps/plugins/pdbox/PDa/src/m_conf.c
index 8d3f5423a1..a3f1c70ec4 100644
--- a/apps/plugins/pdbox/PDa/src/m_conf.c
+++ b/apps/plugins/pdbox/PDa/src/m_conf.c
@@ -99,104 +99,3 @@ void conf_init(void)
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* changes by Thomas Musil IEM KUG Graz Austria 2001 */
-/* all changes are labeled with iemlib */
-
-#include "m_pd.h"
-
-void g_array_setup(void);
-void g_canvas_setup(void);
-void g_guiconnect_setup(void);
-/* iemlib */
-void g_bang_setup(void);
-void g_hradio_setup(void);
-void g_hslider_setup(void);
-void g_mycanvas_setup(void);
-void g_numbox_setup(void);
-void g_toggle_setup(void);
-void g_vradio_setup(void);
-void g_vslider_setup(void);
-void g_vumeter_setup(void);
-/* iemlib */
-void g_io_setup(void);
-void g_scalar_setup(void);
-void g_template_setup(void);
-void g_text_setup(void);
-void g_traversal_setup(void);
-void m_pd_setup(void);
-void x_acoustics_setup(void);
-void x_interface_setup(void);
-void x_connective_setup(void);
-void x_time_setup(void);
-void x_arithmetic_setup(void);
-void x_midi_setup(void);
-void x_misc_setup(void);
-void x_net_setup(void);
-void x_qlist_setup(void);
-void x_gui_setup(void);
-void d_arithmetic_setup(void);
-void d_array_setup(void);
-void d_ctl_setup(void);
-void d_dac_setup(void);
-void d_delay_setup(void);
-void d_fft_setup(void);
-void d_filter_setup(void);
-void d_global_setup(void);
-void d_math_setup(void);
-void d_misc_setup(void);
-void d_osc_setup(void);
-void d_soundfile_setup(void);
-void d_ugen_setup(void);
-
-void conf_init(void)
-{
- g_array_setup();
- g_canvas_setup();
- g_guiconnect_setup();
-/* iemlib */
-
- g_bang_setup();
- g_hradio_setup();
- g_hslider_setup();
- g_mycanvas_setup();
- g_numbox_setup();
- g_toggle_setup();
- g_vradio_setup();
- g_vslider_setup();
- g_vumeter_setup();
-/* iemlib */
-
- g_io_setup();
- g_scalar_setup();
- g_template_setup();
- g_text_setup();
- g_traversal_setup();
- m_pd_setup();
- x_acoustics_setup();
- x_interface_setup();
- x_connective_setup();
- x_time_setup();
- x_arithmetic_setup();
-
- x_midi_setup();
- x_misc_setup();
- x_net_setup();
- x_qlist_setup();
- x_gui_setup();
- d_arithmetic_setup();
- d_dac_setup();
- d_fft_setup();
- d_global_setup();
- d_misc_setup();
-#ifdef STATIC
- d_intern_setup();
-#endif
- d_soundfile_setup();
- d_ugen_setup();
-
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/m_fixed.c b/apps/plugins/pdbox/PDa/src/m_fixed.c
index c91fa0512e..7beaa8077a 100644
--- a/apps/plugins/pdbox/PDa/src/m_fixed.c
+++ b/apps/plugins/pdbox/PDa/src/m_fixed.c
@@ -122,131 +122,4 @@ void pd_checkgui(t_pd *x, t_symbol *s)
pd_bind(&ipod->x_obj.ob_pd,s);
}
}
-
-
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
-#include <stdio.h>
-
-#include "m_pd.h"
-#include "m_imp.h"
-
-static t_class *ipod_class = 0;
-
-typedef struct _ipod
-{
- t_object x_obj;
- t_symbol* x_what;
-} t_ipod;
-
-static t_ipod* ipod;
-static t_int x_fd = -1;
-
-
-
-static void ipod_connect()
-{
- struct sockaddr_in server;
- struct hostent *hp;
- int sockfd;
- int portno = 3334;
- char hostname[] = "127.0.0.1";
- int intarg;
- if (x_fd >= 0)
- {
- error("ipod_connect: already connected");
- return;
- }
-
- /* create a socket */
- sockfd = socket(AF_INET, SOCK_DGRAM, 0);
-
- if (sockfd < 0)
- {
- sys_sockerror("socket");
- return;
- }
-
- /* connect socket using hostname provided in command line */
-
- server.sin_family = AF_INET;
- hp = gethostbyname(hostname);
- if (hp == 0)
- {
- post("bad host?\n");
- return;
- }
-
- memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
-
- server.sin_port = htons((u_short)portno);
- if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0)
- {
- sys_sockerror("connecting stream socket");
- sys_closesocket(sockfd);
- return;
- }
- post("connected %s %d",hostname,portno);
- x_fd = sockfd;
-}
-
-
-
-static void ipod_bang(t_ipod *x)
-{
- static char sendme[200];
- sprintf(sendme,"%s bang;\n",x->x_what->s_name);
- send(x_fd,sendme,strlen(sendme),0);
-
-// if (x->x_sym->s_thing) pd_bang(x->x_sym->s_thing);
-}
-
-static void ipod_float(t_ipod *x, t_float f)
-{
- static char sendme[200];
-
- sprintf(sendme,"%s %f;\n",x->x_what->s_name,f);
- send(x_fd,sendme,strlen(sendme),0);
-
-// post("forwarding float %s",x->x_what->s_name);
-// if (x->x_sym->s_thing) pd_float(x->x_sym->s_thing, f);
-}
-
-static void *ipod_new(t_symbol* what)
-{
- t_ipod *x = (t_ipod *)pd_new(ipod_class);
- post("new ipod %s",what->s_name);
- x->x_what = what;
- return (x);
-}
-
-static void ipod_setup(void)
-{
- ipod_class = class_new(gensym("ipod"), (t_newmethod)ipod_new, 0,
- sizeof(t_ipod), 0, A_DEFSYM, 0);
- class_addbang(ipod_class, ipod_bang);
- class_addfloat(ipod_class, ipod_float);
- ipod_connect();
-}
-
-void pd_checkgui(t_pd *x, t_symbol *s)
-{
- if (!strncmp(s->s_name,"pod_",4))
- if (!strcmp((*x)->c_name->s_name,"gatom") ||
- !strcmp((*x)->c_name->s_name,"vsl") ||
- !strcmp((*x)->c_name->s_name,"hsl") ||
- !strcmp((*x)->c_name->s_name,"bng") ||
- !strcmp((*x)->c_name->s_name,"vradio") ||
- !strcmp((*x)->c_name->s_name,"hradio")) {
-
- post("binding %s to %s",s->s_name,(*x)->c_name->s_name);
- if (!ipod_class) ipod_setup();
- ipod = ipod_new(s);
- pd_bind(&ipod->x_obj.ob_pd,s);
- }
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/m_fixed.h b/apps/plugins/pdbox/PDa/src/m_fixed.h
index 4ccc121ac1..aa7b74b5ba 100644
--- a/apps/plugins/pdbox/PDa/src/m_fixed.h
+++ b/apps/plugins/pdbox/PDa/src/m_fixed.h
@@ -52,59 +52,3 @@ typedef int t_sample;
#endif
-
-#ifndef __M_FIXED_H__
-#define __M_FIXED_H__
-
-typedef int t_sample;
-
-#define t_fixed int
-#define fix1 18 /* (18) number of bits after comma */
-
-
-#define fixfac ((float)(1<<fix1)) /* float factor (for scaling ftofix ..) */
-
-
-/* fixed point multiplication and division */
-
-#define mult(a,b) (long long)(((long long) (a) * (long long) (b))>>fix1)
-#define idiv(a,b) ((((long long) (a) )<<fix1)/(long long) (b) )
-
-/* conversion macros */
-
-#define itofix(a) ((a) << fix1)
-#define ftofix(a) ((t_fixed)( (a) *(double)fixfac + 0.5))
-
-#define fixtof(a) ((double) (a) * 1./(fixfac-0.5))
-#define fixtoi(a) ((a) >>fix1)
-
-
-/* Not working !! */
-
-#define fnum(a) ( (a) >>(fix1-16))
-#define ffrac(a) (0)
-
-
-/* mapping of fft functions */
-
-#ifdef FIXEDPOINT
-#define mayer_realifft imayer_realifft
-#define mayer_realfft imayer_realfft
-#define mayer_fft imayer_fft
-#define mayer_ifft imayer_ifft
-#endif
-
-#ifdef FIXEDPOINT
-#define SCALE16(x) (x>>(fix1-15))
-#define SCALE32(x) (x<<(32-fix1))
-#define INVSCALE16(x) (x<<8)
-#else
-#define SCALE16(x) (32767.*x)
-#define SCALE32(x) (2147483648.*x)
-#define INVSCALE16(x) ((float)3.051850e-05*x)
-#endif
-
-
-#endif
-
-
diff --git a/apps/plugins/pdbox/PDa/src/m_glob.c b/apps/plugins/pdbox/PDa/src/m_glob.c
index 5d62087b3c..2ec584a33d 100644
--- a/apps/plugins/pdbox/PDa/src/m_glob.c
+++ b/apps/plugins/pdbox/PDa/src/m_glob.c
@@ -103,108 +103,4 @@ void glob_init(void)
class_addanything(glob_pdobject, max_default);
pd_bind(&glob_pdobject, gensym("pd"));
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include "m_pd.h"
-#include "m_imp.h"
-
-t_class *glob_pdobject;
-static t_class *maxclass;
-
-/* These "glob" routines, which implement messages to Pd, are from all
-over. Some others are prototyped in m_imp.h as well. */
-
-void glob_setfilename(void *dummy, t_symbol *name, t_symbol *dir);
-void glob_quit(void *dummy);
-void glob_dsp(void *dummy, t_symbol *s, int argc, t_atom *argv);
-void glob_meters(void *dummy, t_floatarg f);
-void glob_key(void *dummy, t_symbol *s, int ac, t_atom *av);
-void glob_audiostatus(void *dummy);
-void glob_finderror(t_pd *dummy);
-void glob_audio_properties(t_pd *dummy, t_floatarg flongform);
-void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv);
-void glob_audio_setapi(t_pd *dummy, t_floatarg f);
-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_start_path_dialog(t_pd *dummy, t_floatarg flongform);
-void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv);
-void glob_ping(t_pd *dummy);
-
-void alsa_resync( void);
-
-
-#ifdef MSW
-void glob_audio(void *dummy, t_floatarg adc, t_floatarg dac);
-#endif
-
-/* a method you add for debugging printout */
-void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv);
-
-#if 0
-void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- *(int *)1 = 3;
-}
-#endif
-
-void max_default(t_pd *x, t_symbol *s, int argc, t_atom *argv)
-{
- int i;
- char str[80];
- startpost("%s: unknown message %s ", class_getname(pd_class(x)),
- s->s_name);
- for (i = 0; i < argc; i++)
- {
- atom_string(argv+i, str, 80);
- poststring(str);
- }
- endpost();
-}
-
-void glob_init(void)
-{
- maxclass = class_new(gensym("max"), 0, 0, sizeof(t_pd),
- CLASS_DEFAULT, A_NULL);
- class_addanything(maxclass, max_default);
- pd_bind(&maxclass, gensym("max"));
- glob_pdobject = class_new(gensym("pd"), 0, 0, sizeof(t_pd),
- CLASS_DEFAULT, A_NULL);
- class_addmethod(glob_pdobject, (t_method)glob_initfromgui, gensym("init"),
- A_GIMME, 0);
- class_addmethod(glob_pdobject, (t_method)glob_setfilename, gensym("filename"),
- A_SYMBOL, A_SYMBOL, 0);
- class_addmethod(glob_pdobject, (t_method)glob_evalfile, gensym("open"),
- A_SYMBOL, A_SYMBOL, 0);
- class_addmethod(glob_pdobject, (t_method)glob_quit, gensym("quit"), 0);
- class_addmethod(glob_pdobject, (t_method)glob_foo, gensym("foo"), A_GIMME, 0);
- class_addmethod(glob_pdobject, (t_method)glob_dsp, gensym("dsp"), A_GIMME, 0);
- class_addmethod(glob_pdobject, (t_method)glob_meters, gensym("meters"),
- A_FLOAT, 0);
- class_addmethod(glob_pdobject, (t_method)glob_key, gensym("key"), A_GIMME, 0);
- class_addmethod(glob_pdobject, (t_method)glob_audiostatus,
- gensym("audiostatus"), 0);
- class_addmethod(glob_pdobject, (t_method)glob_finderror,
- gensym("finderror"), 0);
- class_addmethod(glob_pdobject, (t_method)glob_audio_properties,
- gensym("audio-properties"), A_DEFFLOAT, 0);
- class_addmethod(glob_pdobject, (t_method)glob_audio_dialog,
- gensym("audio-dialog"), A_GIMME, 0);
- class_addmethod(glob_pdobject, (t_method)glob_audio_setapi,
- gensym("audio-setapi"), A_FLOAT, 0);
- class_addmethod(glob_pdobject, (t_method)glob_midi_properties,
- gensym("midi-properties"), A_DEFFLOAT, 0);
- class_addmethod(glob_pdobject, (t_method)glob_midi_dialog,
- gensym("midi-dialog"), A_GIMME, 0);
- class_addmethod(glob_pdobject, (t_method)glob_start_path_dialog,
- gensym("start-path-dialog"), A_DEFFLOAT, 0);
- class_addmethod(glob_pdobject, (t_method)glob_path_dialog,
- gensym("path-dialog"), A_GIMME, 0);
-#ifdef __linux__
- class_addmethod(glob_pdobject, (t_method)glob_ping, gensym("ping"), 0);
-#endif
- class_addanything(glob_pdobject, max_default);
- pd_bind(&glob_pdobject, gensym("pd"));
-}
diff --git a/apps/plugins/pdbox/PDa/src/m_imp.h b/apps/plugins/pdbox/PDa/src/m_imp.h
index 7632af1c2d..0444549d96 100644
--- a/apps/plugins/pdbox/PDa/src/m_imp.h
+++ b/apps/plugins/pdbox/PDa/src/m_imp.h
@@ -76,81 +76,4 @@ EXTERN int obj_sigoutletindex(t_object *x, int m);
/* misc */
EXTERN void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir);
EXTERN void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv);
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* This file contains function prototypes and data types used to implement
-Pd, but not shared with Pd objects. */
-
-/* NOTE: this file describes Pd implementation details which may change
-in future releases. The public (stable) API is in m_pd.h. */
-
-/* LATER consider whether to use 'char' for method arg types to save space */
-
-/* the structure for a method handler ala Max */
-typedef struct _methodentry
-{
- t_symbol *me_name;
- t_gotfn me_fun;
- t_atomtype me_arg[MAXPDARG+1];
-} t_methodentry;
-EXTERN_STRUCT _widgetbehavior;
-
-typedef void (*t_bangmethod)(t_pd *x);
-typedef void (*t_pointermethod)(t_pd *x, t_gpointer *gp);
-typedef void (*t_floatmethod)(t_pd *x, t_float f);
-typedef void (*t_symbolmethod)(t_pd *x, t_symbol *s);
-typedef void (*t_listmethod)(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-typedef void (*t_anymethod)(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-
-struct _class
-{
- t_symbol *c_name; /* name (mostly for error reporting) */
- t_symbol *c_helpname; /* name of help file */
- t_symbol *c_externdir; /* directory extern was loaded from */
- size_t c_size; /* size of an instance */
- t_methodentry *c_methods; /* methods other than bang, etc below */
- int c_nmethod; /* number of methods */
- t_method c_freemethod; /* function to call before freeing */
- t_bangmethod c_bangmethod; /* common methods */
- t_pointermethod c_pointermethod;
- t_floatmethod c_floatmethod;
- t_symbolmethod c_symbolmethod;
- t_listmethod c_listmethod;
- t_anymethod c_anymethod;
- struct _widgetbehavior *c_wb; /* "gobjs" only */
- struct _parentwidgetbehavior *c_pwb;/* widget behavior in parent */
- t_savefn c_savefn; /* function to call when saving */
- t_propertiesfn c_propertiesfn; /* function to start prop dialog */
- int c_floatsignalin; /* onset to float for signal input */
- char c_gobj; /* true if is a gobj */
- char c_patchable; /* true if we have a t_object header */
- char c_firstin; /* if patchable, true if draw first inlet */
- char c_drawcommand; /* a drawing command for a template */
-};
-
-
-/* m_obj.c */
-EXTERN int obj_noutlets(t_object *x);
-EXTERN int obj_ninlets(t_object *x);
-EXTERN t_outconnect *obj_starttraverseoutlet(t_object *x, t_outlet **op,
- int nout);
-EXTERN t_outconnect *obj_nexttraverseoutlet(t_outconnect *lastconnect,
- t_object **destp, t_inlet **inletp, int *whichp);
-EXTERN t_outconnect *obj_connect(t_object *source, int outno,
- t_object *sink, int inno);
-EXTERN void obj_disconnect(t_object *source, int outno, t_object *sink,
- int inno);
-EXTERN void outlet_setstacklim(void);
-EXTERN int obj_issignalinlet(t_object *x, int m);
-EXTERN int obj_issignaloutlet(t_object *x, int m);
-EXTERN int obj_nsiginlets(t_object *x);
-EXTERN int obj_nsigoutlets(t_object *x);
-EXTERN int obj_siginletindex(t_object *x, int m);
-EXTERN int obj_sigoutletindex(t_object *x, int m);
-
-/* misc */
-EXTERN void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir);
-EXTERN void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv);
diff --git a/apps/plugins/pdbox/PDa/src/m_memory.c b/apps/plugins/pdbox/PDa/src/m_memory.c
index 085154299b..ef33d3c1d3 100644
--- a/apps/plugins/pdbox/PDa/src/m_memory.c
+++ b/apps/plugins/pdbox/PDa/src/m_memory.c
@@ -87,92 +87,4 @@ void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
fprintf(stderr, "total mem %d\n", totalmem);
}
#endif
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include <stdlib.h>
-#include <string.h>
-#include "m_pd.h"
-#include "m_imp.h"
-
-/* #define LOUD */
-#ifdef LOUD
-#include <stdio.h>
-#endif
-
-/* #define DEBUGMEM */
-#ifdef DEBUGMEM
-static int totalmem = 0;
-#endif
-
-void *getbytes(size_t nbytes)
-{
- void *ret;
- if (nbytes < 1) nbytes = 1;
- ret = (void *)calloc(nbytes, 1);
-#ifdef LOUD
- fprintf(stderr, "new %x %d\n", (int)ret, nbytes);
-#endif /* LOUD */
-#ifdef DEBUGMEM
- totalmem += nbytes;
-#endif
- if (!ret)
- post("pd: getbytes() failed -- out of memory");
- return (ret);
-}
-
-void *getzbytes(size_t nbytes) /* obsolete name */
-{
- return (getbytes(nbytes));
-}
-
-void *copybytes(void *src, size_t nbytes)
-{
- void *ret;
- ret = getbytes(nbytes);
- if (nbytes)
- memcpy(ret, src, nbytes);
- return (ret);
-}
-
-void *resizebytes(void *old, size_t oldsize, size_t newsize)
-{
- void *ret;
- if (newsize < 1) newsize = 1;
- if (oldsize < 1) oldsize = 1;
- ret = (void *)realloc((char *)old, newsize);
- if (newsize > oldsize && ret)
- memset(((char *)ret) + oldsize, 0, newsize - oldsize);
-#ifdef LOUD
- fprintf(stderr, "resize %x %d --> %x %d\n", (int)old, oldsize, (int)ret, newsize);
-#endif /* LOUD */
-#ifdef DEBUGMEM
- totalmem += (newsize - oldsize);
-#endif
- if (!ret)
- post("pd: resizebytes() failed -- out of memory");
- return (ret);
-}
-
-void freebytes(void *fatso, size_t nbytes)
-{
- if (nbytes == 0)
- nbytes = 1;
-#ifdef LOUD
- fprintf(stderr, "free %x %d\n", (int)fatso, nbytes);
-#endif /* LOUD */
-#ifdef DEBUGMEM
- totalmem -= nbytes;
-#endif
- free(fatso);
-}
-
-#ifdef DEBUGMEM
-#include <stdio.h>
-void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- fprintf(stderr, "total mem %d\n", totalmem);
-}
-#endif
diff --git a/apps/plugins/pdbox/PDa/src/m_obj.c b/apps/plugins/pdbox/PDa/src/m_obj.c
index d53da5722e..785fd240bf 100644
--- a/apps/plugins/pdbox/PDa/src/m_obj.c
+++ b/apps/plugins/pdbox/PDa/src/m_obj.c
@@ -695,700 +695,3 @@ int outlet_getsignalindex(t_outlet *x)
return (n);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* this file handles Max-style patchable objects, i.e., objects which
-can interconnect via inlets and outlets; also, the (terse) generic
-behavior for "gobjs" appears at the end of this file. */
-
-#include "m_pd.h"
-#include "m_imp.h"
-
-union inletunion
-{
- t_symbol *iu_symto;
- t_gpointer *iu_pointerslot;
- t_float *iu_floatslot;
- t_symbol **iu_symslot;
- t_sample iu_floatsignalvalue;
-};
-
-struct _inlet
-{
- t_pd i_pd;
- struct _inlet *i_next;
- t_object *i_owner;
- t_pd *i_dest;
- t_symbol *i_symfrom;
- union inletunion i_un;
-};
-
-#define i_symto i_un.iu_symto
-#define i_pointerslot i_un.iu_pointerslot
-#define i_floatslot i_un.iu_floatslot
-#define i_symslot i_un.iu_symslot
-
-static t_class *inlet_class, *pointerinlet_class, *floatinlet_class,
- *symbolinlet_class;
-
-#define ISINLET(pd) ((*(pd) == inlet_class) || \
- (*(pd) == pointerinlet_class) || \
- (*(pd) == floatinlet_class) || \
- (*(pd) == symbolinlet_class))
-
-/* --------------------- generic inlets ala max ------------------ */
-
-t_inlet *inlet_new(t_object *owner, t_pd *dest, t_symbol *s1, t_symbol *s2)
-{
- t_inlet *x = (t_inlet *)pd_new(inlet_class), *y, *y2;
- x->i_owner = owner;
- x->i_dest = dest;
- if (s1 == &s_signal)
- x->i_un.iu_floatsignalvalue = 0;
- else x->i_symto = s2;
- x->i_symfrom = s1;
- x->i_next = 0;
- if (y = owner->ob_inlet)
- {
- while (y2 = y->i_next) y = y2;
- y->i_next = x;
- }
- else owner->ob_inlet = x;
- return (x);
-}
-
-static void inlet_wrong(t_inlet *x, t_symbol *s)
-{
- pd_error(x->i_owner, "inlet: expected '%s' but got '%s'",
- x->i_symfrom->s_name, s->s_name);
-}
-
- /* LATER figure out how to make these efficient: */
-static void inlet_bang(t_inlet *x)
-{
- if (x->i_symfrom == &s_bang)
- pd_vmess(x->i_dest, x->i_symto, "");
- else if (!x->i_symfrom) pd_bang(x->i_dest);
- else inlet_wrong(x, &s_bang);
-}
-
-static void inlet_pointer(t_inlet *x, t_gpointer *gp)
-{
- if (x->i_symfrom == &s_pointer)
- pd_vmess(x->i_dest, x->i_symto, "p", gp);
- else if (!x->i_symfrom) pd_pointer(x->i_dest, gp);
- else inlet_wrong(x, &s_pointer);
-}
-
-static void inlet_float(t_inlet *x, t_float f)
-{
- if (x->i_symfrom == &s_float)
- pd_vmess(x->i_dest, x->i_symto, "f", (t_floatarg)f);
- else if (x->i_symfrom == &s_signal)
- x->i_un.iu_floatsignalvalue = ftofix(f);
- else if (!x->i_symfrom)
- pd_float(x->i_dest, f);
- else inlet_wrong(x, &s_float);
-}
-
-static void inlet_symbol(t_inlet *x, t_symbol *s)
-{
- if (x->i_symfrom == &s_symbol)
- pd_vmess(x->i_dest, x->i_symto, "s", s);
- else if (!x->i_symfrom) pd_symbol(x->i_dest, s);
- else inlet_wrong(x, &s_symbol);
-}
-
-static void inlet_list(t_inlet *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_atom at;
- if (x->i_symfrom == &s_list || x->i_symfrom == &s_float
- || x->i_symfrom == &s_symbol || x->i_symfrom == &s_pointer)
- typedmess(x->i_dest, x->i_symto, argc, argv);
- else if (!x->i_symfrom) pd_list(x->i_dest, s, argc, argv);
- else inlet_wrong(x, &s_list);
-}
-
-static void inlet_anything(t_inlet *x, t_symbol *s, int argc, t_atom *argv)
-{
- if (x->i_symfrom == s)
- typedmess(x->i_dest, x->i_symto, argc, argv);
- else if (!x->i_symfrom)
- typedmess(x->i_dest, s, argc, argv);
- else inlet_wrong(x, s);
-}
-
-void inlet_free(t_inlet *x)
-{
- t_object *y = x->i_owner;
- t_inlet *x2;
- if (y->ob_inlet == x) y->ob_inlet = x->i_next;
- else for (x2 = y->ob_inlet; x2; x2 = x2->i_next)
- if (x2->i_next == x)
- {
- x2->i_next = x->i_next;
- break;
- }
- t_freebytes(x, sizeof(*x));
-}
-
-/* ----- pointerinlets, floatinlets, syminlets: optimized inlets ------- */
-
-static void pointerinlet_pointer(t_inlet *x, t_gpointer *gp)
-{
- gpointer_unset(x->i_pointerslot);
- *(x->i_pointerslot) = *gp;
- if (gp->gp_stub) gp->gp_stub->gs_refcount++;
-}
-
-t_inlet *pointerinlet_new(t_object *owner, t_gpointer *gp)
-{
- t_inlet *x = (t_inlet *)pd_new(pointerinlet_class), *y, *y2;
- x->i_owner = owner;
- x->i_dest = 0;
- x->i_symfrom = &s_pointer;
- x->i_pointerslot = gp;
- x->i_next = 0;
- if (y = owner->ob_inlet)
- {
- while (y2 = y->i_next) y = y2;
- y->i_next = x;
- }
- else owner->ob_inlet = x;
- return (x);
-}
-
-static void floatinlet_float(t_inlet *x, t_float f)
-{
- *(x->i_floatslot) = f;
-}
-
-t_inlet *floatinlet_new(t_object *owner, t_float *fp)
-{
- t_inlet *x = (t_inlet *)pd_new(floatinlet_class), *y, *y2;
- x->i_owner = owner;
- x->i_dest = 0;
- x->i_symfrom = &s_float;
- x->i_floatslot = fp;
- x->i_next = 0;
- if (y = owner->ob_inlet)
- {
- while (y2 = y->i_next) y = y2;
- y->i_next = x;
- }
- else owner->ob_inlet = x;
- return (x);
-}
-
-static void symbolinlet_symbol(t_inlet *x, t_symbol *s)
-{
- *(x->i_symslot) = s;
-}
-
-t_inlet *symbolinlet_new(t_object *owner, t_symbol **sp)
-{
- t_inlet *x = (t_inlet *)pd_new(symbolinlet_class), *y, *y2;
- x->i_owner = owner;
- x->i_dest = 0;
- x->i_symfrom = &s_symbol;
- x->i_symslot = sp;
- x->i_next = 0;
- if (y = owner->ob_inlet)
- {
- while (y2 = y->i_next) y = y2;
- y->i_next = x;
- }
- else owner->ob_inlet = x;
- return (x);
-}
-
-/* ---------------------- routine to handle lists ---------------------- */
-
- /* objects interpret lists by feeding them to the individual inlets.
- Before you call this check that the object doesn't have a more
- specific way to handle lists. */
-void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_atom *ap;
- int count;
- t_inlet *ip = ((t_object *)x)->ob_inlet;
- if (!argc) return;
- for (count = argc-1, ap = argv+1; ip && count--; ap++, ip = ip->i_next)
- {
- if (ap->a_type == A_POINTER) pd_pointer(&ip->i_pd, ap->a_w.w_gpointer);
- else if (ap->a_type == A_FLOAT) pd_float(&ip->i_pd, ap->a_w.w_float);
- else pd_symbol(&ip->i_pd, ap->a_w.w_symbol);
- }
- if (argv->a_type == A_POINTER) pd_pointer(&x->ob_pd, argv->a_w.w_gpointer);
- else if (argv->a_type == A_FLOAT) pd_float(&x->ob_pd, argv->a_w.w_float);
- else pd_symbol(&x->ob_pd, argv->a_w.w_symbol);
-}
-
-void obj_init(void)
-{
- inlet_class = class_new(gensym("inlet"), 0, 0,
- sizeof(t_inlet), CLASS_PD, 0);
- class_addbang(inlet_class, inlet_bang);
- class_addpointer(inlet_class, inlet_pointer);
- class_addfloat(inlet_class, inlet_float);
- class_addsymbol(inlet_class, inlet_symbol);
- class_addlist(inlet_class, inlet_list);
- class_addanything(inlet_class, inlet_anything);
-
- pointerinlet_class = class_new(gensym("inlet"), 0, 0,
- sizeof(t_inlet), CLASS_PD, 0);
- class_addpointer(pointerinlet_class, pointerinlet_pointer);
-
- floatinlet_class = class_new(gensym("inlet"), 0, 0,
- sizeof(t_inlet), CLASS_PD, 0);
- class_addfloat(floatinlet_class, (t_method)floatinlet_float);
-
- symbolinlet_class = class_new(gensym("inlet"), 0, 0,
- sizeof(t_inlet), CLASS_PD, 0);
- class_addsymbol(symbolinlet_class, symbolinlet_symbol);
-
-}
-
-/* --------------------------- outlets ------------------------------ */
-
-static char *stacklimit, *topstack;
-#define STACKSIZE 1000000
-static int outlet_eventno;
-
- /* set a stack limit (on each incoming event that can set off messages)
- for the outlet functions to check to prevent stack overflow from message
- recursion */
-void outlet_setstacklim(void)
-{
- char c;
- topstack = &c;
- stacklimit = (&c) - STACKSIZE;
- outlet_eventno++;
-}
-
- /* get a number unique to the (clock, MIDI, GUI, etc.) event we're on */
-int sched_geteventno( void)
-{
- return (outlet_eventno);
-}
-
-struct _outconnect
-{
- struct _outconnect *oc_next;
- t_pd *oc_to;
-};
-
-struct _outlet
-{
- t_object *o_owner;
- struct _outlet *o_next;
- t_outconnect *o_connections;
- t_symbol *o_sym;
-};
-
-t_outlet *outlet_new(t_object *owner, t_symbol *s)
-{
- t_outlet *x = (t_outlet *)getbytes(sizeof(*x)), *y, *y2;
- x->o_owner = owner;
- x->o_next = 0;
- if (y = owner->ob_outlet)
- {
- while (y2 = y->o_next) y = y2;
- y->o_next = x;
- }
- else owner->ob_outlet = x;
- x->o_connections = 0;
- x->o_sym = s;
- return (x);
-}
-
-static void outlet_stackerror(t_outlet *x)
-{
- pd_error(x->o_owner, "stack overflow");
- stacklimit = topstack;
-}
-
-void outlet_bang(t_outlet *x)
-{
- t_outconnect *oc;
- char c;
- if (&c < stacklimit)
- outlet_stackerror(x);
- else for (oc = x->o_connections; oc; oc = oc->oc_next)
- pd_bang(oc->oc_to);
-}
-
-void outlet_pointer(t_outlet *x, t_gpointer *gp)
-{
- t_outconnect *oc;
- t_gpointer gpointer;
- char c;
- if (&c < stacklimit)
- outlet_stackerror(x);
- else
- {
-#if 0
- gpointer_copy(gp, &gpointer);
- for (oc = x->o_connections; oc; oc = oc->oc_next)
- pd_pointer(oc->oc_to, &gpointer);
- gpointer_unset(&gpointer);
-#else
- gpointer = *gp;
- for (oc = x->o_connections; oc; oc = oc->oc_next)
- pd_pointer(oc->oc_to, &gpointer);
-#endif
- }
-}
-
-void outlet_float(t_outlet *x, t_float f)
-{
- t_outconnect *oc;
- char c;
- if (&c < stacklimit)
- outlet_stackerror(x);
- else for (oc = x->o_connections; oc; oc = oc->oc_next)
- pd_float(oc->oc_to, f);
-}
-
-void outlet_symbol(t_outlet *x, t_symbol *s)
-{
- t_outconnect *oc;
- char c;
- if (&c < stacklimit)
- outlet_stackerror(x);
- else for (oc = x->o_connections; oc; oc = oc->oc_next)
- pd_symbol(oc->oc_to, s);
-}
-
-void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_outconnect *oc;
- char c;
- if (&c < stacklimit)
- outlet_stackerror(x);
- else for (oc = x->o_connections; oc; oc = oc->oc_next)
- pd_list(oc->oc_to, s, argc, argv);
-}
-
-void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_outconnect *oc;
- char c;
- if (&c < stacklimit)
- outlet_stackerror(x);
- else for (oc = x->o_connections; oc; oc = oc->oc_next)
- typedmess(oc->oc_to, s, argc, argv);
-}
-
- /* get the outlet's declared symbol */
-t_symbol *outlet_getsymbol(t_outlet *x)
-{
- return (x->o_sym);
-}
-
-void outlet_free(t_outlet *x)
-{
- t_object *y = x->o_owner;
- t_outlet *x2;
- if (y->ob_outlet == x) y->ob_outlet = x->o_next;
- else for (x2 = y->ob_outlet; x2; x2 = x2->o_next)
- if (x2->o_next == x)
- {
- x2->o_next = x->o_next;
- break;
- }
- t_freebytes(x, sizeof(*x));
-}
-
-t_outconnect *obj_connect(t_object *source, int outno,
- t_object *sink, int inno)
-{
- t_inlet *i;
- t_outlet *o;
- t_pd *to;
- t_outconnect *oc, *oc2;
-
- for (o = source->ob_outlet; o && outno; o = o->o_next, outno--) ;
- if (!o) return (0);
-
- if (sink->ob_pd->c_firstin)
- {
- if (!inno)
- {
- to = &sink->ob_pd;
- goto doit;
- }
- else inno--;
- }
- for (i = sink->ob_inlet; i && inno; i = i->i_next, inno--) ;
- if (!i) return (0);
- to = &i->i_pd;
-doit:
- oc = (t_outconnect *)t_getbytes(sizeof(*oc));
- oc->oc_next = 0;
- oc->oc_to = to;
- /* append it to the end of the list */
- /* LATER we might cache the last "oc" to make this faster. */
- if ((oc2 = o->o_connections))
- {
- while (oc2->oc_next) oc2 = oc2->oc_next;
- oc2->oc_next = oc;
- }
- else o->o_connections = oc;
- if (o->o_sym == &s_signal) canvas_update_dsp();
-
- return (oc);
-}
-
-void obj_disconnect(t_object *source, int outno, t_object *sink, int inno)
-{
- t_inlet *i;
- t_outlet *o;
- t_pd *to;
- t_outconnect *oc, *oc2;
-
- for (o = source->ob_outlet; o && outno; o = o->o_next, outno--)
- if (!o) return;
- if (sink->ob_pd->c_firstin)
- {
- if (!inno)
- {
- to = &sink->ob_pd;
- goto doit;
- }
- else inno--;
- }
- for (i = sink->ob_inlet; i && inno; i = i->i_next, inno--) ;
- if (!i) return;
- to = &i->i_pd;
-doit:
- if (!(oc = o->o_connections)) return;
- if (oc->oc_to == to)
- {
- o->o_connections = oc->oc_next;
- freebytes(oc, sizeof(*oc));
- goto done;
- }
- while (oc2 = oc->oc_next)
- {
- if (oc2->oc_to == to)
- {
- oc->oc_next = oc2->oc_next;
- freebytes(oc2, sizeof(*oc2));
- goto done;
- }
- oc = oc2;
- }
-done:
- if (o->o_sym == &s_signal) canvas_update_dsp();
-}
-
-/* ------ traversal routines for code that can't see our structures ------ */
-
-int obj_noutlets(t_object *x)
-{
- int n;
- t_outlet *o;
- for (o = x->ob_outlet, n = 0; o; o = o->o_next) n++;
- return (n);
-}
-
-int obj_ninlets(t_object *x)
-{
- int n;
- t_inlet *i;
- for (i = x->ob_inlet, n = 0; i; i = i->i_next) n++;
- if (x->ob_pd->c_firstin) n++;
- return (n);
-}
-
-t_outconnect *obj_starttraverseoutlet(t_object *x, t_outlet **op, int nout)
-{
- t_outlet *o = x->ob_outlet;
- while (nout-- && o) o = o->o_next;
- *op = o;
- if (o) return (o->o_connections);
- else return (0);
-}
-
-t_outconnect *obj_nexttraverseoutlet(t_outconnect *lastconnect,
- t_object **destp, t_inlet **inletp, int *whichp)
-{
- t_pd *y;
- y = lastconnect->oc_to;
- if (ISINLET(y))
- {
- int n;
- t_inlet *i = (t_inlet *)y, *i2;
- t_object *dest = i->i_owner;
- for (n = dest->ob_pd->c_firstin, i2 = dest->ob_inlet;
- i2 && i2 != i; i2 = i2->i_next) n++;
- *whichp = n;
- *destp = dest;
- *inletp = i;
- }
- else
- {
- *whichp = 0;
- *inletp = 0;
- *destp = ((t_object *)y);
- }
- return (lastconnect->oc_next);
-}
-
- /* this one checks that a pd is indeed a patchable object, and returns
- it, correctly typed, or zero if the check failed. */
-t_object *pd_checkobject(t_pd *x)
-{
- if ((*x)->c_patchable) return ((t_object *)x);
- else return (0);
-}
-
- /* move an inlet or outlet to the head of the list */
-void obj_moveinletfirst(t_object *x, t_inlet *i)
-{
- t_inlet *i2;
- if (x->ob_inlet == i) return;
- else for (i2 = x->ob_inlet; i2; i2 = i2->i_next)
- if (i2->i_next == i)
- {
- i2->i_next = i->i_next;
- i->i_next = x->ob_inlet;
- x->ob_inlet = i;
- return;
- }
-}
-
-void obj_moveoutletfirst(t_object *x, t_outlet *o)
-{
- t_outlet *o2;
- if (x->ob_outlet == o) return;
- else for (o2 = x->ob_outlet; o2; o2 = o2->o_next)
- if (o2->o_next == o)
- {
- o2->o_next = o->o_next;
- o->o_next = x->ob_outlet;
- x->ob_outlet = o;
- return;
- }
-}
-
- /* routines for DSP sorting, which are used in d_ugen.c and g_canvas.c */
- /* LATER try to consolidate all the slightly different routines. */
-
-int obj_nsiginlets(t_object *x)
-{
- int n;
- t_inlet *i;
- for (i = x->ob_inlet, n = 0; i; i = i->i_next)
- if (i->i_symfrom == &s_signal) n++;
- if (x->ob_pd->c_firstin && x->ob_pd->c_floatsignalin) n++;
- return (n);
-}
-
- /* get the index, among signal inlets, of the mth inlet overall */
-int obj_siginletindex(t_object *x, int m)
-{
- int n = 0;
- t_inlet *i;
- if (x->ob_pd->c_firstin && x->ob_pd->c_floatsignalin)
- {
- if (!m--) return (0);
- n++;
- }
- for (i = x->ob_inlet; i; i = i->i_next, m--)
- if (i->i_symfrom == &s_signal)
- {
- if (m == 0) return (n);
- n++;
- }
- return (-1);
-}
-
-int obj_issignalinlet(t_object *x, int m)
-{
- t_inlet *i;
- if (x->ob_pd->c_firstin)
- {
- if (!m)
- return (x->ob_pd->c_firstin && x->ob_pd->c_floatsignalin);
- else m--;
- }
- for (i = x->ob_inlet; i && m; i = i->i_next, m--)
- ;
- return (i && (i->i_symfrom == &s_signal));
-}
-
-int obj_nsigoutlets(t_object *x)
-{
- int n;
- t_outlet *o;
- for (o = x->ob_outlet, n = 0; o; o = o->o_next)
- if (o->o_sym == &s_signal) n++;
- return (n);
-}
-
-int obj_sigoutletindex(t_object *x, int m)
-{
- int n;
- t_outlet *o2;
- for (o2 = x->ob_outlet, n = 0; o2; o2 = o2->o_next, m--)
- if (o2->o_sym == &s_signal)
- {
- if (m == 0) return (n);
- n++;
- }
- return (-1);
-}
-
-int obj_issignaloutlet(t_object *x, int m)
-{
- int n;
- t_outlet *o2;
- for (o2 = x->ob_outlet, n = 0; o2 && m--; o2 = o2->o_next);
- return (o2 && (o2->o_sym == &s_signal));
-}
-
-t_sample *obj_findsignalscalar(t_object *x, int m)
-{
- int n = 0;
- t_inlet *i;
- if (x->ob_pd->c_firstin && x->ob_pd->c_floatsignalin)
- {
- if (!m--)
- return (x->ob_pd->c_floatsignalin > 0 ?
- (t_sample *)(((char *)x) + x->ob_pd->c_floatsignalin) : 0);
- n++;
- }
- for (i = x->ob_inlet; i; i = i->i_next, m--)
- if (i->i_symfrom == &s_signal)
- {
- if (m == 0)
- return (&i->i_un.iu_floatsignalvalue);
- n++;
- }
- return (0);
-}
-
-/* and these are only used in g_io.c... */
-
-int inlet_getsignalindex(t_inlet *x)
-{
- int n = 0;
- t_inlet *i;
- for (i = x->i_owner->ob_inlet, n = 0; i && i != x; i = i->i_next)
- if (i->i_symfrom == &s_signal) n++;
- return (n);
-}
-
-int outlet_getsignalindex(t_outlet *x)
-{
- int n = 0;
- t_outlet *o;
- for (o = x->o_owner->ob_outlet, n = 0; o && o != x; o = o->o_next)
- if (o->o_sym == &s_signal) n++;
- return (n);
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/m_pd.c b/apps/plugins/pdbox/PDa/src/m_pd.c
index 321574b5a2..e686c2cb52 100644
--- a/apps/plugins/pdbox/PDa/src/m_pd.c
+++ b/apps/plugins/pdbox/PDa/src/m_pd.c
@@ -304,309 +304,3 @@ void pd_init(void)
glob_init();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include <stdlib.h>
-#include "m_pd.h"
-#include "m_imp.h"
-
- /* FIXME no out-of-memory testing yet! */
-
-t_pd *pd_new(t_class *c)
-{
- t_pd *x;
- if (!c)
- bug ("pd_new: apparently called before setup routine");
- x = (t_pd *)t_getbytes(c->c_size);
- *x = c;
- if (c->c_patchable)
- {
- ((t_object *)x)->ob_inlet = 0;
- ((t_object *)x)->ob_outlet = 0;
- }
- return (x);
-}
-
-void pd_free(t_pd *x)
-{
- t_class *c = *x;
- if (c->c_freemethod) (*(t_gotfn)(c->c_freemethod))(x);
- if (c->c_patchable)
- {
- while (((t_object *)x)->ob_outlet)
- outlet_free(((t_object *)x)->ob_outlet);
- while (((t_object *)x)->ob_inlet)
- inlet_free(((t_object *)x)->ob_inlet);
- if (((t_object *)x)->ob_binbuf)
- binbuf_free(((t_object *)x)->ob_binbuf);
- }
- if (c->c_size) t_freebytes(x, c->c_size);
-}
-
-void gobj_save(t_gobj *x, t_binbuf *b)
-{
- t_class *c = x->g_pd;
- if (c->c_savefn)
- (c->c_savefn)(x, b);
-}
-
-/* deal with several objects bound to the same symbol. If more than one, we
-actually bind a collection object to the symbol, which forwards messages sent
-to the symbol. */
-
-static t_class *bindlist_class;
-
-typedef struct _bindelem
-{
- t_pd *e_who;
- struct _bindelem *e_next;
-} t_bindelem;
-
-typedef struct _bindlist
-{
- t_pd b_pd;
- t_bindelem *b_list;
-} t_bindlist;
-
-static void bindlist_bang(t_bindlist *x)
-{
- t_bindelem *e;
- for (e = x->b_list; e; e = e->e_next)
- pd_bang(e->e_who);
-}
-
-static void bindlist_float(t_bindlist *x, t_float f)
-{
- t_bindelem *e;
- for (e = x->b_list; e; e = e->e_next) {
- pd_float(e->e_who, f);
- }
-}
-
-static void bindlist_symbol(t_bindlist *x, t_symbol *s)
-{
- t_bindelem *e;
- for (e = x->b_list; e; e = e->e_next)
- pd_symbol(e->e_who, s);
-}
-
-static void bindlist_pointer(t_bindlist *x, t_gpointer *gp)
-{
- t_bindelem *e;
- for (e = x->b_list; e; e = e->e_next)
- pd_pointer(e->e_who, gp);
-}
-
-static void bindlist_list(t_bindlist *x, t_symbol *s,
- int argc, t_atom *argv)
-{
- t_bindelem *e;
- for (e = x->b_list; e; e = e->e_next)
- pd_list(e->e_who, s, argc, argv);
-}
-
-static void bindlist_anything(t_bindlist *x, t_symbol *s,
- int argc, t_atom *argv)
-{
- t_bindelem *e;
- for (e = x->b_list; e; e = e->e_next)
- pd_typedmess(e->e_who, s, argc, argv);
-}
-
-void m_pd_setup(void)
-{
- bindlist_class = class_new(gensym("bindlist"), 0, 0,
- sizeof(t_bindlist), CLASS_PD, 0);
- class_addbang(bindlist_class, bindlist_bang);
- class_addfloat(bindlist_class, (t_method)bindlist_float);
- class_addsymbol(bindlist_class, bindlist_symbol);
- class_addpointer(bindlist_class, bindlist_pointer);
- class_addlist(bindlist_class, bindlist_list);
- class_addanything(bindlist_class, bindlist_anything);
-}
-
-void pd_bind(t_pd *x, t_symbol *s)
-{
- pd_checkgui(x,s);
- if (s->s_thing)
- {
- if (*s->s_thing == bindlist_class)
- {
- t_bindlist *b = (t_bindlist *)s->s_thing;
- t_bindelem *e = (t_bindelem *)getbytes(sizeof(t_bindelem));
- e->e_next = b->b_list;
- e->e_who = x;
- b->b_list = e;
- }
- else
- {
- t_bindlist *b = (t_bindlist *)pd_new(bindlist_class);
- t_bindelem *e1 = (t_bindelem *)getbytes(sizeof(t_bindelem));
- t_bindelem *e2 = (t_bindelem *)getbytes(sizeof(t_bindelem));
- b->b_list = e1;
- e1->e_who = x;
- e1->e_next = e2;
- e2->e_who = s->s_thing;
- e2->e_next = 0;
- s->s_thing = &b->b_pd;
- }
- }
- else s->s_thing = x;
-}
-
-void pd_unbind(t_pd *x, t_symbol *s)
-{
- if (s->s_thing == x) s->s_thing = 0;
- else if (s->s_thing && *s->s_thing == bindlist_class)
- {
- /* bindlists always have at least two elements... if the number
- goes down to one, get rid of the bindlist and bind the symbol
- straight to the remaining element. */
-
- t_bindlist *b = (t_bindlist *)s->s_thing;
- t_bindelem *e, *e2;
- if ((e = b->b_list)->e_who == x)
- {
- b->b_list = e->e_next;
- freebytes(e, sizeof(t_bindelem));
- }
- else for (e = b->b_list; e2 = e->e_next; e = e2)
- if (e2->e_who == x)
- {
- e->e_next = e2->e_next;
- freebytes(e2, sizeof(t_bindelem));
- break;
- }
- if (!b->b_list->e_next)
- {
- s->s_thing = b->b_list->e_who;
- freebytes(b->b_list, sizeof(t_bindelem));
- pd_free(&b->b_pd);
- }
- }
- else pd_error(x, "%s: couldn't unbind", s->s_name);
-}
-
-void zz(void) {}
-
-t_pd *pd_findbyclass(t_symbol *s, t_class *c)
-{
- t_pd *x = 0;
-
- if (!s->s_thing) return (0);
- if (*s->s_thing == c) return (s->s_thing);
- if (*s->s_thing == bindlist_class)
- {
- t_bindlist *b = (t_bindlist *)s->s_thing;
- t_bindelem *e, *e2;
- int warned = 0;
- for (e = b->b_list; e; e = e->e_next)
- if (*e->e_who == c)
- {
- if (x && !warned)
- {
- zz();
- post("warning: %s: multiply defined", s->s_name);
- warned = 1;
- }
- x = e->e_who;
- }
- }
- return x;
-}
-
-/* stack for maintaining bindings for the #X symbol during nestable loads.
-*/
-
-typedef struct _gstack
-{
- t_pd *g_what;
- t_symbol *g_loadingabstraction;
- struct _gstack *g_next;
-} t_gstack;
-
-static t_gstack *gstack_head = 0;
-static t_pd *lastpopped;
-static t_symbol *pd_loadingabstraction;
-
-int pd_setloadingabstraction(t_symbol *sym)
-{
- t_gstack *foo = gstack_head;
- for (foo = gstack_head; foo; foo = foo->g_next)
- if (foo->g_loadingabstraction == sym)
- return (1);
- pd_loadingabstraction = sym;
- return (0);
-}
-
-void pd_pushsym(t_pd *x)
-{
- t_gstack *y = (t_gstack *)t_getbytes(sizeof(*y));
- y->g_what = s__X.s_thing;
- y->g_next = gstack_head;
- y->g_loadingabstraction = pd_loadingabstraction;
- pd_loadingabstraction = 0;
- gstack_head = y;
- s__X.s_thing = x;
-}
-
-void pd_popsym(t_pd *x)
-{
- if (!gstack_head || s__X.s_thing != x) bug("gstack_pop");
- else
- {
- t_gstack *headwas = gstack_head;
- s__X.s_thing = headwas->g_what;
- gstack_head = headwas->g_next;
- t_freebytes(headwas, sizeof(*headwas));
- lastpopped = x;
- }
-}
-
-void pd_doloadbang(void)
-{
- if (lastpopped)
- pd_vmess(lastpopped, gensym("loadbang"), "");
- lastpopped = 0;
-}
-
-void pd_bang(t_pd *x)
-{
- (*(*x)->c_bangmethod)(x);
-}
-
-void pd_float(t_pd *x, t_float f)
-{
- (*(*x)->c_floatmethod)(x, f);
-}
-
-void pd_pointer(t_pd *x, t_gpointer *gp)
-{
- (*(*x)->c_pointermethod)(x, gp);
-}
-
-void pd_symbol(t_pd *x, t_symbol *s)
-{
- (*(*x)->c_symbolmethod)(x, s);
-}
-
-void pd_list(t_pd *x, t_symbol *s, int argc, t_atom *argv)
-{
- (*(*x)->c_listmethod)(x, &s_list, argc, argv);
-}
-
-void mess_init(void);
-void obj_init(void);
-void conf_init(void);
-void glob_init(void);
-
-void pd_init(void)
-{
- mess_init();
- obj_init();
- conf_init();
- glob_init();
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/m_pd.h b/apps/plugins/pdbox/PDa/src/m_pd.h
index 67c569c581..9f60baa293 100644
--- a/apps/plugins/pdbox/PDa/src/m_pd.h
+++ b/apps/plugins/pdbox/PDa/src/m_pd.h
@@ -648,653 +648,4 @@ defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */
#define __m_pd_h_
#endif /* __m_pd_h_ */
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#ifndef __m_pd_h_
-
-#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
-extern "C" {
-#endif
-
-#define PD_VERSION 0.37 /* oops, don't use this... */ */
-#define PD_MAJOR_VERSION 0 /* ... use these two instead. */
-#define PD_MINOR_VERSION 37
-
-/* old name for "MSW" flag -- we have to take it for the sake of many old
-"nmakefiles" for externs, which will define NT and not MSW */
-#if defined(NT) && !defined(MSW)
-#define MSW
-#endif
-
-#ifdef MSW
-// #pragma warning( disable : 4091 )
-#pragma warning( disable : 4305 ) /* uncast const double to float */
-#pragma warning( disable : 4244 ) /* uncast float/int conversion etc. */
-#pragma warning( disable : 4101 ) /* unused automatic variables */
-#endif /* MSW */
-
- /* the external storage class is "extern" in UNIX; in MSW it's ugly. */
-#ifdef MSW
-#ifdef PD_INTERNAL
-#define EXTERN __declspec(dllexport) extern
-#else
-#define EXTERN __declspec(dllimport) extern
-#endif /* PD_INTERNAL */
-#else
-#define EXTERN extern
-#endif /* MSW */
-
- /* and depending on the compiler, hidden data structures are
- declared differently: */
-#if defined( __GNUC__) || defined( __BORLANDC__ ) || defined( __MWERKS__ )
-#define EXTERN_STRUCT struct
-#else
-#define EXTERN_STRUCT extern struct
-#endif
-
-
-#if !defined(_SIZE_T) && !defined(_SIZE_T_)
-#include <stddef.h> /* just for size_t -- how lame! */
-#endif
-
-#define MAXPDSTRING 1000 /* use this for anything you want */
-#define MAXPDARG 5 /* max number of args we can typecheck today */
-
- /* signed and unsigned integer types the size of a pointer: */
-#ifdef __alpha__
-typedef long t_int;
-#else
-typedef int t_int;
-#endif
-
-typedef float t_float; /* a floating-point number at most the same size */
-typedef float t_floatarg; /* floating-point type for function calls */
-
-typedef struct _symbol
-{
- char *s_name;
- struct _class **s_thing;
- struct _symbol *s_next;
-} t_symbol;
-
-EXTERN_STRUCT _array;
-#define t_array struct _array /* g_canvas.h */
-
-/* pointers to glist and array elements go through a "stub" which sticks
-around after the glist or array is freed. The stub itself is deleted when
-both the glist/array is gone and the refcount is zero, ensuring that no
-gpointers are pointing here. */
-
-#define GP_NONE 0 /* the stub points nowhere (has been cut off) */
-#define GP_GLIST 1 /* the stub points to a glist element */
-#define GP_ARRAY 2 /* ... or array */
-typedef struct _gstub
-{
- union
- {
- struct _glist *gs_glist; /* glist we're in */
- struct _array *gs_array; /* array we're in */
- } gs_un;
- int gs_which; /* GP_GLIST/GP_ARRAY */
- int gs_refcount; /* number of gpointers pointing here */
-} t_gstub;
-
-typedef struct _gpointer /* pointer to a gobj in a glist */
-{
- union
- {
- struct _scalar *gp_scalar; /* scalar we're in (if glist) */
- union word *gp_w; /* raw data (if array) */
- } gp_un;
- int gp_valid; /* number which must match gpointee */
- t_gstub *gp_stub; /* stub which points to glist/array */
-} t_gpointer;
-
-typedef union word
-{
- t_float w_float;
- t_symbol *w_symbol;
- t_gpointer *w_gpointer;
- t_array *w_array;
- struct _glist *w_list;
- int w_index;
-} t_word;
-
-typedef enum
-{
- A_NULL,
- A_FLOAT,
- A_SYMBOL,
- A_POINTER,
- A_SEMI,
- A_COMMA,
- A_DEFFLOAT,
- A_DEFSYM,
- A_DOLLAR,
- A_DOLLSYM,
- A_GIMME,
- A_CANT
-} t_atomtype;
-
-#define A_DEFSYMBOL A_DEFSYM /* better name for this */
-
-typedef struct _atom
-{
- t_atomtype a_type;
- union word a_w;
-} t_atom;
-
-EXTERN_STRUCT _class;
-#define t_class struct _class
-
-EXTERN_STRUCT _outlet;
-#define t_outlet struct _outlet
-
-EXTERN_STRUCT _inlet;
-#define t_inlet struct _inlet
-
-EXTERN_STRUCT _binbuf;
-#define t_binbuf struct _binbuf
-
-EXTERN_STRUCT _clock;
-#define t_clock struct _clock
-
-EXTERN_STRUCT _outconnect;
-#define t_outconnect struct _outconnect
-
-EXTERN_STRUCT _glist;
-#define t_glist struct _glist
-#define t_canvas struct _glist /* LATER lose this */
-
-typedef t_class *t_pd; /* pure datum: nothing but a class pointer */
-
-typedef struct _gobj /* a graphical object */
-{
- t_pd g_pd; /* pure datum header (class) */
- struct _gobj *g_next; /* next in list */
-} t_gobj;
-
-typedef struct _scalar /* a graphical object holding data */
-{
- t_gobj sc_gobj; /* header for graphical object */
- t_symbol *sc_template; /* template name (LATER replace with pointer) */
- t_word sc_vec[1]; /* indeterminate-length array of words */
-} t_scalar;
-
-typedef struct _text /* patchable object - graphical, with text */
-{
- t_gobj te_g; /* header for graphical object */
- t_binbuf *te_binbuf; /* holder for the text */
- t_outlet *te_outlet; /* linked list of outlets */
- t_inlet *te_inlet; /* linked list of inlets */
- short te_xpix; /* x&y location (within the toplevel) */
- short te_ypix;
- short te_width; /* requested width in chars, 0 if auto */
- unsigned int te_type:2; /* from defs below */
-} t_text;
-
-#define T_TEXT 0 /* just a textual comment */
-#define T_OBJECT 1 /* a MAX style patchable object */
-#define T_MESSAGE 2 /* a MAX stype message */
-#define T_ATOM 3 /* a cell to display a number or symbol */
-
-#define te_pd te_g.g_pd
-
- /* t_object is synonym for t_text (LATER unify them) */
-
-typedef struct _text t_object;
-
-#define ob_outlet te_outlet
-#define ob_inlet te_inlet
-#define ob_binbuf te_binbuf
-#define ob_pd te_g.g_pd
-#define ob_g te_g
-
-typedef void (*t_method)(void);
-typedef void *(*t_newmethod)( void);
-typedef void (*t_gotfn)(void *x, ...);
-
-/* ---------------- pre-defined objects and symbols --------------*/
-EXTERN t_pd pd_objectmaker; /* factory for creating "object" boxes */
-EXTERN t_pd pd_canvasmaker; /* factory for creating canvases */
-EXTERN t_symbol s_pointer;
-EXTERN t_symbol s_float;
-EXTERN t_symbol s_symbol;
-EXTERN t_symbol s_bang;
-EXTERN t_symbol s_list;
-EXTERN t_symbol s_anything;
-EXTERN t_symbol s_signal;
-EXTERN t_symbol s__N;
-EXTERN t_symbol s__X;
-EXTERN t_symbol s_x;
-EXTERN t_symbol s_y;
-EXTERN t_symbol s_;
-
-/* --------- prototypes from the central message system ----------- */
-EXTERN void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN void pd_forwardmess(t_pd *x, int argc, t_atom *argv);
-EXTERN t_symbol *gensym(char *s);
-EXTERN t_gotfn getfn(t_pd *x, t_symbol *s);
-EXTERN t_gotfn zgetfn(t_pd *x, t_symbol *s);
-EXTERN void nullfn(void);
-EXTERN void pd_vmess(t_pd *x, t_symbol *s, char *fmt, ...);
-#define mess0(x, s) ((*getfn((x), (s)))((x)))
-#define mess1(x, s, a) ((*getfn((x), (s)))((x), (a)))
-#define mess2(x, s, a,b) ((*getfn((x), (s)))((x), (a),(b)))
-#define mess3(x, s, a,b,c) ((*getfn((x), (s)))((x), (a),(b),(c)))
-#define mess4(x, s, a,b,c,d) ((*getfn((x), (s)))((x), (a),(b),(c),(d)))
-#define mess5(x, s, a,b,c,d,e) ((*getfn((x), (s)))((x), (a),(b),(c),(d),(e)))
-EXTERN void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN t_pd *pd_newest(void);
-
-/* --------------- memory management -------------------- */
-EXTERN void *getbytes(size_t nbytes);
-EXTERN void *getzbytes(size_t nbytes);
-EXTERN void *copybytes(void *src, size_t nbytes);
-EXTERN void freebytes(void *x, size_t nbytes);
-EXTERN void *resizebytes(void *x, size_t oldsize, size_t newsize);
-
-/* -------------------- atoms ----------------------------- */
-
-#define SETSEMI(atom) ((atom)->a_type = A_SEMI, (atom)->a_w.w_index = 0)
-#define SETCOMMA(atom) ((atom)->a_type = A_COMMA, (atom)->a_w.w_index = 0)
-#define SETPOINTER(atom, gp) ((atom)->a_type = A_POINTER, \
- (atom)->a_w.w_gpointer = (gp))
-#define SETFLOAT(atom, f) ((atom)->a_type = A_FLOAT, (atom)->a_w.w_float = (f))
-#define SETSYMBOL(atom, s) ((atom)->a_type = A_SYMBOL, \
- (atom)->a_w.w_symbol = (s))
-#define SETDOLLAR(atom, n) ((atom)->a_type = A_DOLLAR, \
- (atom)->a_w.w_index = (n))
-#define SETDOLLSYM(atom, s) ((atom)->a_type = A_DOLLSYM, \
- (atom)->a_w.w_symbol= (s))
-
-EXTERN t_float atom_getfloat(t_atom *a);
-EXTERN t_int atom_getint(t_atom *a);
-EXTERN t_symbol *atom_getsymbol(t_atom *a);
-EXTERN t_symbol *atom_gensym(t_atom *a);
-EXTERN t_float atom_getfloatarg(int which, int argc, t_atom *argv);
-EXTERN t_int atom_getintarg(int which, int argc, t_atom *argv);
-EXTERN t_symbol *atom_getsymbolarg(int which, int argc, t_atom *argv);
-
-EXTERN void atom_string(t_atom *a, char *buf, unsigned int bufsize);
-
-/* ------------------ binbufs --------------- */
-
-EXTERN t_binbuf *binbuf_new(void);
-EXTERN void binbuf_free(t_binbuf *x);
-EXTERN t_binbuf *binbuf_duplicate(t_binbuf *y);
-
-EXTERN void binbuf_text(t_binbuf *x, char *text, size_t size);
-EXTERN void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp);
-EXTERN void binbuf_clear(t_binbuf *x);
-EXTERN void binbuf_add(t_binbuf *x, int argc, t_atom *argv);
-EXTERN void binbuf_addv(t_binbuf *x, char *fmt, ...);
-EXTERN void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y);
-EXTERN void binbuf_addsemi(t_binbuf *x);
-EXTERN void binbuf_restore(t_binbuf *x, int argc, t_atom *argv);
-EXTERN void binbuf_print(t_binbuf *x);
-EXTERN int binbuf_getnatom(t_binbuf *x);
-EXTERN t_atom *binbuf_getvec(t_binbuf *x);
-EXTERN void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv);
-EXTERN int binbuf_read(t_binbuf *b, char *filename, char *dirname,
- int crflag);
-EXTERN int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname,
- int crflag);
-EXTERN int binbuf_write(t_binbuf *x, char *filename, char *dir,
- int crflag);
-EXTERN void binbuf_evalfile(t_symbol *name, t_symbol *dir);
-EXTERN t_symbol *binbuf_realizedollsym(t_symbol *s, int ac, t_atom *av,
- int tonew);
-
-/* ------------------ clocks --------------- */
-
-typedef long long t_time;
-EXTERN t_clock *clock_new(void *owner, t_method fn);
-EXTERN void clock_set(t_clock *x, t_time systime);
-EXTERN void clock_delay(t_clock *x, t_time delaytime);
-EXTERN void clock_unset(t_clock *x);
-EXTERN t_time clock_getlogicaltime(void);
-EXTERN t_time clock_getsystime(void); /* OBSOLETE; use clock_getlogicaltime() */
-EXTERN t_time clock_gettimesince(t_time prevsystime);
-EXTERN t_time clock_getsystimeafter(t_time delaytime);
-EXTERN void clock_free(t_clock *x);
-
-/* ----------------- pure data ---------------- */
-EXTERN t_pd *pd_new(t_class *cls);
-EXTERN void pd_free(t_pd *x);
-EXTERN void pd_bind(t_pd *x, t_symbol *s);
-EXTERN void pd_unbind(t_pd *x, t_symbol *s);
-EXTERN t_pd *pd_findbyclass(t_symbol *s, t_class *c);
-EXTERN void pd_pushsym(t_pd *x);
-EXTERN void pd_popsym(t_pd *x);
-EXTERN t_symbol *pd_getfilename(void);
-EXTERN t_symbol *pd_getdirname(void);
-EXTERN void pd_bang(t_pd *x);
-EXTERN void pd_pointer(t_pd *x, t_gpointer *gp);
-EXTERN void pd_float(t_pd *x, t_float f);
-EXTERN void pd_symbol(t_pd *x, t_symbol *s);
-EXTERN void pd_list(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN void pd_anything(t_pd *x, t_symbol *s, int argc, t_atom *argv);
-#define pd_class(x) (*(x))
-
-/* ----------------- pointers ---------------- */
-EXTERN void gpointer_init(t_gpointer *gp);
-EXTERN void gpointer_copy(const t_gpointer *gpfrom, t_gpointer *gpto);
-EXTERN void gpointer_unset(t_gpointer *gp);
-EXTERN int gpointer_check(const t_gpointer *gp, int headok);
-
-/* ----------------- patchable "objects" -------------- */
-EXTERN_STRUCT _inlet;
-#define t_inlet struct _inlet
-EXTERN_STRUCT _outlet;
-#define t_outlet struct _outlet
-
-EXTERN t_inlet *inlet_new(t_object *owner, t_pd *dest, t_symbol *s1,
- t_symbol *s2);
-EXTERN t_inlet *pointerinlet_new(t_object *owner, t_gpointer *gp);
-EXTERN t_inlet *floatinlet_new(t_object *owner, t_float *fp);
-EXTERN t_inlet *symbolinlet_new(t_object *owner, t_symbol **sp);
-EXTERN void inlet_free(t_inlet *x);
-
-EXTERN t_outlet *outlet_new(t_object *owner, t_symbol *s);
-EXTERN void outlet_bang(t_outlet *x);
-EXTERN void outlet_pointer(t_outlet *x, t_gpointer *gp);
-EXTERN void outlet_float(t_outlet *x, t_float f);
-EXTERN void outlet_symbol(t_outlet *x, t_symbol *s);
-EXTERN void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv);
-EXTERN t_symbol *outlet_getsymbol(t_outlet *x);
-EXTERN void outlet_free(t_outlet *x);
-EXTERN t_object *pd_checkobject(t_pd *x);
-
-
-/* -------------------- canvases -------------- */
-
-EXTERN void glob_setfilename(void *dummy, t_symbol *name, t_symbol *dir);
-
-EXTERN void canvas_setargs(int argc, t_atom *argv);
-EXTERN void canvas_getargs(int *argcp, t_atom **argvp);
-EXTERN t_symbol *canvas_getcurrentdir(void);
-EXTERN t_glist *canvas_getcurrent(void);
-EXTERN void canvas_makefilename(t_glist *c, char *file,
- char *result,int resultsize);
-EXTERN t_symbol *canvas_getdir(t_glist *x);
-EXTERN int sys_fontwidth(int fontsize);
-EXTERN int sys_fontheight(int fontsize);
-EXTERN void canvas_dataproperties(t_glist *x, t_scalar *sc, t_binbuf *b);
-
-/* ---------------- widget behaviors ---------------------- */
-
-EXTERN_STRUCT _widgetbehavior;
-#define t_widgetbehavior struct _widgetbehavior
-
-EXTERN_STRUCT _parentwidgetbehavior;
-#define t_parentwidgetbehavior struct _parentwidgetbehavior
-EXTERN t_parentwidgetbehavior *pd_getparentwidget(t_pd *x);
-
-/* -------------------- classes -------------- */
-
-#define CLASS_DEFAULT 0 /* flags for new classes below */
-#define CLASS_PD 1
-#define CLASS_GOBJ 2
-#define CLASS_PATCHABLE 3
-#define CLASS_NOINLET 8
-
-#define CLASS_TYPEMASK 3
-
-
-EXTERN t_class *class_new(t_symbol *name, t_newmethod newmethod,
- t_method freemethod, size_t size, int flags, t_atomtype arg1, ...);
-EXTERN void class_addcreator(t_newmethod newmethod, t_symbol *s,
- t_atomtype type1, ...);
-EXTERN void class_addmethod(t_class *c, t_method fn, t_symbol *sel,
- t_atomtype arg1, ...);
-EXTERN void class_addbang(t_class *c, t_method fn);
-EXTERN void class_addpointer(t_class *c, t_method fn);
-EXTERN void class_doaddfloat(t_class *c, t_method fn);
-EXTERN void class_addsymbol(t_class *c, t_method fn);
-EXTERN void class_addlist(t_class *c, t_method fn);
-EXTERN void class_addanything(t_class *c, t_method fn);
-EXTERN void class_sethelpsymbol(t_class *c, t_symbol *s);
-EXTERN void class_setwidget(t_class *c, t_widgetbehavior *w);
-EXTERN void class_setparentwidget(t_class *c, t_parentwidgetbehavior *w);
-EXTERN t_parentwidgetbehavior *class_parentwidget(t_class *c);
-EXTERN char *class_getname(t_class *c);
-EXTERN char *class_gethelpname(t_class *c);
-EXTERN void class_setdrawcommand(t_class *c);
-EXTERN int class_isdrawcommand(t_class *c);
-EXTERN void class_domainsignalin(t_class *c, int onset);
-#define CLASS_MAINSIGNALIN(c, type, field) \
- class_domainsignalin(c, (char *)(&((type *)0)->field) - (char *)0)
-
- /* prototype for functions to save Pd's to a binbuf */
-typedef void (*t_savefn)(t_gobj *x, t_binbuf *b);
-EXTERN void class_setsavefn(t_class *c, t_savefn f);
-EXTERN t_savefn class_getsavefn(t_class *c);
- /* prototype for functions to open properties dialogs */
-typedef void (*t_propertiesfn)(t_gobj *x, struct _glist *glist);
-EXTERN void class_setpropertiesfn(t_class *c, t_propertiesfn f);
-EXTERN t_propertiesfn class_getpropertiesfn(t_class *c);
-
-#ifndef PD_CLASS_DEF
-#define class_addbang(x, y) class_addbang((x), (t_method)(y))
-#define class_addpointer(x, y) class_addpointer((x), (t_method)(y))
-#define class_addfloat(x, y) class_doaddfloat((x), (t_method)(y))
-#define class_addsymbol(x, y) class_addsymbol((x), (t_method)(y))
-#define class_addlist(x, y) class_addlist((x), (t_method)(y))
-#define class_addanything(x, y) class_addanything((x), (t_method)(y))
-#endif
-
-/* ------------ printing --------------------------------- */
-EXTERN void post(char *fmt, ...);
-EXTERN void startpost(char *fmt, ...);
-EXTERN void poststring(char *s);
-EXTERN void postfloat(float f);
-EXTERN void postatom(int argc, t_atom *argv);
-EXTERN void endpost(void);
-EXTERN void error(char *fmt, ...);
-EXTERN void bug(char *fmt, ...);
-EXTERN void pd_error(void *object, char *fmt, ...);
-EXTERN void sys_logerror(char *object, char *s);
-EXTERN void sys_unixerror(char *object);
-EXTERN void sys_ouch(void);
-
-#ifdef __linux__
-EXTERN char* sys_get_path( void);
-#endif
-EXTERN void sys_addpath(const char* p);
-
-
-/* ------------ system interface routines ------------------- */
-EXTERN int sys_isreadablefile(const char *name);
-EXTERN void sys_bashfilename(const char *from, char *to);
-EXTERN void sys_unbashfilename(const char *from, char *to);
-EXTERN int open_via_path(const char *name, const char *ext, const char *dir,
- char *dirresult, char **nameresult, unsigned int size, int bin);
-EXTERN int sched_geteventno(void);
-EXTERN t_time sys_getrealtime(void);
-
-
-/* ------------ threading ------------------- */
-/* T.Grill - see m_sched.c */
-
-EXTERN void sys_lock(void);
-EXTERN void sys_unlock(void);
-EXTERN int sys_trylock(void);
-
-
-/* --------------- signals ----------------------------------- */
-
-#define MAXLOGSIG 32
-#define MAXSIGSIZE (1 << MAXLOGSIG)
-#ifndef FIXEDPOINT
-typedef float t_sample;
-#else
-#include "m_fixed.h"
-#endif
-
-
-typedef struct _signal
-{
- int s_n; /* number of points in the array */
- t_sample *s_vec; /* the array */
- float s_sr; /* sample rate */
- int s_refcount; /* number of times used */
- int s_isborrowed; /* whether we're going to borrow our array */
- struct _signal *s_borrowedfrom; /* signal to borrow it from */
- struct _signal *s_nextfree; /* next in freelist */
- struct _signal *s_nextused; /* next in used list */
-} t_signal;
-
-
-typedef t_int *(*t_perfroutine)(t_int *args);
-
-EXTERN t_int *plus_perform(t_int *args);
-EXTERN t_int *zero_perform(t_int *args);
-EXTERN t_int *copy_perform(t_int *args);
-
-EXTERN void dsp_add_plus(t_sample *in1, t_sample *in2, t_sample *out, int n);
-EXTERN void dsp_add_copy(t_sample *in, t_sample *out, int n);
-EXTERN void dsp_add_scalarcopy(t_sample *in, t_sample *out, int n);
-EXTERN void dsp_add_zero(t_sample *out, int n);
-
-EXTERN int sys_getblksize(void);
-EXTERN float sys_getsr(void);
-EXTERN int sys_get_inchannels(void);
-EXTERN int sys_get_outchannels(void);
-
-EXTERN void dsp_add(t_perfroutine f, int n, ...);
-EXTERN void dsp_addv(t_perfroutine f, int n, t_int *vec);
-EXTERN void pd_fft(float *buf, int npoints, int inverse);
-EXTERN int ilog2(int n);
-
-EXTERN void mayer_fht(t_sample *fz, int n);
-EXTERN void mayer_fft(int n, t_sample *real, t_sample *imag);
-EXTERN void mayer_ifft(int n, t_sample *real, t_sample *imag);
-EXTERN void mayer_realfft(int n, t_sample *real);
-EXTERN void mayer_realifft(int n, t_sample *real);
-
-//EXTERN t_sample cos_table[];
-
-#define LOGCOSTABSIZE 9
-#define COSTABSIZE (1<<LOGCOSTABSIZE)
-
-EXTERN int canvas_suspend_dsp(void);
-EXTERN void canvas_resume_dsp(int oldstate);
-EXTERN void canvas_update_dsp(void);
-
-/* IOhannes { (up/downsampling) */
-typedef struct _resample
-{
- int method; /* up/downsampling method ID */
-
- t_int downsample; /* downsampling factor */
- t_int upsample; /* upsampling factor */
-
- t_sample *s_vec; /* here we hold the resampled data */
- int s_n;
-
- t_sample *coeffs; /* coefficients for filtering... */
- int coefsize;
-
- t_sample *buffer; /* buffer for filtering */
- int bufsize;
-} t_resample;
-
-EXTERN void resample_init(t_resample *x);
-EXTERN void resample_free(t_resample *x);
-
-EXTERN void resample_dsp(t_resample *x, t_sample *in, int insize, t_sample *out, int outsize, int method);
-EXTERN void resamplefrom_dsp(t_resample *x, t_sample *in, int insize, int outsize, int method);
-EXTERN void resampleto_dsp(t_resample *x, t_sample *out, int insize, int outsize, int method);
-/* } IOhannes */
-
-/* ----------------------- utility functions for signals -------------- */
-EXTERN float mtof(float);
-EXTERN float ftom(float);
-EXTERN float rmstodb(float);
-EXTERN float powtodb(float);
-EXTERN float dbtorms(float);
-EXTERN float dbtopow(float);
-
-EXTERN float q8_sqrt(float);
-EXTERN float q8_rsqrt(float);
-#ifndef N32
-EXTERN float qsqrt(float); /* old names kept for extern compatibility */
-EXTERN float qrsqrt(float);
-#endif
-/* --------------------- data --------------------------------- */
-
- /* graphical arrays */
-EXTERN_STRUCT _garray;
-#define t_garray struct _garray
-
-EXTERN t_class *garray_class;
-EXTERN int garray_getfloatarray(t_garray *x, int *size, t_sample **vec);
-EXTERN float garray_get(t_garray *x, t_symbol *s, t_int indx);
-EXTERN void garray_redraw(t_garray *x);
-EXTERN int garray_npoints(t_garray *x);
-EXTERN char *garray_vec(t_garray *x);
-EXTERN void garray_resize(t_garray *x, t_floatarg f);
-EXTERN void garray_usedindsp(t_garray *x);
-EXTERN void garray_setsaveit(t_garray *x, int saveit);
-EXTERN t_class *scalar_class;
-
-EXTERN t_float *value_get(t_symbol *s);
-EXTERN void value_release(t_symbol *s);
-EXTERN int value_getfloat(t_symbol *s, t_float *f);
-EXTERN int value_setfloat(t_symbol *s, t_float f);
-
-/* ------- GUI interface - functions to send strings to TK --------- */
-EXTERN void sys_vgui(char *fmt, ...);
-EXTERN void sys_gui(char *s);
-
- /* dialog window creation and destruction */
-EXTERN void gfxstub_new(t_pd *owner, void *key, const char *cmd);
-EXTERN void gfxstub_deleteforkey(void *key);
-
-extern t_class *glob_pdobject; /* object to send "pd" messages */
-
-/*------------- Max 0.26 compatibility --------------------*/
-
-/* the following reflects the new way classes are laid out, with the class
- pointing to the messlist and not vice versa. Externs shouldn't feel it. */
-typedef t_class *t_externclass;
-
-EXTERN void c_extern(t_externclass *cls, t_newmethod newroutine,
- t_method freeroutine, t_symbol *name, size_t size, int tiny, \
- t_atomtype arg1, ...);
-EXTERN void c_addmess(t_method fn, t_symbol *sel, t_atomtype arg1, ...);
-
-#define t_getbytes getbytes
-#define t_freebytes freebytes
-#define t_resizebytes resizebytes
-#define typedmess pd_typedmess
-#define vmess pd_vmess
-
-/* A definition to help gui objects straddle 0.34-0.35 changes. If this is
-defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */
-
-#define PD_USE_TE_XPIX
-
-#if 0
-/* a test for NANs and denormals. Should only be necessary on i386. */
-#define PD_BADFLOAT(f) ((((*(unsigned int*)&(f))&0x7f800000)==0) || \
- (((*(unsigned int*)&(f))&0x7f800000)==0x7f800000))
-/* more stringent test: anything not between 1e-19 and 1e19 in absolute val */
-#define PD_BIGORSMALL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \
- (((*(unsigned int*)&(f))&0x60000000)==0x60000000))
-#else
-#define PD_BADFLOAT(f) 0
-#define PD_BIGORSMALL(f) 0
-#endif
-
-#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
-}
-#endif
-
-#define __m_pd_h_
-#endif /* __m_pd_h_ */
diff --git a/apps/plugins/pdbox/PDa/src/m_sched.c b/apps/plugins/pdbox/PDa/src/m_sched.c
index f40f0ff270..9d3bed828a 100644
--- a/apps/plugins/pdbox/PDa/src/m_sched.c
+++ b/apps/plugins/pdbox/PDa/src/m_sched.c
@@ -579,584 +579,4 @@ void sys_exit(void)
{
sys_quit = 1;
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* scheduling stuff */
-
-#include "m_pd.h"
-#include "m_imp.h"
-#include "s_stuff.h"
-
- /* LATER consider making this variable. It's now the LCM of all sample
- rates we expect to see: 32000, 44100, 48000, 88200, 96000. */
-#define TIMEUNITPERSEC (32.*441000.)
-
-
-/* T.Grill - enable PD global thread locking - sys_lock, sys_unlock, sys_trylock functions */
-#define THREAD_LOCKING
-#include "pthread.h"
-
-
-static int sys_quit;
-static t_time sys_time;
-static t_time sys_time_per_msec = TIMEUNITPERSEC / 1000.;
-
-int sys_schedblocksize = DEFDACBLKSIZE;
-int sys_usecsincelastsleep(void);
-int sys_sleepgrain;
-
-typedef void (*t_clockmethod)(void *client);
-
-struct _clock
-{
- t_time c_settime;
- void *c_owner;
- t_clockmethod c_fn;
- struct _clock *c_next;
-};
-
-t_clock *clock_setlist;
-
-#ifdef UNIX
-#include <unistd.h>
-#endif
-
-t_clock *clock_new(void *owner, t_method fn)
-{
- t_clock *x = (t_clock *)getbytes(sizeof *x);
- x->c_settime = -1;
- x->c_owner = owner;
- x->c_fn = (t_clockmethod)fn;
- x->c_next = 0;
- return (x);
-}
-
-void clock_unset(t_clock *x)
-{
- if (x->c_settime >= 0)
- {
- if (x == clock_setlist) clock_setlist = x->c_next;
- else
- {
- t_clock *x2 = clock_setlist;
- while (x2->c_next != x) x2 = x2->c_next;
- x2->c_next = x->c_next;
- }
- x->c_settime = -1;
- }
-}
-
- /* set the clock to call back at an absolute system time */
-void clock_set(t_clock *x, t_time setticks)
-{
- if (setticks < sys_time) setticks = sys_time;
- clock_unset(x);
- x->c_settime = setticks;
- if (clock_setlist && clock_setlist->c_settime <= setticks)
- {
- t_clock *cbefore, *cafter;
- for (cbefore = clock_setlist, cafter = clock_setlist->c_next;
- cbefore; cbefore = cafter, cafter = cbefore->c_next)
- {
- if (!cafter || cafter->c_settime > setticks)
- {
- cbefore->c_next = x;
- x->c_next = cafter;
- return;
- }
- }
- }
- else x->c_next = clock_setlist, clock_setlist = x;
-}
-
- /* set the clock to call back after a delay in msec */
-void clock_delay(t_clock *x, t_time delaytime)
-{
- clock_set(x, sys_time + sys_time_per_msec * delaytime);
-}
-
- /* get current logical time. We don't specify what units this is in;
- use clock_gettimesince() to measure intervals from time of this call.
- This was previously, incorrectly named "clock_getsystime"; the old
- name is aliased to the new one in m_pd.h. */
-t_time clock_getlogicaltime( void)
-{
- return (sys_time);
-}
- /* OBSOLETE NAME */
-t_time clock_getsystime( void) { return (sys_time); }
-
- /* elapsed time in milliseconds since the given system time */
-t_time clock_gettimesince(t_time prevsystime)
-{
- return ((sys_time - prevsystime)/sys_time_per_msec);
-}
-
- /* what value the system clock will have after a delay */
-t_time clock_getsystimeafter(t_time delaytime)
-{
- return (sys_time + sys_time_per_msec * delaytime);
-}
-
-void clock_free(t_clock *x)
-{
- clock_unset(x);
- freebytes(x, sizeof *x);
-}
-
-
-/* the following routines maintain a real-execution-time histogram of the
-various phases of real-time execution. */
-
-static int sys_bin[] = {0, 2, 5, 10, 20, 30, 50, 100, 1000};
-#define NBIN (sizeof(sys_bin)/sizeof(*sys_bin))
-#define NHIST 10
-static int sys_histogram[NHIST][NBIN];
-static t_time sys_histtime;
-static int sched_diddsp, sched_didpoll, sched_didnothing;
-
-static void sys_clearhist( void)
-{
- unsigned int i, j;
- for (i = 0; i < NHIST; i++)
- for (j = 0; j < NBIN; j++) sys_histogram[i][j] = 0;
- sys_histtime = sys_getrealtime();
- sched_diddsp = sched_didpoll = sched_didnothing = 0;
-}
-
-void sys_printhist( void)
-{
- unsigned int i, j;
- for (i = 0; i < NHIST; i++)
- {
- int doit = 0;
- for (j = 0; j < NBIN; j++) if (sys_histogram[i][j]) doit = 1;
- if (doit)
- {
- post("%2d %8d %8d %8d %8d %8d %8d %8d %8d", i,
- sys_histogram[i][0],
- sys_histogram[i][1],
- sys_histogram[i][2],
- sys_histogram[i][3],
- sys_histogram[i][4],
- sys_histogram[i][5],
- sys_histogram[i][6],
- sys_histogram[i][7]);
- }
- }
- post("dsp %d, pollgui %d, nothing %d",
- sched_diddsp, sched_didpoll, sched_didnothing);
-}
-
-static int sys_histphase;
-
-int sys_addhist(int phase)
-{
-#ifndef FIXEDPOINT
- int i, j, phasewas = sys_histphase;
- t_time newtime = sys_getrealtime();
- int msec = (newtime - sys_histtime) * 1000.;
- for (j = NBIN-1; j >= 0; j--)
- {
- if (msec >= sys_bin[j])
- {
- sys_histogram[phasewas][j]++;
- break;
- }
- }
- sys_histtime = newtime;
- sys_histphase = phase;
- return (phasewas);
-#else
- return 0;
-#endif
-}
-
-#define NRESYNC 20
-
-typedef struct _resync
-{
- int r_ntick;
- int r_error;
-} t_resync;
-
-static int oss_resyncphase = 0;
-static int oss_nresync = 0;
-static t_resync oss_resync[NRESYNC];
-
-
-static char *(oss_errornames[]) = {
-"unknown",
-"ADC blocked",
-"DAC blocked",
-"A/D/A sync",
-"data late"
-};
-
-void glob_audiostatus(void)
-{
- int dev, nresync, nresyncphase, i;
- nresync = (oss_nresync >= NRESYNC ? NRESYNC : oss_nresync);
- nresyncphase = oss_resyncphase - 1;
- post("audio I/O error history:");
- post("seconds ago\terror type");
- for (i = 0; i < nresync; i++)
- {
- int errtype;
- if (nresyncphase < 0)
- nresyncphase += NRESYNC;
- errtype = oss_resync[nresyncphase].r_error;
- if (errtype < 0 || errtype > 4)
- errtype = 0;
-
- post("%9.2f\t%s",
- (sched_diddsp - oss_resync[nresyncphase].r_ntick)
- * ((double)sys_schedblocksize) / sys_dacsr,
- oss_errornames[errtype]);
- nresyncphase--;
- }
-}
-
-static int sched_diored;
-static int sched_dioredtime;
-static int sched_meterson;
-
-void sys_log_error(int type)
-{
- oss_resync[oss_resyncphase].r_ntick = sched_diddsp;
- oss_resync[oss_resyncphase].r_error = type;
- oss_nresync++;
- if (++oss_resyncphase == NRESYNC) oss_resyncphase = 0;
- if (type != ERR_NOTHING && !sched_diored &&
- (sched_diddsp >= sched_dioredtime))
- {
- sys_vgui("pdtk_pd_dio 1\n");
- sched_diored = 1;
- }
- sched_dioredtime =
- sched_diddsp + (int)(sys_dacsr /(double)sys_schedblocksize);
-}
-
-static int sched_lastinclip, sched_lastoutclip,
- sched_lastindb, sched_lastoutdb;
-
-void glob_ping(t_pd *dummy);
-
-static void sched_pollformeters( void)
-{
- int inclip, outclip, indb, outdb;
- static int sched_nextmeterpolltime, sched_nextpingtime;
-
- /* if there's no GUI but we're running in "realtime", here is
- where we arrange to ping the watchdog every 2 seconds. */
-#ifdef __linux__
- if (sys_nogui && sys_hipriority && (sched_diddsp - sched_nextpingtime > 0))
- {
- glob_ping(0);
- /* ping every 2 seconds */
- sched_nextpingtime = sched_diddsp +
- (2* sys_dacsr) /(int)sys_schedblocksize;
- }
-#endif
-
- if (sched_diddsp - sched_nextmeterpolltime < 0)
- return;
- if (sched_diored && (sched_diddsp - sched_dioredtime > 0))
- {
- sys_vgui("pdtk_pd_dio 0\n");
- sched_diored = 0;
- }
- if (sched_meterson)
- {
- float inmax, outmax;
- sys_getmeters(&inmax, &outmax);
- indb = 0.5 + rmstodb(inmax);
- outdb = 0.5 + rmstodb(outmax);
- inclip = (inmax > 0.999);
- outclip = (outmax >= 1.0);
- }
- else
- {
- indb = outdb = 0;
- inclip = outclip = 0;
- }
- if (inclip != sched_lastinclip || outclip != sched_lastoutclip
- || indb != sched_lastindb || outdb != sched_lastoutdb)
- {
- sys_vgui("pdtk_pd_meters %d %d %d %d\n", indb, outdb, inclip, outclip);
- sched_lastinclip = inclip;
- sched_lastoutclip = outclip;
- sched_lastindb = indb;
- sched_lastoutdb = outdb;
- }
- sched_nextmeterpolltime =
- sched_diddsp + (int)(sys_dacsr /(double)sys_schedblocksize);
-}
-
-void glob_meters(void *dummy, float f)
-{
- if (f == 0)
- sys_getmeters(0, 0);
- sched_meterson = (f != 0);
- sched_lastinclip = sched_lastoutclip = sched_lastindb = sched_lastoutdb =
- -1;
-}
-
-#if 0
-void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- if (argc) sys_clearhist();
- else sys_printhist();
-}
-#endif
-
-void dsp_tick(void);
-
-static int sched_usedacs = 1;
-static t_time sched_referencerealtime, sched_referencelogicaltime;
-static t_time sys_time_per_dsp_tick;
-
-void sched_set_using_dacs(int flag)
-{
- sched_usedacs = flag;
- if (!flag)
- {
- sched_referencerealtime = sys_getrealtime();
- sched_referencelogicaltime = clock_getlogicaltime();
- post("schedsetuding");
- }
- sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
- ((double)sys_schedblocksize) / sys_dacsr;
-}
-
- /* take the scheduler forward one DSP tick, also handling clock timeouts */
-static void sched_tick(t_time next_sys_time)
-{
- int countdown = 5000;
- while (clock_setlist && clock_setlist->c_settime < next_sys_time)
- {
- t_clock *c = clock_setlist;
- sys_time = c->c_settime;
- clock_unset(clock_setlist);
- outlet_setstacklim();
- (*c->c_fn)(c->c_owner);
- if (!countdown--)
- {
- countdown = 5000;
- sys_pollgui();
- }
- if (sys_quit)
- return;
- }
- sys_time = next_sys_time;
- dsp_tick();
- sched_diddsp++;
-}
-
-/*
-Here is Pd's "main loop." This routine dispatches clock timeouts and DSP
-"ticks" deterministically, and polls for input from MIDI and the GUI. If
-we're left idle we also poll for graphics updates; but these are considered
-lower priority than the rest.
-
-The time source is normally the audio I/O subsystem via the "sys_send_dacs()"
-call. This call returns true if samples were transferred; false means that
-the audio I/O system is still busy with previous transfers.
-*/
-
-void sys_pollmidiqueue( void);
-void sys_initmidiqueue( void);
-
-int m_scheduler_pda( void)
-{
- int idlecount = 0;
- sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
- ((double)sys_schedblocksize) / sys_dacsr;
-
-
- sys_clearhist();
- if (sys_sleepgrain < 1000)
- sys_sleepgrain = sys_schedadvance/4;
- if (sys_sleepgrain < 100)
- sys_sleepgrain = 100;
- else if (sys_sleepgrain > 5000)
- sys_sleepgrain = 5000;
- sys_initmidiqueue();
- while (!sys_quit)
- {
- int didsomething = 0;
- int timeforward;
-
- sys_addhist(0);
- waitfortick:
- if (sched_usedacs)
- {
- timeforward = sys_send_dacs();
- sys_pollgui();
- }
- else {
- if ((sys_getrealtime() - sched_referencerealtime)
- > (t_time)clock_gettimesince(sched_referencelogicaltime)*1000)
- timeforward = SENDDACS_YES;
- else timeforward = SENDDACS_NO;
- if (timeforward == SENDDACS_YES)
- sys_microsleep(sys_sleepgrain);
- }
- if (timeforward != SENDDACS_NO) {
- sched_tick(sys_time + sys_time_per_dsp_tick);
- }
- }
- return 0;
-}
-
-
-int m_scheduler( void)
-{
- int idlecount = 0;
- sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
- ((double)sys_schedblocksize) / sys_dacsr;
-
-#ifdef THREAD_LOCKING
- /* T.Grill - lock mutex */
- sys_lock();
-#endif
- sys_clearhist();
- if (sys_sleepgrain < 1000)
- sys_sleepgrain = sys_schedadvance/4;
- if (sys_sleepgrain < 100)
- sys_sleepgrain = 100;
- else if (sys_sleepgrain > 5000)
- sys_sleepgrain = 5000;
- sys_initmidiqueue();
- while (!sys_quit)
- {
- int didsomething = 0;
- int timeforward;
-
- sys_addhist(0);
- waitfortick:
- if (sched_usedacs)
- {
- timeforward = sys_send_dacs();
-
- /* if dacs remain "idle" for 1 sec, they're hung up. */
- if (timeforward != 0)
- idlecount = 0;
- else
- {
- idlecount++;
- if (!(idlecount & 31))
- {
- static t_time idletime;
- /* on 32nd idle, start a clock watch; every
- 32 ensuing idles, check it */
- if (idlecount == 32)
- idletime = sys_getrealtime();
- else if (sys_getrealtime() - idletime > 1.)
- {
- post("audio I/O stuck... closing audio\n");
- sys_close_audio();
- sched_set_using_dacs(0);
- goto waitfortick;
- }
- }
- }
- }
- else
- {
- if (1000. * (sys_getrealtime() - sched_referencerealtime)
- > clock_gettimesince(sched_referencelogicaltime))
- timeforward = SENDDACS_YES;
- else timeforward = SENDDACS_NO;
- }
- sys_setmiditimediff(0, 1e-6 * sys_schedadvance);
- sys_addhist(1);
- if (timeforward != SENDDACS_NO)
- sched_tick(sys_time + sys_time_per_dsp_tick);
- if (timeforward == SENDDACS_YES)
- didsomething = 1;
-
- sys_addhist(2);
- // sys_pollmidiqueue();
- if (sys_pollgui())
- {
- if (!didsomething)
- sched_didpoll++;
- didsomething = 1;
- }
- sys_addhist(3);
- /* test for idle; if so, do graphics updates. */
- if (!didsomething)
- {
- sched_pollformeters();
- sys_reportidle();
-
-#ifdef THREAD_LOCKING
- /* T.Grill - enter idle phase -> unlock thread lock */
- sys_unlock();
-#endif
- if (timeforward != SENDDACS_SLEPT)
- sys_microsleep(sys_sleepgrain);
-#ifdef THREAD_LOCKING
- /* T.Grill - leave idle phase -> lock thread lock */
- sys_lock();
-#endif
-
- sys_addhist(5);
- sched_didnothing++;
-
- }
- }
-
-#ifdef THREAD_LOCKING
- /* T.Grill - done */
- sys_unlock();
-#endif
-
- return (0);
-}
-
-
-/* ------------ thread locking ------------------- */
-/* added by Thomas Grill */
-
-#ifdef THREAD_LOCKING
-static pthread_mutex_t sys_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-void sys_lock(void)
-{
- pthread_mutex_lock(&sys_mutex);
-}
-
-void sys_unlock(void)
-{
- pthread_mutex_unlock(&sys_mutex);
-}
-
-int sys_trylock(void)
-{
- return pthread_mutex_trylock(&sys_mutex);
-}
-
-#else
-
-void sys_lock(void) {}
-void sys_unlock(void) {}
-int sys_trylock(void) {}
-
-#endif
-
-
-/* ------------ soft quit ------------------- */
-/* added by Thomas Grill -
- just set the quit flag for the scheduler loop
- this is useful for applications using the PD shared library to signal the scheduler to terminate
-*/
-
-void sys_exit(void)
-{
- sys_quit = 1;
-}
diff --git a/apps/plugins/pdbox/PDa/src/makecostab.c b/apps/plugins/pdbox/PDa/src/makecostab.c
index 9227ace16a..6b436b6e57 100644
--- a/apps/plugins/pdbox/PDa/src/makecostab.c
+++ b/apps/plugins/pdbox/PDa/src/makecostab.c
@@ -22,29 +22,3 @@ int main(int argc,char** argv)
}
-
-#include "m_fixed.h"
-#include <math.h>
-
-#define ILOGCOSTABSIZE 15
-#define ICOSTABSIZE (1<<ILOGCOSTABSIZE)
-
-int main(int argc,char** argv)
-{
- int i;
- int *fp;
- double phase, phsinc = (2. * M_PI) / ICOSTABSIZE;
-
- printf("#define ILOGCOSTABSIZE 15\n");
- printf("#define ICOSTABSIZE (1<<ILOGCOSTABSIZE)\n");
- printf("static t_sample cos_table[] = {");
- for (i = ICOSTABSIZE + 1,phase = 0; i--; phase += phsinc) {
- printf("%d,",ftofix(cos(phase)));
- // post("costab %f %f",cos(phase),fixtof(*fp));
-
- }
- printf("0};\n");
-
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/src/makefile b/apps/plugins/pdbox/PDa/src/makefile
index 6a28a95f34..3f074c4a74 100644
--- a/apps/plugins/pdbox/PDa/src/makefile
+++ b/apps/plugins/pdbox/PDa/src/makefile
@@ -174,181 +174,3 @@ clean:
-rm -f *~
-rm -f $(BIN_DIR)/pdsend $(BIN_DIR)/pdreceive
-
-PREFIX = /usr/
-EXT = pd_linux
-
-# pd specific
-
-VPATH = ../obj:./
-OBJ_DIR = ../obj
-BIN_DIR = ../bin
-
-BROOT=/usr
-X11LIB = $(BROOT)/X11R6/lib
-
-DEFINES = -DPD -DUNIX
-
-pd-gui_INCLUDES = -I$(BROOT)/include/tcl8.4 -I$(BROOT)/X11R6/include
-pd-gui_LIBS = -ltk8.4 -ltcl8.4 -lX11 -ldl
-pd-gui_LDFLAGS = -L$(X11LIB)
-pd-gui_DEFINES = $(DEFINES)
-
-pd_LIBS = -lm -lpthread -ldl
-pd_LDFLAGS = -Wl,-export-dynamic
-pd_DEFINES = $(DEFINES) -DINSTALL_PREFIX=\"$(PREFIX)\" \
- -DFIXEDPOINT -DUSEAPI_OSS -DDL_OPEN
-
-extra_DEFINES = $(DEFINES) -DFIXEDPOINT
-extra_INCLUDES = -I../src
-extra_LDFLAGS = -shared
-
-# IPOD toolchain
-
-ifeq ($(CC), arm-elf-gcc)
-pd_LDFLAGS += -elf2flt
-pd_LIBS = -lm -lpthread
-pd_DEFINES = $(DEFINES) -DINSTALL_PREFIX=\"$(PREFIX)\" \
- -DFIXEDPOINT -DUSEAPI_OSS -D__linux__ -Dfork=getpid
-extra_DEFINES += -D__linux__ -Dfork=getpid
-endif
-
-# BLACKFIN toolchain
-
-ifeq ($(CC), bfin-uclinux-gcc)
-pd_LIBS = -lm -lpthread
-pd_DEFINES = $(DEFINES) -DINSTALL_PREFIX=\"$(PREFIX)\" \
- -DFIXEDPOINT -DUSEAPI_OSS -D__linux__
-extra_DEFINES += -D__linux__
-endif
-
-# the sources
-
-pd_SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \
- g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \
- g_all_guis.c g_bang.c g_hdial.c g_hslider.c g_mycanvas.c g_numbox.c \
- g_toggle.c g_vdial.c g_vslider.c g_vumeter.c \
- m_pd.c m_class.c m_obj.c m_atom.c m_memory.c m_binbuf.c \
- m_conf.c m_glob.c m_sched.c \
- s_main.c s_inter.c s_file.c s_print.c \
- s_loader.c s_path.c s_entry.c s_audio.c s_midi.c \
- d_ugen.c d_arithmetic.c d_dac.c d_misc.c \
- d_fft.c d_mayer_fft.c d_fftroutine.c d_global.c \
- d_resample.c d_ctl.c d_soundfile.c \
- x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
- x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c \
- s_midi_oss.c s_audio_oss.c
-
-pd_SRC += d_imayer_fft.c m_fixed.c
-
-pd_OBJ = $(pd_SRC:.c=.o)
-
-pd-gui_SRC = t_main.c t_tkcmd.c
-pd-gui_OBJ = $(pd-gui_SRC:.c=.o)
-
-extra_SRC = $(shell ls ../intern/*.c) $(shell ls ../extra/*.c)
-extra_OBJ = $(extra_SRC:.c=.o)
-extra_EXT = $(extra_SRC:.c=.pd_linux)
-
-#
-# ------------------ targets ------------------------------------
-#
-
-all: $(BIN_DIR)/pd \
- $(BIN_DIR)/pd-gui \
- $(BIN_DIR)/pd-watchdog \
- $(BIN_DIR)/pdsend \
- $(BIN_DIR)/pdreceive \
- $(BIN_DIR)/pd.tk \
- extra
-
-pd: $(BIN_DIR)/pd
-pd-gui: $(BIN_DIR)/pd-gui
-pd-watchdog: $(BIN_DIR)/pd-watchdog
-
-static:
- make pd_SRC="$(pd_SRC) $(extra_SRC)" DEFINES="-DPD -DUNIX -DSTATIC" \
- pd pd-gui pd-watchdog $(BIN_DIR)/pdsend \
- $(BIN_DIR)/pdreceive $(BIN_DIR)/pd.tk
-
-extra: $(extra_EXT)
-
-ipod:
- make CC=arm-elf-gcc static
-
-blackfin:
- make CC=bfin-uclinux-gcc static
-
-$(pd_OBJ) : %.o : %.c
- $(CC) $(CFLAGS) $(pd_DEFINES) $(pd_INCLUDES) -c -o $(OBJ_DIR)/$@ $+
-
-$(pd-gui_OBJ) : %.o : %.c
- $(CC) $(CFLAGS) $(pd-gui_DEFINES) $(pd-gui_INCLUDES) -c -o $(OBJ_DIR)/$@ $+
-
-$(extra_OBJ) : %.o : %.c
- $(CC) $(CFLAGS) $(extra_DEFINES) $(extra_INCLUDES) -c -o $@ $*.c
-
-$(extra_EXT) : %.$(EXT) : %.o
- $(CC) -o $@ $(extra_LDFLAGS) $+
-
-$(BIN_DIR)/pd-watchdog: s_watchdog.c
- $(CC) $(CFLAGS) $(DEFINES) -o $@ s_watchdog.c
-
-$(BIN_DIR)/pdsend: u_pdsend.c
- $(CC) $(CFLAGS) $(DEFINES) -o $@ u_pdsend.c
-
-$(BIN_DIR)/pdreceive: u_pdreceive.c
- $(CC) $(CFLAGS) $(DEFINES) -o $@ u_pdreceive.c
-
-$(BIN_DIR)/pd: $(pd_OBJ)
- cd ../obj; $(CC) $(pd_LDFLAGS) -o $@ $(pd_OBJ) $(pd_LIBS)
-
-$(BIN_DIR)/pd-gui: $(pd-gui_OBJ)
- cd ../obj; $(CC) -o $@ $(pd-gui_OBJ) $(pd-gui_LDFLAGS) $(pd-gui_LIBS)
-
-$(BIN_DIR)/pd.tk: u_main.tk
- echo set pd_nt 0 > $(BIN_DIR)/pd.tk
- grep -v "set pd_nt" < u_main.tk >> $@
-
-INSTDIR = $(DESTDIR)/$(PREFIX)
-
-install: all
-# Create the directory structure
-
- install -d $(INSTDIR)/lib/pd/bin
- install -d $(INSTDIR)/lib/pd/extra
- install -d $(INSTDIR)/lib/pd/intern
- install -d $(INSTDIR)/lib/pd/doc
- install -d $(INSTDIR)/bin
- install -d $(INSTDIR)/include
-
- install $(BIN_DIR)/pd-gui $(INSTDIR)/lib/pd/bin/
- install $(BIN_DIR)/pd-watchdog $(INSTDIR)/lib/pd/bin/
- install -m 644 $(BIN_DIR)/pd.tk $(INSTDIR)/lib/pd/bin/
- install -m 755 $(BIN_DIR)/pd $(INSTDIR)/bin/
- install -m 755 $(BIN_DIR)/pdsend $(INSTDIR)/bin/pdsend
- install -m 755 $(BIN_DIR)/pdreceive $(INSTDIR)/bin/pdreceive
- cp -r ../doc/7.stuff $(INSTDIR)/lib/pd/doc
- cp -r ../doc/5.reference $(INSTDIR)/lib/pd/doc
- install -m 644 m_pd.h $(INSTDIR)/include/m_pd.h
-
-# Install the externals if possible
- cp ../extra/*.pd_linux $(INSTDIR)/lib/pd/extra
- cp ../intern/*.pd_linux $(INSTDIR)/lib/pd/intern
-
-# Install the ICON and desktop file
- install -d $(INSTDIR)/share/pixmaps
- install -d $(INSTDIR)/share/applications
- cp ../ipkg/pd-icon.png $(INSTDIR)/share/pixmaps
- cp ../ipkg/pd.desktop $(INSTDIR)/share/applications/
-
-
-
-clean:
- -rm -f `find ../extra/ -name "*.pd_*"`
- -rm -f tags
- -rm -f ../obj/* $(BIN_DIR)/* ../extra/*.{o,$(EXT)} ../intern/*.{o,$(EXT)}
- -rm -f *~
- -rm -f $(BIN_DIR)/pdsend $(BIN_DIR)/pdreceive
-
-
diff --git a/apps/plugins/pdbox/PDa/src/s_audio.c b/apps/plugins/pdbox/PDa/src/s_audio.c
index 4cb93307b0..5f27d98671 100644
--- a/apps/plugins/pdbox/PDa/src/s_audio.c
+++ b/apps/plugins/pdbox/PDa/src/s_audio.c
@@ -871,876 +871,4 @@ void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
}
#endif
}
-/* Copyright (c) 2003, Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* machine-independent (well, mostly!) audio layer. Stores and recalls
- audio settings from argparse routine and from dialog window.
-*/
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <stdio.h>
-#ifdef UNIX
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#define SYS_DEFAULTCH 2
-#define SYS_MAXCH 100
-#define SYS_DEFAULTSRATE 44100
-typedef long t_pa_sample;
-#define SYS_SAMPLEWIDTH sizeof(t_pa_sample)
-#define SYS_BYTESPERCHAN (DEFDACBLKSIZE * SYS_SAMPLEWIDTH)
-#define SYS_XFERSAMPS (SYS_DEFAULTCH*DEFDACBLKSIZE)
-#define SYS_XFERSIZE (SYS_SAMPLEWIDTH * SYS_XFERSAMPS)
-
- /* these are set in this file when opening audio, but then may be reduced,
- even to zero, in the system dependent open_audio routines. */
-int sys_inchannels;
-int sys_outchannels;
-int sys_advance_samples; /* scheduler advance in samples */
-int sys_blocksize = 0; /* audio I/O block size in sample frames */
-int sys_audioapi = API_DEFAULT;
-
-static int sys_meters; /* true if we're metering */
-static float sys_inmax; /* max input amplitude */
-static float sys_outmax; /* max output amplitude */
-
- /* exported variables */
-int sys_schedadvance; /* scheduler advance in microseconds */
-float sys_dacsr;
-
-#ifdef MACOSX
-int sys_hipriority = 1;
-#else
-int sys_hipriority = 0;
-#endif
-
-t_sample *sys_soundout;
-t_sample *sys_soundin;
-
- /* the "state" is normally one if we're open and zero otherwise;
- but if the state is one, we still haven't necessarily opened the
- audio hardware; see audio_isopen() below. */
-static int audio_state;
-
- /* last requested parameters */
-static int audio_naudioindev;
-static int audio_audioindev[MAXAUDIOINDEV];
-static int audio_audiochindev[MAXAUDIOINDEV];
-static int audio_naudiooutdev;
-static int audio_audiooutdev[MAXAUDIOOUTDEV];
-static int audio_audiochoutdev[MAXAUDIOOUTDEV];
-static int audio_rate;
-static int audio_advance;
-
-static int audio_isopen(void)
-{
- return (audio_state &&
- ((audio_naudioindev > 0 && audio_audiochindev[0] > 0)
- || (audio_naudiooutdev > 0 && audio_audiochoutdev[0] > 0)));
-}
-
-static void sys_get_audio_params(
- int *pnaudioindev, int *paudioindev, int *chindev,
- int *pnaudiooutdev, int *paudiooutdev, int *choutdev,
- int *prate, int *padvance)
-{
- int i;
- *pnaudioindev = audio_naudioindev;
- for (i = 0; i < MAXAUDIOINDEV; i++)
- paudioindev[i] = audio_audioindev[i],
- chindev[i] = audio_audiochindev[i];
- *pnaudiooutdev = audio_naudiooutdev;
- for (i = 0; i < MAXAUDIOOUTDEV; i++)
- paudiooutdev[i] = audio_audiooutdev[i],
- choutdev[i] = audio_audiochoutdev[i];
- *prate = audio_rate;
- *padvance = audio_advance;
-}
-
-static void sys_save_audio_params(
- int naudioindev, int *audioindev, int *chindev,
- int naudiooutdev, int *audiooutdev, int *choutdev,
- int rate, int advance)
-{
- int i;
- audio_naudioindev = naudioindev;
- for (i = 0; i < MAXAUDIOINDEV; i++)
- audio_audioindev[i] = audioindev[i],
- audio_audiochindev[i] = chindev[i];
- audio_naudiooutdev = naudiooutdev;
- for (i = 0; i < MAXAUDIOOUTDEV; i++)
- audio_audiooutdev[i] = audiooutdev[i],
- audio_audiochoutdev[i] = choutdev[i];
- audio_rate = rate;
- audio_advance = advance;
-}
-
- /* init routines for any API which needs to set stuff up before
- any other API gets used. This is only true of OSS so far. */
-#ifdef USEAPI_OSS
-void oss_init(void);
-#endif
-
-static void audio_init( void)
-{
- static int initted = 0;
- if (initted)
- return;
- initted = 1;
-#ifdef USEAPI_OSS
- oss_init();
-#endif
-}
-
- /* set channels and sample rate. */
-
-static void sys_setchsr(int chin, int chout, int sr)
-{
- int nblk;
- int inbytes = (chin ? chin : 2) * (DEFDACBLKSIZE*sizeof(float));
- int outbytes = (chout ? chout : 2) * (DEFDACBLKSIZE*sizeof(float));
-
- sys_inchannels = chin;
- sys_outchannels = chout;
- sys_dacsr = sr;
- sys_advance_samples = (sys_schedadvance * sys_dacsr) / (1000000.);
- if (sys_advance_samples < 3 * DEFDACBLKSIZE)
- sys_advance_samples = 3 * DEFDACBLKSIZE;
-
- if (sys_soundin)
- free(sys_soundin);
- sys_soundin = (t_float *)malloc(inbytes);
- memset(sys_soundin, 0, inbytes);
-
- if (sys_soundout)
- free(sys_soundout);
- sys_soundout = (t_float *)malloc(outbytes);
- memset(sys_soundout, 0, outbytes);
-
- if (sys_verbose)
- post("input channels = %d, output channels = %d",
- sys_inchannels, sys_outchannels);
- canvas_resume_dsp(canvas_suspend_dsp());
-}
-
-/* ----------------------- public routines ----------------------- */
-
- /* open audio devices (after cleaning up the specified device and channel
- vectors). The audio devices are "zero based" (i.e. "0" means the first
- one.) We also save the cleaned-up device specification so that we
- can later re-open audio and/or show the settings on a dialog window. */
-
-void sys_open_audio(int naudioindev, int *audioindev, int nchindev,
- int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
- int *choutdev, int rate, int advance, int enable)
-{
- int i, *ip;
- int defaultchannels = SYS_DEFAULTCH;
- int inchans, outchans;
- if (rate < 1)
- rate = SYS_DEFAULTSRATE;
- audio_init();
- /* Since the channel vector might be longer than the
- audio device vector, or vice versa, we fill the shorter one
- in to match the longer one. Also, if both are empty, we fill in
- one device (the default) and two channels. */
- if (naudioindev == -1)
- { /* no input audio devices specified */
- if (nchindev == -1)
- {
- nchindev=1;
- chindev[0] = defaultchannels;
- naudioindev = 1;
- audioindev[0] = DEFAULTAUDIODEV;
- }
- else
- {
- for (i = 0; i < MAXAUDIOINDEV; i++)
- audioindev[i] = i;
- naudioindev = nchindev;
- }
- }
- else
- {
- if (nchindev == -1)
- {
- nchindev = naudioindev;
- for (i = 0; i < naudioindev; i++)
- chindev[i] = defaultchannels;
- }
- else if (nchindev > naudioindev)
- {
- for (i = naudioindev; i < nchindev; i++)
- {
- if (i == 0)
- audioindev[0] = DEFAULTAUDIODEV;
- else audioindev[i] = audioindev[i-1] + 1;
- }
- naudioindev = nchindev;
- }
- else if (nchindev < naudioindev)
- {
- for (i = nchindev; i < naudioindev; i++)
- {
- if (i == 0)
- chindev[0] = defaultchannels;
- else chindev[i] = chindev[i-1];
- }
- naudioindev = nchindev;
- }
- }
-
- if (naudiooutdev == -1)
- { /* not set */
- if (nchoutdev == -1)
- {
- nchoutdev=1;
- choutdev[0]=defaultchannels;
- naudiooutdev=1;
- audiooutdev[0] = DEFAULTAUDIODEV;
- }
- else
- {
- for (i = 0; i < MAXAUDIOOUTDEV; i++)
- audiooutdev[i] = i;
- naudiooutdev = nchoutdev;
- }
- }
- else
- {
- if (nchoutdev == -1)
- {
- nchoutdev = naudiooutdev;
- for (i = 0; i < naudiooutdev; i++)
- choutdev[i] = defaultchannels;
- }
- else if (nchoutdev > naudiooutdev)
- {
- for (i = naudiooutdev; i < nchoutdev; i++)
- {
- if (i == 0)
- audiooutdev[0] = DEFAULTAUDIODEV;
- else audiooutdev[i] = audiooutdev[i-1] + 1;
- }
- naudiooutdev = nchoutdev;
- }
- else if (nchoutdev < naudiooutdev)
- {
- for (i = nchoutdev; i < naudiooutdev; i++)
- {
- if (i == 0)
- choutdev[0] = defaultchannels;
- else choutdev[i] = choutdev[i-1];
- }
- naudiooutdev = nchoutdev;
- }
- }
-
- /* count total number of input and output channels */
- for (i = inchans = 0; i < naudioindev; i++)
- inchans += chindev[i];
- for (i = outchans = 0; i < naudiooutdev; i++)
- outchans += choutdev[i];
- /* if no input or output devices seem to have been specified,
- this really means just disable audio, which we now do. Meanwhile,
- we can set audio input and output devices to their defaults. */
- if (!inchans && !outchans)
- {
- enable = 0;
- naudioindev = nchindev = naudiooutdev = nchoutdev = 1;
- audioindev[0] = audiooutdev[0] = DEFAULTAUDIODEV;
- chindev[0] = choutdev[0] = 0;
- }
- sys_schedadvance = advance * 1000;
- sys_setchsr(inchans, outchans, rate);
- sys_log_error(ERR_NOTHING);
-
- if (enable && (inchans > 0 || outchans > 0))
- {
-#ifdef USEAPI_PORTAUDIO
- if (sys_audioapi == API_PORTAUDIO)
- {
- int blksize = (sys_blocksize ? sys_blocksize : 64);
- pa_open_audio(inchans, outchans, rate, sys_soundin, sys_soundout,
- blksize, sys_advance_samples/blksize,
- (naudiooutdev > 0 ? audioindev[0] : 0),
- (naudiooutdev > 0 ? audiooutdev[0] : 0));
- }
-else
-#endif
-#ifdef USEAPI_JACK
- if (sys_audioapi == API_JACK)
- jack_open_audio((naudioindev > 0 ? chindev[0] : 0),
- (naudiooutdev > 0 ? choutdev[0] : 0), rate);
-
- else
-#endif
-#ifdef USEAPI_OSS
- if (sys_audioapi == API_OSS)
- oss_open_audio(naudioindev, audioindev, nchindev, chindev,
- naudiooutdev, audiooutdev, nchoutdev, choutdev, rate);
- else
-#endif
-#ifdef USEAPI_ALSA
- /* for alsa, only one device is supported; it may
- be open for both input and output. */
- if (sys_audioapi == API_ALSA)
- alsa_open_audio(naudioindev, audioindev, nchindev, chindev,
- naudiooutdev, audiooutdev, nchoutdev, choutdev, rate);
- else
-#endif
-#ifdef USEAPI_MMIO
- if (sys_audioapi == API_MMIO)
- mmio_open_audio(naudioindev, audioindev, nchindev, chindev,
- naudiooutdev, audiooutdev, nchoutdev, choutdev, rate);
- else
-#endif
- post("unknown audio API specified");
- }
- sys_save_audio_params(naudioindev, audioindev, chindev,
- naudiooutdev, audiooutdev, choutdev, rate, advance);
- if (sys_inchannels == 0 && sys_outchannels == 0)
- enable = 0;
- audio_state = enable;
- sys_vgui("set pd_whichapi %d\n", (audio_isopen() ? sys_audioapi : 0));
- sched_set_using_dacs(enable);
-}
-
-void sys_close_audio(void)
-{
- if (!audio_isopen())
- return;
-#ifdef USEAPI_PORTAUDIO
- if (sys_audioapi == API_PORTAUDIO)
- pa_close_audio();
- else
-#endif
-#ifdef USEAPI_JACK
- if (sys_audioapi == API_JACK)
- jack_close_audio();
- else
-#endif
-#ifdef USEAPI_OSS
- if (sys_audioapi == API_OSS)
- oss_close_audio();
- else
-#endif
-#ifdef USEAPI_ALSA
- if (sys_audioapi == API_ALSA)
- alsa_close_audio();
- else
-#endif
-#ifdef USEAPI_MMIO
- if (sys_audioapi == API_MMIO)
- mmio_close_audio();
- else
-#endif
- post("sys_close_audio: unknown API %d", sys_audioapi);
- sys_inchannels = sys_outchannels = 0;
-}
-
- /* open audio using whatever parameters were last used */
-void sys_reopen_audio( void)
-{
- int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
- int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
- int rate, advance;
- sys_get_audio_params(&naudioindev, audioindev, chindev,
- &naudiooutdev, audiooutdev, choutdev, &rate, &advance);
- sys_open_audio(naudioindev, audioindev, naudioindev, chindev,
- naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, advance, 1);
-}
-
-int sys_send_dacs(void)
-{
- if (sys_meters)
- {
- int i, n;
- float maxsamp;
- for (i = 0, n = sys_inchannels * DEFDACBLKSIZE, maxsamp = sys_inmax;
- i < n; i++)
- {
- float f = sys_soundin[i];
- if (f > maxsamp) maxsamp = f;
- else if (-f > maxsamp) maxsamp = -f;
- }
- sys_inmax = maxsamp;
- for (i = 0, n = sys_outchannels * DEFDACBLKSIZE, maxsamp = sys_outmax;
- i < n; i++)
- {
- float f = sys_soundout[i];
- if (f > maxsamp) maxsamp = f;
- else if (-f > maxsamp) maxsamp = -f;
- }
- sys_outmax = maxsamp;
- }
-
-#ifdef USEAPI_PORTAUDIO
- if (sys_audioapi == API_PORTAUDIO)
- return (pa_send_dacs());
- else
-#endif
-#ifdef USEAPI_JACK
- if (sys_audioapi == API_JACK)
- return (jack_send_dacs());
- else
-#endif
-#ifdef USEAPI_OSS
- if (sys_audioapi == API_OSS)
- return (oss_send_dacs());
- else
-#endif
-#ifdef USEAPI_ALSA
- if (sys_audioapi == API_ALSA)
- return (alsa_send_dacs());
- else
-#endif
-#ifdef USEAPI_MMIO
- if (sys_audioapi == API_MMIO)
- return (mmio_send_dacs());
- else
-#endif
- post("unknown API");
- return (0);
-}
-
-float sys_getsr(void)
-{
- return (sys_dacsr);
-}
-
-int sys_get_outchannels(void)
-{
- return (sys_outchannels);
-}
-
-int sys_get_inchannels(void)
-{
- return (sys_inchannels);
-}
-
-void sys_audiobuf(int n)
-{
- /* set the size, in milliseconds, of the audio FIFO */
- if (n < 5) n = 5;
- else if (n > 5000) n = 5000;
- sys_schedadvance = n * 1000;
-}
-
-void sys_getmeters(float *inmax, float *outmax)
-{
- if (inmax)
- {
- sys_meters = 1;
- *inmax = sys_inmax;
- *outmax = sys_outmax;
- }
- else
- sys_meters = 0;
- sys_inmax = sys_outmax = 0;
-}
-
-void sys_reportidle(void)
-{
-}
-
-#define MAXNDEV 20
-#define DEVDESCSIZE 80
-
-static void audio_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize)
-{
- audio_init();
-#ifdef USEAPI_OSS
- if (sys_audioapi == API_OSS)
- {
- oss_getdevs(indevlist, nindevs, outdevlist, noutdevs, canmulti,
- maxndev, devdescsize);
- }
- else
-#endif
-#ifdef USEAPI_ALSA
- if (sys_audioapi == API_ALSA)
- {
- alsa_getdevs(indevlist, nindevs, outdevlist, noutdevs, canmulti,
- maxndev, devdescsize);
- }
- else
-#endif
-#ifdef USEAPI_PORTAUDIO
- if (sys_audioapi == API_PORTAUDIO)
- {
- pa_getdevs(indevlist, nindevs, outdevlist, noutdevs, canmulti,
- maxndev, devdescsize);
- }
- else
-#endif
-#ifdef USEAPI_MMIO
- if (sys_audioapi == API_MMIO)
- {
- mmio_getdevs(indevlist, nindevs, outdevlist, noutdevs, canmulti,
- maxndev, devdescsize);
- }
- else
-#endif
- {
- /* this shouldn't happen once all the above get filled in. */
- int i;
- *nindevs = *noutdevs = 3;
- for (i = 0; i < 3; i++)
- {
- sprintf(indevlist + i * devdescsize, "input device #%d", i+1);
- sprintf(outdevlist + i * devdescsize, "output device #%d", i+1);
- }
- *canmulti = 0;
- }
-}
-
-#ifdef MSW
-#define DEVONSET 0 /* microsoft device list starts at 0 (the "mapper"). */
-#else /* (see also MSW ifdef in sys_parsedevlist(), s_main.c) */
-#define DEVONSET 1 /* To agree with command line flags, normally start at 1 */
-#endif
-
-static void sys_listaudiodevs(void )
-{
- char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
- int nindevs = 0, noutdevs = 0, i, canmulti = 0;
-
- audio_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, &canmulti,
- MAXNDEV, DEVDESCSIZE);
-
- if (!nindevs)
- post("no audio input devices found");
- else
- {
- post("input devices:");
- for (i = 0; i < nindevs; i++)
- post("%d. %s", i+1, indevlist + i * DEVDESCSIZE);
- }
- if (!noutdevs)
- post("no audio output devices found");
- else
- {
- post("output devices:");
- for (i = 0; i < noutdevs; i++)
- post("%d. %s", i + DEVONSET, outdevlist + i * DEVDESCSIZE);
- }
- post("API number %d\n", sys_audioapi);
-}
-
- /* start an audio settings dialog window */
-void glob_audio_properties(t_pd *dummy, t_floatarg flongform)
-{
- char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)];
- /* these are the devices you're using: */
- int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
- int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
- int audioindev1, audioindev2, audioindev3, audioindev4,
- audioinchan1, audioinchan2, audioinchan3, audioinchan4,
- audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
- audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4;
- int rate, advance;
- /* these are all the devices on your system: */
- char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
- int nindevs = 0, noutdevs = 0, canmulti = 0, i;
-
- char indevliststring[MAXNDEV*(DEVDESCSIZE+4)+80],
- outdevliststring[MAXNDEV*(DEVDESCSIZE+4)+80];
-
- audio_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, &canmulti,
- MAXNDEV, DEVDESCSIZE);
-
- strcpy(indevliststring, "{");
- for (i = 0; i < nindevs; i++)
- {
- strcat(indevliststring, "\"");
- strcat(indevliststring, indevlist + i * DEVDESCSIZE);
- strcat(indevliststring, "\" ");
- }
- strcat(indevliststring, "}");
-
- strcpy(outdevliststring, "{");
- for (i = 0; i < noutdevs; i++)
- {
- strcat(outdevliststring, "\"");
- strcat(outdevliststring, outdevlist + i * DEVDESCSIZE);
- strcat(outdevliststring, "\" ");
- }
- strcat(outdevliststring, "}");
-
- sys_get_audio_params(&naudioindev, audioindev, chindev,
- &naudiooutdev, audiooutdev, choutdev, &rate, &advance);
-
- /* post("naudioindev %d naudiooutdev %d longform %f",
- naudioindev, naudiooutdev, flongform); */
- if (naudioindev > 1 || naudiooutdev > 1)
- flongform = 1;
-
-
- audioindev1 = (naudioindev > 0 && audioindev[0]>= 0 ? audioindev[0] : 0);
- audioindev2 = (naudioindev > 1 && audioindev[1]>= 0 ? audioindev[1] : 0);
- audioindev3 = (naudioindev > 2 && audioindev[2]>= 0 ? audioindev[2] : 0);
- audioindev4 = (naudioindev > 3 && audioindev[3]>= 0 ? audioindev[3] : 0);
- audioinchan1 = (naudioindev > 0 ? chindev[0] : 0);
- audioinchan2 = (naudioindev > 1 ? chindev[1] : 0);
- audioinchan3 = (naudioindev > 2 ? chindev[2] : 0);
- audioinchan4 = (naudioindev > 3 ? chindev[3] : 0);
- audiooutdev1 = (naudiooutdev > 0 && audiooutdev[0]>=0 ? audiooutdev[0] : 0);
- audiooutdev2 = (naudiooutdev > 1 && audiooutdev[1]>=0 ? audiooutdev[1] : 0);
- audiooutdev3 = (naudiooutdev > 2 && audiooutdev[2]>=0 ? audiooutdev[2] : 0);
- audiooutdev4 = (naudiooutdev > 3 && audiooutdev[3]>=0 ? audiooutdev[3] : 0);
- audiooutchan1 = (naudiooutdev > 0 ? choutdev[0] : 0);
- audiooutchan2 = (naudiooutdev > 1 ? choutdev[1] : 0);
- audiooutchan3 = (naudiooutdev > 2 ? choutdev[2] : 0);
- audiooutchan4 = (naudiooutdev > 3 ? choutdev[3] : 0);
- sprintf(buf,
-"pdtk_audio_dialog %%s \
-%s %d %d %d %d %d %d %d %d \
-%s %d %d %d %d %d %d %d %d \
-%d %d %d %d\n",
- indevliststring,
- audioindev1, audioindev2, audioindev3, audioindev4,
- audioinchan1, audioinchan2, audioinchan3, audioinchan4,
- outdevliststring,
- audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
- audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4,
- rate, advance, canmulti, (flongform != 0));
- gfxstub_deleteforkey(0);
- gfxstub_new(&glob_pdobject, glob_audio_properties, buf);
-}
-
- /* new values from dialog window */
-void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
- int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
- int rate, advance, audioon, i, nindev, noutdev;
- int audioindev1, audioinchan1, audiooutdev1, audiooutchan1;
- int newaudioindev[4], newaudioinchan[4],
- newaudiooutdev[4], newaudiooutchan[4];
- /* the new values the dialog came back with: */
- int newrate = atom_getintarg(16, argc, argv);
- int newadvance = atom_getintarg(17, argc, argv);
- int statewas;
-
- for (i = 0; i < 4; i++)
- {
- newaudioindev[i] = atom_getintarg(i, argc, argv);
- newaudioinchan[i] = atom_getintarg(i+4, argc, argv);
- newaudiooutdev[i] = atom_getintarg(i+8, argc, argv);
- newaudiooutchan[i] = atom_getintarg(i+12, argc, argv);
- }
-
- for (i = 0, nindev = 0; i < 4; i++)
- {
- if (newaudioinchan[i] > 0)
- {
- newaudioindev[nindev] = newaudioindev[i];
- newaudioinchan[nindev] = newaudioinchan[i];
- /* post("in %d %d %d", nindev,
- newaudioindev[nindev] , newaudioinchan[nindev]); */
- nindev++;
- }
- }
- for (i = 0, noutdev = 0; i < 4; i++)
- {
- if (newaudiooutchan[i] > 0)
- {
- newaudiooutdev[noutdev] = newaudiooutdev[i];
- newaudiooutchan[noutdev] = newaudiooutchan[i];
- /* post("out %d %d %d", noutdev,
- newaudiooutdev[noutdev] , newaudioinchan[noutdev]); */
- noutdev++;
- }
- }
-
- sys_close_audio();
- sys_open_audio(nindev, newaudioindev, nindev, newaudioinchan,
- noutdev, newaudiooutdev, noutdev, newaudiooutchan,
- newrate, newadvance, 1);
-}
-
-void sys_listdevs(void )
-{
-#ifdef USEAPI_PORTAUDIO
- if (sys_audioapi == API_PORTAUDIO)
- sys_listaudiodevs();
- else
-#endif
-#ifdef USEAPI_JACK
- if (sys_audioapi == API_JACK)
- jack_listdevs();
- else
-#endif
-#ifdef USEAPI_OSS
- if (sys_audioapi == API_OSS)
- sys_listaudiodevs();
- else
-#endif
-#ifdef USEAPI_MMIO
- if (sys_audioapi == API_MMIO)
- sys_listaudiodevs();
- else
-#endif
-#ifdef USEAPI_ALSA
- if (sys_audioapi == API_ALSA)
- sys_listaudiodevs();
- else
-#endif
- post("unknown API");
-
- sys_listmididevs();
-}
-
-void sys_setblocksize(int n)
-{
- if (n < 1)
- n = 1;
- if (n != (1 << ilog2(n)))
- post("warning: adjusting blocksize to power of 2: %d",
- (n = (1 << ilog2(n))));
- sys_blocksize = n;
-}
-
-void sys_set_audio_api(int which)
-{
- sys_audioapi = which;
- if (sys_verbose)
- post("sys_audioapi %d", sys_audioapi);
-}
-
-void glob_audio_setapi(void *dummy, t_floatarg f)
-{
- int newapi = f;
- if (newapi)
- {
- if (newapi == sys_audioapi)
- {
- if (!audio_isopen())
- sys_reopen_audio();
- }
- else
- {
- sys_close_audio();
- sys_audioapi = newapi;
- /* bash device params back to default */
- audio_naudioindev = audio_naudiooutdev = 1;
- audio_audioindev[0] = audio_audiooutdev[0] = DEFAULTAUDIODEV;
- audio_audiochindev[0] = audio_audiochoutdev[0] = SYS_DEFAULTCH;
- sys_reopen_audio();
- }
- glob_audio_properties(0, 0);
- }
- else if (audio_isopen())
- {
- sys_close_audio();
- audio_state = 0;
- sched_set_using_dacs(0);
- }
-}
- /* start or stop the audio hardware */
-void sys_set_audio_state(int onoff)
-{
- if (onoff) /* start */
- {
- if (!audio_isopen())
- sys_reopen_audio();
- }
- else
- {
- if (audio_isopen())
- {
- sys_close_audio();
- sched_set_using_dacs(0);
- }
- }
- audio_state = onoff;
-}
-
-void sys_get_audio_apis(char *buf)
-{
- int n = 0;
- strcpy(buf, "{ ");
-#ifdef USEAPI_OSS
- sprintf(buf + strlen(buf), "{OSS %d} ", API_OSS); n++;
-#endif
-#ifdef USEAPI_MMIO
- sprintf(buf + strlen(buf), "{\"standard (MMIO)\" %d} ", API_MMIO); n++;
-#endif
-#ifdef USEAPI_ALSA
- sprintf(buf + strlen(buf), "{ALSA %d} ", API_ALSA); n++;
-#endif
-#ifdef USEAPI_PORTAUDIO
-#ifdef MSW
- sprintf(buf + strlen(buf),
- "{\"ASIO (via portaudio)\" %d} ", API_PORTAUDIO);
-#else
-#ifdef OSX
- sprintf(buf + strlen(buf),
- "{\"standard (portaudio)\" %d} ", API_PORTAUDIO);
-#else
- sprintf(buf + strlen(buf), "{portaudio %d} ", API_PORTAUDIO);
-#endif
-#endif
- n++;
-#endif
-#ifdef USEAPI_JACK
- sprintf(buf + strlen(buf), "{jack %d} ", API_JACK); n++;
-#endif
- strcat(buf, "}");
- /* then again, if only one API (or none) we don't offer any choice. */
- if (n < 2)
- strcpy(buf, "{}");
-
-}
-
-#ifdef USEAPI_ALSA
-void alsa_putzeros(int n);
-void alsa_getzeros(int n);
-void alsa_printstate( void);
-#endif
-
- /* debugging */
-void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol *arg = atom_getsymbolarg(0, argc, argv);
- if (arg == gensym("restart"))
- {
- int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
- int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
- int rate, advance;
- sys_get_audio_params(&naudioindev, audioindev, chindev,
- &naudiooutdev, audiooutdev, choutdev, &rate, &advance);
- sys_close_audio();
- sys_open_audio(naudioindev, audioindev, naudioindev, chindev,
- naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, advance,
- 1);
- }
-#ifdef USEAPI_ALSA
- else if (arg == gensym("alsawrite"))
- {
- int n = atom_getintarg(1, argc, argv);
- alsa_putzeros(n);
- }
- else if (arg == gensym("alsaread"))
- {
- int n = atom_getintarg(1, argc, argv);
- alsa_getzeros(n);
- }
- else if (arg == gensym("print"))
- {
- alsa_printstate();
- }
-#endif
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_audio_alsa.c b/apps/plugins/pdbox/PDa/src/s_audio_alsa.c
index 87d7cb929b..b8e8535dc9 100644
--- a/apps/plugins/pdbox/PDa/src/s_audio_alsa.c
+++ b/apps/plugins/pdbox/PDa/src/s_audio_alsa.c
@@ -943,948 +943,4 @@ void alsa_getdevs(char *indevlist, int *nindevs,
}
*nindevs = *noutdevs = j;
}
-/* Copyright (c) 1997-2003 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. */
-
-/* this file inputs and outputs audio using the ALSA API available on linux. */
-
-#include <alsa/asoundlib.h>
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sched.h>
-#include <sys/mman.h>
-
-typedef int16_t t_alsa_sample16;
-typedef int32_t t_alsa_sample32;
-#define ALSA_SAMPLEWIDTH_16 sizeof(t_alsa_sample16)
-#define ALSA_SAMPLEWIDTH_32 sizeof(t_alsa_sample32)
-#define ALSA_XFERSIZE16 (signed int)(sizeof(t_alsa_sample16) * DEFDACBLKSIZE)
-#define ALSA_XFERSIZE32 (signed int)(sizeof(t_alsa_sample32) * DEFDACBLKSIZE)
-#define ALSA_MAXDEV 1
-#define ALSA_JITTER 1024
-#define ALSA_EXTRABUFFER 2048
-#define ALSA_DEFFRAGSIZE 64
-#define ALSA_DEFNFRAG 12
-
-#ifndef INT32_MAX
-#define INT32_MAX 0x7fffffff
-#endif
-
-#if (SND_LIB_MAJOR < 1)
-#define ALSAAPI9
-#endif
-
-typedef struct _alsa_dev
-{
- snd_pcm_t *inhandle;
- snd_pcm_t *outhandle;
- int innoninterleave; /* true if we're set for noninterleaved read */
- int outnoninterleave; /* same for write */
-} t_alsa_dev;
-
-t_alsa_dev alsa_device;
-static void *alsa_snd_buf = 0;
-static void **alsa_buf_ptrs;
-static int alsa_samplewidth;
-static snd_pcm_status_t* in_status;
-static snd_pcm_status_t* out_status;
-
-static int alsa_mode;
-static int alsa_buf_samps; /* believed actual ALSA bufsize in sample frames */
-static int alsa_inchannels;
-static int alsa_outchannels;
-
-/* Defines */
-#define DEBUG(x) x
-#define DEBUG2(x) {x;}
-
-static void alsa_checkiosync( void);
-static void alsa_numbertoname(int devno, char *devname, int nchar);
-
- /* don't assume we can turn all 31 bits when doing float-to-fix;
- otherwise some audio drivers (e.g. Midiman/ALSA) wrap around. */
-#define FMAX 0x7ffff000
-#define CLIP32(x) (((x)>FMAX)?FMAX:((x) < -FMAX)?-FMAX:(x))
-
-/* support for ALSA pcmv2 api by Karl MacMillan<karlmac@peabody.jhu.edu> */
-
-static void check_error(int err, const char *why)
-{
- if (err < 0)
- fprintf(stderr, "%s: %s\n", why, snd_strerror(err));
-}
-
-/* was: alsa_open_audio(int wantinchans, int wantoutchans, int srate) */
-
-int alsa_open_audio(int naudioindev, int *audioindev, int nchindev,
- int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
- int *choutdev, int rate)
-{
- int err, inchans = 0, outchans = 0, subunitdir;
- char devname[512];
- snd_pcm_hw_params_t* hw_params;
- snd_pcm_sw_params_t* sw_params;
- snd_output_t* out;
- int frag_size = (sys_blocksize ? sys_blocksize : ALSA_DEFFRAGSIZE);
- int nfrags, i;
- short* tmp_buf;
- unsigned int tmp_uint;
- snd_pcm_uframes_t tmp_snd_pcm_uframes;
- int wantinchans, wantoutchans, devno;
-
- if (naudioindev >= 2 || naudiooutdev >= 2)
- post("alsa: only one input and output device allowed (extras ignored");
- if (naudioindev >= 1 && naudiooutdev >= 1 &&
- audioindev[0] != audiooutdev[0])
- post("alsa: changing output device to agree with input device");
- if (nchindev)
- wantinchans = chindev[0];
- else wantinchans = (naudioindev ? 2 : 0);
- if (nchoutdev)
- wantoutchans = choutdev[0];
- else wantoutchans = (naudiooutdev ? 2 : 0);
- devno = (naudioindev > 0 ? audioindev[0] :
- (naudiooutdev > 0 ? audiooutdev[0] : 0));
-
- alsa_numbertoname(devno, devname, 512);
-
- if (sys_verbose)
- post("device name %s; channels in %d, out %d", devname, wantinchans,
- wantoutchans);
-
- nfrags = sys_schedadvance * (float)rate / (1e6 * frag_size);
- /* save our belief as to ALSA's buffer size for later */
- alsa_buf_samps = nfrags * frag_size;
-
- if (sys_verbose)
- post("audio buffer set to %d", (int)(0.001 * sys_schedadvance));
-
- alsa_device.innoninterleave = alsa_device.outnoninterleave = 0;
- if (wantinchans)
- {
- err = snd_pcm_open(&alsa_device.inhandle, devname,
- SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
-
- check_error(err, "snd_pcm_open (input)");
- if (err < 0)
- inchans = 0;
- else
- {
- inchans = wantinchans;
- snd_pcm_nonblock(alsa_device.inhandle, 1);
- }
- }
- if (wantoutchans)
- {
- err = snd_pcm_open(&alsa_device.outhandle, devname,
- SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
-
- check_error(err, "snd_pcm_open (output)");
- if (err < 0)
- outchans = 0;
- else
- {
- outchans = wantoutchans;
- snd_pcm_nonblock(alsa_device.outhandle, 1);
- }
- }
- if (inchans)
- {
- if (sys_verbose)
- post("opening sound input...");
- err = snd_pcm_hw_params_malloc(&hw_params);
- check_error(err, "snd_pcm_hw_params_malloc (input)");
-
- // get the default params
- err = snd_pcm_hw_params_any(alsa_device.inhandle, hw_params);
- check_error(err, "snd_pcm_hw_params_any (input)");
-
- /* try to set interleaved access */
- err = snd_pcm_hw_params_set_access(alsa_device.inhandle,
- hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
- if (err < 0)
- {
- /* OK, so try non-interleaved */
- err = snd_pcm_hw_params_set_access(alsa_device.inhandle,
- hw_params, SND_PCM_ACCESS_RW_NONINTERLEAVED);
- if (err >= 0)
- {
- post("using non-interleaved audio input");
- alsa_device.innoninterleave = 1;
- }
- }
- check_error(err, "snd_pcm_hw_params_set_access (input)");
- // Try to set 32 bit format first
- err = snd_pcm_hw_params_set_format(alsa_device.inhandle, hw_params,
- SND_PCM_FORMAT_S32);
- if (err < 0)
- {
- /* fprintf(stderr,
- "PD-ALSA: 32 bit format not available - using 16\n"); */
- err = snd_pcm_hw_params_set_format(alsa_device.inhandle, hw_params,
- SND_PCM_FORMAT_S16);
- check_error(err, "snd_pcm_hw_params_set_format (input)");
- alsa_samplewidth = 2;
- }
- else
- {
- alsa_samplewidth = 4;
- }
- post("Sample width set to %d bytes", alsa_samplewidth);
- // set the subformat
- err = snd_pcm_hw_params_set_subformat(alsa_device.inhandle, hw_params,
- SND_PCM_SUBFORMAT_STD);
- check_error(err, "snd_pcm_hw_params_set_subformat (input)");
- // set the number of channels
- tmp_uint = inchans;
- err = snd_pcm_hw_params_set_channels_min(alsa_device.inhandle,
- hw_params, &tmp_uint);
- check_error(err, "snd_pcm_hw_params_set_channels (input)");
- if (tmp_uint != (unsigned)inchans)
- post("ALSA: set input channels to %d", tmp_uint);
- inchans = tmp_uint;
- // set the sampling rate
- err = snd_pcm_hw_params_set_rate_min(alsa_device.inhandle, hw_params,
- &rate, 0);
- check_error(err, "snd_pcm_hw_params_set_rate_min (input)");
-#if 0
- err = snd_pcm_hw_params_get_rate(hw_params, &subunitdir);
- post("input sample rate %d", err);
-#endif
- // set the period - ie frag size
- // post("fragsize a %d", frag_size);
-
- /* LATER try this to get a recommended period size...
- right now, it trips an assertion failure in ALSA lib */
-#if 0
- post("input period was %d, min %d, max %d\n",
- snd_pcm_hw_params_get_period_size(hw_params, 0),
- snd_pcm_hw_params_get_period_size_min(hw_params, 0),
- snd_pcm_hw_params_get_period_size_max(hw_params, 0));
-#endif
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_period_size_near(alsa_device.inhandle,
- hw_params,
- (snd_pcm_uframes_t)
- frag_size, 0);
-#else
- tmp_snd_pcm_uframes = frag_size;
- err = snd_pcm_hw_params_set_period_size_near(alsa_device.inhandle,
- hw_params, &tmp_snd_pcm_uframes, 0);
-#endif
- check_error(err, "snd_pcm_hw_params_set_period_size_near (input)");
- // post("fragsize b %d", frag_size);
- // set the number of periods - ie numfrags
- // post("nfrags a %d", nfrags);
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_periods_near(alsa_device.inhandle,
- hw_params, nfrags, 0);
-#else
- tmp_uint = nfrags;
- err = snd_pcm_hw_params_set_periods_near(alsa_device.inhandle,
- hw_params, &tmp_uint, 0);
-#endif
- check_error(err, "snd_pcm_hw_params_set_periods_near (input)");
- // set the buffer size
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.inhandle,
- hw_params, nfrags * frag_size);
-#else
- tmp_snd_pcm_uframes = nfrags * frag_size;
- err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.inhandle,
- hw_params, &tmp_snd_pcm_uframes);
-#endif
- check_error(err, "snd_pcm_hw_params_set_buffer_size_near (input)");
-
- err = snd_pcm_hw_params(alsa_device.inhandle, hw_params);
- check_error(err, "snd_pcm_hw_params (input)");
-
- snd_pcm_hw_params_free(hw_params);
-
- err = snd_pcm_sw_params_malloc(&sw_params);
- check_error(err, "snd_pcm_sw_params_malloc (input)");
- err = snd_pcm_sw_params_current(alsa_device.inhandle, sw_params);
- check_error(err, "snd_pcm_sw_params_current (input)");
- err = snd_pcm_sw_params_set_start_threshold(alsa_device.inhandle,
- sw_params, nfrags * frag_size);
- check_error(err, "snd_pcm_sw_params_set_start_threshold (input)");
- err = snd_pcm_sw_params_set_stop_threshold(alsa_device.inhandle,
- sw_params, 0x7fffffff);
- check_error(err, "snd_pcm_sw_params_set_stop_threshold (input)");
- err = snd_pcm_sw_params_set_avail_min(alsa_device.inhandle, sw_params,
- frag_size);
- check_error(err, "snd_pcm_sw_params_set_avail_min (input)");
- err = snd_pcm_sw_params(alsa_device.inhandle, sw_params);
- check_error(err, "snd_pcm_sw_params (input)");
-
- snd_pcm_sw_params_free(sw_params);
-
- snd_output_stdio_attach(&out, stderr, 0);
-#if 0
- if (sys_verbose)
- {
- snd_pcm_dump_hw_setup(alsa_device.inhandle, out);
- snd_pcm_dump_sw_setup(alsa_device.inhandle, out);
- }
-#endif
- }
-
- if (outchans)
- {
- int foo;
- if (sys_verbose)
- post("opening sound output...");
- err = snd_pcm_hw_params_malloc(&hw_params);
- check_error(err, "snd_pcm_sw_params (output)");
-
- // get the default params
- err = snd_pcm_hw_params_any(alsa_device.outhandle, hw_params);
- check_error(err, "snd_pcm_hw_params_any (output)");
- // set interleaved access - FIXME deal with other access types
- err = snd_pcm_hw_params_set_access(alsa_device.outhandle, hw_params,
- SND_PCM_ACCESS_RW_INTERLEAVED);
- check_error(err, "snd_pcm_hw_params_set_access (output)");
-
- /* try to set interleaved access */
- err = snd_pcm_hw_params_set_access(alsa_device.outhandle,
- hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
- if (err < 0)
- {
- /* OK, so try non-interleaved */
- err = snd_pcm_hw_params_set_access(alsa_device.outhandle,
- hw_params, SND_PCM_ACCESS_RW_NONINTERLEAVED);
- if (err >= 0)
- {
- post("using non-interleaved audio");
- alsa_device.outnoninterleave = 1;
- }
- }
- check_error(err, "snd_pcm_hw_params_set_access (output)");
-
-
- // Try to set 32 bit format first
- err = snd_pcm_hw_params_set_format(alsa_device.outhandle, hw_params,
- SND_PCM_FORMAT_S32);
- if (err < 0)
- {
- err = snd_pcm_hw_params_set_format(alsa_device.outhandle,
- hw_params,SND_PCM_FORMAT_S16);
- check_error(err, "snd_pcm_hw_params_set_format (output)");
- /* fprintf(stderr,
- "PD-ALSA: 32 bit format not available - using 16\n"); */
- alsa_samplewidth = 2;
- }
- else
- {
- alsa_samplewidth = 4;
- }
- // set the subformat
- err = snd_pcm_hw_params_set_subformat(alsa_device.outhandle, hw_params,
- SND_PCM_SUBFORMAT_STD);
- check_error(err, "snd_pcm_hw_params_set_subformat (output)");
- // set the number of channels
- tmp_uint = outchans;
- err = snd_pcm_hw_params_set_channels_min(alsa_device.outhandle,
- hw_params, &tmp_uint);
- check_error(err, "snd_pcm_hw_params_set_channels (output)");
- if (tmp_uint != (unsigned)outchans)
- post("alsa: set output channels to %d", tmp_uint);
- outchans = tmp_uint;
- // set the sampling rate
- err = snd_pcm_hw_params_set_rate_min(alsa_device.outhandle, hw_params,
- &rate, 0);
- check_error(err, "snd_pcm_hw_params_set_rate_min (output)");
-#if 0
- err = snd_pcm_hw_params_get_rate(hw_params, &subunitdir);
- post("output sample rate %d", err);
-#endif
- // set the period - ie frag size
-#if 0
- post("output period was %d, min %d, max %d\n",
- snd_pcm_hw_params_get_period_size(hw_params, 0),
- snd_pcm_hw_params_get_period_size_min(hw_params, 0),
- snd_pcm_hw_params_get_period_size_max(hw_params, 0));
-#endif
- // post("fragsize c %d", frag_size);
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_period_size_near(alsa_device.outhandle,
- hw_params,
- (snd_pcm_uframes_t)
- frag_size, 0);
-#else
- tmp_snd_pcm_uframes = frag_size;
- err = snd_pcm_hw_params_set_period_size_near(alsa_device.outhandle,
- hw_params, &tmp_snd_pcm_uframes, 0);
-#endif
- // post("fragsize d %d", frag_size);
- check_error(err, "snd_pcm_hw_params_set_period_size_near (output)");
- // set the number of periods - ie numfrags
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_periods_near(alsa_device.outhandle,
- hw_params, nfrags, 0);
-#else
- tmp_uint = nfrags;
- err = snd_pcm_hw_params_set_periods_near(alsa_device.outhandle,
- hw_params, &tmp_uint, 0);
-#endif
- check_error(err, "snd_pcm_hw_params_set_periods_near (output)");
- // set the buffer size
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.outhandle,
- hw_params, nfrags * frag_size);
-#else
- tmp_snd_pcm_uframes = nfrags * frag_size;
- err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.outhandle,
- hw_params, &tmp_snd_pcm_uframes);
-#endif
- check_error(err, "snd_pcm_hw_params_set_buffer_size_near (output)");
-
- err = snd_pcm_hw_params(alsa_device.outhandle, hw_params);
- check_error(err, "snd_pcm_hw_params (output)");
-
- snd_pcm_hw_params_free(hw_params);
-
- err = snd_pcm_sw_params_malloc(&sw_params);
- check_error(err, "snd_pcm_sw_params_malloc (output)");
- err = snd_pcm_sw_params_current(alsa_device.outhandle, sw_params);
- check_error(err, "snd_pcm_sw_params_current (output)");
- err = snd_pcm_sw_params_set_start_threshold(alsa_device.outhandle,
- sw_params, nfrags * frag_size);
- check_error(err, "snd_pcm_sw_params_set_start_threshold (output)");
- err = snd_pcm_sw_params_set_stop_threshold(alsa_device.outhandle,
- sw_params, 0x7fffffff);
- check_error(err, "snd_pcm_sw_params_set_stop_threshold (output)");
- err = snd_pcm_sw_params_set_avail_min(alsa_device.outhandle, sw_params,
- frag_size);
- check_error(err, "snd_pcm_sw_params_set_avail_min (output)");
- err = snd_pcm_sw_params(alsa_device.outhandle, sw_params);
- check_error(err, "snd_pcm_sw_params (output)");
- snd_pcm_sw_params_free(sw_params);
-
- snd_output_stdio_attach(&out, stderr, 0);
-#if 0
- if (sys_verbose)
- {
- snd_pcm_dump_hw_setup(alsa_device.outhandle, out);
- snd_pcm_dump_sw_setup(alsa_device.outhandle, out);
- }
-#endif
- }
-
- if (inchans)
- snd_pcm_prepare(alsa_device.inhandle);
- if (outchans)
- snd_pcm_prepare(alsa_device.outhandle);
-
- // if duplex we can link the channels so they start together
- if (inchans && outchans)
- snd_pcm_link(alsa_device.inhandle, alsa_device.outhandle);
-
- // set up the status variables
- err = snd_pcm_status_malloc(&in_status);
- check_error(err, "snd_pcm_status_malloc");
- err = snd_pcm_status_malloc(&out_status);
- check_error(err, "snd_pcm_status_malloc");
-
- // set up the buffer
- if (alsa_snd_buf)
- free(alsa_snd_buf);
- alsa_snd_buf = (void *)malloc(
- sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE *
- (outchans > inchans ? outchans : inchans));
- memset(alsa_snd_buf, 0, sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE *
- (outchans > inchans ? outchans : inchans));
- /* make an array of pointers too in case we need them */
- if (alsa_buf_ptrs)
- free(alsa_buf_ptrs);
- alsa_buf_ptrs = (void **)malloc(
- sizeof(void *) * (outchans > inchans ? outchans : inchans));
- for (i = 0; i < (outchans > inchans ? outchans : inchans); i++)
- alsa_buf_ptrs[i] = (t_alsa_sample32 *)alsa_snd_buf + i * DEFDACBLKSIZE;
-
- // fill the buffer with silence
- if (outchans)
- {
- i = (frag_size * nfrags)/DEFDACBLKSIZE + 1;
- while (i--)
- {
- if (alsa_device.outnoninterleave)
- snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
- DEFDACBLKSIZE);
- else snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
- DEFDACBLKSIZE);
- }
- /* confused about this: */
- /* if ((err = snd_pcm_start(alsa_device.outhandle) < 0))
- check_error(err, "output start failed\n"); */
- }
- else if (inchans)
- {
- if (snd_pcm_start(alsa_device.inhandle) < 0)
- check_error(err, "input start failed\n");
- }
- alsa_outchannels = outchans;
- alsa_inchannels = inchans;
-
- return (!(inchans || outchans));
-}
-
-void alsa_close_audio(void)
-{
- int err;
- if (alsa_inchannels)
- {
- err = snd_pcm_close(alsa_device.inhandle);
- check_error(err, "snd_pcm_close (input)");
- }
- if (alsa_outchannels)
- {
- err = snd_pcm_close(alsa_device.outhandle);
- check_error(err, "snd_pcm_close (output)");
- }
-}
-
-// #define DEBUG_ALSA_XFER
-
-int alsa_send_dacs(void)
-{
- static int16_t *sp;
- static int xferno = 0;
- static int callno = 0;
- static double timenow;
- double timelast;
- t_sample *fp, *fp1, *fp2;
- int i, j, k, err, devno = 0;
- int inputcount = 0, outputcount = 0, inputlate = 0, outputlate = 0;
- int result;
- int inchannels = (sys_inchannels > alsa_inchannels ?
- alsa_inchannels : sys_inchannels);
- int outchannels = (sys_outchannels > alsa_outchannels ?
- alsa_outchannels : sys_outchannels);
- unsigned int intransfersize = DEFDACBLKSIZE;
- unsigned int outtransfersize = DEFDACBLKSIZE;
-
- // get the status
- if (!inchannels && !outchannels)
- {
- return SENDDACS_NO;
- }
-
- timelast = timenow;
- timenow = sys_getrealtime();
-
-#ifdef DEBUG_ALSA_XFER
- if (timenow - timelast > 0.050)
- fprintf(stderr, "(%d)",
- (int)(1000 * (timenow - timelast))), fflush(stderr);
-#endif
-
- callno++;
-
- alsa_checkiosync(); /* check I/O are in sync and data not late */
-
- if (alsa_inchannels)
- {
- snd_pcm_status(alsa_device.inhandle, in_status);
- if (snd_pcm_status_get_avail(in_status) < intransfersize)
- return SENDDACS_NO;
- }
- if (alsa_outchannels)
- {
- snd_pcm_status(alsa_device.outhandle, out_status);
- if (snd_pcm_status_get_avail(out_status) < outtransfersize)
- return SENDDACS_NO;
- }
-
- /* do output */
- if (alsa_outchannels)
- {
- fp = sys_soundout;
- if (alsa_samplewidth == 4)
- {
- if (alsa_device.outnoninterleave)
- {
- int n = outchannels * DEFDACBLKSIZE;
- for (i = 0, fp1 = fp; i < n; i++)
- {
- float s1 = *fp1 * INT32_MAX;
- ((t_alsa_sample32 *)alsa_snd_buf)[i] = CLIP32(s1);
- }
- n = alsa_outchannels * DEFDACBLKSIZE;
- for (; i < n; i++)
- ((t_alsa_sample32 *)alsa_snd_buf)[i] = 0;
- }
- else
- {
- for (i = 0, fp1 = fp; i < outchannels; i++,
- fp1 += DEFDACBLKSIZE)
- {
- for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
- j += alsa_outchannels, fp2++)
- {
- float s1 = *fp2 * INT32_MAX;
- ((t_alsa_sample32 *)alsa_snd_buf)[j] = CLIP32(s1);
- }
- }
- }
- }
- else
- {
- for (i = 0, fp1 = fp; i < outchannels; i++, fp1 += DEFDACBLKSIZE)
- {
- for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
- j += alsa_outchannels, fp2++)
- {
- int s = *fp2 * 32767.;
- if (s > 32767)
- s = 32767;
- else if (s < -32767)
- s = -32767;
- ((t_alsa_sample16 *)alsa_snd_buf)[j] = s;
- }
- }
- }
-
- if (alsa_device.outnoninterleave)
- result = snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
- outtransfersize);
- else result = snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
- outtransfersize);
-
- if (result != (int)outtransfersize)
- {
- #ifdef DEBUG_ALSA_XFER
- if (result >= 0 || errno == EAGAIN)
- fprintf(stderr, "ALSA: write returned %d of %d\n",
- result, outtransfersize);
- else fprintf(stderr, "ALSA: write: %s\n",
- snd_strerror(errno));
- fprintf(stderr,
- "inputcount %d, outputcount %d, outbufsize %d\n",
- inputcount, outputcount,
- (ALSA_EXTRABUFFER + sys_advance_samples)
- * alsa_samplewidth * outchannels);
- #endif
- sys_log_error(ERR_DACSLEPT);
- return (SENDDACS_NO);
- }
-
- /* zero out the output buffer */
- memset(sys_soundout, 0, DEFDACBLKSIZE * sizeof(*sys_soundout) *
- sys_outchannels);
- if (sys_getrealtime() - timenow > 0.002)
- {
- #ifdef DEBUG_ALSA_XFER
- fprintf(stderr, "output %d took %d msec\n",
- callno, (int)(1000 * (timenow - timelast))), fflush(stderr);
- #endif
- timenow = sys_getrealtime();
- sys_log_error(ERR_DACSLEPT);
- }
- }
- /* do input */
- if (alsa_inchannels)
- {
- if (alsa_device.innoninterleave)
- result = snd_pcm_readn(alsa_device.inhandle, alsa_buf_ptrs,
- intransfersize);
- else result = snd_pcm_readi(alsa_device.inhandle, alsa_snd_buf,
- intransfersize);
- if (result < (int)intransfersize)
- {
-#ifdef DEBUG_ALSA_XFER
- if (result < 0)
- fprintf(stderr,
- "snd_pcm_read %d %d: %s\n",
- callno, xferno, snd_strerror(errno));
- else fprintf(stderr,
- "snd_pcm_read %d %d returned only %d\n",
- callno, xferno, result);
- fprintf(stderr,
- "inputcount %d, outputcount %d, inbufsize %d\n",
- inputcount, outputcount,
- (ALSA_EXTRABUFFER + sys_advance_samples)
- * alsa_samplewidth * inchannels);
-#endif
- sys_log_error(ERR_ADCSLEPT);
- return (SENDDACS_NO);
- }
- fp = sys_soundin;
- if (alsa_samplewidth == 4)
- {
- if (alsa_device.innoninterleave)
- {
- int n = inchannels * DEFDACBLKSIZE;
- for (i = 0, fp1 = fp; i < n; i++)
- *fp1 = (float) ((t_alsa_sample32 *)alsa_snd_buf)[i]
- * (1./ INT32_MAX);
- }
- else
- {
- for (i = 0, fp1 = fp; i < inchannels;
- i++, fp1 += DEFDACBLKSIZE)
- {
- for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
- j += alsa_inchannels, fp2++)
- *fp2 = (float) ((t_alsa_sample32 *)alsa_snd_buf)[j]
- * (1./ INT32_MAX);
- }
- }
- }
- else
- {
- for (i = 0, fp1 = fp; i < inchannels; i++, fp1 += DEFDACBLKSIZE)
- {
- for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
- j += alsa_inchannels, fp2++)
- *fp2 = (float) ((t_alsa_sample16 *)alsa_snd_buf)[j]
- * 3.051850e-05;
- }
- }
- }
- xferno++;
- if (sys_getrealtime() - timenow > 0.002)
- {
-#ifdef DEBUG_ALSA_XFER
- fprintf(stderr, "routine took %d msec\n",
- (int)(1000 * (sys_getrealtime() - timenow)));
-#endif
- sys_log_error(ERR_ADCSLEPT);
- }
- return SENDDACS_YES;
-}
-
-void alsa_printstate( void)
-{
- int i, result;
- snd_pcm_sframes_t indelay, outdelay;
- if (sys_audioapi != API_ALSA)
- {
- error("restart-audio: implemented for ALSA only.");
- return;
- }
- if (sys_inchannels)
- {
- result = snd_pcm_delay(alsa_device.inhandle, &indelay);
- if (result < 0)
- post("snd_pcm_delay 1 failed");
- else post("in delay %d", indelay);
- }
- if (sys_outchannels)
- {
- result = snd_pcm_delay(alsa_device.outhandle, &outdelay);
- if (result < 0)
- post("snd_pcm_delay 2 failed");
- else post("out delay %d", outdelay);
- }
- post("sum %d (%d mod 64)\n", indelay + outdelay, (indelay+outdelay)%64);
-
- post("buf samples %d", alsa_buf_samps);
-}
-
-
-void alsa_resync( void)
-{
- int i, result;
- if (sys_audioapi != API_ALSA)
- {
- error("restart-audio: implemented for ALSA only.");
- return;
- }
- memset(alsa_snd_buf, 0,
- sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE * sys_outchannels);
- for (i = 0; i < 1000000; i++)
- {
- if (alsa_device.outnoninterleave)
- result = snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
- DEFDACBLKSIZE);
- else result = snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
- DEFDACBLKSIZE);
- if (result != (int)DEFDACBLKSIZE)
- break;
- }
- post("%d written", i);
-}
-
-void alsa_putzeros(int n)
-{
- int i, result;
- memset(alsa_snd_buf, 0,
- sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE * alsa_outchannels);
- for (i = 0; i < n; i++)
- {
- if (alsa_device.outnoninterleave)
- result = snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
- DEFDACBLKSIZE);
- else result = snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
- DEFDACBLKSIZE);
-#if 0
- if (result != DEFDACBLKSIZE)
- post("result %d", result);
-#endif
- }
- /* post ("putzeros %d", n); */
-}
-
-void alsa_getzeros(int n)
-{
- int i, result;
- for (i = 0; i < n; i++)
- {
- result = snd_pcm_readi(alsa_device.inhandle, alsa_snd_buf,
- DEFDACBLKSIZE);
-#if 0
- if (result != DEFDACBLKSIZE)
- post("result %d", result);
-#endif
- }
- /* post ("getzeros %d", n); */
-}
-
- /* call this only if both input and output are open */
-static void alsa_checkiosync( void)
-{
- int i, result, checkit = 1, giveup = 1000, alreadylogged = 0;
- snd_pcm_sframes_t indelay, outdelay, defect;
-
- if (!(alsa_outchannels && alsa_inchannels))
- return;
- while (checkit)
- {
- checkit = 0;
- if (giveup-- <= 0)
- return;
- result = snd_pcm_delay(alsa_device.outhandle, &outdelay);
- if (result < 0)
- {
- post("output snd_pcm_delay failed: %s", snd_strerror(result));
- if (snd_pcm_status(alsa_device.outhandle, out_status) < 0)
- post("output snd_pcm_status failed");
- else post("astate %d",
- snd_pcm_status_get_state(out_status));
- return;
- }
- if (outdelay < 0)
- sys_log_error(ERR_DATALATE), alreadylogged = 1;
-
- if (sys_inchannels)
- {
- result = snd_pcm_delay(alsa_device.inhandle, &indelay);
- if (result < 0)
- {
- post("input snd_pcm_delay failed");
- return;
- }
- defect = indelay + outdelay - alsa_buf_samps;
- if (defect < -(3 * DEFDACBLKSIZE / 2) )
- {
- checkit = 1;
- alsa_putzeros(1);
- if (!alreadylogged)
- sys_log_error(ERR_RESYNC), alreadylogged = 1;
- }
- else if (defect > 0)
- {
- checkit = 1;
- alsa_getzeros(1);
- if (!alreadylogged)
- sys_log_error(ERR_RESYNC), alreadylogged = 1;
- }
- /* if (alreadylogged)
- post("in %d out %d defect %d", indelay, outdelay, defect); */
- }
- }
-}
-
-static int alsa_nnames = 0;
-static char **alsa_names = 0;
-
-void alsa_adddev(char *name)
-{
- if (alsa_nnames)
- alsa_names = (char **)t_resizebytes(alsa_names,
- alsa_nnames * sizeof(char *),
- (alsa_nnames+1) * sizeof(char *));
- else alsa_names = (char **)t_getbytes(sizeof(char *));
- alsa_names[alsa_nnames] = gensym(name)->s_name;
- alsa_nnames++;
-}
-
-static void alsa_numbertoname(int devno, char *devname, int nchar)
-{
- int ndev = 0, cardno = -1;
- while (!snd_card_next(&cardno) && cardno >= 0)
- ndev++;
- if (devno < 2*ndev)
- {
- if (devno & 1)
- snprintf(devname, nchar, "plughw:%d", devno/2);
- else snprintf(devname, nchar, "hw:%d", devno/2);
- }
- else if (devno <2*ndev + alsa_nnames)
- snprintf(devname, nchar, "%s", alsa_names[devno - 2*ndev]);
- else snprintf(devname, nchar, "???");
-}
- /* For each hardware card found, we list two devices, the "hard" and
- "plug" one. The card scan is derived from portaudio code. */
-void alsa_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize)
-{
- int ndev = 0, cardno = -1, i, j;
- *canmulti = 0; /* only one device; must be the same for input&output */
- while (!snd_card_next(&cardno) && cardno >= 0)
- {
- snd_ctl_t *ctl;
- snd_ctl_card_info_t *info;
- char devname[80];
- const char *desc;
- if (2 * ndev + 2 > maxndev)
- break;
- /* apparently, "cardno" is just a counter; but check that here */
- if (ndev != cardno)
- fprintf(stderr, "oops: ALSA cards not reported in order?\n");
- sprintf(devname, "hw:%d", cardno );
- /* fprintf(stderr, "\ntry %s...\n", devname); */
- if (snd_ctl_open(&ctl, devname, 0) >= 0)
- {
- snd_ctl_card_info_malloc(&info);
- snd_ctl_card_info(ctl, info);
- desc = snd_ctl_card_info_get_name(info);
- snd_ctl_card_info_free(info);
- }
- else
- {
- fprintf(stderr, "ALSA card scan error\n");
- desc = "???";
- }
- /* fprintf(stderr, "name: %s\n", snd_ctl_card_info_get_name(info)); */
- sprintf(indevlist + 2*ndev * devdescsize, "%s (hardware)", desc);
- sprintf(indevlist + (2*ndev + 1) * devdescsize, "%s (plug-in)", desc);
- sprintf(outdevlist + 2*ndev * devdescsize, "%s (hardware)", desc);
- sprintf(outdevlist + (2*ndev + 1) * devdescsize, "%s (plug-in)", desc);
- ndev++;
- }
- for (i = 0, j = 2*ndev; i < alsa_nnames; i++, j++)
- {
- if (j >= maxndev)
- break;
- snprintf(indevlist + j * devdescsize, devdescsize, "%s",
- alsa_names[i]);
- }
- *nindevs = *noutdevs = j;
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_audio_mmio.c b/apps/plugins/pdbox/PDa/src/s_audio_mmio.c
index 44bbae855b..4a4a8f7354 100644
--- a/apps/plugins/pdbox/PDa/src/s_audio_mmio.c
+++ b/apps/plugins/pdbox/PDa/src/s_audio_mmio.c
@@ -792,797 +792,4 @@ void mmio_getdevs(char *indevlist, int *nindevs,
sprintf(outdevlist + i * devdescsize, (wRtn ? "???" : wocap.szPname));
}
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* modified 2/98 by Winfried Ritsch to deal with up to 4 synchronized
-"wave" devices, which is how ADAT boards appear to the WAVE API. */
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <stdio.h>
-
-#include <windows.h>
-
-#include <MMSYSTEM.H>
-
-/* ------------------------- audio -------------------------- */
-
-static void nt_close_midiin(void);
-static void nt_noresync( void);
-
-static void postflags(void);
-
-#define NAPORTS 16 /* wini hack for multiple ADDA devices */
-#define CHANNELS_PER_DEVICE 2
-#define DEFAULTCHANS 2
-#define DEFAULTSRATE 44100
-#define SAMPSIZE 2
-
-int nt_realdacblksize;
-#define DEFREALDACBLKSIZE (4 * DEFDACBLKSIZE) /* larger underlying bufsize */
-
-#define MAXBUFFER 100 /* number of buffers in use at maximum advance */
-#define DEFBUFFER 30 /* default is about 30x6 = 180 msec! */
-static int nt_naudiobuffer = DEFBUFFER;
-float sys_dacsr = DEFAULTSRATE;
-
-static int nt_whichapi = API_MMIO;
-static int nt_meters; /* true if we're metering */
-static float nt_inmax; /* max input amplitude */
-static float nt_outmax; /* max output amplitude */
-static int nt_nwavein, nt_nwaveout; /* number of WAVE devices in and out */
-
-typedef struct _sbuf
-{
- HANDLE hData;
- HPSTR lpData; // pointer to waveform data memory
- HANDLE hWaveHdr;
- WAVEHDR *lpWaveHdr; // pointer to header structure
-} t_sbuf;
-
-t_sbuf ntsnd_outvec[NAPORTS][MAXBUFFER]; /* circular buffer array */
-HWAVEOUT ntsnd_outdev[NAPORTS]; /* output device */
-static int ntsnd_outphase[NAPORTS]; /* index of next buffer to send */
-
-t_sbuf ntsnd_invec[NAPORTS][MAXBUFFER]; /* circular buffer array */
-HWAVEIN ntsnd_indev[NAPORTS]; /* input device */
-static int ntsnd_inphase[NAPORTS]; /* index of next buffer to read */
-
-static void nt_waveinerror(char *s, int err)
-{
- char t[256];
- waveInGetErrorText(err, t, 256);
- fprintf(stderr, s, t);
-}
-
-static void nt_waveouterror(char *s, int err)
-{
- char t[256];
- waveOutGetErrorText(err, t, 256);
- fprintf(stderr, s, t);
-}
-
-static void wave_prep(t_sbuf *bp, int setdone)
-{
- WAVEHDR *wh;
- short *sp;
- int i;
- /*
- * Allocate and lock memory for the waveform data. The memory
- * for waveform data must be globally allocated with
- * GMEM_MOVEABLE and GMEM_SHARE flags.
- */
-
- if (!(bp->hData =
- GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
- (DWORD) (CHANNELS_PER_DEVICE * SAMPSIZE * nt_realdacblksize))))
- printf("alloc 1 failed\n");
-
- if (!(bp->lpData =
- (HPSTR) GlobalLock(bp->hData)))
- printf("lock 1 failed\n");
-
- /* Allocate and lock memory for the header. */
-
- if (!(bp->hWaveHdr =
- GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, (DWORD) sizeof(WAVEHDR))))
- printf("alloc 2 failed\n");
-
- if (!(wh = bp->lpWaveHdr =
- (WAVEHDR *) GlobalLock(bp->hWaveHdr)))
- printf("lock 2 failed\n");
-
- for (i = CHANNELS_PER_DEVICE * nt_realdacblksize,
- sp = (short *)bp->lpData; i--; )
- *sp++ = 0;
-
- wh->lpData = bp->lpData;
- wh->dwBufferLength = (CHANNELS_PER_DEVICE * SAMPSIZE * nt_realdacblksize);
- wh->dwFlags = 0;
- wh->dwLoops = 0L;
- wh->lpNext = 0;
- wh->reserved = 0;
- /* optionally (for writing) set DONE flag as if we had queued them */
- if (setdone)
- wh->dwFlags = WHDR_DONE;
-}
-
-static UINT nt_whichdac = WAVE_MAPPER, nt_whichadc = WAVE_MAPPER;
-
-int mmio_do_open_audio(void)
-{
- PCMWAVEFORMAT form;
- int i, j;
- UINT mmresult;
- int nad, nda;
- static int naudioprepped = 0, nindevsprepped = 0, noutdevsprepped = 0;
- if (sys_verbose)
- post("%d devices in, %d devices out",
- nt_nwavein, nt_nwaveout);
-
- form.wf.wFormatTag = WAVE_FORMAT_PCM;
- form.wf.nChannels = CHANNELS_PER_DEVICE;
- form.wf.nSamplesPerSec = sys_dacsr;
- form.wf.nAvgBytesPerSec = sys_dacsr * (CHANNELS_PER_DEVICE * SAMPSIZE);
- form.wf.nBlockAlign = CHANNELS_PER_DEVICE * SAMPSIZE;
- form.wBitsPerSample = 8 * SAMPSIZE;
-
- if (nt_nwavein <= 1 && nt_nwaveout <= 1)
- nt_noresync();
-
- if (nindevsprepped < nt_nwavein)
- {
- for (i = nindevsprepped; i < nt_nwavein; i++)
- for (j = 0; j < naudioprepped; j++)
- wave_prep(&ntsnd_invec[i][j], 0);
- nindevsprepped = nt_nwavein;
- }
- if (noutdevsprepped < nt_nwaveout)
- {
- for (i = noutdevsprepped; i < nt_nwaveout; i++)
- for (j = 0; j < naudioprepped; j++)
- wave_prep(&ntsnd_outvec[i][j], 1);
- noutdevsprepped = nt_nwaveout;
- }
- if (naudioprepped < nt_naudiobuffer)
- {
- for (j = naudioprepped; j < nt_naudiobuffer; j++)
- {
- for (i = 0; i < nt_nwavein; i++)
- wave_prep(&ntsnd_invec[i][j], 0);
- for (i = 0; i < nt_nwaveout; i++)
- wave_prep(&ntsnd_outvec[i][j], 1);
- }
- naudioprepped = nt_naudiobuffer;
- }
- for (nad=0; nad < nt_nwavein; nad++)
- {
- /* Open waveform device(s), sucessively numbered, for input */
-
- mmresult = waveInOpen(&ntsnd_indev[nad], nt_whichadc+nad,
- (WAVEFORMATEX *)(&form), 0L, 0L, CALLBACK_NULL);
-
- if (sys_verbose)
- printf("opened adc device %d with return %d\n",
- nt_whichadc+nad,mmresult);
-
- if (mmresult != MMSYSERR_NOERROR)
- {
- nt_waveinerror("waveInOpen: %s\n", mmresult);
- nt_nwavein = nad; /* nt_nwavein = 0 wini */
- }
- else
- {
- for (i = 0; i < nt_naudiobuffer; i++)
- {
- mmresult = waveInPrepareHeader(ntsnd_indev[nad],
- ntsnd_invec[nad][i].lpWaveHdr, sizeof(WAVEHDR));
- if (mmresult != MMSYSERR_NOERROR)
- nt_waveinerror("waveinprepareheader: %s\n", mmresult);
- mmresult = waveInAddBuffer(ntsnd_indev[nad],
- ntsnd_invec[nad][i].lpWaveHdr, sizeof(WAVEHDR));
- if (mmresult != MMSYSERR_NOERROR)
- nt_waveinerror("waveInAddBuffer: %s\n", mmresult);
- }
- }
- }
- /* quickly start them all together */
- for (nad = 0; nad < nt_nwavein; nad++)
- waveInStart(ntsnd_indev[nad]);
-
- for (nda = 0; nda < nt_nwaveout; nda++)
- {
- /* Open a waveform device for output in sucessiv device numbering*/
- mmresult = waveOutOpen(&ntsnd_outdev[nda], nt_whichdac + nda,
- (WAVEFORMATEX *)(&form), 0L, 0L, CALLBACK_NULL);
-
- if (sys_verbose)
- fprintf(stderr,"opened dac device %d, with return %d\n",
- nt_whichdac +nda, mmresult);
-
- if (mmresult != MMSYSERR_NOERROR)
- {
- fprintf(stderr,"Wave out open device %d + %d\n",nt_whichdac,nda);
- nt_waveouterror("waveOutOpen device: %s\n", mmresult);
- nt_nwaveout = nda;
- }
- }
-
- return (0);
-}
-
-void mmio_close_audio( void)
-{
- int errcode;
- int nda, nad;
- if (sys_verbose)
- post("closing audio...");
-
- for (nda=0; nda < nt_nwaveout; nda++) /*if (nt_nwaveout) wini */
- {
- errcode = waveOutReset(ntsnd_outdev[nda]);
- if (errcode != MMSYSERR_NOERROR)
- printf("error resetting output %d: %d\n", nda, errcode);
- errcode = waveOutClose(ntsnd_outdev[nda]);
- if (errcode != MMSYSERR_NOERROR)
- printf("error closing output %d: %d\n",nda , errcode);
- }
- nt_nwaveout = 0;
-
- for(nad=0; nad < nt_nwavein;nad++) /* if (nt_nwavein) wini */
- {
- errcode = waveInReset(ntsnd_indev[nad]);
- if (errcode != MMSYSERR_NOERROR)
- printf("error resetting input: %d\n", errcode);
- errcode = waveInClose(ntsnd_indev[nad]);
- if (errcode != MMSYSERR_NOERROR)
- printf("error closing input: %d\n", errcode);
- }
- nt_nwavein = 0;
-}
-
-
-#define ADCJITTER 10 /* We tolerate X buffers of jitter by default */
-#define DACJITTER 10
-
-static int nt_adcjitterbufsallowed = ADCJITTER;
-static int nt_dacjitterbufsallowed = DACJITTER;
-
- /* ------------- MIDI time stamping from audio clock ------------ */
-
-#ifdef MIDI_TIMESTAMP
-
-static double nt_hibuftime;
-static double initsystime = -1;
-
- /* call this whenever we reset audio */
-static void nt_resetmidisync(void)
-{
- initsystime = clock_getsystime();
- nt_hibuftime = sys_getrealtime();
-}
-
- /* call this whenever we're idled waiting for audio to be ready.
- The routine maintains a high and low water point for the difference
- between real and DAC time. */
-
-static void nt_midisync(void)
-{
- double jittersec, diff;
-
- if (initsystime == -1) nt_resetmidisync();
- jittersec = (nt_dacjitterbufsallowed > nt_adcjitterbufsallowed ?
- nt_dacjitterbufsallowed : nt_adcjitterbufsallowed)
- * nt_realdacblksize / sys_getsr();
- diff = sys_getrealtime() - 0.001 * clock_gettimesince(initsystime);
- if (diff > nt_hibuftime) nt_hibuftime = diff;
- if (diff < nt_hibuftime - jittersec)
- {
- post("jitter excess %d %f", dac, diff);
- nt_resetmidisync();
- }
-}
-
-static double nt_midigettimefor(LARGE_INTEGER timestamp)
-{
- /* this is broken now... used to work when "timestamp" was derived from
- QueryPerformanceCounter() instead of the gates approved
- timeGetSystemTime() call in the MIDI callback routine below. */
- return (nt_tixtotime(timestamp) - nt_hibuftime);
-}
-#endif /* MIDI_TIMESTAMP */
-
-
-static int nt_fill = 0;
-#define WRAPFWD(x) ((x) >= nt_naudiobuffer ? (x) - nt_naudiobuffer: (x))
-#define WRAPBACK(x) ((x) < 0 ? (x) + nt_naudiobuffer: (x))
-#define MAXRESYNC 500
-
-#if 0 /* this is used for debugging */
-static void nt_printaudiostatus(void)
-{
- int nad, nda;
- for (nad = 0; nad < nt_nwavein; nad++)
- {
- int phase = ntsnd_inphase[nad];
- int phase2 = phase, phase3 = WRAPFWD(phase2), count, ntrans = 0;
- int firstphasedone = -1, firstphasebusy = -1;
- for (count = 0; count < nt_naudiobuffer; count++)
- {
- int donethis =
- (ntsnd_invec[nad][phase2].lpWaveHdr->dwFlags & WHDR_DONE);
- int donenext =
- (ntsnd_invec[nad][phase3].lpWaveHdr->dwFlags & WHDR_DONE);
- if (donethis && !donenext)
- {
- if (firstphasebusy >= 0) goto multipleadc;
- firstphasebusy = count;
- }
- if (!donethis && donenext)
- {
- if (firstphasedone >= 0) goto multipleadc;
- firstphasedone = count;
- }
- phase2 = phase3;
- phase3 = WRAPFWD(phase2 + 1);
- }
- post("nad %d phase %d busy %d done %d", nad, phase, firstphasebusy,
- firstphasedone);
- continue;
- multipleadc:
- startpost("nad %d phase %d: oops:", nad, phase);
- for (count = 0; count < nt_naudiobuffer; count++)
- {
- char buf[80];
- sprintf(buf, " %d",
- (ntsnd_invec[nad][count].lpWaveHdr->dwFlags & WHDR_DONE));
- poststring(buf);
- }
- endpost();
- }
- for (nda = 0; nda < nt_nwaveout; nda++)
- {
- int phase = ntsnd_outphase[nad];
- int phase2 = phase, phase3 = WRAPFWD(phase2), count, ntrans = 0;
- int firstphasedone = -1, firstphasebusy = -1;
- for (count = 0; count < nt_naudiobuffer; count++)
- {
- int donethis =
- (ntsnd_outvec[nda][phase2].lpWaveHdr->dwFlags & WHDR_DONE);
- int donenext =
- (ntsnd_outvec[nda][phase3].lpWaveHdr->dwFlags & WHDR_DONE);
- if (donethis && !donenext)
- {
- if (firstphasebusy >= 0) goto multipledac;
- firstphasebusy = count;
- }
- if (!donethis && donenext)
- {
- if (firstphasedone >= 0) goto multipledac;
- firstphasedone = count;
- }
- phase2 = phase3;
- phase3 = WRAPFWD(phase2 + 1);
- }
- if (firstphasebusy < 0) post("nda %d phase %d all %d",
- nda, phase, (ntsnd_outvec[nad][0].lpWaveHdr->dwFlags & WHDR_DONE));
- else post("nda %d phase %d busy %d done %d", nda, phase, firstphasebusy,
- firstphasedone);
- continue;
- multipledac:
- startpost("nda %d phase %d: oops:", nda, phase);
- for (count = 0; count < nt_naudiobuffer; count++)
- {
- char buf[80];
- sprintf(buf, " %d",
- (ntsnd_outvec[nad][count].lpWaveHdr->dwFlags & WHDR_DONE));
- poststring(buf);
- }
- endpost();
- }
-}
-#endif /* 0 */
-
-/* this is a hack to avoid ever resyncing audio pointers in case for whatever
-reason the sync testing below gives false positives. */
-
-static int nt_resync_cancelled;
-static void nt_noresync( void)
-{
- nt_resync_cancelled = 1;
-}
-
-static void nt_resyncaudio(void)
-{
- UINT mmresult;
- int nad, nda, count;
- if (nt_resync_cancelled)
- return;
- /* for each open input device, eat all buffers which are marked
- ready. The next one will thus be "busy". */
- post("resyncing audio");
- for (nad = 0; nad < nt_nwavein; nad++)
- {
- int phase = ntsnd_inphase[nad];
- for (count = 0; count < MAXRESYNC; count++)
- {
- WAVEHDR *inwavehdr = ntsnd_invec[nad][phase].lpWaveHdr;
- if (!(inwavehdr->dwFlags & WHDR_DONE)) break;
- if (inwavehdr->dwFlags & WHDR_PREPARED)
- waveInUnprepareHeader(ntsnd_indev[nad],
- inwavehdr, sizeof(WAVEHDR));
- inwavehdr->dwFlags = 0L;
- waveInPrepareHeader(ntsnd_indev[nad], inwavehdr, sizeof(WAVEHDR));
- mmresult = waveInAddBuffer(ntsnd_indev[nad], inwavehdr,
- sizeof(WAVEHDR));
- if (mmresult != MMSYSERR_NOERROR)
- nt_waveinerror("waveInAddBuffer: %s\n", mmresult);
- ntsnd_inphase[nad] = phase = WRAPFWD(phase + 1);
- }
- if (count == MAXRESYNC) post("resync error 1");
- }
- /* Each output buffer which is "ready" is filled with zeros and
- queued. */
- for (nda = 0; nda < nt_nwaveout; nda++)
- {
- int phase = ntsnd_outphase[nda];
- for (count = 0; count < MAXRESYNC; count++)
- {
- WAVEHDR *outwavehdr = ntsnd_outvec[nda][phase].lpWaveHdr;
- if (!(outwavehdr->dwFlags & WHDR_DONE)) break;
- if (outwavehdr->dwFlags & WHDR_PREPARED)
- waveOutUnprepareHeader(ntsnd_outdev[nda],
- outwavehdr, sizeof(WAVEHDR));
- outwavehdr->dwFlags = 0L;
- memset((char *)(ntsnd_outvec[nda][phase].lpData),
- 0, (CHANNELS_PER_DEVICE * SAMPSIZE * nt_realdacblksize));
- waveOutPrepareHeader(ntsnd_outdev[nda], outwavehdr,
- sizeof(WAVEHDR));
- mmresult = waveOutWrite(ntsnd_outdev[nda], outwavehdr,
- sizeof(WAVEHDR));
- if (mmresult != MMSYSERR_NOERROR)
- nt_waveouterror("waveOutAddBuffer: %s\n", mmresult);
- ntsnd_outphase[nda] = phase = WRAPFWD(phase + 1);
- }
- if (count == MAXRESYNC) post("resync error 2");
- }
-
-#ifdef MIDI_TIMESTAMP
- nt_resetmidisync();
-#endif
-
-}
-
-#define LATE 0
-#define RESYNC 1
-#define NOTHING 2
-static int nt_errorcount;
-static int nt_resynccount;
-static double nt_nextreporttime = -1;
-
-void nt_logerror(int which)
-{
-#if 0
- post("error %d %d", count, which);
- if (which < NOTHING) nt_errorcount++;
- if (which == RESYNC) nt_resynccount++;
- if (sys_getrealtime() > nt_nextreporttime)
- {
- post("%d audio I/O error%s", nt_errorcount,
- (nt_errorcount > 1 ? "s" : ""));
- if (nt_resynccount) post("DAC/ADC sync error");
- nt_errorcount = nt_resynccount = 0;
- nt_nextreporttime = sys_getrealtime() - 5;
- }
-#endif
-}
-
-/* system buffer with t_sample types for one tick */
-t_sample *sys_soundout;
-t_sample *sys_soundin;
-float sys_dacsr;
-
-int mmio_send_dacs(void)
-{
- HMMIO hmmio;
- UINT mmresult;
- HANDLE hFormat;
- int i, j;
- short *sp1, *sp2;
- float *fp1, *fp2;
- int nextfill, doxfer = 0;
- int nda, nad;
- if (!nt_nwavein && !nt_nwaveout) return (0);
-
-
- if (nt_meters)
- {
- int i, n;
- float maxsamp;
- for (i = 0, n = 2 * nt_nwavein * DEFDACBLKSIZE, maxsamp = nt_inmax;
- i < n; i++)
- {
- float f = sys_soundin[i];
- if (f > maxsamp) maxsamp = f;
- else if (-f > maxsamp) maxsamp = -f;
- }
- nt_inmax = maxsamp;
- for (i = 0, n = 2 * nt_nwaveout * DEFDACBLKSIZE, maxsamp = nt_outmax;
- i < n; i++)
- {
- float f = sys_soundout[i];
- if (f > maxsamp) maxsamp = f;
- else if (-f > maxsamp) maxsamp = -f;
- }
- nt_outmax = maxsamp;
- }
-
- /* the "fill pointer" nt_fill controls where in the next
- I/O buffers we will write and/or read. If it's zero, we
- first check whether the buffers are marked "done". */
-
- if (!nt_fill)
- {
- for (nad = 0; nad < nt_nwavein; nad++)
- {
- int phase = ntsnd_inphase[nad];
- WAVEHDR *inwavehdr = ntsnd_invec[nad][phase].lpWaveHdr;
- if (!(inwavehdr->dwFlags & WHDR_DONE)) goto idle;
- }
- for (nda = 0; nda < nt_nwaveout; nda++)
- {
- int phase = ntsnd_outphase[nda];
- WAVEHDR *outwavehdr =
- ntsnd_outvec[nda][phase].lpWaveHdr;
- if (!(outwavehdr->dwFlags & WHDR_DONE)) goto idle;
- }
- for (nad = 0; nad < nt_nwavein; nad++)
- {
- int phase = ntsnd_inphase[nad];
- WAVEHDR *inwavehdr =
- ntsnd_invec[nad][phase].lpWaveHdr;
- if (inwavehdr->dwFlags & WHDR_PREPARED)
- waveInUnprepareHeader(ntsnd_indev[nad],
- inwavehdr, sizeof(WAVEHDR));
- }
- for (nda = 0; nda < nt_nwaveout; nda++)
- {
- int phase = ntsnd_outphase[nda];
- WAVEHDR *outwavehdr = ntsnd_outvec[nda][phase].lpWaveHdr;
- if (outwavehdr->dwFlags & WHDR_PREPARED)
- waveOutUnprepareHeader(ntsnd_outdev[nda],
- outwavehdr, sizeof(WAVEHDR));
- }
- }
-
- /* Convert audio output to fixed-point and put it in the output
- buffer. */
- for (nda = 0, fp1 = sys_soundout; nda < nt_nwaveout; nda++)
- {
- int phase = ntsnd_outphase[nda];
-
- for (i = 0, sp1 = (short *)(ntsnd_outvec[nda][phase].lpData) +
- CHANNELS_PER_DEVICE * nt_fill;
- i < 2; i++, fp1 += DEFDACBLKSIZE, sp1++)
- {
- for (j = 0, fp2 = fp1, sp2 = sp1; j < DEFDACBLKSIZE;
- j++, fp2++, sp2 += CHANNELS_PER_DEVICE)
- {
- int x1 = 32767.f * *fp2;
- if (x1 > 32767) x1 = 32767;
- else if (x1 < -32767) x1 = -32767;
- *sp2 = x1;
- }
- }
- }
- memset(sys_soundout, 0,
- (DEFDACBLKSIZE *sizeof(t_sample)*CHANNELS_PER_DEVICE)*nt_nwaveout);
-
- /* vice versa for the input buffer */
-
- for (nad = 0, fp1 = sys_soundin; nad < nt_nwavein; nad++)
- {
- int phase = ntsnd_inphase[nad];
-
- for (i = 0, sp1 = (short *)(ntsnd_invec[nad][phase].lpData) +
- CHANNELS_PER_DEVICE * nt_fill;
- i < 2; i++, fp1 += DEFDACBLKSIZE, sp1++)
- {
- for (j = 0, fp2 = fp1, sp2 = sp1; j < DEFDACBLKSIZE;
- j++, fp2++, sp2 += CHANNELS_PER_DEVICE)
- {
- *fp2 = ((float)(1./32767.)) * (float)(*sp2);
- }
- }
- }
-
- nt_fill = nt_fill + DEFDACBLKSIZE;
- if (nt_fill == nt_realdacblksize)
- {
- nt_fill = 0;
-
- for (nad = 0; nad < nt_nwavein; nad++)
- {
- int phase = ntsnd_inphase[nad];
- HWAVEIN device = ntsnd_indev[nad];
- WAVEHDR *inwavehdr = ntsnd_invec[nad][phase].lpWaveHdr;
- waveInPrepareHeader(device, inwavehdr, sizeof(WAVEHDR));
- mmresult = waveInAddBuffer(device, inwavehdr, sizeof(WAVEHDR));
- if (mmresult != MMSYSERR_NOERROR)
- nt_waveinerror("waveInAddBuffer: %s\n", mmresult);
- ntsnd_inphase[nad] = WRAPFWD(phase + 1);
- }
- for (nda = 0; nda < nt_nwaveout; nda++)
- {
- int phase = ntsnd_outphase[nda];
- HWAVEOUT device = ntsnd_outdev[nda];
- WAVEHDR *outwavehdr = ntsnd_outvec[nda][phase].lpWaveHdr;
- waveOutPrepareHeader(device, outwavehdr, sizeof(WAVEHDR));
- mmresult = waveOutWrite(device, outwavehdr, sizeof(WAVEHDR));
- if (mmresult != MMSYSERR_NOERROR)
- nt_waveouterror("waveOutWrite: %s\n", mmresult);
- ntsnd_outphase[nda] = WRAPFWD(phase + 1);
- }
-
- /* check for DAC underflow or ADC overflow. */
- for (nad = 0; nad < nt_nwavein; nad++)
- {
- int phase = WRAPBACK(ntsnd_inphase[nad] - 2);
- WAVEHDR *inwavehdr = ntsnd_invec[nad][phase].lpWaveHdr;
- if (inwavehdr->dwFlags & WHDR_DONE) goto late;
- }
- for (nda = 0; nda < nt_nwaveout; nda++)
- {
- int phase = WRAPBACK(ntsnd_outphase[nda] - 2);
- WAVEHDR *outwavehdr = ntsnd_outvec[nda][phase].lpWaveHdr;
- if (outwavehdr->dwFlags & WHDR_DONE) goto late;
- }
- }
- return (1);
-
-late:
-
- nt_logerror(LATE);
- nt_resyncaudio();
- return (1);
-
-idle:
-
- /* If more than nt_adcjitterbufsallowed ADC buffers are ready
- on any input device, resynchronize */
-
- for (nad = 0; nad < nt_nwavein; nad++)
- {
- int phase = ntsnd_inphase[nad];
- WAVEHDR *inwavehdr =
- ntsnd_invec[nad]
- [WRAPFWD(phase + nt_adcjitterbufsallowed)].lpWaveHdr;
- if (inwavehdr->dwFlags & WHDR_DONE)
- {
- nt_resyncaudio();
- return (0);
- }
- }
-
- /* test dac sync the same way */
- for (nda = 0; nda < nt_nwaveout; nda++)
- {
- int phase = ntsnd_outphase[nda];
- WAVEHDR *outwavehdr =
- ntsnd_outvec[nda]
- [WRAPFWD(phase + nt_dacjitterbufsallowed)].lpWaveHdr;
- if (outwavehdr->dwFlags & WHDR_DONE)
- {
- nt_resyncaudio();
- return (0);
- }
- }
-#ifdef MIDI_TIMESTAMP
- nt_midisync();
-#endif
- return (0);
-}
-
-/* ------------------- public routines -------------------------- */
-
-void mmio_open_audio(int naudioindev, int *audioindev,
- int nchindev, int *chindev, int naudiooutdev, int *audiooutdev,
- int nchoutdev, int *choutdev, int rate) /* IOhannes */
-{
- int nbuf;
-
- nt_realdacblksize = (sys_blocksize ? sys_blocksize : DEFREALDACBLKSIZE);
- nbuf = sys_advance_samples/nt_realdacblksize;
- if (nbuf >= MAXBUFFER)
- {
- fprintf(stderr, "pd: audio buffering maxed out to %d\n",
- (int)(MAXBUFFER * ((nt_realdacblksize * 1000.)/44100.)));
- nbuf = MAXBUFFER;
- }
- else if (nbuf < 4) nbuf = 4;
- fprintf(stderr, "%d audio buffers\n", nbuf);
- nt_naudiobuffer = nbuf;
- if (nt_adcjitterbufsallowed > nbuf - 2)
- nt_adcjitterbufsallowed = nbuf - 2;
- if (nt_dacjitterbufsallowed > nbuf - 2)
- nt_dacjitterbufsallowed = nbuf - 2;
-
- nt_nwavein = sys_inchannels / 2;
- nt_nwaveout = sys_outchannels / 2;
- nt_whichadc = (naudioindev < 1 ?
- (nt_nwavein > 1 ? WAVE_MAPPER : -1) : audioindev[0]);
- nt_whichdac = (naudiooutdev < 1 ?
- (nt_nwaveout > 1 ? WAVE_MAPPER : -1) : audiooutdev[0]);
- if (naudiooutdev > 1 || naudioindev > 1)
- post("separate audio device choice not supported; using sequential devices.");
- mmio_do_open_audio();
-}
-
-
-void mmio_reportidle(void)
-{
-}
-
-#if 0
-/* list the audio and MIDI device names */
-void mmio_listdevs(void)
-{
- UINT wRtn, ndevices;
- unsigned int i;
-
- ndevices = waveInGetNumDevs();
- for (i = 0; i < ndevices; i++)
- {
- WAVEINCAPS wicap;
- wRtn = waveInGetDevCaps(i, (LPWAVEINCAPS) &wicap,
- sizeof(wicap));
- if (wRtn) nt_waveinerror("waveInGetDevCaps: %s\n", wRtn);
- else fprintf(stderr,
- "audio input device #%d: %s\n", i+1, wicap.szPname);
- }
-
- ndevices = waveOutGetNumDevs();
- for (i = 0; i < ndevices; i++)
- {
- WAVEOUTCAPS wocap;
- wRtn = waveOutGetDevCaps(i, (LPWAVEOUTCAPS) &wocap,
- sizeof(wocap));
- if (wRtn) nt_waveouterror("waveOutGetDevCaps: %s\n", wRtn);
- else fprintf(stderr,
- "audio output device #%d: %s\n", i+1, wocap.szPname);
- }
-}
-#endif
-
-void mmio_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize)
-{
- int wRtn, ndev, i;
-
- *canmulti = 2; /* supports multiple devices */
- ndev = waveInGetNumDevs();
- if (ndev > maxndev)
- ndev = maxndev;
- *nindevs = ndev;
- for (i = 0; i < ndev; i++)
- {
- WAVEINCAPS wicap;
- wRtn = waveInGetDevCaps(i, (LPWAVEINCAPS) &wicap, sizeof(wicap));
- sprintf(indevlist + i * devdescsize, (wRtn ? "???" : wicap.szPname));
- }
-
- ndev = waveOutGetNumDevs();
- if (ndev > maxndev)
- ndev = maxndev;
- *noutdevs = ndev;
- for (i = 0; i < ndev; i++)
- {
- WAVEOUTCAPS wocap;
- wRtn = waveOutGetDevCaps(i, (LPWAVEOUTCAPS) &wocap, sizeof(wocap));
- sprintf(outdevlist + i * devdescsize, (wRtn ? "???" : wocap.szPname));
- }
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_audio_oss.c b/apps/plugins/pdbox/PDa/src/s_audio_oss.c
index efb15d1bc1..de11f66243 100644
--- a/apps/plugins/pdbox/PDa/src/s_audio_oss.c
+++ b/apps/plugins/pdbox/PDa/src/s_audio_oss.c
@@ -842,847 +842,4 @@ void oss_getdevs(char *indevlist, int *nindevs,
}
#endif
-/* Copyright (c) 1997-2003 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. */
-
-/* this file inputs and outputs audio using the OSS API available on linux. */
-
-#ifdef USEAPI_OSS
-
-#include <linux/soundcard.h>
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sched.h>
-#include <sys/mman.h>
-
-
-/* Defines */
-#define DEBUG(x) x
-#define DEBUG2(x) {x;}
-
-#define OSS_MAXCHPERDEV 32 /* max channels per OSS device */
-#define OSS_MAXDEV 4 /* maximum number of input or output devices */
-#define OSS_DEFFRAGSIZE 256 /* default log fragment size (frames) */
-#define OSS_DEFAUDIOBUF 40000 /* default audiobuffer, microseconds */
-#define OSS_DEFAULTCH 2
-#define RME_DEFAULTCH 8 /* need this even if RME undefined */
-typedef int16_t t_oss_int16;
-typedef int32_t t_oss_int32;
-#define OSS_MAXSAMPLEWIDTH sizeof(t_oss_int32)
-#define OSS_BYTESPERCHAN(width) (DEFDACBLKSIZE * (width))
-#define OSS_XFERSAMPS(chans) (DEFDACBLKSIZE* (chans))
-#define OSS_XFERSIZE(chans, width) (DEFDACBLKSIZE * (chans) * (width))
-
-/* GLOBALS */
-static int linux_meters; /* true if we're metering */
-static float linux_inmax; /* max input amplitude */
-static float linux_outmax; /* max output amplitude */
-static int linux_fragsize = 0; /* for block mode; block size (sample frames) */
-
-/* our device handles */
-
-typedef struct _oss_dev
-{
- int d_fd;
- unsigned int d_space; /* bytes available for writing/reading */
- int d_bufsize; /* total buffer size in blocks for this device */
- int d_dropcount; /* # of buffers to drop for resync (output only) */
- unsigned int d_nchannels; /* number of channels for this device */
- unsigned int d_bytespersamp; /* bytes per sample (2 for 16 bit, 4 for 32) */
-} t_oss_dev;
-
-static t_oss_dev linux_dacs[OSS_MAXDEV];
-static t_oss_dev linux_adcs[OSS_MAXDEV];
-static int linux_noutdevs = 0;
-static int linux_nindevs = 0;
-
- /* exported variables */
-float sys_dacsr;
-t_sample *sys_soundout;
-t_sample *sys_soundin;
-
- /* OSS-specific private variables */
-static int oss_blockmode = 1; /* flag to use "blockmode" */
-static int oss_32bit = 0; /* allow 23 bit transfers in OSS */
-static char ossdsp[] = "/dev/dsp%d";
-
- /* don't assume we can turn all 31 bits when doing float-to-fix;
- otherwise some audio drivers (e.g. Midiman/ALSA) wrap around. */
-#define FMAX 0x7ffff000
-#define CLIP32(x) (((x)>FMAX)?FMAX:((x) < -FMAX)?-FMAX:(x))
-
-
-/* ------------- private routines for all APIS ------------------- */
-
-static void linux_flush_all_underflows_to_zero(void)
-{
-/*
- TODO: Implement similar thing for linux (GGeiger)
-
- One day we will figure this out, I hope, because it
- costs CPU time dearly on Intel - LT
- */
- /* union fpc_csr f;
- f.fc_word = get_fpc_csr();
- f.fc_struct.flush = 1;
- set_fpc_csr(f.fc_word);
- */
-}
-
-static int oss_ndev = 0;
-
- /* find out how many OSS devices we have. Since this has to
- open the devices to find out if they're there, we have
- to be called before audio is actually started up. So we
- cache the results, which in effect are the number of available
- devices. */
-void oss_init(void)
-{
- int fd, i;
- static int countedthem = 0;
- if (countedthem)
- return;
- for (i = 0; i < 10; i++)
- {
- char devname[100];
- if (i == 0)
- strcpy(devname, "/dev/dsp");
- else sprintf(devname, "/dev/dsp%d", i);
- if ( (fd = open(devname, O_WRONLY|O_NONBLOCK)) != -1)
- {
- oss_ndev++;
- close(fd);
- }
- else break;
- }
- countedthem = 1;
-}
-
-
-void oss_set32bit( void)
-{
- oss_32bit = 1;
-}
-
-
-typedef struct _multidev {
- int fd;
- int channels;
- int format;
-} t_multidev;
-
-int oss_reset(int fd) {
- int err;
- if ((err = ioctl(fd,SNDCTL_DSP_RESET)) < 0)
- error("OSS: Could not reset");
- return err;
-}
-
- /* The AFMT_S32_BLOCKED format is not defined in standard linux kernels
- but is proposed by Guenter Geiger to support extending OSS to handle
- 32 bit sample. This is user in Geiger's OSS driver for RME Hammerfall.
- I'm not clear why this isn't called AFMT_S32_[SLN]E... */
-
-#ifndef AFMT_S32_BLOCKED
-#define AFMT_S32_BLOCKED 0x0000400
-#endif
-
-void oss_configure(t_oss_dev *dev, int srate, int dac, int skipblocksize)
-{ /* IOhannes */
- int orig, param, nblk, fd = dev->d_fd, wantformat;
- int nchannels = dev->d_nchannels;
- int advwas = sys_schedadvance;
-
- audio_buf_info ainfo;
-
- /* IOhannes :
- * pd is very likely to crash if different formats are used on
- multiple soundcards
- */
-
- /* set resolution - first try 4 byte samples */
- if (oss_32bit && (ioctl(fd,SNDCTL_DSP_GETFMTS,&param) >= 0) &&
- (param & AFMT_S32_BLOCKED))
- {
- wantformat = AFMT_S32_BLOCKED;
- dev->d_bytespersamp = 4;
- }
- else
- {
- wantformat = AFMT_S16_NE;
- dev->d_bytespersamp = 2;
- }
- param = wantformat;
-
- if (sys_verbose)
- post("bytes per sample = %d", dev->d_bytespersamp);
- if (ioctl(fd, SNDCTL_DSP_SETFMT, &param) == -1)
- fprintf(stderr,"OSS: Could not set DSP format\n");
- else if (wantformat != param)
- fprintf(stderr,"OSS: DSP format: wanted %d, got %d\n",
- wantformat, param);
-
- /* sample rate */
- orig = param = srate;
- if (ioctl(fd, SNDCTL_DSP_SPEED, &param) == -1)
- fprintf(stderr,"OSS: Could not set sampling rate for device\n");
- else if( orig != param )
- fprintf(stderr,"OSS: sampling rate: wanted %d, got %d\n",
- orig, param );
-
- if (oss_blockmode && !skipblocksize)
- {
- int fragbytes, logfragsize, nfragment;
- /* setting fragment count and size. */
- if (!linux_fragsize)
- {
- linux_fragsize = OSS_DEFFRAGSIZE;
- while (linux_fragsize > DEFDACBLKSIZE
- && linux_fragsize * 4 > sys_advance_samples)
- linux_fragsize = linux_fragsize/2;
- }
-
- /* post("adv_samples %d", sys_advance_samples); */
- nfragment = (sys_schedadvance * (44100. * 1.e-6)) / linux_fragsize;
-
- fragbytes = linux_fragsize * (dev->d_bytespersamp * nchannels);
- logfragsize = ilog2(fragbytes);
-
- if (fragbytes != (1 << logfragsize))
- post("warning: OSS takes only power of 2 blocksize; using %d",
- (1 << logfragsize)/(dev->d_bytespersamp * nchannels));
- if (sys_verbose)
- post("setting nfrags = %d, fragsize %d\n", nfragment, fragbytes);
-
- param = orig = (nfragment<<16) + logfragsize;
- if (ioctl(fd,SNDCTL_DSP_SETFRAGMENT, &param) == -1)
- error("OSS: Could not set or read fragment size\n");
- if (param != orig)
- {
- nfragment = ((param >> 16) & 0xffff);
- logfragsize = (param & 0xffff);
- post("warning: actual fragments %d, blocksize %d",
- nfragment, (1 << logfragsize));
- }
- if (sys_verbose)
- post("audiobuffer set to %d msec", (int)(0.001 * sys_schedadvance));
- }
- if (dac)
- {
- /* use "free space" to learn the buffer size. Normally you
- should set this to your own desired value; but this seems not
- to be implemented uniformly across different sound cards. LATER
- we should figure out what to do if the requested scheduler advance
- is greater than this buffer size; for now, we just print something
- out. */
-
- int defect;
- if (ioctl(fd, SOUND_PCM_GETOSPACE,&ainfo) < 0)
- fprintf(stderr,"OSS: ioctl on output device failed");
- dev->d_bufsize = ainfo.bytes;
-
- defect = sys_advance_samples * (dev->d_bytespersamp * nchannels)
- - dev->d_bufsize - OSS_XFERSIZE(nchannels, dev->d_bytespersamp);
- if (defect > 0)
- {
- if (sys_verbose || defect > (dev->d_bufsize >> 2))
- fprintf(stderr,
- "OSS: requested audio buffer size %d limited to %d\n",
- sys_advance_samples * (dev->d_bytespersamp * nchannels),
- dev->d_bufsize);
- sys_advance_samples =
- (dev->d_bufsize - OSS_XFERSAMPS(nchannels)) /
- (dev->d_bytespersamp *nchannels);
- }
- }
-}
-
-static int oss_setchannels(int fd, int wantchannels, char *devname)
-{ /* IOhannes */
- int param = wantchannels;
- while (param>1) {
- int save = param;
- if (ioctl(fd, SNDCTL_DSP_CHANNELS, &param) == -1) {
- error("OSS: SNDCTL_DSP_CHANNELS failed %s",devname);
- } else {
- if (param == save) return (param);
- }
- param=save-1;
- }
-
- return (0);
-}
-
-#define O_AUDIOFLAG 0 /* O_NDELAY */
-
-int oss_open_audio(int nindev, int *indev, int nchin, int *chin,
- int noutdev, int *outdev, int nchout, int *chout, int rate)
-{ /* IOhannes */
- int capabilities = 0;
- int inchannels = 0, outchannels = 0;
- char devname[20];
- int n, i, fd;
- char buf[OSS_MAXSAMPLEWIDTH * DEFDACBLKSIZE * OSS_MAXCHPERDEV];
- int num_devs = 0;
- int wantmore=0;
- int spread = 0;
- audio_buf_info ainfo;
-
- linux_nindevs = linux_noutdevs = 0;
-
-
- /* mark input devices unopened */
- for (i = 0; i < OSS_MAXDEV; i++)
- linux_adcs[i].d_fd = -1;
-
- /* open output devices */
- wantmore=0;
- if (noutdev < 0 || nindev < 0)
- bug("linux_open_audio");
-
- for (n = 0; n < noutdev; n++)
- {
- int gotchans, j, inindex = -1;
- int thisdevice = (outdev[n] >= 0 ? outdev[n] : n-1);
- int wantchannels = (nchout>n) ? chout[n] : wantmore;
- fd = -1;
- if (!wantchannels)
- goto end_out_loop;
-
- if (thisdevice > 1)
- sprintf(devname, "/dev/dsp%d", thisdevice-1);
- else sprintf(devname, "/dev/dsp");
-
- /* search for input request for same device. Succeed only
- if the number of channels matches. */
- for (j = 0; j < nindev; j++)
- if (indev[j] == thisdevice && chin[j] == wantchannels)
- inindex = j;
-
- /* if the same device is requested for input and output,
- try to open it read/write */
- if (inindex >= 0)
- {
- sys_setalarm(1000000);
- if ((fd = open(devname, O_RDWR | O_AUDIOFLAG)) == -1)
- {
- post("%s (read/write): %s", devname, strerror(errno));
- post("(now will try write-only...)");
- }
- else
- {
- if (sys_verbose)
- post("opened %s for reading and writing\n", devname);
- linux_adcs[inindex].d_fd = fd;
- }
- }
- /* if that didn't happen or if it failed, try write-only */
- if (fd == -1)
- {
- sys_setalarm(1000000);
- if ((fd = open(devname, O_WRONLY | O_AUDIOFLAG)) == -1)
- {
- post("%s (writeonly): %s",
- devname, strerror(errno));
- break;
- }
- if (sys_verbose)
- post("opened %s for writing only\n", devname);
- }
- if (ioctl(fd, SNDCTL_DSP_GETCAPS, &capabilities) == -1)
- error("OSS: SNDCTL_DSP_GETCAPS failed %s", devname);
-
- gotchans = oss_setchannels(fd,
- (wantchannels>OSS_MAXCHPERDEV)?OSS_MAXCHPERDEV:wantchannels,
- devname);
-
- if (sys_verbose)
- post("opened audio output on %s; got %d channels",
- devname, gotchans);
-
- if (gotchans < 2)
- {
- /* can't even do stereo? just give up. */
- close(fd);
- }
- else
- {
- linux_dacs[linux_noutdevs].d_nchannels = gotchans;
- linux_dacs[linux_noutdevs].d_fd = fd;
- oss_configure(linux_dacs+linux_noutdevs, rate, 1, 0);
-
- linux_noutdevs++;
- outchannels += gotchans;
- if (inindex >= 0)
- {
- linux_adcs[inindex].d_nchannels = gotchans;
- chin[inindex] = gotchans;
- }
- }
- /* LATER think about spreading large numbers of channels over
- various dsp's and vice-versa */
- wantmore = wantchannels - gotchans;
- end_out_loop: ;
- }
-
- /* open input devices */
- wantmore = 0;
- for (n = 0; n < nindev; n++)
- {
- int gotchans=0;
- int thisdevice = (indev[n] >= 0 ? indev[n] : n-1);
- int wantchannels = (nchin>n)?chin[n]:wantmore;
- int alreadyopened = 0;
- if (!wantchannels)
- goto end_in_loop;
-
- if (thisdevice > 1)
- sprintf(devname, "/dev/dsp%d", thisdevice - 1);
- else sprintf(devname, "/dev/dsp");
-
- sys_setalarm(1000000);
-
- /* perhaps it's already open from the above? */
- if (linux_dacs[n].d_fd >= 0)
- {
- fd = linux_dacs[n].d_fd;
- alreadyopened = 1;
- }
- else
- {
- /* otherwise try to open it here. */
- if ((fd = open(devname, O_RDONLY | O_AUDIOFLAG)) == -1)
- {
- post("%s (readonly): %s", devname, strerror(errno));
- goto end_in_loop;
- }
- if (sys_verbose)
- post("opened %s for reading only\n", devname);
- }
- linux_adcs[linux_nindevs].d_fd = fd;
- gotchans = oss_setchannels(fd,
- (wantchannels>OSS_MAXCHPERDEV)?OSS_MAXCHPERDEV:wantchannels,
- devname);
- if (sys_verbose)
- post("opened audio input device %s; got %d channels",
- devname, gotchans);
-
- if (gotchans < 1)
- {
- close(fd);
- goto end_in_loop;
- }
-
- linux_adcs[linux_nindevs].d_nchannels = gotchans;
-
- oss_configure(linux_adcs+linux_nindevs, rate, 0, alreadyopened);
-
- inchannels += gotchans;
- linux_nindevs++;
-
- wantmore = wantchannels-gotchans;
- /* LATER think about spreading large numbers of channels over
- various dsp's and vice-versa */
- end_in_loop: ;
- }
-
- /* We have to do a read to start the engine. This is
- necessary because sys_send_dacs waits until the input
- buffer is filled and only reads on a filled buffer.
- This is good, because it's a way to make sure that we
- will not block. But I wonder why we only have to read
- from one of the devices and not all of them??? */
-
- if (linux_nindevs)
- {
- if (sys_verbose)
- fprintf(stderr,("OSS: issuing first ADC 'read' ... "));
- read(linux_adcs[0].d_fd, buf,
- linux_adcs[0].d_bytespersamp *
- linux_adcs[0].d_nchannels * DEFDACBLKSIZE);
- if (sys_verbose)
- fprintf(stderr, "...done.\n");
- }
- sys_setalarm(0);
- return (0);
-}
-
-void oss_close_audio( void)
-{
- int i;
- for (i=0;i<linux_nindevs;i++)
- close(linux_adcs[i].d_fd);
-
- for (i=0;i<linux_noutdevs;i++)
- close(linux_dacs[i].d_fd);
-
- linux_nindevs = linux_noutdevs = 0;
-}
-
-static int linux_dacs_write(int fd,void* buf,long bytes)
-{
- return write(fd, buf, bytes);
-}
-
-static int linux_adcs_read(int fd,void* buf,long bytes)
-{
- return read(fd, buf, bytes);
-}
-
- /* query audio devices for "available" data size. */
-static void oss_calcspace(void)
-{
- int dev;
- audio_buf_info ainfo;
- for (dev=0; dev < linux_noutdevs; dev++)
- {
- if (ioctl(linux_dacs[dev].d_fd, SOUND_PCM_GETOSPACE, &ainfo) < 0)
- fprintf(stderr,"OSS: ioctl on output device %d failed",dev);
- linux_dacs[dev].d_space = ainfo.bytes;
- }
-
- for (dev = 0; dev < linux_nindevs; dev++)
- {
- if (ioctl(linux_adcs[dev].d_fd, SOUND_PCM_GETISPACE,&ainfo) < 0)
- fprintf(stderr, "OSS: ioctl on input device %d, fd %d failed",
- dev, linux_adcs[dev].d_fd);
- linux_adcs[dev].d_space = ainfo.bytes;
- }
-}
-
-void linux_audiostatus(void)
-{
- int dev;
- if (!oss_blockmode)
- {
- oss_calcspace();
- for (dev=0; dev < linux_noutdevs; dev++)
- fprintf(stderr, "dac %d space %d\n", dev, linux_dacs[dev].d_space);
-
- for (dev = 0; dev < linux_nindevs; dev++)
- fprintf(stderr, "adc %d space %d\n", dev, linux_adcs[dev].d_space);
-
- }
-}
-
-/* this call resyncs audio output and input which will cause discontinuities
-in audio output and/or input. */
-
-static void oss_doresync( void)
-{
- int dev, zeroed = 0, wantsize;
- char buf[OSS_MAXSAMPLEWIDTH * DEFDACBLKSIZE * OSS_MAXCHPERDEV];
- audio_buf_info ainfo;
-
- /* 1. if any input devices are ahead (have more than 1 buffer stored),
- drop one or more buffers worth */
- for (dev = 0; dev < linux_nindevs; dev++)
- {
- if (linux_adcs[dev].d_space == 0)
- {
- linux_adcs_read(linux_adcs[dev].d_fd, buf,
- OSS_XFERSIZE(linux_adcs[dev].d_nchannels,
- linux_adcs[dev].d_bytespersamp));
- }
- else while (linux_adcs[dev].d_space >
- OSS_XFERSIZE(linux_adcs[dev].d_nchannels,
- linux_adcs[dev].d_bytespersamp))
- {
- linux_adcs_read(linux_adcs[dev].d_fd, buf,
- OSS_XFERSIZE(linux_adcs[dev].d_nchannels,
- linux_adcs[dev].d_bytespersamp));
- if (ioctl(linux_adcs[dev].d_fd, SOUND_PCM_GETISPACE, &ainfo) < 0)
- {
- fprintf(stderr, "OSS: ioctl on input device %d, fd %d failed",
- dev, linux_adcs[dev].d_fd);
- break;
- }
- linux_adcs[dev].d_space = ainfo.bytes;
- }
- }
-
- /* 2. if any output devices are behind, feed them zeros to catch them
- up */
- for (dev = 0; dev < linux_noutdevs; dev++)
- {
- while (linux_dacs[dev].d_space > linux_dacs[dev].d_bufsize -
- sys_advance_samples * (linux_dacs[dev].d_nchannels *
- linux_dacs[dev].d_bytespersamp))
- {
- if (!zeroed)
- {
- unsigned int i;
- for (i = 0; i < OSS_XFERSAMPS(linux_dacs[dev].d_nchannels);
- i++)
- buf[i] = 0;
- zeroed = 1;
- }
- linux_dacs_write(linux_dacs[dev].d_fd, buf,
- OSS_XFERSIZE(linux_dacs[dev].d_nchannels,
- linux_dacs[dev].d_bytespersamp));
- if (ioctl(linux_dacs[dev].d_fd, SOUND_PCM_GETOSPACE, &ainfo) < 0)
- {
- fprintf(stderr, "OSS: ioctl on output device %d, fd %d failed",
- dev, linux_dacs[dev].d_fd);
- break;
- }
- linux_dacs[dev].d_space = ainfo.bytes;
- }
- }
- /* 3. if any DAC devices are too far ahead, plan to drop the
- number of frames which will let the others catch up. */
- for (dev = 0; dev < linux_noutdevs; dev++)
- {
- if (linux_dacs[dev].d_space > linux_dacs[dev].d_bufsize -
- (sys_advance_samples - 1) * linux_dacs[dev].d_nchannels *
- linux_dacs[dev].d_bytespersamp)
- {
- linux_dacs[dev].d_dropcount = sys_advance_samples - 1 -
- (linux_dacs[dev].d_space - linux_dacs[dev].d_bufsize) /
- (linux_dacs[dev].d_nchannels *
- linux_dacs[dev].d_bytespersamp) ;
- }
- else linux_dacs[dev].d_dropcount = 0;
- }
-}
-
-int oss_send_dacs(void)
-{
- t_sample *fp1, *fp2;
- long fill;
- int i, j, dev, rtnval = SENDDACS_YES;
- char buf[OSS_MAXSAMPLEWIDTH * DEFDACBLKSIZE * OSS_MAXCHPERDEV];
- t_oss_int16 *sp;
- t_oss_int32 *lp;
- /* the maximum number of samples we should have in the ADC buffer */
- int idle = 0;
- int thischan;
- t_time timeref, timenow;
-
- if (!linux_nindevs && !linux_noutdevs)
- return (SENDDACS_NO);
-
- if (!oss_blockmode)
- {
- /* determine whether we're idle. This is true if either (1)
- some input device has less than one buffer to read or (2) some
- output device has fewer than (sys_advance_samples) blocks buffered
- already. */
- oss_calcspace();
-
- for (dev=0; dev < linux_noutdevs; dev++)
- if (linux_dacs[dev].d_dropcount ||
- (linux_dacs[dev].d_bufsize - linux_dacs[dev].d_space >
- sys_advance_samples * linux_dacs[dev].d_bytespersamp *
- linux_dacs[dev].d_nchannels))
- idle = 1;
- for (dev=0; dev < linux_nindevs; dev++)
- if (linux_adcs[dev].d_space <
- OSS_XFERSIZE(linux_adcs[dev].d_nchannels,
- linux_adcs[dev].d_bytespersamp))
- idle = 1;
- }
-
- if (idle && !oss_blockmode)
- {
- /* sometimes---rarely---when the ADC available-byte-count is
- zero, it's genuine, but usually it's because we're so
- late that the ADC has overrun its entire kernel buffer. We
- distinguish between the two by waiting 2 msec and asking again.
- There should be an error flag we could check instead; look for this
- someday... */
- for (dev = 0;dev < linux_nindevs; dev++)
- if (linux_adcs[dev].d_space == 0)
- {
- audio_buf_info ainfo;
- sys_microsleep(2000);
- oss_calcspace();
- if (linux_adcs[dev].d_space != 0) continue;
-
- /* here's the bad case. Give up and resync. */
- sys_log_error(ERR_DATALATE);
- oss_doresync();
- return (SENDDACS_NO);
- }
- /* check for slippage between devices, either because
- data got lost in the driver from a previous late condition, or
- because the devices aren't synced. When we're idle, no
- input device should have more than one buffer readable and
- no output device should have less than sys_advance_samples-1
- */
-
- for (dev=0; dev < linux_noutdevs; dev++)
- if (!linux_dacs[dev].d_dropcount &&
- (linux_dacs[dev].d_bufsize - linux_dacs[dev].d_space <
- (sys_advance_samples - 2) *
- (linux_dacs[dev].d_bytespersamp *
- linux_dacs[dev].d_nchannels)))
- goto badsync;
- for (dev=0; dev < linux_nindevs; dev++)
- if (linux_adcs[dev].d_space > 3 *
- OSS_XFERSIZE(linux_adcs[dev].d_nchannels,
- linux_adcs[dev].d_bytespersamp))
- goto badsync;
-
- /* return zero to tell the scheduler we're idle. */
- return (SENDDACS_NO);
- badsync:
- sys_log_error(ERR_RESYNC);
- oss_doresync();
- return (SENDDACS_NO);
-
- }
-
-
- /* do output */
-
- timeref = sys_getrealtime();
- for (dev=0, thischan = 0; dev < linux_noutdevs; dev++)
- {
- int nchannels = linux_dacs[dev].d_nchannels;
- if (linux_dacs[dev].d_dropcount)
- linux_dacs[dev].d_dropcount--;
- else
- {
- if (linux_dacs[dev].d_bytespersamp == 4)
- {
- for (i = DEFDACBLKSIZE * nchannels, fp1 = sys_soundout +
- DEFDACBLKSIZE*thischan,
- lp = (t_oss_int32 *)buf; i--; fp1++, lp++)
- {
- t_sample f = SCALE32(*fp1);
- *lp = (f >= 2147483647 ? 2147483647 :
- (f < -2147483647 ? -2147483647 : f));
- }
- }
- else
- {
- for (i = DEFDACBLKSIZE, fp1 = sys_soundout +
- DEFDACBLKSIZE*thischan,
- sp = (t_oss_int16 *)buf; i--; fp1++, sp += nchannels)
- {
- for (j=0, fp2 = fp1; j<nchannels; j++, fp2 += DEFDACBLKSIZE)
- {
- int s = SCALE16(*fp2);
- if (s > 32767) s = 32767;
- else if (s < -32767) s = -32767;
- sp[j] = s;
- }
- }
- }
-
-
-#if 0
-#define PR_S "%8d"
- {
- int nm = 64;
- int* sp1 = buf;
- post("dac:");
- while (nm > 0)
- {
- post(PR_S PR_S PR_S PR_S PR_S PR_S PR_S PR_S,
- sp1[0], sp1[1], sp1[2], sp1[3], sp1[4], sp1[5], sp1[6], sp1[7]);
- nm -= 8;
- sp1 += 8;
- }
- }
-#endif
- linux_dacs_write(linux_dacs[dev].d_fd, buf,
- OSS_XFERSIZE(nchannels, linux_dacs[dev].d_bytespersamp));
-
-#if 0
- if ((timenow = sys_getrealtime()) - timeref > 200)
- {
- post("dacslept %d",sys_getrealtime() - timeref);
- if (!oss_blockmode)
- sys_log_error(ERR_DACSLEPT);
- else rtnval = SENDDACS_SLEPT;
- }
-#endif
- timeref = timenow;
- }
- thischan += nchannels;
- }
- memset(sys_soundout, 0,
- sys_outchannels * (sizeof(float) * DEFDACBLKSIZE));
-
- /* do input */
-
- for (dev = 0, thischan = 0; dev < linux_nindevs; dev++)
- {
- int nchannels = linux_adcs[dev].d_nchannels;
- linux_adcs_read(linux_adcs[dev].d_fd, buf,
- OSS_XFERSIZE(nchannels, linux_adcs[dev].d_bytespersamp));
-
-#if 0
- if ((timenow = sys_getrealtime()) - timeref > 200)
- {
- if (!oss_blockmode)
- sys_log_error(ERR_ADCSLEPT);
- else
- rtnval = SENDDACS_SLEPT;
- }
-#endif
- timeref = timenow;
-
- if (linux_adcs[dev].d_bytespersamp == 4)
- {
- for (i = DEFDACBLKSIZE*nchannels,
- fp1 = sys_soundin + thischan*DEFDACBLKSIZE,
- lp = (t_oss_int32 *)buf; i--; fp1++, lp++)
- {
- *fp1 = ((t_sample)(*lp))*(t_sample)(1./2147483648.);
- }
- }
- else
- {
- for (i = DEFDACBLKSIZE,fp1 = sys_soundin + thischan*DEFDACBLKSIZE,
- sp = (t_oss_int16 *)buf; i--; fp1++, sp += nchannels)
- {
- for (j=0;j<sys_inchannels;j++)
- fp1[j*DEFDACBLKSIZE] = INVSCALE16(sp[j]);
- }
- }
- thischan += nchannels;
- }
- if (thischan != sys_inchannels)
- bug("inchannels");
- return (rtnval);
-}
-
-void oss_listdevs( void)
-{
- post("device listing not implemented in OSS yet\n");
-}
-
-void oss_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize)
-{
- int i, ndev;
- *canmulti = 2; /* supports multiple devices */
- if ((ndev = oss_ndev) > maxndev)
- ndev = maxndev;
- for (i = 0; i < ndev; i++)
- {
- sprintf(indevlist + i * devdescsize, "OSS device #%d", i+1);
- sprintf(outdevlist + i * devdescsize, "OSS device #%d", i+1);
- }
- *nindevs = *noutdevs = ndev;
-}
-
-#endif
diff --git a/apps/plugins/pdbox/PDa/src/s_audio_pa.c b/apps/plugins/pdbox/PDa/src/s_audio_pa.c
index ebae9679dc..943b57e212 100644
--- a/apps/plugins/pdbox/PDa/src/s_audio_pa.c
+++ b/apps/plugins/pdbox/PDa/src/s_audio_pa.c
@@ -290,295 +290,4 @@ void pa_getdevs(char *indevlist, int *nindevs,
*nindevs = nin;
*noutdevs = nout;
}
-/* Copyright (c) 2001 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* this file calls Ross Bencina's and Phil Burk's Portaudio package. It's
- the main way in for Mac OS and, with Michael Casey's help, also into
- ASIO in Windows. */
-
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include "portaudio.h"
-#include "pablio_pd.h"
-
- /* LATER try to figure out how to handle default devices in portaudio;
- the way s_audio.c handles them isn't going to work here. */
-
-#if defined(MACOSX) || defined(MSW)
-#define Pa_GetDefaultInputDevice Pa_GetDefaultInputDeviceID
-#define Pa_GetDefaultOutputDevice Pa_GetDefaultOutputDeviceID
-#endif
-
- /* public interface declared in m_imp.h */
-
- /* implementation */
-static PABLIO_Stream *pa_stream;
-static int pa_inchans, pa_outchans;
-static float *pa_soundin, *pa_soundout;
-
-#define MAX_PA_CHANS 32
-#define MAX_SAMPLES_PER_FRAME MAX_PA_CHANS * DEFDACBLKSIZE
-
-int pa_open_audio(int inchans, int outchans, int rate, t_sample *soundin,
- t_sample *soundout, int framesperbuf, int nbuffers,
- int indeviceno, int outdeviceno)
-{
- PaError err;
- static int initialized;
- int j, devno, pa_indev = 0, pa_outdev = 0;
-
- if (!initialized)
- {
- /* Initialize PortAudio */
- int err = Pa_Initialize();
- if ( err != paNoError )
- {
- fprintf( stderr,
- "Error number %d occured initializing portaudio\n",
- err);
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return (1);
- }
- initialized = 1;
- }
- /* post("in %d out %d rate %d device %d", inchans, outchans, rate, deviceno); */
- if (inchans != 0 && outchans != 0 && inchans != outchans)
- error("portaudio: number of input and output channels must match");
- if (inchans > MAX_PA_CHANS)
- {
- post("input channels reduced to maximum %d", MAX_PA_CHANS);
- inchans = MAX_PA_CHANS;
- }
- if (outchans > MAX_PA_CHANS)
- {
- post("output channels reduced to maximum %d", MAX_PA_CHANS);
- outchans = MAX_PA_CHANS;
- }
-
- if (inchans > 0)
- {
- for (j = 0, devno = 0; j < Pa_CountDevices(); j++)
- {
- const PaDeviceInfo *info = Pa_GetDeviceInfo(j);
- if (info->maxInputChannels > 0)
- {
- if (devno == indeviceno)
- {
- pa_indev = j;
- break;
- }
- devno++;
- }
- }
- }
-
- if (outchans > 0)
- {
- for (j = 0, devno = 0; j < Pa_CountDevices(); j++)
- {
- const PaDeviceInfo *info = Pa_GetDeviceInfo(j);
- if (info->maxOutputChannels > 0)
- {
- if (devno == outdeviceno)
- {
- pa_outdev = j;
- break;
- }
- devno++;
- }
- }
- }
- if (sys_verbose)
- {
- post("input device %d, channels %d", pa_indev, inchans);
- post("output device %d, channels %d", pa_outdev, outchans);
- post("framesperbuf %d, nbufs %d", framesperbuf, nbuffers);
- }
- if (inchans && outchans)
- err = OpenAudioStream( &pa_stream, rate, paFloat32,
- PABLIO_READ_WRITE, inchans, framesperbuf, nbuffers,
- pa_indev, pa_outdev);
- else if (inchans)
- err = OpenAudioStream( &pa_stream, rate, paFloat32,
- PABLIO_READ, inchans, framesperbuf, nbuffers,
- pa_indev, pa_outdev);
- else if (outchans)
- err = OpenAudioStream( &pa_stream, rate, paFloat32,
- PABLIO_WRITE, outchans, framesperbuf, nbuffers,
- pa_indev, pa_outdev);
- else err = 0;
- if ( err != paNoError )
- {
- fprintf( stderr, "Error number %d occured opening portaudio stream\n",
- err);
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- Pa_Terminate();
- sys_inchannels = sys_outchannels = 0;
- return (1);
- }
- else if (sys_verbose)
- post("... opened OK.");
- pa_inchans = inchans;
- pa_outchans = outchans;
- pa_soundin = soundin;
- pa_soundout = soundout;
- return (0);
-}
-
-void pa_close_audio( void)
-{
- if (pa_inchans || pa_outchans)
- CloseAudioStream( pa_stream );
- pa_inchans = pa_outchans = 0;
-}
-
-int pa_send_dacs(void)
-{
- float samples[MAX_SAMPLES_PER_FRAME], *fp1, *fp2;
- int i, j;
- double timebefore;
-
- timebefore = sys_getrealtime();
- if ((pa_inchans && GetAudioStreamReadable(pa_stream) < DEFDACBLKSIZE) ||
- (pa_outchans && GetAudioStreamWriteable(pa_stream) < DEFDACBLKSIZE))
- {
- if (pa_inchans && pa_outchans)
- {
- int synced = 0;
- while (GetAudioStreamWriteable(pa_stream) > 2*DEFDACBLKSIZE)
- {
- for (j = 0; j < pa_outchans; j++)
- for (i = 0, fp2 = samples + j; i < DEFDACBLKSIZE; i++,
- fp2 += pa_outchans)
- {
- *fp2 = 0;
- }
- synced = 1;
- WriteAudioStream(pa_stream, samples, DEFDACBLKSIZE);
- }
- while (GetAudioStreamReadable(pa_stream) > 2*DEFDACBLKSIZE)
- {
- synced = 1;
- ReadAudioStream(pa_stream, samples, DEFDACBLKSIZE);
- }
- /* if (synced)
- post("sync"); */
- }
- return (SENDDACS_NO);
- }
- if (pa_inchans)
- {
- ReadAudioStream(pa_stream, samples, DEFDACBLKSIZE);
- for (j = 0, fp1 = pa_soundin; j < pa_inchans; j++, fp1 += DEFDACBLKSIZE)
- for (i = 0, fp2 = samples + j; i < DEFDACBLKSIZE; i++,
- fp2 += pa_inchans)
- {
- fp1[i] = *fp2;
- }
- }
-#if 0
- {
- static int nread;
- if (nread == 0)
- {
- post("it's %f %f %f %f",
- pa_soundin[0], pa_soundin[1], pa_soundin[2], pa_soundin[3]);
- nread = 1000;
- }
- nread--;
- }
-#endif
- if (pa_outchans)
- {
- for (j = 0, fp1 = pa_soundout; j < pa_outchans; j++,
- fp1 += DEFDACBLKSIZE)
- for (i = 0, fp2 = samples + j; i < DEFDACBLKSIZE; i++,
- fp2 += pa_outchans)
- {
- *fp2 = fp1[i];
- fp1[i] = 0;
- }
- WriteAudioStream(pa_stream, samples, DEFDACBLKSIZE);
- }
-
- if (sys_getrealtime() > timebefore + 0.002)
- {
- /* post("slept"); */
- return (SENDDACS_SLEPT);
- }
- else return (SENDDACS_YES);
-}
-
-
-void pa_listdevs(void) /* lifted from pa_devs.c in portaudio */
-{
- int i,j;
- int numDevices;
- const PaDeviceInfo *pdi;
- PaError err;
- Pa_Initialize();
- numDevices = Pa_CountDevices();
- if( numDevices < 0 )
- {
- fprintf(stderr, "ERROR: Pa_CountDevices returned 0x%x\n", numDevices );
- err = numDevices;
- goto error;
- }
- fprintf(stderr, "Audio Devices:\n");
- for( i=0; i<numDevices; i++ )
- {
- pdi = Pa_GetDeviceInfo( i );
- fprintf(stderr, "device %d:", i+1 );
- fprintf(stderr, " %s;", pdi->name );
- fprintf(stderr, "%d inputs, ", pdi->maxInputChannels );
- fprintf(stderr, "%d outputs", pdi->maxOutputChannels );
- if ( i == Pa_GetDefaultInputDevice() )
- fprintf(stderr, " (Default Input)");
- if ( i == Pa_GetDefaultOutputDevice() )
- fprintf(stderr, " (Default Output)");
- fprintf(stderr, "\n");
- }
-
- fprintf(stderr, "\n");
- return;
-
-error:
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
-
-}
-
- /* scanning for devices */
-void pa_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize)
-{
- int i, nin = 0, nout = 0, ndev;
- *canmulti = 1; /* one dev each for input and output */
-
- Pa_Initialize();
- ndev = Pa_CountDevices();
- for (i = 0; i < ndev; i++)
- {
- const PaDeviceInfo *pdi = Pa_GetDeviceInfo(i);
- if (pdi->maxInputChannels > 0 && nin < maxndev)
- {
- strcpy(indevlist + nin * devdescsize, pdi->name);
- nin++;
- }
- if (pdi->maxOutputChannels > 0 && nout < maxndev)
- {
- strcpy(outdevlist + nout * devdescsize, pdi->name);
- nout++;
- }
- }
- *nindevs = nin;
- *noutdevs = nout;
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_entry.c b/apps/plugins/pdbox/PDa/src/s_entry.c
index 23a5cb7fe3..fd7b4c52fa 100644
--- a/apps/plugins/pdbox/PDa/src/s_entry.c
+++ b/apps/plugins/pdbox/PDa/src/s_entry.c
@@ -49,54 +49,4 @@ int main(int argc, char **argv)
return (sys_main(argc, argv));
}
#endif
-/* In MSW, this is all there is to pd; the rest sits in a "pdlib" dll so
-that externs can link back to functions defined in pd. */
-
-#include <stdio.h>
-
-int sys_main(int argc, char **argv);
-
- /* WINBASEAPI PVOID WINAPI AddVectoredExceptionHandler(
- ULONG FirstHandler,
- PVECTORED_EXCEPTION_HANDLER VectoredHandler ); */
-
-#ifdef MSW
-#if 0
-#incldue "winbase.h"
-
-LONG NTAPI VectoredExceptionHandler(void *PEXCEPTION_POINTERS)
-{
- fprintf(stderr, "caught exception\n");
- return(EXCEPTION_CONTINUE_SEARCH);
-}
-
-
-int main(int argc, char **argv)
-{
- printf("Pd entry point\n");
- AddVectoredExceptionHandler(
- ULONG FirstHandler,
- PVECTORED_EXCEPTION_HANDLER VectoredHandler );
-
-#endif
-
-#if 1
-int main(int argc, char **argv)
-{
- __try
- {
- sys_main(argc, argv);
- }
- __finally
- {
- printf("caught an exception; stopping\n");
- }
-}
-#endif
-#else /* not MSW */
-int main(int argc, char **argv)
-{
- return (sys_main(argc, argv));
-}
-#endif
diff --git a/apps/plugins/pdbox/PDa/src/s_file.c b/apps/plugins/pdbox/PDa/src/s_file.c
index 2d3c4e5580..27825d5948 100644
--- a/apps/plugins/pdbox/PDa/src/s_file.c
+++ b/apps/plugins/pdbox/PDa/src/s_file.c
@@ -53,58 +53,3 @@ void sys_unbashfilename(const char *from, char *to)
*to = 0;
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/*
- * this file contains file-handling routines.
- */
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-
- /* LATER delete this? -- replaced by find_via_path() in s_path.c */
-int sys_isreadablefile(const char *s)
-{
- struct stat statbuf;
- int mode;
- if (stat(s, &statbuf) < 0) return (0);
-#ifdef UNIX
- mode = statbuf.st_mode;
- if (S_ISDIR(mode)) return (0);
-#endif
- return (1);
-}
-
- /* change '/' characters to the system's native file separator */
-void sys_bashfilename(const char *from, char *to)
-{
- char c;
- while (c = *from++)
- {
-#ifdef MSW
- if (c == '/') c = '\\';
-#endif
- *to++ = c;
- }
- *to = 0;
-}
-
-
- /* change the system's native file separator to '/' characters */
-void sys_unbashfilename(const char *from, char *to)
-{
- char c;
- while (c = *from++)
- {
-#ifdef MSW
- if (c == '\\') c = '/';
-#endif
- *to++ = c;
- }
- *to = 0;
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/s_inter.c b/apps/plugins/pdbox/PDa/src/s_inter.c
index 37c44770ed..9df9c82b40 100644
--- a/apps/plugins/pdbox/PDa/src/s_inter.c
+++ b/apps/plugins/pdbox/PDa/src/s_inter.c
@@ -998,1003 +998,3 @@ void glob_quit(void *dummy)
sys_bail(0);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* Pd side of the Pd/Pd-gui interface. Also, some system interface routines
-that didn't really belong anywhere. */
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include "m_imp.h"
-#ifdef UNIX
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/mman.h>
-#endif
-#ifdef HAVE_BSTRING_H
-#include <bstring.h>
-#endif
-#ifdef MSW
-#include <io.h>
-#include <fcntl.h>
-#include <process.h>
-#include <winsock.h>
-typedef int pid_t;
-#define EADDRINUSE WSAEADDRINUSE
-#endif
-#include <stdarg.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <stdio.h>
-
-#ifdef MACOSX
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <pthread.h>
-#else
-#include <stdlib.h>
-#endif
-
-#define DEBUG_MESSUP 1 /* messages up from pd to pd-gui */
-#define DEBUG_MESSDOWN 2 /* messages down from pd-gui to pd */
-
-/* T.Grill - make it a _little_ more adaptable... */
-#ifndef PDBINDIR
-#define PDBINDIR "bin/"
-#endif
-
-#ifndef WISHAPP
-#define WISHAPP "wish83.exe"
-#endif
-
-extern char pd_version[];
-
-typedef struct _fdpoll
-{
- int fdp_fd;
- t_fdpollfn fdp_fn;
- void *fdp_ptr;
-} t_fdpoll;
-
-#define INBUFSIZE 4096
-
-struct _socketreceiver
-{
- char *sr_inbuf;
- int sr_inhead;
- int sr_intail;
- void *sr_owner;
- int sr_udp;
- t_socketnotifier sr_notifier;
- t_socketreceivefn sr_socketreceivefn;
-};
-
-static int sys_nfdpoll;
-static t_fdpoll *sys_fdpoll;
-static int sys_maxfd;
-static int sys_guisock;
-
-static t_binbuf *inbinbuf;
-static t_socketreceiver *sys_socketreceiver;
-extern int sys_addhist(int phase);
-
-#ifdef MSW
-static LARGE_INTEGER nt_inittime;
-static double nt_freq = 0;
-
-static void sys_initntclock(void)
-{
- LARGE_INTEGER f1;
- LARGE_INTEGER now;
- QueryPerformanceCounter(&now);
- if (!QueryPerformanceFrequency(&f1))
- {
- fprintf(stderr, "pd: QueryPerformanceFrequency failed\n");
- f1.QuadPart = 1;
- }
- nt_freq = f1.QuadPart;
- nt_inittime = now;
-}
-
-#if 0
- /* this is a version you can call if you did the QueryPerformanceCounter
- call yourself. Necessary for time tagging incoming MIDI at interrupt
- level, for instance; but we're not doing that just now. */
-
-double nt_tixtotime(LARGE_INTEGER *dumbass)
-{
- if (nt_freq == 0) sys_initntclock();
- return (((double)(dumbass->QuadPart - nt_inittime.QuadPart)) / nt_freq);
-}
-#endif
-#endif /* MSW */
-
- /* get "real time" in seconds; take the
- first time we get called as a reference time of zero. */
-t_time sys_getrealtime(void)
-{
-#ifdef UNIX
- static struct timeval then;
- struct timeval now;
- gettimeofday(&now, 0);
- if (then.tv_sec == 0 && then.tv_usec == 0) then = now;
- return (now.tv_sec - then.tv_sec)*1000000 +
- (now.tv_usec - then.tv_usec);
-#endif
-#ifdef MSW
- LARGE_INTEGER now;
- QueryPerformanceCounter(&now);
- if (nt_freq == 0) sys_initntclock();
- return (((double)(now.QuadPart - nt_inittime.QuadPart)) / nt_freq);
-#endif
-}
-
-void sys_sockerror(char *s)
-{
-#ifdef MSW
- int err = WSAGetLastError();
- if (err == 10054) return;
- else if (err == 10044)
- {
- fprintf(stderr,
- "Warning: you might not have TCP/IP \"networking\" turned on\n");
- fprintf(stderr, "which is needed for Pd to talk to its GUI layer.\n");
- }
-#endif
-#ifdef UNIX
- int err = errno;
-#endif
- fprintf(stderr, "%s: %s (%d)\n", s, strerror(err), err);
-}
-
-void sys_addpollfn(int fd, t_fdpollfn fn, void *ptr)
-{
- int nfd = sys_nfdpoll;
- int size = nfd * sizeof(t_fdpoll);
- t_fdpoll *fp;
- sys_fdpoll = (t_fdpoll *)t_resizebytes(sys_fdpoll, size,
- size + sizeof(t_fdpoll));
- fp = sys_fdpoll + nfd;
- fp->fdp_fd = fd;
- fp->fdp_fn = fn;
- fp->fdp_ptr = ptr;
- sys_nfdpoll = nfd + 1;
- if (fd >= sys_maxfd) sys_maxfd = fd + 1;
-}
-
-void sys_rmpollfn(int fd)
-{
- int nfd = sys_nfdpoll;
- int i, size = nfd * sizeof(t_fdpoll);
- t_fdpoll *fp;
- for (i = nfd, fp = sys_fdpoll; i--; fp++)
- {
- if (fp->fdp_fd == fd)
- {
- while (i--)
- {
- fp[0] = fp[1];
- fp++;
- }
- sys_fdpoll = (t_fdpoll *)t_resizebytes(sys_fdpoll, size,
- size - sizeof(t_fdpoll));
- sys_nfdpoll = nfd - 1;
- return;
- }
- }
- post("warning: %d removed from poll list but not found", fd);
-}
-
-static int sys_domicrosleep(int microsec, int pollem)
-{
- struct timeval timout;
- int i, didsomething = 0;
- t_fdpoll *fp;
- timout.tv_sec = 0;
- timout.tv_usec = microsec;
- if (pollem)
- {
- fd_set readset, writeset, exceptset;
- FD_ZERO(&writeset);
- FD_ZERO(&readset);
- FD_ZERO(&exceptset);
- for (fp = sys_fdpoll, i = sys_nfdpoll; i--; fp++)
- FD_SET(fp->fdp_fd, &readset);
- select(sys_maxfd+1, &readset, &writeset, &exceptset, &timout);
- for (i = 0; i < sys_nfdpoll; i++)
- if (FD_ISSET(sys_fdpoll[i].fdp_fd, &readset))
- {
- (*sys_fdpoll[i].fdp_fn)(sys_fdpoll[i].fdp_ptr, sys_fdpoll[i].fdp_fd);
- didsomething = 1;
- }
- return (didsomething);
- }
- else
- {
- select(0, 0, 0, 0, &timout);
- return (0);
- }
-}
-
-void sys_microsleep(int microsec)
-{
- sys_domicrosleep(microsec, 1);
-}
-
-t_socketreceiver *socketreceiver_new(void *owner, t_socketnotifier notifier,
- t_socketreceivefn socketreceivefn, int udp)
-{
- t_socketreceiver *x = (t_socketreceiver *)getbytes(sizeof(*x));
- x->sr_inhead = x->sr_intail = 0;
- x->sr_owner = owner;
- x->sr_notifier = notifier;
- x->sr_socketreceivefn = socketreceivefn;
- x->sr_udp = udp;
- if (!(x->sr_inbuf = malloc(INBUFSIZE))) bug("t_socketreceiver");;
- return (x);
-}
-
-void socketreceiver_free(t_socketreceiver *x)
-{
- free(x->sr_inbuf);
- freebytes(x, sizeof(*x));
-}
-
- /* this is in a separately called subroutine so that the buffer isn't
- sitting on the stack while the messages are getting passed. */
-static int socketreceiver_doread(t_socketreceiver *x)
-{
- char messbuf[INBUFSIZE], *bp = messbuf;
- int indx;
- int inhead = x->sr_inhead;
- int intail = x->sr_intail;
- char *inbuf = x->sr_inbuf;
- if (intail == inhead) return (0);
- for (indx = intail; indx != inhead; indx = (indx+1)&(INBUFSIZE-1))
- {
- /* if we hit a semi that isn't preceeded by a \, it's a message
- boundary. LATER we should deal with the possibility that the
- preceeding \ might itself be escaped! */
- char c = *bp++ = inbuf[indx];
- if (c == ';' && (!indx || inbuf[indx-1] != '\\'))
- {
- intail = (indx+1)&(INBUFSIZE-1);
- binbuf_text(inbinbuf, messbuf, bp - messbuf);
- if (sys_debuglevel & DEBUG_MESSDOWN)
- {
- write(2, messbuf, bp - messbuf);
- write(2, "\n", 1);
- }
- x->sr_inhead = inhead;
- x->sr_intail = intail;
- return (1);
- }
- }
- return (0);
-}
-
-static void socketreceiver_getudp(t_socketreceiver *x, int fd)
-{
- char buf[INBUFSIZE+1];
- int ret = recv(fd, buf, INBUFSIZE, 0);
- if (ret < 0)
- {
- sys_sockerror("recv");
- sys_rmpollfn(fd);
- sys_closesocket(fd);
- }
- else if (ret > 0)
- {
- buf[ret] = 0;
-#if 0
- post("%s", buf);
-#endif
- if (buf[ret-1] != '\n')
- {
-#if 0
- buf[ret] = 0;
- error("dropped bad buffer %s\n", buf);
-#endif
- }
- else
- {
- char *semi = strchr(buf, ';');
- if (semi)
- *semi = 0;
- binbuf_text(inbinbuf, buf, strlen(buf));
- outlet_setstacklim();
- if (x->sr_socketreceivefn)
- (*x->sr_socketreceivefn)(x->sr_owner, inbinbuf);
- else bug("socketreceiver_getudp");
- }
- }
-}
-
-
-
-#include <termios.h>
-#include <string.h>
-
-static struct termios stored_settings;
-EXTERN int sys_stdin;
-
-void set_keypress(void)
-{
- struct termios new_settings;
-
- tcgetattr(0,&stored_settings);
-
- new_settings = stored_settings;
-
- /* Disable canonical mode, and set buffer size to 1 byte */
- new_settings.c_lflag &= (~ICANON);
- new_settings.c_cc[VTIME] = 0;
- new_settings.c_cc[VMIN] = 1;
-
-/* echo off */
- new_settings.c_lflag &= (~ECHO);
-
- tcsetattr(0,TCSANOW,&new_settings);
- return;
-}
-
-void reset_keypress(void)
-{
- if (sys_stdin)
- tcsetattr(0,TCSANOW,&stored_settings);
- return;
-}
-
-static t_symbol* _ss;
-
-
-void stdin_read(t_socketreceiver *x, int fd) {
- static char input[256];
-
- char* in;
- int got;
-
- got = read(fd,input,256);
- in = input;
- while (got-- && _ss->s_thing)
- pd_float(_ss->s_thing,(float)*in++);
-}
-
-void socketreceiver_read(t_socketreceiver *x, int fd)
-{
- if (x->sr_udp) /* UDP ("datagram") socket protocol */
- socketreceiver_getudp(x, fd);
- else /* TCP ("streaming") socket protocol */
- {
- char *semi;
- int readto =
- (x->sr_inhead >= x->sr_intail ? INBUFSIZE : x->sr_intail-1);
- int ret;
-
- /* the input buffer might be full. If so, drop the whole thing */
- if (readto == x->sr_inhead)
- {
- fprintf(stderr, "pd: dropped message from gui\n");
- x->sr_inhead = x->sr_intail = 0;
- readto = INBUFSIZE;
- }
- else
- {
- ret = recv(fd, x->sr_inbuf + x->sr_inhead,
- readto - x->sr_inhead, 0);
- if (ret < 0)
- {
- sys_sockerror("recv");
- if (x == sys_socketreceiver) sys_bail(1);
- else
- {
- if (x->sr_notifier) (*x->sr_notifier)(x->sr_owner);
- sys_rmpollfn(fd);
- sys_closesocket(fd);
- }
- }
- else if (ret == 0)
- {
- if (x == sys_socketreceiver)
- {
- fprintf(stderr, "pd: exiting\n");
- sys_bail(0);
- }
- else
- {
- post("EOF on socket %d\n", fd);
- if (x->sr_notifier) (*x->sr_notifier)(x->sr_owner);
- sys_rmpollfn(fd);
- sys_closesocket(fd);
- }
- }
- else
- {
- x->sr_inhead += ret;
- if (x->sr_inhead >= INBUFSIZE) x->sr_inhead = 0;
- while (socketreceiver_doread(x))
- {
- outlet_setstacklim();
- if (x->sr_socketreceivefn)
- (*x->sr_socketreceivefn)(x->sr_owner, inbinbuf);
- else binbuf_eval(inbinbuf, 0, 0, 0);
- }
- }
- }
- }
-}
-
-void sys_closesocket(int fd)
-{
-#ifdef UNIX
- close(fd);
-#endif
-#ifdef MSW
- closesocket(fd);
-#endif
-}
-
-
-void sys_gui(char *s)
-{
- int length = strlen(s), written = 0, res, histwas = sys_addhist(4);
- if (sys_debuglevel & DEBUG_MESSUP)
- fprintf(stderr, "%s", s);
- if (sys_nogui)
- return;
- while (1)
- {
- res = send(sys_guisock, s + written, length, 0);
- if (res < 0)
- {
- perror("pd output pipe");
- sys_bail(1);
- }
- else
- {
- written += res;
- if (written >= length)
- break;
- }
- }
- sys_addhist(histwas);
-}
-
-/* LATER should do a bounds check -- but how do you get printf to do that?
- See also rtext_senditup() in this regard */
-
-void sys_vgui(char *fmt, ...)
-{
- int result, i;
- char buf[2048];
- va_list ap;
-
- va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
- sys_gui(buf);
- va_end(ap);
-}
-
-
-#define FIRSTPORTNUM 5400
-
-/* -------------- signal handling for UNIX -------------- */
-
-#ifdef UNIX
-typedef void (*sighandler_t)(int);
-
-static void sys_signal(int signo, sighandler_t sigfun)
-{
- struct sigaction action;
- action.sa_flags = 0;
- action.sa_handler = sigfun;
- memset(&action.sa_mask, 0, sizeof(action.sa_mask));
-#if 0 /* GG says: don't use that */
- action.sa_restorer = 0;
-#endif
- if (sigaction(signo, &action, 0) < 0)
- perror("sigaction");
-}
-
-static void sys_exithandler(int n)
-{
- static int trouble = 0;
- if (!trouble)
- {
- trouble = 1;
- fprintf(stderr, "Pd: signal %d\n", n);
- sys_bail(1);
-
- }
- else _exit(1);
-}
-
-static void sys_alarmhandler(int n)
-{
- fprintf(stderr, "Pd: system call timed out\n");
-}
-
-static void sys_huphandler(int n)
-{
- struct timeval timout;
- timout.tv_sec = 0;
- timout.tv_usec = 30000;
- select(1, 0, 0, 0, &timout);
-}
-
-void sys_setalarm(int microsec)
-{
- struct itimerval gonzo;
-#if 0
- fprintf(stderr, "timer %d\n", microsec);
-#endif
- gonzo.it_interval.tv_sec = 0;
- gonzo.it_interval.tv_usec = 0;
- gonzo.it_value.tv_sec = 0;
- gonzo.it_value.tv_usec = microsec;
- if (microsec)
- sys_signal(SIGALRM, sys_alarmhandler);
- else sys_signal(SIGALRM, SIG_IGN);
- setitimer(ITIMER_REAL, &gonzo, 0);
-}
-
-#endif
-
-#ifdef __linux__
-
-#if defined(_POSIX_PRIORITY_SCHEDULING) || defined(_POSIX_MEMLOCK)
-#include <sched.h>
-#endif
-
-void sys_set_priority(int higher)
-{
-#ifdef _POSIX_PRIORITY_SCHEDULING
- struct sched_param par;
- int p1 ,p2, p3;
- p1 = sched_get_priority_min(SCHED_FIFO);
- p2 = sched_get_priority_max(SCHED_FIFO);
-#ifdef USEAPI_JACK
- p3 = (higher ? p1 + 7 : p1 + 5);
-#else
- p3 = (higher ? p2 - 1 : p2 - 3);
-#endif
- par.sched_priority = p3;
- if (sched_setscheduler(0,SCHED_FIFO,&par) != -1)
- fprintf(stderr, "priority %d scheduling enabled.\n", p3);
-#endif
-
-#ifdef _POSIX_MEMLOCK
- if (mlockall(MCL_FUTURE) != -1)
- fprintf(stderr, "memory locking enabled.\n");
-#endif
-
-}
-
-#endif /* __linux__ */
-
-static int sys_watchfd;
-
-#ifdef __linux__
-void glob_ping(t_pd *dummy)
-{
- if (write(sys_watchfd, "\n", 1) < 1)
- {
- fprintf(stderr, "pd: watchdog process died\n");
- sys_bail(1);
- }
-}
-#endif
-
-static int defaultfontshit[] = {
- 8, 5, 9, 10, 6, 10, 12, 7, 13, 14, 9, 17, 16, 10, 19, 24, 15, 28,
- 24, 15, 28};
-
-int sys_startgui(const char *guidir)
-{
- pid_t childpid;
- char cmdbuf[4*MAXPDSTRING];
- struct sockaddr_in server;
- int msgsock;
- char buf[15];
- int len = sizeof(server);
- int ntry = 0, portno = FIRSTPORTNUM;
- int xsock = -1;
-#ifdef MSW
- short version = MAKEWORD(2, 0);
- WSADATA nobby;
-#endif
-#ifdef UNIX
- int stdinpipe[2];
-#endif
- /* create an empty FD poll list */
- sys_fdpoll = (t_fdpoll *)t_getbytes(0);
- sys_nfdpoll = 0;
- inbinbuf = binbuf_new();
-
-#ifdef UNIX
- signal(SIGHUP, sys_huphandler);
- signal(SIGINT, sys_exithandler);
- signal(SIGQUIT, sys_exithandler);
- signal(SIGILL, sys_exithandler);
- signal(SIGIOT, sys_exithandler);
- signal(SIGFPE, SIG_IGN);
- /* signal(SIGILL, sys_exithandler);
- signal(SIGBUS, sys_exithandler);
- signal(SIGSEGV, sys_exithandler); */
- signal(SIGPIPE, SIG_IGN);
- signal(SIGALRM, SIG_IGN);
- signal(SIGTERM, SIG_IGN);
-#if 0 /* GG says: don't use that */
- signal(SIGSTKFLT, sys_exithandler);
-#endif
-#endif
-#ifdef MSW
- if (WSAStartup(version, &nobby)) sys_sockerror("WSAstartup");
-#endif
-
- if (sys_nogui)
- {
- /* fake the GUI's message giving cwd and font sizes; then
- skip starting the GUI up. */
- t_atom zz[19];
- int i;
-#ifdef MSW
- if (GetCurrentDirectory(MAXPDSTRING, cmdbuf) == 0)
- strcpy(cmdbuf, ".");
-#endif
-#ifdef UNIX
- if (!getcwd(cmdbuf, MAXPDSTRING))
- strcpy(cmdbuf, ".");
-
-#endif
- SETSYMBOL(zz, gensym(cmdbuf));
- for (i = 1; i < 22; i++)
- SETFLOAT(zz + i, defaultfontshit[i-1]);
- SETFLOAT(zz+22,0);
- glob_initfromgui(0, 0, 23, zz);
- }
- else
- {
-#ifdef MSW
- char scriptbuf[MAXPDSTRING+30], wishbuf[MAXPDSTRING+30], portbuf[80];
- int spawnret;
-
-#endif
-#ifdef MSW
- char intarg;
-#else
- int intarg;
-#endif
-
- /* create a socket */
- xsock = socket(AF_INET, SOCK_STREAM, 0);
- if (xsock < 0) sys_sockerror("socket");
-#if 0
- intarg = 0;
- if (setsockopt(xsock, SOL_SOCKET, SO_SNDBUF,
- &intarg, sizeof(intarg)) < 0)
- post("setsockopt (SO_RCVBUF) failed\n");
- intarg = 0;
- if (setsockopt(xsock, SOL_SOCKET, SO_RCVBUF,
- &intarg, sizeof(intarg)) < 0)
- post("setsockopt (SO_RCVBUF) failed\n");
-#endif
- intarg = 1;
- if (setsockopt(xsock, IPPROTO_TCP, TCP_NODELAY,
- &intarg, sizeof(intarg)) < 0)
-#ifndef MSW
- post("setsockopt (TCP_NODELAY) failed\n")
-#endif
- ;
-
-
- server.sin_family = AF_INET;
- server.sin_addr.s_addr = INADDR_ANY;
-
- /* assign server port number */
- server.sin_port = htons((unsigned short)portno);
-
- /* name the socket */
- while (bind(xsock, (struct sockaddr *)&server, sizeof(server)) < 0)
- {
-#ifdef MSW
- int err = WSAGetLastError();
-#endif
-#ifdef UNIX
- int err = errno;
-#endif
- if ((ntry++ > 20) || (err != EADDRINUSE))
- {
- perror("bind");
- fprintf(stderr,
- "Pd needs your machine to be configured with\n");
- fprintf(stderr,
- "'networking' turned on (see Pd's html doc for details.)\n");
- exit(1);
- }
- portno++;
- server.sin_port = htons((unsigned short)(portno));
- }
-
- if (sys_verbose) fprintf(stderr, "port %d\n", portno);
-
- sys_socketreceiver = socketreceiver_new(0, 0, 0, 0);
-
-#ifdef UNIX
- childpid = fork();
- if (childpid < 0)
- {
- if (errno) perror("sys_startgui");
- else fprintf(stderr, "sys_startgui failed\n");
- return (1);
- }
- else if (!childpid) /* we're the child */
- {
- seteuid(getuid()); /* lose setuid priveliges */
-#ifndef MACOSX
- /* the wish process in Unix will make a wish shell and
- read/write standard in and out unless we close the
- file descriptors. Somehow this doesn't make the MAC OSX
- version of Wish happy...*/
- if (pipe(stdinpipe) < 0)
- sys_sockerror("pipe");
- else
- {
- if (stdinpipe[0] != 0)
- {
- close (0);
- dup2(stdinpipe[0], 0);
- close(stdinpipe[0]);
- }
- }
-#endif
- if (!sys_guicmd)
- {
-#ifdef MACOSX
- char *homedir = getenv("HOME"), filename[250];
- struct stat statbuf;
- if (!homedir || strlen(homedir) > 150)
- goto nohomedir;
- sprintf(filename,
- "%s/Applications/Utilities/Wish shell.app/Contents/MacOS/Wish Shell",
- homedir);
- if (stat(filename, &statbuf) >= 0)
- goto foundit;
- sprintf(filename,
- "%s/Applications/Wish shell.app/Contents/MacOS/Wish Shell",
- homedir);
- if (stat(filename, &statbuf) >= 0)
- goto foundit;
- nohomedir:
- strcpy(filename,
- "/Applications/Utilities/Wish Shell.app/Contents/MacOS/Wish Shell");
- if (stat(filename, &statbuf) >= 0)
- goto foundit;
- strcpy(filename,
- "/Applications/Wish Shell.app/Contents/MacOS/Wish Shell");
- foundit:
- sprintf(cmdbuf, "\"%s\" %s/pd.tk %d\n", filename, guidir, portno);
-#else
- sprintf(cmdbuf,
-"TCL_LIBRARY=\"%s/tcl/library\" TK_LIBRARY=\"%s/tk/library\" \
- \"%s/pd-gui\" %d\n",
- sys_libdir->s_name, sys_libdir->s_name, guidir, portno);
-#endif
- sys_guicmd = cmdbuf;
- }
- if (sys_verbose) fprintf(stderr, "%s", sys_guicmd);
- execl("/bin/sh", "sh", "-c", sys_guicmd, 0);
- perror("pd: exec");
- _exit(1);
- }
-#endif /* UNIX */
-
-#ifdef MSW
- /* in MSW land "guipath" is unused; we just do everything from
- the libdir. */
- /* fprintf(stderr, "%s\n", sys_libdir->s_name); */
-
- strcpy(scriptbuf, "\"");
- strcat(scriptbuf, sys_libdir->s_name);
- strcat(scriptbuf, "/" PDBINDIR "pd.tk\"");
- sys_bashfilename(scriptbuf, scriptbuf);
-
- sprintf(portbuf, "%d", portno);
-
- strcpy(wishbuf, sys_libdir->s_name);
- strcat(wishbuf, "/" PDBINDIR WISHAPP);
- sys_bashfilename(wishbuf, wishbuf);
-
- spawnret = _spawnl(P_NOWAIT, wishbuf, WISHAPP, scriptbuf, portbuf, 0);
- if (spawnret < 0)
- {
- perror("spawnl");
- fprintf(stderr, "%s: couldn't load TCL\n", wishbuf);
- exit(1);
- }
-
-#endif /* MSW */
- }
-
-#ifdef __linux__
- /* now that we've spun off the child process we can promote
- our process's priority, if we happen to be root. */
- if (sys_hipriority)
- {
- if (!getuid() || !geteuid())
- {
- /* To prevent lockup, we fork off a watchdog process with
- higher real-time priority than ours. The GUI has to send
- a stream of ping messages to the watchdog THROUGH the Pd
- process which has to pick them up from the GUI and forward
- them. If any of these things aren't happening the watchdog
- starts sending "stop" and "cont" signals to the Pd process
- to make it timeshare with the rest of the system. (Version
- 0.33P2 : if there's no GUI, the watchdog pinging is done
- from the scheduler idle routine in this process instead.) */
-
- int pipe9[2], watchpid;
- if (pipe(pipe9) < 0)
- {
- seteuid(getuid()); /* lose setuid priveliges */
- sys_sockerror("pipe");
- return (1);
- }
- watchpid = fork();
- if (watchpid < 0)
- {
- seteuid(getuid()); /* lose setuid priveliges */
- if (errno)
- perror("sys_startgui");
- else fprintf(stderr, "sys_startgui failed\n");
- return (1);
- }
- else if (!watchpid) /* we're the child */
- {
- sys_set_priority(1);
- seteuid(getuid()); /* lose setuid priveliges */
- if (pipe9[1] != 0)
- {
- dup2(pipe9[0], 0);
- close(pipe9[0]);
- }
- close(pipe9[1]);
-
- sprintf(cmdbuf, "%s/pd-watchdog\n", guidir);
- if (sys_verbose) fprintf(stderr, "%s", cmdbuf);
- execl("/bin/sh", "sh", "-c", cmdbuf, 0);
- perror("pd: exec");
- _exit(1);
- }
- else /* we're the parent */
- {
- sys_set_priority(0);
- seteuid(getuid()); /* lose setuid priveliges */
- close(pipe9[0]);
- sys_watchfd = pipe9[1];
- /* We also have to start the ping loop in the GUI;
- this is done later when the socket is open. */
- }
- }
- else
- {
- post("realtime setting failed because not root\n");
- sys_hipriority = 0;
- }
- }
-
- seteuid(getuid()); /* lose setuid priveliges */
-#endif /* __linux__ */
-
-#ifdef MSW
- if (!SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS))
- fprintf(stderr, "pd: couldn't set high priority class\n");
-#endif
-#ifdef MACOSX
- if (sys_hipriority)
- {
- struct sched_param param;
- int policy = SCHED_RR;
- int err;
- param.sched_priority = 80; // adjust 0 : 100
-
- err = pthread_setschedparam(pthread_self(), policy, &param);
- if (err)
- post("warning: high priority scheduling failed\n");
- }
-#endif /* MACOSX */
-
- if (!sys_nogui)
- {
- char buf[256];
- if (sys_verbose)
- fprintf(stderr, "Waiting for connection request... \n");
- if (listen(xsock, 5) < 0) sys_sockerror("listen");
-
- sys_guisock = accept(xsock, (struct sockaddr *) &server, &len);
-#ifdef OOPS
- close(xsock);
-#endif
- if (sys_guisock < 0) sys_sockerror("accept");
- sys_addpollfn(sys_guisock, (t_fdpollfn)socketreceiver_read,
- sys_socketreceiver);
-
- if (sys_verbose)
- fprintf(stderr, "... connected\n");
-
- /* here is where we start the pinging. */
-#ifdef __linux__
- if (sys_hipriority)
- sys_gui("pdtk_watchdog\n");
-#endif
- sys_get_audio_apis(buf);
- sys_vgui("pdtk_pd_startup {%s} %s\n", pd_version, buf);
- }
- if (sys_stdin) {
- set_keypress();
- _ss = gensym("stdin");
- sys_addpollfn(1, (t_fdpollfn) stdin_read,NULL);
- }
- return (0);
-
-}
-
-
-static int sys_poll_togui(void)
-{
- /* LATER use this to flush output buffer to gui */
- return (0);
-}
-
-int sys_pollgui(void)
-{
- return (sys_domicrosleep(0, 1) || sys_poll_togui());
-}
-
-
-/* T.Grill - import clean quit function */
-extern void sys_exit(void);
-
-/* This is called when something bad has happened, like a segfault.
-Call glob_quit() below to exit cleanly.
-LATER try to save dirty documents even in the bad case. */
-void sys_bail(int n)
-{
- static int reentered = 0;
- reset_keypress();
- if (!reentered)
- {
- reentered = 1;
-#ifndef __linux /* sys_close_audio() hangs if you're in a signal? */
- fprintf(stderr, "closing audio...\n");
- sys_close_audio();
- fprintf(stderr, "closing MIDI...\n");
- sys_close_midi();
- fprintf(stderr, "... done.\n");
-#endif
- exit(1);
- }
- else _exit(n);
-}
-
-void glob_quit(void *dummy)
-{
- sys_vgui("exit\n");
- if (!sys_nogui)
- {
- close(sys_guisock);
- sys_rmpollfn(sys_guisock);
- }
- reset_keypress();
- sys_bail(0);
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/s_loader.c b/apps/plugins/pdbox/PDa/src/s_loader.c
index 78be948b93..c5a8677f71 100644
--- a/apps/plugins/pdbox/PDa/src/s_loader.c
+++ b/apps/plugins/pdbox/PDa/src/s_loader.c
@@ -161,178 +161,3 @@ int sys_load_lib(char *dirname, char *classname)
#endif
-
-
-
-
-
-
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#ifdef DL_OPEN
-#include <dlfcn.h>
-#endif
-#ifdef UNIX
-#include <stdlib.h>
-#include <unistd.h>
-#endif
-#ifdef MSW
-#include <io.h>
-#include <windows.h>
-#endif
-#ifdef MACOSX
-#include <mach-o/dyld.h>
-#endif
-#include <string.h>
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <stdio.h>
-
-typedef void (*t_xxx)(void);
-
-static char sys_dllextent[] =
-#ifdef __FreeBSD__
- ".pd_freebsd";
-#endif
-#ifdef IRIX
-#ifdef N32
- ".pd_irix6";
-#else
- ".pd_irix5";
-#endif
-#endif
-#ifdef __linux__
- ".pd_linux";
-#endif
-#ifdef MACOSX
- ".pd_darwin";
-#endif
-#ifdef MSW
- ".dll";
-#endif
-
-void class_set_extern_dir(t_symbol *s);
-
-#ifdef STATIC
-int sys_load_lib(char *dirname, char *classname)
-{ return 1;}
-#else
-int sys_load_lib(char *dirname, char *classname)
-{
- char symname[MAXPDSTRING], filename[MAXPDSTRING], dirbuf[MAXPDSTRING],
- classname2[MAXPDSTRING], *nameptr, *lastdot;
- void *dlobj;
- t_xxx makeout = NULL;
- int fd;
-#ifdef MSW
- HINSTANCE ntdll;
-#endif
-#if 0
- fprintf(stderr, "lib %s %s\n", dirname, classname);
-#endif
- /* try looking in the path for (classname).(sys_dllextent) ... */
- if ((fd = open_via_path(dirname, classname, sys_dllextent,
- dirbuf, &nameptr, MAXPDSTRING, 1)) < 0)
- {
- /* next try (classname)/(classname).(sys_dllextent) ... */
- strncpy(classname2, classname, MAXPDSTRING);
- filename[MAXPDSTRING-2] = 0;
- strcat(classname2, "/");
- strncat(classname2, classname, MAXPDSTRING-strlen(classname2));
- filename[MAXPDSTRING-1] = 0;
- if ((fd = open_via_path(dirname, classname2, sys_dllextent,
- dirbuf, &nameptr, MAXPDSTRING, 1)) < 0)
- {
- return (0);
- }
- }
-
-
- close(fd);
- class_set_extern_dir(gensym(dirbuf));
-
- /* refabricate the pathname */
- strncpy(filename, dirbuf, MAXPDSTRING);
- filename[MAXPDSTRING-2] = 0;
- strcat(filename, "/");
- strncat(filename, nameptr, MAXPDSTRING-strlen(filename));
- filename[MAXPDSTRING-1] = 0;
- /* extract the setup function name */
- if (lastdot = strrchr(nameptr, '.'))
- *lastdot = 0;
-
-#ifdef MACOSX
- strcpy(symname, "_");
- strcat(symname, nameptr);
-#else
- strcpy(symname, nameptr);
-#endif
- /* if the last character is a tilde, replace with "_tilde" */
- if (symname[strlen(symname) - 1] == '~')
- strcpy(symname + (strlen(symname) - 1), "_tilde");
- /* and append _setup to form the C setup function name */
- strcat(symname, "_setup");
-#ifdef DL_OPEN
- dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
- if (!dlobj)
- {
- post("%s: %s", filename, dlerror());
- class_set_extern_dir(&s_);
- return (0);
- }
- makeout = (t_xxx)dlsym(dlobj, symname);
-#endif
-#ifdef MSW
- sys_bashfilename(filename, filename);
- ntdll = LoadLibrary(filename);
- if (!ntdll)
- {
- post("%s: couldn't load", filename);
- class_set_extern_dir(&s_);
- return (0);
- }
- makeout = (t_xxx)GetProcAddress(ntdll, symname);
-#endif
-#ifdef MACOSX
- {
- NSObjectFileImage image;
- void *ret;
- NSSymbol s;
- if ( NSCreateObjectFileImageFromFile( filename, &image) != NSObjectFileImageSuccess )
- {
- post("%s: couldn't load", filename);
- class_set_extern_dir(&s_);
- return 0;
- }
- ret = NSLinkModule( image, filename,
- NSLINKMODULE_OPTION_BINDNOW + NSLINKMODULE_OPTION_PRIVATE);
-
- s = NSLookupSymbolInModule(ret, symname);
-
- if (s)
- makeout = (t_xxx)NSAddressOfSymbol( s);
- else makeout = 0;
- }
-#endif
-
- if (!makeout)
- {
- post("load_object: Symbol \"%s\" not found", symname);
- class_set_extern_dir(&s_);
- return 0;
- }
- (*makeout)();
- class_set_extern_dir(&s_);
- return (1);
-}
-
-#endif
-
-
-
-
-
-
-
diff --git a/apps/plugins/pdbox/PDa/src/s_main.c b/apps/plugins/pdbox/PDa/src/s_main.c
index 84f4cfbbc2..b77f804e9f 100644
--- a/apps/plugins/pdbox/PDa/src/s_main.c
+++ b/apps/plugins/pdbox/PDa/src/s_main.c
@@ -836,841 +836,4 @@ static void sys_addreferencepath(void)
{
char sbuf[MAXPDSTRING];
}
-/* Copyright (c) 1997-1999 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* IOhannes :
- * hacked the code to add advanced multidevice-support
- * 1311:forum::für::umläute:2001
- */
-
-char pd_version[] = "Pd version 0.37.4\n";
-char pd_compiletime[] = __TIME__;
-char pd_compiledate[] = __DATE__;
-
-#include "m_pd.h"
-#include "m_imp.h"
-#include "s_stuff.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <limits.h>
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-#ifdef UNIX
-#include <unistd.h>
-#endif
-#ifdef MSW
-#include <io.h>
-#include <windows.h>
-#include <winbase.h>
-#endif
-
-void pd_init(void);
-int sys_argparse(int argc, char **argv);
-void sys_findprogdir(char *progname);
-int sys_startgui(const char *guipath);
-int sys_rcfile(void);
-int m_scheduler(void);
-void sys_addhelppath(char *p);
-void alsa_adddev(char *name);
-
-int sys_debuglevel;
-int sys_verbose;
-int sys_noloadbang;
-int sys_nogui;
-int sys_stdin = 0;
-char *sys_guicmd;
-t_symbol *sys_libdir;
-static t_symbol *sys_guidir;
-static t_namelist *sys_externlist;
-static t_namelist *sys_openlist;
-static t_namelist *sys_messagelist;
-static int sys_version;
-int sys_oldtclversion; /* hack to warn g_rtext.c about old text sel */
-
-int sys_nmidiout = 1;
-#ifdef MSW
-int sys_nmidiin = 0;
-#else
-int sys_nmidiin = 1;
-#endif
-int sys_midiindevlist[MAXMIDIINDEV] = {1};
-int sys_midioutdevlist[MAXMIDIOUTDEV] = {1};
-
-static int sys_main_srate = DEFAULTSRATE;
-static int sys_main_advance = DEFAULTADVANCE;
-
-/* IOhannes { */
-
- /* here the "-1" counts signify that the corresponding vector hasn't been
- specified in command line arguments; sys_open_audio will detect this
- and fill things in. */
-int sys_nsoundin = -1;
-int sys_nsoundout = -1;
-int sys_soundindevlist[MAXAUDIOINDEV];
-int sys_soundoutdevlist[MAXAUDIOOUTDEV];
-
-int sys_nchin = -1;
-int sys_nchout = -1;
-int sys_chinlist[MAXAUDIOINDEV];
-int sys_choutlist[MAXAUDIOOUTDEV];
-/* } IOhannes */
-
-
-typedef struct _fontinfo
-{
- int fi_fontsize;
- int fi_maxwidth;
- int fi_maxheight;
- int fi_hostfontsize;
- int fi_width;
- int fi_height;
-} t_fontinfo;
-
- /* these give the nominal point size and maximum height of the characters
- in the six fonts. */
-
-static t_fontinfo sys_fontlist[] = {
- {8, 5, 9, 0, 0, 0}, {10, 7, 13, 0, 0, 0}, {12, 9, 16, 0, 0, 0},
- {16, 10, 20, 0, 0, 0}, {24, 15, 25, 0, 0, 0}, {36, 25, 45, 0, 0, 0}};
-#define NFONT (sizeof(sys_fontlist)/sizeof(*sys_fontlist))
-
-/* here are the actual font size structs on msp's systems:
-MSW:
-font 8 5 9 8 5 11
-font 10 7 13 10 6 13
-font 12 9 16 14 8 16
-font 16 10 20 16 10 18
-font 24 15 25 16 10 18
-font 36 25 42 36 22 41
-linux:
-font 8 5 9 8 5 9
-font 10 7 13 12 7 13
-font 12 9 16 14 9 15
-font 16 10 20 16 10 19
-font 24 15 25 24 15 24
-font 36 25 42 36 22 41
-*/
-
-static t_fontinfo *sys_findfont(int fontsize)
-{
- unsigned int i;
- t_fontinfo *fi;
- for (i = 0, fi = sys_fontlist; i < (NFONT-1); i++, fi++)
- if (fontsize < fi[1].fi_fontsize) return (fi);
- return (sys_fontlist + (NFONT-1));
-}
-
-int sys_nearestfontsize(int fontsize)
-{
- return (sys_findfont(fontsize)->fi_fontsize);
-}
-
-int sys_hostfontsize(int fontsize)
-{
- return (sys_findfont(fontsize)->fi_hostfontsize);
-}
-
-int sys_fontwidth(int fontsize)
-{
- return (sys_findfont(fontsize)->fi_width);
-}
-
-int sys_fontheight(int fontsize)
-{
- return (sys_findfont(fontsize)->fi_height);
-}
-
-int sys_defaultfont;
-#ifdef MSW
-#define DEFAULTFONT 12
-#else
-#define DEFAULTFONT 10
-#endif
-
-static void openit(const char *dirname, const char *filename)
-{
- char dirbuf[MAXPDSTRING], *nameptr;
- int fd = open_via_path(dirname, filename, "", dirbuf, &nameptr,
- MAXPDSTRING, 0);
- if (fd)
- {
- close (fd);
- glob_evalfile(0, gensym(nameptr), gensym(dirbuf));
- }
- else
- error("%s: can't open", filename);
-}
-
-#define NHOSTFONT 7
-
-/* this is called from the gui process. The first argument is the cwd, and
-succeeding args give the widths and heights of known fonts. We wait until
-these are known to open files and send messages specified on the command line.
-We ask the GUI to specify the "cwd" in case we don't have a local OS to get it
-from; for instance we could be some kind of RT embedded system. However, to
-really make this make sense we would have to implement
-open(), read(), etc, calls to be served somehow from the GUI too. */
-
-void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- char *cwd = atom_getsymbolarg(0, argc, argv)->s_name;
- t_namelist *nl;
- unsigned int i, j;
- if (argc != 2 + 3 * NHOSTFONT) bug("glob_initfromgui");
- for (i = 0; i < NFONT; i++)
- {
- int wantheight = sys_fontlist[i].fi_maxheight;
- for (j = 0; j < NHOSTFONT-1; j++)
- {
- if (atom_getintarg(3 * (j + 1) + 3, argc, argv) > wantheight)
- break;
- }
- /* j is now the "real" font index for the desired font index i. */
- sys_fontlist[i].fi_hostfontsize = atom_getintarg(3 * j + 1, argc, argv);
- sys_fontlist[i].fi_width = atom_getintarg(3 * j + 2, argc, argv);
- sys_fontlist[i].fi_height = atom_getintarg(3 * j + 3, argc, argv);
- }
-#if 0
- for (i = 0; i < 6; i++)
- fprintf(stderr, "font %d %d %d %d %d\n",
- sys_fontlist[i].fi_fontsize,
- sys_fontlist[i].fi_maxheight,
- sys_fontlist[i].fi_hostfontsize,
- sys_fontlist[i].fi_width,
- sys_fontlist[i].fi_height);
-#endif
- /* load dynamic libraries specified with "-lib" args */
- for (nl = sys_externlist; nl; nl = nl->nl_next)
- if (!sys_load_lib(cwd, nl->nl_string))
- post("%s: can't load library", nl->nl_string);
- namelist_free(sys_externlist);
- sys_externlist = 0;
- /* open patches specifies with "-open" args */
- for (nl = sys_openlist; nl; nl = nl->nl_next)
- openit(cwd, nl->nl_string);
- namelist_free(sys_openlist);
- sys_openlist = 0;
- /* send messages specified with "-send" args */
- for (nl = sys_messagelist; nl; nl = nl->nl_next)
- {
- t_binbuf *b = binbuf_new();
- binbuf_text(b, nl->nl_string, strlen(nl->nl_string));
- binbuf_eval(b, 0, 0, 0);
- binbuf_free(b);
- }
- namelist_free(sys_messagelist);
- sys_messagelist = 0;
- sys_oldtclversion = atom_getfloatarg(1 + 3 * NHOSTFONT, argc, argv);
-}
-
-static void sys_afterargparse(void);
-
-/* this is called from main() in s_entry.c */
-int sys_main(int argc, char **argv)
-{
-#ifdef PD_DEBUG
- fprintf(stderr, "Pd: COMPILED FOR DEBUGGING\n");
-#endif
- pd_init();
- sys_findprogdir(argv[0]); /* set sys_progname, guipath */
-#ifdef UNIX
- sys_rcfile(); /* parse the startup file */
-#endif
- if (sys_argparse(argc, argv)) /* parse cmd line */
- return (1);
- sys_afterargparse(); /* post-argparse settings */
- if (sys_verbose || sys_version) fprintf(stderr, "%scompiled %s %s\n",
- pd_version, pd_compiletime, pd_compiledate);
- if (sys_version) /* if we were just asked our version, exit here. */
- return (0);
- if (sys_startgui(sys_guidir->s_name)) /* start the gui */
- return(1);
- /* open audio and MIDI */
- sys_open_midi(sys_nmidiin, sys_midiindevlist,
- sys_nmidiout, sys_midioutdevlist);
- sys_open_audio(sys_nsoundin, sys_soundindevlist, sys_nchin, sys_chinlist,
- sys_nsoundout, sys_soundoutdevlist, sys_nchout, sys_choutlist,
- sys_main_srate, sys_main_advance, 1);
- /* run scheduler until it quits */
-
- return (m_scheduler_pda());
- return (m_scheduler());
-}
-
-static char *(usagemessage[]) = {
-"usage: pd [-flags] [file]...\n",
-"\naudio configuration flags:\n",
-"-r <n> -- specify sample rate\n",
-"-audioindev ... -- audio in devices; e.g., \"1,3\" for first and third\n",
-"-audiooutdev ... -- audio out devices (same)\n",
-"-audiodev ... -- specify input and output together\n",
-"-inchannels ... -- audio input channels (by device, like \"2\" or \"16,8\")\n",
-"-outchannels ... -- number of audio out channels (same)\n",
-"-channels ... -- specify both input and output channels\n",
-"-audiobuf <n> -- specify size of audio buffer in msec\n",
-"-blocksize <n> -- specify audio I/O block size in sample frames\n",
-"-sleepgrain <n> -- specify number of milliseconds to sleep when idle\n",
-"-nodac -- suppress audio output\n",
-"-noadc -- suppress audio input\n",
-"-noaudio -- suppress audio input and output (-nosound is synonym) \n",
-"-listdev -- list audio and MIDI devices\n",
-
-#ifdef USEAPI_OSS
-"-oss -- use OSS audio API\n",
-"-32bit ----- allow 32 bit OSS audio (for RME Hammerfall)\n",
-#endif
-
-#ifdef USEAPI_ALSA
-"-alsa -- use ALSA audio API\n",
-"-alsaadd <name> -- add an ALSA device name to list\n",
-"-alsadev <n> ----- obsolete: use -audiodev\n",
-#endif
-
-#ifdef USEAPI_JACK
-"-jack -- use JACK audio API\n",
-#endif
-
-#ifdef USEAPI_PORTAUDIO
-#ifdef MSW
-"-asio -- use ASIO audio driver (via Portaudio)\n",
-"-pa -- synonym for -asio\n",
-#else
-"-pa -- use Portaudio API\n",
-#endif
-#endif
-
-#ifdef USEAPI_MMIO
-"-mmio -- use MMIO audio API (default for Windows)\n",
-#endif
-" (default audio API for this platform: ", API_DEFSTRING, ")\n\n",
-
-"\nMIDI configuration flags:\n",
-"-midiindev ... -- midi in device list; e.g., \"1,3\" for first and third\n",
-"-midioutdev ... -- midi out device list, same format\n",
-"-mididev ... -- specify -midioutdev and -midiindev together\n",
-"-nomidiin -- suppress MIDI input\n",
-"-nomidiout -- suppress MIDI output\n",
-"-nomidi -- suppress MIDI input and output\n",
-
-"\nother flags:\n",
-"-path <path> -- add to file search path\n",
-"-helppath <path> -- add to help file search path\n",
-"-open <file> -- open file(s) on startup\n",
-"-lib <file> -- load object library(s)\n",
-"-font <n> -- specify default font size in points\n",
-"-verbose -- extra printout on startup and when searching for files\n",
-"-version -- don't run Pd; just print out which version it is \n",
-"-d <n> -- specify debug level\n",
-"-noloadbang -- suppress all loadbangs\n",
-"-nogui -- suppress starting the GUI\n",
-"-stdin -- scan stdin for keypresses\n",
-"-guicmd \"cmd...\" -- substitute another GUI program (e.g., rsh)\n",
-"-send \"msg...\" -- send a message at startup (after patches are loaded)\n",
-#ifdef UNIX
-"-rt or -realtime -- use real-time priority\n",
-"-nrt -- don't use real-time priority\n",
-#endif
-};
-
-static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
-{
- int n = 0;
- while (n < max)
- {
- if (!*str) break;
- else
- {
- char *endp;
- vecp[n] = strtol(str, &endp, 10);
- if (endp == str)
- break;
- n++;
- if (!endp)
- break;
- str = endp + 1;
- }
- }
- *np = n;
-}
-
-static int sys_getmultidevchannels(int n, int *devlist)
-{
- int sum = 0;
- if (n<0)return(-1);
- if (n==0)return 0;
- while(n--)sum+=*devlist++;
- return sum;
-}
-
-
- /* this routine tries to figure out where to find the auxilliary files
- Pd will need to run. This is either done by looking at the command line
- invokation for Pd, or if that fails, by consulting the variable
- INSTALL_PREFIX. In MSW, we don't try to use INSTALL_PREFIX. */
-void sys_findprogdir(char *progname)
-{
- char sbuf[MAXPDSTRING], sbuf2[MAXPDSTRING], *sp;
- char *lastslash;
-#ifdef UNIX
- struct stat statbuf;
-#endif
-
- /* find out by what string Pd was invoked; put answer in "sbuf". */
-#ifdef MSW
- GetModuleFileName(NULL, sbuf2, sizeof(sbuf2));
- sbuf2[MAXPDSTRING-1] = 0;
- sys_unbashfilename(sbuf2, sbuf);
-#endif /* MSW */
-#ifdef UNIX
- strncpy(sbuf, progname, MAXPDSTRING);
- sbuf[MAXPDSTRING-1] = 0;
-#endif
- lastslash = strrchr(sbuf, '/');
- if (lastslash)
- {
- /* bash last slash to zero so that sbuf is directory pd was in,
- e.g., ~/pd/bin */
- *lastslash = 0;
- /* go back to the parent from there, e.g., ~/pd */
- lastslash = strrchr(sbuf, '/');
- if (lastslash)
- {
- strncpy(sbuf2, sbuf, lastslash-sbuf);
- sbuf2[lastslash-sbuf] = 0;
- }
- else strcpy(sbuf2, "..");
- }
- else
- {
- /* no slashes found. Try INSTALL_PREFIX. */
-#ifdef INSTALL_PREFIX
- strcpy(sbuf2, INSTALL_PREFIX);
-#else
- strcpy(sbuf2, ".");
-#endif
- }
- /* now we believe sbuf2 holds the parent directory of the directory
- pd was found in. We now want to infer the "lib" directory and the
- "gui" directory. In "simple" UNIX installations, the layout is
- .../bin/pd
- .../bin/pd-gui
- .../doc
- and in "complicated" UNIX installations, it's:
- .../bin/pd
- .../lib/pd/bin/pd-gui
- .../lib/pd/doc
- To decide which, we stat .../lib/pd; if that exists, we assume it's
- the complicated layout. In MSW, it's the "simple" layout, but
- the gui program is straight wish80:
- .../bin/pd
- .../bin/wish80.exe
- .../doc
- */
-#ifdef UNIX
- strncpy(sbuf, sbuf2, MAXPDSTRING-30);
- sbuf[MAXPDSTRING-30] = 0;
- strcat(sbuf, "/lib/pd");
- if (stat(sbuf, &statbuf) >= 0)
- {
- /* complicated layout: lib dir is the one we just stat-ed above */
- sys_libdir = gensym(sbuf);
- /* gui lives in .../lib/pd/bin */
- strncpy(sbuf, sbuf2, MAXPDSTRING-30);
- sbuf[MAXPDSTRING-30] = 0;
- strcat(sbuf, "/lib/pd/bin");
- sys_guidir = gensym(sbuf);
- }
- else
- {
- /* simple layout: lib dir is the parent */
- sys_libdir = gensym(sbuf2);
- /* gui lives in .../bin */
- strncpy(sbuf, sbuf2, MAXPDSTRING-30);
- sbuf[MAXPDSTRING-30] = 0;
- strcat(sbuf, "/bin");
- sys_guidir = gensym(sbuf);
- }
-#endif
-#ifdef MSW
- sys_libdir = gensym(sbuf2);
- sys_guidir = &s_; /* in MSW the guipath just depends on the libdir */
-#endif
-}
-
-#ifdef MSW
-static int sys_mmio = 1;
-#else
-static int sys_mmio = 0;
-#endif
-
-int sys_argparse(int argc, char **argv)
-{
- char sbuf[MAXPDSTRING];
- int i;
- argc--; argv++;
- while ((argc > 0) && **argv == '-')
- {
- if (!strcmp(*argv, "-r") && argc > 1 &&
- sscanf(argv[1], "%d", &sys_main_srate) >= 1)
- {
- argc -= 2;
- argv += 2;
- }
- else if (!strcmp(*argv, "-inchannels"))
- { /* IOhannes */
- sys_parsedevlist(&sys_nchin,
- sys_chinlist, MAXAUDIOINDEV, argv[1]);
-
- if (!sys_nchin)
- goto usage;
-
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-outchannels"))
- { /* IOhannes */
- sys_parsedevlist(&sys_nchout, sys_choutlist,
- MAXAUDIOOUTDEV, argv[1]);
-
- if (!sys_nchout)
- goto usage;
-
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-channels"))
- {
- sys_parsedevlist(&sys_nchin, sys_chinlist,MAXAUDIOINDEV,
- argv[1]);
- sys_parsedevlist(&sys_nchout, sys_choutlist,MAXAUDIOOUTDEV,
- argv[1]);
-
- if (!sys_nchout)
- goto usage;
-
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-soundbuf") || !strcmp(*argv, "-audiobuf"))
- {
- sys_main_advance = atoi(argv[1]);
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-blocksize"))
- {
- sys_setblocksize(atoi(argv[1]));
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-sleepgrain"))
- {
- sys_sleepgrain = 1000 * atoi(argv[1]);
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-nodac"))
- { /* IOhannes */
- sys_nsoundout=0;
- sys_nchout = 0;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-noadc"))
- { /* IOhannes */
- sys_nsoundin=0;
- sys_nchin = 0;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-nosound") || !strcmp(*argv, "-noaudio"))
- { /* IOhannes */
- sys_nsoundin=sys_nsoundout = 0;
- sys_nchin = sys_nchout = 0;
- argc--; argv++;
- }
-#ifdef USEAPI_OSS
- else if (!strcmp(*argv, "-oss"))
- {
- sys_set_audio_api(API_OSS);
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-32bit"))
- {
- sys_set_audio_api(API_OSS);
- oss_set32bit();
- argc--; argv++;
- }
-#endif
-#ifdef USEAPI_ALSA
- else if (!strcmp(*argv, "-alsa"))
- {
- sys_set_audio_api(API_ALSA);
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-alsaadd"))
- {
- if (argc > 1)
- alsa_adddev(argv[1]);
- else goto usage;
- argc -= 2; argv +=2;
- }
- /* obsolete flag for setting ALSA device number or name */
- else if (!strcmp(*argv, "-alsadev"))
- {
- int devno = 0;
- if (argv[1][0] >= '1' && argv[1][0] <= '9')
- devno = 1 + 2 * (atoi(argv[1]) - 1);
- else if (!strncmp(argv[1], "hw:", 3))
- devno = 1 + 2 * atoi(argv[1]+3);
- else if (!strncmp(argv[1], "plughw:", 7))
- devno = 2 + 2 * atoi(argv[1]+7);
- else goto usage;
- sys_nsoundin = sys_nsoundout = 1;
- sys_soundindevlist[0] = sys_soundoutdevlist[0] = devno;
- sys_set_audio_api(API_ALSA);
- argc -= 2; argv +=2;
- }
-#endif
-#ifdef USEAPI_JACK
- else if (!strcmp(*argv, "-jack"))
- {
- sys_set_audio_api(API_JACK);
- argc--; argv++;
- }
-#endif
-#ifdef USEAPI_PORTAUDIO
- else if (!strcmp(*argv, "-pa") || !strcmp(*argv, "-portaudio")
-#ifdef MSW
- || !strcmp(*argv, "-asio")
-#endif
- )
- {
- sys_set_audio_api(API_PORTAUDIO);
- sys_mmio = 0;
- argc--; argv++;
- }
-#endif
-#ifdef USEAPI_MMIO
- else if (!strcmp(*argv, "-mmio"))
- {
- sys_set_audio_api(API_MMIO);
- sys_mmio = 1;
- argc--; argv++;
- }
-#endif
- else if (!strcmp(*argv, "-nomidiin"))
- {
- sys_nmidiin = 0;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-nomidiout"))
- {
- sys_nmidiout = 0;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-nomidi"))
- {
- sys_nmidiin = sys_nmidiout = 0;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-midiindev"))
- {
- sys_parsedevlist(&sys_nmidiin, sys_midiindevlist, MAXMIDIINDEV,
- argv[1]);
- if (!sys_nmidiin)
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-midioutdev"))
- {
- sys_parsedevlist(&sys_nmidiout, sys_midioutdevlist, MAXMIDIOUTDEV,
- argv[1]);
- if (!sys_nmidiout)
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-mididev"))
- {
- sys_parsedevlist(&sys_nmidiin, sys_midiindevlist, MAXMIDIINDEV,
- argv[1]);
- sys_parsedevlist(&sys_nmidiout, sys_midioutdevlist, MAXMIDIOUTDEV,
- argv[1]);
- if (!sys_nmidiout)
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-path"))
- {
- sys_addpath(argv[1]);
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-helppath"))
- {
- sys_addhelppath(argv[1]);
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-open") && argc > 1)
- {
- sys_openlist = namelist_append(sys_openlist, argv[1]);
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-lib") && argc > 1)
- {
- sys_externlist = namelist_append(sys_externlist, argv[1]);
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-font") && argc > 1)
- {
- sys_defaultfont = sys_nearestfontsize(atoi(argv[1]));
- argc -= 2;
- argv += 2;
- }
- else if (!strcmp(*argv, "-verbose"))
- {
- sys_verbose = 1;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-version"))
- {
- sys_version = 1;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-d") && argc > 1 &&
- sscanf(argv[1], "%d", &sys_debuglevel) >= 1)
- {
- argc -= 2;
- argv += 2;
- }
- else if (!strcmp(*argv, "-noloadbang"))
- {
- sys_noloadbang = 1;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-nogui"))
- {
- sys_nogui = 1;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-stdin"))
- {
- sys_stdin = 1;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-guicmd") && argc > 1)
- {
- sys_guicmd = argv[1];
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-send") && argc > 1)
- {
- sys_messagelist = namelist_append(sys_messagelist, argv[1]);
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-listdev"))
- {
- sys_listdevs();
- argc--; argv++;
- }
-#ifdef UNIX
- else if (!strcmp(*argv, "-rt") || !strcmp(*argv, "-realtime"))
- {
- sys_hipriority = 1;
- argc--; argv++;
- }
- else if (!strcmp(*argv, "-nrt"))
- {
- sys_hipriority = 0;
- argc--; argv++;
- }
-#endif
- else if (!strcmp(*argv, "-soundindev") ||
- !strcmp(*argv, "-audioindev"))
- { /* IOhannes */
- sys_parsedevlist(&sys_nsoundin, sys_soundindevlist,
- MAXAUDIOINDEV, argv[1]);
- if (!sys_nsoundin)
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-soundoutdev") ||
- !strcmp(*argv, "-audiooutdev"))
- { /* IOhannes */
- sys_parsedevlist(&sys_nsoundout, sys_soundoutdevlist,
- MAXAUDIOOUTDEV, argv[1]);
- if (!sys_nsoundout)
- goto usage;
- argc -= 2; argv += 2;
- }
- else if (!strcmp(*argv, "-sounddev") || !strcmp(*argv, "-audiodev"))
- {
- sys_parsedevlist(&sys_nsoundin, sys_soundindevlist,
- MAXAUDIOINDEV, argv[1]);
- sys_parsedevlist(&sys_nsoundout, sys_soundoutdevlist,
- MAXAUDIOOUTDEV, argv[1]);
- if (!sys_nsoundout)
- goto usage;
- argc -= 2; argv += 2;
- }
- else
- {
- unsigned int i;
- usage:
- for (i = 0; i < sizeof(usagemessage)/sizeof(*usagemessage); i++)
- fprintf(stderr, "%s", usagemessage[i]);
- return (1);
- }
- }
- if (!sys_defaultfont)
- sys_defaultfont = DEFAULTFONT;
- for (; argc > 0; argc--, argv++)
- sys_openlist = namelist_append(sys_openlist, *argv);
-
-
- return (0);
-}
-
-int sys_getblksize(void)
-{
- return (DEFDACBLKSIZE);
-}
-
- /* stuff to do, once, after calling sys_argparse() -- which may itself
- be called twice because of the .pdrc hack. */
-static void sys_afterargparse(void)
-{
- char sbuf[MAXPDSTRING];
- int i;
- /* add "extra" library to path */
- strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
- sbuf[MAXPDSTRING-30] = 0;
- strcat(sbuf, "/extra");
- sys_addpath(sbuf);
- strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
- sbuf[MAXPDSTRING-30] = 0;
- strcat(sbuf, "/intern");
- sys_addpath(sbuf);
- /* add "doc/5.reference" library to helppath */
- strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
- sbuf[MAXPDSTRING-30] = 0;
- strcat(sbuf, "/doc/5.reference");
- sys_addhelppath(sbuf);
- /* correct to make audio and MIDI device lists zero based. On
- MMIO, however, "1" really means the second device (the first one
- is "mapper" which is was not included when the command args were
- set up, so we leave it that way for compatibility. */
- if (!sys_mmio)
- {
- for (i = 0; i < sys_nsoundin; i++)
- sys_soundindevlist[i]--;
- for (i = 0; i < sys_nsoundout; i++)
- sys_soundoutdevlist[i]--;
- }
- for (i = 0; i < sys_nmidiin; i++)
- sys_midiindevlist[i]--;
- for (i = 0; i < sys_nmidiout; i++)
- sys_midioutdevlist[i]--;
-}
-
-static void sys_addreferencepath(void)
-{
- char sbuf[MAXPDSTRING];
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_midi.c b/apps/plugins/pdbox/PDa/src/s_midi.c
index 4338b49432..72a8792b25 100644
--- a/apps/plugins/pdbox/PDa/src/s_midi.c
+++ b/apps/plugins/pdbox/PDa/src/s_midi.c
@@ -639,644 +639,4 @@ void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
sys_close_midi();
sys_open_midi(nindev, newmidiindev, noutdev, newmidioutdev);
}
-/* Copyright (c) 1997-1999 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* Clock functions (which should move, but where?) and MIDI queueing */
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include "m_imp.h"
-#ifdef UNIX
-#include <unistd.h>
-#include <sys/time.h>
-#ifdef HAVE_BSTRING_H
-#include <bstring.h>
-#endif
-#endif
-#ifdef MSW
-#include <winsock.h>
-#include <sys/types.h>
-#include <sys/timeb.h>
-#include <wtypes.h>
-#endif
-#include <string.h>
-#include <stdio.h>
-#include <signal.h>
-
-typedef struct _midiqelem
-{
- double q_time;
- int q_portno;
- unsigned char q_onebyte;
- unsigned char q_byte1;
- unsigned char q_byte2;
- unsigned char q_byte3;
-} t_midiqelem;
-
-#define MIDIQSIZE 1024
-
-t_midiqelem midi_outqueue[MIDIQSIZE];
-int midi_outhead, midi_outtail;
-t_midiqelem midi_inqueue[MIDIQSIZE];
-int midi_inhead, midi_intail;
-static double sys_midiinittime;
-
- /* this is our current estimate for at what "system" real time the
- current logical time's output should occur. */
-static double sys_dactimeminusrealtime;
- /* same for input, should be schduler advance earlier. */
-static double sys_adctimeminusrealtime;
-
-static double sys_newdactimeminusrealtime = -1e20;
-static double sys_newadctimeminusrealtime = -1e20;
-static double sys_whenupdate;
-
-void sys_initmidiqueue( void)
-{
- sys_midiinittime = clock_getlogicaltime();
- sys_dactimeminusrealtime = sys_adctimeminusrealtime = 0;
-}
-
- /* this is called from the OS dependent code from time to time when we
- think we know the delay (outbuftime) in seconds, at which the last-output
- audio sample will go out the door. */
-void sys_setmiditimediff(double inbuftime, double outbuftime)
-{
- double dactimeminusrealtime =
- .001 * clock_gettimesince(sys_midiinittime)
- - outbuftime - sys_getrealtime();
- double adctimeminusrealtime =
- .001 * clock_gettimesince(sys_midiinittime)
- + inbuftime - sys_getrealtime();
- if (dactimeminusrealtime > sys_newdactimeminusrealtime)
- sys_newdactimeminusrealtime = dactimeminusrealtime;
- if (adctimeminusrealtime > sys_newadctimeminusrealtime)
- sys_newadctimeminusrealtime = adctimeminusrealtime;
- if (sys_getrealtime() > sys_whenupdate)
- {
- sys_dactimeminusrealtime = sys_newdactimeminusrealtime;
- sys_adctimeminusrealtime = sys_newadctimeminusrealtime;
- sys_newdactimeminusrealtime = -1e20;
- sys_newadctimeminusrealtime = -1e20;
- sys_whenupdate = sys_getrealtime() + 1;
- }
-}
-
- /* return the logical time of the DAC sample we believe is currently
- going out, based on how much "system time" has elapsed since the
- last time sys_setmiditimediff got called. */
-static double sys_getmidioutrealtime( void)
-{
- return (sys_getrealtime() + sys_dactimeminusrealtime);
-}
-
-static double sys_getmidiinrealtime( void)
-{
- return (sys_getrealtime() + sys_adctimeminusrealtime);
-}
-
-static void sys_putnext( void)
-{
- 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);
-}
-
-/* #define TEST_DEJITTER */
-
-void sys_pollmidioutqueue( void)
-{
-#ifdef TEST_DEJITTER
- static int db = 0;
-#endif
- double midirealtime = sys_getmidioutrealtime();
-#ifdef TEST_DEJITTER
- if (midi_outhead == midi_outtail)
- db = 0;
-#endif
- while (midi_outhead != midi_outtail)
- {
-#ifdef TEST_DEJITTER
- if (!db)
- {
- post("out: del %f, midiRT %f logicaltime %f, RT %f dacminusRT %f",
- (midi_outqueue[midi_outtail].q_time - midirealtime),
- midirealtime, .001 * clock_gettimesince(sys_midiinittime),
- sys_getrealtime(), sys_dactimeminusrealtime);
- db = 1;
- }
-#endif
- if (midi_outqueue[midi_outtail].q_time <= midirealtime)
- sys_putnext();
- else break;
- }
-}
-
-static void sys_queuemidimess(int portno, int onebyte, int a, int b, int c)
-{
- t_midiqelem *midiqelem;
- int newhead = midi_outhead +1;
- if (newhead == MIDIQSIZE)
- newhead = 0;
- /* if FIFO is full flush an element to make room */
- if (newhead == midi_outtail)
- sys_putnext();
- midi_outqueue[midi_outhead].q_portno = portno;
- midi_outqueue[midi_outhead].q_onebyte = onebyte;
- midi_outqueue[midi_outhead].q_byte1 = a;
- midi_outqueue[midi_outhead].q_byte2 = b;
- midi_outqueue[midi_outhead].q_byte3 = c;
- midi_outqueue[midi_outhead].q_time =
- .001 * clock_gettimesince(sys_midiinittime);
- midi_outhead = newhead;
- sys_pollmidioutqueue();
-}
-
-#define MIDI_NOTEON 144
-#define MIDI_POLYAFTERTOUCH 160
-#define MIDI_CONTROLCHANGE 176
-#define MIDI_PROGRAMCHANGE 192
-#define MIDI_AFTERTOUCH 208
-#define MIDI_PITCHBEND 224
-
-void outmidi_noteon(int portno, int channel, int pitch, int velo)
-{
- if (pitch < 0) pitch = 0;
- else if (pitch > 127) pitch = 127;
- if (velo < 0) velo = 0;
- else if (velo > 127) velo = 127;
- sys_queuemidimess(portno, 0, MIDI_NOTEON + (channel & 0xf), pitch, velo);
-}
-
-void outmidi_controlchange(int portno, int channel, int ctl, int value)
-{
- if (ctl < 0) ctl = 0;
- else if (ctl > 127) ctl = 127;
- if (value < 0) value = 0;
- else if (value > 127) value = 127;
- sys_queuemidimess(portno, 0, MIDI_CONTROLCHANGE + (channel & 0xf),
- ctl, value);
-}
-
-void outmidi_programchange(int portno, int channel, int value)
-{
- if (value < 0) value = 0;
- else if (value > 127) value = 127;
- sys_queuemidimess(portno, 0,
- MIDI_PROGRAMCHANGE + (channel & 0xf), value, 0);
-}
-
-void outmidi_pitchbend(int portno, int channel, int value)
-{
- if (value < 0) value = 0;
- else if (value > 16383) value = 16383;
- sys_queuemidimess(portno, 0, MIDI_PITCHBEND + (channel & 0xf),
- (value & 127), ((value>>7) & 127));
-}
-
-void outmidi_aftertouch(int portno, int channel, int value)
-{
- if (value < 0) value = 0;
- else if (value > 127) value = 127;
- sys_queuemidimess(portno, 0, MIDI_AFTERTOUCH + (channel & 0xf), value, 0);
-}
-
-void outmidi_polyaftertouch(int portno, int channel, int pitch, int value)
-{
- if (pitch < 0) pitch = 0;
- else if (pitch > 127) pitch = 127;
- if (value < 0) value = 0;
- else if (value > 127) value = 127;
- sys_queuemidimess(portno, 0, MIDI_POLYAFTERTOUCH + (channel & 0xf),
- pitch, value);
-}
-
-void outmidi_mclk(int portno)
-{
- sys_queuemidimess(portno, 1, 0xf8, 0,0);
-}
-
-/* ------------------------- MIDI input queue handling ------------------ */
-typedef struct midiparser
-{
- int mp_status;
- int mp_gotbyte1;
- int mp_byte1;
-} t_midiparser;
-
-#define MIDINOTEOFF 0x80 /* 2 following 'data bytes' */
-#define MIDINOTEON 0x90 /* 2 */
-#define MIDIPOLYTOUCH 0xa0 /* 2 */
-#define MIDICONTROLCHANGE 0xb0 /* 2 */
-#define MIDIPROGRAMCHANGE 0xc0 /* 1 */
-#define MIDICHANNELTOUCH 0xd0 /* 1 */
-#define MIDIPITCHBEND 0xe0 /* 2 */
-#define MIDISTARTSYSEX 0xf0 /* (until F7) */
-#define MIDITIMECODE 0xf1 /* 1 */
-#define MIDISONGPOS 0xf2 /* 2 */
-#define MIDISONGSELECT 0xf3 /* 1 */
-#define MIDIRESERVED1 0xf4 /* ? */
-#define MIDIRESERVED2 0xf5 /* ? */
-#define MIDITUNEREQUEST 0xf6 /* 0 */
-#define MIDIENDSYSEX 0xf7 /* 0 */
-#define MIDICLOCK 0xf8 /* 0 */
-#define MIDITICK 0xf9 /* 0 */
-#define MIDISTART 0xfa /* 0 */
-#define MIDICONT 0xfb /* 0 */
-#define MIDISTOP 0xfc /* 0 */
-#define MIDIACTIVESENSE 0xfe /* 0 */
-#define MIDIRESET 0xff /* 0 */
-
- /* functions in x_midi.c */
-void inmidi_realtimein(int portno, int cmd);
-void inmidi_byte(int portno, int byte);
-void inmidi_sysex(int portno, int byte);
-void inmidi_noteon(int portno, int channel, int pitch, int velo);
-void inmidi_controlchange(int portno, int channel, int ctlnumber, int value);
-void inmidi_programchange(int portno, int channel, int value);
-void inmidi_pitchbend(int portno, int channel, int value);
-void inmidi_aftertouch(int portno, int channel, int value);
-void inmidi_polyaftertouch(int portno, int channel, int pitch, int value);
-
-static void sys_dispatchnextmidiin( void)
-{
- static t_midiparser parser[MAXMIDIINDEV], *parserp;
- int portno = midi_inqueue[midi_intail].q_portno,
- byte = midi_inqueue[midi_intail].q_byte1;
- if (!midi_inqueue[midi_intail].q_onebyte)
- bug("sys_dispatchnextmidiin");
- if (portno < 0 || portno >= MAXMIDIINDEV)
- bug("sys_dispatchnextmidiin 2");
- parserp = parser + portno;
- outlet_setstacklim();
-
- if (byte >= 0xf8)
- inmidi_realtimein(portno, byte);
- else
- {
- inmidi_byte(portno, byte);
- if (byte & 0x80)
- {
- if (byte == MIDITUNEREQUEST || byte == MIDIRESERVED1 ||
- byte == MIDIRESERVED2)
- parserp->mp_status = 0;
- else if (byte == MIDISTARTSYSEX)
- {
- inmidi_sysex(portno, byte);
- parserp->mp_status = byte;
- }
- else if (byte == MIDIENDSYSEX)
- {
- inmidi_sysex(portno, byte);
- parserp->mp_status = 0;
- }
- else
- {
- parserp->mp_status = byte;
- }
- parserp->mp_gotbyte1 = 0;
- }
- else
- {
- int cmd = (parserp->mp_status >= 0xf0 ? parserp->mp_status :
- (parserp->mp_status & 0xf0));
- int chan = (parserp->mp_status & 0xf);
- int byte1 = parserp->mp_byte1, gotbyte1 = parserp->mp_gotbyte1;
- switch (cmd)
- {
- case MIDINOTEOFF:
- if (gotbyte1)
- inmidi_noteon(portno, chan, byte1, 0),
- parserp->mp_gotbyte1 = 0;
- else parserp->mp_byte1 = byte, parserp->mp_gotbyte1 = 1;
- break;
- case MIDINOTEON:
- if (gotbyte1)
- inmidi_noteon(portno, chan, byte1, byte),
- parserp->mp_gotbyte1 = 0;
- else parserp->mp_byte1 = byte, parserp->mp_gotbyte1 = 1;
- break;
- case MIDIPOLYTOUCH:
- if (gotbyte1)
- inmidi_polyaftertouch(portno, chan, byte1, byte),
- parserp->mp_gotbyte1 = 0;
- else parserp->mp_byte1 = byte, parserp->mp_gotbyte1 = 1;
- break;
- case MIDICONTROLCHANGE:
- if (gotbyte1)
- inmidi_controlchange(portno, chan, byte1, byte),
- parserp->mp_gotbyte1 = 0;
- else parserp->mp_byte1 = byte, parserp->mp_gotbyte1 = 1;
- break;
- case MIDIPROGRAMCHANGE:
- inmidi_programchange(portno, chan, byte);
- break;
- case MIDICHANNELTOUCH:
- inmidi_aftertouch(portno, chan, byte);
- break;
- case MIDIPITCHBEND:
- if (gotbyte1)
- inmidi_pitchbend(portno, chan, ((byte << 7) + byte1)),
- parserp->mp_gotbyte1 = 0;
- else parserp->mp_byte1 = byte, parserp->mp_gotbyte1 = 1;
- break;
- case MIDISTARTSYSEX:
- inmidi_sysex(portno, byte);
- break;
-
- /* other kinds of messages are just dropped here. We'll
- need another status byte before we start letting MIDI in
- again (no running status across "system" messages). */
- case MIDITIMECODE: /* 1 data byte*/
- break;
- case MIDISONGPOS: /* 2 */
- break;
- case MIDISONGSELECT: /* 1 */
- break;
- }
- }
- }
- midi_intail = (midi_intail + 1 == MIDIQSIZE ? 0 : midi_intail + 1);
-}
-
-void sys_pollmidiinqueue( void)
-{
-#ifdef TEST_DEJITTER
- static int db = 0;
-#endif
- double logicaltime = .001 * clock_gettimesince(sys_midiinittime);
-#ifdef TEST_DEJITTER
- if (midi_inhead == midi_intail)
- db = 0;
-#endif
- while (midi_inhead != midi_intail)
- {
-#ifdef TEST_DEJITTER
- if (!db)
- {
- post("in del %f, logicaltime %f, RT %f adcminusRT %f",
- (midi_inqueue[midi_intail].q_time - logicaltime),
- logicaltime, sys_getrealtime(), sys_adctimeminusrealtime);
- db = 1;
- }
-#endif
-#if 0
- if (midi_inqueue[midi_intail].q_time <= logicaltime - 0.007)
- post("late %f",
- 1000 * (logicaltime - midi_inqueue[midi_intail].q_time));
-#endif
- if (midi_inqueue[midi_intail].q_time <= logicaltime)
- {
-#if 0
- post("diff %f",
- 1000* (logicaltime - midi_inqueue[midi_intail].q_time));
-#endif
- sys_dispatchnextmidiin();
- }
- else break;
- }
-}
-
- /* this should be called from the system dependent MIDI code when a byte
- comes in, as a result of our calling sys_poll_midi. We stick it on a
- timetag queue and dispatch it at the appropriate logical time. */
-
-
-void sys_midibytein(int portno, int byte)
-{
- static int warned = 0;
- t_midiqelem *midiqelem;
- int newhead = midi_inhead +1;
- if (newhead == MIDIQSIZE)
- newhead = 0;
- /* if FIFO is full flush an element to make room */
- if (newhead == midi_intail)
- {
- if (!warned)
- {
- post("warning: MIDI timing FIFO overflowed");
- warned = 1;
- }
- sys_dispatchnextmidiin();
- }
- midi_inqueue[midi_inhead].q_portno = portno;
- midi_inqueue[midi_inhead].q_onebyte = 1;
- midi_inqueue[midi_inhead].q_byte1 = byte;
- midi_inqueue[midi_inhead].q_time = sys_getmidiinrealtime();
- midi_inhead = newhead;
- sys_pollmidiinqueue();
-}
-
-void sys_pollmidiqueue( void)
-{
-#if 0
- static double lasttime;
- double newtime = sys_getrealtime();
- if (newtime - lasttime > 0.007)
- post("delay %d", (int)(1000 * (newtime - lasttime)));
- lasttime = newtime;
-#endif
- sys_poll_midi(); /* OS dependent poll for MIDI input */
- sys_pollmidioutqueue();
- sys_pollmidiinqueue();
-}
-
-/******************** dialog window and device listing ********************/
-
-#ifdef USEAPI_OSS
-void midi_oss_init( void);
-#endif
-
- /* last requested parameters */
-static int midi_nmidiindev;
-static int midi_midiindev[MAXMIDIINDEV];
-static int midi_nmidioutdev;
-static int midi_midioutdev[MAXMIDIOUTDEV];
-
-static void sys_get_midi_params(int *pnmidiindev, int *pmidiindev,
- int *pnmidioutdev, int *pmidioutdev)
-{
- int i;
- *pnmidiindev = midi_nmidiindev;
- for (i = 0; i < MAXMIDIINDEV; i++)
- pmidiindev[i] = midi_midiindev[i];
- *pnmidioutdev = midi_nmidioutdev;
- for (i = 0; i < MAXMIDIOUTDEV; i++)
- pmidioutdev[i] = midi_midioutdev[i];
-}
-
-static void sys_save_midi_params(
- int nmidiindev, int *midiindev,
- int nmidioutdev, int *midioutdev)
-{
- int i;
- midi_nmidiindev = nmidiindev;
- for (i = 0; i < MAXMIDIINDEV; i++)
- midi_midiindev[i] = midiindev[i];
- midi_nmidioutdev = nmidioutdev;
- for (i = 0; i < MAXMIDIOUTDEV; i++)
- midi_midioutdev[i] = midioutdev[i];
-}
-
-void sys_open_midi(int nmidiindev, int *midiindev,
- int nmidioutdev, int *midioutdev)
-{
-#ifdef USEAPI_OSS
- midi_oss_init();
-#endif
- sys_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
- sys_save_midi_params(nmidiindev, midiindev,
- nmidioutdev, midioutdev);
-}
-
- /* open midi using whatever parameters were last used */
-void sys_reopen_midi( void)
-{
- int nmidiindev, midiindev[MAXMIDIINDEV];
- int nmidioutdev, midioutdev[MAXMIDIOUTDEV];
- sys_get_midi_params(&nmidiindev, midiindev, &nmidioutdev, midioutdev);
- sys_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
-}
-
-#define MAXNDEV 20
-#define DEVDESCSIZE 80
-
-#ifdef MSW
-#define DEVONSET 0 /* microsoft device list starts at 0 (the "mapper"). */
-#else /* (see also MSW ifdef in sys_parsedevlist(), s_main.c) */
-#define DEVONSET 1 /* To agree with command line flags, normally start at 1 */
-#endif
-
-void sys_listmididevs(void )
-{
- char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
- int nindevs = 0, noutdevs = 0, i;
-
- midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs,
- MAXNDEV, DEVDESCSIZE);
-
- if (!nindevs)
- post("no midi input devices found");
- else
- {
- post("input devices:");
- for (i = 0; i < nindevs; i++)
- post("%d. %s", i+1, indevlist + i * DEVDESCSIZE);
- }
- if (!noutdevs)
- post("no midi output devices found");
- else
- {
- post("output devices:");
- for (i = 0; i < noutdevs; i++)
- post("%d. %s", i+DEVONSET, outdevlist + i * DEVDESCSIZE);
- }
-}
-
-extern t_class *glob_pdobject;
-
- /* start an midi settings dialog window */
-void glob_midi_properties(t_pd *dummy, t_floatarg flongform)
-{
- char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)];
- /* these are the devices you're using: */
- int nindev, midiindev[MAXMIDIINDEV];
- int noutdev, midioutdev[MAXMIDIOUTDEV];
- int midiindev1, midiindev2, midiindev3, midiindev4,
- midioutdev1, midioutdev2, midioutdev3, midioutdev4;
-
- /* these are all the devices on your system: */
- char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
- int nindevs = 0, noutdevs = 0, i;
-
- char indevliststring[MAXNDEV*(DEVDESCSIZE+4)+80],
- outdevliststring[MAXNDEV*(DEVDESCSIZE+4)+80];
-
- midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs,
- MAXNDEV, DEVDESCSIZE);
-
- strcpy(indevliststring, "{ {none} ");
- for (i = 0; i < nindevs; i++)
- {
- strcat(indevliststring, "\"");
- strcat(indevliststring, indevlist + i * DEVDESCSIZE);
- strcat(indevliststring, "\" ");
- }
- strcat(indevliststring, "}");
-
- strcpy(outdevliststring, "{ {none} ");
- for (i = 0; i < noutdevs; i++)
- {
- strcat(outdevliststring, "\"");
- strcat(outdevliststring, outdevlist + i * DEVDESCSIZE);
- strcat(outdevliststring, "\" ");
- }
- strcat(outdevliststring, "}");
-
- sys_get_midi_params(&nindev, midiindev, &noutdev, midioutdev);
-
- if (nindev > 1 || noutdev > 1)
- flongform = 1;
-
- midiindev1 = (nindev > 0 && midiindev[0]>= 0 ? midiindev[0]+1 : 0);
- midiindev2 = (nindev > 1 && midiindev[1]>= 0 ? midiindev[1]+1 : 0);
- midiindev3 = (nindev > 2 && midiindev[2]>= 0 ? midiindev[2]+1 : 0);
- midiindev4 = (nindev > 3 && midiindev[3]>= 0 ? midiindev[3]+1 : 0);
- midioutdev1 = (noutdev > 0 && midioutdev[0]>=0 ? midioutdev[0]+1 : 0);
- midioutdev2 = (noutdev > 1 && midioutdev[1]>=0 ? midioutdev[1]+1 : 0);
- midioutdev3 = (noutdev > 2 && midioutdev[2]>=0 ? midioutdev[2]+1 : 0);
- midioutdev4 = (noutdev > 3 && midioutdev[3]>=0 ? midioutdev[3]+1 : 0);
-
- sprintf(buf,
-"pdtk_midi_dialog %%s \
-%s %d %d %d %d %s %d %d %d %d \
-%d\n",
- indevliststring,
- midiindev1, midiindev2, midiindev3, midiindev4,
- outdevliststring,
- midioutdev1, midioutdev2, midioutdev3, midioutdev4,
- (flongform != 0));
- gfxstub_deleteforkey(0);
- gfxstub_new(&glob_pdobject, glob_midi_properties, buf);
-}
-
- /* new values from dialog window */
-void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- int nmidiindev, midiindev[MAXMIDIINDEV];
- int nmidioutdev, midioutdev[MAXMIDIOUTDEV];
- int i, nindev, noutdev;
- int newmidiindev[4], newmidioutdev[4];
-
- for (i = 0; i < 4; i++)
- {
- newmidiindev[i] = atom_getintarg(i, argc, argv);
- newmidioutdev[i] = atom_getintarg(i+4, argc, argv);
- }
- for (i = 0, nindev = 0; i < 4; i++)
- {
- if (newmidiindev[i] > 0)
- {
- newmidiindev[nindev] = newmidiindev[i]-1;
- nindev++;
- }
- }
- for (i = 0, noutdev = 0; i < 4; i++)
- {
- if (newmidioutdev[i] > 0)
- {
- newmidioutdev[noutdev] = newmidioutdev[i]-1;
- noutdev++;
- }
- }
-
- sys_close_midi();
- sys_open_midi(nindev, newmidiindev, noutdev, newmidioutdev);
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_midi_oss.c b/apps/plugins/pdbox/PDa/src/s_midi_oss.c
index 1adfcd0d0c..fab1d84b6f 100644
--- a/apps/plugins/pdbox/PDa/src/s_midi_oss.c
+++ b/apps/plugins/pdbox/PDa/src/s_midi_oss.c
@@ -357,362 +357,4 @@ void midi_getdevs(char *indevlist, int *nindevs,
sprintf(outdevlist + i * devdescsize, "OSS MIDI device #%d", i+1);
*noutdevs = ndev;
}
-/* 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 OSS */
-
-#include <stdio.h>
-#ifdef UNIX
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "m_pd.h"
-#include "s_stuff.h"
-
-static int oss_nmidiin;
-static int oss_midiinfd[MAXMIDIINDEV];
-static int oss_nmidiout;
-static int oss_midioutfd[MAXMIDIOUTDEV];
-
-static void oss_midiout(int fd, int n)
-{
- char b = n;
- if ((write(fd, (char *) &b, 1)) != 1)
- perror("midi write");
-}
-
-#define O_MIDIFLAG O_NDELAY
-
-void sys_do_open_midi(int nmidiin, int *midiinvec,
- int nmidiout, int *midioutvec)
-{
- int i;
- for (i = 0; i < nmidiout; i++)
- oss_midioutfd[i] = -1;
- for (i = 0, oss_nmidiin = 0; i < nmidiin; i++)
- {
- int fd = -1, j, outdevindex = -1;
- char namebuf[80];
- int devno = midiinvec[i];
-
- for (j = 0; j < nmidiout; j++)
- if (midioutvec[j] == midiinvec[i])
- outdevindex = j;
-
- /* try to open the device for read/write. */
- if (devno == 0 && fd < 0 && outdevindex >= 0)
- {
- sys_setalarm(1000000);
- fd = open("/dev/midi", O_RDWR | O_MIDIFLAG);
- if (sys_verbose)
- fprintf(stderr,
- "device 1: tried /dev/midi READ/WRITE; returned %d\n", fd);
- if (outdevindex >= 0 && fd >= 0)
- oss_midioutfd[outdevindex] = fd;
- }
- if (fd < 0 && outdevindex >= 0)
- {
- sys_setalarm(1000000);
- sprintf(namebuf, "/dev/midi%2.2d", devno);
- fd = open(namebuf, O_RDWR | O_MIDIFLAG);
- if (sys_verbose)
- fprintf(stderr,
- "device %d: tried %s READ/WRITE; returned %d\n",
- devno, namebuf, fd);
- if (outdevindex >= 0 && fd >= 0)
- oss_midioutfd[outdevindex] = fd;
- }
- if (fd < 0 && outdevindex >= 0)
- {
- sys_setalarm(1000000);
- sprintf(namebuf, "/dev/midi%d", devno);
- fd = open(namebuf, O_RDWR | O_MIDIFLAG);
- if (sys_verbose)
- fprintf(stderr, "device %d: tried %s READ/WRITE; returned %d\n",
- devno, namebuf, fd);
- if (outdevindex >= 0 && fd >= 0)
- oss_midioutfd[outdevindex] = fd;
- }
- if (devno == 1 && fd < 0)
- {
- sys_setalarm(1000000);
- fd = open("/dev/midi", O_RDONLY | O_MIDIFLAG);
- if (sys_verbose)
- fprintf(stderr,
- "device 1: tried /dev/midi READONLY; returned %d\n", fd);
- }
- if (fd < 0)
- {
- sys_setalarm(1000000);
- sprintf(namebuf, "/dev/midi%2.2d", devno);
- fd = open(namebuf, O_RDONLY | O_MIDIFLAG);
- if (sys_verbose)
- fprintf(stderr, "device %d: tried %s READONLY; returned %d\n",
- devno, namebuf, fd);
- }
- if (fd < 0)
- {
- sys_setalarm(1000000);
- sprintf(namebuf, "/dev/midi%d", devno);
- fd = open(namebuf, O_RDONLY | O_MIDIFLAG);
- if (sys_verbose)
- fprintf(stderr, "device %d: tried %s READONLY; returned %d\n",
- devno, namebuf, fd);
- }
- if (fd >= 0)
- oss_midiinfd[oss_nmidiin++] = fd;
- else post("couldn't open MIDI input device %d", devno);
- }
- for (i = 0, oss_nmidiout = 0; i < nmidiout; i++)
- {
- int fd = oss_midioutfd[i];
- char namebuf[80];
- int devno = midioutvec[i];
- if (devno == 1 && fd < 0)
- {
- sys_setalarm(1000000);
- fd = open("/dev/midi", O_WRONLY | O_MIDIFLAG);
- if (sys_verbose)
- fprintf(stderr,
- "device 1: tried /dev/midi WRITEONLY; returned %d\n", fd);
- }
- if (fd < 0)
- {
- sys_setalarm(1000000);
- sprintf(namebuf, "/dev/midi%2.2d", devno);
- fd = open(namebuf, O_WRONLY | O_MIDIFLAG);
- if (sys_verbose)
- fprintf(stderr, "device %d: tried %s WRITEONLY; returned %d\n",
- devno, namebuf, fd);
- }
- if (fd < 0)
- {
- sys_setalarm(1000000);
- sprintf(namebuf, "/dev/midi%d", devno);
- fd = open(namebuf, O_WRONLY | O_MIDIFLAG);
- if (sys_verbose)
- fprintf(stderr, "device %d: tried %s WRITEONLY; returned %d\n",
- devno, namebuf, fd);
- }
- if (fd >= 0)
- oss_midioutfd[oss_nmidiout++] = fd;
- else post("couldn't open MIDI output device %d", devno);
- }
-
- if (oss_nmidiin < nmidiin || oss_nmidiout < nmidiout || sys_verbose)
- post("opened %d MIDI input device(s) and %d MIDI output device(s).",
- oss_nmidiin, oss_nmidiout);
-
- sys_setalarm(0);
-}
-
-#define md_msglen(x) (((x)<0xC0)?2:((x)<0xE0)?1:((x)<0xF0)?2:\
- ((x)==0xF2)?2:((x)<0xF4)?1:0)
-
-void sys_putmidimess(int portno, int a, int b, int c)
-{
- if (portno >= 0 && portno < oss_nmidiout)
- {
- switch (md_msglen(a))
- {
- case 2:
- oss_midiout(oss_midioutfd[portno],a);
- oss_midiout(oss_midioutfd[portno],b);
- oss_midiout(oss_midioutfd[portno],c);
- return;
- case 1:
- oss_midiout(oss_midioutfd[portno],a);
- oss_midiout(oss_midioutfd[portno],b);
- return;
- case 0:
- oss_midiout(oss_midioutfd[portno],a);
- return;
- };
- }
-}
-
-void sys_putmidibyte(int portno, int byte)
-{
- if (portno >= 0 && portno < oss_nmidiout)
- oss_midiout(oss_midioutfd[portno], byte);
-}
-
-#if 0 /* this is the "select" version which doesn't work with OSS
- driver for emu10k1 (it doesn't implement select.) */
-void sys_poll_midi(void)
-{
- int i, throttle = 100;
- struct timeval timout;
- int did = 1, maxfd = 0;
- while (did)
- {
- fd_set readset, writeset, exceptset;
- did = 0;
- if (throttle-- < 0)
- break;
- timout.tv_sec = 0;
- timout.tv_usec = 0;
-
- FD_ZERO(&writeset);
- FD_ZERO(&readset);
- FD_ZERO(&exceptset);
- for (i = 0; i < oss_nmidiin; i++)
- {
- if (oss_midiinfd[i] > maxfd)
- maxfd = oss_midiinfd[i];
- FD_SET(oss_midiinfd[i], &readset);
- }
- select(maxfd+1, &readset, &writeset, &exceptset, &timout);
- for (i = 0; i < oss_nmidiin; i++)
- if (FD_ISSET(oss_midiinfd[i], &readset))
- {
- char c;
- int ret = read(oss_midiinfd[i], &c, 1);
- if (ret <= 0)
- fprintf(stderr, "Midi read error\n");
- else sys_midibytein(i, (c & 0xff));
- did = 1;
- }
- }
-}
-#else
- /* this version uses the asynchronous "read()" ... */
-void sys_poll_midi(void)
-{
- int i, throttle = 100;
- struct timeval timout;
- int did = 1, maxfd = 0;
- while (did)
- {
- fd_set readset, writeset, exceptset;
- did = 0;
- if (throttle-- < 0)
- break;
- for (i = 0; i < oss_nmidiin; i++)
- {
- char c;
- int ret = read(oss_midiinfd[i], &c, 1);
- if (ret < 0)
- {
- if (errno != EAGAIN)
- perror("MIDI");
- }
- else if (ret != 0)
- {
- sys_midibytein(i, (c & 0xff));
- did = 1;
- }
- }
- }
-}
-#endif
-
-void sys_close_midi()
-{
- int i;
- for (i = 0; i < oss_nmidiin; i++)
- close(oss_midiinfd[i]);
- for (i = 0; i < oss_nmidiout; i++)
- close(oss_midioutfd[i]);
- oss_nmidiin = oss_nmidiout = 0;
-}
-
-#define NSEARCH 10
-static int oss_nmidiindevs, oss_nmidioutdevs, oss_initted;
-
-void midi_oss_init(void)
-{
- int i;
- if (oss_initted)
- return;
- oss_initted = 1;
- for (i = 0; i < NSEARCH; i++)
- {
- int fd;
- char namebuf[80];
-
- oss_nmidiindevs = i;
- /* try to open the device for reading */
- if (i == 0)
- {
- fd = open("/dev/midi", O_RDONLY | O_NDELAY);
- if (fd >= 0)
- {
- close(fd);
- continue;
- }
- }
- sprintf(namebuf, "/dev/midi%2.2d", i);
- fd = open(namebuf, O_RDONLY | O_NDELAY);
- if (fd >= 0)
- {
- close(fd);
- continue;
- }
- sprintf(namebuf, "/dev/midi%d", i);
- fd = open(namebuf, O_RDONLY | O_NDELAY);
- if (fd >= 0)
- {
- close(fd);
- continue;
- }
- break;
- }
- for (i = 0; i < NSEARCH; i++)
- {
- int fd;
- char namebuf[80];
-
- oss_nmidioutdevs = i;
- /* try to open the device for writing */
- if (i == 0)
- {
- fd = open("/dev/midi", O_WRONLY | O_NDELAY);
- if (fd >= 0)
- {
- close(fd);
- continue;
- }
- }
- sprintf(namebuf, "/dev/midi%2.2d", i);
- fd = open(namebuf, O_WRONLY | O_NDELAY);
- if (fd >= 0)
- {
- close(fd);
- continue;
- }
- sprintf(namebuf, "/dev/midi%d", i);
- fd = open(namebuf, O_WRONLY | O_NDELAY);
- if (fd >= 0)
- {
- close(fd);
- continue;
- }
- break;
- }
-}
-
-void midi_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int maxndev, int devdescsize)
-{
- int i, ndev;
- if ((ndev = oss_nmidiindevs) > maxndev)
- ndev = maxndev;
- for (i = 0; i < ndev; i++)
- sprintf(indevlist + i * devdescsize, "OSS MIDI device #%d", i+1);
- *nindevs = ndev;
-
- if ((ndev = oss_nmidioutdevs) > maxndev)
- ndev = maxndev;
- for (i = 0; i < ndev; i++)
- sprintf(outdevlist + i * devdescsize, "OSS MIDI device #%d", i+1);
- *noutdevs = ndev;
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_midi_pm.c b/apps/plugins/pdbox/PDa/src/s_midi_pm.c
index b167175396..a4f376e0ca 100644
--- a/apps/plugins/pdbox/PDa/src/s_midi_pm.c
+++ b/apps/plugins/pdbox/PDa/src/s_midi_pm.c
@@ -164,169 +164,4 @@ void sys_listmididevs(void) /* lifted from pa_devs.c in portaudio */
printf("\n");
}
}
-/* Copyright (c) 1997-2003 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.
-
- this file calls portmidi to do MIDI I/O for MSW and Mac OSX.
-
-*/
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <stdio.h>
-#ifdef UNIX
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "portaudio.h"
-#include "portmidi.h"
-#include "porttime.h"
-#include "pminternal.h"
-static PmStream *mac_midiindevlist[MAXMIDIINDEV];
-static PmStream *mac_midioutdevlist[MAXMIDIOUTDEV];
-static int mac_nmidiindev;
-static int mac_nmidioutdev;
-
-void sys_open_midi(int nmidiin, int *midiinvec,
- int nmidiout, int *midioutvec)
-{
- int i = 0;
- int n = 0;
- PmError err;
-
- Pt_Start(1, 0, 0); /* start a timer with millisecond accuracy */
- mac_nmidiindev = 0;
-
- /* protect the unwary from having MIDI inputs open; they're
- bad news if you close Pd's terminal window. see sys_nmidiin
- in s_main.c too. */
-#ifdef MSW
- if (nmidiin)
- {
- post(
- "midi input enabled; warning, don't close the DOS window directly!");
- }
- else post("not using MIDI input (use 'pd -midiindev 1' to override)");
-#endif
-
- for (i = 0; i < nmidiin; i++)
- {
- if (midiinvec[i] == DEFMIDIDEV)
- midiinvec[i] = Pm_GetDefaultInputDeviceID();
- err = Pm_OpenInput(&mac_midiindevlist[mac_nmidiindev], midiinvec[i],
- NULL, 100, NULL, NULL, NULL);
- if (err)
- post("could not open midi input device number %d: %s",
- midiinvec[i], Pm_GetErrorText(err));
- else
- {
- if (sys_verbose)
- post("Midi Input opened.\n");
- mac_nmidiindev++;
- }
- }
-
- mac_nmidioutdev = 0;
- for (i = 0; i < nmidiout; i++)
- {
- if (midioutvec[i] == DEFMIDIDEV)
- midioutvec[i] = Pm_GetDefaultOutputDeviceID();
- err = Pm_OpenOutput(&mac_midioutdevlist[mac_nmidioutdev], midioutvec[i],
- NULL, 0, NULL, NULL, 0);
- if (err)
- post("could not open midi output device number %d: %s",
- midioutvec[i], Pm_GetErrorText(err));
- else
- {
- if (sys_verbose)
- post("Midi Output opened.\n");
- mac_nmidioutdev++;
- }
- }
-}
-
-void sys_close_midi( void)
-{
- int i;
- for (i = 0; i < mac_nmidiindev; i++)
- Pm_Close(mac_midiindevlist[mac_nmidiindev]);
- mac_nmidiindev = 0;
- for (i = 0; i < mac_nmidioutdev; i++)
- Pm_Close(mac_midioutdevlist[mac_nmidioutdev]);
- mac_nmidioutdev = 0;
-}
-
-void sys_putmidimess(int portno, int a, int b, int c)
-{
- PmEvent buffer;
- fprintf(stderr, "put 1 msg %d %d\n", portno, mac_nmidioutdev);
- if (portno >= 0 && portno < mac_nmidioutdev)
- {
- buffer.message = Pm_Message(a, b, c);
- buffer.timestamp = 0;
- fprintf(stderr, "put msg\n");
- Pm_Write(mac_midioutdevlist[portno], &buffer, 1);
- }
-}
-
-void sys_putmidibyte(int portno, int byte)
-{
- post("sorry, no byte-by-byte MIDI output implemented in MAC OSX");
-}
-
-void sys_poll_midi(void)
-{
- int i, nmess;
- PmEvent buffer;
- for (i = 0; i < mac_nmidiindev; i++)
- {
- int nmess = Pm_Read(mac_midiindevlist[i], &buffer, 1);
- if (nmess > 0)
- {
- int status = Pm_MessageStatus(buffer.message);
- int data1 = Pm_MessageData1(buffer.message);
- int data2 = Pm_MessageData2(buffer.message);
- int msgtype = (status >> 4) - 8;
- switch (msgtype)
- {
- case 0:
- case 1:
- case 2:
- case 3:
- case 6:
- sys_midibytein(i, status);
- sys_midibytein(i, data1);
- sys_midibytein(i, data2);
- break;
- case 4:
- case 5:
- sys_midibytein(i, status);
- sys_midibytein(i, data1);
- break;
- case 7:
- sys_midibytein(i, status);
- break;
- }
- }
- }
-}
-
-void sys_listmididevs(void) /* lifted from pa_devs.c in portaudio */
-{
- int i,j;
- for (i = 0; i < Pm_CountDevices(); i++)
- {
- const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
- printf("%d: %s, %s", i, info->interf, info->name);
- if (info->input) printf(" (input)");
- if (info->output) printf(" (output)");
- printf("\n");
- }
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_midi_sgi.c b/apps/plugins/pdbox/PDa/src/s_midi_sgi.c
index cfe8efb0c8..105a812b49 100644
--- a/apps/plugins/pdbox/PDa/src/s_midi_sgi.c
+++ b/apps/plugins/pdbox/PDa/src/s_midi_sgi.c
@@ -186,191 +186,4 @@ void sys_set_priority(int foo)
fprintf(stderr,
"warning: priority boosting in IRIX not implemented yet\n");
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include "s_stuff.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#ifdef HAVE_BSTRING_H
-#include <bstring.h>
-#endif
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <dmedia/audio.h>
-#include <sys/fpu.h>
-#include <dmedia/midi.h>
-int mdInit(void); /* prototype was messed up in midi.h */
-/* #include "sys/select.h" */
-
-
- /*
- set the special "flush zero" but (FS, bit 24) in the
- Control Status Register of the FPU of R4k and beyond
- so that the result of any underflowing operation will
- be clamped to zero, and no exception of any kind will
- be generated on the CPU.
-
- thanks to cpirazzi@cp.esd.sgi.com (Chris Pirazzi).
- */
-
-static void sgi_flush_all_underflows_to_zero(void)
-{
- union fpc_csr f;
- f.fc_word = get_fpc_csr();
- f.fc_struct.flush = 1;
- set_fpc_csr(f.fc_word);
-}
-
-#define NPORT 2
-
-static MDport sgi_inport[NPORT];
-static MDport sgi_outport[NPORT];
-
-void sgi_open_midi(int midiin, int midiout)
-{
- int i;
- int sgi_nports = mdInit();
- if (sgi_nports < 0) sgi_nports = 0;
- else if (sgi_nports > NPORT) sgi_nports = NPORT;
- if (sys_verbose)
- {
- if (!sgi_nports)
- {
- post("no serial ports are configured for MIDI;");
- post("if you want to use MIDI, try exiting Pd, typing");
- post("'startmidi -d /dev/ttyd2' to a shell, and restarting Pd.");
- }
- else if (sgi_nports == 1)
- post("Found one MIDI port on %s", mdGetName(0));
- else if (sgi_nports == 2)
- post("Found MIDI ports on %s and %s",
- mdGetName(0), mdGetName(1));
- }
- if (midiin)
- {
- for (i = 0; i < sgi_nports; i++)
- {
- if (!(sgi_inport[i] = mdOpenInPort(mdGetName(i))))
- error("MIDI input port %d: open failed", i+1);;
- }
- }
- if (midiout)
- {
- for (i = 0; i < sgi_nports; i++)
- {
- if (!(sgi_outport[i] = mdOpenOutPort(mdGetName(i))))
- error("MIDI output port %d: open failed", i+1);;
- }
- }
- return;
-}
-void sys_putmidimess(int portno, int a, int b, int c)
-{
- MDevent mdv;
- if (portno >= NPORT || portno < 0 || !sgi_outport[portno]) return;
- mdv.msg[0] = a;
- mdv.msg[1] = b;
- mdv.msg[2] = c;
- mdv.msg[3] = 0;
- mdv.sysexmsg = 0;
- mdv.stamp = 0;
- mdv.msglen = 0;
- if (mdSend(sgi_outport[portno], &mdv, 1) < 0)
- error("MIDI output error\n");
- post("msg out %d %d %d", a, b, c);
-}
-
-void sys_putmidibyte(int portno, int foo)
-{
- error("MIDI raw byte output not available on SGI");
-}
-
-void inmidi_noteon(int portno, int channel, int pitch, int velo);
-void inmidi_controlchange(int portno, int channel, int ctlnumber, int value);
-void inmidi_programchange(int portno, int channel, int value);
-void inmidi_pitchbend(int portno, int channel, int value);
-void inmidi_aftertouch(int portno, int channel, int value);
-void inmidi_polyaftertouch(int portno, int channel, int pitch, int value);
-
-void sys_poll_midi(void)
-{
- int i;
- MDport *mp;
- for (i = 0, mp = sgi_inport; i < NPORT; i++, mp++)
- {
- int ret, status, b1, b2, nfds;
- MDevent mdv;
- fd_set inports;
- struct timeval timeout;
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
- if (!*mp) continue;
- FD_ZERO(&inports);
- FD_SET(mdGetFd(*mp), &inports);
-
- if (select(mdGetFd(*mp)+1 , &inports, 0, 0, &timeout) < 0)
- perror("midi select");
- if (FD_ISSET(mdGetFd(*mp),&inports))
- {
- if (mdReceive(*mp, &mdv, 1) < 0)
- error("failure receiving message\n");
- else if (mdv.msg[0] == MD_SYSEX) mdFree(mdv.sysexmsg);
-
- else
- {
- int status = mdv.msg[0];
- int channel = (status & 0xf) + 1;
- int b1 = mdv.msg[1];
- int b2 = mdv.msg[2];
- switch(status & 0xf0)
- {
- case MD_NOTEOFF:
- inmidi_noteon(i, channel, b1, 0);
- break;
- case MD_NOTEON:
- inmidi_noteon(i, channel, b1, b2);
- break;
- case MD_POLYKEYPRESSURE:
- inmidi_polyaftertouch(i, channel, b1, b2);
- break;
- case MD_CONTROLCHANGE:
- inmidi_controlchange(i, channel, b1, b2);
- break;
- case MD_PITCHBENDCHANGE:
- inmidi_pitchbend(i, channel, ((b2 << 7) + b1));
- break;
- case MD_PROGRAMCHANGE:
- inmidi_programchange(i, channel, b1);
- break;
- case MD_CHANNELPRESSURE:
- inmidi_aftertouch(i, channel, b1);
- break;
- }
- }
- }
- }
-}
-
-void sys_open_midi(int nmidiin, int *midiinvec,
- int nmidiout, int *midioutvec)
-{
- sgi_open_midi(nmidiin!=0, nmidiout!=0);
-}
-
-
-void sys_close_midi( void)
-{
- /* ??? */
-}
-
-void sys_set_priority(int foo)
-{
- fprintf(stderr,
- "warning: priority boosting in IRIX not implemented yet\n");
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_path.c b/apps/plugins/pdbox/PDa/src/s_path.c
index 26b8dfda99..f40f1f6e49 100644
--- a/apps/plugins/pdbox/PDa/src/s_path.c
+++ b/apps/plugins/pdbox/PDa/src/s_path.c
@@ -407,414 +407,3 @@ void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
}
}
-
-/* Copyright (c) 1999 Guenter Geiger and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/*
- * This file implements the loader for linux, which includes
- * a little bit of path handling.
- *
- * Generalized by MSP to provide an open_via_path function
- * and lists of files for all purposes.
- */
-
-/* #define DEBUG(x) x */
-#define DEBUG(x)
-void readsf_banana( void); /* debugging */
-
-#include <stdlib.h>
-#ifdef UNIX
-#include <unistd.h>
-#include <sys/stat.h>
-#endif
-#ifdef MSW
-#include <io.h>
-#endif
-
-#include <string.h>
-#include "m_pd.h"
-#include "m_imp.h"
-#include "s_stuff.h"
-#include <stdio.h>
-#include <fcntl.h>
-
-static t_namelist *pd_path, *pd_helppath;
-
-/* Utility functions */
-
-/* copy until delimiter and return position after delimiter in string */
-/* if it was the last substring, return NULL */
-
-static const char* strtokcpy(char *to, const char *from, int delim)
-{
- int size = 0;
-
- while (from[size] != (char)delim && from[size] != '\0')
- size++;
-
- strncpy(to,from,size);
- to[size] = '\0';
- if (from[size] == '\0') return NULL;
- if (size) return from+size+1;
- else return NULL;
-}
-
-/* add a colon-separated list of names to a namelist */
-
-#ifdef MSW
-#define SEPARATOR ';'
-#else
-#define SEPARATOR ':'
-#endif
-
-static t_namelist *namelist_doappend(t_namelist *listwas, const char *s)
-{
- t_namelist *nl = listwas, *rtn = listwas, *nl2;
- nl2 = (t_namelist *)(getbytes(sizeof(*nl)));
- nl2->nl_next = 0;
- nl2->nl_string = (char *)getbytes(strlen(s) + 1);
- strcpy(nl2->nl_string, s);
- sys_unbashfilename(nl2->nl_string, nl2->nl_string);
- if (!nl)
- nl = rtn = nl2;
- else
- {
- while (nl->nl_next)
- nl = nl->nl_next;
- nl->nl_next = nl2;
- }
- return (rtn);
-
-}
-
-t_namelist *namelist_append(t_namelist *listwas, const char *s)
-{
- const char *npos;
- char temp[MAXPDSTRING];
- t_namelist *nl = listwas, *rtn = listwas;
-
- npos = s;
- do
- {
- npos = strtokcpy(temp, npos, SEPARATOR);
- if (! *temp) continue;
- nl = namelist_doappend(nl, temp);
- }
- while (npos);
- return (nl);
-}
-
-void namelist_free(t_namelist *listwas)
-{
- t_namelist *nl, *nl2;
- for (nl = listwas; nl; nl = nl2)
- {
- nl2 = nl->nl_next;
- t_freebytes(nl->nl_string, strlen(nl->nl_string) + 1);
- t_freebytes(nl, sizeof(*nl));
- }
-}
-
-void sys_addpath(const char *p)
-{
- pd_path = namelist_append(pd_path, p);
-}
-
-void sys_addhelppath(const char *p)
-{
- pd_helppath = namelist_append(pd_helppath, p);
-}
-
-#ifdef MSW
-#define MSWOPENFLAG(bin) (bin ? _O_BINARY : _O_TEXT)
-#else
-#define MSWOPENFLAG(bin) 0
-#endif
-
-/* search for a file in a specified directory, then along the globally
-defined search path, using ext as filename extension. Exception:
-if the 'name' starts with a slash or a letter, colon, and slash in MSW,
-there is no search and instead we just try to open the file literally. The
-fd is returned, the directory ends up in the "dirresult" which must be at
-least "size" bytes. "nameresult" is set to point to the filename, which
-ends up in the same buffer as dirresult. */
-
-int open_via_path(const char *dir, const char *name, const char* ext,
- char *dirresult, char **nameresult, unsigned int size, int bin)
-{
- t_namelist *nl, thislist;
- int fd = -1;
- char listbuf[MAXPDSTRING];
-
- if (name[0] == '/'
-#ifdef MSW
- || (name[1] == ':' && name[2] == '/')
-#endif
- )
- {
- thislist.nl_next = 0;
- thislist.nl_string = listbuf;
- listbuf[0] = 0;
- }
- else
- {
- thislist.nl_string = listbuf;
- thislist.nl_next = pd_path;
- strncpy(listbuf, dir, MAXPDSTRING);
- listbuf[MAXPDSTRING-1] = 0;
- sys_unbashfilename(listbuf, listbuf);
- }
-
- for (nl = &thislist; nl; nl = nl->nl_next)
- {
- if (strlen(nl->nl_string) + strlen(name) + strlen(ext) + 4 >
- size)
- continue;
- strcpy(dirresult, nl->nl_string);
- if (*dirresult && dirresult[strlen(dirresult)-1] != '/')
- strcat(dirresult, "/");
- strcat(dirresult, name);
- strcat(dirresult, ext);
- sys_bashfilename(dirresult, dirresult);
-
- DEBUG(post("looking for %s",dirresult));
- /* see if we can open the file for reading */
- if ((fd=open(dirresult,O_RDONLY | MSWOPENFLAG(bin))) >= 0)
- {
- /* in UNIX, further check that it's not a directory */
-#ifdef UNIX
- struct stat statbuf;
- int ok = ((fstat(fd, &statbuf) >= 0) &&
- !S_ISDIR(statbuf.st_mode));
- if (!ok)
- {
- if (sys_verbose) post("tried %s; stat failed or directory",
- dirresult);
- close (fd);
- fd = -1;
- }
- else
-#endif
- {
- char *slash;
- if (sys_verbose) post("tried %s and succeeded", dirresult);
- sys_unbashfilename(dirresult, dirresult);
- slash = strrchr(dirresult, '/');
- if (slash)
- {
- *slash = 0;
- *nameresult = slash + 1;
- }
- else *nameresult = dirresult;
-
- return (fd);
- }
- }
- else
- {
- if (sys_verbose) post("tried %s and failed", dirresult);
- }
- }
- *dirresult = 0;
- *nameresult = dirresult;
- return (-1);
-}
-
-static int do_open_via_helppath(const char *realname, t_namelist *listp)
-{
- t_namelist *nl;
- int fd = -1;
- char dirresult[MAXPDSTRING], realdir[MAXPDSTRING];
- for (nl = listp; nl; nl = nl->nl_next)
- {
- strcpy(dirresult, nl->nl_string);
- strcpy(realdir, dirresult);
- if (*dirresult && dirresult[strlen(dirresult)-1] != '/')
- strcat(dirresult, "/");
- strcat(dirresult, realname);
- sys_bashfilename(dirresult, dirresult);
-
- DEBUG(post("looking for %s",dirresult));
- /* see if we can open the file for reading */
- if ((fd=open(dirresult,O_RDONLY | MSWOPENFLAG(0))) >= 0)
- {
- /* in UNIX, further check that it's not a directory */
-#ifdef UNIX
- struct stat statbuf;
- int ok = ((fstat(fd, &statbuf) >= 0) &&
- !S_ISDIR(statbuf.st_mode));
- if (!ok)
- {
- if (sys_verbose) post("tried %s; stat failed or directory",
- dirresult);
- close (fd);
- fd = -1;
- }
- else
-#endif
- {
- char *slash;
- if (sys_verbose) post("tried %s and succeeded", dirresult);
- sys_unbashfilename(dirresult, dirresult);
- close (fd);
- glob_evalfile(0, gensym((char*)realname), gensym(realdir));
- return (1);
- }
- }
- else
- {
- if (sys_verbose) post("tried %s and failed", dirresult);
- }
- }
- return (0);
-}
-
- /* LATER make this use open_via_path above. We expect the ".pd"
- suffix here, even though we have to tear it back off for one of the
- search attempts. */
-void open_via_helppath(const char *name, const char *dir)
-{
- t_namelist *nl, thislist, *listp;
- int fd = -1;
- char dirbuf2[MAXPDSTRING], realname[MAXPDSTRING];
-
- /* if directory is supplied, put it at head of search list. */
- if (*dir)
- {
- thislist.nl_string = dirbuf2;
- thislist.nl_next = pd_helppath;
- strncpy(dirbuf2, dir, MAXPDSTRING);
- dirbuf2[MAXPDSTRING-1] = 0;
- sys_unbashfilename(dirbuf2, dirbuf2);
- listp = &thislist;
- }
- else listp = pd_helppath;
- /* 1. "objectname-help.pd" */
- strncpy(realname, name, MAXPDSTRING-10);
- realname[MAXPDSTRING-10] = 0;
- if (strlen(realname) > 3 && !strcmp(realname+strlen(realname)-3, ".pd"))
- realname[strlen(realname)-3] = 0;
- strcat(realname, "-help.pd");
- if (do_open_via_helppath(realname, listp))
- return;
- /* 2. "help-objectname.pd" */
- strcpy(realname, "help-");
- strncat(realname, name, MAXPDSTRING-10);
- realname[MAXPDSTRING-1] = 0;
- if (do_open_via_helppath(realname, listp))
- return;
- /* 3. "objectname.pd" */
- if (do_open_via_helppath(name, listp))
- return;
- post("sorry, couldn't find help patch for \"%s\"", name);
- return;
-}
-
-
-/* Startup file reading for linux and MACOSX. This should be replaced by
-a better mechanism. This should be integrated with the audio, MIDI, and
-path dialog system. */
-
-#ifdef UNIX
-
-#define STARTUPNAME ".pdrc"
-#define NUMARGS 1000
-
-int sys_argparse(int argc, char **argv);
-
-int sys_rcfile(void)
-{
- FILE* file;
- int i;
- int k;
- int rcargc;
- char* rcargv[NUMARGS];
- char* buffer;
- char fname[MAXPDSTRING], buf[1000], *home = getenv("HOME");
-
- /* parse a startup file */
-
- *fname = '\0';
-
- strncat(fname, home? home : ".", MAXPDSTRING-10);
- strcat(fname, "/");
-
- strcat(fname, STARTUPNAME);
-
- if (!(file = fopen(fname, "r")))
- return 1;
-
- post("reading startup file: %s", fname);
-
- rcargv[0] = "."; /* this no longer matters to sys_argparse() */
-
- for (i = 1; i < NUMARGS-1; i++)
- {
- if (fscanf(file, "%999s", buf) < 0)
- break;
- buf[1000] = 0;
- if (!(rcargv[i] = malloc(strlen(buf) + 1)))
- return (1);
- strcpy(rcargv[i], buf);
- }
- if (i >= NUMARGS-1)
- fprintf(stderr, "startup file too long; extra args dropped\n");
- rcargv[i] = 0;
-
- rcargc = i;
-
- /* parse the options */
-
- fclose(file);
- if (sys_verbose)
- {
- if (rcargv)
- {
- post("startup args from RC file:");
- for (i = 1; i < rcargc; i++)
- post("%s", rcargv[i]);
- }
- else post("no RC file arguments found");
- }
- if (sys_argparse(rcargc, rcargv))
- {
- post("error parsing RC arguments");
- return (1);
- }
- return (0);
-}
-#endif /* UNIX */
-
- /* start an audio settings dialog window */
-void glob_start_path_dialog(t_pd *dummy, t_floatarg flongform)
-{
- char buf[MAXPDSTRING];
- int i;
- t_namelist *nl;
-
- for (nl = pd_path, i = 0; nl && i < 10; nl = nl->nl_next, i++)
- sys_vgui("pd_set pd_path%d \"%s\"\n", i, nl->nl_string);
- for (; i < 10; i++)
- sys_vgui("pd_set pd_path%d \"\"\n", i);
-
- sprintf(buf, "pdtk_path_dialog %%s\n");
- gfxstub_new(&glob_pdobject, glob_start_path_dialog, buf);
-}
-
- /* new values from dialog window */
-void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
-{
- int i;
- namelist_free(pd_path);
- pd_path = 0;
- for (i = 0; i < argc; i++)
- {
- t_symbol *s = atom_getsymbolarg(i, argc, argv);
- if (*s->s_name)
- sys_addpath(s->s_name);
- }
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/src/s_print.c b/apps/plugins/pdbox/PDa/src/s_print.c
index 1ef0eb6926..d3020782d5 100644
--- a/apps/plugins/pdbox/PDa/src/s_print.c
+++ b/apps/plugins/pdbox/PDa/src/s_print.c
@@ -148,153 +148,4 @@ void sys_ouch(void)
if (*errobject) error("%s: %s", errobject, errstring);
else error("%s", errstring);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include "m_pd.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-
-void post(char *fmt, ...)
-{
- va_list ap;
- t_int arg[8];
- int i;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- putc('\n', stderr);
-}
-
-void startpost(char *fmt, ...)
-{
- va_list ap;
- t_int arg[8];
- int i;
- va_start(ap, fmt);
-
- for (i = 0 ; i < 8; i++) arg[i] = va_arg(ap, t_int);
- va_end(ap);
- fprintf(stderr, fmt, arg[0], arg[1], arg[2], arg[3],
- arg[4], arg[5], arg[6], arg[7]);
-}
-
-void poststring(char *s)
-{
- fprintf(stderr, " %s", s);
-}
-
-void postatom(int argc, t_atom *argv)
-{
- int i;
- for (i = 0; i < argc; i++)
- {
- char buf[80];
- atom_string(argv+i, buf, 80);
- poststring(buf);
- }
-}
-
-void postfloat(float f)
-{
- char buf[80];
- t_atom a;
- SETFLOAT(&a, f);
- postatom(1, &a);
-}
-
-void endpost(void)
-{
- fprintf(stderr, "\n");
-}
-
-void error(char *fmt, ...)
-{
- va_list ap;
- t_int arg[8];
- int i;
- va_start(ap, fmt);
- fprintf(stderr, "error: ");
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- putc('\n', stderr);
-}
- /* here's the good way to log errors -- keep a pointer to the
- offending or offended object around so the user can search for it
- later. */
-
-static void *error_object;
-static char error_string[256];
-void canvas_finderror(void *object);
-
-void pd_error(void *object, char *fmt, ...)
-{
- va_list ap;
- t_int arg[8];
- int i;
- static int saidit = 0;
- va_start(ap, fmt);
- vsprintf(error_string, fmt, ap);
- va_end(ap);
- fprintf(stderr, "error: %s\n", error_string);
- error_object = object;
- if (!saidit)
- {
- post("... you might be able to track this down from the Find menu.");
- saidit = 1;
- }
-}
-
-void glob_finderror(t_pd *dummy)
-{
- if (!error_object)
- post("no findable error yet.");
- else
- {
- post("last trackable error:");
- post("%s", error_string);
- canvas_finderror(error_object);
- }
-}
-
-void bug(char *fmt, ...)
-{
- va_list ap;
- t_int arg[8];
- int i;
- va_start(ap, fmt);
-
- for (i = 0 ; i < 8; i++) arg[i] = va_arg(ap, t_int);
- va_end(ap);
- fprintf(stderr, "Consistency check failed: ");
- fprintf(stderr, fmt, arg[0], arg[1], arg[2], arg[3],
- arg[4], arg[5], arg[6], arg[7]);
- putc('\n', stderr);
-}
-
- /* this isn't worked out yet. */
-static char *errobject;
-static char *errstring;
-
-void sys_logerror(char *object, char *s)
-{
- errobject = object;
- errstring = s;
-}
-
-void sys_unixerror(char *object)
-{
- errobject = object;
- errstring = strerror(errno);
-}
-
-void sys_ouch(void)
-{
- if (*errobject) error("%s: %s", errobject, errstring);
- else error("%s", errstring);
-}
diff --git a/apps/plugins/pdbox/PDa/src/s_stuff.h b/apps/plugins/pdbox/PDa/src/s_stuff.h
index 6dc9a88c4b..2c7ae8b209 100644
--- a/apps/plugins/pdbox/PDa/src/s_stuff.h
+++ b/apps/plugins/pdbox/PDa/src/s_stuff.h
@@ -213,218 +213,4 @@ void sys_set_audio_state(int onoff);
/* API dependent audio flags and settings */
void oss_set32bit( void);
void linux_alsa_devname(char *devname);
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* Audio and MIDI I/O, and other scheduling and system stuff. */
-
-/* NOTE: this file describes Pd implementation details which may change
-in future releases. The public (stable) API is in m_pd.h. */
-
-/* in s_file.c */
-typedef struct _namelist
-{
- struct _namelist *nl_next;
- char *nl_string;
-} t_namelist;
-
-t_namelist *namelist_append(t_namelist *listwas, const char *s);
-void namelist_free(t_namelist *listwas);
-
-/* s_main.c */
-extern int sys_debuglevel;
-extern int sys_verbose;
-extern int sys_noloadbang;
-extern int sys_nogui;
-extern char *sys_guicmd;
-
-EXTERN int sys_nearestfontsize(int fontsize);
-EXTERN int sys_hostfontsize(int fontsize);
-
-extern int sys_defaultfont;
-extern t_symbol *sys_libdir; /* library directory for auxilliary files */
-
-/* s_loader.c */
-int sys_load_lib(char *dirname, char *filename);
-
-/* s_audio.c */
-
-#define SENDDACS_NO 0 /* return values for sys_send_dacs() */
-#define SENDDACS_YES 1
-#define SENDDACS_SLEPT 2
-
-#define DEFDACBLKSIZE 64
-extern int sys_schedblocksize; /* audio block size for scheduler */
-extern int sys_hipriority; /* real-time flag, true if priority boosted */
-extern t_sample *sys_soundout;
-extern t_sample *sys_soundin;
-extern int sys_inchannels;
-extern int sys_outchannels;
-extern int sys_advance_samples; /* scheduler advance in samples */
-extern int sys_blocksize; /* audio I/O block size in sample frames */
-extern float sys_dacsr;
-extern int sys_schedadvance;
-extern int sys_sleepgrain;
-void sys_open_audio(int naudioindev, int *audioindev,
- int nchindev, int *chindev,
- int naudiooutdev, int *audiooutdev, int nchoutdev, int *choutdev,
- int srate, int advance, int enable);
-void sys_close_audio(void);
-
- /* s_midi.c */
-void sys_open_midi(int nmidiin, int *midiinvec, int nmidiout, int *midioutvec);
-
- /* implemented in the system dependent MIDI code (s_midi_pm.c, etc. ) */
-void sys_do_open_midi(int nmidiin, int *midiinvec,
- int nmidiout, int *midioutvec);
-void sys_close_midi(void);
-void midi_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int maxndev, int devdescsize);
-
-int sys_send_dacs(void);
-void sys_reportidle(void);
-void sys_set_priority(int higher);
-void sys_audiobuf(int nbufs);
-void sys_getmeters(float *inmax, float *outmax);
-void sys_listdevs(void);
-void sys_setblocksize(int n);
-
-/* s_midi.c */
-#define MAXMIDIINDEV 16 /* max. number of input ports */
-#define MAXMIDIOUTDEV 16 /* max. number of output ports */
-extern int sys_nmidiin;
-extern int sys_nmidiout;
-extern int sys_midiindevlist[];
-extern int sys_midioutdevlist[];
-
-EXTERN void sys_putmidimess(int portno, int a, int b, int c);
-EXTERN void sys_putmidibyte(int portno, int a);
-EXTERN void sys_poll_midi(void);
-EXTERN void sys_setmiditimediff(double inbuftime, double outbuftime);
-EXTERN void sys_midibytein(int portno, int byte);
-
-/* m_sched.c */
-EXTERN void sys_log_error(int type);
-#define ERR_NOTHING 0
-#define ERR_ADCSLEPT 1
-#define ERR_DACSLEPT 2
-#define ERR_RESYNC 3
-#define ERR_DATALATE 4
-void sched_set_using_dacs(int flag);
-
-/* s_inter.c */
-
-EXTERN void sys_microsleep(int microsec);
-
-EXTERN void sys_bail(int exitcode);
-EXTERN int sys_pollgui(void);
-
-EXTERN_STRUCT _socketreceiver;
-#define t_socketreceiver struct _socketreceiver
-
-typedef void (*t_socketnotifier)(void *x);
-typedef void (*t_socketreceivefn)(void *x, t_binbuf *b);
-
-EXTERN t_socketreceiver *socketreceiver_new(void *owner,
- t_socketnotifier notifier, t_socketreceivefn socketreceivefn, int udp);
-EXTERN void socketreceiver_read(t_socketreceiver *x, int fd);
-EXTERN void sys_sockerror(char *s);
-EXTERN void sys_closesocket(int fd);
-
-typedef void (*t_fdpollfn)(void *ptr, int fd);
-EXTERN void sys_addpollfn(int fd, t_fdpollfn fn, void *ptr);
-EXTERN void sys_rmpollfn(int fd);
-#ifdef UNIX
-void sys_setalarm(int microsec);
-void sys_setvirtualalarm( void);
-#endif
-
-#define API_ALSA 1
-#define API_OSS 2
-#define API_MMIO 3
-#define API_PORTAUDIO 4
-#define API_JACK 5
-
-#ifdef __linux__
-#define API_DEFAULT API_OSS
-#define API_DEFSTRING "OSS"
-#endif
-#ifdef MSW
-#define API_DEFAULT API_MMIO
-#define API_DEFSTRING "MMIO"
-#endif
-#ifdef MACOSX
-#define API_DEFAULT API_PORTAUDIO
-#define API_DEFSTRING "portaudio"
-#endif
-#define DEFAULTAUDIODEV 0
-#define MAXAUDIOINDEV 4
-#define MAXAUDIOOUTDEV 4
-
-#define DEFMIDIDEV 0
-
-#define DEFAULTSRATE 44100
-#ifdef MSW
-#define DEFAULTADVANCE 70
-#else
-#define DEFAULTADVANCE 50
-#endif
-
-int pa_open_audio(int inchans, int outchans, int rate, t_sample *soundin,
- t_sample *soundout, int framesperbuf, int nbuffers,
- int indeviceno, int outdeviceno);
-void pa_close_audio(void);
-int pa_send_dacs(void);
-void sys_reportidle(void);
-void pa_listdevs(void);
-void pa_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize);
-
-int oss_open_audio(int naudioindev, int *audioindev, int nchindev,
- int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
- int *choutdev, int rate); /* IOhannes */
-void oss_close_audio(void);
-int oss_send_dacs(void);
-void oss_reportidle(void);
-void oss_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize);
-
-int alsa_open_audio(int naudioindev, int *audioindev, int nchindev,
- int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
- int *choutdev, int rate);
-void alsa_close_audio(void);
-int alsa_send_dacs(void);
-void alsa_reportidle(void);
-void alsa_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize);
-
-int jack_open_audio(int wantinchans, int wantoutchans, int srate);
-void jack_close_audio(void);
-int jack_send_dacs(void);
-void jack_reportidle(void);
-void jack_listdevs(void);
-
-void mmio_open_audio(int naudioindev, int *audioindev,
- int nchindev, int *chindev, int naudiooutdev, int *audiooutdev,
- int nchoutdev, int *choutdev, int rate);
-void mmio_close_audio( void);
-void mmio_reportidle(void);
-int mmio_send_dacs(void);
-void mmio_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize);
-
-void sys_listmididevs(void);
-void sys_set_audio_api(int whichapi);
-void sys_get_audio_apis(char *buf);
-extern int sys_audioapi;
-void sys_set_audio_state(int onoff);
-
-/* API dependent audio flags and settings */
-void oss_set32bit( void);
-void linux_alsa_devname(char *devname);
diff --git a/apps/plugins/pdbox/PDa/src/s_watchdog.c b/apps/plugins/pdbox/PDa/src/s_watchdog.c
index 48309c16c4..e8653e9e39 100644
--- a/apps/plugins/pdbox/PDa/src/s_watchdog.c
+++ b/apps/plugins/pdbox/PDa/src/s_watchdog.c
@@ -45,50 +45,4 @@ int main(int argc, char **argv)
fprintf(stderr, "watchdog: signaling pd...\n");
}
}
-/* Copyright (c) 1997-2000 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* This file is compiled into the separate program, "pd-watchdog," which
-tries to prevent Pd from locking up the processor if it's at realtime
-priority. Linux only. Invoked from s_inter.c. */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <signal.h>
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- int happy = 1;
- while (1)
- {
- struct timeval timout;
- fd_set readset;
- if (happy)
- {
- timout.tv_sec = 5;
- timout.tv_usec = 0;
- }
- else
- {
- timout.tv_sec = 2;
- timout.tv_usec = 0;
- }
- FD_ZERO(&readset);
- FD_SET(0, &readset);
- select(1, &readset, 0, 0, &timout);
- if (FD_ISSET(0, &readset))
- {
- char buf[100];
- happy = 1;
- if (read(0, &buf, 100) <= 0)
- return (0);
- else continue;
- }
- happy = 0;
- kill(getppid(), SIGHUP);
- fprintf(stderr, "watchdog: signaling pd...\n");
- }
-}
diff --git a/apps/plugins/pdbox/PDa/src/t_main.c b/apps/plugins/pdbox/PDa/src/t_main.c
index 7b80cb0dd6..d68579e745 100644
--- a/apps/plugins/pdbox/PDa/src/t_main.c
+++ b/apps/plugins/pdbox/PDa/src/t_main.c
@@ -118,123 +118,4 @@ Tcl_AppInit(interp)
}
#endif /* MACOSX */
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* This file should be compared with the corresponding thing in the TK
-* distribution whenever updating to newer versions of TCL/TK. */
-
-/*
- * Copyright (c) 1993 The Regents of the University of California.
- * Copyright (c) 1994 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-
-#ifndef MACOSX /* linux and IRIX only; in MACOSX we don't link this in */
-#include "tk.h"
-#include <stdlib.h>
-
-/*
- * The following variable is a special hack that is needed in order for
- * Sun shared libraries to be used for Tcl.
- */
-
-extern int matherr(void);
-int *tclDummyMathPtr = (int *) matherr;
-
-/*
- *----------------------------------------------------------------------
- *
- * main --
- *
- * This is the main program for the application.
- *
- * Results:
- * None: Tk_Main never returns here, so this procedure never
- * returns either.
- *
- * Side effects:
- * Whatever the application does.
- *
- *----------------------------------------------------------------------
- */
-
-void pdgui_startup(Tcl_Interp *interp);
-void pdgui_setname(char *name);
-void pdgui_setsock(int port);
-void pdgui_sethost(char *name);
-int
-main(int argc, char **argv)
-{
- pdgui_setname(argv[0]);
- if (argc >= 2)
- {
- pdgui_setsock(atoi(argv[1]));
- argc--; argv++;
- argv[0] = "Pd";
- }
- if (argc >= 2)
- {
- pdgui_sethost(argv[1]);
- argc--; argv++;
- argv[0] = "Pd";
- }
- Tk_Main(argc, argv, Tcl_AppInit);
- return 0; /* Needed only to prevent compiler warning. */
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_AppInit --
- *
- * This procedure performs application-specific initialization.
- * Most applications, especially those that incorporate additional
- * packages, will have their own version of this procedure.
- * Results:
- * Returns a standard Tcl completion code, and leaves an error
- * message in interp->result if an error occurs.
- *
- * Side effects:
- * Depends on the startup script.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tcl_AppInit(interp)
- Tcl_Interp *interp; /* Interpreter for application. */
-{
-
- if (Tcl_Init(interp) == TCL_ERROR) {
- return TCL_ERROR;
- }
- if (Tk_Init(interp) == TCL_ERROR) {
- return TCL_ERROR;
- }
-
- /* setup specific to pd-gui: */
-
- pdgui_startup(interp);
-
- /*
- * Specify a user-specific startup file to invoke if the application
- * is run interactively. Typically the startup file is "~/.apprc"
- * where "app" is the name of the application. If this line is deleted
- * then no user-specific startup file will be run under any conditions.
- */
-
-#if 0
- tcl_RcFileName = "~/.pdrc";
-#endif
-
- return TCL_OK;
-}
-
-#endif /* MACOSX */
diff --git a/apps/plugins/pdbox/PDa/src/t_tk.h b/apps/plugins/pdbox/PDa/src/t_tk.h
index e1c8e4e871..c72ff9bdb5 100644
--- a/apps/plugins/pdbox/PDa/src/t_tk.h
+++ b/apps/plugins/pdbox/PDa/src/t_tk.h
@@ -8,13 +8,4 @@ void pdgui_mess(char *s);
void pdgui_evalfile(char *s);
#define GUISTRING 1000
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-void pdgui_vmess(char *fmt, ...);
-void pdgui_mess(char *s);
-
-void pdgui_evalfile(char *s);
-
-#define GUISTRING 1000
diff --git a/apps/plugins/pdbox/PDa/src/t_tkcmd.c b/apps/plugins/pdbox/PDa/src/t_tkcmd.c
index 136412cad7..ff12a28494 100644
--- a/apps/plugins/pdbox/PDa/src/t_tkcmd.c
+++ b/apps/plugins/pdbox/PDa/src/t_tkcmd.c
@@ -396,401 +396,3 @@ int Pdtcl_SafeInit(Tcl_Interp *interp) {
return (TCL_OK);
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#ifdef UNIX /* in unix this only works first; in NT it only works last. */
-#include "tk.h"
-#endif
-
-#include "t_tk.h"
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#ifdef UNIX
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#ifdef HAVE_BSTRING_H
-#include <bstring.h>
-#endif
-#include <sys/time.h>
-#include <errno.h>
-#endif
-#ifdef MSW
-#include <winsock.h>
-#include <io.h>
-#endif
-#ifdef MSW
-#pragma warning( disable : 4305 ) /* uncast const double to float */
-#pragma warning( disable : 4244 ) /* uncast double to float */
-#pragma warning( disable : 4101 ) /* unused local variables */
-#endif
-
-#ifdef MSW
-#include "tk.h"
-#endif
-
-void tcl_mess(char *s);
-
-/***************** the socket setup code ********************/
-
-static int portno = 5400;
-
- /* some installations of linux don't know about "localhost" so give
- the loopback address; NT, on the other hand, can't understand the
- hostname "127.0.0.1". */
-char hostname[100] =
-#ifdef __linux__
- "127.0.0.1";
-#else
- "localhost";
-#endif
-
-void pdgui_setsock(int port)
-{
- portno = port;
-}
-
-void pdgui_sethost(char *name)
-{
- strncpy(hostname, name, 100);
- hostname[99] = 0;
-}
-
-static void pdgui_sockerror(char *s)
-{
-#ifdef MSW
- int err = WSAGetLastError();
-#endif
-#ifdef UNIX
- int err = errno;
-#endif
-
- fprintf(stderr, "%s: %s (%d)\n", s, strerror(err), err);
- tcl_mess("exit\n");
- exit(1);
-}
-
-static int sockfd;
-
-/* The "pd_suck" command, which polls the socket.
- FIXME: if Pd sends something bigger than SOCKSIZE we're in trouble!
- This has to be set bigger than any array update message for instance.
-*/
-#define SOCKSIZE 20000
-
-static char pd_tkbuf[SOCKSIZE+1];
-int pd_spillbytes = 0;
-
-static void pd_readsocket(ClientData cd, int mask)
-{
- int ngot;
- fd_set readset, writeset, exceptset;
- struct timeval timout;
-
- timout.tv_sec = 0;
- timout.tv_usec = 0;
- FD_ZERO(&writeset);
- FD_ZERO(&readset);
- FD_ZERO(&exceptset);
- FD_SET(sockfd, &readset);
- FD_SET(sockfd, &exceptset);
-
- if (select(sockfd+1, &readset, &writeset, &exceptset, &timout) < 0)
- perror("select");
- if (FD_ISSET(sockfd, &exceptset) || FD_ISSET(sockfd, &readset))
- {
- int ret;
- ret = recv(sockfd, pd_tkbuf + pd_spillbytes,
- SOCKSIZE - pd_spillbytes, 0);
- if (ret < 0) pdgui_sockerror("socket receive error");
- else if (ret == 0)
- {
- /* fprintf(stderr, "read %d\n", SOCKSIZE - pd_spillbytes); */
- fprintf(stderr, "pd_gui: pd process exited\n");
- tcl_mess("exit\n");
- }
- else
- {
- char *lastcr = 0, *bp = pd_tkbuf, *ep = bp + (pd_spillbytes + ret);
- int brace = 0;
- char lastc = 0;
- while (bp < ep)
- {
- char c = *bp;
- if (c == '}' && brace) brace--;
- else if (c == '{') brace++;
- else if (!brace && c == '\n' && lastc != '\\') lastcr = bp;
- lastc = c;
- bp++;
- }
- if (lastcr)
- {
- int xtra = pd_tkbuf + pd_spillbytes + ret - (lastcr+1);
- char bashwas = lastcr[1];
- lastcr[1] = 0;
- tcl_mess(pd_tkbuf);
- lastcr[1] = bashwas;
- if (xtra)
- {
- /* fprintf(stderr, "x %d\n", xtra); */
- memmove(pd_tkbuf, lastcr+1, xtra);
- }
- pd_spillbytes = xtra;
- }
- else
- {
- pd_spillbytes += ret;
- }
- }
- }
-}
-
-#ifndef UNIX
- /* if we aren't UNIX, we add a tcl command to poll the
- socket for data. */
-static int pd_pollsocketCmd(ClientData cd, Tcl_Interp *interp,
- int argc, char **argv)
-{
- pd_readsocket(cd, 0);
- return (TCL_OK);
-}
-#endif
-
-void pdgui_setupsocket(void)
-{
- struct sockaddr_in server;
- struct hostent *hp;
-#ifdef UNIX
- int retry = 10;
-#else
- int retry = 1;
-#endif
-#ifdef MSW
- short version = MAKEWORD(2, 0);
- WSADATA nobby;
-
- if (WSAStartup(version, &nobby)) pdgui_sockerror("setup");
-#endif
-
- /* create a socket */
- sockfd = socket(AF_INET, SOCK_STREAM, 0);
- if (sockfd < 0) pdgui_sockerror("socket");
-
- /* connect socket using hostname provided in command line */
- server.sin_family = AF_INET;
-
- hp = gethostbyname(hostname);
-
- if (hp == 0)
- {
- fprintf(stderr,
- "localhost not found (inet protocol not installed?)\n");
- exit(1);
- }
- memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
-
- /* assign client port number */
- server.sin_port = htons((unsigned short)portno);
-
- /* try to connect */
- while (1)
- {
- if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) >= 0)
- goto gotit;
- retry--;
- if (retry <= 0)
- break;
- /* In UNIX there's a race condition; the child won't be
- able to connect before the parent (pd) has shed its
- setuid-ness. In case this is the problem, sleep and
- retry. */
- else
- {
-#ifdef UNIX
- fd_set readset, writeset, exceptset;
- struct timeval timout;
-
- timout.tv_sec = 0;
- timout.tv_usec = 100000;
- FD_ZERO(&writeset);
- FD_ZERO(&readset);
- FD_ZERO(&exceptset);
- fprintf(stderr, "retrying connect...\n");
- if (select(1, &readset, &writeset, &exceptset, &timout) < 0)
- perror("select");
-#endif /* UNIX */
- }
- }
- pdgui_sockerror("connecting stream socket");
-gotit: ;
-#ifdef UNIX
- /* in unix we ask TK to call us back. In NT we have to poll. */
- Tk_CreateFileHandler(sockfd, TK_READABLE | TK_EXCEPTION,
- pd_readsocket, 0);
-#endif /* UNIX */
-}
-
-/**************************** commands ************************/
-static char *pdgui_path;
-
-/* The "pd" command, which cats its args together and throws the result
-* at the Pd interpreter.
-*/
-#define MAXWRITE 1024
-
-static int pdCmd(ClientData cd, Tcl_Interp *interp, int argc, char **argv)
-{
- if (argc == 2)
- {
- int n = strlen(argv[1]);
- if (send(sockfd, argv[1], n, 0) < n)
- {
- perror("stdout");
- tcl_mess("exit\n");
- }
- }
- else
- {
- int i;
- char buf[MAXWRITE];
- buf[0] = 0;
- for (i = 1; i < argc; i++)
- {
- if (strlen(argv[i]) + strlen(buf) + 2 > MAXWRITE)
- {
- interp->result = "pd: arg list too long";
- return (TCL_ERROR);
- }
- if (i > 1) strcat(buf, " ");
- strcat(buf, argv[i]);
- }
- if (send(sockfd, buf, strlen(buf), 0) < 0)
- {
- perror("stdout");
- tcl_mess("exit\n");
- }
- }
- return (TCL_OK);
-}
-
-/*********** "c" level access to tk functions. ******************/
-
-static Tcl_Interp *tk_myinterp;
-
-void tcl_mess(char *s)
-{
- int result;
- result = Tcl_Eval(tk_myinterp, s);
- if (result != TCL_OK)
- {
- if (*tk_myinterp->result) printf("%s\n", tk_myinterp->result);
- }
-}
-
-/* LATER should do a bounds check -- but how do you get printf to do that? */
-void tcl_vmess(char *fmt, ...)
-{
- int result, i;
- char buf[MAXWRITE];
- va_list ap;
-
- va_start(ap, fmt);
-
- vsprintf(buf, fmt, ap);
- result = Tcl_Eval(tk_myinterp, buf);
- if (result != TCL_OK)
- {
- if (*tk_myinterp->result) printf("%s\n", tk_myinterp->result);
- }
- va_end(ap);
-}
-
-#ifdef UNIX
-void pdgui_doevalfile(Tcl_Interp *interp, char *s)
-{
- char buf[GUISTRING];
- sprintf(buf, "set pd_guidir \"%s\"\n", pdgui_path);
- tcl_mess(buf);
- strcpy(buf, pdgui_path);
- strcat(buf, "/bin/");
- strcat(buf, s);
- if (Tcl_EvalFile(interp, buf) != TCL_OK)
- {
- char buf2[1000];
- sprintf(buf2, "puts [concat tcl: %s: can't open script]\n",
- buf);
- tcl_mess(buf2);
- }
-}
-
-void pdgui_evalfile(char *s)
-{
- pdgui_doevalfile(tk_myinterp, s);
-}
-#endif
-
-void pdgui_startup(Tcl_Interp *interp)
-{
-
- /* save pointer to the main interpreter */
- tk_myinterp = interp;
-
-
- /* add our own TK commands */
- Tcl_CreateCommand(interp, "pd", (Tcl_CmdProc*)pdCmd, (ClientData)NULL,
- (Tcl_CmdDeleteProc *)NULL);
-#ifndef UNIX
- Tcl_CreateCommand(interp, "pd_pollsocket",(Tcl_CmdProc*) pd_pollsocketCmd,
- (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
-#endif
- pdgui_setupsocket();
-
- /* read in the startup file */
-#if !defined(MSW) && !defined(MACOSX)
- pdgui_evalfile("pd.tk");
-#endif
-}
-
-#ifdef UNIX
-void pdgui_setname(char *s)
-{
- char *t;
- char *str;
- int n;
- if (t = strrchr(s, '/')) str = s, n = (t-s) + 1;
- else str = "./", n = 2;
- if (n > GUISTRING-100) n = GUISTRING-100;
- pdgui_path = malloc(n+9);
-
- strncpy(pdgui_path, str, n);
- while (strlen(pdgui_path) > 0 && pdgui_path[strlen(pdgui_path)-1] == '/')
- pdgui_path[strlen(pdgui_path)-1] = 0;
- if (t = strrchr(pdgui_path, '/'))
- *t = 0;
-}
-#endif
-
-int Pdtcl_Init(Tcl_Interp *interp)
-{
- const char *myvalue = Tcl_GetVar(interp, "argv", 0);
- int myportno;
- if (myvalue && (myportno = atoi(myvalue)) > 1)
- pdgui_setsock(myportno);
- tk_myinterp = interp;
- pdgui_startup(interp);
- interp->result = "loaded pdtcl_init";
-
- return (TCL_OK);
-}
-
-int Pdtcl_SafeInit(Tcl_Interp *interp) {
- fprintf(stderr, "Pdtcl_Safeinit 51\n");
- return (TCL_OK);
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/u_main.tk b/apps/plugins/pdbox/PDa/src/u_main.tk
index 00cb25c4a2..e8d5702f32 100644
--- a/apps/plugins/pdbox/PDa/src/u_main.tk
+++ b/apps/plugins/pdbox/PDa/src/u_main.tk
@@ -3365,3370 +3365,4 @@ proc pd_set {var value} {
global $var
set $var $value
}
-set pd_nt 1
-# (The above is 0 for unix, 1 for microsoft, and 2 for Mac OSX. The first
-# line is automatically munged by the relevant makefiles.)
-
-# Copyright (c) 1997-1999 Miller Puckette.
-# For information on usage and redistribution, and for a DISCLAIMER OF ALL
-# WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-
-# changed by Thomas Musil 09.2001
-# between "pdtk_graph_dialog -- dialog window for graphs"
-# and "pdtk_array_dialog -- dialog window for arrays"
-# a new dialogbox was inserted, named:
-# "pdtk_iemgui_dialog -- dialog window for iem guis"
-#
-# all this changes are labeled with #######iemlib##########
-
-# Tearoff is set to true by default:
-set pd_tearoff 0
-set menubar 1
-
-set File "F"
-set Windows "W"
-set Edit "E"
-set Find "F"
-set Put "P"
-set Media "M"
-set Help "H"
-
-set color grey16
-set lightcolor grey24
-
-option add *font -*-helvetica-*--bold--9-*
-
-# los colores de la muerte
-
-option add *background $color
-option add *activeBackground $lightcolor
-
-option add *foreground white
-option add *activeForeground white
-
-option add *troughColor $lightcolor
-
-option add *highlightThickness 0
-option add *relief solid startupFile
-
-if {$pd_nt == 1} {
- global pd_guidir
- global pd_tearoff
- set pd_gui2 [string range $argv0 0 [expr [string last \\ $argv0 ] - 1]]
- regsub -all \\\\ $pd_gui2 / pd_gui3
- set pd_guidir $pd_gui3/..
- load $pd_guidir/bin/pdtcl
- set pd_tearoff 1
-}
-
-if {$pd_nt == 2} {
- global pd_guidir
- global pd_tearoff
- set pd_gui2 [string range $argv0 0 [expr [string last / $argv0 ] - 1]]
- set pd_guidir $pd_gui2/..
- load $pd_guidir/bin/pdtcl
- set pd_tearoff 0
-}
-
-# hack so you can easily test-run this script in linux... define pd_guidir
-# (which is normally defined at startup in pd under linux...)
-
-if {$pd_nt == 0} {
- if {! [info exists pd_guidir]} {
- global pd_guidir
- puts stderr {setting pd_guidir to '.'}
- set pd_guidir .
- }
-}
-
-# it's unfortunate but we seem to have to turn off global bindings
-# for Text objects to get control-s and control-t to do what we want for
-# "text" dialogs below. Also we have to get rid of tab's changing the focus.
-
-bind all <Key-Tab> ""
-bind all <<PrevWindow>> ""
-bind Text <Control-t> {}
-bind Text <Control-s> {}
-# puts stderr [bind all]
-
-################## set up main window #########################
-menu .mbar
-canvas .dummy -height 2p -width 6c
-
-frame .controls
-pack .controls .dummy -side top -fill x
-menu .mbar.file -tearoff $pd_tearoff
-.mbar add cascade -label "$File" -menu .mbar.file
-menu .mbar.find -tearoff $pd_tearoff
-.mbar add cascade -label "$Find" -menu .mbar.find
-menu .mbar.windows -postcommand [concat pdtk_fixwindowmenu] -tearoff $pd_tearoff
-menu .mbar.audio -tearoff $pd_tearoff
-if {$pd_nt != 2} {
- .mbar add cascade -label "$Windows" -menu .mbar.windows
- .mbar add cascade -label "$Media" -menu .mbar.audio
-} else {
-# Perhaps this is silly, but Mac HIG want "Window Help" as the last menus
- .mbar add cascade -label "$Media" -menu .mbar.audio
- .mbar add cascade -label "$Windows" -menu .mbar.windows
-}
-menu .mbar.help -tearoff $pd_tearoff
-.mbar add cascade -label "$Help" -menu .mbar.help
-
-set ctrls_audio_on 0
-set ctrls_meter_on 0
-set ctrls_inlevel 0
-set ctrls_outlevel 0
-
-frame .controls.switches
-checkbutton .controls.switches.audiobutton -text {compute audio} \
- -variable ctrls_audio_on \
- -anchor w \
- -command {pd [concat pd dsp $ctrls_audio_on \;]}
-
-checkbutton .controls.switches.meterbutton -text {peak meters} \
- -variable ctrls_meter_on \
- -anchor w \
- -command {pd [concat pd meters $ctrls_meter_on \;]}
-
-pack .controls.switches.meterbutton .controls.switches.audiobutton -side left
-
-frame .controls.inout
-frame .controls.inout.in
-label .controls.inout.in.label -text IN
-entry .controls.inout.in.level -textvariable ctrls_inlevel -width 3
-button .controls.inout.in.clip -text {CLIP} -state disabled
-pack .controls.inout.in.label .controls.inout.in.level \
- .controls.inout.in.clip -side top -pady 2
-
-frame .controls.inout.out
-label .controls.inout.out.label -text OUT
-entry .controls.inout.out.level -textvariable ctrls_outlevel -width 3
-button .controls.inout.out.clip -text {CLIP} -state disabled
-pack .controls.inout.out.label .controls.inout.out.level \
- .controls.inout.out.clip -side top -pady 2
-
-button .controls.dio -text "DIO\nerrors" \
- -command {pd [concat pd audiostatus \;]}
-
-pack .controls.switches -side bottom -pady 12
-pack .controls.inout.in .controls.inout.out -side left -padx 6
-pack .controls.inout -side left -padx 14
-pack .controls.dio -side right -padx 20
-
-bind . <Control-Key> {pdtk_pd_ctrlkey %W %K 0}
-bind . <Control-Shift-Key> {pdtk_pd_ctrlkey %W %K 1}
-if {$pd_nt == 2} {
- bind . <Mod1-Key> {pdtk_canvas_ctrlkey %W %K 0}
- bind . <Mod1-Shift-Key> {pdtk_canvas_ctrlkey %W %K 1}
-}
-
-
-wm title . "PDa"
-. configure -menu .mbar -width 200 -height 150
-
-############### set up global variables ################################
-
-set untitled_number 1
-set untitled_directory [pwd]
-set saveas_client doggy
-set pd_opendir $untitled_directory
-set pd_undoaction no
-set pd_redoaction no
-set pd_undocanvas no
-
-################ utility functions #########################
-
-proc pdtk_enquote {x} {
- set foo [string map {"," "" ";" "" \" ""} $x]
- set foo2 [string map {" " "\\ "} $foo]
- concat $foo2
-}
-
-proc pdtk_debug {x} {
- tk_messageBox -message $x -type ok
-}
-
-proc pdtk_watchdog {} {
- pd [concat pd ping \;]
- after 2000 {pdtk_watchdog}
-}
-
-proc pdtk_check {x message} {
- set answer [tk_messageBox \-message $x \-type yesno \-icon question]
- switch $answer {
- yes {pd $message} }
-# no {tk_messageBox \-message "cancelled" \-type ok}
-}
-
-set menu_windowlist {}
-
-proc pdtk_fixwindowmenu {} {
- global menu_windowlist
- .mbar.windows delete 0 end
- foreach i $menu_windowlist {
- .mbar.windows add command -label [lindex $i 0] \
- -command [concat menu_domenuwindow [lindex $i 1]]
- menu_fixwindowmenu [lindex $i 1]
- }
-}
-
-####### Odd little function to make better Mac accelerators #####
-
-proc accel_munge {acc} {
- global pd_nt
-
- if {$pd_nt == 2} {
- if [string is upper [string index $acc end]] {
- return [format "%s%s" "Shift+" \
- [string toupper [string map {Ctrl Meta} $acc] end]]
- } else {
- return [string toupper [string map {Ctrl Meta} $acc] end]
- }
- } else {
- return $acc
- }
-}
-
-
-
-############### the "New" menu command ########################
-proc menu_new {} {
- global untitled_number
- global untitled_directory
- pd [concat pd filename Untitled-$untitled_number $untitled_directory \;]
- pd {
- #N canvas;
- #X pop 1;
- }
- set untitled_number [expr $untitled_number + 1]
-}
-
-################## the "Open" menu command #########################
-
-proc menu_open {} {
- global pd_opendir
-
- set filename [tk_getOpenFile -defaultextension .pd \
- -filetypes { {{pd files} {.pd}} {{max files} {.pat}}} \
- -initialdir $pd_opendir]
-
- if {$filename != ""} {
- set directory [string range $filename 0 \
- [expr [string last / $filename ] - 1]]
- set pd_opendir $directory
- set basename [string range $filename \
- [expr [string last / $filename ] + 1] end]
-
-# pd_debug [concat file $filename base $basename dir $directory]
-
- pd [concat pd open [pdtk_enquote $basename] \
- [pdtk_enquote $directory]\;]
- }
-}
-
-################## the "Message" menu command #########################
-proc menu_send {} {
- toplevel .sendpanel
- entry .sendpanel.entry -textvariable send_textvariable
- pack .sendpanel.entry -side bottom -fill both -ipadx 100
- .sendpanel.entry select from 0
- .sendpanel.entry select adjust end
- bind .sendpanel.entry <KeyPress-Return> {
- pd [concat $send_textvariable \;]
- after 50 {destroy .sendpanel}
- }
- focus .sendpanel.entry
-}
-
-################## the "Quit" menu command #########################
-proc menu_really_quit {} {pd {pd quit;}}
-
-proc menu_quit {} {pd {pd quit;}}
-
-######### the "Pd" menu command, which puts the Pd window on top ########
-proc menu_pop_pd {} {raise .}
-
-######### the "audio" menu command ###############
-proc menu_audio {flag} {pd [concat pd dsp $flag \;]}
-
-######### the "documentation" menu command ###############
-
-set doc_number 1
-
-proc menu_opentext {filename} {
- global doc_number
- global pd_guidir
- global pd_myversion
- set name [format ".help%d" $doc_number]
- toplevel $name
- text $name.text -fg black -relief raised -bd 2 -font -*-courier-bold--normal--12-* \
- -yscrollcommand "$name.scroll set" -background white
- scrollbar $name.scroll -command "$name.text yview"
- pack $name.scroll -side right -fill y
- pack $name.text -side left -fill both -expand 1
-
- set f [open $filename]
- while {![eof $f]} {
- set bigstring [read $f 1000]
- regsub -all PD_BASEDIR $bigstring $pd_guidir bigstring2
- regsub -all PD_VERSION $bigstring2 $pd_myversion bigstring3
- $name.text insert end $bigstring3
- }
- close $f
- set doc_number [expr $doc_number + 1]
-}
-
-set help_directory $pd_guidir/doc
-
-proc menu_documentation {} {
- global help_directory
- global pd_nt
-
- set filename [tk_getOpenFile -defaultextension .pd \
- -filetypes { {{documentation} {.pd .txt .htm}} } \
- -initialdir $help_directory]
-
- if {$filename != ""} {
- if {[string first .txt $filename] >= 0} {
- menu_opentext $filename
- } elseif {[string first .htm $filename] >= 0} {
- if {$pd_nt == 0} {
- exec sh -c \
- [format "mozilla file:%s || netscape file:%s &\n" \
- $filename $filename]
- } elseif {$pd_nt == 2} {
- puts stderr [format "open %s" $filename]
- exec sh -c \
- [format "open %s" $filename]
- } else {
- exec rundll32 url.dll,FileProtocolHandler \
- [format "file:%s" $filename] &
- }
- } else {
- set help_directory [string range $filename 0 \
- [expr [string last / $filename ] - 1]]
- set basename [string range $filename \
- [expr [string last / $filename ] + 1] end]
- pd [concat pd open [pdtk_enquote $basename] \
- [pdtk_enquote $help_directory] \;]
- }
- }
-}
-
-proc menu_doc_open {subdir basename} {
- global pd_guidir
-
- set dirname $pd_guidir/$subdir
-
- if {[string first .txt $basename] >= 0} {
- menu_opentext $dirname/$basename
- } else {
- pd [concat pd open [pdtk_enquote $basename] \
- [pdtk_enquote $dirname] \;]
- }
-}
-
-############# routine to add audio and help menus ###############
-
-proc menu_addstd {mbar} {
- global pd_apilist
-# the "Audio" menu
- $mbar.audio add command -label {audio ON} -accelerator [accel_munge "Ctrl+/"] \
- -command {menu_audio 1}
- $mbar.audio add command -label {audio OFF} -accelerator [accel_munge "Ctrl+."] \
- -command {menu_audio 0}
- for {set x 0} {$x<[llength $pd_apilist]} {incr x} {
- $mbar.audio add radiobutton -label [lindex [lindex $pd_apilist $x] 0] \
- -command {menu_audio 0} -variable pd_whichapi \
- -value [lindex [lindex $pd_apilist $x] 1]\
- -command {pd [concat pd audio-setapi $pd_whichapi \;]}
- }
- $mbar.audio add command -label {Audio settings...} \
- -command {pd pd audio-properties \;}
-
- $mbar.audio add command -label {MIDI settings...} \
- -command {pd pd midi-properties \;}
- $mbar.audio add command -label {Test Audio and MIDI} \
- -command {menu_doc_open doc/7.stuff/tools testtone.pd}
- $mbar.audio add command -label {Load Meter} \
- -command {menu_doc_open doc/7.stuff/tools load-meter.pd}
-
-
- $mbar.audio add checkbutton -label "Show Menubar" \
- -indicatoron true -selectcolor grey85 \
- -variable menubar
-
-# the "Help" menu
- $mbar.help add command -label {About Pd} \
- -command {menu_doc_open doc/1.manual 1.introduction.txt}
- $mbar.help add command -label {Pure Documentation...} \
- -command {menu_documentation}
-}
-
-#################### the "File" menu for the Pd window ##############
-
-.mbar.file add command -label New -command {menu_new} \
- -accelerator [accel_munge "Ctrl+n"]
-.mbar.file add command -label Open -command {menu_open} \
- -accelerator [accel_munge "Ctrl+o"]
-.mbar.file add separator
-.mbar.file add command -label Message -command {menu_send} \
- -accelerator [accel_munge "Ctrl+m"]
-.mbar.file add command -label Path... \
- -command {pd pd start-path-dialog \;}
-.mbar.file add separator
-.mbar.file add command -label Quit -command {menu_quit} \
- -accelerator [accel_munge "Ctrl+q"]
-
-#################### the "Find" menu for the Pd window ##############
-.mbar.find add command -label {last error?} -command {menu_finderror}
-
-########### functions for menu functions on document windows ########
-
-proc menu_save {name} {
- pdtk_canvas_checkgeometry $name
- pd [concat $name menusave \;]
-}
-
-proc menu_saveas {name} {
- pdtk_canvas_checkgeometry $name
- pd [concat $name menusaveas \;]
-}
-
-proc menu_print {name} {
- set filename [tk_getSaveFile -initialfile pd.ps \
- -defaultextension .ps \
- -filetypes { {{postscript} {.ps}} }]
-
- if {$filename != ""} {
- $name.c postscript -file $filename
- }
-}
-
-proc menu_close {name} {
- pd [concat $name menuclose \;]
-}
-
-proc menu_undo {name} {
- global pd_undoaction
- global pd_redoaction
- global pd_undocanvas
- if {$name == $pd_undocanvas && $pd_undoaction != "no"} {
- pd [concat $name undo \;]
- }
-}
-
-proc menu_redo {name} {
- global pd_undoaction
- global pd_redoaction
- global pd_undocanvas
- if {$name == $pd_undocanvas && $pd_redoaction != "no"} {
- pd [concat $name redo \;]
- }
-}
-
-proc menu_cut {name} {
- pd [concat $name cut \;]
-}
-
-proc menu_copy {name} {
- pd [concat $name copy \;]
-}
-
-proc menu_paste {name} {
- pd [concat $name paste \;]
-}
-
-proc menu_duplicate {name} {
- pd [concat $name duplicate \;]
-}
-
-proc menu_selectall {name} {
- pd [concat $name selectall \;]
-}
-
-proc menu_texteditor {name} {
- pd [concat $name texteditor \;]
-}
-
-proc menu_font {name} {
- pd [concat $name menufont \;]
-}
-
-proc menu_tidyup {name} {
- pd [concat $name tidy \;]
-}
-
-proc menu_editmode {name} {
- pd [concat $name editmode 0 \;]
-}
-
-proc menu_object {name accel} {
- pd [concat $name obj $accel \;]
-}
-
-proc menu_message {name accel} {
- pd [concat $name msg $accel \;]
-}
-
-proc menu_floatatom {name accel} {
- pd [concat $name floatatom $accel \;]
-}
-
-proc menu_symbolatom {name accel} {
- pd [concat $name symbolatom $accel \;]
-}
-
-proc menu_comment {name accel} {
- pd [concat $name text $accel \;]
-}
-
-proc menu_graph {name} {
- pd [concat $name graph \;]
-}
-
-proc menu_array {name} {
- pd [concat $name menuarray \;]
-}
-
-############iemlib##################
-proc menu_bng {name accel} {
- pd [concat $name bng $accel \;]
-}
-
-proc menu_toggle {name accel} {
- pd [concat $name toggle $accel \;]
-}
-
-proc menu_numbox {name accel} {
- pd [concat $name numbox $accel \;]
-}
-
-proc menu_vslider {name accel} {
- pd [concat $name vslider $accel \;]
-}
-
-proc menu_hslider {name accel} {
- pd [concat $name hslider $accel \;]
-}
-
-proc menu_hradio {name accel} {
- pd [concat $name hradio $accel \;]
-}
-
-proc menu_vradio {name accel} {
- pd [concat $name vradio $accel \;]
-}
-
-proc menu_vumeter {name accel} {
- pd [concat $name vumeter $accel \;]
-}
-
-proc menu_mycnv {name accel} {
- pd [concat $name mycnv $accel \;]
-}
-
-############iemlib##################
-
-# correct edit menu, enabling or disabling undo/redo
-# LATER also cut/copy/paste
-proc menu_fixeditmenu {name} {
- global pd_undoaction
- global pd_redoaction
- global pd_undocanvas
-# puts stderr [concat menu_fixeditmenu $name $pd_undocanvas $pd_undoaction]
- if {$name == $pd_undocanvas && $pd_undoaction != "no"} {
- $name.m.edit entryconfigure "Undo*" -state normal \
- -label [concat "Undo " $pd_undoaction]
- } else {
- $name.m.edit entryconfigure "Undo*" -state disabled -label "Undo"
- }
- if {$name == $pd_undocanvas && $pd_redoaction != "no"} {
- $name.m.edit entryconfigure "Redo*" -state normal\
- -label [concat "Redo " $pd_redoaction]
- } else {
- $name.m.edit entryconfigure "Redo*" -state disabled
- }
-}
-
-# message from Pd to update the currently available undo/redo action
-proc pdtk_undomenu {name undoaction redoaction} {
- global pd_undoaction
- global pd_redoaction
- global pd_undocanvas
-# puts stderr [concat pdtk_undomenu $name $undoaction $redoaction]
- set pd_undocanvas $name
- set pd_undoaction $undoaction
- set pd_redoaction $redoaction
- if {$name != "nobody"} {
-# unpleasant way of avoiding a more unpleasant bug situation --atl 2002.11.25
- menu_fixeditmenu $name
- }
-}
-
-proc menu_windowparent {name} {
- pd [concat $name findparent \;]
-}
-
-proc menu_findagain {name} {
- pd [concat $name findagain \;]
-}
-
-proc menu_finderror {} {
- pd [concat pd finderror \;]
-}
-
-proc menu_domenuwindow {i} {
- raise $i
-}
-
-proc menu_fixwindowmenu {name} {
- global menu_windowlist
- global pd_tearoff
- global menubar
-
- if { $menubar == 1 } {
- $name.m.windows add command
- if $pd_tearoff {
- $name.m.windows delete 4 end
- } else {
- $name.m.windows delete 3 end
- }
- foreach i $menu_windowlist {
- $name.m.windows add command -label [lindex $i 0] \
- -command [concat menu_domenuwindow [lindex $i 1]]
- }
- }
-}
-
-################## the "find" menu item ###################
-
-set find_canvas nobody
-set find_string ""
-set find_count 1
-
-proc find_apply {name} {
- global find_string
- global find_canvas
- regsub -all \; $find_string " _semi_ " find_string2
- regsub -all \, $find_string2 " _comma_ " find_string3
-# puts stderr [concat $find_canvas find $find_string3 \
-# \;]
- pd [concat $find_canvas find $find_string3 \
- \;]
- after 50 destroy $name
-}
-
-proc find_cancel {name} {
- after 50 destroy $name
-}
-
-proc menu_findobject {canvas} {
- global find_string
- global find_canvas
- global find_count
-
- set name [format ".find%d" $find_count]
- set find_count [expr $find_count + 1]
-
- set find_canvas $canvas
-
- toplevel $name
-
- label $name.label -text {find...}
- pack $name.label -side top
-
- entry $name.entry -textvariable find_string
- pack $name.entry -side top
-
- frame $name.buttonframe
- pack $name.buttonframe -side bottom -fill x -pady 2m
- button $name.buttonframe.cancel -text {Cancel}\
- -command "find_cancel $name"
- button $name.buttonframe.ok -text {OK}\
- -command "find_apply $name"
- pack $name.buttonframe.cancel -side left -expand 1
- pack $name.buttonframe.ok -side left -expand 1
-
- $name.entry select from 0
- $name.entry select adjust end
- bind $name.entry <KeyPress-Return> [ concat find_apply $name]
- focus $name.entry
-}
-
-
-
-proc pdtk_canvas_menubar {name width height geometry editable} {
- global pd_opendir
- global pd_tearoff
- global pd_nt
-
- global File Edit Find Put Windows Media Help
-
-
- menu $name.m.file -tearoff $pd_tearoff
- $name.m add cascade -label "$File" -menu $name.m.file
-
- $name.m.file add command -label New -command {menu_new} \
- -accelerator [accel_munge "Ctrl+n"]
-
- $name.m.file add command -label Open -command {menu_open} \
- -accelerator [accel_munge "Ctrl+o"]
-
- $name.m.file add separator
- $name.m.file add command -label Message -command {menu_send} \
- -accelerator [accel_munge "Ctrl+m"]
-
- $name.m.file add command -label Path... \
- -command {pd pd start-path-dialog \;}
-
- $name.m.file add separator
- $name.m.file add command -label Close \
- -command [concat menu_close $name] \
- -accelerator [accel_munge "Ctrl+w"]
-
- $name.m.file add command -label Save -command [concat menu_save $name] \
- -accelerator [accel_munge "Ctrl+s"]
-
- $name.m.file add command -label "Save as..." \
- -command [concat menu_saveas $name] \
- -accelerator [accel_munge "Ctrl+S"]
-
- $name.m.file add command -label Print -command [concat menu_print $name] \
- -accelerator [accel_munge "Ctrl+p"]
-
- $name.m.file add separator
-
- $name.m.file add command -label Quit -command {menu_quit} \
- -accelerator [accel_munge "Ctrl+q"]
-
-# the edit menu
- menu $name.m.edit -postcommand [concat menu_fixeditmenu $name] -tearoff $pd_tearoff
- $name.m add cascade -label $Edit -menu $name.m.edit
-
- $name.m.edit add command -label Undo -command [concat menu_undo $name] \
- -accelerator [accel_munge "Ctrl+z"]
-
- $name.m.edit add command -label Redo -command [concat menu_redo $name] \
- -accelerator [accel_munge "Ctrl+Z"]
-
- $name.m.edit add separator
-
- $name.m.edit add command -label Cut -command [concat menu_cut $name] \
- -accelerator [accel_munge "Ctrl+x"]
-
- $name.m.edit add command -label Copy -command [concat menu_copy $name] \
- -accelerator [accel_munge "Ctrl+c"]
-
- $name.m.edit add command -label Paste \
- -command [concat menu_paste $name] \
- -accelerator [accel_munge "Ctrl+v"]
-
- $name.m.edit add command -label Duplicate \
- -command [concat menu_duplicate $name] \
- -accelerator [accel_munge "Ctrl+d"]
-
- $name.m.edit add command -label {Select all} \
- -command [concat menu_selectall $name] \
- -accelerator [accel_munge "Ctrl+a"]
-
- $name.m.edit add separator
-
- $name.m.edit add command -label {Text Editor} \
- -command [concat menu_texteditor $name] \
- -accelerator [accel_munge "Ctrl+t"]
-
- $name.m.edit add command -label Font \
- -command [concat menu_font $name]
-
- $name.m.edit add command -label {Tidy Up} \
- -command [concat menu_tidyup $name]
-
- $name.m.edit add separator
-
-############iemlib##################
-# instead of "red = #BC3C60" we take "grey85", so there is no difference,
-# if widget is selected or not.
-
- $name.m.edit add checkbutton -label "Edit mode" \
- -indicatoron true -selectcolor grey85 \
- -command [concat menu_editmode $name] \
- -accelerator [accel_munge "Ctrl+e"]
-
- if { $editable == 0 } {
- $name.m.edit entryconfigure "Edit mode" -indicatoron false }
-
-############iemlib##################
-
-# the put menu
- menu $name.m.put -tearoff $pd_tearoff
- $name.m add cascade -label $Put -menu $name.m.put
-
- $name.m.put add command -label Object \
- -command [concat menu_object $name 0] \
- -accelerator [accel_munge "Ctrl+1"]
-
- $name.m.put add command -label Message \
- -command [concat menu_message $name 0] \
- -accelerator [accel_munge "Ctrl+2"]
-
- $name.m.put add command -label Number \
- -command [concat menu_floatatom $name 0] \
- -accelerator [accel_munge "Ctrl+3"]
-
- $name.m.put add command -label Symbol \
- -command [concat menu_symbolatom $name 0] \
- -accelerator [accel_munge "Ctrl+4"]
-
- $name.m.put add command -label Comment \
- -command [concat menu_comment $name 0] \
- -accelerator [accel_munge "Ctrl+5"]
-
- $name.m.put add separator
-
-############iemlib##################
-
- $name.m.put add command -label Bang \
- -command [concat menu_bng $name 0] \
- -accelerator [accel_munge "Alt+b"]
-
- $name.m.put add command -label Toggle \
- -command [concat menu_toggle $name 0] \
- -accelerator [accel_munge "Alt+t"]
-
- $name.m.put add command -label Number2 \
- -command [concat menu_numbox $name 0] \
- -accelerator [accel_munge "Alt+n"]
-
- $name.m.put add command -label Vslider \
- -command [concat menu_vslider $name 0] \
- -accelerator [accel_munge "Alt+v"]
-
- $name.m.put add command -label Hslider \
- -command [concat menu_hslider $name 0] \
- -accelerator [accel_munge "Alt+h"]
-
- $name.m.put add command -label Vradio \
- -command [concat menu_vradio $name 0] \
- -accelerator [accel_munge "Alt+d"]
-
- $name.m.put add command -label Hradio \
- -command [concat menu_hradio $name 0] \
- -accelerator [accel_munge "Alt+i"]
-
- $name.m.put add command -label VU \
- -command [concat menu_vumeter $name 0] \
- -accelerator [accel_munge "Alt+u"]
-
- $name.m.put add command -label Canvas \
- -command [concat menu_mycnv $name 0] \
- -accelerator [accel_munge "Alt+c"]
-
-############iemlib##################
-
- $name.m.put add separator
-
- $name.m.put add command -label Graph \
- -command [concat menu_graph $name]
-
- $name.m.put add command -label Array \
- -command [concat menu_array $name]
-
-# the find menu
- menu $name.m.find -tearoff $pd_tearoff
- $name.m add cascade -label "$Find" -menu $name.m.find
-
- $name.m.find add command -label {Find...} \
- -accelerator [accel_munge "Ctrl+f"] \
- -command [concat menu_findobject $name]
- $name.m.find add command -label {Find Again} \
- -accelerator [accel_munge "Ctrl+g"] \
- -command [concat menu_findagain $name]
- $name.m.find add command -label {Find last error} \
- -command [concat menu_finderror]
-
-# the window menu
- menu $name.m.windows -postcommand [concat menu_fixwindowmenu $name] \
- -tearoff $pd_tearoff
-
- $name.m.windows add command -label {parent window}\
- -command [concat menu_windowparent $name]
- $name.m.windows add command -label {Pd window} -command menu_pop_pd
- $name.m.windows add separator
-
-# the audio menu
- menu $name.m.audio -tearoff $pd_tearoff
-
- if {$pd_nt != 2} {
- $name.m add cascade -label $Windows -menu $name.m.windows
- $name.m add cascade -label $Media -menu $name.m.audio
- } else {
- $name.m add cascade -label $Media -menu $name.m.audio
- $name.m add cascade -label $Windows -menu $name.m.windows
- }
-
-# the help menu
- menu $name.m.help -tearoff $pd_tearoff
- $name.m add cascade -label $Help -menu $name.m.help
-
- menu_addstd $name.m
-}
-
-
-############# pdtk_canvas_new -- create a new canvas ###############
-proc pdtk_canvas_new {name width height geometry editable} {
- global pd_opendir
- global pd_tearoff
- global pd_nt
- global menubar
-
- toplevel $name -menu $name.m
-# puts stderr [concat geometry: $geometry]
- wm geometry $name $geometry
- wm minsize $name 1 1
-
- canvas $name.c -width $width -height $height -background white \
- -yscrollcommand "$name.scrollvert set" \
- -xscrollcommand "$name.scrollhort set" \
- -scrollregion [concat 0 0 $width $height]
-
-
- scrollbar $name.scrollvert -command "$name.c yview" -width 7
- scrollbar $name.scrollhort -command "$name.c xview" \
- -orient horizontal -width 7
-
- pack $name.scrollhort -side bottom -fill x
- pack $name.scrollvert -side right -fill y
- pack $name.c -side left -expand 1 -fill both
-
-# the menubar
-
- menu $name.m
-
- if { $menubar == 1 } {
- pdtk_canvas_menubar $name $width $height $geometry $editable
- }
-
-# the popup menu
- menu $name.popup -tearoff false
- $name.popup add command -label {Properties} \
- -command [concat popup_action $name 0]
- $name.popup add command -label {Open} \
- -command [concat popup_action $name 1]
- $name.popup add command -label {Help} \
- -command [concat popup_action $name 2]
-
-# WM protocol
- wm protocol $name WM_DELETE_WINDOW [concat menu_close $name]
-
-# bindings.
-# this is idiotic -- how do you just sense what mod keys are down and
-# pass them on? I can't find it anywhere.
-# Here we encode shift as 1, control 2, alt 4, in agreement
-# with definitions in g_canvas.c. The third button gets "8" but we don't
-# bother with modifiers there.
-# We don't handle multiple clicks yet.
-
- bind $name.c <Button> {pdtk_canvas_click %W %x %y %b 0}
- bind $name.c <Shift-Button> {pdtk_canvas_click %W %x %y %b 1}
- bind $name.c <Control-Shift-Button> {pdtk_canvas_click %W %x %y %b 3}
- bind $name.c <Alt-Button> {pdtk_canvas_click %W %x %y %b 4}
- bind $name.c <Alt-Shift-Button> {pdtk_canvas_click %W %x %y %b 5}
- bind $name.c <Alt-Control-Button> {pdtk_canvas_click %W %x %y %b 6}
- bind $name.c <Alt-Control-Shift-Button> {pdtk_canvas_click %W %x %y %b 7}
- global pd_nt
- if {$pd_nt == 2} {
- bind $name.c <Button-2> {pdtk_canvas_click %W %x %y %b 8}
- bind $name.c <Control-Button> {pdtk_canvas_click %W %x %y %b 8}
- } else {
- bind $name.c <Button-3> {pdtk_canvas_click %W %x %y %b 8}
- bind $name.c <Control-Button> {pdtk_canvas_click %W %x %y %b 2}
- }
-# change mac to right-click, not middle click -atl 2002.09.02
-
- bind $name.c <ButtonRelease> {pdtk_canvas_mouseup %W %x %y %b}
- bind $name.c <Control-Key> {pdtk_canvas_ctrlkey %W %K 0}
- bind $name.c <Control-Shift-Key> {pdtk_canvas_ctrlkey %W %K 1}
- bind $name.c <Alt-Key> {pdtk_canvas_altkey %W %K %A}
-# bind $name.c <Mod1-Key> {puts stderr [concat mod1 %W %K %A]}
- if {$pd_nt == 2} {
- bind $name.c <Mod1-Key> {pdtk_canvas_ctrlkey %W %K 0}
- bind $name.c <Mod1-Shift-Key> {pdtk_canvas_ctrlkey %W %K 1}
- }
- bind $name.c <Key> {pdtk_canvas_key %W %K %A 0}
- bind $name.c <Shift-Key> {pdtk_canvas_key %W %K %A 1}
- bind $name.c <KeyRelease> {pdtk_canvas_keyup %W %K %A}
- bind $name.c <Motion> {pdtk_canvas_motion %W %x %y 0}
- bind $name.c <Alt-Motion> {pdtk_canvas_motion %W %x %y 4}
- bind $name.c <Map> {pdtk_canvas_map %W}
- bind $name.c <Unmap> {pdtk_canvas_unmap %W}
- focus $name.c
-# puts stderr "all done"
-# after 1 [concat raise $name]
-}
-
-#################### event binding procedures ################
-
-#get the name of the toplevel window for a canvas; this is also
-#the name of the canvas object in Pd.
-
-proc canvastosym {name} {
- string range $name 0 [expr [string length $name] - 3]
-}
-
-set pdtk_lastcanvasconfigured ""
-set pdtk_lastcanvasconfiguration ""
-
-proc pdtk_canvas_checkgeometry {topname} {
- set boo [winfo geometry $topname.c]
- set boo2 [wm geometry $topname]
- global pdtk_lastcanvasconfigured
- global pdtk_lastcanvasconfiguration
- if {$topname != $pdtk_lastcanvasconfigured || \
- $boo != $pdtk_lastcanvasconfiguration} {
- set pdtk_lastcanvasconfigured $topname
- set pdtk_lastcanvasconfiguration $boo
- pd $topname relocate $boo $boo2 \;
- }
-}
-
-proc pdtk_canvas_click {name x y b f} {
-# puts stderr [concat got $f]
- pd [canvastosym $name] mouse [$name canvasx $x] [$name canvasy $y] $b $f \;
-}
-
-proc pdtk_canvas_shiftclick {name x y b} {
- pd [canvastosym $name] mouse [$name canvasx $x] [$name canvasy $y] $b 1 \;
-}
-
-proc pdtk_canvas_ctrlclick {name x y b} {
- pd [canvastosym $name] mouse [$name canvasx $x] [$name canvasy $y] $b 2 \;
-}
-
-proc pdtk_canvas_altclick {name x y b} {
- pd [canvastosym $name] mouse [$name canvasx $x] [$name canvasy $y] $b 3 \;
-}
-
-proc pdtk_canvas_dblclick {name x y b} {
- pd [canvastosym $name] mouse [$name canvasx $x] [$name canvasy $y] $b 4 \;
-}
-
-set pdtk_canvas_mouseup_name 0
-set pdtk_canvas_mouseup_xminval 0
-set pdtk_canvas_mouseup_xmaxval 0
-set pdtk_canvas_mouseup_yminval 0
-set pdtk_canvas_mouseup_ymaxval 0
-
-proc pdtk_canvas_mouseup {name x y b} {
- pd [concat [canvastosym $name] mouseup [$name canvasx $x] \
- [$name canvasy $y] $b \;]
-
-# we use the mouseup event to update scrollbar ranges and recheck the
-# geometry of the window since I haven't taken the time to figure out
-# how to do it right.
-
- global pdtk_canvas_mouseup_name
- global pdtk_canvas_mouseup_xminval
- global pdtk_canvas_mouseup_xmaxval
- global pdtk_canvas_mouseup_yminval
- global pdtk_canvas_mouseup_ymaxval
-
- set size [$name bbox all]
- if {$size != ""} {
- set xminval 0
- set yminval 0
- set xmaxval 100
- set ymaxval 100
- set x1 [lindex $size 0]
- set x2 [lindex $size 2]
- set y1 [lindex $size 1]
- set y2 [lindex $size 3]
-
- if {$x1 < 0} {set xminval $x1}
- if {$y1 < 0} {set yminval $y1}
-
- if {$x2 > 100} {set xmaxval $x2}
- if {$y2 > 100} {set ymaxval $y2}
-
- if {$pdtk_canvas_mouseup_name != $name || \
- $pdtk_canvas_mouseup_xminval != $xminval || \
- $pdtk_canvas_mouseup_xmaxval != $xmaxval || \
- $pdtk_canvas_mouseup_yminval != $yminval || \
- $pdtk_canvas_mouseup_ymaxval != $ymaxval } {
-
- set newsize "$xminval $yminval $xmaxval $ymaxval"
- $name configure -scrollregion $newsize
- set pdtk_canvas_mouseup_name $name
- set pdtk_canvas_mouseup_xminval $xminval
- set pdtk_canvas_mouseup_xmaxval $xmaxval
- set pdtk_canvas_mouseup_yminval $yminval
- set pdtk_canvas_mouseup_ymaxval $ymaxval
- }
-
- }
- pdtk_canvas_checkgeometry [canvastosym $name]
-}
-
-proc pdtk_canvas_key {name key iso shift} {
-# puts stderr [concat down key= $key iso= $iso]
-# .controls.switches.meterbutton configure -text $key
-# HACK for MAC OSX -- backspace seems different; I don't understand why.
-# invesigate this LATER...
- global pd_nt
- if {$pd_nt == 2} {
- if {$key == "BackSpace"} {
- set key 8
- set keynum 8
- }
- if {$key == "Delete"} {
- set key 8
- set keynum 8
- }
- }
- if {$key == "KP_Delete"} {
- set key 127
- set keynum 127
- }
- if {$iso != ""} {
- scan $iso %c keynum
- pd [canvastosym $name] key 1 $keynum $shift\;
- } else {
- pd [canvastosym $name] key 1 $key $shift\;
- }
-}
-
-proc pdtk_canvas_keyup {name key iso} {
-# puts stderr [concat up key= $key iso= $iso]
- if {$iso != ""} {
- scan $iso %c keynum
- pd [canvastosym $name] key 0 $keynum 0 \;
- } else {
- pd [canvastosym $name] key 0 $key 0 \;
- }
-}
-
-proc pdtk_canvas_altkey {name key iso} {
-# puts stderr [concat alt-key $iso]
-############iemlib##################
- set topname [string trimright $name .c]
- if {$key == "b" || $key == "B"} {menu_bng $topname 1}
- if {$key == "t" || $key == "T"} {menu_toggle $topname 1}
- if {$key == "n" || $key == "N"} {menu_numbox $topname 1}
- if {$key == "v" || $key == "V"} {menu_vslider $topname 1}
- if {$key == "h" || $key == "H"} {menu_hslider $topname 1}
- if {$key == "i" || $key == "I"} {menu_hradio $topname 1}
- if {$key == "d" || $key == "D"} {menu_vradio $topname 1}
- if {$key == "u" || $key == "U"} {menu_vumeter $topname 1}
- if {$key == "c" || $key == "C"} {menu_mycnv $topname 1}
-############iemlib##################
-}
-
-proc pdtk_canvas_ctrlkey {name key shift} {
-# first get rid of ".c" suffix; we'll refer to the toplevel instead
- set topname [string trimright $name .c]
-# puts stderr [concat ctrl-key $key $topname]
-
- if {$key == "n" || $key == "N"} {menu_new}
- if {$key == "o" || $key == "O"} {menu_open}
- if {$key == "m" || $key == "M"} {menu_send}
- if {$key == "q" || $key == "Q"} {
- if {$shift == 1} {menu_really_quit} else {menu_quit}
- }
- if {$key == "s" || $key == "S"} {
- if {$shift == 1} {menu_saveas $topname} else {menu_save $topname}
- }
- if {$key == "z" || $key == "Z"} {
- if {$shift == 1} {menu_redo $topname} else {menu_undo $topname}
- }
- if {$key == "w" || $key == "W"} {menu_close $topname}
- if {$key == "p" || $key == "P"} {menu_print $topname}
- if {$key == "x" || $key == "X"} {menu_cut $topname}
- if {$key == "c" || $key == "C"} {menu_copy $topname}
- if {$key == "v" || $key == "V"} {menu_paste $topname}
- if {$key == "d" || $key == "D"} {menu_duplicate $topname}
- if {$key == "a" || $key == "A"} {menu_selectall $topname}
- if {$key == "t" || $key == "T"} {menu_texteditor $topname}
- if {$key == "f" || $key == "F"} {menu_findobject $topname}
- if {$key == "g" || $key == "G"} {menu_findagain $topname}
- if {$key == "1"} {menu_object $topname 1}
- if {$key == "2"} {menu_message $topname 1}
- if {$key == "3"} {menu_floatatom $topname 1}
- if {$key == "4"} {menu_symbolatom $topname 1}
- if {$key == "5"} {menu_comment $topname 1}
- if {$key == "slash"} {menu_audio 1}
- if {$key == "period"} {menu_audio 0}
- if {$key == "e" || $key == "E"} {menu_editmode $topname}
-}
-
-proc pdtk_canvas_motion {name x y mods} {
-# puts stderr [concat [canvastosym $name] $name $x $y]
- pd [canvastosym $name] motion [$name canvasx $x] [$name canvasy $y] $mods \;
-}
-
-# "map" event tells us when the canvas becomes visible (arg is "0") or
-# invisible (arg is ""). Invisibility means the Window Manager has minimized
-# us. We don't get a final "unmap" event when we destroy the window.
-proc pdtk_canvas_map {name} {
-# puts stderr [concat map $name]
- pd [canvastosym $name] map 1 \;
-}
-
-proc pdtk_canvas_unmap {name} {
-# puts stderr [concat unmap $name]
- pd [canvastosym $name] map 0 \;
-}
-
-set saveas_dir nowhere
-
-############ pdtk_canvas_saveas -- run a saveas dialog ##############
-
-proc pdtk_canvas_saveas {name initfile initdir} {
- set filename [tk_getSaveFile -initialfile $initfile \
- -initialdir $initdir -defaultextension .pd \
- -filetypes { {{pd files} {.pd}} {{max files} {.pat}} }]
-
- if {$filename != ""} {
- set directory [string range $filename 0 \
- [expr [string last / $filename ] - 1]]
- set basename [string range $filename \
- [expr [string last / $filename ] + 1] end]
- pd [concat $name savetofile [pdtk_enquote $basename] \
- [pdtk_enquote $directory] \;]
-# pd [concat $name savetofile $basename $directory \;]
- }
-}
-
-############ pdtk_canvas_dofont -- run a font and resize dialog #########
-
-set fontsize 0
-set stretchval 0
-set whichstretch 0
-
-proc dofont_apply {name} {
- global fontsize
- global stretchval
- global whichstretch
- set cmd [concat $name font $fontsize $stretchval $whichstretch \;]
-# puts stderr $cmd
- pd $cmd
-}
-
-proc dofont_cancel {name} {
- set cmd [concat $name cancel \;]
-# puts stderr $cmd
- pd $cmd
-}
-
-proc pdtk_canvas_dofont {name initsize} {
-
- global fontsize
- set fontsize $initsize
-
- global stretchval
- set stretchval 100
-
- global whichstretch
- set whichstretch 1
-
- toplevel $name
- wm title $name {FONT BOMB}
- wm protocol $name WM_DELETE_WINDOW [concat dofont_cancel $name]
-
- frame $name.buttonframe
- pack $name.buttonframe -side bottom -fill x -pady 2m
- button $name.buttonframe.cancel -text {Cancel}\
- -command "dofont_cancel $name"
- button $name.buttonframe.ok -text {Do it}\
- -command "dofont_apply $name"
- pack $name.buttonframe.cancel -side left -expand 1
- pack $name.buttonframe.ok -side left -expand 1
-
- frame $name.radiof
- pack $name.radiof -side left
-
- label $name.radiof.label -text {Font Size:}
- pack $name.radiof.label -side top
-
- radiobutton $name.radiof.radio8 -value 8 -variable fontsize -text "8"
- radiobutton $name.radiof.radio10 -value 10 -variable fontsize -text "10"
- radiobutton $name.radiof.radio12 -value 12 -variable fontsize -text "12"
- radiobutton $name.radiof.radio16 -value 16 -variable fontsize -text "16"
- radiobutton $name.radiof.radio24 -value 24 -variable fontsize -text "24"
- radiobutton $name.radiof.radio36 -value 36 -variable fontsize -text "36"
- pack $name.radiof.radio8 -side top -anchor w
- pack $name.radiof.radio10 -side top -anchor w
- pack $name.radiof.radio12 -side top -anchor w
- pack $name.radiof.radio16 -side top -anchor w
- pack $name.radiof.radio24 -side top -anchor w
- pack $name.radiof.radio36 -side top -anchor w
-
- frame $name.stretchf
- pack $name.stretchf -side left
-
- label $name.stretchf.label -text {Stretch:}
- pack $name.stretchf.label -side top
-
- entry $name.stretchf.entry -textvariable stretchval -width 5
- pack $name.stretchf.entry -side left
-
- radiobutton $name.stretchf.radio1 \
- -value 1 -variable whichstretch -text "X and Y"
- radiobutton $name.stretchf.radio2 \
- -value 2 -variable whichstretch -text "X only"
- radiobutton $name.stretchf.radio3 \
- -value 3 -variable whichstretch -text "Y only"
-
- pack $name.stretchf.radio1 -side top -anchor w
- pack $name.stretchf.radio2 -side top -anchor w
- pack $name.stretchf.radio3 -side top -anchor w
-
-}
-
-############ pdtk_gatom_dialog -- run a gatom dialog #########
-
-# see graph_apply, etc., for comments about handling variable names here...
-
-proc gatom_escape {sym} {
- if {[string length $sym] == 0} {
- set ret "-"
-# puts stderr [concat escape1 $sym $ret]
- } else {
- if {[string equal -length 1 $sym "-"]} {
- set ret [string replace $sym 0 0 "--"]
-# puts stderr [concat escape $sym $ret]
- } else {
- if {[string equal -length 1 $sym "$"]} {
- set ret [string replace $sym 0 0 "#"]
-# puts stderr [concat unescape $sym $ret]
- } else {
- set ret $sym
-# puts stderr [concat escape $sym "no change"]
- }
- }
- }
- concat $ret
-}
-
-proc gatom_unescape {sym} {
- if {[string equal -length 1 $sym "-"]} {
- set ret [string replace $sym 0 0 ""]
-# puts stderr [concat unescape $sym $ret]
- } else {
- if {[string equal -length 1 $sym "#"]} {
- set ret [string replace $sym 0 0 "$"]
-# puts stderr [concat unescape $sym $ret]
- } else {
- set ret $sym
-# puts stderr [concat unescape $sym "no change"]
- }
- }
- concat $ret
-}
-
-proc dogatom_apply {id} {
- set vid [string trimleft $id .]
-
- set var_gatomwidth [concat gatomwidth_$vid]
- global $var_gatomwidth
- set var_gatomlo [concat gatomlo_$vid]
- global $var_gatomlo
- set var_gatomhi [concat gatomhi_$vid]
- global $var_gatomhi
- set var_gatomwherelabel [concat gatomwherelabel_$vid]
- global $var_gatomwherelabel
- set var_gatomlabel [concat gatomlabel_$vid]
- global $var_gatomlabel
- set var_gatomsymfrom [concat gatomsymfrom_$vid]
- global $var_gatomsymfrom
- set var_gatomsymto [concat gatomsymto_$vid]
- global $var_gatomsymto
-
-# set cmd [concat $id param $gatomwidth $gatomlo $gatomhi \;]
-
- set cmd [concat $id param \
- [eval concat $$var_gatomwidth] \
- [eval concat $$var_gatomlo] \
- [eval concat $$var_gatomhi] \
- [eval gatom_escape $$var_gatomlabel] \
- [eval concat $$var_gatomwherelabel] \
- [eval gatom_escape $$var_gatomsymfrom] \
- [eval gatom_escape $$var_gatomsymto] \
- \;]
-
-# puts stderr $cmd
- pd $cmd
-}
-
-proc dogatom_cancel {name} {
- set cmd [concat $name cancel \;]
-# puts stderr $cmd
- pd $cmd
-}
-
-proc dogatom_ok {name} {
- dogatom_apply $name
- dogatom_cancel $name
-}
-
-proc pdtk_gatom_dialog {id initwidth initlo inithi \
- wherelabel label symfrom symto} {
-
- set vid [string trimleft $id .]
-
- set var_gatomwidth [concat gatomwidth_$vid]
- global $var_gatomwidth
- set var_gatomlo [concat gatomlo_$vid]
- global $var_gatomlo
- set var_gatomhi [concat gatomhi_$vid]
- global $var_gatomhi
- set var_gatomwherelabel [concat gatomwherelabel_$vid]
- global $var_gatomwherelabel
- set var_gatomlabel [concat gatomlabel_$vid]
- global $var_gatomlabel
- set var_gatomsymfrom [concat gatomsymfrom_$vid]
- global $var_gatomsymfrom
- set var_gatomsymto [concat gatomsymto_$vid]
- global $var_gatomsymto
-
- set $var_gatomwidth $initwidth
- set $var_gatomlo $initlo
- set $var_gatomhi $inithi
- set $var_gatomwherelabel $wherelabel
- set $var_gatomlabel [gatom_unescape $label]
- set $var_gatomsymfrom [gatom_unescape $symfrom]
- set $var_gatomsymto [gatom_unescape $symto]
-
- toplevel $id
- wm title $id {Atom}
- wm protocol $id WM_DELETE_WINDOW [concat dogatom_cancel $id]
-
- frame $id.buttonframe
- pack $id.buttonframe -side bottom -fill x -pady 2m
- button $id.buttonframe.cancel -text {Cancel}\
- -command "dogatom_cancel $id"
- button $id.buttonframe.apply -text {Apply}\
- -command "dogatom_apply $id"
- button $id.buttonframe.ok -text {OK}\
- -command "dogatom_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.paramsymto
- pack $id.paramsymto -side bottom
- label $id.paramsymto.entryname -text {send symbol}
- entry $id.paramsymto.entry -textvariable $var_gatomsymto -width 20
- pack $id.paramsymto.entryname $id.paramsymto.entry -side left
-
- frame $id.paramsymfrom
- pack $id.paramsymfrom -side bottom
- label $id.paramsymfrom.entryname -text {receive symbol}
- entry $id.paramsymfrom.entry -textvariable $var_gatomsymfrom -width 20
- pack $id.paramsymfrom.entryname $id.paramsymfrom.entry -side left
-
- frame $id.radio
- pack $id.radio -side bottom
- label $id.radio.label -text {show label on:}
- frame $id.radio.l
- frame $id.radio.r
- pack $id.radio.label -side top
- pack $id.radio.l $id.radio.r -side left
- radiobutton $id.radio.l.radio0 -value 0 \
- -variable $var_gatomwherelabel \
- -text "left"
- radiobutton $id.radio.l.radio1 -value 1 \
- -variable $var_gatomwherelabel \
- -text "right"
- radiobutton $id.radio.r.radio2 -value 2 \
- -variable $var_gatomwherelabel \
- -text "top"
- radiobutton $id.radio.r.radio3 -value 3 \
- -variable $var_gatomwherelabel \
- -text "bottom"
- pack $id.radio.l.radio0 $id.radio.l.radio1 -side top -anchor w
- pack $id.radio.r.radio2 $id.radio.r.radio3 -side top -anchor w
-
-
- frame $id.paramlabel
- pack $id.paramlabel -side bottom
- label $id.paramlabel.entryname -text label
- entry $id.paramlabel.entry -textvariable $var_gatomlabel -width 20
- pack $id.paramlabel.entryname $id.paramlabel.entry -side left
-
- frame $id.paramhi
- pack $id.paramhi -side bottom
- label $id.paramhi.entryname -text "upper limit"
- entry $id.paramhi.entry -textvariable $var_gatomhi -width 8
- pack $id.paramhi.entryname $id.paramhi.entry -side left
-
- frame $id.paramlo
- pack $id.paramlo -side bottom
- label $id.paramlo.entryname -text "lower limit"
- entry $id.paramlo.entry -textvariable $var_gatomlo -width 8
- pack $id.paramlo.entryname $id.paramlo.entry -side left
-
- frame $id.params
- pack $id.params -side bottom
- label $id.params.entryname -text width
- entry $id.params.entry -textvariable $var_gatomwidth -width 4
- pack $id.params.entryname $id.params.entry -side left
-
-
-
- bind $id.paramhi.entry <KeyPress-Return> [concat dogatom_ok $id]
- bind $id.paramlo.entry <KeyPress-Return> [concat dogatom_ok $id]
- bind $id.params.entry <KeyPress-Return> [concat dogatom_ok $id]
- $id.params.entry select from 0
- $id.params.entry select adjust end
- focus $id.params.entry
-}
-
-############ pdtk_canvas_popup -- popup menu for canvas #########
-
-set popup_xpix 0
-set popup_ypix 0
-
-proc popup_action {name action} {
- global popup_xpix popup_ypix
- set cmd [concat $name done-popup $action $popup_xpix $popup_ypix \;]
-# puts stderr $cmd
- pd $cmd
-}
-
-proc pdtk_canvas_popup {name xpix ypix canprop canopen} {
- global popup_xpix popup_ypix
- set popup_xpix $xpix
- set popup_ypix $ypix
- if {$canprop == 0} {$name.popup entryconfigure 0 -state disabled}
- if {$canprop == 1} {$name.popup entryconfigure 0 -state active}
- if {$canopen == 0} {$name.popup entryconfigure 1 -state disabled}
- if {$canopen == 1} {$name.popup entryconfigure 1 -state active}
- tk_popup $name.popup [expr $xpix + [winfo rootx $name.c]] \
- [expr $ypix + [winfo rooty $name.c]] 0
-}
-
-############ pdtk_graph_dialog -- dialog window for graphs #########
-
-# the graph and array dialogs can come up in many copies; but in TK the easiest
-# way to get data from an "entry", etc., is to set an associated variable
-# name. This is especially true for grouped "radio buttons". So we have
-# to synthesize variable names for each instance of the dialog. The dialog
-# gets a TK pathname $id, from which it strips the leading "." to make a
-# variable suffix $vid. Then you can get the actual value out by asking for
-# [eval concat $$variablename]. There should be an easier way but I don't see
-# it yet.
-
-proc graph_apply {id} {
-# strip "." from the TK id to make a variable name suffix
- set vid [string trimleft $id .]
-# for each variable, make a local variable to hold its name...
- set var_graph_x1 [concat graph_x1_$vid]
- global $var_graph_x1
- set var_graph_x2 [concat graph_x2_$vid]
- global $var_graph_x2
- set var_graph_xpix [concat graph_xpix_$vid]
- global $var_graph_xpix
- set var_graph_y1 [concat graph_y1_$vid]
- global $var_graph_y1
- set var_graph_y2 [concat graph_y2_$vid]
- global $var_graph_y2
- set var_graph_ypix [concat graph_ypix_$vid]
- global $var_graph_ypix
-
- pd [concat $id dialog \
- [eval concat $$var_graph_x1] \
- [eval concat $$var_graph_y1] \
- [eval concat $$var_graph_x2] \
- [eval concat $$var_graph_y2] \
- [eval concat $$var_graph_xpix] \
- [eval concat $$var_graph_ypix] \
- \;]
-}
-
-proc graph_cancel {id} {
- set cmd [concat $id cancel \;]
-# puts stderr $cmd
- pd $cmd
-}
-
-proc graph_ok {id} {
- graph_apply $id
- graph_cancel $id
-}
-
-proc pdtk_graph_dialog {id x1 y1 x2 y2 xpix ypix} {
- set vid [string trimleft $id .]
- set var_graph_x1 [concat graph_x1_$vid]
- global $var_graph_x1
- set var_graph_x2 [concat graph_x2_$vid]
- global $var_graph_x2
- set var_graph_xpix [concat graph_xpix_$vid]
- global $var_graph_xpix
- set var_graph_y1 [concat graph_y1_$vid]
- global $var_graph_y1
- set var_graph_y2 [concat graph_y2_$vid]
- global $var_graph_y2
- set var_graph_ypix [concat graph_ypix_$vid]
- global $var_graph_ypix
-
- set $var_graph_x1 $x1
- set $var_graph_x2 $x2
- set $var_graph_xpix $xpix
- set $var_graph_y1 $y1
- set $var_graph_y2 $y2
- set $var_graph_ypix $ypix
-
- toplevel $id
- wm title $id {graph}
- wm protocol $id WM_DELETE_WINDOW [concat graph_cancel $id]
-
- label $id.label -text {GRAPH BOUNDS}
- pack $id.label -side top
-
- frame $id.buttonframe
- pack $id.buttonframe -side bottom -fill x -pady 2m
- button $id.buttonframe.cancel -text {Cancel}\
- -command "graph_cancel $id"
- button $id.buttonframe.apply -text {Apply}\
- -command "graph_apply $id"
- button $id.buttonframe.ok -text {OK}\
- -command "graph_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.xrangef
- pack $id.xrangef -side top
-
- label $id.xrangef.l1 -text "X from:"
- entry $id.xrangef.x1 -textvariable $var_graph_x1 -width 7
- label $id.xrangef.l2 -text "to:"
- entry $id.xrangef.x2 -textvariable $var_graph_x2 -width 7
- label $id.xrangef.l3 -text "screen width:"
- entry $id.xrangef.xpix -textvariable $var_graph_xpix -width 7
- pack $id.xrangef.l1 $id.xrangef.x1 \
- $id.xrangef.l2 $id.xrangef.x2 \
- $id.xrangef.l3 $id.xrangef.xpix -side left
-
- frame $id.yrangef
- pack $id.yrangef -side top
-
-# dig in the following that the upper bound is labeled y1 but the variable is
-# y2, etc. This is to deal with the inconsistent use of "upper and lower"
-# graph bounds... in the dialog the upper Y bound is the lower valued Y pixel.
- label $id.yrangef.l1 -text "Y from:"
- entry $id.yrangef.y1 -textvariable $var_graph_y2 -width 7
- label $id.yrangef.l2 -text "to:"
- entry $id.yrangef.y2 -textvariable $var_graph_y1 -width 7
- label $id.yrangef.l3 -text "screen height:"
- entry $id.yrangef.ypix -textvariable $var_graph_ypix -width 7
- pack $id.yrangef.l1 $id.yrangef.y1 \
- $id.yrangef.l2 $id.yrangef.y2 \
- $id.yrangef.l3 $id.yrangef.ypix -side left
-
- bind $id.xrangef.x1 <KeyPress-Return> [concat graph_ok $id]
- bind $id.xrangef.x2 <KeyPress-Return> [concat graph_ok $id]
- bind $id.xrangef.xpix <KeyPress-Return> [concat graph_ok $id]
- bind $id.yrangef.y1 <KeyPress-Return> [concat graph_ok $id]
- bind $id.yrangef.y2 <KeyPress-Return> [concat graph_ok $id]
- bind $id.yrangef.ypix <KeyPress-Return> [concat graph_ok $id]
- $id.xrangef.x2 select from 0
- $id.xrangef.x2 select adjust end
- focus $id.xrangef.x2
-}
-
-# begin of change "iemlib"
-############ pdtk_iemgui_dialog -- dialog window for iem guis #########
-
-set iemgui_define_min_flashhold 50
-set iemgui_define_min_flashbreak 10
-set iemgui_define_min_fontsize 4
-
-proc iemgui_clip_dim {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_wdt [concat iemgui_wdt_$vid]
- global $var_iemgui_wdt
- set var_iemgui_min_wdt [concat iemgui_min_wdt_$vid]
- global $var_iemgui_min_wdt
- set var_iemgui_hgt [concat iemgui_hgt_$vid]
- global $var_iemgui_hgt
- set var_iemgui_min_hgt [concat iemgui_min_hgt_$vid]
- global $var_iemgui_min_hgt
-
- if {[eval concat $$var_iemgui_wdt] < [eval concat $$var_iemgui_min_wdt]} {
- set $var_iemgui_wdt [eval concat $$var_iemgui_min_wdt]
- $id.dim.w_ent configure -textvariable $var_iemgui_wdt
- }
- if {[eval concat $$var_iemgui_hgt] < [eval concat $$var_iemgui_min_hgt]} {
- set $var_iemgui_hgt [eval concat $$var_iemgui_min_hgt]
- $id.dim.h_ent configure -textvariable $var_iemgui_hgt
- }
-}
-
-proc iemgui_clip_num {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_num [concat iemgui_num_$vid]
- global $var_iemgui_num
-
- if {[eval concat $$var_iemgui_num] > 2000} {
- set $var_iemgui_num 2000
- $id.para.num_ent configure -textvariable $var_iemgui_num
- }
- if {[eval concat $$var_iemgui_num] < 1} {
- set $var_iemgui_num 1
- $id.para.num_ent configure -textvariable $var_iemgui_num
- }
-}
-
-proc iemgui_sched_rng {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_min_rng [concat iemgui_min_rng_$vid]
- global $var_iemgui_min_rng
- set var_iemgui_max_rng [concat iemgui_max_rng_$vid]
- global $var_iemgui_max_rng
- set var_iemgui_rng_sch [concat iemgui_rng_sch_$vid]
- global $var_iemgui_rng_sch
-
- global iemgui_define_min_flashhold
- global iemgui_define_min_flashbreak
-
- if {[eval concat $$var_iemgui_rng_sch] == 2} {
- if {[eval concat $$var_iemgui_max_rng] < [eval concat $$var_iemgui_min_rng]} {
- set hhh [eval concat $$var_iemgui_min_rng]
- set $var_iemgui_min_rng [eval concat $$var_iemgui_max_rng]
- set $var_iemgui_max_rng $hhh
- $id.rng.max_ent configure -textvariable $var_iemgui_max_rng
- $id.rng.min_ent configure -textvariable $var_iemgui_min_rng }
- if {[eval concat $$var_iemgui_max_rng] < $iemgui_define_min_flashhold} {
- set $var_iemgui_max_rng $iemgui_define_min_flashhold
- $id.rng.max_ent configure -textvariable $var_iemgui_max_rng
- }
- if {[eval concat $$var_iemgui_min_rng] < $iemgui_define_min_flashbreak} {
- set $var_iemgui_min_rng $iemgui_define_min_flashbreak
- $id.rng.min_ent configure -textvariable $var_iemgui_min_rng
- }
- }
- if {[eval concat $$var_iemgui_rng_sch] == 1} {
- if {[eval concat $$var_iemgui_min_rng] == 0.0} {
- set $var_iemgui_min_rng 1.0
- $id.rng.min_ent configure -textvariable $var_iemgui_min_rng
- }
- }
-}
-
-proc iemgui_verify_rng {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_min_rng [concat iemgui_min_rng_$vid]
- global $var_iemgui_min_rng
- set var_iemgui_max_rng [concat iemgui_max_rng_$vid]
- global $var_iemgui_max_rng
- set var_iemgui_lin0_log1 [concat iemgui_lin0_log1_$vid]
- global $var_iemgui_lin0_log1
-
- if {[eval concat $$var_iemgui_lin0_log1] == 1} {
- if {[eval concat $$var_iemgui_max_rng] == 0.0 && [eval concat $$var_iemgui_min_rng] == 0.0} {
- set $var_iemgui_max_rng 1.0
- $id.rng.max_ent configure -textvariable $var_iemgui_max_rng
- }
- if {[eval concat $$var_iemgui_max_rng] > 0} {
- if {[eval concat $$var_iemgui_min_rng] <= 0} {
- set $var_iemgui_min_rng [expr [eval concat $$var_iemgui_max_rng] * 0.01]
- $id.rng.min_ent configure -textvariable $var_iemgui_min_rng
- }
- } else {
- if {[eval concat $$var_iemgui_min_rng] > 0} {
- set $var_iemgui_max_rng [expr [eval concat $$var_iemgui_min_rng] * 0.01]
- $id.rng.max_ent configure -textvariable $var_iemgui_max_rng
- }
- }
- }
-}
-
-proc iemgui_clip_fontsize {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_gn_fs [concat iemgui_gn_fs_$vid]
- global $var_iemgui_gn_fs
-
- global iemgui_define_min_fontsize
-
- if {[eval concat $$var_iemgui_gn_fs] < $iemgui_define_min_fontsize} {
- set $var_iemgui_gn_fs $iemgui_define_min_fontsize
- $id.gnfs.fs_ent configure -textvariable $var_iemgui_gn_fs
- }
-}
-
-proc iemgui_set_col_example {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_bcol [concat iemgui_bcol_$vid]
- global $var_iemgui_bcol
- set var_iemgui_fcol [concat iemgui_fcol_$vid]
- global $var_iemgui_fcol
- set var_iemgui_lcol [concat iemgui_lcol_$vid]
- global $var_iemgui_lcol
-
- $id.col_example_choose.lb_bk configure \
- -background [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -activebackground [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -foreground [format "#%6.6x" [eval concat $$var_iemgui_lcol]] \
- -activeforeground [format "#%6.6x" [eval concat $$var_iemgui_lcol]]
-
- if { [eval concat $$var_iemgui_fcol] >= 0 } {
- $id.col_example_choose.fr_bk configure \
- -background [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -activebackground [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -foreground [format "#%6.6x" [eval concat $$var_iemgui_fcol]] \
- -activeforeground [format "#%6.6x" [eval concat $$var_iemgui_fcol]]
- } else {
- $id.col_example_choose.fr_bk configure \
- -background [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -activebackground [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -foreground [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -activeforeground [format "#%6.6x" [eval concat $$var_iemgui_bcol]]}
-}
-
-proc iemgui_preset_col {id presetcol} {
- set vid [string trimleft $id .]
-
- set var_iemgui_l2_f1_b0 [concat iemgui_l2_f1_b0_$vid]
- global $var_iemgui_l2_f1_b0
- set var_iemgui_bcol [concat iemgui_bcol_$vid]
- global $var_iemgui_bcol
- set var_iemgui_fcol [concat iemgui_fcol_$vid]
- global $var_iemgui_fcol
- set var_iemgui_lcol [concat iemgui_lcol_$vid]
- global $var_iemgui_lcol
-
- if { [eval concat $$var_iemgui_l2_f1_b0] == 0 } { set $var_iemgui_bcol $presetcol }
- if { [eval concat $$var_iemgui_l2_f1_b0] == 1 } { set $var_iemgui_fcol $presetcol }
- if { [eval concat $$var_iemgui_l2_f1_b0] == 2 } { set $var_iemgui_lcol $presetcol }
- iemgui_set_col_example $id
-}
-
-proc iemgui_choose_col_bkfrlb {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_l2_f1_b0 [concat iemgui_l2_f1_b0_$vid]
- global $var_iemgui_l2_f1_b0
- set var_iemgui_bcol [concat iemgui_bcol_$vid]
- global $var_iemgui_bcol
- set var_iemgui_fcol [concat iemgui_fcol_$vid]
- global $var_iemgui_fcol
- set var_iemgui_lcol [concat iemgui_lcol_$vid]
- global $var_iemgui_lcol
-
- if {[eval concat $$var_iemgui_l2_f1_b0] == 0} {
- set $var_iemgui_bcol [expr [eval concat $$var_iemgui_bcol] & 0xFCFCFC]
- set helpstring [tk_chooseColor -title "Background-Color" -initialcolor [format "#%6.6x" [eval concat $$var_iemgui_bcol]]]
- if { $helpstring != "" } {
- set $var_iemgui_bcol [string replace $helpstring 0 0 "0x"]
- set $var_iemgui_bcol [expr [eval concat $$var_iemgui_bcol] & 0xFCFCFC] }
- }
- if {[eval concat $$var_iemgui_l2_f1_b0] == 1} {
- set $var_iemgui_fcol [expr [eval concat $$var_iemgui_fcol] & 0xFCFCFC]
- set helpstring [tk_chooseColor -title "Front-Color" -initialcolor [format "#%6.6x" [eval concat $$var_iemgui_fcol]]]
- if { $helpstring != "" } {
- set $var_iemgui_fcol [string replace $helpstring 0 0 "0x"]
- set $var_iemgui_fcol [expr [eval concat $$var_iemgui_fcol] & 0xFCFCFC] }
- }
- if {[eval concat $$var_iemgui_l2_f1_b0] == 2} {
- set $var_iemgui_lcol [expr [eval concat $$var_iemgui_lcol] & 0xFCFCFC]
- set helpstring [tk_chooseColor -title "Label-Color" -initialcolor [format "#%6.6x" [eval concat $$var_iemgui_lcol]]]
- if { $helpstring != "" } {
- set $var_iemgui_lcol [string replace $helpstring 0 0 "0x"]
- set $var_iemgui_lcol [expr [eval concat $$var_iemgui_lcol] & 0xFCFCFC] }
- }
- iemgui_set_col_example $id
-}
-
-proc iemgui_lilo {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_lin0_log1 [concat iemgui_lin0_log1_$vid]
- global $var_iemgui_lin0_log1
- set var_iemgui_lilo0 [concat iemgui_lilo0_$vid]
- global $var_iemgui_lilo0
- set var_iemgui_lilo1 [concat iemgui_lilo1_$vid]
- global $var_iemgui_lilo1
-
- iemgui_sched_rng $id
-
- if {[eval concat $$var_iemgui_lin0_log1] == 0} {
- set $var_iemgui_lin0_log1 1
- $id.para.lilo configure -text [eval concat $$var_iemgui_lilo1]
- iemgui_verify_rng $id
- iemgui_sched_rng $id
- } else {
- set $var_iemgui_lin0_log1 0
- $id.para.lilo configure -text [eval concat $$var_iemgui_lilo0]
- }
-}
-
-proc iemgui_toggle_font {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_gn_f [concat iemgui_gn_f_$vid]
- global $var_iemgui_gn_f
-
- set $var_iemgui_gn_f [expr [eval concat $$var_iemgui_gn_f] + 1]
- if {[eval concat $$var_iemgui_gn_f] > 2} {set $var_iemgui_gn_f 0}
- if {[eval concat $$var_iemgui_gn_f] == 0} {$id.gnfs.fb configure -text "courier" -font {courier 10 bold}}
- if {[eval concat $$var_iemgui_gn_f] == 1} {$id.gnfs.fb configure -text "helvetica" -font {helvetica 10 bold}}
- if {[eval concat $$var_iemgui_gn_f] == 2} {$id.gnfs.fb configure -text "times" -font {times 10 bold}}
-}
-
-proc iemgui_lb {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_loadbang [concat iemgui_loadbang_$vid]
- global $var_iemgui_loadbang
-
- if {[eval concat $$var_iemgui_loadbang] == 0} {
- set $var_iemgui_loadbang 1
- $id.para.lb configure -text "init"
- } else {
- set $var_iemgui_loadbang 0
- $id.para.lb configure -text "no init"
- }
-}
-
-proc iemgui_stdy_jmp {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_steady [concat iemgui_steady_$vid]
- global $var_iemgui_steady
-
- if {[eval concat $$var_iemgui_steady]} {
- set $var_iemgui_steady 0
- $id.para.stdy_jmp configure -text "jump on click"
- } else {
- set $var_iemgui_steady 1
- $id.para.stdy_jmp configure -text "steady on click"
- }
-}
-
-proc iemgui_apply {id} {
- set vid [string trimleft $id .]
-
- set var_iemgui_wdt [concat iemgui_wdt_$vid]
- global $var_iemgui_wdt
- set var_iemgui_min_wdt [concat iemgui_min_wdt_$vid]
- global $var_iemgui_min_wdt
- set var_iemgui_hgt [concat iemgui_hgt_$vid]
- global $var_iemgui_hgt
- set var_iemgui_min_hgt [concat iemgui_min_hgt_$vid]
- global $var_iemgui_min_hgt
- set var_iemgui_min_rng [concat iemgui_min_rng_$vid]
- global $var_iemgui_min_rng
- set var_iemgui_max_rng [concat iemgui_max_rng_$vid]
- global $var_iemgui_max_rng
- set var_iemgui_lin0_log1 [concat iemgui_lin0_log1_$vid]
- global $var_iemgui_lin0_log1
- set var_iemgui_lilo0 [concat iemgui_lilo0_$vid]
- global $var_iemgui_lilo0
- set var_iemgui_lilo1 [concat iemgui_lilo1_$vid]
- global $var_iemgui_lilo1
- set var_iemgui_loadbang [concat iemgui_loadbang_$vid]
- global $var_iemgui_loadbang
- set var_iemgui_num [concat iemgui_num_$vid]
- global $var_iemgui_num
- set var_iemgui_steady [concat iemgui_steady_$vid]
- global $var_iemgui_steady
- set var_iemgui_snd [concat iemgui_snd_$vid]
- global $var_iemgui_snd
- set var_iemgui_rcv [concat iemgui_rcv_$vid]
- global $var_iemgui_rcv
- set var_iemgui_gui_nam [concat iemgui_gui_nam_$vid]
- global $var_iemgui_gui_nam
- set var_iemgui_gn_dx [concat iemgui_gn_dx_$vid]
- global $var_iemgui_gn_dx
- set var_iemgui_gn_dy [concat iemgui_gn_dy_$vid]
- global $var_iemgui_gn_dy
- set var_iemgui_gn_f [concat iemgui_gn_f_$vid]
- global $var_iemgui_gn_f
- set var_iemgui_gn_fs [concat iemgui_gn_fs_$vid]
- global $var_iemgui_gn_fs
- set var_iemgui_bcol [concat iemgui_bcol_$vid]
- global $var_iemgui_bcol
- set var_iemgui_fcol [concat iemgui_fcol_$vid]
- global $var_iemgui_fcol
- set var_iemgui_lcol [concat iemgui_lcol_$vid]
- global $var_iemgui_lcol
-
- iemgui_clip_dim $id
- iemgui_clip_num $id
- iemgui_sched_rng $id
- iemgui_verify_rng $id
- iemgui_sched_rng $id
- iemgui_clip_fontsize $id
-
- if {[eval concat $$var_iemgui_snd] == ""} {set hhhsnd "empty"} else {set hhhsnd [eval concat $$var_iemgui_snd]}
- if {[eval concat $$var_iemgui_rcv] == ""} {set hhhrcv "empty"} else {set hhhrcv [eval concat $$var_iemgui_rcv]}
- if {[eval concat $$var_iemgui_gui_nam] == ""} {set hhhgui_nam "empty"
- } else {
- set hhhgui_nam [eval concat $$var_iemgui_gui_nam]}
-
- if {[string index $hhhsnd 0] == "$"} {
- set hhhsnd [string replace $hhhsnd 0 0 #] }
- if {[string index $hhhrcv 0] == "$"} {
- set hhhrcv [string replace $hhhrcv 0 0 #] }
- if {[string index $hhhgui_nam 0] == "$"} {
- set hhhgui_nam [string replace $hhhgui_nam 0 0 #] }
-
- set hhhsnd [string map {" " _} $hhhsnd]
- set hhhrcv [string map {" " _} $hhhrcv]
- set hhhgui_nam [string map {" " _} $hhhgui_nam]
-
- pd [concat $id dialog \
- [eval concat $$var_iemgui_wdt] \
- [eval concat $$var_iemgui_hgt] \
- [eval concat $$var_iemgui_min_rng] \
- [eval concat $$var_iemgui_max_rng] \
- [eval concat $$var_iemgui_lin0_log1] \
- [eval concat $$var_iemgui_loadbang] \
- [eval concat $$var_iemgui_num] \
- $hhhsnd \
- $hhhrcv \
- $hhhgui_nam \
- [eval concat $$var_iemgui_gn_dx] \
- [eval concat $$var_iemgui_gn_dy] \
- [eval concat $$var_iemgui_gn_f] \
- [eval concat $$var_iemgui_gn_fs] \
- [eval concat $$var_iemgui_bcol] \
- [eval concat $$var_iemgui_fcol] \
- [eval concat $$var_iemgui_lcol] \
- [eval concat $$var_iemgui_steady] \
- \;]
-}
-
-proc iemgui_cancel {id} {pd [concat $id cancel \;]}
-
-proc iemgui_ok {id} {
- iemgui_apply $id
- iemgui_cancel $id
-}
-
-proc pdtk_iemgui_dialog {id mainheader \
- dim_header wdt min_wdt wdt_label hgt min_hgt hgt_label \
- rng_header min_rng min_rng_label max_rng max_rng_label rng_sched \
- lin0_log1 lilo0_label lilo1_label loadbang steady num_label num \
- snd rcv \
- gui_name \
- gn_dx gn_dy \
- gn_f gn_fs \
- bcol fcol lcol} {
-
- set vid [string trimleft $id .]
-
- set var_iemgui_wdt [concat iemgui_wdt_$vid]
- global $var_iemgui_wdt
- set var_iemgui_min_wdt [concat iemgui_min_wdt_$vid]
- global $var_iemgui_min_wdt
- set var_iemgui_hgt [concat iemgui_hgt_$vid]
- global $var_iemgui_hgt
- set var_iemgui_min_hgt [concat iemgui_min_hgt_$vid]
- global $var_iemgui_min_hgt
- set var_iemgui_min_rng [concat iemgui_min_rng_$vid]
- global $var_iemgui_min_rng
- set var_iemgui_max_rng [concat iemgui_max_rng_$vid]
- global $var_iemgui_max_rng
- set var_iemgui_rng_sch [concat iemgui_rng_sch_$vid]
- global $var_iemgui_rng_sch
- set var_iemgui_lin0_log1 [concat iemgui_lin0_log1_$vid]
- global $var_iemgui_lin0_log1
- set var_iemgui_lilo0 [concat iemgui_lilo0_$vid]
- global $var_iemgui_lilo0
- set var_iemgui_lilo1 [concat iemgui_lilo1_$vid]
- global $var_iemgui_lilo1
- set var_iemgui_loadbang [concat iemgui_loadbang_$vid]
- global $var_iemgui_loadbang
- set var_iemgui_num [concat iemgui_num_$vid]
- global $var_iemgui_num
- set var_iemgui_steady [concat iemgui_steady_$vid]
- global $var_iemgui_steady
- set var_iemgui_snd [concat iemgui_snd_$vid]
- global $var_iemgui_snd
- set var_iemgui_rcv [concat iemgui_rcv_$vid]
- global $var_iemgui_rcv
- set var_iemgui_gui_nam [concat iemgui_gui_nam_$vid]
- global $var_iemgui_gui_nam
- set var_iemgui_gn_dx [concat iemgui_gn_dx_$vid]
- global $var_iemgui_gn_dx
- set var_iemgui_gn_dy [concat iemgui_gn_dy_$vid]
- global $var_iemgui_gn_dy
- set var_iemgui_gn_f [concat iemgui_gn_f_$vid]
- global $var_iemgui_gn_f
- set var_iemgui_gn_fs [concat iemgui_gn_fs_$vid]
- global $var_iemgui_gn_fs
- set var_iemgui_l2_f1_b0 [concat iemgui_l2_f1_b0_$vid]
- global $var_iemgui_l2_f1_b0
- set var_iemgui_bcol [concat iemgui_bcol_$vid]
- global $var_iemgui_bcol
- set var_iemgui_fcol [concat iemgui_fcol_$vid]
- global $var_iemgui_fcol
- set var_iemgui_lcol [concat iemgui_lcol_$vid]
- global $var_iemgui_lcol
-
- set $var_iemgui_wdt $wdt
- set $var_iemgui_min_wdt $min_wdt
- set $var_iemgui_hgt $hgt
- set $var_iemgui_min_hgt $min_hgt
- set $var_iemgui_min_rng $min_rng
- set $var_iemgui_max_rng $max_rng
- set $var_iemgui_rng_sch $rng_sched
- set $var_iemgui_lin0_log1 $lin0_log1
- set $var_iemgui_lilo0 $lilo0_label
- set $var_iemgui_lilo1 $lilo1_label
- set $var_iemgui_loadbang $loadbang
- set $var_iemgui_num $num
- set $var_iemgui_steady $steady
- if {$snd == "empty"} {set $var_iemgui_snd [format ""]
- } else {set $var_iemgui_snd [format "%s" $snd]}
- if {$rcv == "empty"} {set $var_iemgui_rcv [format ""]
- } else {set $var_iemgui_rcv [format "%s" $rcv]}
- if {$gui_name == "empty"} {set $var_iemgui_gui_nam [format ""]
- } else {set $var_iemgui_gui_nam [format "%s" $gui_name]}
-
- if {[string index [eval concat $$var_iemgui_snd] 0] == "#"} {
- set $var_iemgui_snd [string replace [eval concat $$var_iemgui_snd] 0 0 $] }
- if {[string index [eval concat $$var_iemgui_rcv] 0] == "#"} {
- set $var_iemgui_rcv [string replace [eval concat $$var_iemgui_rcv] 0 0 $] }
- if {[string index [eval concat $$var_iemgui_gui_nam] 0] == "#"} {
- set $var_iemgui_gui_nam [string replace [eval concat $$var_iemgui_gui_nam] 0 0 $] }
- set $var_iemgui_gn_dx $gn_dx
- set $var_iemgui_gn_dy $gn_dy
- set $var_iemgui_gn_f $gn_f
- set $var_iemgui_gn_fs $gn_fs
-
- set $var_iemgui_bcol $bcol
- set $var_iemgui_fcol $fcol
- set $var_iemgui_lcol $lcol
-
- set $var_iemgui_l2_f1_b0 0
-
- toplevel $id
- wm title $id [format "%s-PROPERTIES" $mainheader]
- wm protocol $id WM_DELETE_WINDOW [concat iemgui_cancel $id]
-
- frame $id.dim
- pack $id.dim -side top
- label $id.dim.head -text $dim_header
- label $id.dim.w_lab -text $wdt_label -width 6
- entry $id.dim.w_ent -textvariable $var_iemgui_wdt -width 5
- label $id.dim.dummy1 -text " " -width 10
- label $id.dim.h_lab -text $hgt_label -width 6
- entry $id.dim.h_ent -textvariable $var_iemgui_hgt -width 5
- pack $id.dim.head -side top
- pack $id.dim.w_lab $id.dim.w_ent $id.dim.dummy1 -side left
- if { $hgt_label != "empty" } {
- pack $id.dim.h_lab $id.dim.h_ent -side left}
- frame $id.rng
- pack $id.rng -side top
- label $id.rng.head -text $rng_header
- label $id.rng.min_lab -text $min_rng_label -width 6
- entry $id.rng.min_ent -textvariable $var_iemgui_min_rng -width 9
- label $id.rng.dummy1 -text " " -width 1
- label $id.rng.max_lab -text $max_rng_label -width 8
- entry $id.rng.max_ent -textvariable $var_iemgui_max_rng -width 9
- if { $rng_header != "empty" } {
- pack $id.rng.head -side top
- if { $min_rng_label != "empty" } {
- pack $id.rng.min_lab $id.rng.min_ent -side left}
- if { $max_rng_label != "empty" } {
- pack $id.rng.dummy1 \
- $id.rng.max_lab $id.rng.max_ent -side left} }
-
- if { [eval concat $$var_iemgui_lin0_log1] >= 0 || [eval concat $$var_iemgui_loadbang] >= 0 || [eval concat $$var_iemgui_num] > 0 || [eval concat $$var_iemgui_steady] >= 0 } {
- label $id.space1 -text "---------------------------------"
- pack $id.space1 -side top }
-
- frame $id.para
- pack $id.para -side top
- label $id.para.dummy2 -text "" -width 1
- label $id.para.dummy3 -text "" -width 1
- if {[eval concat $$var_iemgui_lin0_log1] == 0} {
- button $id.para.lilo -text [eval concat $$var_iemgui_lilo0] -width 5 -command "iemgui_lilo $id" }
- if {[eval concat $$var_iemgui_lin0_log1] == 1} {
- button $id.para.lilo -text [eval concat $$var_iemgui_lilo1] -width 5 -command "iemgui_lilo $id" }
- if {[eval concat $$var_iemgui_loadbang] == 0} {
- button $id.para.lb -text "no init" -width 5 -command "iemgui_lb $id" }
- if {[eval concat $$var_iemgui_loadbang] == 1} {
- button $id.para.lb -text "init" -width 5 -command "iemgui_lb $id" }
- label $id.para.num_lab -text $num_label -width 9
- entry $id.para.num_ent -textvariable $var_iemgui_num -width 4
- if {[eval concat $$var_iemgui_steady] == 0} {
- button $id.para.stdy_jmp -text "jump on click" -width 11 -command "iemgui_stdy_jmp $id" }
- if {[eval concat $$var_iemgui_steady] == 1} {
- button $id.para.stdy_jmp -text "steady on click" -width 11 -command "iemgui_stdy_jmp $id" }
- if {[eval concat $$var_iemgui_lin0_log1] >= 0} {
- pack $id.para.lilo -side left -expand 1}
- if {[eval concat $$var_iemgui_loadbang] >= 0} {
- pack $id.para.dummy2 $id.para.lb -side left -expand 1}
- if {[eval concat $$var_iemgui_num] > 0} {
- pack $id.para.dummy3 $id.para.num_lab $id.para.num_ent -side left -expand 1}
- if {[eval concat $$var_iemgui_steady] >= 0} {
- pack $id.para.dummy3 $id.para.stdy_jmp -side left -expand 1}
- if { $snd != "nosndno" || $rcv != "norcvno" } {
- label $id.space2 -text "---------------------------------"
- pack $id.space2 -side top }
-
- frame $id.snd
- pack $id.snd -side top
- label $id.snd.dummy1 -text "" -width 2
- label $id.snd.lab -text "send-symbol:" -width 12
- entry $id.snd.ent -textvariable $var_iemgui_snd -width 20
- if { $snd != "nosndno" } {
- pack $id.snd.dummy1 $id.snd.lab $id.snd.ent -side left}
-
- frame $id.rcv
- pack $id.rcv -side top
- label $id.rcv.lab -text "receive-symbol:" -width 15
- entry $id.rcv.ent -textvariable $var_iemgui_rcv -width 20
- if { $rcv != "norcvno" } {
- pack $id.rcv.lab $id.rcv.ent -side left}
-
- frame $id.gnam
- pack $id.gnam -side top
- label $id.gnam.head -text "--------------label:---------------"
- label $id.gnam.dummy1 -text "" -width 1
- label $id.gnam.lab -text "name:" -width 6
- entry $id.gnam.ent -textvariable $var_iemgui_gui_nam -width 29
- label $id.gnam.dummy2 -text "" -width 1
- pack $id.gnam.head -side top
- pack $id.gnam.dummy1 $id.gnam.lab $id.gnam.ent $id.gnam.dummy2 -side left
-
- frame $id.gnxy
- pack $id.gnxy -side top
- label $id.gnxy.x_lab -text "x_off:" -width 6
- entry $id.gnxy.x_ent -textvariable $var_iemgui_gn_dx -width 5
- label $id.gnxy.dummy1 -text " " -width 10
- label $id.gnxy.y_lab -text "y_off:" -width 6
- entry $id.gnxy.y_ent -textvariable $var_iemgui_gn_dy -width 5
- pack $id.gnxy.x_lab $id.gnxy.x_ent $id.gnxy.dummy1 \
- $id.gnxy.y_lab $id.gnxy.y_ent -side left
-
- frame $id.gnfs
- pack $id.gnfs -side top
- label $id.gnfs.f_lab -text "font:" -width 6
- if {[eval concat $$var_iemgui_gn_f] == 0} {
- button $id.gnfs.fb -text "courier" -font {courier 10 bold} -width 7 -command "iemgui_toggle_font $id" }
- if {[eval concat $$var_iemgui_gn_f] == 1} {
- button $id.gnfs.fb -text "helvetica" -font {helvetica 10 bold} -width 7 -command "iemgui_toggle_font $id" }
- if {[eval concat $$var_iemgui_gn_f] == 2} {
- button $id.gnfs.fb -text "times" -font {times 10 bold} -width 7 -command "iemgui_toggle_font $id" }
- label $id.gnfs.dummy1 -text "" -width 1
- label $id.gnfs.fs_lab -text "fontsize:" -width 8
- entry $id.gnfs.fs_ent -textvariable $var_iemgui_gn_fs -width 5
- pack $id.gnfs.f_lab $id.gnfs.fb $id.gnfs.dummy1 \
- $id.gnfs.fs_lab $id.gnfs.fs_ent -side left
-
- label $id.col_head -text "--------------colors:--------------"
- pack $id.col_head -side top
-
- frame $id.col_select
- pack $id.col_select -side top
- radiobutton $id.col_select.radio0 -value 0 -variable $var_iemgui_l2_f1_b0 \
- -text "backgd" -width 5
- radiobutton $id.col_select.radio1 -value 1 -variable $var_iemgui_l2_f1_b0 \
- -text "front" -width 5
- radiobutton $id.col_select.radio2 -value 2 -variable $var_iemgui_l2_f1_b0 \
- -text "label" -width 5
- if { [eval concat $$var_iemgui_fcol] >= 0 } {
- pack $id.col_select.radio0 $id.col_select.radio1 $id.col_select.radio2 -side left
- } else {pack $id.col_select.radio0 $id.col_select.radio2 -side left}
-
- frame $id.col_example_choose
- pack $id.col_example_choose -side top
- button $id.col_example_choose.but -text "compose color" -width 10 \
- -command "iemgui_choose_col_bkfrlb $id"
- label $id.col_example_choose.dummy1 -text "" -width 1
- if { [eval concat $$var_iemgui_fcol] >= 0 } {
- button $id.col_example_choose.fr_bk -text "o=||=o" -width 5 \
- -background [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -activebackground [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -foreground [format "#%6.6x" [eval concat $$var_iemgui_fcol]] \
- -activeforeground [format "#%6.6x" [eval concat $$var_iemgui_fcol]] -pady 2
- } else {
- button $id.col_example_choose.fr_bk -text "o=||=o" -width 5 \
- -background [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -activebackground [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -foreground [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -activeforeground [format "#%6.6x" [eval concat $$var_iemgui_bcol]] -pady 2}
- button $id.col_example_choose.lb_bk -text "testlabel" -width 7 \
- -background [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -activebackground [format "#%6.6x" [eval concat $$var_iemgui_bcol]] \
- -foreground [format "#%6.6x" [eval concat $$var_iemgui_lcol]] \
- -activeforeground [format "#%6.6x" [eval concat $$var_iemgui_lcol]] -pady 2
-
- pack $id.col_example_choose.but $id.col_example_choose.dummy1 \
- $id.col_example_choose.fr_bk $id.col_example_choose.lb_bk -side left
-
- label $id.space3 -text "------or click color preset:-------"
- pack $id.space3 -side top
-
- frame $id.bcol
- pack $id.bcol -side top
- foreach i { 0 1 2 3 4 5 6 7 8 9 } hexcol { 16579836 14737632 12369084 \
- 16572640 16572608 16579784 14220504 14220540 14476540 16308476 } {
- button $id.bcol.c$i -background [format "#%6.6x" $hexcol] \
- -activebackground [format "#%6.6x" $hexcol] \
- -font {courier 2 normal} -padx 7 -pady 6 \
- -command [format "iemgui_preset_col %s %d" $id $hexcol] }
- pack $id.bcol.c0 $id.bcol.c1 $id.bcol.c2 $id.bcol.c3 $id.bcol.c4 \
- $id.bcol.c5 $id.bcol.c6 $id.bcol.c7 $id.bcol.c8 $id.bcol.c9 -side left
-
- frame $id.fcol
- pack $id.fcol -side top
- foreach i { 0 1 2 3 4 5 6 7 8 9 } hexcol { 10526880 8158332 6316128 \
- 16525352 16559172 15263784 1370132 2684148 3952892 16003312 } {
- button $id.fcol.c$i -background [format "#%6.6x" $hexcol] \
- -activebackground [format "#%6.6x" $hexcol] \
- -font {courier 2 normal} -padx 7 -pady 6 \
- -command [format "iemgui_preset_col %s %d" $id $hexcol] }
- pack $id.fcol.c0 $id.fcol.c1 $id.fcol.c2 $id.fcol.c3 $id.fcol.c4 \
- $id.fcol.c5 $id.fcol.c6 $id.fcol.c7 $id.fcol.c8 $id.fcol.c9 -side left
-
- frame $id.lcol
- pack $id.lcol -side top
- foreach i { 0 1 2 3 4 5 6 7 8 9 } hexcol { 4210752 2105376 0 \
- 9177096 5779456 7874580 2641940 17488 5256 5767248 } {
- button $id.lcol.c$i -background [format "#%6.6x" $hexcol] \
- -activebackground [format "#%6.6x" $hexcol] \
- -font {courier 2 normal} -padx 7 -pady 6 \
- -command [format "iemgui_preset_col %s %d" $id $hexcol] }
- pack $id.lcol.c0 $id.lcol.c1 $id.lcol.c2 $id.lcol.c3 $id.lcol.c4 \
- $id.lcol.c5 $id.lcol.c6 $id.lcol.c7 $id.lcol.c8 $id.lcol.c9 -side left
-
-
- label $id.space4 -text "---------------------------------"
- pack $id.space4 -side top
-
- frame $id.cao
- pack $id.cao -side top
- button $id.cao.cancel -text {Cancel} -width 6 \
- -command "iemgui_cancel $id"
- label $id.cao.dummy1 -text "" -width 3
- button $id.cao.apply -text {Apply} -width 6 \
- -command "iemgui_apply $id"
- label $id.cao.dummy2 -text "" -width 3
- button $id.cao.ok -text {OK} -width 6 \
- -command "iemgui_ok $id"
- pack $id.cao.cancel $id.cao.dummy1 \
- $id.cao.apply $id.cao.dummy2 \
- $id.cao.ok -side left
-
- label $id.space5 -text ""
- pack $id.space5 -side top
-
- if {[info tclversion] < 8.4} {
- bind $id <Key-Tab> {tkTabToWindow [tk_focusNext %W]}
- bind $id <<PrevWindow>> {tkTabToWindow [tk_focusPrev %W]}
- } else {
- bind $id <Key-Tab> {tk::TabToWindow [tk_focusNext %W]}
- bind $id <<PrevWindow>> {tk::TabToWindow [tk_focusPrev %W]}
- }
-
- bind $id.dim.w_ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.dim.h_ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.rng.min_ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.rng.max_ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.para.num_ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.snd.ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.rcv.ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.gnam.ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.gnxy.x_ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.gnxy.y_ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.gnfs.fs_ent <KeyPress-Return> [concat iemgui_ok $id]
- bind $id.cao.ok <KeyPress-Return> [concat iemgui_ok $id]
-
- $id.dim.w_ent select from 0
- $id.dim.w_ent select adjust end
- focus $id.dim.w_ent
-}
-# end of change "iemlib"
-
-############ pdtk_array_dialog -- dialog window for arrays #########
-proc array_apply {id} {
-# strip "." from the TK id to make a variable name suffix
- set vid [string trimleft $id .]
-# for each variable, make a local variable to hold its name...
- set var_array_name [concat array_name_$vid]
- global $var_array_name
- set var_array_n [concat array_n_$vid]
- global $var_array_n
- set var_array_saveit [concat array_saveit_$vid]
- global $var_array_saveit
- set var_array_otherflag [concat array_otherflag_$vid]
- global $var_array_otherflag
- set mofo [eval concat $$var_array_name]
- if {[string index $mofo 0] == "$"} {
- set mofo [string replace $mofo 0 0 #] }
-
- pd [concat $id arraydialog $mofo \
- [eval concat $$var_array_n] \
- [eval concat $$var_array_saveit] \
- [eval concat $$var_array_otherflag] \
- \;]
-}
-
-proc array_cancel {id} {
- set cmd [concat $id cancel \;]
- pd $cmd
-}
-
-proc array_ok {id} {
- array_apply $id
- array_cancel $id
-}
-
-proc pdtk_array_dialog {id name n saveit newone} {
- set vid [string trimleft $id .]
-
- set var_array_name [concat array_name_$vid]
- global $var_array_name
- set var_array_n [concat array_n_$vid]
- global $var_array_n
- set var_array_saveit [concat array_saveit_$vid]
- global $var_array_saveit
- set var_array_otherflag [concat array_otherflag_$vid]
- global $var_array_otherflag
-
- set $var_array_name $name
- set $var_array_n $n
- set $var_array_saveit $saveit
- set $var_array_otherflag 0
-
- toplevel $id
- wm title $id {array}
- wm protocol $id WM_DELETE_WINDOW [concat array_cancel $id]
-
- frame $id.name
- pack $id.name -side top
- label $id.name.label -text "name"
- entry $id.name.entry -textvariable $var_array_name
- pack $id.name.label $id.name.entry -side left
-
- frame $id.n
- pack $id.n -side top
- label $id.n.label -text "size"
- entry $id.n.entry -textvariable $var_array_n
- pack $id.n.label $id.n.entry -side left
-
- checkbutton $id.saveme -text {save contents} -variable $var_array_saveit \
- -anchor w
- pack $id.saveme -side top
-
- if {$newone != 0} {
- frame $id.radio
- pack $id.radio -side top
- radiobutton $id.radio.radio0 -value 0 \
- -variable $var_array_otherflag \
- -text "in new graph"
- radiobutton $id.radio.radio1 -value 1 \
- -variable $var_array_otherflag \
- -text "in last graph"
- pack $id.radio.radio0 -side top -anchor w
- pack $id.radio.radio1 -side top -anchor w
- } else {
- checkbutton $id.deleteme -text {delete me} \
- -variable $var_array_otherflag -anchor w
- pack $id.deleteme -side top
- }
- frame $id.buttonframe
- pack $id.buttonframe -side bottom -fill x -pady 2m
- button $id.buttonframe.cancel -text {Cancel}\
- -command "array_cancel $id"
- if {$newone == 0} {button $id.buttonframe.apply -text {Apply}\
- -command "array_apply $id"}
- button $id.buttonframe.ok -text {OK}\
- -command "array_ok $id"
- pack $id.buttonframe.cancel -side left -expand 1
- if {$newone == 0} {pack $id.buttonframe.apply -side left -expand 1}
- pack $id.buttonframe.ok -side left -expand 1
-
- bind $id.name.entry <KeyPress-Return> [concat array_ok $id]
- bind $id.n.entry <KeyPress-Return> [concat array_ok $id]
- $id.name.entry select from 0
- $id.name.entry select adjust end
- focus $id.name.entry
-}
-
-############ pdtk_canvas_dialog -- dialog window for canvass #########
-proc canvas_apply {id} {
-# strip "." from the TK id to make a variable name suffix
- set vid [string trimleft $id .]
-# for each variable, make a local variable to hold its name...
- set var_canvas_xscale [concat canvas_xscale_$vid]
- global $var_canvas_xscale
- set var_canvas_yscale [concat canvas_yscale_$vid]
- global $var_canvas_yscale
- set var_canvas_graphme [concat canvas_graphme_$vid]
- global $var_canvas_graphme
-# set var_canvas_stretch [concat canvas_stretch_$vid]
-# global $var_canvas_stretch
- pd [concat $id donecanvasdialog \
- [eval concat $$var_canvas_xscale] \
- [eval concat $$var_canvas_yscale] \
- [eval concat $$var_canvas_graphme] \
- \;]
-}
-
-proc canvas_cancel {id} {
- set cmd [concat $id cancel \;]
- pd $cmd
-}
-
-proc canvas_ok {id} {
- canvas_apply $id
- canvas_cancel $id
-}
-
-proc pdtk_canvas_dialog {id xscale yscale graphme stretch} {
- set vid [string trimleft $id .]
-
- set var_canvas_xscale [concat canvas_xscale_$vid]
- global $var_canvas_xscale
- set var_canvas_yscale [concat canvas_yscale_$vid]
- global $var_canvas_yscale
- set var_canvas_graphme [concat canvas_graphme_$vid]
- global $var_canvas_graphme
-# set var_canvas_stretch [concat canvas_stretch_$vid]
-# global $var_canvas_stretch
-
- set $var_canvas_xscale $xscale
- set $var_canvas_yscale $yscale
- set $var_canvas_graphme $graphme
-# set $var_canvas_stretch $stretch
-
- toplevel $id
- wm title $id {canvas}
- wm protocol $id WM_DELETE_WINDOW [concat canvas_cancel $id]
-
- frame $id.xscale
- pack $id.xscale -side top
- label $id.xscale.label -text "X units per pixel"
- entry $id.xscale.entry -textvariable $var_canvas_xscale -width 10
- pack $id.xscale.label $id.xscale.entry -side left
-
- frame $id.yscale
- pack $id.yscale -side top
- label $id.yscale.label -text "Y units per pixel"
- entry $id.yscale.entry -textvariable $var_canvas_yscale -width 10
- pack $id.yscale.label $id.yscale.entry -side left
-
- checkbutton $id.graphme -text {graph on parent} \
- -variable $var_canvas_graphme -anchor w
- pack $id.graphme -side top
-
-# checkbutton $id.stretch -text {stretch on resize} \
-# -variable $var_canvas_stretch -anchor w
-# pack $id.stretch -side top
-
-
- frame $id.buttonframe
- pack $id.buttonframe -side bottom -fill x -pady 2m
- button $id.buttonframe.cancel -text {Cancel}\
- -command "canvas_cancel $id"
- button $id.buttonframe.apply -text {Apply}\
- -command "canvas_apply $id"
- button $id.buttonframe.ok -text {OK}\
- -command "canvas_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
-
- bind $id.xscale.entry <KeyPress-Return> [concat canvas_ok $id]
- bind $id.yscale.entry <KeyPress-Return> [concat canvas_ok $id]
- $id.xscale.entry select from 0
- $id.xscale.entry select adjust end
- focus $id.xscale.entry
-}
-
-############ pdtk_data_dialog -- run a data dialog #########
-proc dodata_send {name} {
-# puts stderr [$name.text get 0.0 end]
-
- for {set i 1} {[$name.text compare [concat $i.0 + 3 chars] < end]} \
- {incr i 1} {
-# puts stderr [concat it's [$name.text get $i.0 [expr $i + 1].0]]
- set cmd [concat $name data [$name.text get $i.0 [expr $i + 1].0] \;]
-# puts stderr $cmd
- pd $cmd
- }
- set cmd [concat $name end \;]
-# puts stderr $cmd
- pd $cmd
-}
-
-proc dodata_cancel {name} {
- set cmd [concat $name cancel \;]
-# puts stderr $cmd
- pd $cmd
-}
-
-proc dodata_ok {name} {
- dodata_send $name
- dodata_cancel $name
-}
-
-proc pdtk_data_dialog {name stuff} {
-
- toplevel $name
- wm title $name {Atom}
- wm protocol $name WM_DELETE_WINDOW [concat dodata_cancel $name]
-
- frame $name.buttonframe
- pack $name.buttonframe -side bottom -fill x -pady 2m
- button $name.buttonframe.send -text {Send (Ctrl s)}\
- -command [concat dodata_send $name]
- button $name.buttonframe.ok -text {OK (Ctrl t)}\
- -command [concat dodata_ok $name]
- pack $name.buttonframe.send -side left -expand 1
- pack $name.buttonframe.ok -side left -expand 1
-
- text $name.text -relief raised -bd 2 -height 40 -width 60 \
- -yscrollcommand "$name.scroll set" -font -*-courier-bold--normal--12-*
- scrollbar $name.scroll -command "$name.text yview"
- pack $name.scroll -side right -fill y
- pack $name.text -side left -fill both -expand 1
- $name.text insert end $stuff
- focus $name.text
- bind $name.text <Control-t> [concat dodata_ok $name]
- bind $name.text <Control-s> [concat dodata_send $name]
-}
-
-############ check or uncheck the "edit" menu item ##############
-#####################iemlib#######################
-proc pdtk_canvas_editval {name value} {
- if { $value } {
- $name.m.edit entryconfigure "Edit mode" -indicatoron true
- } else {
- $name.m.edit entryconfigure "Edit mode" -indicatoron false
- }
-}
-#####################iemlib#######################
-
-############ pdtk_text_new -- create a new text object #2###########
-proc pdtk_text_new {canvasname myname x y text font color} {
-# if {$font < 13} {set fontname [format -*-courier-bold----%d-* $font]}
-# if {$font >= 13} {set fontname [format -*-courier-----%d-* $font]}
- $canvasname create text $x $y \
- -font [format -*-courier-bold--normal--%d-* $font] \
- -tags $myname -text $text -fill $color -anchor nw
-# pd [concat $myname size [$canvasname bbox $myname] \;]
-}
-
-################ pdtk_text_set -- change the text ##################
-proc pdtk_text_set {canvasname myname text} {
- $canvasname itemconfig $myname -text $text
-# pd [concat $myname size [$canvasname bbox $myname] \;]
-}
-
-############### event binding procedures for Pd window ################
-
-proc pdtk_pd_ctrlkey {name key shift} {
-# puts stderr [concat key $key shift $shift]
-# .dummy itemconfig goo -text [concat ---> control-key event $key];
- if {$key == "n" || $key == "N"} {menu_new}
- if {$key == "o" || $key == "O"} {menu_open}
- if {$key == "m" || $key == "M"} {menu_send}
- if {$key == "q" || $key == "Q"} {
- if {$shift == 1} {menu_really_quit} else {menu_quit}
- }
- if {$key == "slash"} {menu_audio 1}
- if {$key == "period"} {menu_audio 0}
-}
-
-######### startup function. ##############
-# Tell pd the current directory; this is used in case the command line
-# asked pd to open something. Also, get character width and height for
-# font sizes 8, 10, 12, 14, 16, and 24.
-
-proc pdtk_pd_startup {version apilist} {
- global pd_myversion pd_apilist
- set pd_myversion $version
- set pd_apilist $apilist
-
- set width1 [font measure -*-courier-bold--normal--8-* x]
- set height1 [lindex [font metrics -*-courier-bold--normal--8-*] 5]
-
- set width2 [font measure -*-courier-bold--normal--10-* x]
- set height2 [lindex [font metrics -*-courier-bold--normal--10-*] 5]
-
- set width3 [font measure -*-courier-bold--normal--12-* x]
- set height3 [lindex [font metrics -*-courier-bold--normal--12-*] 5]
-
- set width4 [font measure -*-courier-bold--normal--14-* x]
- set height4 [lindex [font metrics -*-courier-bold--normal--14-*] 5]
-
- set width5 [font measure -*-courier-bold--normal--16-* x]
- set height5 [lindex [font metrics -*-courier-bold--normal--16-*] 5]
-
- set width6 [font measure -*-courier-bold--normal--24-* x]
- set height6 [lindex [font metrics -*-courier-bold--normal--24-*] 5]
-
- set width7 [font measure -*-courier-bold--normal--36-* x]
- set height7 [lindex [font metrics -*-courier-bold--normal--36-*] 5]
-
- set tclpatch [info patchlevel]
- if {$tclpatch == "8.3.0" || \
- $tclpatch == "8.3.1" || \
- $tclpatch == "8.3.2" || \
- $tclpatch == "8.3.3" } {
- set oldtclversion 1
- } else {
- set oldtclversion 0
- }
- pd [concat pd init [pdtk_enquote [pwd]] \
- 8 $width1 $height1 \
- 10 $width2 $height2 \
- 12 $width3 $height3 \
- 14 $width4 $height4 \
- 16 $width5 $height5 \
- 24 $width6 $height6 \
- 36 $width7 $height7 \
- $oldtclversion \;];
-
- # add the audio and help menus to the Pd window. We delayed this
- # so that we'd know the value of "apilist".
- menu_addstd .mbar
-
-}
-
-##################### DSP ON/OFF, METERS, DIO ERROR ###################
-proc pdtk_pd_dsp {value} {
- global ctrls_audio_on
- if {$value == "ON"} {set ctrls_audio_on 1} else {set ctrls_audio_on 0}
-# puts stderr [concat its $ctrls_audio_on]
-}
-
-proc pdtk_pd_meters {indb outdb inclip outclip} {
-# puts stderr [concat meters $indb $outdb $inclip $outclip]
- global ctrls_inlevel ctrls_outlevel
- set ctrls_inlevel $indb
- if {$inclip == 1} {
- .controls.inout.in.clip configure -background red
- } else {
- .controls.inout.in.clip configure -background grey
- }
- set ctrls_outlevel $outdb
- if {$outclip == 1} {
- .controls.inout.out.clip configure -background red
- } else {
- .controls.inout.out.clip configure -background grey
- }
-
-}
-
-proc pdtk_pd_dio {red} {
-# puts stderr [concat dio $red]
- if {$red == 1} {
- .controls.dio configure -background red -activebackground red
- } else {
- .controls.dio configure -background grey -activebackground lightgrey
- }
-
-}
-
-############# text editing from the "edit" menu ###################
-set edit_number 1
-
-proc texteditor_send {name} {
- set topname [string trimright $name .text]
- for {set i 0} \
- {[$name compare [concat 0.0 + [expr $i + 1] chars] < end]} \
- {incr i 1} {
- set cha [$name get [concat 0.0 + $i chars]]
- scan $cha %c keynum
- pd [concat pd key 1 $keynum 0 \;]
- }
-}
-
-proc texteditor_ok {name} {
- set topname [string trimright $name .text]
- texteditor_send $name
- destroy $topname
-}
-
-
-proc pdtk_pd_texteditor {stuff} {
- global edit_number
- set name [format ".text%d" $edit_number]
- set edit_number [expr $edit_number + 1]
-
- toplevel $name
- wm title $name {TEXT}
-
- frame $name.buttons
- pack $name.buttons -side bottom -fill x -pady 2m
- button $name.buttons.send -text {Send (Ctrl s)}\
- -command "texteditor_send $name.text"
- button $name.buttons.ok -text {OK (Ctrl t)}\
- -command "texteditor_ok $name.text"
- pack $name.buttons.send -side left -expand 1
- pack $name.buttons.ok -side left -expand 1
-
- text $name.text -relief raised -bd 2 -height 12 -width 60 \
- -yscrollcommand "$name.scroll set" -font -*-courier-bold--normal--12-*
- scrollbar $name.scroll -command "$name.text yview"
- pack $name.scroll -side right -fill y
- pack $name.text -side left -fill both -expand 1
- $name.text insert end $stuff
- focus $name.text
- bind $name.text <Control-t> {texteditor_ok %W}
- bind $name.text <Control-s> {texteditor_send %W}
-}
-
-############# open and save dialogs for objects in Pd ##########
-
-proc pdtk_openpanel {target} {
- global pd_opendir
- set filename [tk_getOpenFile \
- -initialdir $pd_opendir]
- if {$filename != ""} {
- set directory [string range $filename 0 \
- [expr [string last / $filename ] - 1]]
- set pd_opendir $directory
-
- pd [concat $target symbol [pdtk_enquote $filename] \;]
- }
-}
-
-proc pdtk_savepanel {target} {
- set filename [tk_getSaveFile]
- if {$filename != ""} {
- pd [concat $target symbol [pdtk_enquote $filename] \;]
- }
-}
-
-########################### comport hack ########################
-
-set com1 0
-set com2 0
-set com3 0
-set com4 0
-
-proc com1_open {} {
- global com1
- set com1 [open com1 w]
- .dummy itemconfig goo -text $com1
- fconfigure $com1 -buffering none
- fconfigure $com1 -mode 19200,e,8,2
-}
-
-proc com1_send {str} {
- global com1
- puts -nonewline $com1 $str
-}
-
-
-############# start a polling process to watch the socket ##############
-# this is needed for nt, and presumably for Mac as well.
-# in UNIX this is handled by a tcl callback (set up in t_tkcmd.c)
-
-if {$pd_nt == 1} {
- proc polleofloop {} {
- pd_pollsocket
- after 20 polleofloop
- }
-
- polleofloop
-}
-
-####################### audio dialog ##################3
-
-proc audio_apply {id} {
- global audio_indev1 audio_indev2 audio_indev3 audio_indev4
- global audio_inchan1 audio_inchan2 audio_inchan3 audio_inchan4
- global audio_outdev1 audio_outdev2 audio_outdev3 audio_outdev4
- global audio_outchan1 audio_outchan2 audio_outchan3 audio_outchan4
- global audio_sr audio_advance
-
- pd [concat pd audio-dialog \
- $audio_indev1 \
- $audio_indev2 \
- $audio_indev3 \
- $audio_indev4 \
- $audio_inchan1 \
- $audio_inchan2 \
- $audio_inchan3 \
- $audio_inchan4 \
- $audio_outdev1 \
- $audio_outdev2 \
- $audio_outdev3 \
- $audio_outdev4 \
- $audio_outchan1 \
- $audio_outchan2 \
- $audio_outchan3 \
- $audio_outchan4 \
- $audio_sr \
- $audio_advance \
- \;]
-}
-
-proc audio_cancel {id} {
- pd [concat $id cancel \;]
-}
-
-proc audio_ok {id} {
- audio_apply $id
- audio_cancel $id
-}
-
-# callback from popup menu
-proc audio_popup_action {buttonname varname devlist index} {
- global audio_indevlist audio_outdevlist $varname
- $buttonname configure -text [lindex $devlist $index]
-# puts stderr [concat popup_action $buttonname $varname $index]
- set $varname $index
-}
-
-# create a popup menu
-proc audio_popup {name buttonname varname devlist} {
- if [winfo exists $name.popup] {destroy $name.popup}
- menu $name.popup -tearoff false
-# puts stderr [concat $devlist ]
- for {set x 0} {$x<[llength $devlist]} {incr x} {
- $name.popup add command -label [lindex $devlist $x] \
- -command [list audio_popup_action \
- $buttonname $varname $devlist $x]
- }
- tk_popup $name.popup [winfo pointerx $name] [winfo pointery $name] 0
-}
-
-# start a dialog window to select audio devices and settings. "multi"
-# is 0 if only one device is allowed; 1 if one apiece may be specified for
-# input and output; and 2 if we can select multiple devices. "longform"
-# (which only makes sense if "multi" is 2) asks us to make controls for
-# opening several devices; if not, we get an extra button to turn longform
-# on and restart the dialog.
-
-proc pdtk_audio_dialog {id indevlist indev1 indev2 indev3 indev4 \
- inchan1 inchan2 inchan3 inchan4 \
- outdevlist outdev1 outdev2 outdev3 outdev4 \
- outchan1 outchan2 outchan3 outchan4 sr advance multi longform} {
- global audio_indev1 audio_indev2 audio_indev3 audio_indev4
- global audio_inchan1 audio_inchan2 audio_inchan3 audio_inchan4
- global audio_outdev1 audio_outdev2 audio_outdev3 audio_outdev4
- global audio_outchan1 audio_outchan2 audio_outchan3 audio_outchan4
- global audio_sr audio_advance
- global audio_indevlist audio_outdevlist
-
- set audio_indev1 $indev1
- set audio_indev2 $indev2
- set audio_indev3 $indev3
- set audio_indev4 $indev4
- set audio_inchan1 $inchan1
- set audio_inchan2 $inchan2
- set audio_inchan3 $inchan3
- set audio_inchan4 $inchan4
- set audio_outdev1 $outdev1
- set audio_outdev2 $outdev2
- set audio_outdev3 $outdev3
- set audio_outdev4 $outdev4
- set audio_outchan1 $outchan1
- set audio_outchan2 $outchan2
- set audio_outchan3 $outchan3
- set audio_outchan4 $outchan4
- set audio_sr $sr
- set audio_advance $advance
- set audio_indevlist $indevlist
- set audio_outdevlist $outdevlist
-
- toplevel $id
- wm title $id {audio}
- wm protocol $id WM_DELETE_WINDOW [concat audio_cancel $id]
-
- frame $id.buttonframe
- pack $id.buttonframe -side bottom -fill x -pady 2m
- button $id.buttonframe.cancel -text {Cancel}\
- -command "audio_cancel $id"
- button $id.buttonframe.apply -text {Apply}\
- -command "audio_apply $id"
- button $id.buttonframe.ok -text {OK}\
- -command "audio_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
-
- # sample rate and advance
- frame $id.srf
- pack $id.srf -side top
-
- label $id.srf.l1 -text "sample rate:"
- entry $id.srf.x1 -textvariable audio_sr -width 7
- label $id.srf.l2 -text "delay (msec):"
- entry $id.srf.x2 -textvariable audio_advance -width 4
- pack $id.srf.l1 $id.srf.x1 $id.srf.l2 $id.srf.x2 -side left
-
- # input device 1
- frame $id.in1f
- pack $id.in1f -side top
-
- label $id.in1f.l1 -text "input device 1:"
- button $id.in1f.x1 -text [lindex $indevlist $audio_indev1] \
- -command [list audio_popup $id $id.in1f.x1 audio_indev1 $indevlist]
- label $id.in1f.l2 -text "channels:"
- entry $id.in1f.x2 -textvariable audio_inchan1 -width 3
- pack $id.in1f.l1 $id.in1f.x1 $id.in1f.l2 $id.in1f.x2 -side left
-
- # input device 2
- if {$longform && $multi > 1 && [llength $indevlist] > 1} {
- frame $id.in2f
- pack $id.in2f -side top
-
- label $id.in2f.l1 -text "input device 2:"
- button $id.in2f.x1 -text [lindex $indevlist $audio_indev2] \
- -command [list audio_popup $id $id.in2f.x1 audio_indev2 $indevlist]
- label $id.in2f.l2 -text "channels:"
- entry $id.in2f.x2 -textvariable audio_inchan2 -width 3
- pack $id.in2f.l1 $id.in2f.x1 $id.in2f.l2 $id.in2f.x2 -side left
- }
-
- # input device 3
- if {$longform && $multi > 1 && [llength $indevlist] > 2} {
- frame $id.in3f
- pack $id.in3f -side top
-
- label $id.in3f.l1 -text "input device 3:"
- button $id.in3f.x1 -text [lindex $indevlist $audio_indev3] \
- -command [list audio_popup $id $id.in3f.x1 audio_indev3 $indevlist]
- label $id.in3f.l2 -text "channels:"
- entry $id.in3f.x2 -textvariable audio_inchan3 -width 3
- pack $id.in3f.l1 $id.in3f.x1 $id.in3f.l2 $id.in3f.x2 -side left
- }
-
- # input device 4
- if {$longform && $multi > 1 && [llength $indevlist] > 3} {
- frame $id.in4f
- pack $id.in4f -side top
-
- label $id.in4f.l1 -text "input device 4:"
- button $id.in4f.x1 -text [lindex $indevlist $audio_indev4] \
- -command [list audio_popup $id $id.in4f.x1 audio_indev4 $indevlist]
- label $id.in4f.l2 -text "channels:"
- entry $id.in4f.x2 -textvariable audio_inchan4 -width 3
- pack $id.in4f.l1 $id.in4f.x1 $id.in4f.l2 $id.in4f.x2 -side left
- }
-
- # output device 1
- frame $id.out1f
- pack $id.out1f -side top
-
- if {$multi == 0} {
- label $id.out1f.l1 \
- -text "(output device same as input device) .............. "
- } else {
- label $id.out1f.l1 -text "output device 1:"
- button $id.out1f.x1 -text [lindex $outdevlist $audio_outdev1] \
- -command \
- [list audio_popup $id $id.out1f.x1 audio_outdev1 $outdevlist]
- }
- label $id.out1f.l2 -text "channels:"
- entry $id.out1f.x2 -textvariable audio_outchan1 -width 3
- if {$multi == 0} {
- pack $id.out1f.l1 $id.out1f.l2 $id.out1f.x2 -side left
- } else {
- pack $id.out1f.l1 $id.out1f.x1 $id.out1f.l2 $id.out1f.x2 -side left
- }
-
- # output device 2
- if {$longform && $multi > 1 && [llength $indevlist] > 1} {
- frame $id.out2f
- pack $id.out2f -side top
- label $id.out2f.l1 -text "output device 2:"
- button $id.out2f.x1 -text [lindex $outdevlist $audio_outdev2] \
- -command \
- [list audio_popup $id $id.out2f.x1 audio_outdev2 $outdevlist]
- label $id.out2f.l2 -text "channels:"
- entry $id.out2f.x2 -textvariable audio_outchan2 -width 3
- pack $id.out2f.l1 $id.out2f.x1 $id.out2f.l2 $id.out2f.x2 -side left
- }
-
- # output device 3
- if {$longform && $multi > 1 && [llength $indevlist] > 2} {
- frame $id.out3f
- pack $id.out3f -side top
- label $id.out3f.l1 -text "output device 3:"
- button $id.out3f.x1 -text [lindex $outdevlist $audio_outdev3] \
- -command \
- [list audio_popup $id $id.out3f.x1 audio_outdev3 $outdevlist]
- label $id.out3f.l2 -text "channels:"
- entry $id.out3f.x2 -textvariable audio_outchan3 -width 3
- pack $id.out3f.l1 $id.out3f.x1 $id.out3f.l2 $id.out3f.x2 -side left
- }
-
- # output device 4
- if {$longform && $multi > 1 && [llength $indevlist] > 3} {
- frame $id.out4f
- pack $id.out4f -side top
- label $id.out4f.l1 -text "output device 4:"
- button $id.out4f.x1 -text [lindex $outdevlist $audio_outdev4] \
- -command \
- [list audio_popup $id $id.out4f.x1 audio_outdev4 $outdevlist]
- label $id.out4f.l2 -text "channels:"
- entry $id.out4f.x2 -textvariable audio_outchan4 -width 3
- pack $id.out4f.l1 $id.out4f.x1 $id.out4f.l2 $id.out4f.x2 -side left
- }
-
- # if not the "long form" but if "multi" is 2, make a button to
- # restart with longform set.
-
- if {$longform == 0 && $multi > 1} {
- frame $id.longbutton
- pack $id.longbutton -side top
- button $id.longbutton.b -text {use multiple devices} \
- -command {pd pd audio-properties 1 \;}
- pack $id.longbutton.b
- }
- bind $id.srf.x1 <KeyPress-Return> [concat audio_ok $id]
- bind $id.srf.x2 <KeyPress-Return> [concat audio_ok $id]
- bind $id.in1f.x2 <KeyPress-Return> [concat audio_ok $id]
- $id.srf.x1 select from 0
- $id.srf.x1 select adjust end
- focus $id.srf.x1
-}
-
-####################### 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 \
- $midi_indev1 \
- $midi_indev2 \
- $midi_indev3 \
- $midi_indev4 \
- $midi_outdev1 \
- $midi_outdev2 \
- $midi_outdev3 \
- $midi_outdev4 \
- \;]
-}
-
-proc midi_cancel {id} {
- pd [concat $id cancel \;]
-}
-
-proc midi_ok {id} {
- midi_apply $id
- midi_cancel $id
-}
-
-# callback from popup menu
-proc midi_popup_action {buttonname varname devlist index} {
- global midi_indevlist midi_outdevlist $varname
- $buttonname configure -text [lindex $devlist $index]
-# puts stderr [concat popup_action $buttonname $varname $index]
- set $varname $index
-}
-
-# create a popup menu
-proc midi_popup {name buttonname varname devlist} {
- if [winfo exists $name.popup] {destroy $name.popup}
- menu $name.popup -tearoff false
-# puts stderr [concat $devlist ]
- for {set x 0} {$x<[llength $devlist]} {incr x} {
- $name.popup add command -label [lindex $devlist $x] \
- -command [list midi_popup_action \
- $buttonname $varname $devlist $x]
- }
- tk_popup $name.popup [winfo pointerx $name] [winfo pointery $name] 0
-}
-
-# start a dialog window to select midi devices. "longform" asks us to make
-# 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} {
- global midi_indev1 midi_indev2 midi_indev3 midi_indev4
- global midi_outdev1 midi_outdev2 midi_outdev3 midi_outdev4
- global midi_indevlist midi_outdevlist
-
- 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
-
- 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
-
- # input device 1
- frame $id.in1f
- pack $id.in1f -side top
-
- 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 devices} \
- -command {pd pd midi-properties 1 \;}
- pack $id.longbutton.b
- }
-}
-
-############ pdtk_path_dialog -- dialog window for search path #########
-
-proc path_apply {id} {
- global pd_path0 pd_path1 pd_path2 pd_path3 pd_path4
- global pd_path5 pd_path6 pd_path7 pd_path8 pd_path9
-
- pd [concat pd path-dialog \
- $pd_path0 $pd_path1 $pd_path2 $pd_path3 $pd_path4 \
- $pd_path5 $pd_path6 $pd_path7 $pd_path8 $pd_path9 \
- \;]
-}
-
-proc path_cancel {id} {
- pd [concat $id cancel \;]
-}
-
-proc path_ok {id} {
- path_apply $id
- path_cancel $id
-}
-set pd_path0 sdfgh
-
-proc pdtk_path_dialog {id} {
- global pd_path0 pd_path1 pd_path2 pd_path3 pd_path4
- global pd_path5 pd_path6 pd_path7 pd_path8 pd_path9
-
- toplevel $id
- wm title $id {PD search path for patches and other files}
- wm protocol $id WM_DELETE_WINDOW [concat path_cancel $id]
-
- frame $id.buttonframe
- pack $id.buttonframe -side bottom -fill x -pady 2m
- button $id.buttonframe.cancel -text {Cancel}\
- -command "path_cancel $id"
- button $id.buttonframe.apply -text {Apply}\
- -command "path_apply $id"
- button $id.buttonframe.ok -text {OK}\
- -command "path_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
-
- for {set x 0} {$x < 10} {incr x} {
- # input device 1
- entry $id.f$x -textvariable pd_path$x -width 80
- bind $id.f$x <KeyPress-Return> [concat path_ok $id]
- pack $id.f$x -side top
- }
-
- focus $id.f0
-}
-
-proc pd_set {var value} {
- global $var
- set $var $value
-}
diff --git a/apps/plugins/pdbox/PDa/src/u_pdreceive.c b/apps/plugins/pdbox/PDa/src/u_pdreceive.c
index 3ec097edcc..51e60f7d5f 100644
--- a/apps/plugins/pdbox/PDa/src/u_pdreceive.c
+++ b/apps/plugins/pdbox/PDa/src/u_pdreceive.c
@@ -323,328 +323,4 @@ static void x_closesocket(int fd)
closesocket(fd);
#endif
}
-/* Copyright (c) 2000 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in the Pd distribution. */
-
-/* the "pdreceive" command. This is a standalone program that receives messages
-from Pd via the netsend/netreceive ("FUDI") protocol, and copies them to
-standard output. */
-
-#include <sys/types.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#ifdef UNIX
-#include <sys/time.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#define SOCKET_ERROR -1
-#else
-#include <winsock.h>
-#endif
-
-typedef struct _fdpoll
-{
- int fdp_fd;
- char *fdp_inbuf;
- int fdp_inhead;
- int fdp_intail;
- int fdp_udp;
-} t_fdpoll;
-
-static int nfdpoll;
-static t_fdpoll *fdpoll;
-static int maxfd;
-static int sockfd;
-static int protocol;
-
-static void sockerror(char *s);
-static void x_closesocket(int fd);
-static void dopoll(void);
-#define BUFSIZE 4096
-
-int main(int argc, char **argv)
-{
- int portno;
- struct sockaddr_in server;
- int nretry = 10;
-#ifdef MSW
- short version = MAKEWORD(2, 0);
- WSADATA nobby;
-#endif
- if (argc < 2 || sscanf(argv[1], "%d", &portno) < 1 || portno <= 0)
- goto usage;
- if (argc >= 3)
- {
- if (!strcmp(argv[2], "tcp"))
- protocol = SOCK_STREAM;
- else if (!strcmp(argv[2], "udp"))
- protocol = SOCK_DGRAM;
- else goto usage;
- }
- else protocol = SOCK_STREAM;
-#ifdef MSW
- if (WSAStartup(version, &nobby)) sockerror("WSAstartup");
-#endif
- sockfd = socket(AF_INET, protocol, 0);
- if (sockfd < 0)
- {
- sockerror("socket()");
- exit(1);
- }
- maxfd = sockfd + 1;
- server.sin_family = AF_INET;
- server.sin_addr.s_addr = INADDR_ANY;
-
-#ifdef IRIX
- /* this seems to work only in IRIX but is unnecessary in
- Linux. Not sure what MSW needs in place of this. */
- if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, 0, 0) < 0)
- post("setsockopt failed\n");
-#endif
-
- /* assign client port number */
- server.sin_port = htons((unsigned short)portno);
-
- /* name the socket */
- if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
- {
- sockerror("bind");
- x_closesocket(sockfd);
- return (0);
- }
- if (protocol == SOCK_STREAM)
- {
- if (listen(sockfd, 5) < 0)
- {
- sockerror("listen");
- x_closesocket(sockfd);
- exit(1);
- }
- }
- /* now loop forever selecting on sockets */
- while (1)
- dopoll();
-
-usage:
- fprintf(stderr, "usage: pdreceive <portnumber> [udp|tcp]\n");
- fprintf(stderr, "(default is tcp)\n");
- exit(1);
-}
-
-static void addport(int fd)
-{
- int nfd = nfdpoll;
- t_fdpoll *fp;
- fdpoll = (t_fdpoll *)realloc(fdpoll,
- (nfdpoll+1) * sizeof(t_fdpoll));
- fp = fdpoll + nfdpoll;
- fp->fdp_fd = fd;
- nfdpoll++;
- if (fd >= maxfd) maxfd = fd + 1;
- fp->fdp_inhead = fp->fdp_intail = 0;
- if (!(fp->fdp_inbuf = malloc(BUFSIZE)))
- {
- fprintf(stderr, "out of memory");
- exit(1);
- }
- printf("number_connected %d;\n", nfdpoll);
-}
-
-static void rmport(t_fdpoll *x)
-{
- int nfd = nfdpoll;
- int i, size = nfdpoll * sizeof(t_fdpoll);
- t_fdpoll *fp;
- for (i = nfdpoll, fp = fdpoll; i--; fp++)
- {
- if (fp == x)
- {
- x_closesocket(fp->fdp_fd);
- free(fp->fdp_inbuf);
- while (i--)
- {
- fp[0] = fp[1];
- fp++;
- }
- fdpoll = (t_fdpoll *)realloc(fdpoll,
- (nfdpoll-1) * sizeof(t_fdpoll));
- nfdpoll--;
- printf("number_connected %d;\n", nfdpoll);
- return;
- }
- }
- fprintf(stderr, "warning: item removed from poll list but not found");
-}
-
-static void doconnect(void)
-{
- int fd = accept(sockfd, 0, 0);
- if (fd < 0)
- perror("accept");
- else addport(fd);
-}
-
-static void udpread(void)
-{
- char buf[BUFSIZE];
- int ret = recv(sockfd, buf, BUFSIZE, 0);
- if (ret < 0)
- {
- sockerror("recv (udp)");
- x_closesocket(sockfd);
- exit(1);
- }
- else if (ret > 0)
- {
-#ifdef UNIX
- if (write(1, buf, ret) < ret)
- {
- perror("write");
- exit(1);
- }
-#else
- int j;
- for (j = 0; j < ret; j++)
- putchar(buf[j]);
-#endif
- }
-}
-
-static int tcpmakeoutput(t_fdpoll *x)
-{
- char messbuf[BUFSIZE+1], *bp = messbuf;
- int indx;
- int inhead = x->fdp_inhead;
- int intail = x->fdp_intail;
- char *inbuf = x->fdp_inbuf;
- if (intail == inhead)
- return (0);
- for (indx = intail; indx != inhead; indx = (indx+1)&(BUFSIZE-1))
- {
- /* search for a semicolon. */
- char c = *bp++ = inbuf[indx];
- if (c == ';')
- {
- intail = (indx+1)&(BUFSIZE-1);
- if (inbuf[intail] == '\n')
- intail = (intail+1)&(BUFSIZE-1);
- *bp++ = '\n';
-#ifdef UNIX
- write(1, messbuf, bp - messbuf);
-#else
- {
- int j;
- for (j = 0; j < bp - messbuf; j++)
- putchar(messbuf[j]);
- }
-#endif
- x->fdp_inhead = inhead;
- x->fdp_intail = intail;
- return (1);
- }
- }
- return (0);
-}
-
-static void tcpread(t_fdpoll *x)
-{
- int readto =
- (x->fdp_inhead >= x->fdp_intail ? BUFSIZE : x->fdp_intail-1);
- int ret;
-
- /* the input buffer might be full. If so, drop the whole thing */
- if (readto == x->fdp_inhead)
- {
- fprintf(stderr, "pd: dropped message from gui\n");
- x->fdp_inhead = x->fdp_intail = 0;
- readto = BUFSIZE;
- }
- else
- {
- ret = recv(x->fdp_fd, x->fdp_inbuf + x->fdp_inhead,
- readto - x->fdp_inhead, 0);
- if (ret < 0)
- {
- sockerror("recv (tcp)");
- rmport(x);
- }
- else if (ret == 0)
- rmport(x);
- else
- {
- x->fdp_inhead += ret;
- if (x->fdp_inhead >= BUFSIZE)
- x->fdp_inhead = 0;
- while (tcpmakeoutput(x))
- ;
- }
- }
-}
-static void dopoll(void)
-{
- int i;
- t_fdpoll *fp;
- fd_set readset, writeset, exceptset;
- FD_ZERO(&writeset);
- FD_ZERO(&readset);
- FD_ZERO(&exceptset);
-
- FD_SET(sockfd, &readset);
- if (protocol == SOCK_STREAM)
- {
- for (fp = fdpoll, i = nfdpoll; i--; fp++)
- FD_SET(fp->fdp_fd, &readset);
- }
- if (select(maxfd+1, &readset, &writeset, &exceptset, 0) < 0)
- {
- perror("select");
- exit(1);
- }
- if (protocol == SOCK_STREAM)
- {
- for (i = 0; i < nfdpoll; i++)
- if (FD_ISSET(fdpoll[i].fdp_fd, &readset))
- tcpread(&fdpoll[i]);
- if (FD_ISSET(sockfd, &readset))
- doconnect();
- }
- else
- {
- if (FD_ISSET(sockfd, &readset))
- udpread();
- }
-}
-
-
-static void sockerror(char *s)
-{
-#ifdef MSW
- int err = WSAGetLastError();
- if (err == 10054) return;
- else if (err == 10044)
- {
- fprintf(stderr,
- "Warning: you might not have TCP/IP \"networking\" turned on\n");
- }
-#endif
-#ifdef UNIX
- int err = errno;
-#endif
- fprintf(stderr, "%s: %s (%d)\n", s, strerror(err), err);
-}
-
-static void x_closesocket(int fd)
-{
-#ifdef UNIX
- close(fd);
-#endif
-#ifdef MSW
- closesocket(fd);
-#endif
-}
diff --git a/apps/plugins/pdbox/PDa/src/u_pdsend.c b/apps/plugins/pdbox/PDa/src/u_pdsend.c
index 9f2f9232bb..4fe714d70f 100644
--- a/apps/plugins/pdbox/PDa/src/u_pdsend.c
+++ b/apps/plugins/pdbox/PDa/src/u_pdsend.c
@@ -155,160 +155,4 @@ void x_closesocket(int fd)
closesocket(fd);
#endif
}
-/* Copyright (c) 2000 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in the Pd distribution. */
-
-/* the "pdsend" command. This is a standalone program that forwards messages
-from its standard input to Pd via the netsend/netreceive ("FUDI") protocol. */
-
-#include <sys/types.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#ifdef UNIX
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#define SOCKET_ERROR -1
-#else
-#include <winsock.h>
-#endif
-
-void sockerror(char *s);
-void x_closesocket(int fd);
-#define BUFSIZE 4096
-
-int main(int argc, char **argv)
-{
- int sockfd, portno, protocol;
- struct sockaddr_in server;
- struct hostent *hp;
- char *hostname;
- int nretry = 10;
-#ifdef MSW
- short version = MAKEWORD(2, 0);
- WSADATA nobby;
-#endif
- if (argc < 2 || sscanf(argv[1], "%d", &portno) < 1 || portno <= 0)
- goto usage;
- if (argc >= 3)
- hostname = argv[2];
- else hostname = "127.0.0.1";
- if (argc >= 4)
- {
- if (!strcmp(argv[3], "tcp"))
- protocol = SOCK_STREAM;
- else if (!strcmp(argv[3], "udp"))
- protocol = SOCK_DGRAM;
- else goto usage;
- }
- else protocol = SOCK_STREAM;
-#ifdef MSW
- if (WSAStartup(version, &nobby)) sockerror("WSAstartup");
-#endif
-
- sockfd = socket(AF_INET, protocol, 0);
- if (sockfd < 0)
- {
- sockerror("socket()");
- exit(1);
- }
- /* connect socket using hostname provided in command line */
- server.sin_family = AF_INET;
- hp = gethostbyname(hostname);
- if (hp == 0)
- {
- fprintf(stderr, "%s: unknown host\n", hostname);
- x_closesocket(sockfd);
- exit(1);
- }
- memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
-
- /* assign client port number */
- server.sin_port = htons((unsigned short)portno);
-
-#if 0 /* try this again for 4.0; this crashed my RH 6.2 machine!) */
-
- /* try to connect. */
- for (nretry = 0; nretry < (protocol == SOCK_STREAM ? 10 : 1); nretry++)
-
- {
- if (nretry > 0)
- {
- sleep (nretry < 5 ? 1 : 5);
- fprintf(stderr, "retrying...");
- }
- if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) >= 0)
- goto connected;
- sockerror("connect");
- }
- x_closesocket(sockfd);
- exit(1);
-connected: ;
-#else
- /* try to connect. */
- if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0)
- {
- sockerror("connect");
- x_closesocket(sockfd);
- exit(1);
- }
-#endif
- /* now loop reading stdin and sending it to socket */
- while (1)
- {
- char buf[BUFSIZE], *bp, nsent, nsend;
- if (!fgets(buf, BUFSIZE, stdin))
- break;
- nsend = strlen(buf);
- for (bp = buf, nsent = 0; nsent < nsend;)
- {
- int res = send(sockfd, buf, nsend-nsent, 0);
- if (res < 0)
- {
- sockerror("send");
- goto done;
- }
- nsent += res;
- bp += res;
- }
- }
-done:
- if (ferror(stdin))
- perror("stdin");
- exit (0);
-usage:
- fprintf(stderr, "usage: pdsend <portnumber> [host] [udp|tcp]\n");
- fprintf(stderr, "(default is localhost and tcp)\n");
- exit(1);
-}
-void sockerror(char *s)
-{
-#ifdef MSW
- int err = WSAGetLastError();
- if (err == 10054) return;
- else if (err == 10044)
- {
- fprintf(stderr,
- "Warning: you might not have TCP/IP \"networking\" turned on\n");
- }
-#endif
-#ifdef UNIX
- int err = errno;
-#endif
- fprintf(stderr, "%s: %s (%d)\n", s, strerror(err), err);
-}
-
-void x_closesocket(int fd)
-{
-#ifdef UNIX
- close(fd);
-#endif
-#ifdef MSW
- closesocket(fd);
-#endif
-}
diff --git a/apps/plugins/pdbox/PDa/src/x_acoustics.c b/apps/plugins/pdbox/PDa/src/x_acoustics.c
index 8fc04f77d1..9c5cd07495 100644
--- a/apps/plugins/pdbox/PDa/src/x_acoustics.c
+++ b/apps/plugins/pdbox/PDa/src/x_acoustics.c
@@ -190,197 +190,4 @@ void x_acoustics_setup(void)
class_addfloat(dbtorms_class, (t_method)dbtorms_float);
class_sethelpsymbol(dbtorms_class, s);
}
-
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* utility functions for signals
-*/
-
-#include "m_pd.h"
-#include <math.h>
-#define LOGTEN 2.302585092994
-
-float mtof(float f)
-{
- if (f <= -1500) return(0);
- else if (f > 1499) return(mtof(1499));
- else return (8.17579891564 * exp(.0577622650 * f));
-}
-
-float ftom(float f)
-{
- return (f > 0 ? 17.3123405046 * log(.12231220585 * f) : -1500);
-}
-
-float powtodb(float f)
-{
- if (f <= 0) return (0);
- else
- {
- float val = 100 + 10./LOGTEN * log(f);
- return (val < 0 ? 0 : val);
- }
-}
-
-float rmstodb(float f)
-{
- if (f <= 0) return (0);
- else
- {
- float val = 100 + 20./LOGTEN * log(f);
- return (val < 0 ? 0 : val);
- }
-}
-
-float dbtopow(float f)
-{
- if (f <= 0)
- return(0);
- else
- {
- if (f > 870)
- f = 870;
- return (exp((LOGTEN * 0.1) * (f-100.)));
- }
-}
-
-float dbtorms(float f)
-{
- if (f <= 0)
- return(0);
- else
- {
- if (f > 485)
- f = 485;
- }
- return (exp((LOGTEN * 0.05) * (f-100.)));
-}
-
-/* ------------- corresponding objects ----------------------- */
-
-static t_class *mtof_class;
-
-static void *mtof_new(void)
-{
- t_object *x = (t_object *)pd_new(mtof_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void mtof_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, mtof(f));
-}
-
-
-static t_class *ftom_class;
-
-static void *ftom_new(void)
-{
- t_object *x = (t_object *)pd_new(ftom_class);
- outlet_new(x, &s_float);
- return (x);
-}
-static void ftom_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, ftom(f));
-}
-
-
-static t_class *rmstodb_class;
-
-static void *rmstodb_new(void)
-{
- t_object *x = (t_object *)pd_new(rmstodb_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void rmstodb_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, rmstodb(f));
-}
-
-
-static t_class *powtodb_class;
-
-static void *powtodb_new(void)
-{
- t_object *x = (t_object *)pd_new(powtodb_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void powtodb_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, powtodb(f));
-}
-
-
-static t_class *dbtopow_class;
-
-static void *dbtopow_new(void)
-{
- t_object *x = (t_object *)pd_new(dbtopow_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void dbtopow_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, dbtopow(f));
-}
-
-
-static t_class *dbtorms_class;
-
-static void *dbtorms_new(void)
-{
- t_object *x = (t_object *)pd_new(dbtorms_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void dbtorms_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, dbtorms(f));
-}
-
-
-void x_acoustics_setup(void)
-{
- t_symbol *s = gensym("acoustics.pd");
- mtof_class = class_new(gensym("mtof"), mtof_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(mtof_class, (t_method)mtof_float);
- class_sethelpsymbol(mtof_class, s);
-
- ftom_class = class_new(gensym("ftom"), ftom_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(ftom_class, (t_method)ftom_float);
- class_sethelpsymbol(ftom_class, s);
-
- powtodb_class = class_new(gensym("powtodb"), powtodb_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(powtodb_class, (t_method)powtodb_float);
- class_sethelpsymbol(powtodb_class, s);
-
- rmstodb_class = class_new(gensym("rmstodb"), rmstodb_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(rmstodb_class, (t_method)rmstodb_float);
- class_sethelpsymbol(rmstodb_class, s);
-
- dbtopow_class = class_new(gensym("dbtopow"), dbtopow_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(dbtopow_class, (t_method)dbtopow_float);
- class_sethelpsymbol(dbtopow_class, s);
-
- dbtorms_class = class_new(gensym("dbtorms"), dbtorms_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(dbtorms_class, (t_method)dbtorms_float);
- class_sethelpsymbol(dbtorms_class, s);
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/x_arithmetic.c b/apps/plugins/pdbox/PDa/src/x_arithmetic.c
index ad309f7a68..f060f2fd49 100644
--- a/apps/plugins/pdbox/PDa/src/x_arithmetic.c
+++ b/apps/plugins/pdbox/PDa/src/x_arithmetic.c
@@ -893,900 +893,3 @@ void x_arithmetic_setup(void)
clip_setup();
}
-
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* arithmetic: binops ala C language. The 4 functions and relationals are
-done on floats; the logical and bitwise binops convert their
-inputs to int and their outputs back to float. */
-
-#include "m_pd.h"
-#include <math.h>
-
-
-/* MSW and OSX don't appear to have single-precision ANSI math */
-
-#define sinf sin
-#define cosf cos
-#define atanf atan
-#define atan2f atan2
-#define sqrtf sqrt
-#define logf log
-#define expf exp
-#define fabsf fabs
-#define powf pow
-
-
-typedef struct _binop
-{
- t_object x_obj;
- t_float x_f1;
- t_float x_f2;
-} t_binop;
-
-/* ------------------ binop1: +, -, *, / ----------------------------- */
-
-static void *binop1_new(t_class *floatclass, t_floatarg f)
-{
- t_binop *x = (t_binop *)pd_new(floatclass);
- outlet_new(&x->x_obj, &s_float);
- floatinlet_new(&x->x_obj, &x->x_f2);
- x->x_f1 = 0;
- x->x_f2 = f;
- return (x);
-}
-
-/* --------------------- addition ------------------------------- */
-
-static t_class *binop1_plus_class;
-
-static void *binop1_plus_new(t_floatarg f)
-{
- return (binop1_new(binop1_plus_class, f));
-}
-
-static void binop1_plus_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f1 + x->x_f2);
-}
-
-static void binop1_plus_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) + x->x_f2);
-}
-
-/* --------------------- subtraction ------------------------------- */
-
-static t_class *binop1_minus_class;
-
-static void *binop1_minus_new(t_floatarg f)
-{
- return (binop1_new(binop1_minus_class, f));
-}
-
-static void binop1_minus_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f1 - x->x_f2);
-}
-
-static void binop1_minus_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) - x->x_f2);
-}
-
-/* --------------------- multiplication ------------------------------- */
-
-static t_class *binop1_times_class;
-
-static void *binop1_times_new(t_floatarg f)
-{
- return (binop1_new(binop1_times_class, f));
-}
-
-static void binop1_times_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f1 * x->x_f2);
-}
-
-static void binop1_times_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) * x->x_f2);
-}
-
-/* --------------------- division ------------------------------- */
-
-static t_class *binop1_div_class;
-
-static void *binop1_div_new(t_floatarg f)
-{
- return (binop1_new(binop1_div_class, f));
-}
-
-static void binop1_div_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet,
- (x->x_f2 != 0 ? x->x_f1 / x->x_f2 : 0));
-}
-
-static void binop1_div_float(t_binop *x, t_float f)
-{
- x->x_f1 = f;
- outlet_float(x->x_obj.ob_outlet,
- (x->x_f2 != 0 ? x->x_f1 / x->x_f2 : 0));
-}
-
-/* ------------------------ pow -------------------------------- */
-
-static t_class *binop1_pow_class;
-
-static void *binop1_pow_new(t_floatarg f)
-{
- return (binop1_new(binop1_pow_class, f));
-}
-
-static void binop1_pow_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet,
- (x->x_f1 > 0 ? powf(x->x_f1, x->x_f2) : 0));
-}
-
-static void binop1_pow_float(t_binop *x, t_float f)
-{
- x->x_f1 = f;
- outlet_float(x->x_obj.ob_outlet,
- (x->x_f1 > 0 ? powf(x->x_f1, x->x_f2) : 0));
-}
-
-/* ------------------------ max -------------------------------- */
-
-static t_class *binop1_max_class;
-
-static void *binop1_max_new(t_floatarg f)
-{
- return (binop1_new(binop1_max_class, f));
-}
-
-static void binop1_max_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet,
- (x->x_f1 > x->x_f2 ? x->x_f1 : x->x_f2));
-}
-
-static void binop1_max_float(t_binop *x, t_float f)
-{
- x->x_f1 = f;
- outlet_float(x->x_obj.ob_outlet,
- (x->x_f1 > x->x_f2 ? x->x_f1 : x->x_f2));
-}
-
-/* ------------------------ min -------------------------------- */
-
-static t_class *binop1_min_class;
-
-static void *binop1_min_new(t_floatarg f)
-{
- return (binop1_new(binop1_min_class, f));
-}
-
-static void binop1_min_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet,
- (x->x_f1 < x->x_f2 ? x->x_f1 : x->x_f2));
-}
-
-static void binop1_min_float(t_binop *x, t_float f)
-{
- x->x_f1 = f;
- outlet_float(x->x_obj.ob_outlet,
- (x->x_f1 < x->x_f2 ? x->x_f1 : x->x_f2));
-}
-
-/* ------------------ binop2: ==, !=, >, <, >=, <=. -------------------- */
-
-static void *binop2_new(t_class *floatclass, t_floatarg f)
-{
- t_binop *x = (t_binop *)pd_new(floatclass);
- outlet_new(&x->x_obj, &s_float);
- floatinlet_new(&x->x_obj, &x->x_f2);
- x->x_f1 = 0;
- x->x_f2 = f;
- return (x);
-}
-
-/* --------------------- == ------------------------------- */
-
-static t_class *binop2_ee_class;
-
-static void *binop2_ee_new(t_floatarg f)
-{
- return (binop2_new(binop2_ee_class, f));
-}
-
-static void binop2_ee_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f1 == x->x_f2);
-}
-
-static void binop2_ee_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) == x->x_f2);
-}
-
-/* --------------------- != ------------------------------- */
-
-static t_class *binop2_ne_class;
-
-static void *binop2_ne_new(t_floatarg f)
-{
- return (binop2_new(binop2_ne_class, f));
-}
-
-static void binop2_ne_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f1 != x->x_f2);
-}
-
-static void binop2_ne_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) != x->x_f2);
-}
-
-/* --------------------- > ------------------------------- */
-
-static t_class *binop2_gt_class;
-
-static void *binop2_gt_new(t_floatarg f)
-{
- return (binop2_new(binop2_gt_class, f));
-}
-
-static void binop2_gt_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f1 > x->x_f2);
-}
-
-static void binop2_gt_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) > x->x_f2);
-}
-
-/* --------------------- < ------------------------------- */
-
-static t_class *binop2_lt_class;
-
-static void *binop2_lt_new(t_floatarg f)
-{
- return (binop2_new(binop2_lt_class, f));
-}
-
-static void binop2_lt_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f1 < x->x_f2);
-}
-
-static void binop2_lt_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) < x->x_f2);
-}
-
-/* --------------------- >= ------------------------------- */
-
-static t_class *binop2_ge_class;
-
-static void *binop2_ge_new(t_floatarg f)
-{
- return (binop2_new(binop2_ge_class, f));
-}
-
-static void binop2_ge_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f1 >= x->x_f2);
-}
-
-static void binop2_ge_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) >= x->x_f2);
-}
-
-/* --------------------- <= ------------------------------- */
-
-static t_class *binop2_le_class;
-
-static void *binop2_le_new(t_floatarg f)
-{
- return (binop2_new(binop2_le_class, f));
-}
-
-static void binop2_le_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f1 <= x->x_f2);
-}
-
-static void binop2_le_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) <= x->x_f2);
-}
-
-/* ------------- binop3: &, |, &&, ||, <<, >>, %, mod, div ------------------ */
-
-static void *binop3_new(t_class *fixclass, t_floatarg f)
-{
- t_binop *x = (t_binop *)pd_new(fixclass);
- outlet_new(&x->x_obj, &s_float);
- floatinlet_new(&x->x_obj, &x->x_f2);
- x->x_f1 = 0;
- x->x_f2 = f;
- return (x);
-}
-
-/* --------------------------- & ---------------------------- */
-
-static t_class *binop3_ba_class;
-
-static void *binop3_ba_new(t_floatarg f)
-{
- return (binop3_new(binop3_ba_class, f));
-}
-
-static void binop2_ba_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) & (int)(x->x_f2));
-}
-
-static void binop2_ba_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) & (int)(x->x_f2));
-}
-
-/* --------------------------- && ---------------------------- */
-
-static t_class *binop3_la_class;
-
-static void *binop3_la_new(t_floatarg f)
-{
- return (binop3_new(binop3_la_class, f));
-}
-
-static void binop2_la_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) && (int)(x->x_f2));
-}
-
-static void binop2_la_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) && (int)(x->x_f2));
-}
-
-/* --------------------------- | ---------------------------- */
-
-static t_class *binop3_bo_class;
-
-static void *binop3_bo_new(t_floatarg f)
-{
- return (binop3_new(binop3_bo_class, f));
-}
-
-static void binop2_bo_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) | (int)(x->x_f2));
-}
-
-static void binop2_bo_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) | (int)(x->x_f2));
-}
-
-/* --------------------------- || ---------------------------- */
-
-static t_class *binop3_lo_class;
-
-static void *binop3_lo_new(t_floatarg f)
-{
- return (binop3_new(binop3_lo_class, f));
-}
-
-static void binop2_lo_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) || (int)(x->x_f2));
-}
-
-static void binop2_lo_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) || (int)(x->x_f2));
-}
-
-/* --------------------------- << ---------------------------- */
-
-static t_class *binop3_ls_class;
-
-static void *binop3_ls_new(t_floatarg f)
-{
- return (binop3_new(binop3_ls_class, f));
-}
-
-static void binop2_ls_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) << (int)(x->x_f2));
-}
-
-static void binop2_ls_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) << (int)(x->x_f2));
-}
-
-/* --------------------------- >> ---------------------------- */
-
-static t_class *binop3_rs_class;
-
-static void *binop3_rs_new(t_floatarg f)
-{
- return (binop3_new(binop3_rs_class, f));
-}
-
-static void binop2_rs_bang(t_binop *x)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) >> (int)(x->x_f2));
-}
-
-static void binop2_rs_float(t_binop *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) >> (int)(x->x_f2));
-}
-
-/* --------------------------- % ---------------------------- */
-
-static t_class *binop3_pc_class;
-
-static void *binop3_pc_new(t_floatarg f)
-{
- return (binop3_new(binop3_pc_class, f));
-}
-
-static void binop2_pc_bang(t_binop *x)
-{
- int n2 = x->x_f2;
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) % (n2 ? n2 : 1));
-}
-
-static void binop2_pc_float(t_binop *x, t_float f)
-{
- int n2 = x->x_f2;
- outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) % (n2 ? n2 : 1));
-}
-
-/* --------------------------- mod ---------------------------- */
-
-static t_class *binop3_mod_class;
-
-static void *binop3_mod_new(t_floatarg f)
-{
- return (binop3_new(binop3_mod_class, f));
-}
-
-static void binop3_mod_bang(t_binop *x)
-{
- int n2 = x->x_f2, result;
- if (n2 < 0) n2 = -n2;
- else if (!n2) n2 = 1;
- result = ((int)(x->x_f1)) % n2;
- if (result < 0) result += n2;
- outlet_float(x->x_obj.ob_outlet, (t_float)result);
-}
-
-static void binop3_mod_float(t_binop *x, t_float f)
-{
- x->x_f1 = f;
- binop3_mod_bang(x);
-}
-
-/* --------------------------- div ---------------------------- */
-
-static t_class *binop3_div_class;
-
-static void *binop3_div_new(t_floatarg f)
-{
- return (binop3_new(binop3_div_class, f));
-}
-
-static void binop3_div_bang(t_binop *x)
-{
- int n1 = x->x_f1, n2 = x->x_f2, result;
- if (n2 < 0) n2 = -n2;
- else if (!n2) n2 = 1;
- if (n1 < 0) n1 -= (n2-1);
- result = n1 / n2;
- outlet_float(x->x_obj.ob_outlet, (t_float)result);
-}
-
-static void binop3_div_float(t_binop *x, t_float f)
-{
- x->x_f1 = f;
- binop3_div_bang(x);
-}
-
-/* -------------------- mathematical functions ------------------ */
-
-static t_class *sin_class; /* ----------- sin --------------- */
-
-static void *sin_new(void)
-{
- t_object *x = (t_object *)pd_new(sin_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void sin_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, sinf(f));
-}
-
-static t_class *cos_class; /* ----------- cos --------------- */
-
-static void *cos_new(void)
-{
- t_object *x = (t_object *)pd_new(cos_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void cos_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, cosf(f));
-}
-
-static t_class *tan_class; /* ----------- tan --------------- */
-
-static void *tan_new(void)
-{
- t_object *x = (t_object *)pd_new(tan_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void tan_float(t_object *x, t_float f)
-{
- float c = cosf(f);
- float t = (c == 0 ? 0 : sinf(f)/c);
- outlet_float(x->ob_outlet, t);
-}
-
-static t_class *atan_class; /* ----------- atan --------------- */
-
-static void *atan_new(void)
-{
- t_object *x = (t_object *)pd_new(atan_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void atan_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, atanf(f));
-}
-
-static t_class *atan2_class; /* ----------- atan2 --------------- */
-
-typedef struct _atan2
-{
- t_object x_ob;
- float x_y;
-} t_atan2;
-
-static void *atan2_new(void)
-{
- t_atan2 *x = (t_atan2 *)pd_new(atan2_class);
- floatinlet_new(&x->x_ob, &x->x_y);
- outlet_new(&x->x_ob, &s_float);
- return (x);
-}
-
-static void atan2_float(t_atan2 *x, t_float f)
-{
- float r = (f == 0 && x->x_y == 0 ? 0 : atan2f(x->x_y, f));
- outlet_float(x->x_ob.ob_outlet, r);
-}
-
-static t_class *sqrt_class; /* ----------- sqrt --------------- */
-
-static void *sqrt_new(void)
-{
- t_object *x = (t_object *)pd_new(sqrt_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void sqrt_float(t_object *x, t_float f)
-{
- float r = (f > 0 ? sqrtf(f) : 0);
- outlet_float(x->ob_outlet, r);
-}
-
-static t_class *log_class; /* ----------- log --------------- */
-
-static void *log_new(void)
-{
- t_object *x = (t_object *)pd_new(log_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void log_float(t_object *x, t_float f)
-{
- float r = (f > 0 ? logf(f) : -1000);
- outlet_float(x->ob_outlet, r);
-}
-
-
-static t_class *exp_class; /* ----------- exp --------------- */
-
-static void *exp_new(void)
-{
- t_object *x = (t_object *)pd_new(exp_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-#define MAXLOG 87.3365
-static void exp_float(t_object *x, t_float f)
-{
- float g;
-#ifdef MSW
- char buf[10];
-#endif
- if (f > MAXLOG) f = MAXLOG;
- g = expf(f);
- outlet_float(x->ob_outlet, g);
-}
-
-static t_class *abs_class; /* ----------- abs --------------- */
-
-static void *abs_new(void)
-{
- t_object *x = (t_object *)pd_new(abs_class);
- outlet_new(x, &s_float);
- return (x);
-}
-
-static void abs_float(t_object *x, t_float f)
-{
- outlet_float(x->ob_outlet, fabsf(f));
-}
-
-/* ------------------------ misc ------------------------ */
-
-static t_class *clip_class;
-
-typedef struct _clip
-{
- t_object x_ob;
- float x_f1;
- float x_f2;
-} t_clip;
-
-static void *clip_new(t_floatarg f1, t_floatarg f2)
-{
- t_clip *x = (t_clip *)pd_new(clip_class);
- floatinlet_new(&x->x_ob, &x->x_f1);
- floatinlet_new(&x->x_ob, &x->x_f2);
- outlet_new(&x->x_ob, &s_float);
- x->x_f1 = f1;
- x->x_f2 = f2;
- return (x);
-}
-
-static void clip_float(t_clip *x, t_float f)
-{
- outlet_float(x->x_ob.ob_outlet, (f < x->x_f1 ? x->x_f1 : (
- f > x->x_f2 ? x->x_f2 : f)));
-}
-
-static void clip_setup(void)
-{
- clip_class = class_new(gensym("clip"), (t_newmethod)clip_new, 0,
- sizeof(t_clip), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addfloat(clip_class, clip_float);
-}
-
-void x_arithmetic_setup(void)
-{
- t_symbol *binop1_sym = gensym("operators");
- t_symbol *binop23_sym = gensym("otherbinops");
- t_symbol *math_sym = gensym("math");
-
- binop1_plus_class = class_new(gensym("+"), (t_newmethod)binop1_plus_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop1_plus_class, binop1_plus_bang);
- class_addfloat(binop1_plus_class, (t_method)binop1_plus_float);
- class_sethelpsymbol(binop1_plus_class, binop1_sym);
-
- binop1_minus_class = class_new(gensym("-"),
- (t_newmethod)binop1_minus_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop1_minus_class, binop1_minus_bang);
- class_addfloat(binop1_minus_class, (t_method)binop1_minus_float);
- class_sethelpsymbol(binop1_minus_class, binop1_sym);
-
- binop1_times_class = class_new(gensym("*"),
- (t_newmethod)binop1_times_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop1_times_class, binop1_times_bang);
- class_addfloat(binop1_times_class, (t_method)binop1_times_float);
- class_sethelpsymbol(binop1_times_class, binop1_sym);
-
- binop1_div_class = class_new(gensym("/"),
- (t_newmethod)binop1_div_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop1_div_class, binop1_div_bang);
- class_addfloat(binop1_div_class, (t_method)binop1_div_float);
- class_sethelpsymbol(binop1_div_class, binop1_sym);
-
- binop1_pow_class = class_new(gensym("pow"),
- (t_newmethod)binop1_pow_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop1_pow_class, binop1_pow_bang);
- class_addfloat(binop1_pow_class, (t_method)binop1_pow_float);
- class_sethelpsymbol(binop1_pow_class, binop1_sym);
-
- binop1_max_class = class_new(gensym("max"),
- (t_newmethod)binop1_max_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop1_max_class, binop1_max_bang);
- class_addfloat(binop1_max_class, (t_method)binop1_max_float);
- class_sethelpsymbol(binop1_max_class, binop1_sym);
-
- binop1_min_class = class_new(gensym("min"),
- (t_newmethod)binop1_min_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop1_min_class, binop1_min_bang);
- class_addfloat(binop1_min_class, (t_method)binop1_min_float);
- class_sethelpsymbol(binop1_min_class, binop1_sym);
-
- /* ------------------ binop2 ----------------------- */
-
- binop2_ee_class = class_new(gensym("=="), (t_newmethod)binop2_ee_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop2_ee_class, binop2_ee_bang);
- class_addfloat(binop2_ee_class, (t_method)binop2_ee_float);
- class_sethelpsymbol(binop2_ee_class, binop23_sym);
-
- binop2_ne_class = class_new(gensym("!="), (t_newmethod)binop2_ne_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop2_ne_class, binop2_ne_bang);
- class_addfloat(binop2_ne_class, (t_method)binop2_ne_float);
- class_sethelpsymbol(binop2_ne_class, binop23_sym);
-
- binop2_gt_class = class_new(gensym(">"), (t_newmethod)binop2_gt_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop2_gt_class, binop2_gt_bang);
- class_addfloat(binop2_gt_class, (t_method)binop2_gt_float);
- class_sethelpsymbol(binop2_gt_class, binop23_sym);
-
- binop2_lt_class = class_new(gensym("<"), (t_newmethod)binop2_lt_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop2_lt_class, binop2_lt_bang);
- class_addfloat(binop2_lt_class, (t_method)binop2_lt_float);
- class_sethelpsymbol(binop2_lt_class, binop23_sym);
-
- binop2_ge_class = class_new(gensym(">="), (t_newmethod)binop2_ge_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop2_ge_class, binop2_ge_bang);
- class_addfloat(binop2_ge_class, (t_method)binop2_ge_float);
- class_sethelpsymbol(binop2_ge_class, binop23_sym);
-
- binop2_le_class = class_new(gensym("<="), (t_newmethod)binop2_le_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop2_le_class, binop2_le_bang);
- class_addfloat(binop2_le_class, (t_method)binop2_le_float);
- class_sethelpsymbol(binop2_le_class, binop23_sym);
-
- /* ------------------ binop3 ----------------------- */
-
- binop3_ba_class = class_new(gensym("&"), (t_newmethod)binop3_ba_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop3_ba_class, binop2_ba_bang);
- class_addfloat(binop3_ba_class, (t_method)binop2_ba_float);
- class_sethelpsymbol(binop3_ba_class, binop23_sym);
-
- binop3_la_class = class_new(gensym("&&"), (t_newmethod)binop3_la_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop3_la_class, binop2_la_bang);
- class_addfloat(binop3_la_class, (t_method)binop2_la_float);
- class_sethelpsymbol(binop3_la_class, binop23_sym);
-
- binop3_bo_class = class_new(gensym("|"), (t_newmethod)binop3_bo_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop3_bo_class, binop2_bo_bang);
- class_addfloat(binop3_bo_class, (t_method)binop2_bo_float);
- class_sethelpsymbol(binop3_bo_class, binop23_sym);
-
- binop3_lo_class = class_new(gensym("||"), (t_newmethod)binop3_lo_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop3_lo_class, binop2_lo_bang);
- class_addfloat(binop3_lo_class, (t_method)binop2_lo_float);
- class_sethelpsymbol(binop3_lo_class, binop23_sym);
-
- binop3_ls_class = class_new(gensym("<<"), (t_newmethod)binop3_ls_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop3_ls_class, binop2_ls_bang);
- class_addfloat(binop3_ls_class, (t_method)binop2_ls_float);
- class_sethelpsymbol(binop3_ls_class, binop23_sym);
-
- binop3_rs_class = class_new(gensym(">>"), (t_newmethod)binop3_rs_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop3_rs_class, binop2_rs_bang);
- class_addfloat(binop3_rs_class, (t_method)binop2_rs_float);
- class_sethelpsymbol(binop3_rs_class, binop23_sym);
-
- binop3_pc_class = class_new(gensym("%"), (t_newmethod)binop3_pc_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop3_pc_class, binop2_pc_bang);
- class_addfloat(binop3_pc_class, (t_method)binop2_pc_float);
- class_sethelpsymbol(binop3_pc_class, binop23_sym);
-
- binop3_mod_class = class_new(gensym("mod"), (t_newmethod)binop3_mod_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop3_mod_class, binop3_mod_bang);
- class_addfloat(binop3_mod_class, (t_method)binop3_mod_float);
- class_sethelpsymbol(binop3_mod_class, binop23_sym);
-
- binop3_div_class = class_new(gensym("div"), (t_newmethod)binop3_div_new, 0,
- sizeof(t_binop), 0, A_DEFFLOAT, 0);
- class_addbang(binop3_div_class, binop3_div_bang);
- class_addfloat(binop3_div_class, (t_method)binop3_div_float);
- class_sethelpsymbol(binop3_div_class, binop23_sym);
-
- /* ------------------- math functions --------------- */
-
- sin_class = class_new(gensym("sin"), sin_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(sin_class, (t_method)sin_float);
- class_sethelpsymbol(sin_class, math_sym);
-
- cos_class = class_new(gensym("cos"), cos_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(cos_class, (t_method)cos_float);
- class_sethelpsymbol(cos_class, math_sym);
-
- tan_class = class_new(gensym("tan"), tan_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(tan_class, (t_method)tan_float);
- class_sethelpsymbol(tan_class, math_sym);
-
- atan_class = class_new(gensym("atan"), atan_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(atan_class, (t_method)atan_float);
- class_sethelpsymbol(atan_class, math_sym);
-
- atan2_class = class_new(gensym("atan2"), atan2_new, 0,
- sizeof(t_atan2), 0, 0);
- class_addfloat(atan2_class, (t_method)atan2_float);
- class_sethelpsymbol(atan2_class, math_sym);
-
- sqrt_class = class_new(gensym("sqrt"), sqrt_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(sqrt_class, (t_method)sqrt_float);
- class_sethelpsymbol(sqrt_class, math_sym);
-
- log_class = class_new(gensym("log"), log_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(log_class, (t_method)log_float);
- class_sethelpsymbol(log_class, math_sym);
-
- exp_class = class_new(gensym("exp"), exp_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(exp_class, (t_method)exp_float);
- class_sethelpsymbol(exp_class, math_sym);
-
- abs_class = class_new(gensym("abs"), abs_new, 0,
- sizeof(t_object), 0, 0);
- class_addfloat(abs_class, (t_method)abs_float);
- class_sethelpsymbol(abs_class, math_sym);
-
-/* ------------------------ misc ------------------------ */
-
- clip_setup();
-}
-
-
diff --git a/apps/plugins/pdbox/PDa/src/x_connective.c b/apps/plugins/pdbox/PDa/src/x_connective.c
index d68192ea9a..52bc0920a1 100644
--- a/apps/plugins/pdbox/PDa/src/x_connective.c
+++ b/apps/plugins/pdbox/PDa/src/x_connective.c
@@ -1450,1455 +1450,4 @@ void x_connective_setup(void)
change_setup();
value_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* connective objects */
-
-#include "m_pd.h"
-
-#include <string.h>
-#include <stdio.h>
-extern t_pd *newest;
-
-/* -------------------------- int ------------------------------ */
-static t_class *pdint_class;
-
-typedef struct _pdint
-{
- t_object x_obj;
- t_float x_f;
-} t_pdint;
-
-static void *pdint_new(t_floatarg f)
-{
- t_pdint *x = (t_pdint *)pd_new(pdint_class);
- x->x_f = f;
- outlet_new(&x->x_obj, &s_float);
- floatinlet_new(&x->x_obj, &x->x_f);
- return (x);
-}
-
-static void pdint_bang(t_pdint *x)
-{
- outlet_float(x->x_obj.ob_outlet, (t_float)(int)(x->x_f));
-}
-
-static void pdint_float(t_pdint *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, (t_float)(int)(x->x_f = f));
-}
-
-void pdint_setup(void)
-{
- pdint_class = class_new(gensym("int"), (t_newmethod)pdint_new, 0,
- sizeof(t_pdint), 0, A_DEFFLOAT, 0);
- class_addcreator((t_newmethod)pdint_new, gensym("i"), A_DEFFLOAT, 0);
- class_addbang(pdint_class, pdint_bang);
- class_addfloat(pdint_class, pdint_float);
-}
-
-/* -------------------------- float ------------------------------ */
-static t_class *pdfloat_class;
-
-typedef struct _pdfloat
-{
- t_object x_obj;
- t_float x_f;
-} t_pdfloat;
-
- /* "float," "symbol," and "bang" are special because
- they're created by short-circuited messages to the "new"
- object which are handled specially in pd_typedmess(). */
-
-static void *pdfloat_new(t_pd *dummy, t_float f)
-{
- t_pdfloat *x = (t_pdfloat *)pd_new(pdfloat_class);
- x->x_f = f;
- outlet_new(&x->x_obj, &s_float);
- floatinlet_new(&x->x_obj, &x->x_f);
- newest = &x->x_obj.ob_pd;
- return (x);
-}
-
-static void *pdfloat_new2(t_floatarg f)
-{
- return (pdfloat_new(0, f));
-}
-
-static void pdfloat_bang(t_pdfloat *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f);
-}
-
-static void pdfloat_float(t_pdfloat *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f = f);
-}
-
-void pdfloat_setup(void)
-{
- pdfloat_class = class_new(gensym("float"), (t_newmethod)pdfloat_new, 0,
- sizeof(t_pdfloat), 0, A_FLOAT, 0);
- class_addcreator((t_newmethod)pdfloat_new2, gensym("f"), A_DEFFLOAT, 0);
- class_addbang(pdfloat_class, pdfloat_bang);
- class_addfloat(pdfloat_class, (t_method)pdfloat_float);
-}
-
-/* -------------------------- symbol ------------------------------ */
-static t_class *pdsymbol_class;
-
-typedef struct _pdsymbol
-{
- t_object x_obj;
- t_symbol *x_s;
-} t_pdsymbol;
-
-static void *pdsymbol_new(t_pd *dummy, t_symbol *s)
-{
- t_pdsymbol *x = (t_pdsymbol *)pd_new(pdsymbol_class);
- x->x_s = s;
- outlet_new(&x->x_obj, &s_symbol);
- symbolinlet_new(&x->x_obj, &x->x_s);
- newest = &x->x_obj.ob_pd;
- return (x);
-}
-
-static void pdsymbol_bang(t_pdsymbol *x)
-{
- outlet_symbol(x->x_obj.ob_outlet, x->x_s);
-}
-
-static void pdsymbol_symbol(t_pdsymbol *x, t_symbol *s)
-{
- outlet_symbol(x->x_obj.ob_outlet, x->x_s = s);
-}
-
-static void pdsymbol_anything(t_pdsymbol *x, t_symbol *s, int ac, t_atom *av)
-{
- outlet_symbol(x->x_obj.ob_outlet, x->x_s = s);
-}
-
-void pdsymbol_setup(void)
-{
- pdsymbol_class = class_new(gensym("symbol"), (t_newmethod)pdsymbol_new, 0,
- sizeof(t_pdsymbol), 0, A_SYMBOL, 0);
- class_addbang(pdsymbol_class, pdsymbol_bang);
- class_addsymbol(pdsymbol_class, pdsymbol_symbol);
- class_addanything(pdsymbol_class, pdsymbol_anything);
-}
-
-/* -------------------------- bang ------------------------------ */
-static t_class *bang_class;
-
-typedef struct _bang
-{
- t_object x_obj;
-} t_bang;
-
-static void *bang_new(t_pd *dummy)
-{
- t_bang *x = (t_bang *)pd_new(bang_class);
- outlet_new(&x->x_obj, &s_bang);
- newest = &x->x_obj.ob_pd;
- return (x);
-}
-
-static void *bang_new2(t_bang f)
-{
- return (bang_new(0));
-}
-
-static void bang_bang(t_bang *x)
-{
- outlet_bang(x->x_obj.ob_outlet);
-}
-
-void bang_setup(void)
-{
- bang_class = class_new(gensym("bang"), (t_newmethod)bang_new, 0,
- sizeof(t_bang), 0, 0);
- class_addcreator((t_newmethod)bang_new2, gensym("b"), 0);
- class_addbang(bang_class, bang_bang);
- class_addfloat(bang_class, bang_bang);
- class_addsymbol(bang_class, bang_bang);
- class_addlist(bang_class, bang_bang);
- class_addanything(bang_class, bang_bang);
-}
-
-/* -------------------- send ------------------------------ */
-
-static t_class *send_class;
-
-typedef struct _send
-{
- t_object x_obj;
- t_symbol *x_sym;
-} t_send;
-
-static void send_bang(t_send *x)
-{
- if (x->x_sym->s_thing) pd_bang(x->x_sym->s_thing);
-}
-
-static void send_float(t_send *x, t_float f)
-{
- if (x->x_sym->s_thing) pd_float(x->x_sym->s_thing, f);
-}
-
-static void send_symbol(t_send *x, t_symbol *s)
-{
- if (x->x_sym->s_thing) pd_symbol(x->x_sym->s_thing, s);
-}
-
-static void send_pointer(t_send *x, t_gpointer *gp)
-{
- if (x->x_sym->s_thing) pd_pointer(x->x_sym->s_thing, gp);
-}
-
-static void send_list(t_send *x, t_symbol *s, int argc, t_atom *argv)
-{
- if (x->x_sym->s_thing) pd_list(x->x_sym->s_thing, s, argc, argv);
-}
-
-static void send_anything(t_send *x, t_symbol *s, int argc, t_atom *argv)
-{
- if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, s, argc, argv);
-}
-
-static void *send_new(t_symbol *s)
-{
- t_send *x = (t_send *)pd_new(send_class);
- x->x_sym = s;
- return (x);
-}
-
-static void send_setup(void)
-{
- send_class = class_new(gensym("send"), (t_newmethod)send_new, 0,
- sizeof(t_send), 0, A_DEFSYM, 0);
- class_addcreator((t_newmethod)send_new, gensym("s"), A_DEFSYM, 0);
- class_addbang(send_class, send_bang);
- class_addfloat(send_class, send_float);
- class_addsymbol(send_class, send_symbol);
- class_addpointer(send_class, send_pointer);
- class_addlist(send_class, send_list);
- class_addanything(send_class, send_anything);
-}
-/* -------------------- receive ------------------------------ */
-
-static t_class *receive_class;
-
-typedef struct _receive
-{
- t_object x_obj;
- t_symbol *x_sym;
-} t_receive;
-
-static void receive_bang(t_receive *x)
-{
- outlet_bang(x->x_obj.ob_outlet);
-}
-
-static void receive_float(t_receive *x, t_float f)
-{
- outlet_float(x->x_obj.ob_outlet, f);
-}
-
-static void receive_symbol(t_receive *x, t_symbol *s)
-{
- outlet_symbol(x->x_obj.ob_outlet, s);
-}
-
-static void receive_pointer(t_receive *x, t_gpointer *gp)
-{
- outlet_pointer(x->x_obj.ob_outlet, gp);
-}
-
-static void receive_list(t_receive *x, t_symbol *s, int argc, t_atom *argv)
-{
- outlet_list(x->x_obj.ob_outlet, s, argc, argv);
-}
-
-static void receive_anything(t_receive *x, t_symbol *s, int argc, t_atom *argv)
-{
- outlet_anything(x->x_obj.ob_outlet, s, argc, argv);
-}
-
-static void *receive_new(t_symbol *s)
-{
- t_receive *x = (t_receive *)pd_new(receive_class);
- x->x_sym = s;
- pd_bind(&x->x_obj.ob_pd, s);
- outlet_new(&x->x_obj, 0);
- return (x);
-}
-
-static void receive_free(t_receive *x)
-{
- pd_unbind(&x->x_obj.ob_pd, x->x_sym);
-}
-
-static void receive_setup(void)
-{
- receive_class = class_new(gensym("receive"), (t_newmethod)receive_new,
- (t_method)receive_free, sizeof(t_receive), CLASS_NOINLET, A_DEFSYM, 0);
- class_addcreator((t_newmethod)receive_new, gensym("r"), A_DEFSYM, 0);
- class_addbang(receive_class, receive_bang);
- class_addfloat(receive_class, (t_method)receive_float);
- class_addsymbol(receive_class, receive_symbol);
- class_addpointer(receive_class, receive_pointer);
- class_addlist(receive_class, receive_list);
- class_addanything(receive_class, receive_anything);
-}
-
-/* -------------------------- select ------------------------------ */
-
-static t_class *sel1_class;
-
-typedef struct _sel1
-{
- t_object x_obj;
- t_atom x_atom;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
-} t_sel1;
-
-static void sel1_float(t_sel1 *x, t_float f)
-{
- if (x->x_atom.a_type == A_FLOAT && f == x->x_atom.a_w.w_float)
- outlet_bang(x->x_outlet1);
- else outlet_float(x->x_outlet2, f);
-}
-
-static void sel1_symbol(t_sel1 *x, t_symbol *s)
-{
- if (x->x_atom.a_type == A_SYMBOL && s == x->x_atom.a_w.w_symbol)
- outlet_bang(x->x_outlet1);
- else outlet_symbol(x->x_outlet2, s);
-}
-
-static t_class *sel2_class;
-
-typedef struct _selectelement
-{
- t_word e_w;
- t_outlet *e_outlet;
-} t_selectelement;
-
-typedef struct _sel2
-{
- t_object x_obj;
- t_atomtype x_type;
- t_int x_nelement;
- t_selectelement *x_vec;
- t_outlet *x_rejectout;
-} t_sel2;
-
-static void sel2_float(t_sel2 *x, t_float f)
-{
- t_selectelement *e;
- int nelement;
- if (x->x_type == A_FLOAT)
- {
- for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
- if (e->e_w.w_float == f)
- {
- outlet_bang(e->e_outlet);
- return;
- }
- }
- outlet_float(x->x_rejectout, f);
-}
-
-static void sel2_symbol(t_sel2 *x, t_symbol *s)
-{
- t_selectelement *e;
- int nelement;
- if (x->x_type == A_SYMBOL)
- {
- for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
- if (e->e_w.w_symbol == s)
- {
- outlet_bang(e->e_outlet);
- return;
- }
- }
- outlet_symbol(x->x_rejectout, s);
-}
-
-static void sel2_free(t_sel2 *x)
-{
- freebytes(x->x_vec, x->x_nelement * sizeof(*x->x_vec));
-}
-
-static void *select_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_atom a;
- if (argc == 0)
- {
- argc = 1;
- SETFLOAT(&a, 0);
- argv = &a;
- }
- if (argc == 1)
- {
- t_sel1 *x = (t_sel1 *)pd_new(sel1_class);
- x->x_atom = *argv;
- x->x_outlet1 = outlet_new(&x->x_obj, &s_bang);
- if (argv->a_type == A_FLOAT)
- {
- floatinlet_new(&x->x_obj, &x->x_atom.a_w.w_float);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- }
- else
- {
- symbolinlet_new(&x->x_obj, &x->x_atom.a_w.w_symbol);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_symbol);
- }
- return (x);
- }
- else
- {
- int n;
- t_selectelement *e;
- t_sel2 *x = (t_sel2 *)pd_new(sel2_class);
- x->x_nelement = argc;
- x->x_vec = (t_selectelement *)getbytes(argc * sizeof(*x->x_vec));
- x->x_type = argv[0].a_type;
- for (n = 0, e = x->x_vec; n < argc; n++, e++)
- {
- e->e_outlet = outlet_new(&x->x_obj, &s_bang);
- if ((x->x_type = argv->a_type) == A_FLOAT)
- e->e_w.w_float = atom_getfloatarg(n, argc, argv);
- else e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv);
- }
- x->x_rejectout = outlet_new(&x->x_obj, &s_float);
- return (x);
- }
-
-}
-
-void select_setup(void)
-{
- sel1_class = class_new(gensym("select"), 0, 0,
- sizeof(t_sel1), 0, 0);
- class_addfloat(sel1_class, sel1_float);
- class_addsymbol(sel1_class, sel1_symbol);
-
- sel2_class = class_new(gensym("select"), 0, (t_method)sel2_free,
- sizeof(t_sel2), 0, 0);
- class_addfloat(sel2_class, sel2_float);
- class_addsymbol(sel2_class, sel2_symbol);
-
- class_addcreator((t_newmethod)select_new, gensym("select"), A_GIMME, 0);
- class_addcreator((t_newmethod)select_new, gensym("sel"), A_GIMME, 0);
-}
-
-/* -------------------------- route ------------------------------ */
-
-static t_class *route_class;
-
-typedef struct _routeelement
-{
- t_word e_w;
- t_outlet *e_outlet;
-} t_routeelement;
-
-typedef struct _route
-{
- t_object x_obj;
- t_atomtype x_type;
- t_int x_nelement;
- t_routeelement *x_vec;
- t_outlet *x_rejectout;
-} t_route;
-
-static void route_anything(t_route *x, t_symbol *sel, int argc, t_atom *argv)
-{
- t_routeelement *e;
- int nelement;
- if (x->x_type == A_SYMBOL)
- {
- for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
- if (e->e_w.w_symbol == sel)
- {
- if (argc > 0 && argv[0].a_type == A_SYMBOL)
- outlet_anything(e->e_outlet, argv[0].a_w.w_symbol,
- argc-1, argv+1);
- else outlet_list(e->e_outlet, 0, argc, argv);
- return;
- }
- }
- outlet_anything(x->x_rejectout, sel, argc, argv);
-}
-
-static void route_list(t_route *x, t_symbol *sel, int argc, t_atom *argv)
-{
- t_routeelement *e;
- int nelement;
- if (x->x_type == A_FLOAT)
- {
- float f;
- if (!argc) return;
- f = atom_getfloat(argv);
- for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
- if (e->e_w.w_float == f)
- {
- if (argc > 1 && argv[1].a_type == A_SYMBOL)
- outlet_anything(e->e_outlet, argv[1].a_w.w_symbol,
- argc-2, argv+2);
- else outlet_list(e->e_outlet, 0, argc-1, argv+1);
- return;
- }
- }
- else /* symbol arguments */
- {
- if (argc > 1) /* 2 or more args: treat as "list" */
- {
- for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
- {
- if (e->e_w.w_symbol == &s_list)
- {
- if (argc > 0 && argv[0].a_type == A_SYMBOL)
- outlet_anything(e->e_outlet, argv[0].a_w.w_symbol,
- argc-1, argv+1);
- else outlet_list(e->e_outlet, 0, argc, argv);
- return;
- }
- }
- }
- else if (argc == 0) /* no args: treat as "bang" */
- {
- for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
- {
- if (e->e_w.w_symbol == &s_bang)
- {
- outlet_bang(e->e_outlet);
- return;
- }
- }
- }
- else if (argv[0].a_type == A_FLOAT) /* one float arg */
- {
- for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
- {
- if (e->e_w.w_symbol == &s_float)
- {
- outlet_float(e->e_outlet, argv[0].a_w.w_float);
- return;
- }
- }
- }
- else
- {
- for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
- {
- if (e->e_w.w_symbol == &s_symbol)
- {
- outlet_symbol(e->e_outlet, argv[0].a_w.w_symbol);
- return;
- }
- }
- }
- }
- outlet_list(x->x_rejectout, 0, argc, argv);
-}
-
-
-static void route_free(t_route *x)
-{
- freebytes(x->x_vec, x->x_nelement * sizeof(*x->x_vec));
-}
-
-static void *route_new(t_symbol *s, int argc, t_atom *argv)
-{
- int n;
- t_routeelement *e;
- t_route *x = (t_route *)pd_new(route_class);
- t_atom a;
- if (argc == 0)
- {
- argc = 1;
- SETFLOAT(&a, 0);
- argv = &a;
- }
- x->x_type = argv[0].a_type;
- x->x_nelement = argc;
- x->x_vec = (t_routeelement *)getbytes(argc * sizeof(*x->x_vec));
- for (n = 0, e = x->x_vec; n < argc; n++, e++)
- {
- e->e_outlet = outlet_new(&x->x_obj, &s_list);
- if (x->x_type == A_FLOAT)
- e->e_w.w_float = atom_getfloatarg(n, argc, argv);
- else e->e_w.w_symbol = atom_getsymbolarg(n, argc, argv);
- }
- x->x_rejectout = outlet_new(&x->x_obj, &s_list);
- return (x);
-}
-
-void route_setup(void)
-{
- route_class = class_new(gensym("route"), (t_newmethod)route_new,
- (t_method)route_free, sizeof(t_route), 0, A_GIMME, 0);
- class_addlist(route_class, route_list);
- class_addanything(route_class, route_anything);
-}
-
-/* -------------------------- pack ------------------------------ */
-
-static t_class *pack_class;
-
-typedef struct _pack
-{
- t_object x_obj;
- t_int x_n; /* number of args */
- t_atom *x_vec; /* input values */
- t_int x_nptr; /* number of pointers */
- t_gpointer *x_gpointer; /* the pointers */
- t_atom *x_outvec; /* space for output values */
-} t_pack;
-
-static void *pack_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_pack *x = (t_pack *)pd_new(pack_class);
- t_atom defarg[2], *ap, *vec, *vp;
- t_gpointer *gp;
- int nptr = 0;
- int i;
- if (!argc)
- {
- argv = defarg;
- argc = 2;
- SETFLOAT(&defarg[0], 0);
- SETFLOAT(&defarg[1], 0);
- }
-
- x->x_n = argc;
- vec = x->x_vec = (t_atom *)getbytes(argc * sizeof(*x->x_vec));
- x->x_outvec = (t_atom *)getbytes(argc * sizeof(*x->x_outvec));
-
- for (i = argc, ap = argv; i--; ap++)
- if (ap->a_type == A_SYMBOL && *ap->a_w.w_symbol->s_name == 'p')
- nptr++;
-
- gp = x->x_gpointer = (t_gpointer *)t_getbytes(nptr * sizeof (*gp));
- x->x_nptr = nptr;
-
- for (i = 0, vp = x->x_vec, ap = argv; i < argc; i++, ap++, vp++)
- {
- if (ap->a_type == A_FLOAT)
- {
- *vp = *ap;
- if (i) floatinlet_new(&x->x_obj, &vp->a_w.w_float);
- }
- else if (ap->a_type == A_SYMBOL)
- {
- char c = *ap->a_w.w_symbol->s_name;
- if (c == 's')
- {
- SETSYMBOL(vp, &s_symbol);
- if (i) symbolinlet_new(&x->x_obj, &vp->a_w.w_symbol);
- }
- else if (c == 'p')
- {
- vp->a_type = A_POINTER;
- vp->a_w.w_gpointer = gp;
- gpointer_init(gp);
- if (i) pointerinlet_new(&x->x_obj, gp);
- gp++;
- }
- else
- {
- if (c != 'f') pd_error(x, "pack: %s: bad type",
- ap->a_w.w_symbol->s_name);
- SETFLOAT(vp, 0);
- if (i) floatinlet_new(&x->x_obj, &vp->a_w.w_float);
- }
- }
- }
- outlet_new(&x->x_obj, &s_list);
- return (x);
-}
-
-static void pack_bang(t_pack *x)
-{
- int i, reentered = 0, size = x->x_n * sizeof (t_atom);
- t_gpointer *gp;
- t_atom *outvec;
- for (i = x->x_nptr, gp = x->x_gpointer; i--; gp++)
- if (!gpointer_check(gp, 1))
- {
- pd_error(x, "pack: stale pointer");
- return;
- }
- /* reentrancy protection. The first time through use the pre-allocated
- x_outvec; if we're reentered we have to allocate new memory. */
- if (!x->x_outvec)
- {
- /* LATER figure out how to deal with reentrancy and pointers... */
- if (x->x_nptr)
- post("pack_bang: warning: reentry with pointers unprotected");
- outvec = t_getbytes(size);
- reentered = 1;
- }
- else
- {
- outvec = x->x_outvec;
- x->x_outvec = 0;
- }
- memcpy(outvec, x->x_vec, size);
- outlet_list(x->x_obj.ob_outlet, &s_list, x->x_n, outvec);
- if (reentered)
- t_freebytes(outvec, size);
- else x->x_outvec = outvec;
-}
-
-static void pack_pointer(t_pack *x, t_gpointer *gp)
-{
- if (x->x_vec->a_type == A_POINTER)
- {
- gpointer_unset(x->x_gpointer);
- *x->x_gpointer = *gp;
- if (gp->gp_stub) gp->gp_stub->gs_refcount++;
- pack_bang(x);
- }
- else pd_error(x, "pack_pointer: wrong type");
-}
-
-static void pack_float(t_pack *x, t_float f)
-{
- if (x->x_vec->a_type == A_FLOAT)
- {
- x->x_vec->a_w.w_float = f;
- pack_bang(x);
- }
- else pd_error(x, "pack_float: wrong type");
-}
-static void pack_symbol(t_pack *x, t_symbol *s)
-{
- if (x->x_vec->a_type == A_SYMBOL)
- {
- x->x_vec->a_w.w_symbol = s;
- pack_bang(x);
- }
- else pd_error(x, "pack_symbol: wrong type");
-}
-
-static void pack_list(t_pack *x, t_symbol *s, int ac, t_atom *av)
-{
- obj_list(&x->x_obj, 0, ac, av);
-}
-
-static void pack_anything(t_pack *x, t_symbol *s, int ac, t_atom *av)
-{
- t_atom *av2 = (t_atom *)getbytes((ac + 1) * sizeof(t_atom));
- int i;
- for (i = 0; i < ac; i++)
- av2[i + 1] = av[i];
- SETSYMBOL(av2, s);
- obj_list(&x->x_obj, 0, ac+1, av2);
- freebytes(av2, (ac + 1) * sizeof(t_atom));
-}
-
-static void pack_free(t_pack *x)
-{
- t_gpointer *gp;
- int i;
- for (gp = x->x_gpointer, i = x->x_nptr; i--; gp++)
- gpointer_unset(gp);
- freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec));
- freebytes(x->x_outvec, x->x_n * sizeof(*x->x_outvec));
- freebytes(x->x_gpointer, x->x_nptr * sizeof(*x->x_gpointer));
-}
-
-static void pack_setup(void)
-{
- pack_class = class_new(gensym("pack"), (t_newmethod)pack_new,
- (t_method)pack_free, sizeof(t_pack), 0, A_GIMME, 0);
- class_addbang(pack_class, pack_bang);
- class_addpointer(pack_class, pack_pointer);
- class_addfloat(pack_class, pack_float);
- class_addsymbol(pack_class, pack_symbol);
- class_addlist(pack_class, pack_list);
- class_addanything(pack_class, pack_anything);
-}
-
-/* -------------------------- unpack ------------------------------ */
-
-static t_class *unpack_class;
-
-typedef struct unpackout
-{
- t_atomtype u_type;
- t_outlet *u_outlet;
-} t_unpackout;
-
-typedef struct _unpack
-{
- t_object x_obj;
- t_int x_n;
- t_unpackout *x_vec;
-} t_unpack;
-
-static void *unpack_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_unpack *x = (t_unpack *)pd_new(unpack_class);
- t_atom defarg[2], *ap;
- t_unpackout *u;
- int i;
- if (!argc)
- {
- argv = defarg;
- argc = 2;
- SETFLOAT(&defarg[0], 0);
- SETFLOAT(&defarg[1], 0);
- }
- x->x_n = argc;
- x->x_vec = (t_unpackout *)getbytes(argc * sizeof(*x->x_vec));
- for (i = 0, ap = argv, u = x->x_vec; i < argc; u++, ap++, i++)
- {
- t_atomtype type = ap->a_type;
- if (type == A_SYMBOL)
- {
- char c = *ap->a_w.w_symbol->s_name;
- if (c == 's')
- {
- u->u_type = A_SYMBOL;
- u->u_outlet = outlet_new(&x->x_obj, &s_symbol);
- }
- else if (c == 'p')
- {
- u->u_type = A_POINTER;
- u->u_outlet = outlet_new(&x->x_obj, &s_pointer);
- }
- else
- {
- if (c != 'f') pd_error(x, "unpack: %s: bad type",
- ap->a_w.w_symbol->s_name);
- u->u_type = A_FLOAT;
- u->u_outlet = outlet_new(&x->x_obj, &s_float);
- }
- }
- else
- {
- u->u_type = A_FLOAT;
- u->u_outlet = outlet_new(&x->x_obj, &s_float);
- }
- }
- return (x);
-}
-
-static void unpack_list(t_unpack *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_atom *ap;
- t_unpackout *u;
- int i;
- if (argc > x->x_n) argc = x->x_n;
- for (i = argc, u = x->x_vec + i, ap = argv + i; u--, ap--, i--;)
- {
- t_atomtype type = u->u_type;
- if (type != ap->a_type)
- pd_error(x, "unpack: type mismatch");
- else if (type == A_FLOAT)
- outlet_float(u->u_outlet, ap->a_w.w_float);
- else if (type == A_SYMBOL)
- outlet_symbol(u->u_outlet, ap->a_w.w_symbol);
- else outlet_pointer(u->u_outlet, ap->a_w.w_gpointer);
- }
-}
-
-static void unpack_anything(t_unpack *x, t_symbol *s, int ac, t_atom *av)
-{
- t_atom *av2 = (t_atom *)getbytes((ac + 1) * sizeof(t_atom));
- int i;
- for (i = 0; i < ac; i++)
- av2[i + 1] = av[i];
- SETSYMBOL(av2, s);
- unpack_list(x, 0, ac+1, av2);
- freebytes(av2, (ac + 1) * sizeof(t_atom));
-}
-
-static void unpack_free(t_unpack *x)
-{
- freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec));
-}
-
-static void unpack_setup(void)
-{
- unpack_class = class_new(gensym("unpack"), (t_newmethod)unpack_new,
- (t_method)unpack_free, sizeof(t_unpack), 0, A_GIMME, 0);
- class_addlist(unpack_class, unpack_list);
- class_addanything(unpack_class, unpack_anything);
-}
-
-/* -------------------------- trigger ------------------------------ */
-
-static t_class *trigger_class;
-#define TR_BANG 0
-#define TR_FLOAT 1
-#define TR_SYMBOL 2
-#define TR_POINTER 3
-#define TR_LIST 4
-#define TR_ANYTHING 5
-
-typedef struct triggerout
-{
- int u_type; /* outlet type from above */
- t_outlet *u_outlet;
-} t_triggerout;
-
-typedef struct _trigger
-{
- t_object x_obj;
- t_int x_n;
- t_triggerout *x_vec;
-} t_trigger;
-
-static void *trigger_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_trigger *x = (t_trigger *)pd_new(trigger_class);
- t_atom defarg[2], *ap;
- t_triggerout *u;
- int i;
- if (!argc)
- {
- argv = defarg;
- argc = 2;
- SETSYMBOL(&defarg[0], &s_bang);
- SETSYMBOL(&defarg[1], &s_bang);
- }
- x->x_n = argc;
- x->x_vec = (t_triggerout *)getbytes(argc * sizeof(*x->x_vec));
- for (i = 0, ap = argv, u = x->x_vec; i < argc; u++, ap++, i++)
- {
- t_atomtype thistype = ap->a_type;
- char c;
- if (thistype == TR_SYMBOL) c = ap->a_w.w_symbol->s_name[0];
- else if (thistype == TR_FLOAT) c = 'f';
- else c = 0;
- if (c == 'p')
- u->u_type = TR_POINTER,
- u->u_outlet = outlet_new(&x->x_obj, &s_pointer);
- else if (c == 'f')
- u->u_type = TR_FLOAT, u->u_outlet = outlet_new(&x->x_obj, &s_float);
- else if (c == 'b')
- u->u_type = TR_BANG, u->u_outlet = outlet_new(&x->x_obj, &s_bang);
- else if (c == 'l')
- u->u_type = TR_LIST, u->u_outlet = outlet_new(&x->x_obj, &s_list);
- else if (c == 's')
- u->u_type = TR_SYMBOL,
- u->u_outlet = outlet_new(&x->x_obj, &s_symbol);
- else if (c == 'a')
- u->u_type = TR_ANYTHING,
- u->u_outlet = outlet_new(&x->x_obj, &s_symbol);
- else
- {
- pd_error(x, "trigger: %s: bad type", ap->a_w.w_symbol->s_name);
- u->u_type = TR_FLOAT, u->u_outlet = outlet_new(&x->x_obj, &s_float);
- }
- }
- return (x);
-}
-
-static void trigger_list(t_trigger *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_triggerout *u;
- int i;
- t_atom at;
- if (!argc)
- {
- argc = 1;
- SETFLOAT(&at, 0);
- argv = &at;
- }
- for (i = x->x_n, u = x->x_vec + i; u--, i--;)
- {
- if (u->u_type == TR_FLOAT)
- outlet_float(u->u_outlet, atom_getfloat(argv));
- else if (u->u_type == TR_BANG)
- outlet_bang(u->u_outlet);
- else if (u->u_type == TR_SYMBOL)
- outlet_symbol(u->u_outlet, atom_getsymbol(argv));
- else if (u->u_type == TR_POINTER)
- {
- if (argv->a_type != TR_POINTER)
- pd_error(x, "unpack: bad pointer");
- else outlet_pointer(u->u_outlet, argv->a_w.w_gpointer);
- }
- else outlet_list(u->u_outlet, &s_list, argc, argv);
- }
-}
-
-static void trigger_anything(t_trigger *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_triggerout *u;
- int i;
- for (i = x->x_n, u = x->x_vec + i; u--, i--;)
- {
- if (u->u_type == TR_BANG)
- outlet_bang(u->u_outlet);
- else if (u->u_type == TR_ANYTHING)
- outlet_anything(u->u_outlet, s, argc, argv);
- else pd_error(x, "trigger: can only convert 's' to 'b' or 'a'",
- s->s_name);
- }
-}
-
-static void trigger_bang(t_trigger *x)
-{
- trigger_list(x, 0, 0, 0);
-}
-
-static void trigger_pointer(t_trigger *x, t_gpointer *gp)
-{
- t_atom at;
- SETPOINTER(&at, gp);
- trigger_list(x, 0, 1, &at);
-}
-
-static void trigger_float(t_trigger *x, t_float f)
-{
- t_atom at;
- SETFLOAT(&at, f);
- trigger_list(x, 0, 1, &at);
-}
-
-static void trigger_symbol(t_trigger *x, t_symbol *s)
-{
- t_atom at;
- SETSYMBOL(&at, s);
- trigger_list(x, 0, 1, &at);
-}
-
-static void trigger_free(t_trigger *x)
-{
- freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec));
-}
-
-static void trigger_setup(void)
-{
- trigger_class = class_new(gensym("trigger"), (t_newmethod)trigger_new,
- (t_method)trigger_free, sizeof(t_trigger), 0, A_GIMME, 0);
- class_addcreator((t_newmethod)trigger_new, gensym("t"), A_GIMME, 0);
- class_addlist(trigger_class, trigger_list);
- class_addbang(trigger_class, trigger_bang);
- class_addpointer(trigger_class, trigger_pointer);
- class_addfloat(trigger_class, (t_method)trigger_float);
- class_addsymbol(trigger_class, trigger_symbol);
- class_addanything(trigger_class, trigger_anything);
-}
-
-/* -------------------------- spigot ------------------------------ */
-static t_class *spigot_class;
-
-typedef struct _spigot
-{
- t_object x_obj;
- float x_state;
-} t_spigot;
-
-static void *spigot_new(void)
-{
- t_spigot *x = (t_spigot *)pd_new(spigot_class);
- floatinlet_new(&x->x_obj, &x->x_state);
- outlet_new(&x->x_obj, 0);
- x->x_state = 0;
- return (x);
-}
-
-static void spigot_bang(t_spigot *x)
-{
- if (x->x_state != 0) outlet_bang(x->x_obj.ob_outlet);
-}
-
-static void spigot_pointer(t_spigot *x, t_gpointer *gp)
-{
- if (x->x_state != 0) outlet_pointer(x->x_obj.ob_outlet, gp);
-}
-
-static void spigot_float(t_spigot *x, t_float f)
-{
- if (x->x_state != 0) outlet_float(x->x_obj.ob_outlet, f);
-}
-
-static void spigot_symbol(t_spigot *x, t_symbol *s)
-{
- if (x->x_state != 0) outlet_symbol(x->x_obj.ob_outlet, s);
-}
-
-static void spigot_list(t_spigot *x, t_symbol *s, int argc, t_atom *argv)
-{
- if (x->x_state != 0) outlet_list(x->x_obj.ob_outlet, s, argc, argv);
-}
-
-static void spigot_anything(t_spigot *x, t_symbol *s, int argc, t_atom *argv)
-{
- if (x->x_state != 0) outlet_anything(x->x_obj.ob_outlet, s, argc, argv);
-}
-
-static void spigot_setup(void)
-{
- spigot_class = class_new(gensym("spigot"), (t_newmethod)spigot_new, 0,
- sizeof(t_spigot), 0, A_DEFSYM, 0);
- class_addbang(spigot_class, spigot_bang);
- class_addpointer(spigot_class, spigot_pointer);
- class_addfloat(spigot_class, spigot_float);
- class_addsymbol(spigot_class, spigot_symbol);
- class_addlist(spigot_class, spigot_list);
- class_addanything(spigot_class, spigot_anything);
-}
-
-/* --------------------------- moses ----------------------------- */
-static t_class *moses_class;
-
-typedef struct _moses
-{
- t_object x_ob;
- t_outlet *x_out2;
- float x_y;
-} t_moses;
-
-static void *moses_new(t_floatarg f)
-{
- t_moses *x = (t_moses *)pd_new(moses_class);
- floatinlet_new(&x->x_ob, &x->x_y);
- outlet_new(&x->x_ob, &s_float);
- x->x_out2 = outlet_new(&x->x_ob, &s_float);
- x->x_y = f;
- return (x);
-}
-
-static void moses_float(t_moses *x, t_float f)
-{
- if (f < x->x_y) outlet_float(x->x_ob.ob_outlet, f);
- else outlet_float(x->x_out2, f);
-}
-
-static void moses_setup(void)
-{
- moses_class = class_new(gensym("moses"), (t_newmethod)moses_new, 0,
- sizeof(t_moses), 0, A_DEFFLOAT, 0);
- class_addfloat(moses_class, moses_float);
-}
-
-/* ----------------------- until --------------------- */
-
-static t_class *until_class;
-
-typedef struct _until
-{
- t_object x_obj;
- int x_run;
- int x_count;
-} t_until;
-
-static void *until_new(void)
-{
- t_until *x = (t_until *)pd_new(until_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("bang"), gensym("bang2"));
- outlet_new(&x->x_obj, &s_bang);
- x->x_run = 0;
- return (x);
-}
-
-static void until_bang(t_until *x)
-{
- x->x_run = 1;
- x->x_count = -1;
- while (x->x_run && x->x_count)
- x->x_count--, outlet_bang(x->x_obj.ob_outlet);
-}
-
-static void until_float(t_until *x, t_float f)
-{
- x->x_run = 1;
- x->x_count = f;
- while (x->x_run && x->x_count)
- x->x_count--, outlet_bang(x->x_obj.ob_outlet);
-}
-
-static void until_bang2(t_until *x)
-{
- x->x_run = 0;
-}
-
-static void until_setup(void)
-{
- until_class = class_new(gensym("until"), (t_newmethod)until_new, 0,
- sizeof(t_until), 0, 0);
- class_addbang(until_class, until_bang);
- class_addfloat(until_class, until_float);
- class_addmethod(until_class, (t_method)until_bang2, gensym("bang2"), 0);
-}
-
-/* ----------------------- makefilename --------------------- */
-
-static t_class *makefilename_class;
-
-typedef struct _makefilename
-{
- t_object x_obj;
- t_symbol *x_format;
-} t_makefilename;
-
-static void *makefilename_new(t_symbol *s)
-{
- t_makefilename *x = (t_makefilename *)pd_new(makefilename_class);
- if (!s->s_name) s = gensym("file.%d");
- outlet_new(&x->x_obj, &s_symbol);
- x->x_format = s;
- return (x);
-}
-
-static void makefilename_float(t_makefilename *x, t_floatarg f)
-{
- char buf[MAXPDSTRING];
- sprintf(buf, x->x_format->s_name, (int)f);
- outlet_symbol(x->x_obj.ob_outlet, gensym(buf));
-}
-
-static void makefilename_symbol(t_makefilename *x, t_symbol *s)
-{
- char buf[MAXPDSTRING];
- sprintf(buf, x->x_format->s_name, s->s_name);
- outlet_symbol(x->x_obj.ob_outlet, gensym(buf));
-}
-
-static void makefilename_setup(void)
-{
- makefilename_class = class_new(gensym("makefilename"),
- (t_newmethod)makefilename_new, 0,
- sizeof(t_makefilename), 0, A_DEFSYM, 0);
- class_addfloat(makefilename_class, makefilename_float);
- class_addsymbol(makefilename_class, makefilename_symbol);
-}
-
-/* -------------------------- swap ------------------------------ */
-static t_class *swap_class;
-
-typedef struct _swap
-{
- t_object x_obj;
- t_outlet *x_out2;
- t_float x_f1;
- t_float x_f2;
-} t_swap;
-
-static void *swap_new(t_floatarg f)
-{
- t_swap *x = (t_swap *)pd_new(swap_class);
- x->x_f2 = f;
- x->x_f1 = 0;
- outlet_new(&x->x_obj, &s_float);
- x->x_out2 = outlet_new(&x->x_obj, &s_float);
- floatinlet_new(&x->x_obj, &x->x_f2);
- return (x);
-}
-
-static void swap_bang(t_swap *x)
-{
- outlet_float(x->x_out2, x->x_f1);
- outlet_float(x->x_obj.ob_outlet, x->x_f2);
-}
-
-static void swap_float(t_swap *x, t_float f)
-{
- x->x_f1 = f;
- swap_bang(x);
-}
-
-void swap_setup(void)
-{
- swap_class = class_new(gensym("swap"), (t_newmethod)swap_new, 0,
- sizeof(t_swap), 0, A_DEFFLOAT, 0);
- class_addcreator((t_newmethod)swap_new, gensym("fswap"), A_DEFFLOAT, 0);
- class_addbang(swap_class, swap_bang);
- class_addfloat(swap_class, swap_float);
-}
-
-/* -------------------------- change ------------------------------ */
-static t_class *change_class;
-
-typedef struct _change
-{
- t_object x_obj;
- t_float x_f;
-} t_change;
-
-static void *change_new(t_floatarg f)
-{
- t_change *x = (t_change *)pd_new(change_class);
- x->x_f = f;
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-static void change_bang(t_change *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_f);
-}
-
-static void change_float(t_change *x, t_float f)
-{
- if (f != x->x_f)
- {
- x->x_f = f;
- outlet_float(x->x_obj.ob_outlet, x->x_f);
- }
-}
-
-static void change_set(t_change *x, t_float f)
-{
- x->x_f = f;
-}
-
-void change_setup(void)
-{
- change_class = class_new(gensym("change"), (t_newmethod)change_new, 0,
- sizeof(t_change), 0, A_DEFFLOAT, 0);
- class_addbang(change_class, change_bang);
- class_addfloat(change_class, change_float);
- class_addmethod(change_class, (t_method)change_set, gensym("set"),
- A_DEFFLOAT, 0);
-}
-
-/* -------------------- value ------------------------------ */
-
-static t_class *value_class, *vcommon_class;
-
-typedef struct vcommon
-{
- t_pd c_pd;
- int c_refcount;
- t_float c_f;
-} t_vcommon;
-
-typedef struct _value
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_float *x_floatstar;
-} t_value;
-
- /* get a pointer to a named floating-point variable. The variable
- belongs to a "vcommon" object, which is created if necessary. */
-t_float *value_get(t_symbol *s)
-{
- t_vcommon *c = (t_vcommon *)pd_findbyclass(s, vcommon_class);
- if (!c)
- {
- c = (t_vcommon *)pd_new(vcommon_class);
- c->c_f = 0;
- c->c_refcount = 0;
- pd_bind(&c->c_pd, s);
- }
- c->c_refcount++;
- return (&c->c_f);
-}
-
- /* release a variable. This only frees the "vcommon" resource when the
- last interested party releases it. */
-void value_release(t_symbol *s)
-{
- t_vcommon *c = (t_vcommon *)pd_findbyclass(s, vcommon_class);
- if (c)
- {
- if (!--c->c_refcount)
- {
- pd_unbind(&c->c_pd, s);
- pd_free(&c->c_pd);
- }
- }
- else bug("value_release");
-}
-
-/*
- * value_getfloat -- obtain the float value of a "value" object
- * return 0 on success, 1 otherwise
- */
-int
-value_getfloat(t_symbol *s, t_float *f)
-{
- t_vcommon *c = (t_vcommon *)pd_findbyclass(s, vcommon_class);
- if (!c)
- return (1);
- *f = c->c_f;
- return (0);
-}
-
-/*
- * value_setfloat -- set the float value of a "value" object
- * return 0 on success, 1 otherwise
- */
-int
-value_setfloat(t_symbol *s, t_float f)
-{
- t_vcommon *c = (t_vcommon *)pd_findbyclass(s, vcommon_class);
- if (!c)
- return (1);
- c->c_f = f;
- return (0);
-}
-
-static void *value_new(t_symbol *s)
-{
- t_value *x = (t_value *)pd_new(value_class);
- x->x_sym = s;
- x->x_floatstar = value_get(s);
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-static void value_bang(t_value *x)
-{
- outlet_float(x->x_obj.ob_outlet, *x->x_floatstar);
-}
-
-static void value_float(t_value *x, t_float f)
-{
- *x->x_floatstar = f;
-}
-
-static void value_ff(t_value *x)
-{
- value_release(x->x_sym);
-}
-
-static void value_setup(void)
-{
- value_class = class_new(gensym("value"), (t_newmethod)value_new,
- (t_method)value_ff,
- sizeof(t_value), 0, A_DEFSYM, 0);
- class_addcreator((t_newmethod)value_new, gensym("v"), A_DEFSYM, 0);
- class_addbang(value_class, value_bang);
- class_addfloat(value_class, value_float);
- vcommon_class = class_new(gensym("value"), 0, 0,
- sizeof(t_vcommon), CLASS_PD, 0);
-}
-
-/* -------------- overall setup routine for this file ----------------- */
-
-void x_connective_setup(void)
-{
- pdint_setup();
- pdfloat_setup();
- pdsymbol_setup();
- bang_setup();
- send_setup();
- receive_setup();
- select_setup();
- route_setup();
- pack_setup();
- unpack_setup();
- trigger_setup();
- spigot_setup();
- moses_setup();
- until_setup();
- makefilename_setup();
- swap_setup();
- change_setup();
- value_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/x_gui.c b/apps/plugins/pdbox/PDa/src/x_gui.c
index edff70e8cd..c54fef948d 100644
--- a/apps/plugins/pdbox/PDa/src/x_gui.c
+++ b/apps/plugins/pdbox/PDa/src/x_gui.c
@@ -375,380 +375,4 @@ void x_gui_setup(void)
savepanel_setup();
key_setup();
}
-/* Copyright (c) 1997-2000 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* dialogs. LATER, deal with the situation where the object goes
-away before the panel does... */
-
-#include "m_pd.h"
-#include <stdio.h>
-#include <string.h>
-#ifdef UNIX
-#include <unistd.h>
-#endif
-
-/* --------------------- graphics responder ---------------- */
-
-/* make one of these if you want to put up a dialog window but want to be
-protected from getting deleted and then having the dialog call you back. In
-this design the calling object doesn't have to keep the address of the dialog
-window around; instead we keep a list of all open dialogs. Any object that
-might have dialogs, when it is deleted, simply checks down the dialog window
-list and breaks off any dialogs that might later have sent messages to it.
-Only when the dialog window itself closes do we delete the gfxstub object. */
-
-static t_class *gfxstub_class;
-
-typedef struct _gfxstub
-{
- t_pd x_pd;
- t_pd *x_owner;
- void *x_key;
- t_symbol *x_sym;
- struct _gfxstub *x_next;
-} t_gfxstub;
-
-static t_gfxstub *gfxstub_list;
-
- /* create a new one. the "key" is an address by which the owner
- will identify it later; if the owner only wants one dialog, this
- could just be a pointer to the owner itself. The string "cmd"
- is a TK command to create the dialog, with "%s" embedded in
- it so we can provide a name by which the GUI can send us back
- messages; e.g., "pdtk_canvas_dofont %s 10". */
-
-void gfxstub_new(t_pd *owner, void *key, const char *cmd)
-{
- char buf[MAXPDSTRING];
- char namebuf[80];
- t_gfxstub *x;
- t_symbol *s;
- /* if any exists with matching key, no need to make a
- new one; just tell tk to send it front. */
- for (x = gfxstub_list; x; x = x->x_next)
- {
- if (x->x_key == key)
- {
- sys_vgui("raise .gfxstub%x\n", x);
- sys_vgui("focus .gfxstub%x\n", x);
- return;
- }
- }
- if (strlen(cmd) + 84 > MAXPDSTRING)
- return;
- x = (t_gfxstub *)pd_new(gfxstub_class);
- sprintf(namebuf, ".gfxstub%x", (t_int)x);
-
- s = gensym(namebuf);
- pd_bind(&x->x_pd, s);
- x->x_owner = owner;
- x->x_sym = s;
- x->x_key = key;
- x->x_next = gfxstub_list;
- gfxstub_list = x;
- sprintf(buf, cmd, s->s_name);
- sys_gui(buf);
-}
-
-static void gfxstub_offlist(t_gfxstub *x)
-{
- t_gfxstub *y1, *y2;
- if (gfxstub_list == x)
- gfxstub_list = x->x_next;
- else for (y1 = gfxstub_list; y2 = y1->x_next; y1 = y2)
- if (y2 == x)
- {
- y1->x_next = y2->x_next;
- break;
- }
-}
-
- /* if the owner disappears, we still may have to stay around until our
- dialog window signs off. Anyway we can now tell the GUI to destroy the
- window. */
-void gfxstub_deleteforkey(void *key)
-{
- t_gfxstub *y;
- int didit = 1;
- while (didit)
- {
- didit = 0;
- for (y = gfxstub_list; y; y = y->x_next)
- {
- if (y->x_key == key)
- {
- sys_vgui("destroy .gfxstub%x\n", y);
- y->x_owner = 0;
- gfxstub_offlist(y);
- didit = 1;
- break;
- }
- }
- }
-}
-
-/* --------- pd messages for gfxstub (these come from the GUI) ---------- */
-
- /* "cancel" to request that we close the dialog window. */
-static void gfxstub_cancel(t_gfxstub *x)
-{
- gfxstub_deleteforkey(x->x_key);
-}
-
- /* "signoff" comes from the GUI to say the dialog window closed. */
-static void gfxstub_signoff(t_gfxstub *x)
-{
- gfxstub_offlist(x);
- pd_free(&x->x_pd);
-}
-
-static t_binbuf *gfxstub_binbuf;
-
- /* a series of "data" messages rebuilds a scalar */
-static void gfxstub_data(t_gfxstub *x, t_symbol *s, int argc, t_atom *argv)
-{
- if (!gfxstub_binbuf)
- gfxstub_binbuf = binbuf_new();
- binbuf_add(gfxstub_binbuf, argc, argv);
- binbuf_addsemi(gfxstub_binbuf);
-}
- /* the "end" message terminates rebuilding the scalar */
-static void gfxstub_end(t_gfxstub *x)
-{
- canvas_dataproperties((t_canvas *)x->x_owner,
- (t_scalar *)x->x_key, gfxstub_binbuf);
- binbuf_free(gfxstub_binbuf);
- gfxstub_binbuf = 0;
-}
-
- /* anything else is a message from the dialog window to the owner;
- just forward it. */
-static void gfxstub_anything(t_gfxstub *x, t_symbol *s, int argc, t_atom *argv)
-{
- if (x->x_owner)
- pd_typedmess(x->x_owner, s, argc, argv);
-}
-
-static void gfxstub_free(t_gfxstub *x)
-{
- pd_unbind(&x->x_pd, x->x_sym);
-}
-
-static void gfxstub_setup(void)
-{
- gfxstub_class = class_new(gensym("gfxstub"), (t_newmethod)gfxstub_new,
- (t_method)gfxstub_free,
- sizeof(t_gfxstub), CLASS_PD, 0);
- class_addanything(gfxstub_class, gfxstub_anything);
- class_addmethod(gfxstub_class, (t_method)gfxstub_signoff,
- gensym("signoff"), 0);
- class_addmethod(gfxstub_class, (t_method)gfxstub_data,
- gensym("data"), A_GIMME, 0);
- class_addmethod(gfxstub_class, (t_method)gfxstub_end,
- gensym("end"), 0);
- class_addmethod(gfxstub_class, (t_method)gfxstub_cancel,
- gensym("cancel"), 0);
-}
-
-/* -------------------------- openpanel ------------------------------ */
-
-static t_class *openpanel_class;
-
-typedef struct _openpanel
-{
- t_object x_obj;
- t_symbol *x_s;
-} t_openpanel;
-
-static void *openpanel_new(void)
-{
- char buf[50];
- t_openpanel *x = (t_openpanel *)pd_new(openpanel_class);
- sprintf(buf, "d%x", (t_int)x);
- x->x_s = gensym(buf);
- pd_bind(&x->x_obj.ob_pd, x->x_s);
- outlet_new(&x->x_obj, &s_symbol);
- return (x);
-}
-
-static void openpanel_bang(t_openpanel *x)
-{
- sys_vgui("pdtk_openpanel %s\n", x->x_s->s_name);
-}
-
-static void openpanel_symbol(t_openpanel *x, t_symbol *s)
-{
- outlet_symbol(x->x_obj.ob_outlet, s);
-}
-
-static void openpanel_free(t_openpanel *x)
-{
- pd_unbind(&x->x_obj.ob_pd, x->x_s);
-}
-
-static void openpanel_setup(void)
-{
- openpanel_class = class_new(gensym("openpanel"),
- (t_newmethod)openpanel_new, (t_method)openpanel_free,
- sizeof(t_openpanel), 0, A_DEFFLOAT, 0);
- class_addbang(openpanel_class, openpanel_bang);
- class_addsymbol(openpanel_class, openpanel_symbol);
-}
-
-/* -------------------------- savepanel ------------------------------ */
-
-static t_class *savepanel_class;
-
-typedef struct _savepanel
-{
- t_object x_obj;
- t_symbol *x_s;
-} t_savepanel;
-
-static void *savepanel_new(void)
-{
- char buf[50];
- t_savepanel *x = (t_savepanel *)pd_new(savepanel_class);
- sprintf(buf, "d%x", (t_int)x);
- x->x_s = gensym(buf);
- pd_bind(&x->x_obj.ob_pd, x->x_s);
- outlet_new(&x->x_obj, &s_symbol);
- return (x);
-}
-
-static void savepanel_bang(t_savepanel *x)
-{
- sys_vgui("pdtk_savepanel %s\n", x->x_s->s_name);
-}
-
-static void savepanel_symbol(t_savepanel *x, t_symbol *s)
-{
- outlet_symbol(x->x_obj.ob_outlet, s);
-}
-
-static void savepanel_free(t_savepanel *x)
-{
- pd_unbind(&x->x_obj.ob_pd, x->x_s);
-}
-
-static void savepanel_setup(void)
-{
- savepanel_class = class_new(gensym("savepanel"),
- (t_newmethod)savepanel_new, (t_method)savepanel_free,
- sizeof(t_savepanel), 0, A_DEFFLOAT, 0);
- class_addbang(savepanel_class, savepanel_bang);
- class_addsymbol(savepanel_class, savepanel_symbol);
-}
-
-/* ---------------------- key and its relatives ------------------ */
-
-static t_symbol *key_sym, *keyup_sym, *keyname_sym;
-static t_class *key_class, *keyup_class, *keyname_class;
-
-typedef struct _key
-{
- t_object x_obj;
-} t_key;
-
-static void *key_new( void)
-{
- t_key *x = (t_key *)pd_new(key_class);
- outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, key_sym);
- return (x);
-}
-
-static void key_float(t_key *x, t_floatarg f)
-{
- outlet_float(x->x_obj.ob_outlet, f);
-}
-
-static void key_free(t_key *x)
-{
- pd_unbind(&x->x_obj.ob_pd, key_sym);
-}
-
-typedef struct _keyup
-{
- t_object x_obj;
-} t_keyup;
-
-static void *keyup_new( void)
-{
- t_keyup *x = (t_keyup *)pd_new(keyup_class);
- outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, keyup_sym);
- return (x);
-}
-
-static void keyup_float(t_keyup *x, t_floatarg f)
-{
- outlet_float(x->x_obj.ob_outlet, f);
-}
-
-static void keyup_free(t_keyup *x)
-{
- pd_unbind(&x->x_obj.ob_pd, keyup_sym);
-}
-
-typedef struct _keyname
-{
- t_object x_obj;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
-} t_keyname;
-
-static void *keyname_new( void)
-{
- t_keyname *x = (t_keyname *)pd_new(keyname_class);
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_symbol);
- pd_bind(&x->x_obj.ob_pd, keyname_sym);
- return (x);
-}
-
-static void keyname_list(t_keyname *x, t_symbol *s, int ac, t_atom *av)
-{
- outlet_symbol(x->x_outlet2, atom_getsymbolarg(1, ac, av));
- outlet_float(x->x_outlet1, atom_getfloatarg(0, ac, av));
-}
-
-static void keyname_free(t_keyname *x)
-{
- pd_unbind(&x->x_obj.ob_pd, keyname_sym);
-}
-
-static void key_setup(void)
-{
- key_class = class_new(gensym("key"),
- (t_newmethod)key_new, (t_method)key_free,
- sizeof(t_key), CLASS_NOINLET, 0);
- class_addfloat(key_class, key_float);
- key_sym = gensym("#key");
- keyup_class = class_new(gensym("keyup"),
- (t_newmethod)keyup_new, (t_method)keyup_free,
- sizeof(t_keyup), CLASS_NOINLET, 0);
- class_addfloat(keyup_class, keyup_float);
- keyup_sym = gensym("#keyup");
- class_sethelpsymbol(keyup_class, gensym("key"));
-
- keyname_class = class_new(gensym("keyname"),
- (t_newmethod)keyname_new, (t_method)keyname_free,
- sizeof(t_keyname), CLASS_NOINLET, 0);
- class_addlist(keyname_class, keyname_list);
- keyname_sym = gensym("#keyname");
- class_sethelpsymbol(keyname_class, gensym("key"));
-}
-
-/* -------------------------- setup routine ------------------------------ */
-
-void x_gui_setup(void)
-{
- gfxstub_setup();
- openpanel_setup();
- savepanel_setup();
- key_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/x_interface.c b/apps/plugins/pdbox/PDa/src/x_interface.c
index f6ab350a91..227ca0f4fd 100644
--- a/apps/plugins/pdbox/PDa/src/x_interface.c
+++ b/apps/plugins/pdbox/PDa/src/x_interface.c
@@ -76,81 +76,4 @@ void x_interface_setup(void)
{
print_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* interface objects */
-
-#include "m_pd.h"
-
-/* -------------------------- print ------------------------------ */
-static t_class *print_class;
-
-typedef struct _print
-{
- t_object x_obj;
- t_symbol *x_sym;
-} t_print;
-
-static void *print_new(t_symbol *s)
-{
- t_print *x = (t_print *)pd_new(print_class);
- if (*s->s_name) x->x_sym = s;
- else x->x_sym = gensym("");
- return (x);
-}
-
-static void print_bang(t_print *x)
-{
- post("%sbang", x->x_sym->s_name);
-}
-
-static void print_pointer(t_print *x, t_gpointer *gp)
-{
- post("%s(gpointer)", x->x_sym->s_name);
-}
-
-static void print_float(t_print *x, t_float f)
-{
- post("%s%g", x->x_sym->s_name, f);
-}
-static void print_list(t_print *x, t_symbol *s, int argc, t_atom *argv)
-{
- int i;
- char buf[80];
- if (argc && argv->a_type != A_SYMBOL) startpost("%s:", x->x_sym->s_name);
- else startpost("%s%s", x->x_sym->s_name,
- (argc > 1 ? s_list.s_name : (argc == 1 ? s_symbol.s_name :
- s_bang.s_name)));
- postatom(argc, argv);
- endpost();
-}
-
-static void print_anything(t_print *x, t_symbol *s, int argc, t_atom *argv)
-{
- int i;
- char buf[80];
- startpost("%s%s", x->x_sym->s_name, s->s_name);
- postatom(argc, argv);
- endpost();
-}
-
-static void print_setup(void)
-{
- print_class = class_new(gensym("print"), (t_newmethod)print_new, 0,
- sizeof(t_print), 0, A_DEFSYM, 0);
- class_addbang(print_class, print_bang);
- class_addfloat(print_class, print_float);
- class_addpointer(print_class, print_pointer);
- class_addlist(print_class, print_list);
- class_addanything(print_class, print_anything);
-}
-
-
-
-void x_interface_setup(void)
-{
- print_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/x_midi.c b/apps/plugins/pdbox/PDa/src/x_midi.c
index a71000f121..e9f3601057 100644
--- a/apps/plugins/pdbox/PDa/src/x_midi.c
+++ b/apps/plugins/pdbox/PDa/src/x_midi.c
@@ -1311,1316 +1311,4 @@ void x_midi_setup(void)
poly_setup();
bag_setup();
}
-/* Copyright (c) 1997-2001 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* MIDI. */
-
-#include "m_pd.h"
-void outmidi_noteon(int portno, int channel, int pitch, int velo);
-void outmidi_controlchange(int portno, int channel, int ctlno, int value);
-void outmidi_programchange(int portno, int channel, int value);
-void outmidi_pitchbend(int portno, int channel, int value);
-void outmidi_aftertouch(int portno, int channel, int value);
-void outmidi_polyaftertouch(int portno, int channel, int pitch, int value);
-void outmidi_mclk(int portno);
-
-/* ----------------------- midiin and sysexin ------------------------- */
-
-static t_symbol *midiin_sym, *sysexin_sym;
-
-static t_class *midiin_class, *sysexin_class;
-
-typedef struct _midiin
-{
- t_object x_obj;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
-} t_midiin;
-
-static void *midiin_new( void)
-{
- t_midiin *x = (t_midiin *)pd_new(midiin_class);
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, midiin_sym);
-#ifndef __linux__
- pd_error(x, "midiin: works under Linux only");
-#endif
- return (x);
-}
-
-static void midiin_list(t_midiin *x, t_symbol *s, int ac, t_atom *av)
-{
- outlet_float(x->x_outlet2, atom_getfloatarg(1, ac, av) + 1);
- outlet_float(x->x_outlet1, atom_getfloatarg(0, ac, av));
-}
-
-static void midiin_free(t_midiin *x)
-{
- pd_unbind(&x->x_obj.ob_pd, midiin_sym);
-}
-
-static void *sysexin_new( void)
-{
- t_midiin *x = (t_midiin *)pd_new(sysexin_class);
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, sysexin_sym);
-#ifndef __linux__
- pd_error(x, "sysexin: works under Linux only");
-#endif
- return (x);
-}
-
-static void sysexin_free(t_midiin *x)
-{
- pd_unbind(&x->x_obj.ob_pd, sysexin_sym);
-}
-
-static void midiin_setup(void)
-{
- midiin_class = class_new(gensym("midiin"), (t_newmethod)midiin_new,
- (t_method)midiin_free, sizeof(t_midiin),
- CLASS_NOINLET, A_DEFFLOAT, 0);
- class_addlist(midiin_class, midiin_list);
- class_sethelpsymbol(midiin_class, gensym("midi"));
- midiin_sym = gensym("#midiin");
-
- sysexin_class = class_new(gensym("sysexin"), (t_newmethod)sysexin_new,
- (t_method)sysexin_free, sizeof(t_midiin),
- CLASS_NOINLET, A_DEFFLOAT, 0);
- class_addlist(sysexin_class, midiin_list);
- class_sethelpsymbol(sysexin_class, gensym("midi"));
- sysexin_sym = gensym("#sysexin");
-}
-
-void inmidi_byte(int portno, int byte)
-{
- t_atom at[2];
- if (midiin_sym->s_thing)
- {
- SETFLOAT(at, byte);
- SETFLOAT(at+1, portno + 1);
- pd_list(midiin_sym->s_thing, 0, 2, at);
- }
-}
-
-void inmidi_sysex(int portno, int byte)
-{
- t_atom at[2];
- if (sysexin_sym->s_thing)
- {
- SETFLOAT(at, byte);
- SETFLOAT(at+1, portno + 1);
- pd_list(sysexin_sym->s_thing, 0, 2, at);
- }
-}
-
-/* ----------------------- notein ------------------------- */
-
-static t_symbol *notein_sym;
-
-static t_class *notein_class;
-
-typedef struct _notein
-{
- t_object x_obj;
- t_float x_channel;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
- t_outlet *x_outlet3;
-} t_notein;
-
-static void *notein_new(t_floatarg f)
-{
- t_notein *x = (t_notein *)pd_new(notein_class);
- x->x_channel = f;
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- if (f == 0) x->x_outlet3 = outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, notein_sym);
- return (x);
-}
-
-static void notein_list(t_notein *x, t_symbol *s, int argc, t_atom *argv)
-{
- float pitch = atom_getfloatarg(0, argc, argv);
- float velo = atom_getfloatarg(1, argc, argv);
- float channel = atom_getfloatarg(2, argc, argv);
- if (x->x_channel != 0)
- {
- if (channel != x->x_channel) return;
- outlet_float(x->x_outlet2, velo);
- outlet_float(x->x_outlet1, pitch);
- }
- else
- {
- outlet_float(x->x_outlet3, channel);
- outlet_float(x->x_outlet2, velo);
- outlet_float(x->x_outlet1, pitch);
- }
-}
-
-static void notein_free(t_notein *x)
-{
- pd_unbind(&x->x_obj.ob_pd, notein_sym);
-}
-
-static void notein_setup(void)
-{
- notein_class = class_new(gensym("notein"), (t_newmethod)notein_new,
- (t_method)notein_free, sizeof(t_notein), CLASS_NOINLET, A_DEFFLOAT, 0);
- class_addlist(notein_class, notein_list);
- class_sethelpsymbol(notein_class, gensym("midi"));
- notein_sym = gensym("#notein");
-}
-
-void inmidi_noteon(int portno, int channel, int pitch, int velo)
-{
- if (notein_sym->s_thing)
- {
- t_atom at[3];
- SETFLOAT(at, pitch);
- SETFLOAT(at+1, velo);
- SETFLOAT(at+2, (channel + (portno << 4) + 1));
- pd_list(notein_sym->s_thing, &s_list, 3, at);
- }
-}
-
-/* ----------------------- ctlin ------------------------- */
-
-static t_symbol *ctlin_sym;
-
-static t_class *ctlin_class;
-
-typedef struct _ctlin
-{
- t_object x_obj;
- t_float x_channel;
- t_float x_ctlno;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
- t_outlet *x_outlet3;
-} t_ctlin;
-
-static void *ctlin_new(t_symbol *s, int argc, t_atom *argv)
-{
- int ctlno, channel;
- t_ctlin *x = (t_ctlin *)pd_new(ctlin_class);
- if (!argc) ctlno = -1;
- else ctlno = atom_getfloatarg(0, argc, argv);
- channel = atom_getfloatarg(1, argc, argv);
- x->x_channel = channel;
- x->x_ctlno = ctlno;
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- if (!channel)
- {
- if (x->x_ctlno < 0) x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- x->x_outlet3 = outlet_new(&x->x_obj, &s_float);
- }
- pd_bind(&x->x_obj.ob_pd, ctlin_sym);
- return (x);
-}
-
-static void ctlin_list(t_ctlin *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_float ctlnumber = atom_getfloatarg(0, argc, argv);
- t_float value = atom_getfloatarg(1, argc, argv);
- t_float channel = atom_getfloatarg(2, argc, argv);
- if (x->x_ctlno >= 0 && x->x_ctlno != ctlnumber) return;
- if (x->x_channel > 0 && x->x_channel != channel) return;
- if (x->x_channel == 0) outlet_float(x->x_outlet3, channel);
- if (x->x_ctlno < 0) outlet_float(x->x_outlet2, ctlnumber);
- outlet_float(x->x_outlet1, value);
-}
-
-static void ctlin_free(t_ctlin *x)
-{
- pd_unbind(&x->x_obj.ob_pd, ctlin_sym);
-}
-
-static void ctlin_setup(void)
-{
- ctlin_class = class_new(gensym("ctlin"), (t_newmethod)ctlin_new,
- (t_method)ctlin_free, sizeof(t_ctlin),
- CLASS_NOINLET, A_GIMME, 0);
- class_addlist(ctlin_class, ctlin_list);
- class_sethelpsymbol(ctlin_class, gensym("midi"));
- ctlin_sym = gensym("#ctlin");
-}
-
-void inmidi_controlchange(int portno, int channel, int ctlnumber, int value)
-{
- if (ctlin_sym->s_thing)
- {
- t_atom at[3];
- SETFLOAT(at, ctlnumber);
- SETFLOAT(at+1, value);
- SETFLOAT(at+2, (channel + (portno << 4) + 1));
- pd_list(ctlin_sym->s_thing, &s_list, 3, at);
- }
-}
-
-/* ----------------------- pgmin ------------------------- */
-
-static t_symbol *pgmin_sym;
-
-static t_class *pgmin_class;
-
-typedef struct _pgmin
-{
- t_object x_obj;
- t_float x_channel;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
-} t_pgmin;
-
-static void *pgmin_new(t_floatarg f)
-{
- t_pgmin *x = (t_pgmin *)pd_new(pgmin_class);
- x->x_channel = f;
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- if (f == 0) x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, pgmin_sym);
- return (x);
-}
-
-static void pgmin_list(t_pgmin *x, t_symbol *s, int argc, t_atom *argv)
-{
- float value = atom_getfloatarg(0, argc, argv);
- float channel = atom_getfloatarg(1, argc, argv);
- if (x->x_channel != 0)
- {
- if (channel != x->x_channel) return;
- outlet_float(x->x_outlet1, value);
- }
- else
- {
- outlet_float(x->x_outlet2, channel);
- outlet_float(x->x_outlet1, value);
- }
-}
-
-static void pgmin_free(t_pgmin *x)
-{
- pd_unbind(&x->x_obj.ob_pd, pgmin_sym);
-}
-
-static void pgmin_setup(void)
-{
- pgmin_class = class_new(gensym("pgmin"), (t_newmethod)pgmin_new,
- (t_method)pgmin_free, sizeof(t_pgmin),
- CLASS_NOINLET, A_DEFFLOAT, 0);
- class_addlist(pgmin_class, pgmin_list);
- class_sethelpsymbol(pgmin_class, gensym("midi"));
- pgmin_sym = gensym("#pgmin");
-}
-
-void inmidi_programchange(int portno, int channel, int value)
-{
- if (pgmin_sym->s_thing)
- {
- t_atom at[2];
- SETFLOAT(at, value + 1);
- SETFLOAT(at+1, (channel + (portno << 4) + 1));
- pd_list(pgmin_sym->s_thing, &s_list, 2, at);
- }
-}
-
-/* ----------------------- bendin ------------------------- */
-
-static t_symbol *bendin_sym;
-
-static t_class *bendin_class;
-
-typedef struct _bendin
-{
- t_object x_obj;
- t_float x_channel;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
-} t_bendin;
-
-static void *bendin_new(t_floatarg f)
-{
- t_bendin *x = (t_bendin *)pd_new(bendin_class);
- x->x_channel = f;
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- if (f == 0) x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, bendin_sym);
- return (x);
-}
-
-static void bendin_list(t_bendin *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_float value = atom_getfloatarg(0, argc, argv);
- t_float channel = atom_getfloatarg(1, argc, argv);
- if (x->x_channel != 0)
- {
- if (channel != x->x_channel) return;
- outlet_float(x->x_outlet1, value);
- }
- else
- {
- outlet_float(x->x_outlet2, channel);
- outlet_float(x->x_outlet1, value);
- }
-}
-
-static void bendin_free(t_bendin *x)
-{
- pd_unbind(&x->x_obj.ob_pd, bendin_sym);
-}
-
-static void bendin_setup(void)
-{
- bendin_class = class_new(gensym("bendin"), (t_newmethod)bendin_new,
- (t_method)bendin_free, sizeof(t_bendin), CLASS_NOINLET, A_DEFFLOAT, 0);
- class_addlist(bendin_class, bendin_list);
- class_sethelpsymbol(bendin_class, gensym("midi"));
- bendin_sym = gensym("#bendin");
-}
-
-void inmidi_pitchbend(int portno, int channel, int value)
-{
- if (bendin_sym->s_thing)
- {
- t_atom at[2];
- SETFLOAT(at, value);
- SETFLOAT(at+1, (channel + (portno << 4) + 1));
- pd_list(bendin_sym->s_thing, &s_list, 2, at);
- }
-}
-
-/* ----------------------- touchin ------------------------- */
-
-static t_symbol *touchin_sym;
-
-static t_class *touchin_class;
-
-typedef struct _touchin
-{
- t_object x_obj;
- t_float x_channel;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
-} t_touchin;
-
-static void *touchin_new(t_floatarg f)
-{
- t_touchin *x = (t_touchin *)pd_new(touchin_class);
- x->x_channel = f;
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- if (f == 0) x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, touchin_sym);
- return (x);
-}
-
-static void touchin_list(t_touchin *x, t_symbol *s, int argc, t_atom *argv)
-{
- t_float value = atom_getfloatarg(0, argc, argv);
- t_float channel = atom_getfloatarg(1, argc, argv);
- if (x->x_channel)
- {
- if (channel != x->x_channel) return;
- outlet_float(x->x_outlet1, value);
- }
- else
- {
- outlet_float(x->x_outlet2, channel);
- outlet_float(x->x_outlet1, value);
- }
-}
-
-static void touchin_free(t_touchin *x)
-{
- pd_unbind(&x->x_obj.ob_pd, touchin_sym);
-}
-
-static void touchin_setup(void)
-{
- touchin_class = class_new(gensym("touchin"), (t_newmethod)touchin_new,
- (t_method)touchin_free, sizeof(t_touchin),
- CLASS_NOINLET, A_DEFFLOAT, 0);
- class_addlist(touchin_class, touchin_list);
- class_sethelpsymbol(touchin_class, gensym("midi"));
- touchin_sym = gensym("#touchin");
-}
-
-void inmidi_aftertouch(int portno, int channel, int value)
-{
- if (touchin_sym->s_thing)
- {
- t_atom at[2];
- SETFLOAT(at, value);
- SETFLOAT(at+1, (channel + (portno << 4) + 1));
- pd_list(touchin_sym->s_thing, &s_list, 2, at);
- }
-}
-
-/* ----------------------- polytouchin ------------------------- */
-
-static t_symbol *polytouchin_sym;
-
-static t_class *polytouchin_class;
-
-typedef struct _polytouchin
-{
- t_object x_obj;
- t_float x_channel;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
- t_outlet *x_outlet3;
-} t_polytouchin;
-
-static void *polytouchin_new(t_floatarg f)
-{
- t_polytouchin *x = (t_polytouchin *)pd_new(polytouchin_class);
- x->x_channel = f;
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- if (f == 0) x->x_outlet3 = outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, polytouchin_sym);
- return (x);
-}
-
-static void polytouchin_list(t_polytouchin *x, t_symbol *s, int argc,
- t_atom *argv)
-{
- t_float pitch = atom_getfloatarg(0, argc, argv);
- t_float value = atom_getfloatarg(1, argc, argv);
- t_float channel = atom_getfloatarg(2, argc, argv);
- if (x->x_channel != 0)
- {
- if (channel != x->x_channel) return;
- outlet_float(x->x_outlet2, pitch);
- outlet_float(x->x_outlet1, value);
- }
- else
- {
- outlet_float(x->x_outlet3, channel);
- outlet_float(x->x_outlet2, pitch);
- outlet_float(x->x_outlet1, value);
- }
-}
-
-static void polytouchin_free(t_polytouchin *x)
-{
- pd_unbind(&x->x_obj.ob_pd, polytouchin_sym);
-}
-
-static void polytouchin_setup(void)
-{
- polytouchin_class = class_new(gensym("polytouchin"),
- (t_newmethod)polytouchin_new, (t_method)polytouchin_free,
- sizeof(t_polytouchin), CLASS_NOINLET, A_DEFFLOAT, 0);
- class_addlist(polytouchin_class, polytouchin_list);
- class_sethelpsymbol(polytouchin_class, gensym("midi"));
- polytouchin_sym = gensym("#polytouchin");
-}
-
-void inmidi_polyaftertouch(int portno, int channel, int pitch, int value)
-{
- if (polytouchin_sym->s_thing)
- {
- t_atom at[3];
- SETFLOAT(at, pitch);
- SETFLOAT(at+1, value);
- SETFLOAT(at+2, (channel + (portno << 4) + 1));
- pd_list(polytouchin_sym->s_thing, &s_list, 3, at);
- }
-}
-
-/*----------------------- midiclkin--(midi F8 message )---------------------*/
-static t_symbol *midiclkin_sym;
-
-static t_class *midiclkin_class;
-
-
-typedef struct _midiclkin
-{
- t_object x_obj;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
-} t_midiclkin;
-
-static void *midiclkin_new(t_floatarg f)
-{
- t_midiclkin *x = (t_midiclkin *)pd_new(midiclkin_class);
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, midiclkin_sym);
- return (x);
-}
-
-static void midiclkin_list(t_midiclkin *x, t_symbol *s, int argc, t_atom *argv)
-{
- float value = atom_getfloatarg(0, argc, argv);
- float count = atom_getfloatarg(1, argc, argv);
- outlet_float(x->x_outlet2, count);
- outlet_float(x->x_outlet1, value);
-}
-
-static void midiclkin_free(t_midiclkin *x)
-{
- pd_unbind(&x->x_obj.ob_pd, midiclkin_sym);
-}
-
-static void midiclkin_setup(void)
-{
- midiclkin_class = class_new(gensym("midiclkin"),
- (t_newmethod)midiclkin_new, (t_method)midiclkin_free,
- sizeof(t_midiclkin), CLASS_NOINLET, A_DEFFLOAT, 0);
- class_addlist(midiclkin_class, midiclkin_list);
- class_sethelpsymbol(midiclkin_class, gensym("midi"));
- midiclkin_sym = gensym("#midiclkin");
-}
-
-void inmidi_clk(double timing)
-{
-
- static float prev = 0;
- static float count = 0;
- float cur,diff;
-
- if (midiclkin_sym->s_thing)
- {
- t_atom at[2];
- diff =timing - prev;
- count++;
-
- if (count == 3)
- { /* 24 count per quoter note */
- SETFLOAT(at, 1 );
- count = 0;
- }
- else SETFLOAT(at, 0);
-
- SETFLOAT(at+1, diff);
- pd_list(midiclkin_sym->s_thing, &s_list, 2, at);
- prev = timing;
- }
-}
-
-/*----------midirealtimein (midi FA,FB,FC,FF message )-----------------*/
-
-static t_symbol *midirealtimein_sym;
-
-static t_class *midirealtimein_class;
-
-typedef struct _midirealtimein
-{
- t_object x_obj;
- t_outlet *x_outlet1;
- t_outlet *x_outlet2;
-} t_midirealtimein;
-
-static void *midirealtimein_new( void)
-{
- t_midirealtimein *x = (t_midirealtimein *)pd_new(midirealtimein_class);
- x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
- x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
- pd_bind(&x->x_obj.ob_pd, midirealtimein_sym);
-#ifndef MSW
- pd_error(x, "midirealtimein: works under MSW only");
-#endif
- return (x);
-}
-
-static void midirealtimein_list(t_midirealtimein *x, t_symbol *s,
- int argc, t_atom *argv)
-{
- float portno = atom_getfloatarg(0, argc, argv);
- float byte = atom_getfloatarg(1, argc, argv);
-
- outlet_float(x->x_outlet2, portno);
- outlet_float(x->x_outlet1, byte);
-}
-
-static void midirealtimein_free(t_midirealtimein *x)
-{
- pd_unbind(&x->x_obj.ob_pd, midirealtimein_sym);
-}
-
-static void midirealtimein_setup(void)
-{
- midirealtimein_class = class_new(gensym("midirealtimein"),
- (t_newmethod)midirealtimein_new, (t_method)midirealtimein_free,
- sizeof(t_midirealtimein), CLASS_NOINLET, A_DEFFLOAT, 0);
- class_addlist(midirealtimein_class, midirealtimein_list);
- class_sethelpsymbol(midirealtimein_class, gensym("midi"));
- midirealtimein_sym = gensym("#midirealtimein");
-}
-
-void inmidi_realtimein(int portno, int SysMsg)
-{
- if (midirealtimein_sym->s_thing)
- {
- t_atom at[2];
- SETFLOAT(at, portno);
- SETFLOAT(at+1, SysMsg);
- pd_list(midirealtimein_sym->s_thing, &s_list, 1, at);
- }
-}
-
-/* -------------------------- midiout -------------------------- */
-
-static t_class *midiout_class;
-
-void sys_putmidibyte(int portno, int byte);
-
-typedef struct _midiout
-{
- t_object x_obj;
- t_float x_portno;
-} t_midiout;
-
-static void *midiout_new(t_floatarg portno)
-{
- t_midiout *x = (t_midiout *)pd_new(midiout_class);
- if (portno <= 0) portno = 1;
- x->x_portno = portno;
- floatinlet_new(&x->x_obj, &x->x_portno);
-#ifdef __irix__
- post("midiout: unimplemented in IRIX");
-#endif
- return (x);
-}
-
-static void midiout_float(t_midiout *x, t_floatarg f)
-{
- sys_putmidibyte(x->x_portno - 1, f);
-}
-
-static void midiout_setup(void)
-{
- midiout_class = class_new(gensym("midiout"), (t_newmethod)midiout_new, 0,
- sizeof(t_midiout), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addfloat(midiout_class, midiout_float);
- class_sethelpsymbol(midiout_class, gensym("midi"));
-}
-
-/* -------------------------- noteout -------------------------- */
-
-static t_class *noteout_class;
-
-typedef struct _noteout
-{
- t_object x_obj;
- t_float x_velo;
- t_float x_channel;
-} t_noteout;
-
-static void *noteout_new(t_floatarg channel)
-{
- t_noteout *x = (t_noteout *)pd_new(noteout_class);
- x->x_velo = 0;
- if (channel < 1) channel = 1;
- x->x_channel = channel;
- floatinlet_new(&x->x_obj, &x->x_velo);
- floatinlet_new(&x->x_obj, &x->x_channel);
- return (x);
-}
-
-static void noteout_float(t_noteout *x, t_float f)
-{
- int binchan = x->x_channel - 1;
- if (binchan < 0)
- binchan = 0;
- outmidi_noteon((binchan >> 4),
- (binchan & 15), (int)f, (int)x->x_velo);
-}
-
-static void noteout_setup(void)
-{
- noteout_class = class_new(gensym("noteout"), (t_newmethod)noteout_new, 0,
- sizeof(t_noteout), 0, A_DEFFLOAT, 0);
- class_addfloat(noteout_class, noteout_float);
- class_sethelpsymbol(noteout_class, gensym("midi"));
-}
-
-
-/* -------------------------- ctlout -------------------------- */
-
-static t_class *ctlout_class;
-
-typedef struct _ctlout
-{
- t_object x_obj;
- t_float x_ctl;
- t_float x_channel;
-} t_ctlout;
-
-static void *ctlout_new(t_floatarg ctl, t_floatarg channel)
-{
- t_ctlout *x = (t_ctlout *)pd_new(ctlout_class);
- x->x_ctl = ctl;
- if (channel <= 0) channel = 1;
- x->x_channel = channel;
- floatinlet_new(&x->x_obj, &x->x_ctl);
- floatinlet_new(&x->x_obj, &x->x_channel);
- return (x);
-}
-
-static void ctlout_float(t_ctlout *x, t_float f)
-{
- int binchan = x->x_channel - 1;
- if (binchan < 0)
- binchan = 0;
- outmidi_controlchange((binchan >> 4),
- (binchan & 15), (int)(x->x_ctl), (int)f);
-}
-
-static void ctlout_setup(void)
-{
- ctlout_class = class_new(gensym("ctlout"), (t_newmethod)ctlout_new, 0,
- sizeof(t_ctlout), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addfloat(ctlout_class, ctlout_float);
- class_sethelpsymbol(ctlout_class, gensym("midi"));
-}
-
-
-/* -------------------------- pgmout -------------------------- */
-
-static t_class *pgmout_class;
-
-typedef struct _pgmout
-{
- t_object x_obj;
- t_float x_channel;
-} t_pgmout;
-
-static void *pgmout_new(t_floatarg channel)
-{
- t_pgmout *x = (t_pgmout *)pd_new(pgmout_class);
- if (channel <= 0) channel = 1;
- x->x_channel = channel;
- floatinlet_new(&x->x_obj, &x->x_channel);
- return (x);
-}
-
-static void pgmout_float(t_pgmout *x, t_floatarg f)
-{
- int binchan = x->x_channel - 1;
- int n = f - 1;
- if (binchan < 0)
- binchan = 0;
- if (n < 0) n = 0;
- else if (n > 127) n = 127;
- outmidi_programchange((binchan >> 4),
- (binchan & 15), n);
-}
-
-static void pgmout_setup(void)
-{
- pgmout_class = class_new(gensym("pgmout"), (t_newmethod)pgmout_new, 0,
- sizeof(t_pgmout), 0, A_DEFFLOAT, 0);
- class_addfloat(pgmout_class, pgmout_float);
- class_sethelpsymbol(pgmout_class, gensym("midi"));
-}
-
-
-/* -------------------------- bendout -------------------------- */
-
-static t_class *bendout_class;
-
-typedef struct _bendout
-{
- t_object x_obj;
- t_float x_channel;
-} t_bendout;
-
-static void *bendout_new(t_floatarg channel)
-{
- t_bendout *x = (t_bendout *)pd_new(bendout_class);
- if (channel <= 0) channel = 1;
- x->x_channel = channel;
- floatinlet_new(&x->x_obj, &x->x_channel);
- return (x);
-}
-
-static void bendout_float(t_bendout *x, t_float f)
-{
- int binchan = x->x_channel - 1;
- int n = (int)f + 8192;
- if (binchan < 0)
- binchan = 0;
- outmidi_pitchbend((binchan >> 4), (binchan & 15), n);
-}
-
-static void bendout_setup(void)
-{
- bendout_class = class_new(gensym("bendout"), (t_newmethod)bendout_new, 0,
- sizeof(t_bendout), 0, A_DEFFLOAT, 0);
- class_addfloat(bendout_class, bendout_float);
- class_sethelpsymbol(bendout_class, gensym("midi"));
-}
-
-/* -------------------------- touch -------------------------- */
-
-static t_class *touchout_class;
-
-typedef struct _touchout
-{
- t_object x_obj;
- t_float x_channel;
-} t_touchout;
-
-static void *touchout_new(t_floatarg channel)
-{
- t_touchout *x = (t_touchout *)pd_new(touchout_class);
- if (channel <= 0) channel = 1;
- x->x_channel = channel;
- floatinlet_new(&x->x_obj, &x->x_channel);
- return (x);
-}
-
-static void touchout_float(t_touchout *x, t_float f)
-{
- int binchan = x->x_channel - 1;
- if (binchan < 0)
- binchan = 0;
- outmidi_aftertouch((binchan >> 4), (binchan & 15), (int)f);
-}
-
-static void touchout_setup(void)
-{
- touchout_class = class_new(gensym("touchout"), (t_newmethod)touchout_new, 0,
- sizeof(t_touchout), 0, A_DEFFLOAT, 0);
- class_addfloat(touchout_class, touchout_float);
- class_sethelpsymbol(touchout_class, gensym("midi"));
-}
-
-/* -------------------------- polytouch -------------------------- */
-
-static t_class *polytouchout_class;
-
-typedef struct _polytouchout
-{
- t_object x_obj;
- t_float x_channel;
- t_float x_pitch;
-} t_polytouchout;
-
-static void *polytouchout_new(t_floatarg channel)
-{
- t_polytouchout *x = (t_polytouchout *)pd_new(polytouchout_class);
- if (channel <= 0) channel = 1;
- x->x_channel = channel;
- x->x_pitch = 0;
- floatinlet_new(&x->x_obj, &x->x_pitch);
- floatinlet_new(&x->x_obj, &x->x_channel);
- return (x);
-}
-
-static void polytouchout_float(t_polytouchout *x, t_float n)
-{
- int binchan = x->x_channel - 1;
- if (binchan < 0)
- binchan = 0;
- outmidi_polyaftertouch((binchan >> 4), (binchan & 15), x->x_pitch, n);
-}
-
-static void polytouchout_setup(void)
-{
- polytouchout_class = class_new(gensym("polytouchout"),
- (t_newmethod)polytouchout_new, 0,
- sizeof(t_polytouchout), 0, A_DEFFLOAT, 0);
- class_addfloat(polytouchout_class, polytouchout_float);
- class_sethelpsymbol(polytouchout_class, gensym("midi"));
-}
-
-/* -------------------------- makenote -------------------------- */
-
-static t_class *makenote_class;
-
-typedef struct _hang
-{
- t_clock *h_clock;
- struct _hang *h_next;
- t_float h_pitch;
- struct _makenote *h_owner;
-} t_hang;
-
-typedef struct _makenote
-{
- t_object x_obj;
- t_float x_velo;
- t_float x_dur;
- t_outlet *x_pitchout;
- t_outlet *x_velout;
- t_hang *x_hang;
-} t_makenote;
-
-static void *makenote_new(t_floatarg velo, t_floatarg dur)
-{
- t_makenote *x = (t_makenote *)pd_new(makenote_class);
- x->x_velo = velo;
- x->x_dur = dur;
- floatinlet_new(&x->x_obj, &x->x_velo);
- floatinlet_new(&x->x_obj, &x->x_dur);
- x->x_pitchout = outlet_new(&x->x_obj, &s_float);
- x->x_velout = outlet_new(&x->x_obj, &s_float);
- x->x_hang = 0;
- return (x);
-}
-
-static void makenote_tick(t_hang *hang)
-{
- t_makenote *x = hang->h_owner;
- t_hang *h2, *h3;
- outlet_float(x->x_velout, 0);
- outlet_float(x->x_pitchout, hang->h_pitch);
- if (x->x_hang == hang) x->x_hang = hang->h_next;
- else for (h2 = x->x_hang; h3 = h2->h_next; h2 = h3)
- {
- if (h3 == hang)
- {
- h2->h_next = h3->h_next;
- break;
- }
- }
- clock_free(hang->h_clock);
- freebytes(hang, sizeof(*hang));
-}
-
-static void makenote_float(t_makenote *x, t_float f)
-{
- t_hang *hang;
- if (!x->x_velo) return;
- outlet_float(x->x_velout, x->x_velo);
- outlet_float(x->x_pitchout, f);
- hang = (t_hang *)getbytes(sizeof *hang);
- hang->h_next = x->x_hang;
- x->x_hang = hang;
- hang->h_pitch = f;
- hang->h_owner = x;
- hang->h_clock = clock_new(hang, (t_method)makenote_tick);
- clock_delay(hang->h_clock, (x->x_dur >= 0 ? x->x_dur : 0));
-}
-
-static void makenote_stop(t_makenote *x)
-{
- t_hang *hang;
- while (hang = x->x_hang)
- {
- outlet_float(x->x_velout, 0);
- outlet_float(x->x_pitchout, hang->h_pitch);
- x->x_hang = hang->h_next;
- clock_free(hang->h_clock);
- freebytes(hang, sizeof(*hang));
- }
-}
-
-static void makenote_clear(t_makenote *x)
-{
- t_hang *hang;
- while (hang = x->x_hang)
- {
- x->x_hang = hang->h_next;
- clock_free(hang->h_clock);
- freebytes(hang, sizeof(*hang));
- }
-}
-
-static void makenote_setup(void)
-{
- makenote_class = class_new(gensym("makenote"),
- (t_newmethod)makenote_new, (t_method)makenote_clear,
- sizeof(t_makenote), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addfloat(makenote_class, makenote_float);
- class_addmethod(makenote_class, (t_method)makenote_stop, gensym("stop"),
- 0);
- class_addmethod(makenote_class, (t_method)makenote_clear, gensym("clear"),
- 0);
-}
-
-/* -------------------------- stripnote -------------------------- */
-
-static t_class *stripnote_class;
-
-typedef struct _stripnote
-{
- t_object x_obj;
- t_float x_velo;
- t_outlet *x_pitchout;
- t_outlet *x_velout;
-} t_stripnote;
-
-static void *stripnote_new(void )
-{
- t_stripnote *x = (t_stripnote *)pd_new(stripnote_class);
- floatinlet_new(&x->x_obj, &x->x_velo);
- x->x_pitchout = outlet_new(&x->x_obj, &s_float);
- x->x_velout = outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-static void stripnote_float(t_stripnote *x, t_float f)
-{
- t_hang *hang;
- if (!x->x_velo) return;
- outlet_float(x->x_velout, x->x_velo);
- outlet_float(x->x_pitchout, f);
-}
-
-static void stripnote_setup(void)
-{
- stripnote_class = class_new(gensym("stripnote"),
- (t_newmethod)stripnote_new, 0, sizeof(t_stripnote), 0, 0);
- class_addfloat(stripnote_class, stripnote_float);
-}
-
-/* -------------------------- poly -------------------------- */
-
-static t_class *poly_class;
-
-typedef struct voice
-{
- float v_pitch;
- int v_used;
- unsigned long v_serial;
-} t_voice;
-
-typedef struct poly
-{
- t_object x_obj;
- int x_n;
- t_voice *x_vec;
- float x_vel;
- t_outlet *x_pitchout;
- t_outlet *x_velout;
- unsigned long x_serial;
- int x_steal;
-} t_poly;
-
-static void *poly_new(float fnvoice, float fsteal)
-{
- int i, n = fnvoice;
- t_poly *x = (t_poly *)pd_new(poly_class);
- t_voice *v;
- if (n < 1) n = 1;
- x->x_n = n;
- x->x_vec = (t_voice *)getbytes(n * sizeof(*x->x_vec));
- for (v = x->x_vec, i = n; i--; v++)
- v->v_pitch = v->v_used = v->v_serial = 0;
- x->x_vel = 0;
- x->x_steal = (fsteal != 0);
- floatinlet_new(&x->x_obj, &x->x_vel);
- outlet_new(&x->x_obj, &s_float);
- x->x_pitchout = outlet_new(&x->x_obj, &s_float);
- x->x_velout = outlet_new(&x->x_obj, &s_float);
- x->x_serial = 0;
- return (x);
-}
-
-static void poly_float(t_poly *x, t_float f)
-{
- int i;
- t_voice *v;
- t_voice *firston, *firstoff;
- unsigned int serialon, serialoff, onindex = 0, offindex = 0;
- if (x->x_vel > 0)
- {
- /* note on. Look for a vacant voice */
- for (v = x->x_vec, i = 0, firston = firstoff = 0,
- serialon = serialoff = 0xffffffff; i < x->x_n; v++, i++)
- {
- if (v->v_used && v->v_serial < serialon)
- firston = v, serialon = v->v_serial, onindex = i;
- else if (!v->v_used && v->v_serial < serialoff)
- firstoff = v, serialoff = v->v_serial, offindex = i;
- }
- if (firstoff)
- {
- outlet_float(x->x_velout, x->x_vel);
- outlet_float(x->x_pitchout, firstoff->v_pitch = f);
- outlet_float(x->x_obj.ob_outlet, offindex+1);
- firstoff->v_used = 1;
- firstoff->v_serial = x->x_serial++;
- }
- /* if none, steal one */
- else if (firston && x->x_steal)
- {
- outlet_float(x->x_velout, 0);
- outlet_float(x->x_pitchout, firston->v_pitch);
- outlet_float(x->x_obj.ob_outlet, onindex+1);
- outlet_float(x->x_velout, x->x_vel);
- outlet_float(x->x_pitchout, firston->v_pitch = f);
- outlet_float(x->x_obj.ob_outlet, onindex+1);
- firston->v_serial = x->x_serial++;
- }
- }
- else /* note off. Turn off oldest match */
- {
- for (v = x->x_vec, i = 0, firston = 0, serialon = 0xffffffff;
- i < x->x_n; v++, i++)
- if (v->v_used && v->v_pitch == f && v->v_serial < serialon)
- firston = v, serialon = v->v_serial, onindex = i;
- if (firston)
- {
- firston->v_used = 0;
- firston->v_serial = x->x_serial++;
- outlet_float(x->x_velout, 0);
- outlet_float(x->x_pitchout, firston->v_pitch);
- outlet_float(x->x_obj.ob_outlet, onindex+1);
- }
- }
-}
-
-static void poly_stop(t_poly *x)
-{
- int i;
- t_voice *v;
- for (i = 0, v = x->x_vec; i < x->x_n; i++, v++)
- if (v->v_used)
- {
- outlet_float(x->x_velout, 0L);
- outlet_float(x->x_pitchout, v->v_pitch);
- outlet_float(x->x_obj.ob_outlet, i+1);
- v->v_used = 0;
- v->v_serial = x->x_serial++;
- }
-}
-
-static void poly_clear(t_poly *x)
-{
- int i;
- t_voice *v;
- for (v = x->x_vec, i = x->x_n; i--; v++) v->v_used = v->v_serial = 0;
-}
-
-static void poly_free(t_poly *x)
-{
- freebytes(x->x_vec, x->x_n * sizeof (*x->x_vec));
-}
-
-static void poly_setup(void)
-{
- poly_class = class_new(gensym("poly"),
- (t_newmethod)poly_new, (t_method)poly_clear,
- sizeof(t_poly), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addfloat(poly_class, poly_float);
- class_addmethod(poly_class, (t_method)poly_stop, gensym("stop"), 0);
- class_addmethod(poly_class, (t_method)poly_clear, gensym("clear"), 0);
-}
-
-/* -------------------------- bag -------------------------- */
-
-static t_class *bag_class;
-
-typedef struct _bagelem
-{
- struct _bagelem *e_next;
- t_float e_value;
-} t_bagelem;
-
-typedef struct _bag
-{
- t_object x_obj;
- t_float x_velo;
- t_bagelem *x_first;
-} t_bag;
-
-static void *bag_new(void )
-{
- t_bag *x = (t_bag *)pd_new(bag_class);
- x->x_velo = 0;
- floatinlet_new(&x->x_obj, &x->x_velo);
- outlet_new(&x->x_obj, &s_float);
- x->x_first = 0;
- return (x);
-}
-
-static void bag_float(t_bag *x, t_float f)
-{
- t_bagelem *bagelem, *e2, *e3;
- if (x->x_velo != 0)
- {
- bagelem = (t_bagelem *)getbytes(sizeof *bagelem);
- bagelem->e_next = 0;
- bagelem->e_value = f;
- if (!x->x_first) x->x_first = bagelem;
- else /* LATER replace with a faster algorithm */
- {
- for (e2 = x->x_first; e3 = e2->e_next; e2 = e3)
- ;
- e2->e_next = bagelem;
- }
- }
- else
- {
- if (!x->x_first) return;
- if (x->x_first->e_value == f)
- {
- bagelem = x->x_first;
- x->x_first = x->x_first->e_next;
- freebytes(bagelem, sizeof(*bagelem));
- return;
- }
- for (e2 = x->x_first; e3 = e2->e_next; e2 = e3)
- if (e3->e_value == f)
- {
- e2->e_next = e3->e_next;
- freebytes(e3, sizeof(*e3));
- return;
- }
- }
-}
-
-static void bag_flush(t_bag *x)
-{
- t_bagelem *bagelem;
- while (bagelem = x->x_first)
- {
- outlet_float(x->x_obj.ob_outlet, bagelem->e_value);
- x->x_first = bagelem->e_next;
- freebytes(bagelem, sizeof(*bagelem));
- }
-}
-
-static void bag_clear(t_bag *x)
-{
- t_bagelem *bagelem;
- while (bagelem = x->x_first)
- {
- x->x_first = bagelem->e_next;
- freebytes(bagelem, sizeof(*bagelem));
- }
-}
-static void bag_setup(void)
-{
- bag_class = class_new(gensym("bag"),
- (t_newmethod)bag_new, (t_method)bag_clear,
- sizeof(t_bag), 0, 0);
- class_addfloat(bag_class, bag_float);
- class_addmethod(bag_class, (t_method)bag_flush, gensym("flush"), 0);
- class_addmethod(bag_class, (t_method)bag_clear, gensym("clear"), 0);
-}
-
-void x_midi_setup(void)
-{
- midiin_setup();
- midirealtimein_setup();
- notein_setup();
- ctlin_setup();
- pgmin_setup();
- bendin_setup();
- touchin_setup();
- polytouchin_setup();
- midiclkin_setup();
- midiout_setup();
- noteout_setup();
- ctlout_setup();
- pgmout_setup();
- bendout_setup();
- touchout_setup();
- polytouchout_setup();
- makenote_setup();
- stripnote_setup();
- poly_setup();
- bag_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/x_misc.c b/apps/plugins/pdbox/PDa/src/x_misc.c
index 394b294f62..e7d0005421 100644
--- a/apps/plugins/pdbox/PDa/src/x_misc.c
+++ b/apps/plugins/pdbox/PDa/src/x_misc.c
@@ -319,324 +319,4 @@ void x_misc_setup(void)
cputime_setup();
realtime_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* misc. */
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef UNIX
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/times.h>
-//#include <sys/param.h>
-#endif
-#ifdef MSW
-#include <wtypes.h>
-#include <time.h>
-#endif
-
-#if defined (MACOSX) || defined (__FreeBSD__)
-#define HZ CLK_TCK
-#endif
-
-/* -------------------------- random ------------------------------ */
-/* this is strictly homebrew and untested. */
-
-static t_class *random_class;
-
-typedef struct _random
-{
- t_object x_obj;
- t_float x_f;
- unsigned int x_state;
-} t_random;
-
-
-static int makeseed(void)
-{
- static unsigned int random_nextseed = 1489853723;
- random_nextseed = random_nextseed * 435898247 + 938284287;
- return (random_nextseed & 0x7fffffff);
-}
-
-static void *random_new(t_floatarg f)
-{
- t_random *x = (t_random *)pd_new(random_class);
- x->x_f = f;
- x->x_state = makeseed();
- floatinlet_new(&x->x_obj, &x->x_f);
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-static void random_bang(t_random *x)
-{
- int n = x->x_f, nval;
- int range = (n < 1 ? 1 : n);
- unsigned int randval = x->x_state;
- x->x_state = randval = randval * 472940017 + 832416023;
- nval = ((double)range) * ((double)randval)
- * (1./4294967296.);
- if (nval >= range) nval = range-1;
- outlet_float(x->x_obj.ob_outlet, nval);
-}
-
-static void random_seed(t_random *x, float f, float glob)
-{
- x->x_state = f;
-}
-
-static void random_setup(void)
-{
- random_class = class_new(gensym("random"), (t_newmethod)random_new, 0,
- sizeof(t_random), 0, A_DEFFLOAT, 0);
- class_addbang(random_class, random_bang);
- class_addmethod(random_class, (t_method)random_seed,
- gensym("seed"), A_FLOAT, 0);
-}
-
-
-/* -------------------------- loadbang ------------------------------ */
-static t_class *loadbang_class;
-
-typedef struct _loadbang
-{
- t_object x_obj;
-} t_loadbang;
-
-static void *loadbang_new(void)
-{
- t_loadbang *x = (t_loadbang *)pd_new(loadbang_class);
- outlet_new(&x->x_obj, &s_bang);
- return (x);
-}
-
-static void loadbang_loadbang(t_loadbang *x)
-{
- if (!sys_noloadbang)
- outlet_bang(x->x_obj.ob_outlet);
-}
-
-static void loadbang_setup(void)
-{
- loadbang_class = class_new(gensym("loadbang"), (t_newmethod)loadbang_new, 0,
- sizeof(t_loadbang), 0, 0);
- class_addmethod(loadbang_class, (t_method)loadbang_loadbang,
- gensym("loadbang"), 0);
-}
-
-/* ------------- namecanvas (delete this later) --------------------- */
-static t_class *namecanvas_class;
-
-typedef struct _namecanvas
-{
- t_object x_obj;
- t_symbol *x_sym;
- t_pd *x_owner;
-} t_namecanvas;
-
-static void *namecanvas_new(t_symbol *s)
-{
- t_namecanvas *x = (t_namecanvas *)pd_new(namecanvas_class);
- x->x_owner = (t_pd *)canvas_getcurrent();
- x->x_sym = s;
- if (*s->s_name) pd_bind(x->x_owner, s);
- return (x);
-}
-
-static void namecanvas_free(t_namecanvas *x)
-{
- if (*x->x_sym->s_name) pd_unbind(x->x_owner, x->x_sym);
-}
-
-static void namecanvas_setup(void)
-{
- namecanvas_class = class_new(gensym("namecanvas"),
- (t_newmethod)namecanvas_new, (t_method)namecanvas_free,
- sizeof(t_namecanvas), CLASS_NOINLET, A_DEFSYM, 0);
-}
-
-/* ---------------serial ports (MSW only -- hack) ------------------------- */
-#define MAXSERIAL 100
-
-static t_class *serial_class;
-
-typedef struct _serial
-{
- t_object x_obj;
- int x_portno;
- int x_open;
-} t_serial;
-
-static void serial_float(t_serial *x, t_float f)
-{
- int n = f;
- char message[MAXSERIAL * 4 + 100];
- if (!x->x_open)
- {
- sys_vgui("com%d_open\n", x->x_portno);
- x->x_open = 1;
- }
- sprintf(message, "com%d_send \"\\%3.3o\"\n", x->x_portno, n);
- sys_gui(message);
-}
-
-static void *serial_new(t_floatarg fportno)
-{
- int portno = fportno;
- t_serial *x = (t_serial *)pd_new(serial_class);
- if (!portno) portno = 1;
- x->x_portno = portno;
- x->x_open = 0;
- return (x);
-}
-
-static void serial_setup(void)
-{
- serial_class = class_new(gensym("serial"), (t_newmethod)serial_new, 0,
- sizeof(t_serial), 0, A_DEFFLOAT, 0);
- class_addfloat(serial_class, serial_float);
-}
-
-/* -------------------------- cputime ------------------------------ */
-
-static t_class *cputime_class;
-
-typedef struct _cputime
-{
- t_object x_obj;
-#ifdef UNIX
- struct tms x_setcputime;
-#endif
-#ifdef MSW
- LARGE_INTEGER x_kerneltime;
- LARGE_INTEGER x_usertime;
- int x_warned;
-#endif
-} t_cputime;
-
-static void cputime_bang(t_cputime *x)
-{
-#ifdef UNIX
- times(&x->x_setcputime);
-#endif
-#ifdef MSW
- FILETIME ignorethis, ignorethat;
- BOOL retval;
- retval = GetProcessTimes(GetCurrentProcess(), &ignorethis, &ignorethat,
- (FILETIME *)&x->x_kerneltime, (FILETIME *)&x->x_usertime);
- if (!retval)
- {
- if (!x->x_warned)
- post("cputime is apparently not supported on your platform");
- x->x_warned = 1;
- x->x_kerneltime.QuadPart = 0;
- x->x_usertime.QuadPart = 0;
- }
-#endif
-}
-
-#define HZ 100
-static void cputime_bang2(t_cputime *x)
-{
-#ifdef UNIX
- float elapsedcpu;
- struct tms newcputime;
- times(&newcputime);
- elapsedcpu = 1000 * (
- newcputime.tms_utime + newcputime.tms_stime -
- x->x_setcputime.tms_utime - x->x_setcputime.tms_stime) / HZ;
- outlet_float(x->x_obj.ob_outlet, elapsedcpu);
-#endif
-#ifdef MSW
- float elapsedcpu;
- FILETIME ignorethis, ignorethat;
- LARGE_INTEGER usertime, kerneltime;
- BOOL retval;
-
- retval = GetProcessTimes(GetCurrentProcess(), &ignorethis, &ignorethat,
- (FILETIME *)&kerneltime, (FILETIME *)&usertime);
- if (retval)
- elapsedcpu = 0.0001 *
- ((kerneltime.QuadPart - x->x_kerneltime.QuadPart) +
- (usertime.QuadPart - x->x_usertime.QuadPart));
- else elapsedcpu = 0;
- outlet_float(x->x_obj.ob_outlet, elapsedcpu);
-#endif
-}
-
-static void *cputime_new(void)
-{
- t_cputime *x = (t_cputime *)pd_new(cputime_class);
- outlet_new(&x->x_obj, gensym("float"));
-
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("bang"), gensym("bang2"));
-#ifdef MSW
- x->x_warned = 0;
-#endif
- cputime_bang(x);
- return (x);
-}
-
-static void cputime_setup(void)
-{
- cputime_class = class_new(gensym("cputime"), (t_newmethod)cputime_new, 0,
- sizeof(t_cputime), 0, 0);
- class_addbang(cputime_class, cputime_bang);
- class_addmethod(cputime_class, (t_method)cputime_bang2, gensym("bang2"), 0);
-}
-
-/* -------------------------- realtime ------------------------------ */
-
-static t_class *realtime_class;
-
-typedef struct _realtime
-{
- t_object x_obj;
- double x_setrealtime;
-} t_realtime;
-
-static void realtime_bang(t_realtime *x)
-{
- x->x_setrealtime = sys_getrealtime();
-}
-
-static void realtime_bang2(t_realtime *x)
-{
- outlet_float(x->x_obj.ob_outlet,
- (sys_getrealtime() - x->x_setrealtime) * 1000.);
-}
-
-static void *realtime_new(void)
-{
- t_realtime *x = (t_realtime *)pd_new(realtime_class);
- outlet_new(&x->x_obj, gensym("float"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("bang"), gensym("bang2"));
- realtime_bang(x);
- return (x);
-}
-
-static void realtime_setup(void)
-{
- realtime_class = class_new(gensym("realtime"), (t_newmethod)realtime_new, 0,
- sizeof(t_realtime), 0, 0);
- class_addbang(realtime_class, realtime_bang);
- class_addmethod(realtime_class, (t_method)realtime_bang2, gensym("bang2"),
- 0);
-}
-void x_misc_setup(void)
-{
- random_setup();
- loadbang_setup();
- namecanvas_setup();
- serial_setup();
- cputime_setup();
- realtime_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/x_net.c b/apps/plugins/pdbox/PDa/src/x_net.c
index 5094661214..c4a004cc5c 100644
--- a/apps/plugins/pdbox/PDa/src/x_net.c
+++ b/apps/plugins/pdbox/PDa/src/x_net.c
@@ -361,366 +361,4 @@ void x_net_setup(void)
netreceive_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* network */
-
-#include "m_pd.h"
-#include "s_stuff.h"
-
-#include <sys/types.h>
-#include <string.h>
-#ifdef UNIX
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
-#include <stdio.h>
-#define SOCKET_ERROR -1
-#else
-#include <winsock.h>
-#endif
-
-static t_class *netsend_class;
-
-typedef struct _netsend
-{
- t_object x_obj;
- int x_fd;
- int x_protocol;
-} t_netsend;
-
-static void *netsend_new(t_floatarg udpflag)
-{
- t_netsend *x = (t_netsend *)pd_new(netsend_class);
- outlet_new(&x->x_obj, &s_float);
- x->x_fd = -1;
- x->x_protocol = (udpflag != 0 ? SOCK_DGRAM : SOCK_STREAM);
- return (x);
-}
-
-static void netsend_connect(t_netsend *x, t_symbol *hostname,
- t_floatarg fportno)
-{
- struct sockaddr_in server;
- struct hostent *hp;
- int sockfd;
- int portno = fportno;
- int intarg;
- if (x->x_fd >= 0)
- {
- error("netsend_connect: already connected");
- return;
- }
-
- /* create a socket */
- sockfd = socket(AF_INET, x->x_protocol, 0);
-#if 0
- fprintf(stderr, "send socket %d\n", sockfd);
-#endif
- if (sockfd < 0)
- {
- sys_sockerror("socket");
- return;
- }
- /* connect socket using hostname provided in command line */
- server.sin_family = AF_INET;
- hp = gethostbyname(hostname->s_name);
- if (hp == 0)
- {
- post("bad host?\n");
- return;
- }
-#if 0
- intarg = 0;
- if (setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF,
- &intarg, sizeof(intarg)) < 0)
- post("setsockopt (SO_RCVBUF) failed\n");
-#endif
- /* for stream (TCP) sockets, specify "nodelay" */
- if (x->x_protocol == SOCK_STREAM)
- {
- intarg = 1;
- if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY,
- &intarg, sizeof(intarg)) < 0)
- post("setsockopt (TCP_NODELAY) failed\n");
- }
- memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
-
- /* assign client port number */
- server.sin_port = htons((u_short)portno);
-
- post("connecting to port %d", portno);
- /* try to connect. LATER make a separate thread to do this
- because it might block */
- if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0)
- {
- sys_sockerror("connecting stream socket");
- sys_closesocket(sockfd);
- return;
- }
- x->x_fd = sockfd;
- outlet_float(x->x_obj.ob_outlet, 1);
-}
-
-static void netsend_disconnect(t_netsend *x)
-{
- if (x->x_fd >= 0)
- {
- sys_closesocket(x->x_fd);
- x->x_fd = -1;
- outlet_float(x->x_obj.ob_outlet, 0);
- }
-}
-
-static void netsend_send(t_netsend *x, t_symbol *s, int argc, t_atom *argv)
-{
- if (x->x_fd >= 0)
- {
- t_binbuf *b = binbuf_new();
- char *buf, *bp;
- int length, sent;
- t_atom at;
- binbuf_add(b, argc, argv);
- SETSEMI(&at);
- binbuf_add(b, 1, &at);
- binbuf_gettext(b, &buf, &length);
- for (bp = buf, sent = 0; sent < length;)
- {
- static double lastwarntime;
- static double pleasewarn;
- double timebefore = sys_getrealtime();
- int res = send(x->x_fd, buf, length-sent, 0);
- double timeafter = sys_getrealtime();
- int late = (timeafter - timebefore > 0.005);
- if (late || pleasewarn)
- {
- if (timeafter > lastwarntime + 2)
- {
- post("netsend blocked %d msec",
- (int)(1000 * ((timeafter - timebefore) + pleasewarn)));
- pleasewarn = 0;
- lastwarntime = timeafter;
- }
- else if (late) pleasewarn += timeafter - timebefore;
- }
- if (res <= 0)
- {
- sys_sockerror("netsend");
- netsend_disconnect(x);
- break;
- }
- else
- {
- sent += res;
- bp += res;
- }
- }
- t_freebytes(buf, length);
- binbuf_free(b);
- }
- else error("netsend: not connected");
-}
-
-static void netsend_free(t_netsend *x)
-{
- netsend_disconnect(x);
-}
-
-static void netsend_setup(void)
-{
- netsend_class = class_new(gensym("netsend"), (t_newmethod)netsend_new,
- (t_method)netsend_free,
- sizeof(t_netsend), 0, A_DEFFLOAT, 0);
- class_addmethod(netsend_class, (t_method)netsend_connect,
- gensym("connect"), A_SYMBOL, A_FLOAT, 0);
- class_addmethod(netsend_class, (t_method)netsend_disconnect,
- gensym("disconnect"), 0);
- class_addmethod(netsend_class, (t_method)netsend_send, gensym("send"),
- A_GIMME, 0);
-}
-
-/* ----------------------------- netreceive ------------------------- */
-
-static t_class *netreceive_class;
-
-typedef struct _netreceive
-{
- t_object x_obj;
- t_outlet *x_msgout;
- t_outlet *x_connectout;
- int x_connectsocket;
- int x_nconnections;
- int x_udp;
-} t_netreceive;
-
-static void netreceive_notify(t_netreceive *x)
-{
- outlet_float(x->x_connectout, --x->x_nconnections);
-}
-
-static void netreceive_doit(void *z, t_binbuf *b)
-{
- t_atom messbuf[1024];
- t_netreceive *x = (t_netreceive *)z;
- int msg, natom = binbuf_getnatom(b);
- t_atom *at = binbuf_getvec(b);
- for (msg = 0; msg < natom;)
- {
- int emsg;
- for (emsg = msg; emsg < natom && at[emsg].a_type != A_COMMA
- && at[emsg].a_type != A_SEMI; emsg++)
- ;
- if (emsg > msg)
- {
- int i;
- for (i = msg; i < emsg; i++)
- if (at[i].a_type == A_DOLLAR || at[i].a_type == A_DOLLSYM)
- {
- pd_error(x, "netreceive: got dollar sign in message");
- goto nodice;
- }
- if (at[msg].a_type == A_FLOAT)
- {
- if (emsg > msg + 1)
- outlet_list(x->x_msgout, 0, emsg-msg, at + msg);
- else outlet_float(x->x_msgout, at[msg].a_w.w_float);
- }
- else if (at[msg].a_type == A_SYMBOL)
- outlet_anything(x->x_msgout, at[msg].a_w.w_symbol,
- emsg-msg-1, at + msg + 1);
- }
- nodice:
- msg = emsg + 1;
- }
-}
-
-static void netreceive_connectpoll(t_netreceive *x)
-{
- int fd = accept(x->x_connectsocket, 0, 0);
- if (fd < 0) post("netreceive: accept failed");
- else
- {
- t_socketreceiver *y = socketreceiver_new((void *)x,
- (t_socketnotifier)netreceive_notify,
- (x->x_msgout ? netreceive_doit : 0), 0);
- sys_addpollfn(fd, (t_fdpollfn)socketreceiver_read, y);
- outlet_float(x->x_connectout, ++x->x_nconnections);
- }
-}
-
-static void *netreceive_new(t_symbol *compatflag,
- t_floatarg fportno, t_floatarg udpflag)
-{
- t_netreceive *x;
- struct sockaddr_in server;
- int sockfd, portno = fportno, udp = (udpflag != 0);
- int old = !strcmp(compatflag->s_name , "old");
- int intarg;
- /* create a socket */
- sockfd = socket(AF_INET, (udp ? SOCK_DGRAM : SOCK_STREAM), 0);
-#if 0
- fprintf(stderr, "receive socket %d\n", sockfd);
-#endif
- if (sockfd < 0)
- {
- sys_sockerror("socket");
- return (0);
- }
- server.sin_family = AF_INET;
- server.sin_addr.s_addr = INADDR_ANY;
-
-#if 1
- /* ask OS to allow another Pd to repoen this port after we close it. */
- intarg = 1;
- if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
- &intarg, sizeof(intarg)) < 0)
- post("setsockopt (SO_REUSEADDR) failed\n");
-#endif
-#if 0
- intarg = 0;
- if (setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF,
- &intarg, sizeof(intarg)) < 0)
- post("setsockopt (SO_RCVBUF) failed\n");
-#endif
- /* Stream (TCP) sockets are set NODELAY */
- if (!udp)
- {
- intarg = 1;
- if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY,
- &intarg, sizeof(intarg)) < 0)
- post("setsockopt (TCP_NODELAY) failed\n");
- }
- /* assign server port number */
- server.sin_port = htons((u_short)portno);
-
- /* name the socket */
- if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
- {
- sys_sockerror("bind");
- sys_closesocket(sockfd);
- return (0);
- }
- x = (t_netreceive *)pd_new(netreceive_class);
- if (old)
- {
- /* old style, nonsecure version */
- x->x_msgout = 0;
- }
- else x->x_msgout = outlet_new(&x->x_obj, &s_anything);
-
- if (udp) /* datagram protocol */
- {
- t_socketreceiver *y = socketreceiver_new((void *)x,
- (t_socketnotifier)netreceive_notify,
- (x->x_msgout ? netreceive_doit : 0), 1);
- sys_addpollfn(sockfd, (t_fdpollfn)socketreceiver_read, y);
- x->x_connectout = 0;
- }
- else /* streaming protocol */
- {
- if (listen(sockfd, 5) < 0)
- {
- sys_sockerror("listen");
- sys_closesocket(sockfd);
- sockfd = -1;
- }
- else
- {
- sys_addpollfn(sockfd, (t_fdpollfn)netreceive_connectpoll, x);
- x->x_connectout = outlet_new(&x->x_obj, &s_float);
- }
- }
- x->x_connectsocket = sockfd;
- x->x_nconnections = 0;
- x->x_udp = udp;
-
- return (x);
-}
-
-static void netreceive_free(t_netreceive *x)
-{
- /* LATER make me clean up open connections */
- if (x->x_connectsocket >= 0)
- {
- sys_rmpollfn(x->x_connectsocket);
- sys_closesocket(x->x_connectsocket);
- }
-}
-
-static void netreceive_setup(void)
-{
- netreceive_class = class_new(gensym("netreceive"),
- (t_newmethod)netreceive_new, (t_method)netreceive_free,
- sizeof(t_netreceive), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT,
- A_DEFSYM, 0);
-}
-
-void x_net_setup(void)
-{
- netsend_setup();
- netreceive_setup();
-}
diff --git a/apps/plugins/pdbox/PDa/src/x_qlist.c b/apps/plugins/pdbox/PDa/src/x_qlist.c
index e2c0605087..7dbec5e7b4 100644
--- a/apps/plugins/pdbox/PDa/src/x_qlist.c
+++ b/apps/plugins/pdbox/PDa/src/x_qlist.c
@@ -343,348 +343,3 @@ void x_qlist_setup(void )
class_addbang(textfile_class, textfile_bang);
}
-/* Copyright (c) 1997-1999 Miller Puckette and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#include "m_pd.h"
-#include <string.h>
-#ifdef UNIX
-#include <unistd.h>
-#endif
-#ifdef MSW
-#include <io.h>
-#endif
-
-typedef struct _qlist
-{
- t_object x_ob;
- t_outlet *x_bangout;
- void *x_binbuf;
- int x_onset; /* playback position */
- t_clock *x_clock;
- float x_tempo;
- double x_whenclockset;
- float x_clockdelay;
- t_symbol *x_dir;
- t_canvas *x_canvas;
- int x_reentered;
-} t_qlist;
-
-static void qlist_tick(t_qlist *x);
-
-static t_class *qlist_class;
-
-static void *qlist_new( void)
-{
- t_symbol *name, *filename = 0;
- t_qlist *x = (t_qlist *)pd_new(qlist_class);
- x->x_binbuf = binbuf_new();
- x->x_clock = clock_new(x, (t_method)qlist_tick);
- outlet_new(&x->x_ob, &s_list);
- x->x_bangout = outlet_new(&x->x_ob, &s_bang);
- x->x_onset = 0x7fffffff;
- x->x_tempo = 1;
- x->x_whenclockset = 0;
- x->x_clockdelay = 0;
- x->x_canvas = canvas_getcurrent();
- x->x_reentered = 0;
- return (x);
-}
-
-static void qlist_rewind(t_qlist *x)
-{
- x->x_onset = 0;
- if (x->x_clock) clock_unset(x->x_clock);
- x->x_whenclockset = 0;
- x->x_reentered = 1;
-}
-
-static void qlist_donext(t_qlist *x, int drop, int automatic)
-{
- t_pd *target = 0;
- while (1)
- {
- int argc = binbuf_getnatom(x->x_binbuf),
- count, onset = x->x_onset, onset2, wasreentered;
- t_atom *argv = binbuf_getvec(x->x_binbuf);
- t_atom *ap = argv + onset, *ap2;
- if (onset >= argc) goto end;
- while (ap->a_type == A_SEMI || ap->a_type == A_COMMA)
- {
- if (ap->a_type == A_SEMI) target = 0;
- onset++, ap++;
- if (onset >= argc) goto end;
- }
-
- if (!target && ap->a_type == A_FLOAT)
- {
- ap2 = ap + 1;
- onset2 = onset + 1;
- while (onset2 < argc && ap2->a_type == A_FLOAT)
- onset2++, ap2++;
- x->x_onset = onset2;
- if (automatic)
- {
- clock_delay(x->x_clock,
- x->x_clockdelay = ap->a_w.w_float * x->x_tempo);
- x->x_whenclockset = clock_getsystime();
- }
- else outlet_list(x->x_ob.ob_outlet, 0, onset2-onset, ap);
- return;
- }
- ap2 = ap + 1;
- onset2 = onset + 1;
- while (onset2 < argc &&
- (ap2->a_type == A_FLOAT || ap2->a_type == A_SYMBOL))
- onset2++, ap2++;
- x->x_onset = onset2;
- count = onset2 - onset;
- if (!target)
- {
- if (ap->a_type != A_SYMBOL) continue;
- else if (!(target = ap->a_w.w_symbol->s_thing))
- {
- error("qlist: %s: no such object", ap->a_w.w_symbol->s_name);
- continue;
- }
- ap++;
- onset++;
- count--;
- if (!count)
- {
- x->x_onset = onset2;
- continue;
- }
- }
- wasreentered = x->x_reentered;
- x->x_reentered = 0;
- if (!drop)
- {
- if (ap->a_type == A_FLOAT)
- typedmess(target, &s_list, count, ap);
- else if (ap->a_type == A_SYMBOL)
- typedmess(target, ap->a_w.w_symbol, count-1, ap+1);
- }
- if (x->x_reentered)
- return;
- x->x_reentered = wasreentered;
- } /* while (1); never falls through */
-
-end:
- x->x_onset = 0x7fffffff;
- outlet_bang(x->x_bangout);
- x->x_whenclockset = 0;
-}
-
-static void qlist_next(t_qlist *x, t_floatarg drop)
-{
- qlist_donext(x, drop != 0, 0);
-}
-
-static void qlist_bang(t_qlist *x)
-{
- qlist_rewind(x);
- qlist_donext(x, 0, 1);
-}
-
-static void qlist_tick(t_qlist *x)
-{
- x->x_whenclockset = 0;
- qlist_donext(x, 0, 1);
-}
-
-static void qlist_add(t_qlist *x, t_symbol *s, int ac, t_atom *av)
-{
- t_atom a;
- SETSEMI(&a);
- binbuf_add(x->x_binbuf, ac, av);
- binbuf_add(x->x_binbuf, 1, &a);
-}
-
-static void qlist_add2(t_qlist *x, t_symbol *s, int ac, t_atom *av)
-{
- binbuf_add(x->x_binbuf, ac, av);
-}
-
-static void qlist_clear(t_qlist *x)
-{
- qlist_rewind(x);
- binbuf_clear(x->x_binbuf);
-}
-
-static void qlist_set(t_qlist *x, t_symbol *s, int ac, t_atom *av)
-{
- qlist_clear(x);
- qlist_add(x, s, ac, av);
-}
-
-static void qlist_read(t_qlist *x, t_symbol *filename, t_symbol *format)
-{
- int cr = 0;
- if (!strcmp(format->s_name, "cr"))
- cr = 1;
- else if (*format->s_name)
- error("qlist_read: unknown flag: %s", format->s_name);
-
- if (binbuf_read_via_path(x->x_binbuf, filename->s_name,
- canvas_getdir(x->x_canvas)->s_name, cr))
- error("%s: read failed", filename->s_name);
- x->x_onset = 0x7fffffff;
- x->x_reentered = 1;
-}
-
-static void qlist_write(t_qlist *x, t_symbol *filename, t_symbol *format)
-{
- int cr = 0;
- char buf[MAXPDSTRING];
- canvas_makefilename(x->x_canvas, filename->s_name,
- buf, MAXPDSTRING);
- if (!strcmp(format->s_name, "cr"))
- cr = 1;
- else if (*format->s_name)
- error("qlist_read: unknown flag: %s", format->s_name);
- if (binbuf_write(x->x_binbuf, buf, "", cr))
- error("%s: write failed", filename->s_name);
-}
-
-static void qlist_print(t_qlist *x)
-{
- post("--------- textfile or qlist contents: -----------");
- binbuf_print(x->x_binbuf);
-}
-
-static void qlist_tempo(t_qlist *x, t_float f)
-{
- float newtempo;
- if (f < 1e-20) f = 1e-20;
- else if (f > 1e20) f = 1e20;
- newtempo = 1./f;
- if (x->x_whenclockset != 0)
- {
- float elapsed = clock_gettimesince(x->x_whenclockset);
- float left = x->x_clockdelay - elapsed;
- if (left < 0) left = 0;
- left *= newtempo / x->x_tempo;
- clock_delay(x->x_clock, left);
- }
- x->x_tempo = newtempo;
-}
-
-static void qlist_free(t_qlist *x)
-{
- binbuf_free(x->x_binbuf);
- if (x->x_clock) clock_free(x->x_clock);
-}
-
-/* -------------------- textfile ------------------------------- */
-
-static t_class *textfile_class;
-typedef t_qlist t_textfile;
-
-static void *textfile_new( void)
-{
- t_symbol *name, *filename = 0;
- t_textfile *x = (t_textfile *)pd_new(textfile_class);
- x->x_binbuf = binbuf_new();
- outlet_new(&x->x_ob, &s_list);
- x->x_bangout = outlet_new(&x->x_ob, &s_bang);
- x->x_onset = 0x7fffffff;
- x->x_reentered = 0;
- x->x_tempo = 1;
- x->x_whenclockset = 0;
- x->x_clockdelay = 0;
- x->x_clock = NULL;
- x->x_canvas = canvas_getcurrent();
- return (x);
-}
-
-static void textfile_bang(t_textfile *x)
-{
- int argc = binbuf_getnatom(x->x_binbuf),
- count, onset = x->x_onset, onset2;
- t_atom *argv = binbuf_getvec(x->x_binbuf);
- t_atom *ap = argv + onset, *ap2;
- while (onset < argc &&
- (ap->a_type == A_SEMI || ap->a_type == A_COMMA))
- onset++, ap++;
- onset2 = onset;
- ap2 = ap;
- while (onset2 < argc &&
- (ap2->a_type != A_SEMI && ap2->a_type != A_COMMA))
- onset2++, ap2++;
- if (onset2 > onset)
- {
- x->x_onset = onset2;
- if (ap->a_type == A_SYMBOL)
- outlet_anything(x->x_ob.ob_outlet, ap->a_w.w_symbol,
- onset2-onset-1, ap+1);
- else outlet_list(x->x_ob.ob_outlet, 0, onset2-onset, ap);
- }
- else
- {
- x->x_onset = 0x7fffffff;
- outlet_bang(x->x_bangout);
- }
-}
-
-static void textfile_rewind(t_qlist *x)
-{
- x->x_onset = 0;
-}
-
-static void textfile_free(t_textfile *x)
-{
- binbuf_free(x->x_binbuf);
-}
-
-/* ---------------- global setup function -------------------- */
-
-void x_qlist_setup(void )
-{
- qlist_class = class_new(gensym("qlist"), (t_newmethod)qlist_new,
- (t_method)qlist_free, sizeof(t_qlist), 0, 0);
- class_addmethod(qlist_class, (t_method)qlist_rewind, gensym("rewind"), 0);
- class_addmethod(qlist_class, (t_method)qlist_next,
- gensym("next"), A_DEFFLOAT, 0);
- class_addmethod(qlist_class, (t_method)qlist_set, gensym("set"),
- A_GIMME, 0);
- class_addmethod(qlist_class, (t_method)qlist_clear, gensym("clear"), 0);
- class_addmethod(qlist_class, (t_method)qlist_add, gensym("add"),
- A_GIMME, 0);
- class_addmethod(qlist_class, (t_method)qlist_add2, gensym("add2"),
- A_GIMME, 0);
- class_addmethod(qlist_class, (t_method)qlist_add, gensym("append"),
- A_GIMME, 0);
- class_addmethod(qlist_class, (t_method)qlist_read, gensym("read"),
- A_SYMBOL, A_DEFSYM, 0);
- class_addmethod(qlist_class, (t_method)qlist_write, gensym("write"),
- A_SYMBOL, A_DEFSYM, 0);
- class_addmethod(qlist_class, (t_method)qlist_print, gensym("print"),
- A_DEFSYM, 0);
- class_addmethod(qlist_class, (t_method)qlist_tempo,
- gensym("tempo"), A_FLOAT, 0);
- class_addbang(qlist_class, qlist_bang);
-
- textfile_class = class_new(gensym("textfile"), (t_newmethod)textfile_new,
- (t_method)textfile_free, sizeof(t_textfile), 0, 0);
- class_addmethod(textfile_class, (t_method)textfile_rewind, gensym("rewind"),
- 0);
- class_addmethod(textfile_class, (t_method)qlist_set, gensym("set"),
- A_GIMME, 0);
- class_addmethod(textfile_class, (t_method)qlist_clear, gensym("clear"), 0);
- class_addmethod(textfile_class, (t_method)qlist_add, gensym("add"),
- A_GIMME, 0);
- class_addmethod(textfile_class, (t_method)qlist_add2, gensym("add2"),
- A_GIMME, 0);
- class_addmethod(textfile_class, (t_method)qlist_add, gensym("append"),
- A_GIMME, 0);
- class_addmethod(textfile_class, (t_method)qlist_read, gensym("read"),
- A_SYMBOL, A_DEFSYM, 0);
- class_addmethod(textfile_class, (t_method)qlist_write, gensym("write"),
- A_SYMBOL, A_DEFSYM, 0);
- class_addmethod(textfile_class, (t_method)qlist_print, gensym("print"),
- A_DEFSYM, 0);
- class_addbang(textfile_class, textfile_bang);
-}
-
diff --git a/apps/plugins/pdbox/PDa/src/x_time.c b/apps/plugins/pdbox/PDa/src/x_time.c
index 580a30b36d..4cab8bc364 100644
--- a/apps/plugins/pdbox/PDa/src/x_time.c
+++ b/apps/plugins/pdbox/PDa/src/x_time.c
@@ -518,523 +518,4 @@ void x_time_setup(void)
timer_setup();
pipe_setup();
}
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* clock objects */
-
-#include "m_pd.h"
-#include <stdio.h>
-/* -------------------------- delay ------------------------------ */
-static t_class *delay_class;
-
-typedef struct _delay
-{
- t_object x_obj;
- t_clock *x_clock;
- double x_deltime;
-} t_delay;
-
-static void delay_bang(t_delay *x)
-{
- clock_delay(x->x_clock, x->x_deltime);
-}
-
-static void delay_stop(t_delay *x)
-{
- clock_unset(x->x_clock);
-}
-
-static void delay_ft1(t_delay *x, t_floatarg g)
-{
- if (g < 0) g = 0;
- x->x_deltime = g;
-}
-
-static void delay_float(t_delay *x, t_float f)
-{
- delay_ft1(x, f);
- delay_bang(x);
-}
-
-static void delay_tick(t_delay *x)
-{
- outlet_bang(x->x_obj.ob_outlet);
-}
-
-static void delay_free(t_delay *x)
-{
- clock_free(x->x_clock);
-}
-
-static void *delay_new(t_floatarg f)
-{
- t_delay *x = (t_delay *)pd_new(delay_class);
- delay_ft1(x, f);
- x->x_clock = clock_new(x, (t_method)delay_tick);
- outlet_new(&x->x_obj, gensym("bang"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- return (x);
-}
-
-static void delay_setup(void)
-{
- delay_class = class_new(gensym("delay"), (t_newmethod)delay_new,
- (t_method)delay_free, sizeof(t_delay), 0, A_DEFFLOAT, 0);
- class_addcreator((t_newmethod)delay_new, gensym("del"), A_DEFFLOAT, 0);
- class_addbang(delay_class, delay_bang);
- class_addmethod(delay_class, (t_method)delay_stop, gensym("stop"), 0);
- class_addmethod(delay_class, (t_method)delay_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addfloat(delay_class, (t_method)delay_float);
-}
-
-/* -------------------------- metro ------------------------------ */
-static t_class *metro_class;
-
-typedef struct _metro
-{
- t_object x_obj;
- t_clock *x_clock;
- double x_deltime;
- int x_hit;
-} t_metro;
-
-static void metro_tick(t_metro *x)
-{
- x->x_hit = 0;
- outlet_bang(x->x_obj.ob_outlet);
- if (!x->x_hit) clock_delay(x->x_clock, x->x_deltime);
-}
-
-static void metro_float(t_metro *x, t_float f)
-{
- if (f != 0) metro_tick(x);
- else clock_unset(x->x_clock);
- x->x_hit = 1;
-}
-
-static void metro_bang(t_metro *x)
-{
- metro_float(x, 1);
-}
-
-static void metro_stop(t_metro *x)
-{
- metro_float(x, 0);
-}
-
-static void metro_ft1(t_metro *x, t_floatarg g)
-{
- if (g < 1) g = 1;
- x->x_deltime = g;
-}
-
-static void metro_free(t_metro *x)
-{
- clock_free(x->x_clock);
-}
-
-static void *metro_new(t_floatarg f)
-{
- t_metro *x = (t_metro *)pd_new(metro_class);
- metro_ft1(x, f);
- x->x_hit = 0;
- x->x_clock = clock_new(x, (t_method)metro_tick);
- outlet_new(&x->x_obj, gensym("bang"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- return (x);
-}
-
-static void metro_setup(void)
-{
- metro_class = class_new(gensym("metro"), (t_newmethod)metro_new,
- (t_method)metro_free, sizeof(t_metro), 0, A_DEFFLOAT, 0);
- class_addbang(metro_class, metro_bang);
- class_addmethod(metro_class, (t_method)metro_stop, gensym("stop"), 0);
- class_addmethod(metro_class, (t_method)metro_ft1, gensym("ft1"),
- A_FLOAT, 0);
- class_addfloat(metro_class, (t_method)metro_float);
-}
-
-/* -------------------------- line ------------------------------ */
-static t_class *line_class;
-
-typedef struct _line
-{
- t_object x_obj;
- t_clock *x_clock;
- double x_targettime;
- t_float x_targetval;
- double x_prevtime;
- t_float x_setval;
- int x_gotinlet;
- t_float x_grain;
- double x_1overtimediff;
- double x_in1val;
-} t_line;
-
-static void line_tick(t_line *x)
-{
- double timenow = clock_getsystime();
- double msectogo = - clock_gettimesince(x->x_targettime);
- if (msectogo < 1E-9)
- {
- outlet_float(x->x_obj.ob_outlet, x->x_targetval);
- }
- else
- {
- outlet_float(x->x_obj.ob_outlet,
- x->x_setval + x->x_1overtimediff * (timenow - x->x_prevtime)
- * (x->x_targetval - x->x_setval));
- clock_delay(x->x_clock,
- (x->x_grain > msectogo ? msectogo : x->x_grain));
- }
-}
-
-static void line_float(t_line *x, t_float f)
-{
- double timenow = clock_getsystime();
- if (x->x_gotinlet && x->x_in1val > 0)
- {
- if (timenow > x->x_targettime) x->x_setval = x->x_targetval;
- else x->x_setval = x->x_setval + x->x_1overtimediff *
- (timenow - x->x_prevtime)
- * (x->x_targetval - x->x_setval);
- x->x_prevtime = timenow;
- x->x_targettime = clock_getsystimeafter(x->x_in1val);
- x->x_targetval = f;
- line_tick(x);
- x->x_gotinlet = 0;
- x->x_1overtimediff = 1./ (x->x_targettime - timenow);
- clock_delay(x->x_clock,
- (x->x_grain > x->x_in1val ? x->x_in1val : x->x_grain));
-
- }
- else
- {
- clock_unset(x->x_clock);
- x->x_targetval = x->x_setval = f;
- outlet_float(x->x_obj.ob_outlet, f);
- }
- x->x_gotinlet = 0;
-}
-static void line_ft1(t_line *x, t_floatarg g)
-{
- x->x_in1val = g;
- x->x_gotinlet = 1;
-}
-
-static void line_stop(t_line *x)
-{
- x->x_targetval = x->x_setval;
- clock_unset(x->x_clock);
-}
-
-static void line_free(t_line *x)
-{
- clock_free(x->x_clock);
-}
-
-static void *line_new(t_floatarg f, t_floatarg grain)
-{
- t_line *x = (t_line *)pd_new(line_class);
- x->x_targetval = x->x_setval = f;
- x->x_gotinlet = 0;
- x->x_1overtimediff = 1;
- x->x_clock = clock_new(x, (t_method)line_tick);
- x->x_targettime = x->x_prevtime = clock_getsystime();
- if (grain <= 0) grain = 20;
- x->x_grain = grain;
- outlet_new(&x->x_obj, gensym("float"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- return (x);
-}
-
-static void line_setup(void)
-{
- line_class = class_new(gensym("line"), (t_newmethod)line_new,
- (t_method)line_free, sizeof(t_line), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addmethod(line_class, (t_method)line_ft1,
- gensym("ft1"), A_FLOAT, 0);
- class_addmethod(line_class, (t_method)line_stop,
- gensym("stop"), 0);
- class_addfloat(line_class, (t_method)line_float);
-}
-
-/* -------------------------- timer ------------------------------ */
-static t_class *timer_class;
-
-typedef struct _timer
-{
- t_object x_obj;
- t_time x_settime;
-} t_timer;
-
-static void timer_bang(t_timer *x)
-{
- x->x_settime = clock_getsystime();
-}
-
-static void timer_bang2(t_timer *x)
-{
- t_time diff = clock_gettimesince(x->x_settime);
- outlet_float(x->x_obj.ob_outlet, diff);
-}
-
-static void *timer_new(t_floatarg f)
-{
- t_timer *x = (t_timer *)pd_new(timer_class);
- timer_bang(x);
- outlet_new(&x->x_obj, gensym("float"));
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("bang"), gensym("bang2"));
- return (x);
-}
-
-static void timer_setup(void)
-{
- timer_class = class_new(gensym("timer"), (t_newmethod)timer_new, 0,
- sizeof(t_timer), 0, A_DEFFLOAT, 0);
- class_addbang(timer_class, timer_bang);
- class_addmethod(timer_class, (t_method)timer_bang2, gensym("bang2"), 0);
-}
-
-
-/* -------------------------- pipe -------------------------- */
-
-static t_class *pipe_class;
-
-typedef struct _hang
-{
- t_clock *h_clock;
- struct _hang *h_next;
- struct _pipe *h_owner;
- t_gpointer *h_gp;
- union word h_vec[1]; /* not the actual number. */
-} t_hang;
-
-typedef struct pipeout
-{
- t_atom p_atom;
- t_outlet *p_outlet;
-} t_pipeout;
-
-typedef struct _pipe
-{
- t_object x_obj;
- int x_n;
- int x_nptr;
- float x_deltime;
- t_pipeout *x_vec;
- t_gpointer *x_gp;
- t_hang *x_hang;
-} t_pipe;
-
-static void *pipe_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_pipe *x = (t_pipe *)pd_new(pipe_class);
- t_atom defarg, *ap;
- t_pipeout *vec, *vp;
- t_gpointer *gp;
- int nptr = 0;
- int i;
- float deltime;
- if (argc)
- {
- if (argv[argc-1].a_type != A_FLOAT)
- {
- char stupid[80];
- atom_string(&argv[argc-1], stupid, 79);
- post("pipe: %s: bad time delay value", stupid);
- deltime = 0;
- }
- else deltime = argv[argc-1].a_w.w_float;
- argc--;
- }
- else deltime = 0;
- if (!argc)
- {
- argv = &defarg;
- argc = 1;
- SETFLOAT(&defarg, 0);
- }
- x->x_n = argc;
- vec = x->x_vec = (t_pipeout *)getbytes(argc * sizeof(*x->x_vec));
-
- for (i = argc, ap = argv; i--; ap++)
- if (ap->a_type == A_SYMBOL && *ap->a_w.w_symbol->s_name == 'p')
- nptr++;
-
- gp = x->x_gp = (t_gpointer *)t_getbytes(nptr * sizeof (*gp));
- x->x_nptr = nptr;
-
- for (i = 0, vp = vec, ap = argv; i < argc; i++, ap++, vp++)
- {
- if (ap->a_type == A_FLOAT)
- {
- vp->p_atom = *ap;
- vp->p_outlet = outlet_new(&x->x_obj, &s_float);
- if (i) floatinlet_new(&x->x_obj, &vp->p_atom.a_w.w_float);
- }
- else if (ap->a_type == A_SYMBOL)
- {
- char c = *ap->a_w.w_symbol->s_name;
- if (c == 's')
- {
- SETSYMBOL(&vp->p_atom, &s_symbol);
- vp->p_outlet = outlet_new(&x->x_obj, &s_symbol);
- if (i) symbolinlet_new(&x->x_obj, &vp->p_atom.a_w.w_symbol);
- }
- else if (c == 'p')
- {
- vp->p_atom.a_type = A_POINTER;
- vp->p_atom.a_w.w_gpointer = gp;
- gpointer_init(gp);
- vp->p_outlet = outlet_new(&x->x_obj, &s_pointer);
- if (i) pointerinlet_new(&x->x_obj, gp);
- gp++;
- }
- else
- {
- if (c != 'f') error("pack: %s: bad type",
- ap->a_w.w_symbol->s_name);
- SETFLOAT(&vp->p_atom, 0);
- vp->p_outlet = outlet_new(&x->x_obj, &s_float);
- if (i) floatinlet_new(&x->x_obj, &vp->p_atom.a_w.w_float);
- }
- }
- }
- floatinlet_new(&x->x_obj, &x->x_deltime);
- x->x_hang = 0;
- x->x_deltime = deltime;
- return (x);
-}
-
-static void hang_free(t_hang *h)
-{
- t_pipe *x = h->h_owner;
- t_gpointer *gp;
- int i;
- for (gp = h->h_gp, i = x->x_nptr; i--; gp++)
- gpointer_unset(gp);
- freebytes(h->h_gp, x->x_nptr * sizeof(*h->h_gp));
- clock_free(h->h_clock);
- freebytes(h, sizeof(*h) + (x->x_n - 1) * sizeof(*h->h_vec));
-}
-
-static void hang_tick(t_hang *h)
-{
- t_pipe *x = h->h_owner;
- t_hang *h2, *h3;
- t_pipeout *p;
- int i;
- union word *w;
- if (x->x_hang == h) x->x_hang = h->h_next;
- else for (h2 = x->x_hang; h3 = h2->h_next; h2 = h3)
- {
- if (h3 == h)
- {
- h2->h_next = h3->h_next;
- break;
- }
- }
- for (i = x->x_n, p = x->x_vec + (x->x_n - 1), w = h->h_vec + (x->x_n - 1);
- i--; p--, w--)
- {
- switch (p->p_atom.a_type)
- {
- case A_FLOAT: outlet_float(p->p_outlet, w->w_float); break;
- case A_SYMBOL: outlet_symbol(p->p_outlet, w->w_symbol); break;
- case A_POINTER:
- if (gpointer_check(w->w_gpointer, 1))
- outlet_pointer(p->p_outlet, w->w_gpointer);
- else post("pipe: stale pointer");
- break;
- }
- }
- hang_free(h);
-}
-
-static void pipe_list(t_pipe *x, t_symbol *s, int ac, t_atom *av)
-{
- t_hang *h = (t_hang *)
- getbytes(sizeof(*h) + (x->x_n - 1) * sizeof(*h->h_vec));
- t_gpointer *gp, *gp2;
- t_pipeout *p;
- int i, n = x->x_n;
- t_atom *ap;
- t_word *w;
- h->h_gp = (t_gpointer *)getbytes(x->x_nptr * sizeof(t_gpointer));
- if (ac > n) ac = n;
- for (i = 0, gp = x->x_gp, p = x->x_vec, ap = av; i < ac;
- i++, p++, ap++)
- {
- switch (p->p_atom.a_type)
- {
- case A_FLOAT: p->p_atom.a_w.w_float = atom_getfloat(ap); break;
- case A_SYMBOL: p->p_atom.a_w.w_symbol = atom_getsymbol(ap); break;
- case A_POINTER:
- gpointer_unset(gp);
- if (ap->a_type != A_POINTER)
- post("pipe: bad pointer");
- else
- {
- *gp = *(ap->a_w.w_gpointer);
- if (gp->gp_stub) gp->gp_stub->gs_refcount++;
- }
- gp++;
- }
- }
- for (i = 0, gp = x->x_gp, gp2 = h->h_gp, p = x->x_vec, w = h->h_vec;
- i < n; i++, p++, w++)
- {
- if (p->p_atom.a_type == A_POINTER)
- {
- if (gp->gp_stub) gp->gp_stub->gs_refcount++;
- w->w_gpointer = gp2;
- *gp2++ = *gp++;
- }
- else *w = p->p_atom.a_w;
- }
- h->h_next = x->x_hang;
- x->x_hang = h;
- h->h_owner = x;
- h->h_clock = clock_new(h, (t_method)hang_tick);
- clock_delay(h->h_clock, (x->x_deltime >= 0 ? x->x_deltime : 0));
-}
-
-static void pipe_flush(t_pipe *x)
-{
- while (x->x_hang) hang_tick(x->x_hang);
-}
-
-static void pipe_clear(t_pipe *x)
-{
- t_hang *hang;
- while (hang = x->x_hang)
- {
- x->x_hang = hang->h_next;
- hang_free(hang);
- }
-}
-
-static void pipe_setup(void)
-{
- pipe_class = class_new(gensym("pipe"),
- (t_newmethod)pipe_new, (t_method)pipe_clear,
- sizeof(t_pipe), 0, A_GIMME, 0);
- class_addlist(pipe_class, pipe_list);
- class_addmethod(pipe_class, (t_method)pipe_flush, gensym("flush"), 0);
- class_addmethod(pipe_class, (t_method)pipe_clear, gensym("clear"), 0);
-}
-
-void x_time_setup(void)
-{
- delay_setup();
- metro_setup();
- line_setup();
- timer_setup();
- pipe_setup();
-}
diff --git a/apps/plugins/pdbox/dbestfit-3.3/CHANGES b/apps/plugins/pdbox/dbestfit-3.3/CHANGES
index f244f66f87..7f63d384fa 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/CHANGES
+++ b/apps/plugins/pdbox/dbestfit-3.3/CHANGES
@@ -10,15 +10,3 @@ Changes
* 3.2
Made eons ago, all older changes have been forgotten.
-Changes
-
-* (March 30 2005) Daniel
-
- Linus Nielsen Feltzing provided a patch that corrected several minor problems
- that prevented dbestfit from working good. Linus also tested and timed
- dbestfit for real in a target where he replaced the pSOS-provided memory
- subsystem.
-
-* 3.2
-
- Made eons ago, all older changes have been forgotten.
diff --git a/apps/plugins/pdbox/dbestfit-3.3/FILES b/apps/plugins/pdbox/dbestfit-3.3/FILES
index 684a225972..6076c5fe20 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/FILES
+++ b/apps/plugins/pdbox/dbestfit-3.3/FILES
@@ -13,18 +13,3 @@
/thoughts
/malloc.man
/CHANGES
-/bysize.c
-/bysize.h
-/bmalloc.c
-/bmalloc.h
-/dmalloc.c
-/dmalloc.h
-/FILES
-/README
-/Makefile
-/Malloc.c
-/mytest.c
-/dmytest.c
-/thoughts
-/malloc.man
-/CHANGES
diff --git a/apps/plugins/pdbox/dbestfit-3.3/Makefile b/apps/plugins/pdbox/dbestfit-3.3/Makefile
index e34b02e918..fc1e7e68d9 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/Makefile
+++ b/apps/plugins/pdbox/dbestfit-3.3/Makefile
@@ -36,41 +36,3 @@ tgz:
clean:
rm -f *.o *~ $(TARGET1) $(TARGET2) $(TARGET3)
-
-OBJS1 = bmalloc.o bysize.o mytest.o
-TARGET1 = mytest
-
-OBJS2 = dmalloc.o bmalloc.o bysize.o Malloc.o
-TARGET2 = mtest
-
-OBJS3 = dmalloc.o bmalloc.o bysize.o dmytest.o
-TARGET3 = dmytest
-
-CFLAGS = -g -DUNIX -DBMALLOC -Wall -pedantic -DDEBUG
-CC = gcc
-
-all: $(TARGET1) $(TARGET2) $(TARGET3)
-
-$(TARGET1): $(OBJS1)
- $(CC) -g -o $(TARGET1) $(OBJS1)
-
-$(TARGET2): $(OBJS2)
- $(CC) -g -o $(TARGET2) $(OBJS2)
-
-$(TARGET3): $(OBJS3)
- $(CC) -g -o $(TARGET3) $(OBJS3)
-
-bmalloc.o: bmalloc.c
-dmalloc.o: dmalloc.c
-mytest.o: mytest.c
-dmytest.o: dmytest.c
-Malloc.o : Malloc.c
-bysize.o : bysize.c
-
-tgz:
- @(dir=`pwd`;name=`basename $$dir`;echo Creates $$name.tar.gz; cd .. ; \
- tar -cf $$name.tar `cat $$name/FILES | sed "s:^/:$$name/:g"` ; \
- gzip $$name.tar ; chmod a+r $$name.tar.gz ; mv $$name.tar.gz $$name/)
-
-clean:
- rm -f *.o *~ $(TARGET1) $(TARGET2) $(TARGET3)
diff --git a/apps/plugins/pdbox/dbestfit-3.3/Malloc.c b/apps/plugins/pdbox/dbestfit-3.3/Malloc.c
index 25e30706fe..10b02c94ec 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/Malloc.c
+++ b/apps/plugins/pdbox/dbestfit-3.3/Malloc.c
@@ -198,205 +198,3 @@ int main(void)
printf("\n");
return 0;
}
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-/* Storleken på allokeringen bestäms genom att först slumpas en position i
-"size_table" ut, sedan slumpas en storlek mellan den postionen och nästa värde
-i tabellen. Genom att ha tabellen koncentrerad med låga värden, så skapas
-flest såna. Rutinen håller på tills minnet en allokeringen nekas. Den kommer
-aldrig att ha mer än MAXIMAL_MEMORY_TO_ALLOCATE allokerat samtidigt. Maximalt
-har den MAX_ALLOCATIONS allokeringar samtidigt.
-
-Statistiskt sätt så kommer efter ett tag MAX_ALLOCATIONS/2 allokeringar finnas
-samtidigt, med varje allokering i median med värdet av halva "size_table".
-
-När minnet är slut (malloc()=NULL), frågas användaren om han ska fortsätta.
-
-Med jämna mellanrum skrivs statisktik ut på skärmen. (DISPLAY_WHEN)
-
-För att stressa systemet med fler små allokeringar, så kan man öka
-MAX_ALLOCATIONS. AMOUNT_OF_MEMORY bör få den att slå i taket fortare om man
-minskar det.
-
-Ingen initiering görs av slumptalen, så allt är upprepbart (men plocka bort
-kommentaren på srand() och det löser sig.
-
-*/
-
-/*#undef BMALLOC*/
-
-#ifdef BMALLOC
-#include "dmalloc.h"
-
-#include "bmalloc.h"
-#endif
-
-#define MAX_ALLOCATIONS 100000
-#define AMOUNT_OF_MEMORY 180000 /* bytes */
-#define MAXIMAL_MEMORY_TO_ALLOCATE 100000 /* Sätt den här högre än
- AMOUNT_OF_MEMORY, och malloc() bör
- returnera NULL förr eller senare */
-
-#define DISPLAY_WHEN (123456) /* When to display statistic */
-
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define BOOL char
-#define TRUE 1
-#define FALSE 0
-
-typedef struct {
- char *memory;
- long size;
- char filled_with;
- long table_position;
-} MallocStruct;
-
-/*
-Skapar en lista med MAX_ALLOCATIONS storlek där det slumpvis allokeras
-eller reallokeras i.
-*/
-
-MallocStruct my_mallocs[MAX_ALLOCATIONS];
-
-long size_table[]={5,8,10,11,12,14,16,18,20,26,33,50,70,90,120,150,200,400,800,1000,2000,4000,8000,10000,11000,12000,13000,14000,15000,16000,17000,18000};
-#define TABLESIZE ((sizeof(size_table)-1)/sizeof(long))
-long size_allocs[TABLESIZE];
-
-int main(void)
-{
- int i;
- long count=-1;
- long count_free=0, count_malloc=0, count_realloc=0;
- long total_memory=0;
- BOOL out_of_memory=FALSE;
- unsigned int seed = time( NULL );
-
-#ifdef BMALLOC
- void *thisisourheap;
- thisisourheap = (malloc)(AMOUNT_OF_MEMORY);
- if(!thisisourheap)
- return -1; /* can't get memory */
- add_pool(thisisourheap, AMOUNT_OF_MEMORY);
-#endif
-
- seed = 1109323906;
-
- srand( seed ); /* Initialize randomize */
-
- printf("seed: %d\n", seed);
-
- while (!out_of_memory) {
- long number=rand()%MAX_ALLOCATIONS;
- long size;
- long table_position=rand()%TABLESIZE;
- char fill_with=rand()&255;
-
- count++;
-
- size=rand()%(size_table[table_position+1]-size_table[table_position])+size_table[table_position];
-
-/* fprintf(stderr, "number %d size %d\n", number, size); */
-
- if (my_mallocs[number].size) { /* Om allokering redan finns på den här
- positionen, så reallokerar vi eller
- friar. */
- long old_size=my_mallocs[number].size;
- if (my_mallocs[number].size && fill_with<40) {
- free(my_mallocs[number].memory);
- total_memory -= my_mallocs[number].size;
- count_free++;
- size_allocs[my_mallocs[number].table_position]--;
- size=0;
- my_mallocs[number].size = 0;
- my_mallocs[number].memory = NULL;
- } else {
- /*
- * realloc() part
- *
- */
- char *temp;
-#if 0
- if(my_mallocs[number].size > size) {
- printf("*** %d is realloc()ed to %d\n",
- my_mallocs[number].size, size);
- }
-#endif
- if (total_memory-old_size+size>MAXIMAL_MEMORY_TO_ALLOCATE)
- goto output; /* for-loop */
- temp = (char *)realloc(my_mallocs[number].memory, size);
- if (!temp)
- out_of_memory=TRUE;
- else {
- my_mallocs[number].memory = temp;
-
- my_mallocs[number].size=size;
- size_allocs[my_mallocs[number].table_position]--;
- size_allocs[table_position]++;
- total_memory -= old_size;
- total_memory += size;
- old_size=min(old_size, size);
- while (--old_size>0) {
- if (my_mallocs[number].memory[old_size]!=my_mallocs[number].filled_with)
- fprintf(stderr, "Wrong filling!\n");
- }
- count_realloc++;
- }
- }
- } else {
- if (total_memory+size>MAXIMAL_MEMORY_TO_ALLOCATE) {
- goto output; /* for-loop */
- }
- my_mallocs[number].memory=(char *)malloc(size); /* Allokera! */
- if (!my_mallocs[number].memory)
- out_of_memory=TRUE;
- else {
- size_allocs[table_position]++;
- count_malloc++;
- total_memory += size;
- }
- }
-
- if(!out_of_memory) {
- my_mallocs[number].table_position=table_position;
- my_mallocs[number].size=size;
- my_mallocs[number].filled_with=fill_with;
- memset(my_mallocs[number].memory, fill_with, size);
- }
- output:
- if (out_of_memory || !(count%DISPLAY_WHEN)) {
- printf("(%d) malloc %d, realloc %d, free %d, total size %d\n", count, count_malloc, count_realloc, count_free, total_memory);
- {
- int count;
- printf("[size bytes]=[number of allocations]\n");
- for (count=0; count<TABLESIZE; count++) {
- printf("%ld=%ld, ", size_table[count], size_allocs[count]);
- }
- printf("\n\n");
- }
- }
- if (out_of_memory) {
- fprintf(stderr, "Memory is out! Continue (y/n)");
- switch (getchar()) {
- case 'y':
- case 'Y':
- out_of_memory=FALSE;
- break;
- }
- fprintf(stderr, "\n");
- }
- }
- for(i = 0;i < MAX_ALLOCATIONS;i++) {
- if((my_mallocs[i].memory))
- free(my_mallocs[i].memory);
- }
-
- print_lists();
-
- printf("\n");
- return 0;
-}
-
diff --git a/apps/plugins/pdbox/dbestfit-3.3/README b/apps/plugins/pdbox/dbestfit-3.3/README
index 919875df96..7452e36279 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/README
+++ b/apps/plugins/pdbox/dbestfit-3.3/README
@@ -19,26 +19,3 @@ TODO:
* Make a separate application that samples the memory usage of a program
and is capable of replaying it (in order to test properly).
-
-Package: dbestfit - a dynamic memory allocator
-Date: March 30, 2005
-Version: 3.3
-Author: Daniel Stenberg <daniel@haxx.se>
-
- I wrote the dmalloc part for small allocation sizes to improve the behavior
-of the built-in (first-fit) allocator found in pSOS (around 1996).
-
- I wrote the bmalloc part (best-fit with splay-tree sorting) just for the fun
-of it and to see how good malloc() clone I could make. The quality of my
-implementation is still left to be judged in real-world tests.
-
-TODO:
- * Remove the final not-so-very-nice loop in dmalloc.c that checks for a block
- with free fragments (when the list gets longer too much time might be spent
- in that loop).
-
- * Add semaphore protection in bmalloc.
-
- * Make a separate application that samples the memory usage of a program
- and is capable of replaying it (in order to test properly).
-
diff --git a/apps/plugins/pdbox/dbestfit-3.3/bmalloc.c b/apps/plugins/pdbox/dbestfit-3.3/bmalloc.c
index f95b4f6125..35cafb8f96 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/bmalloc.c
+++ b/apps/plugins/pdbox/dbestfit-3.3/bmalloc.c
@@ -367,374 +367,3 @@ void bfree(void *ptr)
#endif
}
-
-/*****************************************************************************
- *
- * Big (best-fit) Memory Allocation
- *
- * Author: Daniel Stenberg
- * Date: March 5, 1997
- * Version: 2.0
- * Email: Daniel.Stenberg@sth.frontec.se
- *
- *
- * Read 'thoughts' for theories and details in implementation.
- *
- * Routines meant to replace the most low level functions of an Operting
- * System
- *
- * v2.0
- * - Made all size-routines get moved out from this file. This way, the size
- * functions can much more easily get replaced.
- * - Improved how new memory blocks get added to the size-sorted list. When
- * not adding new pools, there should never ever be any list traversing
- * since all information is dynamically gathered.
- *
- ****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "bysize.h"
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-/* #define DEBUG */
-
-#define BMEM_ALIGN 64 /* resolution */
-
-#define BMEMERR_TOOSMALL -1
-
-/* this struct will be stored in all CHUNKS and AREAS */
-struct BlockInfo {
- struct BlockInfo *lower; /* previous block in memory (lower address) */
- struct BlockInfo *higher; /* next block in memory (higher address) */
- unsigned long info; /* 31 bits size: 1 bit free boolean */
-#define INFO_FREE 1
-#define INFO_SIZE (~ INFO_FREE) /* inverted FREE bit pattern */
-
- /* FREE+SIZE Could be written to use ordinary bitfields if using a smart
- (like gcc) compiler in a manner like:
- int size:31;
- int free:1;
-
- The 'higher' pointer COULD be removed completely if the size is used as
- an index to the higher one. This would then REQUIRE the entire memory
- pool to be contiguous and it needs a 'terminating' "node" or an extra
- flag that informs about the end of the list.
- */
-};
-
-/* the BLOCK list should be sorted in a lower to higher address order */
-struct BlockInfo *blockHead=NULL; /* nothing from the start */
-
-void print_lists(void);
-
-
-/***********************************************************************
- *
- * remove_block()
- *
- * Remove the block from the address-sorted list.
- *
- ***********************************************************************/
-
-void remove_block(struct BlockInfo *block)
-{
- if(block->lower)
- block->lower->higher = block->higher;
- else
- blockHead = block->higher;
- if(block->higher)
- block->higher->lower = block->lower;
-}
-
-/****************************************************************************
- *
- * add_blocktolists()
- *
- * Adds the specified block at the specified place in the address-sorted
- * list and at the appropriate place in the size-sorted.
- *
- ***************************************************************************/
-void add_blocktolists(struct BlockInfo *block,
- struct BlockInfo *newblock,
- size_t newsize)
-{
- struct BlockInfo *temp; /* temporary storage variable */
- if(block) {
- /* `block' is now a lower address than 'newblock' */
-
- /*
- * Check if the new CHUNK is wall-to-wall with the lower addressed
- * one (if *that* is free)
- */
- if(block->info&INFO_FREE) {
- if((char *)block + (block->info&INFO_SIZE) == (char *)newblock) {
- /* yes sir, this is our lower address neighbour, enlarge that one
- pick it out from the list and recursively add that chunk and
- then we escape */
-
- /* remove from size-sorted list: */
- remove_chunksize((char*)block+sizeof(struct BlockInfo));
-
- block->info += newsize; /* newsize is an even number and thus the FREE
- bit is untouched */
-
- remove_block(block); /* unlink the block address-wise */
-
- /* recursively check our lower friend(s) */
- add_blocktolists(block->lower, block, block->info&INFO_SIZE);
- return;
- }
- }
-
- temp = block->higher;
-
- block->higher = newblock;
- newblock->lower = block;
- newblock->higher = temp;
- if(newblock->higher)
- newblock->higher->lower = newblock;
- }
- else {
- /* this block should preceed the heading one */
- temp = blockHead;
-
- /* check if this is our higher addressed neighbour */
- if((char *)newblock + newsize == (char *)temp) {
-
- /* yes, we are wall-to-wall with the higher CHUNK */
- if(temp->info&INFO_FREE) {
- /* and the neighbour is even free, remove that one and enlarge
- ourselves, call add_pool() recursively and then escape */
-
- remove_block(temp); /* unlink 'temp' from list */
-
- /* remove from size-sorted list: */
- remove_chunksize((char*)temp+sizeof(struct BlockInfo) );
-
- /* add the upper block's size on ourselves */
- newsize += temp->info&INFO_SIZE;
-
- /* add the new, bigger block */
- add_blocktolists(block, newblock, newsize);
- return;
- }
- }
-
- blockHead = newblock;
- newblock->higher = temp;
- newblock->lower = NULL; /* there is no lower one */
- if(newblock->higher)
- newblock->higher->lower = newblock;
- }
-
- newblock->info = newsize | INFO_FREE; /* we do assume size isn't using the
- FREE bit */
- insert_bysize((char *)newblock+sizeof(struct BlockInfo), newsize);
-}
-
-/***********************************************************************
- *
- * findblockbyaddr()
- *
- * Find the block that is just before the input block in memory. Returns NULL
- * if none is.
- *
- ***********************************************************************/
-
-static struct BlockInfo *findblockbyaddr(struct BlockInfo *block)
-{
- struct BlockInfo *test = blockHead;
- struct BlockInfo *lower = NULL;
-
- while(test && (test < block)) {
- lower = test;
- test = test->higher;
- }
- return lower;
-}
-
-/***********************************************************************
- *
- * add_pool()
- *
- * This function should be the absolutely first function to call. It sets up
- * the memory bounds of the [first] CHUNK(s). It should be possible to call
- * this function several times to add more CHUNKs to the pool of free
- * memory. This allows the bmalloc system to deal with a non-contigous memory
- * area.
- *
- * Returns non-zero if an error occured. The memory was not added then.
- *
- ***********************************************************************/
-
-int add_pool(void *start,
- size_t size)
-{
- struct BlockInfo *newblock = (struct BlockInfo *)start;
- struct BlockInfo *block;
-
- if(size < BMEM_ALIGN)
- return BMEMERR_TOOSMALL;
-
- block = findblockbyaddr( newblock );
- /* `block' is now a lower address than 'newblock' or NULL */
-
- if(size&1)
- size--; /* only add even sizes */
-
- add_blocktolists(block, newblock, size);
-
- return 0;
-}
-
-
-#ifdef DEBUG
-static void bmalloc_failed(size_t size)
-{
- printf("*** " __FILE__ " Couldn't allocate %d bytes\n", size);
- print_lists();
-}
-#else
-#define bmalloc_failed(x)
-#endif
-
-void print_lists()
-{
- struct BlockInfo *block = blockHead;
-#if 1
- printf("List of BLOCKS (in address order):\n");
- while(block) {
- printf(" START %p END %p SIZE %ld FLAG %s\n",
- (char *)block,
- (char *)block+(block->info&INFO_SIZE), block->info&INFO_SIZE,
- (block->info&INFO_FREE)?"free":"used");
- block = block->higher;
- }
- printf("End of BLOCKS:\n");
-#endif
- print_sizes();
-}
-
-void *bmalloc(size_t size)
-{
- void *mem;
-
-#ifdef DEBUG
- {
- static int count=0;
- int realsize = size + sizeof(struct BlockInfo);
- if(realsize%4096)
- realsize = ((size / BMEM_ALIGN)+1) * BMEM_ALIGN;
- printf("%d bmalloc(%d) [%d]\n", count++, size, realsize);
- }
-#endif
-
- size += sizeof(struct BlockInfo); /* add memory for our header */
-
- if(size&(BMEM_ALIGN-1)) /* a lot faster than %BMEM_ALIGN but this MUST be
- changed if the BLOCKSIZE is not 2^X ! */
- size = ((size / BMEM_ALIGN)+1) * BMEM_ALIGN; /* align like this */
-
- /* get a CHUNK from the list with this size */
- mem = obtainbysize ( size );
- if(mem) {
- /* the memory block we have got is the "best-fit" and it is already
- un-linked from the free list */
-
- /* now do the math to get the proper block pointer */
- struct BlockInfo *block= (struct BlockInfo *)
- ((char *)mem - sizeof(struct BlockInfo));
-
- block->info &= ~INFO_FREE;
- /* not free anymore */
-
- if( size != (block->info&INFO_SIZE)) {
- /* split this chunk into two pieces and return the one that fits us */
- size_t othersize = (block->info&INFO_SIZE) - size;
-
- if(othersize > BMEM_ALIGN) {
- /* prevent losing small pieces of memory due to weird alignments
- of the memory pool */
-
- block->info = size; /* set new size (leave FREE bit cleared) */
-
- /* Add the new chunk to the lists: */
- add_blocktolists(block,
- (struct BlockInfo *)((char *)block + size),
- othersize );
- }
- }
-
- /* Return the memory our parent may use: */
- return (char *)block+sizeof(struct BlockInfo);
- }
- else {
- bmalloc_failed(size);
- return NULL; /* can't find any memory, fail hard */
- }
- return NULL;
-}
-
-void bfree(void *ptr)
-{
- struct BlockInfo *block = (struct BlockInfo *)
- ((char *)ptr - sizeof(struct BlockInfo));
- size_t size;
-
- /* setup our initial higher and lower pointers */
- struct BlockInfo *lower = block->lower;
- struct BlockInfo *higher = block->higher;
-
-#ifdef DEBUG
- static int freecount=0;
- printf("%d bfree(%p)\n", freecount++, ptr);
-#endif
-
- /* bind together lower addressed FREE CHUNKS */
- if(lower && (lower->info&INFO_FREE) &&
- ((char *)lower + (lower->info&INFO_SIZE) == (char *)block)) {
- size = block->info&INFO_SIZE; /* original size */
-
- /* remove from size-link: */
- remove_chunksize((char *)lower+sizeof(struct BlockInfo));
-
- remove_block(block); /* unlink from address list */
- block = lower; /* new base area pointer */
- block->info += size; /* append the new size (the FREE bit
- will remain untouched) */
-
- lower = lower->lower; /* new lower pointer */
- }
- /* bind together higher addressed FREE CHUNKS */
- if(higher && (higher->info&INFO_FREE) &&
- ((char *)block + (block->info&INFO_SIZE) == (char *)higher)) {
- /* append higher size, the FREE bit won't be affected */
- block->info += (higher->info&INFO_SIZE);
-
- /* unlink from size list: */
- remove_chunksize((char *)higher+sizeof(struct BlockInfo));
- remove_block(higher); /* unlink from address list */
- higher = higher->higher; /* the new higher link */
- block->higher = higher; /* new higher link */
- }
- block->info |= INFO_FREE; /* consider this FREE! */
-
- block->lower = lower;
- block->higher = higher;
-
- insert_bysize((char *)block+sizeof(struct BlockInfo), block->info&INFO_SIZE);
-
-#ifdef DEBUG
- print_lists();
-#endif
-
-}
-
diff --git a/apps/plugins/pdbox/dbestfit-3.3/bmalloc.h b/apps/plugins/pdbox/dbestfit-3.3/bmalloc.h
index 4f77667290..550aa5a010 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/bmalloc.h
+++ b/apps/plugins/pdbox/dbestfit-3.3/bmalloc.h
@@ -3,10 +3,3 @@ void print_lists();
void *bmalloc(size_t size);
void bfree(void *ptr);
-
-int add_pool(void *start, size_t size);
-void print_lists();
-
-void *bmalloc(size_t size);
-void bfree(void *ptr);
-
diff --git a/apps/plugins/pdbox/dbestfit-3.3/bysize.c b/apps/plugins/pdbox/dbestfit-3.3/bysize.c
index 6808406dbc..85dc327491 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/bysize.c
+++ b/apps/plugins/pdbox/dbestfit-3.3/bysize.c
@@ -422,427 +422,3 @@ void print_sizes(void)
}
#endif
-/*****************************************************************************
- *
- * Size-sorted list/tree functions.
- *
- * Author: Daniel Stenberg
- * Date: March 7, 1997
- * Version: 2.0
- * Email: Daniel.Stenberg@sth.frontec.se
- *
- *
- * v2.0
- * - Added SPLAY TREE functionality.
- *
- * Adds and removes CHUNKS from a list or tree.
- *
- ****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define SPLAY /* we use the splay version as that is much faster */
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef SPLAY /* these routines are for the non-splay version */
-
-struct ChunkInfo {
- struct ChunkInfo *larger;
- struct ChunkInfo *smaller;
- size_t size;
-};
-
-/* the CHUNK list anchor */
-struct ChunkInfo *chunkHead=NULL;
-
-/***********************************************************************
-
- findchunkbysize()
-
- Find the chunk that is smaller than the input size. Returns
- NULL if none is.
-
- **********************************************************************/
-
-static struct ChunkInfo *findchunkbysize(size_t size)
-{
- struct ChunkInfo *test = chunkHead;
- struct ChunkInfo *smaller = NULL;
- while(test && (test->size < size)) {
- smaller = test;
- test = test->larger;
- }
- return smaller;
-}
-
-/***********************************************************************
-
- remove_chunksize()
-
- Remove the chunk from the size-sorted list.
- ***********************************************************************/
-
-void remove_chunksize(void *data)
-{
- struct ChunkInfo *chunk = (struct ChunkInfo *)data;
- if(chunk->smaller)
- chunk->smaller->larger = chunk->larger;
- else {
- /* if this has no smaller, this is the head */
- chunkHead = chunk->larger; /* new head */
- }
- if(chunk->larger)
- chunk->larger->smaller = chunk->smaller;
-}
-
-void insert_bysize(char *data, size_t size)
-{
- struct ChunkInfo *newchunk = (struct ChunkInfo *)data;
- struct ChunkInfo *chunk = findchunkbysize ( size );
-
- newchunk->size = size;
-
- if(chunk) {
- /* 'chunk' is smaller than size, append the new chunk ahead of this */
- newchunk->smaller = chunk;
- newchunk->larger = chunk->larger;
- if(chunk->larger)
- chunk->larger->smaller = newchunk;
- chunk->larger = newchunk;
- }
- else {
- /* smallest CHUNK around, append first in the list */
- newchunk->larger = chunkHead;
- newchunk->smaller = NULL;
-
- if(chunkHead)
- chunkHead->smaller = newchunk;
- chunkHead = newchunk;
- }
-}
-
-char *obtainbysize( size_t size)
-{
- struct ChunkInfo *chunk = findchunkbysize( size );
-
- if(!chunk) {
- if(size <= (chunkHead->size))
- /* there is no smaller CHUNK, use the first one (if we fit within that)
- */
- chunk = chunkHead;
- }
- else
- /* we're on the last CHUNK that is smaller than requested, step onto
- the bigger one */
- chunk = chunk->larger;
-
- if(chunk) {
- remove_chunksize( chunk ); /* unlink size-wise */
- return (char *)chunk;
- }
- else
- return NULL;
-}
-
-void print_sizes(void)
-{
- struct ChunkInfo *chunk = chunkHead;
- printf("List of CHUNKS (in size order):\n");
-#if 1
- while(chunk) {
- printf(" START %p END %p SIZE %d\n",
- chunk, (char *)chunk+chunk->size, chunk->size);
- chunk = chunk->larger;
- }
-#endif
- printf("End of CHUNKS:\n");
-}
-
-#else /* Here follows all routines dealing with the SPLAY TREES */
-
-typedef struct tree_node Tree;
-struct tree_node {
- Tree *smaller; /* smaller node */
- Tree *larger; /* larger node */
- Tree *same; /* points to a node with identical key */
- int key; /* the "sort" key */
-};
-
-Tree *chunkHead = NULL; /* the root */
-
-#define compare(i,j) ((i)-(j))
-
-/* Set this to a key value that will *NEVER* appear otherwise */
-#define KEY_NOTUSED -1
-
-/*
- * Splay using the key i (which may or may not be in the tree.) The starting
- * root is t. Weight fields are maintained.
- */
-Tree * splay (int i, Tree *t)
-{
- Tree N, *l, *r, *y;
- int comp;
-
- if (t == NULL)
- return t;
- N.smaller = N.larger = NULL;
- l = r = &N;
-
- for (;;) {
- comp = compare(i, t->key);
- if (comp < 0) {
- if (t->smaller == NULL)
- break;
- if (compare(i, t->smaller->key) < 0) {
- y = t->smaller; /* rotate smaller */
- t->smaller = y->larger;
- y->larger = t;
-
- t = y;
- if (t->smaller == NULL)
- break;
- }
- r->smaller = t; /* link smaller */
- r = t;
- t = t->smaller;
- }
- else if (comp > 0) {
- if (t->larger == NULL)
- break;
- if (compare(i, t->larger->key) > 0) {
- y = t->larger; /* rotate larger */
- t->larger = y->smaller;
- y->smaller = t;
- t = y;
- if (t->larger == NULL)
- break;
- }
- l->larger = t; /* link larger */
- l = t;
- t = t->larger;
- }
- else {
- break;
- }
- }
-
- l->larger = r->smaller = NULL;
-
- l->larger = t->smaller; /* assemble */
- r->smaller = t->larger;
- t->smaller = N.larger;
- t->larger = N.smaller;
-
- return t;
-}
-
-/* Insert key i into the tree t. Return a pointer to the resulting tree or
- NULL if something went wrong. */
-Tree *insert(int i, Tree *t, Tree *new)
-{
- if (new == NULL) {
- return t;
- }
-
- if (t != NULL) {
- t = splay(i,t);
- if (compare(i, t->key)==0) {
- /* it already exists one of this size */
-
- new->same = t;
- new->key = i;
- new->smaller = t->smaller;
- new->larger = t->larger;
-
- t->smaller = new;
- t->key = KEY_NOTUSED;
-
- return new; /* new root node */
- }
- }
-
- if (t == NULL) {
- new->smaller = new->larger = NULL;
- }
- else if (compare(i, t->key) < 0) {
- new->smaller = t->smaller;
- new->larger = t;
- t->smaller = NULL;
- }
- else {
- new->larger = t->larger;
- new->smaller = t;
- t->larger = NULL;
- }
- new->key = i;
-
- new->same = NULL; /* no identical node (yet) */
-
- return new;
-}
-
-/* Finds and deletes the best-fit node from the tree. Return a pointer to the
- resulting tree. best-fit means the smallest node that fits the requested
- size. */
-Tree *removebestfit(int i, Tree *t, Tree **removed)
-{
- Tree *x;
-
- if (t==NULL)
- return NULL;
- t = splay(i,t);
- if(compare(i, t->key) > 0) {
- /* too small node, try the larger chain */
- if(t->larger)
- t=splay(t->larger->key, t);
- else {
- /* fail */
- *removed = NULL;
- return t;
- }
- }
-
- if (compare(i, t->key) <= 0) { /* found it */
-
- /* FIRST! Check if there is a list with identical sizes */
- x = t->same;
- if(x) {
- /* there is, pick one from the list */
-
- /* 'x' is the new root node */
-
- x->key = t->key;
- x->larger = t->larger;
- x->smaller = t->smaller;
- *removed = t;
- return x; /* new root */
- }
-
- if (t->smaller == NULL) {
- x = t->larger;
- }
- else {
- x = splay(i, t->smaller);
- x->larger = t->larger;
- }
- *removed = t;
-
- return x;
- }
- else {
- *removed = NULL; /* no match */
- return t; /* It wasn't there */
- }
-}
-
-
-/* Deletes the node we point out from the tree if it's there. Return a pointer
- to the resulting tree. */
-Tree *removebyaddr(Tree *t, Tree *remove)
-{
- Tree *x;
-
- if (!t || !remove)
- return NULL;
-
- if(KEY_NOTUSED == remove->key) {
- /* just unlink ourselves nice and quickly: */
- remove->smaller->same = remove->same;
- if(remove->same)
- remove->same->smaller = remove->smaller;
- /* voila, we're done! */
- return t;
- }
-
- t = splay(remove->key,t);
-
- /* Check if there is a list with identical sizes */
-
- x = t->same;
- if(x) {
- /* 'x' is the new root node */
-
- x->key = t->key;
- x->larger = t->larger;
- x->smaller = t->smaller;
-
- return x; /* new root */
- }
-
- /* Remove the actualy root node: */
-
- if (t->smaller == NULL) {
- x = t->larger;
- }
- else {
- x = splay(remove->key, t->smaller);
- x->larger = t->larger;
- }
-
- return x;
-}
-
-int printtree(Tree * t, int d, char output)
-{
- int distance=0;
- Tree *node;
- int i;
- if (t == NULL)
- return 0;
- distance += printtree(t->larger, d+1, output);
- for (i=0; i<d; i++)
- if(output)
- printf(" ");
-
- if(output) {
- printf("%d[%d]", t->key, i);
- }
-
- for(node = t->same; node; node = node->same) {
- distance += i; /* this has the same "virtual" distance */
-
- if(output)
- printf(" [+]");
- }
- if(output)
- puts("");
-
- distance += i;
- distance += printtree(t->smaller, d+1, output);
- return distance;
-}
-
-/* Here follow the look-alike interface so that the tree-function names are
- the same as the list-ones to enable easy interchange */
-
-void remove_chunksize(void *data)
-{
- chunkHead = removebyaddr(chunkHead, data);
-}
-
-void insert_bysize(char *data, size_t size)
-{
- chunkHead = insert(size, chunkHead, (Tree *)data);
-}
-
-char *obtainbysize( size_t size)
-{
- Tree *receive;
- chunkHead = removebestfit(size, chunkHead, &receive);
- return (char *)receive;
-}
-
-void print_sizes(void)
-{
- printtree(chunkHead, 0, 1);
-}
-
-#endif
diff --git a/apps/plugins/pdbox/dbestfit-3.3/bysize.h b/apps/plugins/pdbox/dbestfit-3.3/bysize.h
index 2fbf23154d..877e2ea4c5 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/bysize.h
+++ b/apps/plugins/pdbox/dbestfit-3.3/bysize.h
@@ -2,7 +2,3 @@ void remove_chunksize(void *data);
void insert_bysize(char *data, size_t size);
char *obtainbysize( size_t size);
void print_sizes(void);
-void remove_chunksize(void *data);
-void insert_bysize(char *data, size_t size);
-char *obtainbysize( size_t size);
-void print_sizes(void);
diff --git a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c
index 9336276883..6ce38cced0 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c
+++ b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c
@@ -688,693 +688,3 @@ dcalloc (size_t nmemb, size_t size)
return result;
}
-/*****************************************************************************
- *
- * Dynamic Memory Allocation
- *
- * Author: Daniel Stenberg
- * Date: March 10, 1997
- * Version: 2.3
- * Email: Daniel.Stenberg@sth.frontec.se
- *
- *
- * Read 'thoughts' for theories and details of this implementation.
- *
- * v2.1
- * - I once again managed to gain some memory. BLOCK allocations now only use
- * a 4 bytes header (instead of previos 8) just as FRAGMENTS.
- *
- * v2.2
- * - Re-adjusted the fragment sizes to better fit into the somewhat larger
- * block.
- *
- * v2.3
- * - Made realloc(NULL, size) work as it should. Which is like a malloc(size)
- *
- *****************************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef DEBUG
-#include <stdarg.h>
-#endif
-
-#ifdef PSOS
-#include <psos.h>
-#define SEMAPHORE /* the PSOS routines use semaphore protection */
-#else
-#include <stdlib.h> /* makes the PSOS complain on the 'size_t' typedef */
-#endif
-
-#ifdef BMALLOC
-#include "bmalloc.h"
-#endif
-
-/* Each TOP takes care of a chain of BLOCKS */
-struct MemTop {
- struct MemBlock *chain; /* pointer to the BLOCK chain */
- long nfree; /* total number of free FRAGMENTS in the chain */
- short nmax; /* total number of FRAGMENTS in this kind of BLOCK */
- size_t fragsize; /* the size of each FRAGMENT */
-
-#ifdef SEMAPHORE /* if we're protecting the list with SEMAPHORES */
- long semaphore_id; /* semaphore used to lock this particular list */
-#endif
-
-};
-
-/* Each BLOCK takes care of an amount of FRAGMENTS */
-struct MemBlock {
- struct MemTop *top; /* our TOP struct */
- struct MemBlock *next; /* next BLOCK */
- struct MemBlock *prev; /* prev BLOCK */
-
- struct MemFrag *first; /* the first free FRAGMENT in this block */
-
- short nfree; /* number of free FRAGMENTS in this BLOCK */
-};
-
-/* This is the data kept in all _free_ FRAGMENTS */
-struct MemFrag {
- struct MemFrag *next; /* next free FRAGMENT */
- struct MemFrag *prev; /* prev free FRAGMENT */
-};
-
-/* This is the data kept in all _allocated_ FRAGMENTS and BLOCKS. We add this
- to the allocation size first thing in the ALLOC function to make room for
- this smoothly. */
-
-struct MemInfo {
- void *block;
- /* which BLOCK is our father, if BLOCK_BIT is set it means this is a
- stand-alone, large allocation and then the rest of the bits should be
- treated as the size of the block */
-#define BLOCK_BIT 1
-};
-
-/* ---------------------------------------------------------------------- */
-/* Defines */
-/* ---------------------------------------------------------------------- */
-
-#ifdef DEBUG
-#define MEMINCR(addr,x) memchange(addr, x)
-#define MEMDECR(addr,x) memchange(addr,-(x))
-#else
-#define MEMINCR(a,x)
-#define MEMDECR(a,x)
-#endif
-
-/* The low level functions used to get memory from the OS and to return memory
- to the OS, we may also define a stub that does the actual allocation and
- free, these are the defined function names used in the dmalloc system
- anyway: */
-#ifdef PSOS
-
-#ifdef DEBUG
-#define DMEM_OSALLOCMEM(size,pointer,type) pointer=(type)dbgmalloc(size)
-#define DMEM_OSFREEMEM(x) dbgfree(x)
-#else
-#define DMEM_OSALLOCMEM(size,pointer,type) rn_getseg(0,size,RN_NOWAIT,0,(void **)&pointer)
-/* Similar, but this returns the memory */
-#define DMEM_OSFREEMEM(x) rn_retseg(0, x)
-#endif
-
-/* Argument: <id> */
-#define SEMAPHOREOBTAIN(x) sm_p(x, SM_WAIT, 0)
-/* Argument: <id> */
-#define SEMAPHORERETURN(x) sm_v(x)
-/* Argument: <name> <id-variable name> */
-#define SEMAPHORECREATE(x,y) sm_create(x, 1, SM_FIFO, (ULONG *)&(y))
-
-#else
-#ifdef BMALLOC /* use our own big-memory-allocation system */
-#define DMEM_OSALLOCMEM(size,pointer,type) pointer=(type)bmalloc(size)
-#define DMEM_OSFREEMEM(x) bfree(x)
-#elif DEBUG
-#define DMEM_OSALLOCMEM(size,pointer,type) pointer=(type)dbgmalloc(size)
-#define DMEM_OSFREEMEM(x) dbgfree(x)
-#else
-#define DMEM_OSALLOCMEM(size,pointer,type) pointer=(type)malloc(size)
-#define DMEM_OSFREEMEM(x) free(x)
-#endif
-#endif
-
-
-/* the largest memory allocation that is made a FRAGMENT: (grab the highest
- number from the list below) */
-#define DMEM_LARGESTSIZE 2032
-
-/* The total size of a BLOCK used for FRAGMENTS
- In order to make this use only *1* even alignment from the big-block-
- allocation-system (possible the bmalloc() system also written by me)
- we need to subtract the [maximum] struct sizes that could get added all
- the way through to the grab from the memory. */
-#define DMEM_BLOCKSIZE 4064 /* (4096 - sizeof(struct MemBlock) - 12) */
-
-/* Since the blocksize isn't an even 2^X story anymore, we make a table with
- the FRAGMENT sizes and amounts that fills up a BLOCK nicely */
-
-/* a little 'bc' script that helps us maximize the usage:
- - for 32-bit aligned addresses (SPARC crashes otherwise):
- for(i=20; i<2040; i++) { a=4064/i; if(a*i >= 4060) { if(i%4==0) {i;} } }
-
-
- I try to approximate a double of each size, starting with ~20. We don't do
- ODD sizes since several CPU flavours dump core when accessing such
- addresses. We try to do 32-bit aligned to make ALL kinds of CPUs to remain
- happy with us.
- */
-
-#if BIGBLOCKS==4060 /* previously */
-short qinfo[]= { 20, 28, 52, 116, 312, 580, 812, 2028 };
-#else
-short qinfo[]= { 20, 28, 52, 116, 312, 580, 1016, 2032};
-/* 52 and 312 only make use of 4056 bytes, but without them there are too
- wide gaps */
-#endif
-
-#define MIN(x,y) ((x)<(y)?(x):(y))
-
-/* ---------------------------------------------------------------------- */
-/* Globals */
-/* ---------------------------------------------------------------------- */
-
-/* keeper of the chain of BLOCKS */
-static struct MemTop top[ sizeof(qinfo)/sizeof(qinfo[0]) ];
-
-/* are we experienced? */
-static char initialized = 0;
-
-/* ---------------------------------------------------------------------- */
-/* Start of the real code */
-/* ---------------------------------------------------------------------- */
-
-#ifdef DEBUG
-/************
- * A few functions that are verbose and tells us about the current status
- * of the dmalloc system
- ***********/
-
-static void dmalloc_status()
-{
- int i;
- int used;
- int num;
- int totalfree=0;
- struct MemBlock *block;
- for(i=0; i<sizeof(qinfo)/sizeof(qinfo[0]);i++) {
- block = top[i].chain;
- used = 0;
- num = 0;
- while(block) {
- used += top[i].nmax-block->nfree;
- num++;
- block = block->next;
- }
- printf("Q %d (FRAG %4d), USED %4d FREE %4ld (SIZE %4ld) BLOCKS %d\n",
- i, top[i].fragsize, used, top[i].nfree,
- top[i].nfree*top[i].fragsize, num);
- totalfree += top[i].nfree*top[i].fragsize;
- }
- printf("Total unused memory stolen by dmalloc: %d\n", totalfree);
-}
-
-static void dmalloc_failed(size_t size)
-{
- printf("*** " __FILE__ " Couldn't allocate %d bytes\n", size);
- dmalloc_status();
-}
-#else
-#define dmalloc_failed(x)
-#endif
-
-#ifdef DEBUG
-
-#define BORDER 1200
-
-void *dbgmalloc(int size)
-{
- char *mem;
- size += BORDER;
-#ifdef PSOS
- rn_getseg(0,size,RN_NOWAIT,0,(void **)&mem);
-#else
- mem = malloc(size);
-#endif
- if(mem) {
- memset(mem, 0xaa, BORDER/2);
- memset(mem+BORDER/2, 0xbb, size -BORDER);
- memset(mem-BORDER/2+size, 0xcc, BORDER/2);
- *(long *)mem = size;
- mem += (BORDER/2);
- }
- printf("OSmalloc(%p)\n", mem);
- return (void *)mem;
-}
-
-void checkmem(char *ptr)
-{
- int i;
- long size;
- ptr -= BORDER/2;
-
- for(i=4; i<(BORDER/2); i++)
- if((unsigned char)ptr[i] != 0xaa) {
- printf("########### ALERT ALERT\n");
- break;
- }
- size = *(long *)ptr;
- for(i=size-1; i>=(size - BORDER/2); i--)
- if((unsigned char)ptr[i] != 0xcc) {
- printf("********* POST ALERT\n");
- break;
- }
-}
-
-void dbgfree(char *ptr)
-{
- long size;
- checkmem(ptr);
- ptr -= BORDER/2;
- size = *(long *)ptr;
-
- printf("OSfree(%ld)\n", size);
-#ifdef PSOS
- rn_retseg(0, ptr);
-#else
- free(ptr);
-#endif
-}
-
-
-#define DBG(x) syslog x
-
-void syslog(char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stdout, fmt, ap);
- va_end(ap);
-}
-
-void memchange(void *a, int x)
-{
- static int memory=0;
- static int count=0;
- static int max=0;
- if(memory > max)
- max = memory;
- memory += x;
- DBG(("%d. PTR %p / %d TOTAL %d MAX %d\n", ++count, a, x, memory, max));
-}
-#else
-#define DBG(x)
-#endif
-
-/****************************************************************************
- *
- * FragBlock()
- *
- * This function makes FRAGMENTS of the BLOCK sent as argument.
- *
- ***************************************************************************/
-
-static void FragBlock(char *memp, int size)
-{
- struct MemFrag *frag=(struct MemFrag *)memp;
- struct MemFrag *prev=NULL; /* no previous in the first round */
- int count=0;
- while((count+size) <= DMEM_BLOCKSIZE) {
- memp += size;
- frag->next = (struct MemFrag *)memp;
- frag->prev = prev;
- prev = frag;
- frag = frag->next;
- count += size;
- }
- prev->next = NULL; /* the last one has no next struct */
-}
-
-/***************************************************************************
- *
- * initialize();
- *
- * Called in the first dmalloc(). Inits a few memory things.
- *
- **************************************************************************/
-static void initialize(void)
-{
- int i;
- /* Setup the nmax and fragsize fields of the top structs */
- for(i=0; i< sizeof(qinfo)/sizeof(qinfo[0]); i++) {
- top[i].fragsize = qinfo[i];
- top[i].nmax = DMEM_BLOCKSIZE/qinfo[i];
-
-#ifdef PSOS
- /* for some reason, these aren't nulled from start: */
- top[i].chain = NULL; /* no BLOCKS */
- top[i].nfree = 0; /* no FRAGMENTS */
-#endif
-#ifdef SEMAPHORE
- {
- char name[7];
- sprintf(name, "MEM%d", i);
- SEMAPHORECREATE(name, top[i].semaphore_id);
- /* doesn't matter if it failed, we continue anyway ;-( */
- }
-#endif
- }
- initialized = 1;
-}
-
-/****************************************************************************
- *
- * FragFromBlock()
- *
- * This should return a fragment from the block and mark it as used
- * accordingly.
- *
- ***************************************************************************/
-
-static void *FragFromBlock(struct MemBlock *block)
-{
- /* make frag point to the first free FRAGMENT */
- struct MemFrag *frag = block->first;
- struct MemInfo *mem = (struct MemInfo *)frag;
-
- /*
- * Remove the FRAGMENT from the list and decrease the free counters.
- */
- block->first = frag->next; /* new first free FRAGMENT */
-
- block->nfree--; /* BLOCK counter */
- block->top->nfree--; /* TOP counter */
-
- /* heal the FRAGMENT list */
- if(frag->prev) {
- frag->prev->next = frag->next;
- }
- if(frag->next) {
- frag->next->prev = frag->prev;
- }
- mem->block = block; /* no block bit set here */
-
- return ((char *)mem)+sizeof(struct MemInfo);
-}
-
-/***************************************************************************
- *
- * dmalloc()
- *
- * This needs no explanation. A malloc() look-alike.
- *
- **************************************************************************/
-
-void *dmalloc(size_t size)
-{
- void *mem;
-
- DBG(("dmalloc(%d)\n", size));
-
- if(!initialized)
- initialize();
-
- /* First, we make room for the space needed in every allocation */
- size += sizeof(struct MemInfo);
-
- if(size < DMEM_LARGESTSIZE) {
- /* get a FRAGMENT */
-
- struct MemBlock *block=NULL; /* SAFE */
- struct MemBlock *newblock=NULL; /* SAFE */
- struct MemTop *memtop=NULL; /* SAFE */
-
- /* Determine which queue to use */
- int queue;
- for(queue=0; size > qinfo[queue]; queue++)
- ;
- do {
- /* This is the head master of our chain: */
- memtop = &top[queue];
-
- DBG(("Top info: %p %d %d %d\n",
- memtop->chain,
- memtop->nfree,
- memtop->nmax,
- memtop->fragsize));
-
-#ifdef SEMAPHORE
- if(SEMAPHOREOBTAIN(memtop->semaphore_id))
- return NULL; /* failed somehow */
-#endif
-
- /* get the first BLOCK in the chain */
- block = memtop->chain;
-
- /* check if we have a free FRAGMENT */
- if(memtop->nfree) {
- /* there exists a free FRAGMENT in this chain */
-
- /* I WANT THIS LOOP OUT OF HERE! */
-
- /* search for the free FRAGMENT */
- while(!block->nfree)
- block = block->next; /* check next BLOCK */
-
- /*
- * Now 'block' is the first BLOCK with a free FRAGMENT
- */
-
- mem = FragFromBlock(block);
-
- }
- else {
- /* we do *not* have a free FRAGMENT but need to get us a new BLOCK */
-
- DMEM_OSALLOCMEM(DMEM_BLOCKSIZE + sizeof(struct MemBlock),
- newblock,
- struct MemBlock *);
- if(!newblock) {
- if(++queue < sizeof(qinfo)/sizeof(qinfo[0])) {
- /* There are queues for bigger FRAGMENTS that we should check
- before we fail this for real */
-#ifdef DEBUG
- printf("*** " __FILE__ " Trying a bigger Q: %d\n", queue);
-#endif
- mem = NULL;
- }
- else {
- dmalloc_failed(size- sizeof(struct MemInfo));
- return NULL; /* not enough memory */
- }
- }
- else {
- /* allocation of big BLOCK was successful */
-
- MEMINCR(newblock, DMEM_BLOCKSIZE + sizeof(struct MemBlock));
-
- memtop->chain = newblock; /* attach this BLOCK to the chain */
- newblock->next = block; /* point to the previous first BLOCK */
- if(block)
- block->prev = newblock; /* point back on this new BLOCK */
- newblock->prev = NULL; /* no previous */
- newblock->top = memtop; /* our head master */
-
- /* point to the new first FRAGMENT */
- newblock->first = (struct MemFrag *)
- ((char *)newblock+sizeof(struct MemBlock));
-
- /* create FRAGMENTS of the BLOCK: */
- FragBlock((char *)newblock->first, memtop->fragsize);
-
-#if defined(DEBUG) && !defined(BMALLOC)
- checkmem((char *)newblock);
-#endif
-
- /* fix the nfree counters */
- newblock->nfree = memtop->nmax;
- memtop->nfree += memtop->nmax;
-
- /* get a FRAGMENT from the BLOCK */
- mem = FragFromBlock(newblock);
- }
- }
-#ifdef SEMAPHORE
- SEMAPHORERETURN(memtop->semaphore_id); /* let it go */
-#endif
- } while(NULL == mem); /* if we should retry a larger FRAGMENT */
- }
- else {
- /* get a stand-alone BLOCK */
- struct MemInfo *meminfo;
-
- if(size&1)
- /* don't leave this with an odd size since we'll use that bit for
- information */
- size++;
-
- DMEM_OSALLOCMEM(size, meminfo, struct MemInfo *);
-
- if(meminfo) {
- MEMINCR(meminfo, size);
- meminfo->block = (void *)(size|BLOCK_BIT);
- mem = (char *)meminfo + sizeof(struct MemInfo);
- }
- else {
- dmalloc_failed(size);
- mem = NULL;
- }
- }
- return (void *)mem;
-}
-
-/***************************************************************************
- *
- * dfree()
- *
- * This needs no explanation. A free() look-alike.
- *
- **************************************************************************/
-
-void dfree(void *memp)
-{
- struct MemInfo *meminfo = (struct MemInfo *)
- ((char *)memp- sizeof(struct MemInfo));
-
- DBG(("dfree(%p)\n", memp));
-
- if(!((size_t)meminfo->block&BLOCK_BIT)) {
- /* this is a FRAGMENT we have to deal with */
-
- struct MemBlock *block=meminfo->block;
- struct MemTop *memtop = block->top;
-
-#ifdef SEMAPHORE
- SEMAPHOREOBTAIN(memtop->semaphore_id);
-#endif
-
- /* increase counters */
- block->nfree++;
- memtop->nfree++;
-
- /* is this BLOCK completely empty now? */
- if(block->nfree == memtop->nmax) {
- /* yes, return the BLOCK to the system */
- if(block->prev)
- block->prev->next = block->next;
- else
- memtop->chain = block->next;
- if(block->next)
- block->next->prev = block->prev;
-
- memtop->nfree -= memtop->nmax; /* total counter subtraction */
- MEMDECR(block, DMEM_BLOCKSIZE + sizeof(struct MemBlock));
- DMEM_OSFREEMEM((void *)block); /* return the whole block */
- }
- else {
- /* there are still used FRAGMENTS in the BLOCK, link this one
- into the chain of free ones */
- struct MemFrag *frag = (struct MemFrag *)meminfo;
- frag->prev = NULL;
- frag->next = block->first;
- if(block->first)
- block->first->prev = frag;
- block->first = frag;
- }
-#ifdef SEMAPHORE
- SEMAPHORERETURN(memtop->semaphore_id);
-#endif
- }
- else {
- /* big stand-alone block, just give it back to the OS: */
- MEMDECR(&meminfo->block, (size_t)meminfo->block&~BLOCK_BIT); /* clean BLOCK_BIT */
- DMEM_OSFREEMEM((void *)meminfo);
- }
-}
-
-/***************************************************************************
- *
- * drealloc()
- *
- * This needs no explanation. A realloc() look-alike.
- *
- **************************************************************************/
-
-void *drealloc(char *ptr, size_t size)
-{
- struct MemInfo *meminfo = (struct MemInfo *)
- ((char *)ptr- sizeof(struct MemInfo));
- /*
- * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- * NOTE: the ->size field of the meminfo will now contain the MemInfo
- * struct size too!
- * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
- void *mem=NULL; /* SAFE */
- size_t prevsize;
-
- /* NOTE that this is only valid if BLOCK_BIT isn't set: */
- struct MemBlock *block;
-
- DBG(("drealloc(%p, %d)\n", ptr, size));
-
- if(NULL == ptr)
- return dmalloc( size );
-
- block = meminfo->block;
-
- if(!((size_t)meminfo->block&BLOCK_BIT) &&
- (size + sizeof(struct MemInfo) <
- (prevsize = block->top->fragsize) )) {
- /* This is a FRAGMENT and new size is possible to retain within the same
- FRAGMENT */
- if((prevsize > qinfo[0]) &&
- /* this is not the smallest memory Q */
- (size < (block->top-1)->fragsize))
- /* this fits in a smaller Q */
- ;
- else
- mem = ptr; /* Just return the same pointer as we got in. */
- }
- if(!mem) {
- /* This is a stand-alone BLOCK or a realloc that no longer fits within
- the same FRAGMENT */
-
- if((size_t)meminfo->block&BLOCK_BIT) {
- prevsize = ((size_t)meminfo->block&~BLOCK_BIT) -
- sizeof(struct MemInfo);
- }
- else
- prevsize -= sizeof(struct MemInfo);
-
- /* No tricks involved here, just grab a new bite of memory, copy the data
- * from the old place and free the old memory again. */
- mem = dmalloc(size);
- if(mem) {
- memcpy(mem, ptr, MIN(size, prevsize) );
- dfree(ptr);
- }
- }
- return mem;
-}
-
-/***************************************************************************
- *
- * dcalloc()
- *
- * This needs no explanation. A calloc() look-alike.
- *
- **************************************************************************/
-/* Allocate an array of NMEMB elements each SIZE bytes long.
- The entire array is initialized to zeros. */
-void *
-dcalloc (size_t nmemb, size_t size)
-{
- void *result = dmalloc (nmemb * size);
-
- if (result != NULL)
- memset (result, 0, nmemb * size);
-
- return result;
-}
diff --git a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.h b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.h
index 053b3a114b..9921e3b94a 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.h
+++ b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.h
@@ -1,12 +1,3 @@
-
-void *dmalloc(size_t);
-void dfree(void *);
-void *drealloc(void *, size_t);
-
-#define malloc(x) dmalloc(x)
-#define free(x) dfree(x)
-#define realloc(x,y) drealloc(x,y)
-
void *dmalloc(size_t);
void dfree(void *);
void *drealloc(void *, size_t);
diff --git a/apps/plugins/pdbox/dbestfit-3.3/dmytest.c b/apps/plugins/pdbox/dbestfit-3.3/dmytest.c
index 46d4c73efd..ed12686b3d 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/dmytest.c
+++ b/apps/plugins/pdbox/dbestfit-3.3/dmytest.c
@@ -136,141 +136,3 @@ int main(int argc, char **argv)
#endif
return 0;
}
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "dmalloc.h"
-
-#define MAX 500
-#define MAX2 1000
-#define MAXC 2
-
-#define TESTA
-#define TESTB
-#define TESTC
-#define TESTD
-
-int main(int argc, char **argv)
-{
- int i;
- int memory = 0;
-
-#ifdef BMALLOC
-#define HEAP 10000
- void *heap = (malloc)(HEAP);
- if(!heap)
- return -1;
- add_pool(heap, HEAP);
-#endif
-
- {
-#define MAXK 100
- void *wow[MAXK];
- wow[0]=malloc(700);
- realloc(wow[0], 680);
- return 0;
-
- for(i=0; i<MAXK; i++)
- if(!(wow[i]=malloc(412))) {
- printf("*** Couldn't allocated memory, exiting\n");
- return -2;
- }
- for(i=MAXK-1; i>=0; i-=2)
- free(wow[i]);
- return 0;
- }
-
-
-#ifdef TESTD
- {
-#define MAXS 10
-#define MAXS1 0
- void *ptr[MAXS];
-
- for(i=MAXS1; i< MAXS; i++) {
- printf("%d malloc(%d)\n", i, i*55);
- ptr[i] = malloc (i*55);
- }
- for(i=MAXS1; i< MAXS; i++) {
- void *tmp;
- printf("%d realloc(%d)\n", i, i*155);
- tmp=realloc(ptr[i], i*155);
- if(tmp)
- ptr[i] = tmp;
- }
- for(i=MAXS1; i< MAXS; i++) {
- printf("%d free(%d)\n", i, i*155);
- free(ptr[i]);
- }
- }
-#endif
-
-#ifdef TESTC
- {
- void *ptr[MAXC];
- printf("This is test C:\n");
-
- for(i=0; i< MAXC; i++) {
- printf("%d malloc(100)\n", i+1);
- ptr[i] = malloc(100);
- printf(" ...returned %p\n", ptr[i]);
- }
-
- for(i=0; i< MAXC; i++) {
- printf("%d free()\n", i+1);
- free(ptr[i]);
- }
-
- printf("End of test C:\n");
- }
-#endif
-
-#ifdef TESTA
- {
- void *pointers[MAX];
- printf("This is test I:\n");
-
- for(i=0; i<MAX; i++) {
- printf("%d attempts malloc(%d)\n", i, i*6);
- pointers[i]=malloc(i*6);
- if(!pointers[i]) {
- printf("cant get more memory!");
- return(0);
- }
- memory += (i*6);
- }
- printf("\namount: %d\n", memory);
- memory = 0;
- for(i=0; i<MAX; i++) {
- printf("%d attempts realloc(%d)\n", i, i*7);
- pointers[i]=realloc(pointers[i], i*7);
- memory += i*7;
- }
- printf("\namount: %d\n", memory);
- for(i=0; i<MAX; i++) {
- printf("%d attempts free(%d)\n", i, i*7);
- free(pointers[i]);
- }
- printf("\nend of test 1\n");
- }
-#endif
-#ifdef TESTB
- {
- void *pointers2[MAX2];
- memory = 0;
- printf("\nTest II\n");
- for(i=0; i< MAX2; i++) {
-/* printf("%d attempts malloc(%d)\n", i, 7); */
- pointers2[i] = malloc(7);
- memory += 7;
- }
- printf("\namount: %d\n", memory);
- for(i=0; i< MAX2; i++) {
- free(pointers2[i]);
- }
- printf("\nend of test II\n");
-
- }
-#endif
- return 0;
-}
diff --git a/apps/plugins/pdbox/dbestfit-3.3/malloc.man b/apps/plugins/pdbox/dbestfit-3.3/malloc.man
index 79f6f3ea37..8b6e3dbea5 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/malloc.man
+++ b/apps/plugins/pdbox/dbestfit-3.3/malloc.man
@@ -93,98 +93,3 @@ BUGS
call to malloc(), calloc() or realloc(), a degradation of
performance results. The semantics of free() should be changed
so that the contents of a previously freed block are undefined.
-MALLOC(3V) C LIBRARY FUNCTIONS MALLOC(3V)
-
-
-NAME
- malloc, free, realloc, calloc
-
-SYNOPSIS
- #include <malloc.h>
-
- void *malloc(size)
- size_t size;
-
- void free(ptr)
- void *ptr;
-
- void *realloc(ptr, size)
- void *ptr;
- size_t size;
-
- void *calloc(nelem, elsize)
- size_t nelem;
- size_t elsize;
-
-DESCRIPTION
- These routines provide a general-purpose memory allocation
- package. They maintain a table of free blocks for efficient
- allocation and coalescing of free storage. When there is no
- suitable space already free, the allocation routines call
- rn_getseg() to get more memory from the system.
-
- Each of the allocation routines returns a pointer to space
- suitably aligned for storage of any type of object. Each
- returns a NULL pointer if the request cannot be completed
- (see DIAGNOSTICS).
-
- malloc() returns a pointer to a block of at least size
- bytes, which is appropriately aligned.
-
- free() releases a previously allocated block. Its argument
- is a pointer to a block previously allocated by malloc(),
- calloc() or realloc().
-
- realloc() changes the size of the block referenced by ptr to
- size bytes and returns a pointer to the (possibly moved)
- block. The contents will be unchanged up to the lesser of
- the new and old sizes. If unable to honor a reallocation
- request, realloc() leaves its first argument unaltered.
-
- **** DMALLOC DOES NOT COMPLY WITH THE PARAGRAPH BELOW ****
-
- For backwards compatibility, realloc() accepts a pointer to a
- block freed since the most recent call to malloc(), cal-
- loc() or realloc().
-
- Note: using realloc() with a block freed before the most recent
- call to malloc(), calloc() or realloc() is an error.
-
- calloc() uses malloc() to allocate space for an array of
- nelem elements of size elsize, initializes the space to
- zeros, and returns a pointer to the initialized block. The
- block should be freed with free().
-
-
- malloc() and realloc() return a non- NULL pointer if size is 0,
- and calloc() returns a non-NULL pointer if nelem or elsize is 0,
- but these pointers should not be dereferenced.
-
- Note: Always cast the value returned by malloc(), realloc() or
- calloc().
-
-
-RETURN VALUES On success, malloc(), calloc() and realloc() return a
- pointer to space suitably aligned for storage of any type of
- object. On failure, they return NULL.
-
- free() does not return a value.
-
-
-NOTES
- Because malloc() and realloc() return a non-NULL pointer if size
- is 0, and calloc() returns a non-NULL pointer if nelem or elsize
- is 0, a zero size need not be treated as a special case if it
- should be passed to these functions unpredictably. Also, the
- pointer returned by these functions may be passed to subsequent
- invocations of realloc().
-
-
-BUGS
-
- **** DMALLOC DOES NOT COMPLY WITH THE PARAGRAPH BELOW ****
-
- Since realloc() accepts a pointer to a block freed since the last
- call to malloc(), calloc() or realloc(), a degradation of
- performance results. The semantics of free() should be changed
- so that the contents of a previously freed block are undefined.
diff --git a/apps/plugins/pdbox/dbestfit-3.3/mytest.c b/apps/plugins/pdbox/dbestfit-3.3/mytest.c
index bf338b72ef..80407dee00 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/mytest.c
+++ b/apps/plugins/pdbox/dbestfit-3.3/mytest.c
@@ -1,74 +1,3 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "bmalloc.h"
-
-int main(int argc, char **argv)
-{
- void *pointers[5];
- int i;
- void *area;
-
- for(i=0; i<5; i++)
- pointers[i] = malloc(8000);
-
- if(argc>1) {
- switch(argv[1][0]) {
- case '1':
- for(i=0; i<5; i++) {
- add_pool(pointers[i], 4000);
- add_pool((char *)pointers[i]+4000, 4000);
- }
- break;
- case '2':
- area = malloc(20000);
- add_pool(area, 3000);
- add_pool((char *)area+6000, 3000);
- add_pool((char *)area+3000, 3000);
- add_pool((char *)area+12000, 3000);
- add_pool((char *)area+9000, 3000);
- break;
- case '3':
- {
- void *ptr[10];
- area = malloc(20000);
- add_pool(area, 20000);
-
- printf(" ** TEST USAGE\n");
- for(i=0; i<9; i++)
- ptr[i]=bmalloc(200);
- print_lists();
- for(i=0; i<9; i++)
- bfree(ptr[i]);
- printf(" ** END OF TEST USAGE\n");
- }
-
- break;
- case '4':
- {
- void *ptr[10];
- area = malloc(20000);
- add_pool(area, 20000);
-
- ptr[0]=bmalloc(4080);
- print_lists();
- bfree(ptr[0]);
- printf(" ** END OF TEST USAGE\n");
- }
-
- break;
- }
- }
- else
- for(i=4; i>=0; i--)
- add_pool(pointers[i], 8000-i*100);
-
- print_lists();
-
- return 0;
-}
-
#include <stdio.h>
#include <stdlib.h>
diff --git a/apps/plugins/pdbox/dbestfit-3.3/thoughts b/apps/plugins/pdbox/dbestfit-3.3/thoughts
index 8dbd8b9979..d509d36d2a 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/thoughts
+++ b/apps/plugins/pdbox/dbestfit-3.3/thoughts
@@ -168,173 +168,3 @@ MEMORY SYSTEM
* "A Memory Allocator" (Doug Lea)
http://g.oswego.edu/dl/html/malloc.html
- =====================================
- Memory Allocation Algorithm Theories.
- =====================================
-
-GOAL
- It is intended to be a 100% working memory allocation system. It should be
- capable of replacing an ordinary Operating System's own routines. It should
- work good in a multitasking, shared memory, non-virtual memory environment
- without clogging the memory. Primary aimed for small machines, CPUs and
- memory amounts.
-
- I use a best-fit algorithm with a slight overhead in order to increase speed
- a lot. It should remain scalable and work good with very large amount of
- memory and free/used memory blocks too.
-
-TERMINOLOGY
-
- FRAGMENT - small identically sized parts of a larger BLOCK, they are when
- travered in lists etc _not_ allocated.
- BLOCK - large memory area, if used for FRAGMENTS, they are linked in a
- lists. One list for each FRAGMENT size supported.
- TOP - head struct that holds information about and points to a chain
- of BLOCKS for a particular FRAGMENT size.
- CHUNK - a contiguous area of free memory
-
-MEMORY SYSTEM
-
- We split the system in two parts. One part allocates small memory amounts
- and one part allocates large memory amounts, but all allocations are done
- "through" the small-part-system. There is an option to use only the small
- system (and thus use the OS for large blocks) or the complete package.
-
-##############################################################################
- SMALL SIZE ALLOCATIONS
-##############################################################################
-
- Keywords for this system is 'Deferred Coalescing' and 'quick lists'.
-
- ALLOC
-
- * Small allocations are "aligned" upwards to a set of preset sizes. In the
- current implementation I use 20, 28, 52, 116, 312, 580, 812, 2028 bytes.
- Memory allocations of these sizes are refered to as FRAGMENTS.
- (The reason for these specific sizes is the requirement that they must be
- 32-bit aligned and fit as good as possible within 4060 bytes.)
-
- * Allocations larger than 2028 will get a BLOCK for that allocation only.
-
- * Each of these sizes has it's own TOP. When a FRAGMENT is requested, a
- larger BLOCK will be allocated and divided into many FRAGMENTS (all of the
- same size). TOP points to a list with BLOCKS that contains FRAGMENTS of
- the same size. Each BLOCK has a 'number of free FRAGMENTS' counter and so
- has each TOP (for the entire chain).
-
- * A BLOCK is around 4060 bytes plus the size of the information header. This
- size is adjusted to make the allocation of the big block not require more
- than 4096 bytes. (This might not be so easy to be sure of, if you don't
- know how the big-block system works, but the BMALLOC system uses an
- extra header of 12 bytes and the header for the FRAGMENT BLOCK is 20 bytes
- in a general 32-bit unix environment.)
-
- * In case the allocation of a BLOCK fails when a FRAGMENT is required, the
- next size of FRAGMENTS will be checked for a free FRAGMENT. First when the
- larger size lists have been tested without success it will fail for real.
-
- FREE
-
- * When FRAGMENTS are freed so that a BLOCK becomes non-used, it is returned
- to the system.
-
- * FREEing a fragment adds the buffer in a LIFO-order. That means that the
- next request for a fragment from the same list, the last freed buffer will
- be returned first.
-
- REALLOC
-
- * REALLOCATION of a FRAGMENT does first check if the new size would fit
- within the same FRAGMENT and if it would use the same FRAGMENT size. If it
- does and would, the same pointer is returned.
-
- OVERHEAD
-
- Yes, there is an overhead on small allocations (internal fragmentation).
- Yet, I do believe that small allocations more often than larger ones are
- used dynamically. I believe that a large overhead is not a big problem if it
- remains only for a while. The big gain is with the extreme speed we can GET
- and RETURN small allocations. This has yet to be proven. I am open to other
- systems of dealing with the small ones, but I don`t believe in using the
- same system for all sizes of allocations.
-
- IMPROVEMENT
-
- An addition to the above described algorithm is the `save-empty-BLOCKS-a-
- while-afterwards`. It will be used when the last used FRAGMENT within a
- BLOCK is freed. The BLOCK will then not get returned to the system until "a
- few more" FRAGMENTS have been freed in case the last [few] freed FRAGMENTS
- are allocated yet again (and thus prevent the huge overhead of making
- FRAGMENTS in a BLOCK). The "only" drawback of such a SEBAWA concept is
- that it would mean an even bigger overhead...
-
- HEADERS (in allocated data)
-
- FRAGMENTS - 32-bit pointer to its parent BLOCK (lowest bit must be 0)
- BLOCK - 32-bit size (lowest bit must be 1 to separate this from
- FRAGMENTS)
-
-##############################################################################
- LARGER ALLOCATIONS
-##############################################################################
-
- If the requested size is larger than the largest FRAGMENT size supported,
- the allocation will be made for this memory area alone, or if a BLOCK is
- allocated to fit lots of FRAGMENTS a large block is also desired.
-
- * We add memory to the "system" with the add_pool() function call. It
- specifies the start and size of the new block of memory that will be
- used in this memory allocation system. Several add_pool() calls are
- supported and they may or may not add contiguous memory.
-
- * Make all blocks get allocated aligned to BLOCKSIZE (sometimes referred to
- as 'grain size'), 64 bytes in my implementation. Reports tell us there is
- no real gain in increasing the size of the align.
-
- * We link *all* pieces of memory (AREAS), free or not free. We keep the list
- in address order and thus when a FREE() occurs we know instanstly if there
- are FREE CHUNKS wall-to-wall. No list "travels" needed. Requires some
- extra space in every allocated BLOCK. Still needs to put the new CHUNK in
- the right place in size-sorted list/tree. All memory areas, allocated or
- not, contain the following header:
- - size of this memory area
- - FREE status
- - pointer to the next AREA closest in memory
- - pointer to the prev AREA closest in memory
- (12 bytes)
-
- * Sort all FREE CHUNKS in size-order. We use a SPLAY TREE algorithm for
- maximum speed. Data/structs used for the size-sorting functions are kept
- in an abstraction layer away from this since it is really not changing
- anything (except executing speed).
-
- ALLOC (RSIZE - requested size, aligned properly)
-
- * Fetch a CHUNK that RSIZE fits within. If the found CHUNK is larger than
- RSIZE, split it and return the RSIZE to the caller. Link the new CHUNK
- into the list/tree.
-
- FREE (AREA - piece of memory that is returned to the system)
-
- * Since the allocated BLOCK has kept its link-pointers, we can without
- checking any list instantly see if there are any FREE CHUNKS that are
- wall-to-wall with the AREA (both sides). If the AREA *is* wall-to-wall
- with one or two CHUNKS that or they are unlinked from the lists, enlarged
- and re-linked into the lists.
-
- REALLOC
-
- * There IS NO realloc() of large blocks, they are performed in the higher
- layer (dmalloc).
-
-
-##############################################################################
- FURTHER READING
-##############################################################################
-
- * "Dynamic Storage Allocation: A Survey and Critical Review" (Paul R. Wilson,
- Mark S. Johnstone, Michael Neely, David Boles)
- ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps
-
- * "A Memory Allocator" (Doug Lea)
- http://g.oswego.edu/dl/html/malloc.html
diff --git a/apps/plugins/pdbox/pdbox.h b/apps/plugins/pdbox/pdbox.h
index d8ddd96078..eda3245258 100644
--- a/apps/plugins/pdbox/pdbox.h
+++ b/apps/plugins/pdbox/pdbox.h
@@ -69,75 +69,4 @@ extern struct event_queue core_to_gui;
receive_datagram(&core_to_gui, PD_GUI_PORT, buffer)
#endif
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2009 Wincent Balin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#ifndef PDBOX_H
-#define PDBOX_H
-
-#if 0
-/* Use dbestfit. */
-#include "bmalloc.h"
-#include "dmalloc.h"
-#endif
-
-/* Minimal memory size. */
-#define MIN_MEM_SIZE (4 * 1024 * 1024)
-
-/* Maximal size of the datagram. */
-#define MAX_DATAGRAM_SIZE 255
-
-/* This structure replaces a UDP datagram. */
-struct datagram
-{
- bool used;
- uint8_t size;
- char data[MAX_DATAGRAM_SIZE];
-};
-
-/* Network functions prototypes. */
-void net_init(void);
-void net_destroy(void);
-bool send_datagram(struct event_queue* route, int port,
- char* data, size_t size);
-bool receive_datagram(struct event_queue* route, int port,
- struct datagram* buffer);
-
-/* Network message queues. */
-extern struct event_queue gui_to_core;
-extern struct event_queue core_to_gui;
-
-/* UDP ports of the original software. */
-#define PD_CORE_PORT 3333
-#define PD_GUI_PORT 3334
-
-/* Convinience macros. */
-#define SEND_TO_CORE(data) \
- send_datagram(&gui_to_core, PD_CORE_PORT, data, rb->strlen(data))
-#define RECEIVE_TO_CORE(buffer) \
- receive_datagram(&gui_to_core, PD_CORE_PORT, buffer)
-#define SEND_FROM_CORE(data) \
- send_datagram(&core_to_gui, PD_GUI_PORT, data, rb->strlen(data))
-#define RECEIVE_FROM_CORE(buffer) \
- receive_datagram(&core_to_gui, PD_GUI_PORT, buffer)
-
-#endif