[SCM] python-pyo/master: Imported Upstream version 0.7.6
tiago at users.alioth.debian.org
tiago at users.alioth.debian.org
Tue Jul 28 21:25:04 UTC 2015
The following commit has been merged in the master branch:
commit 963680012d6b505e428b8f1d52cca608ac329a49
Author: Tiago Bortoletto Vaz <tiago at debian.org>
Date: Tue Jul 28 16:59:40 2015 -0400
Imported Upstream version 0.7.6
diff --git a/COPYING.LESSER.txt b/COPYING.LESSER.txt
new file mode 100644
index 0000000..853047c
--- /dev/null
+++ b/COPYING.LESSER.txt
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/pyolib/COPYING.txt b/COPYING.txt
similarity index 100%
copy from pyolib/COPYING.txt
copy to COPYING.txt
diff --git a/ChangeLog b/ChangeLog
index e792be3..73619a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,350 @@
-------------------------------------------------------------------------------------
-2013-10-16 belangeo <belangeo at gmail.com>
+2015-07-27 belangeo <belangeo at gmail.com>
+
+ * Final revision for version 0.7.6.
+ - rev 1335
+
+2015-07-24 belangeo <belangeo at gmail.com>
+
+ * Release tag: 0.7.6.
+ - rev 1333
+
+2015-07-24 belangeo <belangeo at gmail.com>
+
+ * Added missing types to OscDataSend and OscDataReceive (char, blob, True,
+ False, None and MIDI packet).
+ - rev 1332
+
+2015-07-21 belangeo <belangeo at gmail.com>
+
+ * Fixed Centroid output with silence as input.
+ - rev 1330
+
+2015-07-21 belangeo <belangeo at gmail.com>
+
+ * Added new objet: RawMidi, a raw Midi handler.
+ - rev 1329
+
+2015-07-21 belangeo <belangeo at gmail.com>
+
+ * Added pyoArgsAssert call in each object's methods.
+ - rev 1320, 1325, 1327, 1328
+
+2015-07-20 belangeo <belangeo at gmail.com>
+
+ * Fixed the "segmentation fault" that occur sometimes when deleting an object.
+ - rev 1326
+
+2015-05-31 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: Fixed project tree.
+ - rev 1315
+
+2015-05-29 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: stderr now prints to the output panel.
+ - rev 1314
+
+2015-05-25 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: Added code block selection (#--> and #<-- are delimiters).
+ The background server now prints to the output panel.
+ - rev 1313
+
+2015-04-29 belangeo <belangeo at gmail.com>
+
+ * Fixed CPU usage of PeakAmp.
+ - rev 1312
+
+-------------------------------------------------------------------------------------
+2015-03-05 belangeo <belangeo at gmail.com>
+
+ * Fixed crash when portaudio stream is stopped on OSX (created when fixed
+ for Windows). Rev 1310 is the sources for 0.7.5 release.
+ - rev 1310
+
+2015-03-05 belangeo <belangeo at gmail.com>
+
+ * Release tag: 0.7.5.
+ - rev 1308
+
+2015-03-05 belangeo <belangeo at gmail.com>
+
+ * Added documentation for server methods setTimeCallable and setMeterCallable.
+ - rev 1304
+
+2015-03-05 belangeo <belangeo at gmail.com>
+
+ * Changed license to the more permissive LGPL version 3.
+ - rev 1303
+
+2015-03-03 belangeo <belangeo at gmail.com>
+
+ * The Server can be booted with a different number of input and output channels.
+ - rev 1301
+
+2015-03-03 belangeo <belangeo at gmail.com>
+
+ * Wraped input of Record in an InputFader object.
+ - rev 1300
+
+2015-03-03 belangeo <belangeo at gmail.com>
+
+ * Fixed bug in Hilbert object.
+ - rev 1299
+
+2015-02-18 belangeo <belangeo at gmail.com>
+
+ * Added mul, add and sub methods to PyoTableObject. These methods can
+ take float, list or another PyoTableObject as argument.
+ - rev 1298
+
+2015-02-13 belangeo <belangeo at gmail.com>
+
+ * Added new objet: AtanTable, generates arctangent transfert functions.
+ - rev 1296
+
+2015-02-11 belangeo <belangeo at gmail.com>
+
+ * Fixed a bug when changing the looping mode of the Looper object.
+ - rev 1295
+
+2015-02-09 belangeo <belangeo at gmail.com>
+
+ * Added a reset method to the Looper objet.
+ - rev 1294
+
+2015-02-08 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: Added a refresh button to actualize the content of the folder panel.
+ - rev 1292
+
+2015-02-07 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: Added a menu item to set a master document (the one that will be executed whatever
+ which one has the focus).
+ - rev 1291
+
+2015-02-03 belangeo <belangeo at gmail.com>
+
+ * Added getServer, getSamplingRate and getBufferSize to PyoObjectBase. These methods can be
+ accessed from any pyo objects.
+ - rev 1290
+
+2015-02-03 belangeo <belangeo at gmail.com>
+
+ * Fixed a bug with class method referenced inside pyo object. Save them as weak reference,
+ allowing the garbage collector to properly delete the objects when reference count falls to 0.
+ - rev 1289
+
+2015-02-02 belangeo <belangeo at gmail.com>
+
+ * Added new objet: TableWrite, records values in a table at arbitrary location.
+ - rev 1288
+
+-------------------------------------------------------------------------------------
+
+2015-01-29 belangeo <belangeo at gmail.com>
+
+ * Release tag: 0.7.4
+ - rev 1284
+
+2015-01-29 belangeo <belangeo at gmail.com>
+
+ * Added new function: floatmap, 0-1 range mapper. Fixed bug in DataTable initialization
+ and added an automatic refresh of the DataTable grapher window.
+ - rev 1282
+
+2015-01-26 belangeo <belangeo at gmail.com>
+
+ * Added new objet: Particle, a full control granular synthesis generator.
+ - rev 1281
+
+2015-01-24 belangeo <belangeo at gmail.com>
+
+ * Added setSync method to Granule object. Allow to toggle between synchronous
+ and asynchronous granulation. Added noteon and noteoff trigger streams to Notein
+ object.
+
+ - rev 1280
+
+2014-12-15 belangeo <belangeo at gmail.com>
+
+ * Added reset method to CtlScan and CtlScan2 objects.
+ - rev 1279
+
+2014-12-03 belangeo <belangeo at gmail.com>
+
+ * Added new objet: PeakAmp, a peak amplitude follower.
+ - rev 1277
+
+2014-11-27 belangeo <belangeo at gmail.com>
+
+ * Added reset method to Beat and Euclide objects.
+ - rev 1275
+
+-------------------------------------------------------------------------------------
+
+2014-10-17 belangeo <belangeo at gmail.com>
+
+ * Release tag: 0.7.3.
+ - rev 1273
+
+2014-11-15 belangeo <belangeo at gmail.com>
+
+ * Added new objet: Scope, an audio waveform display.
+ - rev 1270
+
+2014-11-12 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: Fix marker's line numbering.
+ - rev 1267
+
+2014-11-08 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: Added Save As Template... menu item.
+ - rev 1263
+
+2014-11-02 belangeo <belangeo at gmail.com>
+
+ * Fixed bug in Fader decreasing ramp.
+ - rev 1262
+
+2014-10-28 belangeo <belangeo at gmail.com>
+
+ * Added midi output methods to the Server object. noteout, afterout, ctlout, programout, pressout and bendout.
+ - rev 1261
+
+2014-10-28 belangeo <belangeo at gmail.com>
+
+ * Server.setMidiOutputDevice(idx) with `idx` greater than the higher portmidi devices index opens all available output devices.
+ - rev 1260
+
+2014-10-24 belangeo <belangeo at gmail.com>
+
+ * Added new object: FToM, converts an audio stream containning frequencies in hertz to a midi note audio stream.
+ - rev 1259
+
+2014-10-23 belangeo <belangeo at gmail.com>
+
+ * Added new function: hzToMidi, converts a frequency in hertz to a midi note value.
+ - rev 1258
+
+-------------------------------------------------------------------------------------
+
+2014-10-17 belangeo <belangeo at gmail.com>
+
+ * Release tag: 0.7.2.
+ - rev 1256
+
+2014-10-16 belangeo <belangeo at gmail.com>
+
+ * Server.setMidiInputDevice(idx) with `idx` greater than the higher portmidi input index opens all available devices.
+ - rev 1254
+
+2014-10-16 belangeo <belangeo at gmail.com>
+
+ * OSX installer: Also install pyo in anaconda site-packages directory if exist.
+ - rev 1253
+
+2014-10-16 belangeo <belangeo at gmail.com>
+
+ * Added new object : TrigBurst, generates a time/amplitude expandable trigger pattern.
+ - rev 1252
+
+2014-10-14 belangeo <belangeo at gmail.com>
+
+ * Added new object : Euclide, Euclidean rhythm generator.
+ - rev 1251
+
+2014-10-13 belangeo <belangeo at gmail.com>
+
+ * Windows installers now check for the current python installation directory before installing files.
+ - rev 1244 - 1250
+
+2014-10-10 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: Fixed inconsistencies in Find/Replace behaviours.
+ - rev 1241
+
+2014-10-10 belangeo <belangeo at gmail.com>
+
+ * Added new object : SmoothDelay, a delay line that does not produce clicks or pitch shifting when the delay time is changing.
+ - rev 1239
+
+2014-10-08 belangeo <belangeo at gmail.com>
+
+ * Added new object : AttackDetector, audio signal onset detection.
+ - rev 1238
+
+2014-10-07 belangeo <belangeo at gmail.com>
+
+ * Added new object : Centroid, Computes the spectral centroid of an input signal.
+ - rev 1237
+
+-------------------------------------------------------------------------------------
+
+2014-08-29 belangeo <belangeo at gmail.com>
+
+ * Release tag: 0.7.1.
+ - rev 1236
+
+2014-09-12 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: Added RadioPyo to the template choices.
+ - rev 1234
+
+2014-09-09 belangeo <belangeo at gmail.com>
+
+ * Fixed Compare when used with None or a string. Print a warning and set 'comp' attribute to 0.
+ - rev 1229
+
+2014-09-05 belangeo <belangeo at gmail.com>
+
+ * Fixed live interpreter of the server window when using arrow keys navigation.
+ - rev 1228
+
+2014-09-04 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: Check if WxPython 3.0 is installed, otherwise uses 2.8.
+ - rev 1227
+
+2014-09-02 belangeo <belangeo at gmail.com>
+
+ * Added anti-aliasing to PyoTableObject's grapher widget. Fixed Ctrl+W on the grapher.
+ - rev 1225, 1226
+
+-------------------------------------------------------------------------------------
+
+2014-08-29 belangeo <belangeo at gmail.com>
+
+ * Release tag: 0.7.0.
+ - rev 1224
+
+2014-08-26 belangeo <belangeo at gmail.com>
+
+ * pyo can now be used without any GUI toolkit (WxPython or TKinter). Widgets are simply disabled.
+ - rev 1208
+
+2014-06-22 belangeo <belangeo at gmail.com>
+
+ * Added Server methods to auto-connect Jack ports to already opened ports.
+ - rev 1201
+
+2014-05-23 belangeo <belangeo at gmail.com>
+
+ * E-Pyo: output log now in realtime.
+ - rev 1197
+
+2014-04-24 belangeo <belangeo at gmail.com>
+
+ * Added new object: Tanh, hyperbolic tangent function on audio signal.
+ - rev 1188
+
+-------------------------------------------------------------------------------------
+
+2014-04-11 belangeo <belangeo at gmail.com>
* Release tag: 0.6.9.
- rev 1185
diff --git a/doc-sphinx/build.py b/doc-sphinx/build.py
index fdcb309..50c9fe8 100644
--- a/doc-sphinx/build.py
+++ b/doc-sphinx/build.py
@@ -62,10 +62,8 @@ os.system("sphinx-build -a -b %s ./source %s" % (build_format, build_folder))
if build_format == "latex":
os.system("cd build_latex; pdflatex -interaction nonstopmode Pyo; pdflatex -interaction nonstopmode Pyo")
-else:
- # Upload on iACT server
- print "Upload documentation (y/n)?"
- ans = raw_input()
- if (ans == 'y'):
- os.system('scp -r %s/* sysop at 132.204.178.49:/Library/WebServer/Documents/pyo/manual-dev/' % build_folder)
+
+rep = raw_input("Do you want to upload to ajax server (y/n) ? ")
+if rep == "y":
+ os.system("scp -r build_html/* jeadum1 at ajaxsoundstudio.com:/home/jeadum1/ajaxsoundstudio.com/pyodoc")
diff --git a/doc-sphinx/source/about.rst b/doc-sphinx/source/about.rst
index 4add116..b7488f9 100644
--- a/doc-sphinx/source/about.rst
+++ b/doc-sphinx/source/about.rst
@@ -12,4 +12,4 @@ For questions and comments, please subscribe to the `pyo-discuss <http://groups.
To report a bug or to request a feature, use the `issues tracker <http://code.google.com/p/pyo/issues/list>`_ on googlecode.
Sources and binaries can be downloaded at:
-http://code.google.com/p/pyo/
+http://ajaxsoundstudio.com/software/pyo/
diff --git a/doc-sphinx/source/api/alphabetical.rst b/doc-sphinx/source/api/alphabetical.rst
index 3ad686f..ad48bdc 100644
--- a/doc-sphinx/source/api/alphabetical.rst
+++ b/doc-sphinx/source/api/alphabetical.rst
@@ -7,20 +7,22 @@ Alphabetical class reference
- :py:class:`AToDB` : Returns the decibel equivalent of an amplitude value.
- :py:class:`Abs` : Performs an absolute function on audio signal.
- :py:class:`Adsr` : Attack - Decay - Sustain - Release envelope generator.
-- :py:class:`Allpass2` : Second-order phase shifter allpass.
+- :py:class:`Allpass2` : Second-order phase shifter allpass.
- :py:class:`AllpassWG` : Out of tune waveguide model with a recursive allpass network.
- :py:class:`Allpass` : Delay line based allpass filter.
- :py:class:`Atan2` : Computes the principal value of the arc tangent of b/a.
+- :py:class:`AtanTable` : Generates an arctangent transfert function.
- :py:class:`Atone` : A first-order recursive high-pass filter with variable frequency response.
+- :py:class:`AttackDetector` : Audio signal onset detection.
- :py:class:`Average` : Moving average filter.
- :py:class:`Balance` : Adjust rms power of an audio signal according to the rms power of another.
- :py:class:`BandSplit` : Splits an input signal into multiple frequency bands.
- :py:class:`Beat` : Generates algorithmic trigger patterns.
- :py:class:`Bendin` : Get the current value of the pitch bend controller.
- :py:class:`Between` : Informs when an input signal is contained in a specified range.
-- :py:class:`Biquad` : A sweepable general purpose biquadratic digital filter.
+- :py:class:`Biquad` : A sweepable general purpose biquadratic digital filter.
- :py:class:`Biquada` : A general purpose biquadratic digital filter (floating-point arguments).
-- :py:class:`Biquadx` : A multi-stages sweepable general purpose biquadratic digital filter.
+- :py:class:`Biquadx` : A multi-stages sweepable general purpose biquadratic digital filter.
- :py:class:`Blit` : Band limited impulse train synthesis.
- :py:class:`BrownNoise` : A brown noise generator.
- :py:class:`ButBP` : A second-order Butterworth bandpass filter.
@@ -30,6 +32,7 @@ Alphabetical class reference
- :py:class:`CallAfter` : Calls a Python function after a given time.
- :py:class:`CarToPol` : Performs the cartesian to polar conversion.
- :py:class:`Ceil` : Rounds to smallest integral value greater than or equal to the input signal.
+- :py:class:`Centroid` : Computes the spectral centroid of an input signal.
- :py:class:`CentsToTranspo` : Returns the transposition factor equivalent of a given cents value.
- :py:class:`Change` : Sends trigger that informs when input value has changed.
- :py:class:`ChebyTable` : Chebyshev polynomials of the first kind.
@@ -39,7 +42,7 @@ Alphabetical class reference
- :py:class:`Clip` : Clips a signal to a predefined limit.
- :py:class:`Cloud` : Generates random triggers.
- :py:class:`Compare` : Comparison object.
-- :py:class:`ComplexRes` : Complex one-pole resonator filter.
+- :py:class:`ComplexRes` : Complex one-pole resonator filter.
- :py:class:`Compress` : Reduces the dynamic range of an audio signal.
- :py:class:`ControlRead` : Reads control values previously stored in text files.
- :py:class:`ControlRec` : Records control values and writes them in a text file.
@@ -63,11 +66,13 @@ Alphabetical class reference
- :py:class:`Denorm` : Mixes low level noise to an input signal.
- :py:class:`Disto` : Arc tangent distortion.
- :py:class:`Dummy` : Dummy object used to perform arithmetics on PyoObject.
-- :py:class:`EQ` : Equalizer filter.
+- :py:class:`EQ` : Equalizer filter.
+- :py:class:`Euclide` : Euclidean rhythm generator.
- :py:class:`ExpTable` : Construct a table from exponential interpolated segments.
-- :py:class:`Expseg` : Trace a series of exponential segments between specified break-points.
+- :py:class:`Expseg` : Trace a series of exponential segments between specified break-points.
- :py:class:`FFT` : Fast Fourier Transform.
- :py:class:`FM` : A simple frequency modulation generator.
+- :py:class:`FToM` : Returns the midi note equivalent to a frequency in Hz.
- :py:class:`Fader` : Fadein - fadeout envelope generator.
- :py:class:`Floor` : Rounds to largest integral value not greater than audio signal.
- :py:class:`Follower2` : Envelope follower with different attack and release times.
@@ -80,7 +85,7 @@ Alphabetical class reference
- :py:class:`Gate` : Allows a signal to pass only when its amplitude is above a set threshold.
- :py:class:`Granulator` : Granular synthesis generator.
- :py:class:`Granule` : Another granular synthesis generator.
-- :py:class:`HannTable` : Generates Hanning window function.
+- :py:class:`HannTable` : Generates Hanning window function.
- :py:class:`HarmTable` : Harmonic waveform generator.
- :py:class:`Harmonizer` : Generates harmonizing voices in synchrony with its audio input.
- :py:class:`Hilbert` : Hilbert transform.
@@ -95,7 +100,7 @@ Alphabetical class reference
- :py:class:`Iter` : Triggers iterate over a list of values.
- :py:class:`LFO` : Band-limited Low Frequency Oscillator with different wave shapes.
- :py:class:`LinTable` : Construct a table from segments of straight lines in breakpoint fashion.
-- :py:class:`Linseg` : Trace a series of line segments between specified break-points.
+- :py:class:`Linseg` : Trace a series of line segments between specified break-points.
- :py:class:`Log10` : Performs a base 10 log function on audio signal.
- :py:class:`Log2` : Performs a base 2 log function on audio signal.
- :py:class:`LogTable` : Construct a table from logarithmic segments in breakpoint fashion.
@@ -119,7 +124,7 @@ Alphabetical class reference
- :py:class:`Mix` : Mix audio streams to arbitrary number of streams.
- :py:class:`Mixer` : Audio mixer.
- :py:class:`NewMatrix` : Create a new matrix ready for recording.
-- :py:class:`NewTable` : Create an empty table ready for recording.
+- :py:class:`NewTable` : Create an empty table ready for recording.
- :py:class:`NextTrig` : A trigger in the second stream opens a gate only for the next one in the first stream.
- :py:class:`Noise` : A white noise generator.
- :py:class:`NoteinRead` : Reads Notein values previously stored in text files.
@@ -153,11 +158,13 @@ Alphabetical class reference
- :py:class:`PVTranspose` : Transpose the frequency components of a pv stream.
- :py:class:`PVVerb` : Spectral domain reverberation.
- :py:class:`Pan` : Cosinus panner with control on the spread factor.
-- :py:class:`ParaTable` : Generates parabola window function.
+- :py:class:`ParaTable` : Generates parabola window function.
- :py:class:`PartialTable` : Inharmonic waveform generator.
+- :py:class:`Particle` : A full control granular synthesis generator.
- :py:class:`Pattern` : Periodically calls a Python function.
+- :py:class:`PeakAmp` : Peak amplitude follower.
- :py:class:`Percent` : Lets pass a certain percentage of the input triggers.
-- :py:class:`Phaser` : Multi-stages second-order phase shifter allpass filters.
+- :py:class:`Phaser` : Multi-stages second-order phase shifter allpass filters.
- :py:class:`Phasor` : A simple phase incrementor.
- :py:class:`PinkNoise` : A pink noise generator.
- :py:class:`Pointer2` : High quality table reader with control on the pointer position.
@@ -173,9 +180,10 @@ Alphabetical class reference
- :py:class:`RandInt` : Periodic pseudo-random integer generator.
- :py:class:`Randh` : Periodic pseudo-random generator.
- :py:class:`Randi` : Periodic pseudo-random generator with interpolation.
+- :py:class:`RawMidi` : Raw Midi handler.
- :py:class:`Record` : Writes input sound in an audio file on the disk.
-- :py:class:`Reson` : A second-order resonant bandpass filter.
-- :py:class:`Resonx` : A multi-stages second-order resonant bandpass filter.
+- :py:class:`Reson` : A second-order resonant bandpass filter.
+- :py:class:`Resonx` : A multi-stages second-order resonant bandpass filter.
- :py:class:`Rossler` : Chaotic attractor for the Rossler system.
- :py:class:`Round` : Rounds to the nearest integer value in a floating-point format.
- :py:class:`SDelay` : Simple delay without interpolation.
@@ -187,10 +195,11 @@ Alphabetical class reference
- :py:class:`SLMapQ` : SLMap with normalized values for a 'q' slider.
- :py:class:`SPan` : Simple equal power panner.
- :py:class:`STRev` : Stereo reverb.
-- :py:class:`SVF` : Fourth-order state variable filter allowing continuous change of the filter type.
-- :py:class:`SampHold` : Performs a sample-and-hold operation on its input.
+- :py:class:`SVF` : Fourth-order state variable filter allowing continuous change of the filter type.
+- :py:class:`SampHold` : Performs a sample-and-hold operation on its input.
- :py:class:`SawTable` : Sawtooth waveform generator.
- :py:class:`Scale` : Maps an input range of audio values to an output range.
+- :py:class:`Scope` : Oscilloscope - audio waveform display.
- :py:class:`Score` : Calls functions by incrementation of a preformatted name.
- :py:class:`Select` : Sends trigger on matching integer values.
- :py:class:`Selector` : Audio selector.
@@ -201,9 +210,10 @@ Alphabetical class reference
- :py:class:`SigTo` : Convert numeric value to PyoObject signal with portamento.
- :py:class:`Sig` : Convert numeric value to PyoObject signal.
- :py:class:`Sin` : Performs a sine function on audio signal.
-- :py:class:`SincTable` : Generates sinc window function.
+- :py:class:`SincTable` : Generates sinc window function.
- :py:class:`SineLoop` : A simple sine wave oscillator with feedback.
- :py:class:`Sine` : A simple sine wave oscillator.
+- :py:class:`SmoothDelay` : Artifact free sweepable recursive delay.
- :py:class:`Snap` : Snap input values on a user's defined midi scale.
- :py:class:`SndTable` : Transfers data from a soundfile into a function table.
- :py:class:`Spectrum` : Spectrum analyzer and display.
@@ -218,13 +228,16 @@ Alphabetical class reference
- :py:class:`TableRead` : Simple waveform table reader.
- :py:class:`TableRec` : TableRec is for writing samples into a previously created NewTable.
- :py:class:`TableScale` : Scales all the values contained in a PyoTableObject.
+- :py:class:`TableWrite` : TableWrite writes samples into a previously created NewTable.
- :py:class:`Tan` : Performs a tangent function on audio signal.
+- :py:class:`Tanh` : Performs a hyperbolic tangent function on audio signal.
- :py:class:`Thresh` : Informs when a signal crosses a threshold.
- :py:class:`Timer` : Reports elapsed time between two trigs.
- :py:class:`Tone` : A first-order recursive low-pass filter with variable frequency response.
- :py:class:`Touchin` : Get the current value of an after-touch Midi controller.
-- :py:class:`TrackHold` : Performs a track-and-hold operation on its input.
+- :py:class:`TrackHold` : Performs a track-and-hold operation on its input.
- :py:class:`TranspoToCents` : Returns the cents value equivalent of a transposition factor.
+- :py:class:`TrigBurst` : Generates a time/amplitude expandable trigger pattern.
- :py:class:`TrigChoice` : Random generator from user's defined values.
- :py:class:`TrigEnv` : Envelope reader generator.
- :py:class:`TrigExpseg` : Exponential segments trigger.
@@ -240,11 +253,11 @@ Alphabetical class reference
- :py:class:`Urn` : Periodic pseudo-random integer generator without duplicates.
- :py:class:`VarPort` : Convert numeric value to PyoObject signal with portamento.
- :py:class:`Vectral` : Performs magnitude smoothing between successive frames.
-- :py:class:`Vocoder` : Applies the spectral envelope of a first sound to the spectrum of a second sound.
+- :py:class:`Vocoder` : Applies the spectral envelope of a first sound to the spectrum of a second sound.
- :py:class:`VoiceManager` : Polyphony voice manager.
-- :py:class:`WGVerb` : 8 delay line mono FDN reverb.
+- :py:class:`WGVerb` : 8 delay lines mono FDN reverb.
- :py:class:`Waveguide` : Basic waveguide model.
-- :py:class:`WinTable` : Generates different kind of windowing functions.
+- :py:class:`WinTable` : Generates different kind of windowing functions.
- :py:class:`Wrap` : Wraps-around the signal that exceeds the `min` and `max` thresholds.
- :py:class:`XnoiseDur` : Recursive time varying X-class pseudo-random generator.
- :py:class:`XnoiseMidi` : X-class midi notes pseudo-random generator.
diff --git a/doc-sphinx/source/api/classes/analysis.rst b/doc-sphinx/source/api/classes/analysis.rst
index 233842a..6a94baa 100644
--- a/doc-sphinx/source/api/classes/analysis.rst
+++ b/doc-sphinx/source/api/classes/analysis.rst
@@ -33,3 +33,32 @@ can use them for controlling parameters of others objects.
.. autoclass:: Yin
:members:
+*Centroid*
+------------
+
+.. autoclass:: Centroid
+ :members:
+
+*AttackDetector*
+-----------------
+
+.. autoclass:: AttackDetector
+ :members:
+
+*Spectrum*
+-----------------------------------
+
+.. autoclass:: Spectrum
+ :members:
+
+*Scope*
+-----------------------------------
+
+.. autoclass:: Scope
+ :members:
+
+*PeakAmp*
+-----------------------------------
+
+.. autoclass:: PeakAmp
+ :members:
diff --git a/doc-sphinx/source/api/classes/arithmetic.rst b/doc-sphinx/source/api/classes/arithmetic.rst
index af5fc7f..757bdfc 100644
--- a/doc-sphinx/source/api/classes/arithmetic.rst
+++ b/doc-sphinx/source/api/classes/arithmetic.rst
@@ -23,6 +23,12 @@ Tools to perform arithmetic operations on audio signals.
.. autoclass:: Tan
:members:
+*Tanh*
+------------
+
+.. autoclass:: Tanh
+ :members:
+
*Abs*
------------
diff --git a/doc-sphinx/source/api/classes/dynamics.rst b/doc-sphinx/source/api/classes/dynamics.rst
index 0ac8200..cb68212 100644
--- a/doc-sphinx/source/api/classes/dynamics.rst
+++ b/doc-sphinx/source/api/classes/dynamics.rst
@@ -11,6 +11,12 @@ Objects to modify the dynamic range and sample quality of audio signals.
.. autoclass:: Clip
:members:
+*Degrade*
+----------
+
+.. autoclass:: Degrade
+ :members:
+
*Mirror*
------------
diff --git a/doc-sphinx/source/api/classes/effects.rst b/doc-sphinx/source/api/classes/effects.rst
index 4a3ce41..25a3201 100644
--- a/doc-sphinx/source/api/classes/effects.rst
+++ b/doc-sphinx/source/api/classes/effects.rst
@@ -84,3 +84,9 @@ as distortions, delays, chorus and reverbs.
.. autoclass:: STRev
:members:
+*SmoothDelay*
+---------------
+
+.. autoclass:: SmoothDelay
+ :members:
+
diff --git a/doc-sphinx/source/api/classes/fourier.rst b/doc-sphinx/source/api/classes/fourier.rst
index 148ea3d..1955415 100644
--- a/doc-sphinx/source/api/classes/fourier.rst
+++ b/doc-sphinx/source/api/classes/fourier.rst
@@ -51,12 +51,6 @@ spectral domain.
.. autoclass:: CvlVerb
:members:
-*Spectrum*
------------------------------------
-
-.. autoclass:: Spectrum
- :members:
-
*Vectral*
-----------------------------------
diff --git a/doc-sphinx/source/api/classes/midi.rst b/doc-sphinx/source/api/classes/midi.rst
index bb7dc1d..094c588 100644
--- a/doc-sphinx/source/api/classes/midi.rst
+++ b/doc-sphinx/source/api/classes/midi.rst
@@ -64,3 +64,8 @@ used as controls and can't be sent to the output soundcard.
.. autoclass:: Touchin
:members:
+*RawMidi*
+-----------------------------------
+
+.. autoclass:: RawMidi
+ :members:
diff --git a/doc-sphinx/source/api/classes/tableprocess.rst b/doc-sphinx/source/api/classes/tableprocess.rst
index bbb09d2..8e9da9e 100644
--- a/doc-sphinx/source/api/classes/tableprocess.rst
+++ b/doc-sphinx/source/api/classes/tableprocess.rst
@@ -56,6 +56,12 @@ store audio samples or algorithmic sequences for future uses.
.. autoclass:: OscTrig
:members:
+*Particle*
+-----------------------------------
+
+.. autoclass:: Particle
+ :members:
+
*Pointer*
-----------------------------------
@@ -104,6 +110,12 @@ store audio samples or algorithmic sequences for future uses.
.. autoclass:: TableRec
:members:
+*TableWrite*
+-----------------------------------
+
+.. autoclass:: TableWrite
+ :members:
+
*TableScale*
-----------------------------------
diff --git a/doc-sphinx/source/api/classes/tables.rst b/doc-sphinx/source/api/classes/tables.rst
index 569743b..326aefa 100644
--- a/doc-sphinx/source/api/classes/tables.rst
+++ b/doc-sphinx/source/api/classes/tables.rst
@@ -78,6 +78,12 @@ in memory and access them quickly.
.. autoclass:: ParaTable
:members:
+*PartialTable*
+-----------------------------------
+
+.. autoclass:: PartialTable
+ :members:
+
*SawTable*
-----------------------------------
@@ -108,3 +114,8 @@ in memory and access them quickly.
.. autoclass:: WinTable
:members:
+*AtanTable*
+-----------------------------------
+
+.. autoclass:: AtanTable
+ :members:
diff --git a/doc-sphinx/source/api/classes/triggers.rst b/doc-sphinx/source/api/classes/triggers.rst
index 778d1d9..917c802 100644
--- a/doc-sphinx/source/api/classes/triggers.rst
+++ b/doc-sphinx/source/api/classes/triggers.rst
@@ -40,6 +40,12 @@ processes with sample rate timing accuracy.
.. autoclass:: Counter
:members:
+*Euclide*
+-----------------------------------
+
+.. autoclass:: Euclide
+ :members:
+
*Iter*
-----------------------------------
@@ -94,6 +100,12 @@ processes with sample rate timing accuracy.
.. autoclass:: Trig
:members:
+*TrigBurst*
+-----------------------------------
+
+.. autoclass:: TrigBurst
+ :members:
+
*TrigChoice*
-----------------------------------
diff --git a/doc-sphinx/source/api/functions/conv.rst b/doc-sphinx/source/api/functions/conv.rst
index ec0273c..9261abd 100644
--- a/doc-sphinx/source/api/functions/conv.rst
+++ b/doc-sphinx/source/api/functions/conv.rst
@@ -33,6 +33,11 @@ Conversions
.. autofunction:: rescale(data, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, xlog=False, ylog=False)
+*floatmap*
+---------------------------------
+
+.. autofunction:: floatmap(x, min=0.0, max=1.0, exp=1.0)
+
*distanceToSegment*
---------------------------------
diff --git a/doc-sphinx/source/compiling.rst b/doc-sphinx/source/compiling.rst
index 78adfb0..b984826 100644
--- a/doc-sphinx/source/compiling.rst
+++ b/doc-sphinx/source/compiling.rst
@@ -9,26 +9,25 @@ Dependencies
To compile pyo, you will need the following dependencies:
- `Python 2.6 or 2.7 <http://www.python.org/download/releases/>`_
+- `WxPython 3.0 <http://www.wxpython.org/download.php/>`_
- `Portaudio <http://www.portaudio.com/>`_
- `Portmidi <http://portmedia.sourceforge.net/portmidi/>`_
- `libsndfile <http://www.mega-nerd.com/libsndfile/>`_
- `liblo <http://liblo.sourceforge.net/>`_
+Under Mac OS X, you can use Homebrew to retrieve necessary dependency librairies and headers (except for wxpython 3.0) to compile pyo.
-Under Mac OS X, to retrieve necessary dependency librairies and headers to compile pyo, you can run the "get_dependencies.sh" script from the scripts folder in pyo sources, it will download them to /usr/local/lib and /usr/local/include directory.
-
-For i386 architecture (32-bit python):
+First, install Homebrew with this command:
.. code-block:: bash
- sh scripts/get_dependencies.sh
+ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
-For i386/x86_64 architectures (64-bit python):
+Then, install packages:
.. code-block:: bash
- sh scripts/get_dependencies_x86_64.sh
-
+ brew install python liblo libsndfile portaudio portmidi --universal
Getting sources
-------------------
@@ -135,7 +134,7 @@ Under OS X, it is very simple to build pyo from sources with the Homebrew packag
.. code-block:: bash
- brew install python liblo libsndfile portaudio portmidi
+ brew install python liblo libsndfile portaudio portmidi --universal
svn checkout http://pyo.googlecode.com/svn/trunk/ pyo
cd pyo
python setup.py install --use-coreaudio --use-double
diff --git a/doc-sphinx/source/conf.py b/doc-sphinx/source/conf.py
index 413f581..c2779e5 100644
--- a/doc-sphinx/source/conf.py
+++ b/doc-sphinx/source/conf.py
@@ -12,6 +12,7 @@
# serve to show the default.
import sys, os
+from pyo import PYO_VERSION
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -42,16 +43,16 @@ master_doc = 'index'
# General information about the project.
project = u'Pyo'
-copyright = u'2013, Olivier Bélanger'
+copyright = u'2014, Olivier Bélanger'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
-version = '0.6.9'
+version = PYO_VERSION
# The full version, including alpha/beta/rc tags.
-release = '0.6.9'
+release = PYO_VERSION
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/doc-sphinx/source/download.rst b/doc-sphinx/source/download.rst
index fdf63a4..fb5024b 100644
--- a/doc-sphinx/source/download.rst
+++ b/doc-sphinx/source/download.rst
@@ -1,8 +1,8 @@
Downloading
=================
-Installers are available for Windows (XP, Vista, 7, 8) and for Max OS X (from 10.5 to 10.8).
+Installers are available for Windows (Win 7/8) and for Max OS X (from 10.6 to 10.9).
-To download the latest pre-compiled version of pyo, go to the pyo's googlecode `download <http://code.google.com/p/pyo/downloads/list>`_ page.
+To download the latest pre-compiled version of pyo, go to the pyo's `web page <http://ajaxsoundstudio.com/software/pyo/>`_.
Under Debian distros, you can get pyo from the package manager. The library's name is **python-pyo**.
diff --git a/doc-sphinx/source/index.rst b/doc-sphinx/source/index.rst
index 0698ad1..c2c953b 100644
--- a/doc-sphinx/source/index.rst
+++ b/doc-sphinx/source/index.rst
@@ -3,7 +3,7 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
-Welcome to the Pyo 0.6.9 documentation
+Welcome to the Pyo 0.7.6 documentation
===================================================
.. toctree::
diff --git a/doc-sphinx/source/tutorials/pyoobject2.rst b/doc-sphinx/source/tutorials/pyoobject2.rst
index db3db1c..3b31ba5 100644
--- a/doc-sphinx/source/tutorials/pyoobject2.rst
+++ b/doc-sphinx/source/tutorials/pyoobject2.rst
@@ -30,7 +30,7 @@ First of all, we need to import the pyo module
Step 1 - Declaring the class
------------------------------
-We will create a new class called RingMod with PyoObject as its parent class.
+We will create a new class called Flanger with PyoObject as its parent class.
Another good habit is to put a __doc__ string at the beginning of our classes.
Doing so will allow other users to retrieve the object's documentation with the
standard python help() function.
diff --git a/embedded/puredata/m_pd.h b/embedded/puredata/m_pd.h
deleted file mode 100755
index 71bd28e..0000000
--- a/embedded/puredata/m_pd.h
+++ /dev/null
@@ -1,665 +0,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. */
-
-#ifndef __m_pd_h_
-
-#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
-extern "C" {
-#endif
-
-#define PD_MAJOR_VERSION 0
-#define PD_MINOR_VERSION 41
-#define PD_BUGFIX_VERSION 4
-#define PD_TEST_VERSION "extended"
-
-/* 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
-
-/* These pragmas are only used for MSVC, not MinGW or Cygwin <hans at at.or.at> */
-#ifdef _MSC_VER
-/* #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 /* _MSC_VER */
-
- /* 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 /* must be >= FILENAME_MAX */
-#define MAXPDARG 5 /* max number of args we can typecheck today */
-
-/* signed and unsigned integer types the size of a pointer: */
-/* GG: long is the size of a pointer */
-typedef long t_int;
-
-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;
-
-#define PD_BLOBS 1 /* MP20070211 Use this to test for blob capability */
-/* MP20061223 blob type: */
-typedef struct _blob /* pointer to a blob */
-{
- unsigned long s_length; /* length of blob in bytes */
- unsigned char *s_data; /* pointer to 1st byte of blob */
-} t_blob;
-/* ...MP20061223 blob type */
-
-
-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_blob *w_blob; /* MP20061223 blob type */
-} 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,
- A_BLOB /* MP20061223 blob type */
-} 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_blob;
-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(const 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 SETBLOB(atom, st) ((atom)->a_type = A_BLOB, (atom)->a_w.w_blob = (st)) /* MP 20061226 blob type */
-#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_blob *atom_getblob(t_atom *a);/* MP 20070108 blob type */
-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_canvas(t_binbuf *b, char *filename, t_canvas *canvas,
- 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 --------------- */
-
-EXTERN t_clock *clock_new(void *owner, t_method fn);
-EXTERN void clock_set(t_clock *x, double systime);
-EXTERN void clock_delay(t_clock *x, double delaytime);
-EXTERN void clock_unset(t_clock *x);
-EXTERN double clock_getlogicaltime(void);
-EXTERN double clock_getsystime(void); /* OBSOLETE; use clock_getlogicaltime() */
-EXTERN double clock_gettimesince(double prevsystime);
-EXTERN double clock_getsystimeafter(double 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_blob(t_pd *x, t_blob *st); /* MP 20061226 blob type */
-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 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 t_inlet *signalinlet_new(t_object *owner, t_float f);
-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_blob(t_outlet *x, t_blob *st); /* MP 20061226 blob type */
-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 char sys_font[]; /* default typeface set in s_main.c */
-EXTERN char sys_fontweight[]; /* default font weight set in s_main.c */
-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);
-EXTERN int canvas_open(t_canvas *x, const char *name, const char *ext,
- char *dirresult, char **nameresult, unsigned int size, int bin);
-
-/* ---------------- 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_addblob(t_class *c, t_method fn);/* MP 20061226 blob type */
-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);
-EXTERN void class_set_extern_dir(t_symbol *s);
-#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_addblob(x, y) class_addblob((x), (t_method)(y)) /* MP20061226 blob type */
-#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(const char *fmt, ...);
-EXTERN void startpost(const char *fmt, ...);
-EXTERN void poststring(const char *s);
-EXTERN void postfloat(float f);
-EXTERN void postatom(int argc, t_atom *argv);
-EXTERN void endpost(void);
-EXTERN void error(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-EXTERN void verbose(int level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
-EXTERN void bug(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-EXTERN void pd_error(void *object, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
-EXTERN void sys_logerror(const char *object, const char *s);
-EXTERN void sys_unixerror(const char *object);
-EXTERN void sys_ouch(void);
-
-
-/* ------------ system interface routines ------------------- */
-EXTERN int sys_isreadablefile(const char *name);
-EXTERN int sys_isabsolutepath(const char *dir);
-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);
-EXTERN int (*sys_idlehook)(void); /* hook to add idle time computation */
-
-
-/* ------------ threading ------------------- */
-EXTERN void sys_lock(void);
-EXTERN void sys_unlock(void);
-EXTERN int sys_trylock(void);
-
-
-/* --------------- signals ----------------------------------- */
-
-typedef float t_sample;
-#define MAXLOGSIG 32
-#define MAXSIGSIZE (1 << MAXLOGSIG)
-
-typedef struct _signal
-{
- int s_n; /* number of points in the array */
- t_sample *s_vec; /* the array */
- t_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 */
- int s_vecsize; /* allocated size of array in points */
-} 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_float *in, t_sample *out, int n);
-EXTERN void dsp_add_zero(t_sample *out, int n);
-
-EXTERN int sys_getblksize(void);
-EXTERN t_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(t_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 float *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);
-EXTERN int canvas_dspstate;
-
-/* 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);
-
-/* ----------------------- utility functions for signals -------------- */
-EXTERN t_float mtof(t_float);
-EXTERN t_float ftom(t_float);
-EXTERN t_float rmstodb(t_float);
-EXTERN t_float powtodb(t_float);
-EXTERN t_float dbtorms(t_float);
-EXTERN t_float dbtopow(t_float);
-
-EXTERN t_float q8_sqrt(t_float);
-EXTERN t_float q8_rsqrt(t_float);
-#ifndef N32
-EXTERN t_float qsqrt(t_float); /* old names kept for extern compatibility */
-EXTERN t_float qrsqrt(t_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_float **vec);
-EXTERN int garray_getfloatwords(t_garray *x, int *size, t_word **vec);
-EXTERN t_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 --------- */
-typedef void (*t_guicallbackfn)(t_gobj *client, t_glist *glist);
-
-EXTERN void sys_vgui(char *fmt, ...);
-EXTERN void sys_gui(char *s);
-EXTERN void sys_pretendguibytes(int n);
-EXTERN void sys_queuegui(void *client, t_glist *glist, t_guicallbackfn f);
-EXTERN void sys_unqueuegui(void *client);
- /* 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 defined(__i386__) || defined(__x86_64__)
-/* 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/embedded/puredata/pyo~-help.pd b/embedded/puredata/pyo~-help.pd
index e8c9c8a..d1f07d9 100644
--- a/embedded/puredata/pyo~-help.pd
+++ b/embedded/puredata/pyo~-help.pd
@@ -1,14 +1,14 @@
-#N canvas 296 140 952 365 10;
+#N canvas 295 147 1007 365 10;
#X obj 28 108 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
-#X obj 144 108 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
+#X obj 144 108 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 13 234 *~;
#X obj 51 234 *~;
#X obj 13 256 dac~;
#X obj 72 213 hsl 128 15 0 1 0 1 empty empty master_gain -2 -8 0 10
-262144 -1 -1 6200 1;
-#X obj 274 223 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
+#X obj 274 223 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X msg 274 243 \; pd dsp \$1;
#X obj 13 59 r msg_to_pyo;
@@ -18,34 +18,34 @@
to 2).;
#N canvas 1 75 824 583 resonators_example 0;
#X obj 35 103 hsl 128 15 0.01 30 1 0 empty empty resonance -2 -8 0
-10 -262144 -1 -1 11200 0;
-#X floatatom 32 120 5 0 0 0 - - -;
+10 -262144 -1 -1 0 0;
+#X floatatom 32 120 5 0 0 0 - - -, f 5;
#X obj 21 530 s msg_to_pyo;
#X obj 98 387 hsl 128 15 0 1 0 0 empty empty delay_time -2 -8 0 10
--262144 -1 -1 1300 0;
-#X floatatom 95 403 5 0 0 0 - - -;
+-262144 -1 -1 0 0;
+#X floatatom 95 403 5 0 0 0 - - -, f 5;
#X msg 95 418 value deltime \$1;
#X obj 111 454 hsl 128 15 0 1 0 0 empty empty delay_feedback -2 -8
-0 10 -262144 -1 -1 10800 0;
-#X floatatom 108 470 5 0 0 0 - - -;
+0 10 -262144 -1 -1 0 0;
+#X floatatom 108 470 5 0 0 0 - - -, f 5;
#X msg 108 485 value delfeed \$1;
#X msg 32 136 value reson \$1;
#X obj 52 177 vsl 15 80 50 500 0 0 empty empty empty 0 -9 0 10 -262144
--1 -1 4700 0;
+-1 -1 0 0;
#X obj 71 177 vsl 15 80 50 500 0 0 empty empty empty 0 -9 0 10 -262144
--1 -1 3200 0;
+-1 -1 0 0;
#X obj 91 177 vsl 15 80 50 500 0 0 empty empty empty 0 -9 0 10 -262144
--1 -1 5800 0;
+-1 -1 0 0;
#X obj 110 177 vsl 15 80 50 500 0 0 empty empty empty 0 -9 0 10 -262144
--1 -1 7100 0;
+-1 -1 0 0;
#X obj 130 177 vsl 15 80 50 500 0 0 empty empty empty 0 -9 0 10 -262144
--1 -1 5500 0;
+-1 -1 0 0;
#X obj 149 177 vsl 15 80 50 500 0 0 empty empty empty 0 -9 0 10 -262144
--1 -1 7100 0;
+-1 -1 0 0;
#X obj 169 177 vsl 15 80 50 500 0 0 empty empty empty 0 -9 0 10 -262144
--1 -1 4400 0;
+-1 -1 0 0;
#X obj 189 177 vsl 15 80 50 500 0 0 empty empty empty 0 -9 0 10 -262144
--1 -1 1800 0;
+-1 -1 0 0;
#X msg 52 306 value freqs \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8;
#X obj 52 264 bondo 8 ____________;
#X obj 52 285 pack f f f f f f f f;
@@ -100,8 +100,8 @@ input;
-1 -1 4233 1;
#X obj 127 144 hsl 128 15 0 36 0 0 empty empty empty -2 -8 0 10 -262144
-1 -1 4233 1;
-#X floatatom 75 125 5 0 0 0 - - -;
-#X floatatom 124 160 5 0 0 0 - - -;
+#X floatatom 75 125 5 0 0 0 - - -, f 5;
+#X floatatom 124 160 5 0 0 0 - - -, f 5;
#X obj 124 209 +;
#X obj 124 179 t b f;
#X obj 75 144 t f f;
@@ -142,15 +142,15 @@ input;
;
#X obj 67 172 hsl 128 15 0 0.25 0 0 empty empty brightness -2 -8 0
10 -262144 -1 -1 0 0;
-#X floatatom 64 188 5 0 0 0 - - -;
+#X floatatom 64 188 5 0 0 0 - - -, f 5;
#X msg 64 203 value feed \$1;
#X obj 158 75 hsl 128 15 50 500 0 0 empty empty metro_speed -2 -8 0
10 -262144 -1 -1 0 1;
-#X floatatom 155 93 5 0 0 0 - - -;
-#X floatatom 222 186 5 0 0 0 - - -;
+#X floatatom 155 93 5 0 0 0 - - -, f 5;
+#X floatatom 222 186 5 0 0 0 - - -, f 5;
#X msg 222 216 set amp.fadeout \$1;
#X msg 281 184 set amp.dur \$1;
-#X floatatom 281 165 5 0 0 0 - - -;
+#X floatatom 281 165 5 0 0 0 - - -, f 5;
#X obj 222 132 * 0.001;
#X obj 221 111 - 20;
#X obj 222 165 - 0.005;
@@ -218,7 +218,7 @@ input;
#N canvas 1 75 532 224 conv_reverb_example 0;
#X obj 24 110 hsl 128 15 0 1 0 0 empty empty balance -2 -8 0 10 -262144
-1 -1 0 0;
-#X floatatom 21 127 5 0 0 0 - - -;
+#X floatatom 21 127 5 0 0 0 - - -, f 5;
#X msg 21 143 value bal \$1;
#X obj -3 170 s msg_to_pyo;
#X msg -3 74 read examples/cvlverb.py;
diff --git a/embedded/puredata/pyo~.c b/embedded/puredata/pyo~.c
index 1e675b1..972f66e 100644
--- a/embedded/puredata/pyo~.c
+++ b/embedded/puredata/pyo~.c
@@ -1,5 +1,5 @@
#include <stdlib.h>
-#include "m_pd.h"
+#include <pd/m_pd.h>
#include "Python.h"
#include "m_pyo.h"
diff --git a/examples/algorithmic/01_music_box.py b/examples/algorithmic/01_music_box.py
index 56f86a8..3548f95 100644
--- a/examples/algorithmic/01_music_box.py
+++ b/examples/algorithmic/01_music_box.py
@@ -4,18 +4,23 @@
Music box. 5 voices randomly choosing frequencies over a common scale.
"""
+
from pyo import *
s = Server(duplex=0).boot()
+#--> set list of frequencies
low_freqs = [midiToHz(m+7) for m in [36,43.01,48,55.01,60]]
mid_freqs = [midiToHz(m+7) for m in [60,62,63.93,65,67.01,69,71,72]]
high_freqs = [midiToHz(m+7) for m in [72,74,75.93,77,79.01]]
freqs = [low_freqs,low_freqs,mid_freqs,mid_freqs,high_freqs]
+#<--
+#-->
chx = Choice(choice=freqs, freq=[1,2,3,3,4])
port = Port(chx, risetime=.001, falltime=.001)
sines = SineLoop(port, feedback=[.06,.057,.033,.035,.016], mul=[.15,.15,.1,.1,.06])
pan = SPan(sines, pan=[0, 1, .2, .8, .5]).out()
+#<--
s.gui(locals())
\ No newline at end of file
diff --git a/examples/effects/01_flanger.py b/examples/effects/01_flanger.py
index 4d52111..9be597d 100644
--- a/examples/effects/01_flanger.py
+++ b/examples/effects/01_flanger.py
@@ -8,9 +8,13 @@ from pyo import *
s = Server(sr=44100, nchnls=2, buffersize=512, duplex=0).boot()
+#-->
src = BrownNoise(.1).mix(2).out()
+#<--
+#-->
lf = Sine(freq=.2, mul=.0045, add=.005)
flg = Delay(src, delay=lf, feedback=.25).out()
+#<--
s.gui(locals())
\ No newline at end of file
diff --git a/examples/effects/02_chorus.py b/examples/effects/02_chorus.py
index 57262ef..90fff48 100644
--- a/examples/effects/02_chorus.py
+++ b/examples/effects/02_chorus.py
@@ -8,9 +8,12 @@ from pyo import *
s = Server(sr=44100, nchnls=2, buffersize=512, duplex=0).boot()
+#--> Start a sound
sf = SfPlayer('../snds/baseballmajeur_m.aif', speed=1, loop=True, mul=.3)
sf2 = sf.mix(2).out()
+#<--
+#--> Sets values for 8 delay lines
# delay line frequencies
freqs = [.254, .465, .657, .879, 1.23, 1.342, 1.654, 1.879]
# delay line center delays
@@ -19,8 +22,11 @@ cdelay = [.0087, .0102, .0111, .01254, .0134, .01501, .01707, .0178]
adelay = [.001, .0012, .0013, .0014, .0015, .0016, .002, .0023]
# modulation depth
depth = Sig(1)
+#<--
+#--> Add the delay lines to the source sound
lfos = Sine(freqs, mul=adelay*depth, add=cdelay)
delays = Delay(sf, lfos, feedback=.5, mul=.5).out()
+#<--
s.gui(locals())
diff --git a/examples/tables/05_table_maker.py b/examples/tables/05_table_maker.py
index 7213bb3..fdcd0ae 100644
--- a/examples/tables/05_table_maker.py
+++ b/examples/tables/05_table_maker.py
@@ -13,7 +13,8 @@ path = "../snds/baseballmajeur_m.aif"
dur = sndinfo(path)[1]
t = SndTable(path, start=0, stop=1)
-a = Looper(t, pitch=[1.,1.], dur=t.getDur(), xfade=5, mul=.4).out()
+amp = Fader(fadein=0.005, fadeout=0.005, dur=0, mul=0.4).play()
+a = Looper(t, pitch=[1.,1.], dur=t.getDur(), xfade=5, mul=amp).out()
def addsnd():
start = random.uniform(0, dur*0.7)
@@ -22,14 +23,20 @@ def addsnd():
cross = random.uniform(0.04, duration/2)
t.insert(path, pos=pos, crossfade=cross, start=start, stop=start+duration)
-def gen():
+def delayed_generation():
start = random.uniform(0, dur*0.7)
duration = random.uniform(.1, .3)
t.setSound(path, start=start, stop=start+duration)
for i in range(10):
addsnd()
-
a.dur = t.getDur()
+ a.reset()
+ amp.play()
+
+caller = CallAfter(function=delayed_generation, time=0.005).stop()
+def gen():
+ amp.stop()
+ caller.play()
gen()
diff --git a/include/dummymodule.h b/include/dummymodule.h
index e082a70..8ce3436 100644
--- a/include/dummymodule.h
+++ b/include/dummymodule.h
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -25,7 +25,7 @@ typedef struct {
pyo_audio_HEAD
PyObject *input;
Stream *input_stream;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
} Dummy;
extern PyObject * Dummy_initialize(Dummy *self);
@@ -33,4 +33,3 @@ extern PyObject * Dummy_initialize(Dummy *self);
#define MAKE_NEW_DUMMY(self, type, rt_error) \
(self) = (Dummy *)(type)->tp_alloc((type), 0); \
if ((self) == rt_error) { return rt_error; }
-
diff --git a/include/fft.h b/include/fft.h
index 99f8d7d..a7019b5 100644
--- a/include/fft.h
+++ b/include/fft.h
@@ -1,29 +1,29 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include "pyomodule.h"
-
+
#ifndef _FFT_
#define _FFT_
/* in-place split-radix real fft */
void realfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle);
-void irealfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle);
+void irealfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle);
void fft_compute_split_twiddle(MYFLT **twiddle, int size);
void fft_compute_window(MYFLT *window, int size, int wintype);
/* in-place radix-2 real fft (not used actually) */
@@ -33,4 +33,3 @@ void irealfft_packed(MYFLT *data, MYFLT *outdata, int size, MYFLT *twiddle);
void fft_compute_split_twiddle(MYFLT **twiddle, int size);
void fft_compute_radix2_twiddle(MYFLT *twiddle, int size);
#endif
-
diff --git a/include/interpolation.h b/include/interpolation.h
index 370c02c..5b3d042 100644
--- a/include/interpolation.h
+++ b/include/interpolation.h
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include "pyomodule.h"
diff --git a/include/matrixmodule.h b/include/matrixmodule.h
index abcb1c3..72f5593 100644
--- a/include/matrixmodule.h
+++ b/include/matrixmodule.h
@@ -1,21 +1,21 @@
- /*************************************************************************
- * Copyright 2010 Olivier Belanger *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
* *
* This file is part of pyo, a python module to help digital signal *
* processing script creation. *
* *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include "Python.h"
diff --git a/include/pvstreammodule.h b/include/pvstreammodule.h
index 5194e3e..d4ceb23 100644
--- a/include/pvstreammodule.h
+++ b/include/pvstreammodule.h
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -56,6 +56,6 @@ extern PyTypeObject PVStreamType;
/* include from other modules to use API */
// #define Stream_setStreamObject(op, v) (((Stream *)(op))->streamobject = (v))
-
+
#endif
/* __PVSTREAMMODULE */
\ No newline at end of file
diff --git a/include/pyomodule.h b/include/pyomodule.h
index d83f8f7..32a3f3c 100644
--- a/include/pyomodule.h
+++ b/include/pyomodule.h
@@ -1,27 +1,27 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include "Python.h"
#include <math.h>
-#define PYO_VERSION "0.6.9"
+#define PYO_VERSION "0.7.6"
#ifndef __MYFLT_DEF
#define __MYFLT_DEF
@@ -38,6 +38,8 @@
#define TYPE__FII "|fii"
#define TYPE_F_II "f|ii"
#define TYPE__FFF "|fff"
+#define TYPE_F_FFF "f|fff"
+#define TYPE_O_FIFFI "O|fiffi"
#define TYPE_O_F "O|f"
#define TYPE_O_FO "O|fO"
#define TYPE__OF "|Of"
@@ -106,6 +108,7 @@
#define MYATAN2 atan2f
#define MYEXP expf
#define MYROUND roundf
+#define MYTANH tanhf
#else
#define LIB_BASE_NAME "_pyo64"
@@ -119,6 +122,8 @@
#define TYPE__FII "|dii"
#define TYPE_F_II "d|ii"
#define TYPE__FFF "|ddd"
+#define TYPE_F_FFF "d|ddd"
+#define TYPE_O_FIFFI "O|diddi"
#define TYPE_O_F "O|d"
#define TYPE_O_FO "O|dO"
#define TYPE__OF "|Od"
@@ -187,7 +192,7 @@
#define MYATAN2 atan2
#define MYEXP exp
#define MYROUND round
-
+#define MYTANH tanh
#endif
#endif
@@ -304,6 +309,7 @@ extern PyTypeObject CtlScanType;
extern PyTypeObject CtlScan2Type;
extern PyTypeObject MidiNoteType;
extern PyTypeObject NoteinType;
+extern PyTypeObject NoteinTrigType;
extern PyTypeObject BendinType;
extern PyTypeObject TouchinType;
extern PyTypeObject PrograminType;
@@ -338,6 +344,7 @@ extern PyTypeObject SndTableType;
extern PyTypeObject DataTableType;
extern PyTypeObject NewTableType;
extern PyTypeObject TableRecType;
+extern PyTypeObject TableWriteType;
extern PyTypeObject TableRecTimeStreamType;
extern PyTypeObject TableMorphType;
extern PyTypeObject TrigTableRecType;
@@ -397,6 +404,7 @@ extern PyTypeObject ScaleType;
extern PyTypeObject CentsToTranspoType;
extern PyTypeObject TranspoToCentsType;
extern PyTypeObject MToFType;
+extern PyTypeObject FToMType;
extern PyTypeObject MToTType;
extern PyTypeObject M_SinType;
extern PyTypeObject M_CosType;
@@ -411,6 +419,7 @@ extern PyTypeObject M_Atan2Type;
extern PyTypeObject M_FloorType;
extern PyTypeObject M_CeilType;
extern PyTypeObject M_RoundType;
+extern PyTypeObject M_TanhType;
extern PyTypeObject FFTMainType;
extern PyTypeObject FFTType;
extern PyTypeObject IFFTType;
@@ -462,6 +471,21 @@ extern PyTypeObject ComplexResType;
extern PyTypeObject STReverbType;
extern PyTypeObject STRevType;
extern PyTypeObject Pointer2Type;
+extern PyTypeObject CentroidType;
+extern PyTypeObject AttackDetectorType;
+extern PyTypeObject SmoothDelayType;
+extern PyTypeObject TrigBursterType;
+extern PyTypeObject TrigBurstType;
+extern PyTypeObject TrigBurstTapStreamType;
+extern PyTypeObject TrigBurstAmpStreamType;
+extern PyTypeObject TrigBurstDurStreamType;
+extern PyTypeObject TrigBurstEndStreamType;
+extern PyTypeObject ScopeType;
+extern PyTypeObject PeakAmpType;
+extern PyTypeObject MainParticleType;
+extern PyTypeObject ParticleType;
+extern PyTypeObject AtanTableType;
+extern PyTypeObject RawMidiType;
/* Constants */
#define E M_E
@@ -499,6 +523,8 @@ extern PyTypeObject Pointer2Type;
#define FREEVERB_ID 24
#define XNOISEDUR_ID 25
#define URN_ID 26
+#define GRANULE_ID 27
+#define MAINPARTICLE_ID 28
/* Do not forget to modify Server_generateSeed function */
/* object headers */
@@ -515,8 +541,9 @@ extern PyTypeObject Pointer2Type;
Stream *add_stream; \
int bufsize; \
int nchnls; \
+ int ichnls; \
double sr; \
- MYFLT *data;
+ MYFLT *data;
#define pyo_table_HEAD \
PyObject_HEAD \
@@ -535,62 +562,65 @@ extern PyTypeObject Pointer2Type;
/* VISIT & CLEAR */
#define pyo_VISIT \
- if (PyServer_get_server() != NULL) \
+ if (self->server != NULL) \
Py_VISIT(self->server); \
- Py_VISIT(self->stream); \
+ if (self->stream != NULL) \
+ Py_VISIT(self->stream); \
Py_VISIT(self->mul); \
Py_VISIT(self->mul_stream); \
Py_VISIT(self->add); \
- Py_VISIT(self->add_stream);
+ Py_VISIT(self->add_stream);
#define pyo_table_VISIT \
- if (PyServer_get_server() != NULL) \
+ if (self->server != NULL) \
Py_VISIT(self->server); \
- Py_VISIT(self->tablestream); \
+ if (self->tablestream != NULL) \
+ Py_VISIT(self->tablestream); \
#define pyo_matrix_VISIT \
- if (PyServer_get_server() != NULL) \
+ if (self->server != NULL) \
Py_VISIT(self->server); \
- Py_VISIT(self->matrixstream); \
+ if (self->matrixstream != NULL) \
+ Py_VISIT(self->matrixstream); \
#define pyo_CLEAR \
- if (PyServer_get_server() != NULL) { \
+ if (self->server != NULL) { \
Py_INCREF(self->server); \
Py_CLEAR(self->server); \
} \
- Py_CLEAR(self->stream); \
+ if (self->stream != NULL) \
+ Py_CLEAR(self->stream); \
Py_CLEAR(self->mul); \
Py_CLEAR(self->mul_stream); \
Py_CLEAR(self->add); \
Py_CLEAR(self->add_stream); \
#define pyo_table_CLEAR \
- if (PyServer_get_server() != NULL) { \
+ if (self->server != NULL) { \
Py_INCREF(self->server); \
Py_CLEAR(self->server); \
} \
- Py_CLEAR(self->tablestream); \
+ if (self->tablestream != NULL) \
+ Py_CLEAR(self->tablestream); \
#define pyo_matrix_CLEAR \
- if (PyServer_get_server() != NULL) { \
+ if (self->server != NULL) { \
Py_INCREF(self->server); \
Py_CLEAR(self->server); \
} \
- Py_CLEAR(self->matrixstream); \
+ if (self->matrixstream != NULL) \
+ Py_CLEAR(self->matrixstream); \
#define pyo_DEALLOC \
- if (PyServer_get_server() != NULL) \
+ if (self->server != NULL && self->stream != NULL) \
Server_removeStream((Server *)self->server, Stream_getStreamId(self->stream)); \
free(self->data); \
/* INIT INPUT STREAM */
#define INIT_INPUT_STREAM \
if ( PyObject_HasAttrString((PyObject *)inputtmp, "server") == 0 ) { \
- PySys_WriteStderr("TypeError: \"input\" argument must be a PyoObject.\n"); \
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) { \
- PyObject_CallMethod(self->server, "shutdown", NULL); \
- } \
- Py_Exit(1); \
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument must be a PyoObject.\n"); \
+ Py_RETURN_NONE; \
} \
Py_INCREF(inputtmp); \
Py_XDECREF(self->input); \
@@ -617,6 +647,7 @@ extern PyTypeObject Pointer2Type;
self->bufsize = PyInt_AsLong(PyObject_CallMethod(self->server, "getBufferSize", NULL)); \
self->sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL)); \
self->nchnls = PyInt_AsLong(PyObject_CallMethod(self->server, "getNchnls", NULL)); \
+ self->ichnls = PyInt_AsLong(PyObject_CallMethod(self->server, "getIchnls", NULL)); \
self->data = (MYFLT *)realloc(self->data, (self->bufsize) * sizeof(MYFLT)); \
for (i=0; i<self->bufsize; i++) \
self->data[i] = 0.0; \
@@ -645,13 +676,14 @@ extern PyTypeObject Pointer2Type;
PyErr_SetString(PyExc_TypeError, "The data must be a list of floats."); \
return PyInt_FromLong(-1); \
} \
- self->size = PyList_Size(arg)-1; \
+ self->size = PyList_Size(arg); \
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT)); \
TableStream_setSize(self->tablestream, self->size+1); \
\
- for (i=0; i<(self->size+1); i++) { \
+ for (i=0; i<(self->size); i++) { \
self->data[i] = PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(arg, i))); \
} \
+ self->data[self->size] = self->data[0]; \
TableStream_setData(self->tablestream, self->data); \
\
Py_INCREF(Py_None); \
@@ -694,7 +726,115 @@ extern PyTypeObject Pointer2Type;
} \
self->data[self->size] = self->data[0]; \
Py_RETURN_NONE; \
-
+
+#define TABLE_ADD \
+ int i, tabsize; \
+ MYFLT x = 0.0; \
+ MYFLT *list = NULL; \
+ PyObject *table = NULL; \
+ if (PyNumber_Check(arg)) { \
+ x = PyFloat_AsDouble(PyNumber_Float(arg)); \
+ for (i=0; i<self->size; i++) { \
+ self->data[i] += x; \
+ } \
+ } \
+ else if ( PyObject_HasAttrString((PyObject *)arg, "getTableStream") == 1 ) { \
+ Py_XDECREF(table); \
+ table = PyObject_CallMethod((PyObject *)arg, "getTableStream", ""); \
+ list = TableStream_getData((TableStream *)table); \
+ tabsize = TableStream_getSize((TableStream *)table); \
+ if (self->size < tabsize) \
+ tabsize = self->size; \
+ for (i=0; i<tabsize; i++) { \
+ self->data[i] += list[i]; \
+ } \
+ } \
+ else if (PyList_Check(arg)) { \
+ tabsize = PyList_Size(arg); \
+ if (self->size < tabsize) \
+ tabsize = self->size; \
+ for (i=0; i<tabsize; i++) { \
+ self->data[i] += PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(arg, i))); \
+ } \
+ } \
+ \
+ self->data[self->size] = self->data[0]; \
+ \
+ Py_INCREF(Py_None); \
+ return Py_None; \
+
+#define TABLE_SUB \
+ int i, tabsize; \
+ MYFLT x = 0.0; \
+ MYFLT *list = NULL; \
+ PyObject *table = NULL; \
+ if (PyNumber_Check(arg)) { \
+ x = PyFloat_AsDouble(PyNumber_Float(arg)); \
+ for (i=0; i<self->size; i++) { \
+ self->data[i] -= x; \
+ } \
+ } \
+ else if ( PyObject_HasAttrString((PyObject *)arg, "getTableStream") == 1 ) { \
+ Py_XDECREF(table); \
+ table = PyObject_CallMethod((PyObject *)arg, "getTableStream", ""); \
+ list = TableStream_getData((TableStream *)table); \
+ tabsize = TableStream_getSize((TableStream *)table); \
+ if (self->size < tabsize) \
+ tabsize = self->size; \
+ for (i=0; i<tabsize; i++) { \
+ self->data[i] -= list[i]; \
+ } \
+ } \
+ else if (PyList_Check(arg)) { \
+ tabsize = PyList_Size(arg); \
+ if (self->size < tabsize) \
+ tabsize = self->size; \
+ for (i=0; i<tabsize; i++) { \
+ self->data[i] -= PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(arg, i))); \
+ } \
+ } \
+ \
+ self->data[self->size] = self->data[0]; \
+ \
+ Py_INCREF(Py_None); \
+ return Py_None; \
+
+#define TABLE_MUL \
+ int i, tabsize; \
+ MYFLT x = 0.0; \
+ MYFLT *list = NULL; \
+ PyObject *table = NULL; \
+ if (PyNumber_Check(arg)) { \
+ x = PyFloat_AsDouble(PyNumber_Float(arg)); \
+ for (i=0; i<self->size; i++) { \
+ self->data[i] *= x; \
+ } \
+ } \
+ else if ( PyObject_HasAttrString((PyObject *)arg, "getTableStream") == 1 ) { \
+ Py_XDECREF(table); \
+ table = PyObject_CallMethod((PyObject *)arg, "getTableStream", ""); \
+ list = TableStream_getData((TableStream *)table); \
+ tabsize = TableStream_getSize((TableStream *)table); \
+ if (self->size < tabsize) \
+ tabsize = self->size; \
+ for (i=0; i<tabsize; i++) { \
+ self->data[i] *= list[i]; \
+ } \
+ } \
+ else if (PyList_Check(arg)) { \
+ tabsize = PyList_Size(arg); \
+ if (self->size < tabsize) \
+ tabsize = self->size; \
+ for (i=0; i<tabsize; i++) { \
+ self->data[i] *= PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(arg, i))); \
+ } \
+ } \
+ \
+ self->data[self->size] = self->data[0]; \
+ \
+ Py_INCREF(Py_None); \
+ return Py_None; \
+
#define SET_TABLE \
int i; \
if (arg == NULL) { \
@@ -728,21 +868,44 @@ extern PyTypeObject Pointer2Type;
return samples;
#define GET_VIEW_TABLE \
- int i, y; \
- int w = 500; \
- int h = 200; \
- int h2 = h/2; \
- int amp = h2 - 2; \
- float step = (float)self->size / (float)(w); \
- PyObject *samples; \
+ int i, y, w, h, h2, amp; \
+ float step; \
+ PyObject *samples, *tuple, *sizetmp = NULL; \
+ \
+ static char *kwlist[] = {"size", NULL}; \
+ \
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &sizetmp)) \
+ return PyInt_FromLong(-1); \
+ \
+ if (sizetmp) { \
+ if (PyTuple_Check(sizetmp)) { \
+ w = PyInt_AsLong(PyTuple_GET_ITEM(sizetmp, 0)); \
+ h = PyInt_AsLong(PyTuple_GET_ITEM(sizetmp, 1)); \
+ } \
+ else if (PyList_Check(sizetmp)) { \
+ w = PyInt_AsLong(PyList_GET_ITEM(sizetmp, 0)); \
+ h = PyInt_AsLong(PyList_GET_ITEM(sizetmp, 1)); \
+ } \
+ else { \
+ w = 500; \
+ h = 200; \
+ } \
+ } \
+ else { \
+ w = 500; \
+ h = 200; \
+ } \
+ h2 = h/2; \
+ amp = h2 - 2; \
+ step = (float)self->size / (float)(w); \
\
- samples = PyList_New(w*4); \
+ samples = PyList_New(w); \
for(i=0; i<w; i++) { \
- y = self->data[(int)(i*step)] * amp + amp; \
- PyList_SetItem(samples, i*4, PyInt_FromLong(i)); \
- PyList_SetItem(samples, i*4+1, PyInt_FromLong(h-y)); \
- PyList_SetItem(samples, i*4+2, PyInt_FromLong(i)); \
- PyList_SetItem(samples, i*4+3, PyInt_FromLong(h-y)); \
+ y = self->data[(int)(i*step)] * amp + amp + 2; \
+ tuple = PyTuple_New(2); \
+ PyTuple_SetItem(tuple, 0, PyInt_FromLong(i)); \
+ PyTuple_SetItem(tuple, 1, PyInt_FromLong(h-y)); \
+ PyList_SetItem(samples, i, tuple); \
} \
\
return samples;
@@ -968,10 +1131,10 @@ extern PyTypeObject Pointer2Type;
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_F_I, kwlist, &val, &pos)) \
return PyInt_FromLong(-1); \
\
- if (pos >= self->size) { \
- PyErr_SetString(PyExc_TypeError, "position outside of table boundaries!."); \
- return PyInt_FromLong(-1); \
- } \
+ if (pos >= self->size) \
+ pos = self->size - 1; \
+ else if (pos < 0) \
+ pos = 0; \
\
self->data[pos] = val; \
\
@@ -1163,7 +1326,7 @@ extern PyTypeObject Pointer2Type;
(*self->mode_func_ptr)(self); \
\
Py_INCREF(Py_None); \
- return Py_None;
+ return Py_None;
#define SET_ADD \
PyObject *tmp, *streamtmp; \
@@ -1194,7 +1357,7 @@ extern PyTypeObject Pointer2Type;
(*self->mode_func_ptr)(self); \
\
Py_INCREF(Py_None); \
- return Py_None;
+ return Py_None;
#define SET_SUB \
PyObject *tmp, *streamtmp; \
@@ -1225,7 +1388,7 @@ extern PyTypeObject Pointer2Type;
(*self->mode_func_ptr)(self); \
\
Py_INCREF(Py_None); \
- return Py_None;
+ return Py_None;
#define SET_DIV \
PyObject *tmp, *streamtmp; \
@@ -1259,7 +1422,7 @@ extern PyTypeObject Pointer2Type;
(*self->mode_func_ptr)(self); \
\
Py_INCREF(Py_None); \
- return Py_None;
+ return Py_None;
/* Multiply, Add, inplace_multiply & inplace_add */
#define MULTIPLY \
@@ -1386,7 +1549,7 @@ extern PyTypeObject Pointer2Type;
self->data[i] = 0; \
} \
Py_INCREF(Py_None); \
- return Py_None;
+ return Py_None;
/* Post processing (mul & add) macros */
#define POST_PROCESSING_II \
@@ -1422,7 +1585,7 @@ extern PyTypeObject Pointer2Type;
old = self->data[i]; \
val = mul * old + add[i]; \
self->data[i] = val; \
- }
+ }
#define POST_PROCESSING_AA \
MYFLT old, val; \
@@ -1472,7 +1635,7 @@ extern PyTypeObject Pointer2Type;
old = self->data[i]; \
val = mul * old - add[i]; \
self->data[i] = val; \
- }
+ }
#define POST_PROCESSING_AREVA \
MYFLT old, val; \
@@ -1498,4 +1661,3 @@ extern PyTypeObject Pointer2Type;
val = old / tmp - add[i]; \
self->data[i] = val; \
}
-
diff --git a/include/servermodule.h b/include/servermodule.h
index 396ed16..91e9d22 100644
--- a/include/servermodule.h
+++ b/include/servermodule.h
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
* *
* Octobre 2013 : Multiple servers facility and embeded backend added by *
* Guillaume Barrette. See embeded possibilities at: *
@@ -61,7 +61,7 @@ typedef struct {
jack_port_t **jack_out_ports;
#endif
} PyoJackBackendData;
-
+
typedef struct {
PyObject_HEAD
PyObject *streams;
@@ -70,12 +70,17 @@ typedef struct {
char *serverName; /* Only used for jack client name */
int jackautoin; /* jack port auto-connection (on by default) */
int jackautoout; /* jack port auto-connection (on by default) */
- PmStream *in;
- PmStream *out;
+ PyObject *jackAutoConnectInputPorts; /* list of regex to match for jack auto-connection */
+ PyObject *jackAutoConnectOutputPorts; /* list of regex to match for jack auto-connection */
+ PmStream *midiin[64];
+ PmStream *midiout[64];
+ int midiin_count;
+ int midiout_count;
PmEvent midiEvents[200];
int midi_count;
double samplingRate;
int nchnls;
+ int ichnls;
int bufferSize;
int duplex;
int input;
@@ -92,7 +97,7 @@ typedef struct {
int stream_count;
int record;
int thisServerID; /* To keep the reference index in the array of servers */
-
+
/* global amplitude */
MYFLT amp;
MYFLT resetAmp;
@@ -101,13 +106,13 @@ typedef struct {
MYFLT stepVal;
int timeStep;
int timeCount;
-
+
MYFLT *input_buffer;
float *output_buffer; /* Has to be float since audio callbacks must use floats */
-
+
/* rendering offline of the first "startoffset" seconds */
double startoffset;
-
+
/* rendering settings */
double recdur;
char *recpath;
@@ -115,7 +120,7 @@ typedef struct {
int rectype;
SNDFILE *recfile;
SF_INFO recinfo;
-
+
/* GUI VUMETER */
int withGUI;
int numPass;
@@ -129,7 +134,7 @@ typedef struct {
int timePass;
int tcount;
PyObject *TIME;
-
+
/* Properties */
int verbosity; /* a sum of values to display different levels: 1 = error */
/* 2 = message, 4 = warning , 8 = debug. Default 7.*/
@@ -138,15 +143,14 @@ typedef struct {
PyObject * PyServer_get_server();
extern PyObject * Server_removeStream(Server *self, int sid);
-extern MYFLT * Server_getInputBuffer(Server *self);
-extern PmEvent * Server_getMidiEventBuffer(Server *self);
-extern int Server_getMidiEventCount(Server *self);
+extern MYFLT * Server_getInputBuffer(Server *self);
+extern PmEvent * Server_getMidiEventBuffer(Server *self);
+extern int Server_getMidiEventCount(Server *self);
extern int Server_generateSeed(Server *self, int oid);
-extern PyTypeObject ServerType;
+extern PyTypeObject ServerType;
#ifdef __cplusplus
}
#endif
#endif /* !defined(Py_SERVERMODULE_H) */
-
diff --git a/include/streammodule.h b/include/streammodule.h
index 4febd94..78a8fa3 100644
--- a/include/streammodule.h
+++ b/include/streammodule.h
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -87,6 +87,6 @@ extern PyTypeObject TriggerStreamType;
#define Stream_setBufferCountWait(op, v) (((Stream *)(op))->bufferCountWait = (v))
#define Stream_setDuration(op, v) (((Stream *)(op))->duration = (v))
#define Stream_setBufferSize(op, v) (((Stream *)(op))->bufsize = (v))
-
+
#endif
-/* __STREAMMODULE */
+/* __STREAMMODULE */
\ No newline at end of file
diff --git a/include/tablemodule.h b/include/tablemodule.h
index 8b2dccf..26e2ac5 100644
--- a/include/tablemodule.h
+++ b/include/tablemodule.h
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include "Python.h"
@@ -44,4 +44,4 @@ double TableStream_getSamplingRate(PyObject *self);
MYFLT * TableStream_getData(PyObject *self);
extern PyTypeObject TableStreamType;
-#endif
+#endif
\ No newline at end of file
diff --git a/include/wind.h b/include/wind.h
index c7c939b..bc3658d 100644
--- a/include/wind.h
+++ b/include/wind.h
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2011 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
* *
* Envelope window generator : *
* 0 : Rectangular (no window) *
@@ -28,10 +28,10 @@
* 7 : Tuckey (alpha = 0.66) *
* 8 : Sine (half-sine window) *
*************************************************************************/
+
#include "pyomodule.h"
-
+
#ifndef _WIND_
#define _WIND_
void gen_window(MYFLT *window, int size, int wintype);
#endif
-
diff --git a/installers/osx/PkgResources_i386/License.rtf b/installers/osx/PkgResources_i386/License.rtf
deleted file mode 100755
index 66b2d2a..0000000
--- a/installers/osx/PkgResources_i386/License.rtf
+++ /dev/null
@@ -1,681 +0,0 @@
-{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
-{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
-{\colortbl;\red255\green255\blue255;}
-\margl1440\margr1440\vieww10100\viewh11340\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
-
-\f0\fs26 \cf0 GNU GENERAL PUBLIC LICENSE\
- Version 3, 29 June 2007\
-\
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\
- Everyone is permitted to copy and distribute verbatim copies\
- of this license document, but changing it is not allowed.\
-\
- Preamble\
-\
- The GNU General Public License is a free, copyleft license for\
-software and other kinds of works.\
-\
- The licenses for most software and other practical works are designed\
-to take away your freedom to share and change the works. By contrast,\
-the GNU General Public License is intended to guarantee your freedom to\
-share and change all versions of a program--to make sure it remains free\
-software for all its users. We, the Free Software Foundation, use the\
-GNU General Public License for most of our software; it applies also to\
-any other work released this way by its authors. You can apply it to\
-your programs, too.\
-\
- When we speak of free software, we are referring to freedom, not\
-price. Our General Public Licenses are designed to make sure that you\
-have the freedom to distribute copies of free software (and charge for\
-them if you wish), that you receive source code or can get it if you\
-want it, that you can change the software or use pieces of it in new\
-free programs, and that you know you can do these things.\
-\
- To protect your rights, we need to prevent others from denying you\
-these rights or asking you to surrender the rights. Therefore, you have\
-certain responsibilities if you distribute copies of the software, or if\
-you modify it: responsibilities to respect the freedom of others.\
-\
- For example, if you distribute copies of such a program, whether\
-gratis or for a fee, you must pass on to the recipients the same\
-freedoms that you received. You must make sure that they, too, receive\
-or can get the source code. And you must show them these terms so they\
-know their rights.\
-\
- Developers that use the GNU GPL protect your rights with two steps:\
-(1) assert copyright on the software, and (2) offer you this License\
-giving you legal permission to copy, distribute and/or modify it.\
-\
- For the developers' and authors' protection, the GPL clearly explains\
-that there is no warranty for this free software. For both users' and\
-authors' sake, the GPL requires that modified versions be marked as\
-changed, so that their problems will not be attributed erroneously to\
-authors of previous versions.\
-\
- Some devices are designed to deny users access to install or run\
-modified versions of the software inside them, although the manufacturer\
-can do so. This is fundamentally incompatible with the aim of\
-protecting users' freedom to change the software. The systematic\
-pattern of such abuse occurs in the area of products for individuals to\
-use, which is precisely where it is most unacceptable. Therefore, we\
-have designed this version of the GPL to prohibit the practice for those\
-products. If such problems arise substantially in other domains, we\
-stand ready to extend this provision to those domains in future versions\
-of the GPL, as needed to protect the freedom of users.\
-\
- Finally, every program is threatened constantly by software patents.\
-States should not allow patents to restrict development and use of\
-software on general-purpose computers, but in those that do, we wish to\
-avoid the special danger that patents applied to a free program could\
-make it effectively proprietary. To prevent this, the GPL assures that\
-patents cannot be used to render the program non-free.\
-\
- The precise terms and conditions for copying, distribution and\
-modification follow.\
-\
- TERMS AND CONDITIONS\
-\
- 0. Definitions.\
-\
- "This License" refers to version 3 of the GNU General Public License.\
-\
- "Copyright" also means copyright-like laws that apply to other kinds of\
-works, such as semiconductor masks.\
-\
- "The Program" refers to any copyrightable work licensed under this\
-License. Each licensee is addressed as "you". "Licensees" and\
-"recipients" may be individuals or organizations.\
-\
- To "modify" a work means to copy from or adapt all or part of the work\
-in a fashion requiring copyright permission, other than the making of an\
-exact copy. The resulting work is called a "modified version" of the\
-earlier work or a work "based on" the earlier work.\
-\
- A "covered work" means either the unmodified Program or a work based\
-on the Program.\
-\
- To "propagate" a work means to do anything with it that, without\
-permission, would make you directly or secondarily liable for\
-infringement under applicable copyright law, except executing it on a\
-computer or modifying a private copy. Propagation includes copying,\
-distribution (with or without modification), making available to the\
-public, and in some countries other activities as well.\
-\
- To "convey" a work means any kind of propagation that enables other\
-parties to make or receive copies. Mere interaction with a user through\
-a computer network, with no transfer of a copy, is not conveying.\
-\
- An interactive user interface displays "Appropriate Legal Notices"\
-to the extent that it includes a convenient and prominently visible\
-feature that (1) displays an appropriate copyright notice, and (2)\
-tells the user that there is no warranty for the work (except to the\
-extent that warranties are provided), that licensees may convey the\
-work under this License, and how to view a copy of this License. If\
-the interface presents a list of user commands or options, such as a\
-menu, a prominent item in the list meets this criterion.\
-\
- 1. Source Code.\
-\
- The "source code" for a work means the preferred form of the work\
-for making modifications to it. "Object code" means any non-source\
-form of a work.\
-\
- A "Standard Interface" means an interface that either is an official\
-standard defined by a recognized standards body, or, in the case of\
-interfaces specified for a particular programming language, one that\
-is widely used among developers working in that language.\
-\
- The "System Libraries" of an executable work include anything, other\
-than the work as a whole, that (a) is included in the normal form of\
-packaging a Major Component, but which is not part of that Major\
-Component, and (b) serves only to enable use of the work with that\
-Major Component, or to implement a Standard Interface for which an\
-implementation is available to the public in source code form. A\
-"Major Component", in this context, means a major essential component\
-(kernel, window system, and so on) of the specific operating system\
-(if any) on which the executable work runs, or a compiler used to\
-produce the work, or an object code interpreter used to run it.\
-\
- The "Corresponding Source" for a work in object code form means all\
-the source code needed to generate, install, and (for an executable\
-work) run the object code and to modify the work, including scripts to\
-control those activities. However, it does not include the work's\
-System Libraries, or general-purpose tools or generally available free\
-programs which are used unmodified in performing those activities but\
-which are not part of the work. For example, Corresponding Source\
-includes interface definition files associated with source files for\
-the work, and the source code for shared libraries and dynamically\
-linked subprograms that the work is specifically designed to require,\
-such as by intimate data communication or control flow between those\
-subprograms and other parts of the work.\
-\
- The Corresponding Source need not include anything that users\
-can regenerate automatically from other parts of the Corresponding\
-Source.\
-\
- The Corresponding Source for a work in source code form is that\
-same work.\
-\
- 2. Basic Permissions.\
-\
- All rights granted under this License are granted for the term of\
-copyright on the Program, and are irrevocable provided the stated\
-conditions are met. This License explicitly affirms your unlimited\
-permission to run the unmodified Program. The output from running a\
-covered work is covered by this License only if the output, given its\
-content, constitutes a covered work. This License acknowledges your\
-rights of fair use or other equivalent, as provided by copyright law.\
-\
- You may make, run and propagate covered works that you do not\
-convey, without conditions so long as your license otherwise remains\
-in force. You may convey covered works to others for the sole purpose\
-of having them make modifications exclusively for you, or provide you\
-with facilities for running those works, provided that you comply with\
-the terms of this License in conveying all material for which you do\
-not control copyright. Those thus making or running the covered works\
-for you must do so exclusively on your behalf, under your direction\
-and control, on terms that prohibit them from making any copies of\
-your copyrighted material outside their relationship with you.\
-\
- Conveying under any other circumstances is permitted solely under\
-the conditions stated below. Sublicensing is not allowed; section 10\
-makes it unnecessary.\
-\
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\
-\
- No covered work shall be deemed part of an effective technological\
-measure under any applicable law fulfilling obligations under article\
-11 of the WIPO copyright treaty adopted on 20 December 1996, or\
-similar laws prohibiting or restricting circumvention of such\
-measures.\
-\
- When you convey a covered work, you waive any legal power to forbid\
-circumvention of technological measures to the extent such circumvention\
-is effected by exercising rights under this License with respect to\
-the covered work, and you disclaim any intention to limit operation or\
-modification of the work as a means of enforcing, against the work's\
-users, your or third parties' legal rights to forbid circumvention of\
-technological measures.\
-\
- 4. Conveying Verbatim Copies.\
-\
- You may convey verbatim copies of the Program's source code as you\
-receive it, in any medium, provided that you conspicuously and\
-appropriately publish on each copy an appropriate copyright notice;\
-keep intact all notices stating that this License and any\
-non-permissive terms added in accord with section 7 apply to the code;\
-keep intact all notices of the absence of any warranty; and give all\
-recipients a copy of this License along with the Program.\
-\
- You may charge any price or no price for each copy that you convey,\
-and you may offer support or warranty protection for a fee.\
-\
- 5. Conveying Modified Source Versions.\
-\
- You may convey a work based on the Program, or the modifications to\
-produce it from the Program, in the form of source code under the\
-terms of section 4, provided that you also meet all of these conditions:\
-\
- a) The work must carry prominent notices stating that you modified\
- it, and giving a relevant date.\
-\
- b) The work must carry prominent notices stating that it is\
- released under this License and any conditions added under section\
- 7. This requirement modifies the requirement in section 4 to\
- "keep intact all notices".\
-\
- c) You must license the entire work, as a whole, under this\
- License to anyone who comes into possession of a copy. This\
- License will therefore apply, along with any applicable section 7\
- additional terms, to the whole of the work, and all its parts,\
- regardless of how they are packaged. This License gives no\
- permission to license the work in any other way, but it does not\
- invalidate such permission if you have separately received it.\
-\
- d) If the work has interactive user interfaces, each must display\
- Appropriate Legal Notices; however, if the Program has interactive\
- interfaces that do not display Appropriate Legal Notices, your\
- work need not make them do so.\
-\
- A compilation of a covered work with other separate and independent\
-works, which are not by their nature extensions of the covered work,\
-and which are not combined with it such as to form a larger program,\
-in or on a volume of a storage or distribution medium, is called an\
-"aggregate" if the compilation and its resulting copyright are not\
-used to limit the access or legal rights of the compilation's users\
-beyond what the individual works permit. Inclusion of a covered work\
-in an aggregate does not cause this License to apply to the other\
-parts of the aggregate.\
-\
- 6. Conveying Non-Source Forms.\
-\
- You may convey a covered work in object code form under the terms\
-of sections 4 and 5, provided that you also convey the\
-machine-readable Corresponding Source under the terms of this License,\
-in one of these ways:\
-\
- a) Convey the object code in, or embodied in, a physical product\
- (including a physical distribution medium), accompanied by the\
- Corresponding Source fixed on a durable physical medium\
- customarily used for software interchange.\
-\
- b) Convey the object code in, or embodied in, a physical product\
- (including a physical distribution medium), accompanied by a\
- written offer, valid for at least three years and valid for as\
- long as you offer spare parts or customer support for that product\
- model, to give anyone who possesses the object code either (1) a\
- copy of the Corresponding Source for all the software in the\
- product that is covered by this License, on a durable physical\
- medium customarily used for software interchange, for a price no\
- more than your reasonable cost of physically performing this\
- conveying of source, or (2) access to copy the\
- Corresponding Source from a network server at no charge.\
-\
- c) Convey individual copies of the object code with a copy of the\
- written offer to provide the Corresponding Source. This\
- alternative is allowed only occasionally and noncommercially, and\
- only if you received the object code with such an offer, in accord\
- with subsection 6b.\
-\
- d) Convey the object code by offering access from a designated\
- place (gratis or for a charge), and offer equivalent access to the\
- Corresponding Source in the same way through the same place at no\
- further charge. You need not require recipients to copy the\
- Corresponding Source along with the object code. If the place to\
- copy the object code is a network server, the Corresponding Source\
- may be on a different server (operated by you or a third party)\
- that supports equivalent copying facilities, provided you maintain\
- clear directions next to the object code saying where to find the\
- Corresponding Source. Regardless of what server hosts the\
- Corresponding Source, you remain obligated to ensure that it is\
- available for as long as needed to satisfy these requirements.\
-\
- e) Convey the object code using peer-to-peer transmission, provided\
- you inform other peers where the object code and Corresponding\
- Source of the work are being offered to the general public at no\
- charge under subsection 6d.\
-\
- A separable portion of the object code, whose source code is excluded\
-from the Corresponding Source as a System Library, need not be\
-included in conveying the object code work.\
-\
- A "User Product" is either (1) a "consumer product", which means any\
-tangible personal property which is normally used for personal, family,\
-or household purposes, or (2) anything designed or sold for incorporation\
-into a dwelling. In determining whether a product is a consumer product,\
-doubtful cases shall be resolved in favor of coverage. For a particular\
-product received by a particular user, "normally used" refers to a\
-typical or common use of that class of product, regardless of the status\
-of the particular user or of the way in which the particular user\
-actually uses, or expects or is expected to use, the product. A product\
-is a consumer product regardless of whether the product has substantial\
-commercial, industrial or non-consumer uses, unless such uses represent\
-the only significant mode of use of the product.\
-\
- "Installation Information" for a User Product means any methods,\
-procedures, authorization keys, or other information required to install\
-and execute modified versions of a covered work in that User Product from\
-a modified version of its Corresponding Source. The information must\
-suffice to ensure that the continued functioning of the modified object\
-code is in no case prevented or interfered with solely because\
-modification has been made.\
-\
- If you convey an object code work under this section in, or with, or\
-specifically for use in, a User Product, and the conveying occurs as\
-part of a transaction in which the right of possession and use of the\
-User Product is transferred to the recipient in perpetuity or for a\
-fixed term (regardless of how the transaction is characterized), the\
-Corresponding Source conveyed under this section must be accompanied\
-by the Installation Information. But this requirement does not apply\
-if neither you nor any third party retains the ability to install\
-modified object code on the User Product (for example, the work has\
-been installed in ROM).\
-\
- The requirement to provide Installation Information does not include a\
-requirement to continue to provide support service, warranty, or updates\
-for a work that has been modified or installed by the recipient, or for\
-the User Product in which it has been modified or installed. Access to a\
-network may be denied when the modification itself materially and\
-adversely affects the operation of the network or violates the rules and\
-protocols for communication across the network.\
-\
- Corresponding Source conveyed, and Installation Information provided,\
-in accord with this section must be in a format that is publicly\
-documented (and with an implementation available to the public in\
-source code form), and must require no special password or key for\
-unpacking, reading or copying.\
-\
- 7. Additional Terms.\
-\
- "Additional permissions" are terms that supplement the terms of this\
-License by making exceptions from one or more of its conditions.\
-Additional permissions that are applicable to the entire Program shall\
-be treated as though they were included in this License, to the extent\
-that they are valid under applicable law. If additional permissions\
-apply only to part of the Program, that part may be used separately\
-under those permissions, but the entire Program remains governed by\
-this License without regard to the additional permissions.\
-\
- When you convey a copy of a covered work, you may at your option\
-remove any additional permissions from that copy, or from any part of\
-it. (Additional permissions may be written to require their own\
-removal in certain cases when you modify the work.) You may place\
-additional permissions on material, added by you to a covered work,\
-for which you have or can give appropriate copyright permission.\
-\
- Notwithstanding any other provision of this License, for material you\
-add to a covered work, you may (if authorized by the copyright holders of\
-that material) supplement the terms of this License with terms:\
-\
- a) Disclaiming warranty or limiting liability differently from the\
- terms of sections 15 and 16 of this License; or\
-\
- b) Requiring preservation of specified reasonable legal notices or\
- author attributions in that material or in the Appropriate Legal\
- Notices displayed by works containing it; or\
-\
- c) Prohibiting misrepresentation of the origin of that material, or\
- requiring that modified versions of such material be marked in\
- reasonable ways as different from the original version; or\
-\
- d) Limiting the use for publicity purposes of names of licensors or\
- authors of the material; or\
-\
- e) Declining to grant rights under trademark law for use of some\
- trade names, trademarks, or service marks; or\
-\
- f) Requiring indemnification of licensors and authors of that\
- material by anyone who conveys the material (or modified versions of\
- it) with contractual assumptions of liability to the recipient, for\
- any liability that these contractual assumptions directly impose on\
- those licensors and authors.\
-\
- All other non-permissive additional terms are considered "further\
-restrictions" within the meaning of section 10. If the Program as you\
-received it, or any part of it, contains a notice stating that it is\
-governed by this License along with a term that is a further\
-restriction, you may remove that term. If a license document contains\
-a further restriction but permits relicensing or conveying under this\
-License, you may add to a covered work material governed by the terms\
-of that license document, provided that the further restriction does\
-not survive such relicensing or conveying.\
-\
- If you add terms to a covered work in accord with this section, you\
-must place, in the relevant source files, a statement of the\
-additional terms that apply to those files, or a notice indicating\
-where to find the applicable terms.\
-\
- Additional terms, permissive or non-permissive, may be stated in the\
-form of a separately written license, or stated as exceptions;\
-the above requirements apply either way.\
-\
- 8. Termination.\
-\
- You may not propagate or modify a covered work except as expressly\
-provided under this License. Any attempt otherwise to propagate or\
-modify it is void, and will automatically terminate your rights under\
-this License (including any patent licenses granted under the third\
-paragraph of section 11).\
-\
- However, if you cease all violation of this License, then your\
-license from a particular copyright holder is reinstated (a)\
-provisionally, unless and until the copyright holder explicitly and\
-finally terminates your license, and (b) permanently, if the copyright\
-holder fails to notify you of the violation by some reasonable means\
-prior to 60 days after the cessation.\
-\
- Moreover, your license from a particular copyright holder is\
-reinstated permanently if the copyright holder notifies you of the\
-violation by some reasonable means, this is the first time you have\
-received notice of violation of this License (for any work) from that\
-copyright holder, and you cure the violation prior to 30 days after\
-your receipt of the notice.\
-\
- Termination of your rights under this section does not terminate the\
-licenses of parties who have received copies or rights from you under\
-this License. If your rights have been terminated and not permanently\
-reinstated, you do not qualify to receive new licenses for the same\
-material under section 10.\
-\
- 9. Acceptance Not Required for Having Copies.\
-\
- You are not required to accept this License in order to receive or\
-run a copy of the Program. Ancillary propagation of a covered work\
-occurring solely as a consequence of using peer-to-peer transmission\
-to receive a copy likewise does not require acceptance. However,\
-nothing other than this License grants you permission to propagate or\
-modify any covered work. These actions infringe copyright if you do\
-not accept this License. Therefore, by modifying or propagating a\
-covered work, you indicate your acceptance of this License to do so.\
-\
- 10. Automatic Licensing of Downstream Recipients.\
-\
- Each time you convey a covered work, the recipient automatically\
-receives a license from the original licensors, to run, modify and\
-propagate that work, subject to this License. You are not responsible\
-for enforcing compliance by third parties with this License.\
-\
- An "entity transaction" is a transaction transferring control of an\
-organization, or substantially all assets of one, or subdividing an\
-organization, or merging organizations. If propagation of a covered\
-work results from an entity transaction, each party to that\
-transaction who receives a copy of the work also receives whatever\
-licenses to the work the party's predecessor in interest had or could\
-give under the previous paragraph, plus a right to possession of the\
-Corresponding Source of the work from the predecessor in interest, if\
-the predecessor has it or can get it with reasonable efforts.\
-\
- You may not impose any further restrictions on the exercise of the\
-rights granted or affirmed under this License. For example, you may\
-not impose a license fee, royalty, or other charge for exercise of\
-rights granted under this License, and you may not initiate litigation\
-(including a cross-claim or counterclaim in a lawsuit) alleging that\
-any patent claim is infringed by making, using, selling, offering for\
-sale, or importing the Program or any portion of it.\
-\
- 11. Patents.\
-\
- A "contributor" is a copyright holder who authorizes use under this\
-License of the Program or a work on which the Program is based. The\
-work thus licensed is called the contributor's "contributor version".\
-\
- A contributor's "essential patent claims" are all patent claims\
-owned or controlled by the contributor, whether already acquired or\
-hereafter acquired, that would be infringed by some manner, permitted\
-by this License, of making, using, or selling its contributor version,\
-but do not include claims that would be infringed only as a\
-consequence of further modification of the contributor version. For\
-purposes of this definition, "control" includes the right to grant\
-patent sublicenses in a manner consistent with the requirements of\
-this License.\
-\
- Each contributor grants you a non-exclusive, worldwide, royalty-free\
-patent license under the contributor's essential patent claims, to\
-make, use, sell, offer for sale, import and otherwise run, modify and\
-propagate the contents of its contributor version.\
-\
- In the following three paragraphs, a "patent license" is any express\
-agreement or commitment, however denominated, not to enforce a patent\
-(such as an express permission to practice a patent or covenant not to\
-sue for patent infringement). To "grant" such a patent license to a\
-party means to make such an agreement or commitment not to enforce a\
-patent against the party.\
-\
- If you convey a covered work, knowingly relying on a patent license,\
-and the Corresponding Source of the work is not available for anyone\
-to copy, free of charge and under the terms of this License, through a\
-publicly available network server or other readily accessible means,\
-then you must either (1) cause the Corresponding Source to be so\
-available, or (2) arrange to deprive yourself of the benefit of the\
-patent license for this particular work, or (3) arrange, in a manner\
-consistent with the requirements of this License, to extend the patent\
-license to downstream recipients. "Knowingly relying" means you have\
-actual knowledge that, but for the patent license, your conveying the\
-covered work in a country, or your recipient's use of the covered work\
-in a country, would infringe one or more identifiable patents in that\
-country that you have reason to believe are valid.\
-\
- If, pursuant to or in connection with a single transaction or\
-arrangement, you convey, or propagate by procuring conveyance of, a\
-covered work, and grant a patent license to some of the parties\
-receiving the covered work authorizing them to use, propagate, modify\
-or convey a specific copy of the covered work, then the patent license\
-you grant is automatically extended to all recipients of the covered\
-work and works based on it.\
-\
- A patent license is "discriminatory" if it does not include within\
-the scope of its coverage, prohibits the exercise of, or is\
-conditioned on the non-exercise of one or more of the rights that are\
-specifically granted under this License. You may not convey a covered\
-work if you are a party to an arrangement with a third party that is\
-in the business of distributing software, under which you make payment\
-to the third party based on the extent of your activity of conveying\
-the work, and under which the third party grants, to any of the\
-parties who would receive the covered work from you, a discriminatory\
-patent license (a) in connection with copies of the covered work\
-conveyed by you (or copies made from those copies), or (b) primarily\
-for and in connection with specific products or compilations that\
-contain the covered work, unless you entered into that arrangement,\
-or that patent license was granted, prior to 28 March 2007.\
-\
- Nothing in this License shall be construed as excluding or limiting\
-any implied license or other defenses to infringement that may\
-otherwise be available to you under applicable patent law.\
-\
- 12. No Surrender of Others' Freedom.\
-\
- If conditions are imposed on you (whether by court order, agreement or\
-otherwise) that contradict the conditions of this License, they do not\
-excuse you from the conditions of this License. If you cannot convey a\
-covered work so as to satisfy simultaneously your obligations under this\
-License and any other pertinent obligations, then as a consequence you may\
-not convey it at all. For example, if you agree to terms that obligate you\
-to collect a royalty for further conveying from those to whom you convey\
-the Program, the only way you could satisfy both those terms and this\
-License would be to refrain entirely from conveying the Program.\
-\
- 13. Use with the GNU Affero General Public License.\
-\
- Notwithstanding any other provision of this License, you have\
-permission to link or combine any covered work with a work licensed\
-under version 3 of the GNU Affero General Public License into a single\
-combined work, and to convey the resulting work. The terms of this\
-License will continue to apply to the part which is the covered work,\
-but the special requirements of the GNU Affero General Public License,\
-section 13, concerning interaction through a network will apply to the\
-combination as such.\
-\
- 14. Revised Versions of this License.\
-\
- The Free Software Foundation may publish revised and/or new versions of\
-the GNU General Public License from time to time. Such new versions will\
-be similar in spirit to the present version, but may differ in detail to\
-address new problems or concerns.\
-\
- Each version is given a distinguishing version number. If the\
-Program specifies that a certain numbered version of the GNU General\
-Public License "or any later version" applies to it, you have the\
-option of following the terms and conditions either of that numbered\
-version or of any later version published by the Free Software\
-Foundation. If the Program does not specify a version number of the\
-GNU General Public License, you may choose any version ever published\
-by the Free Software Foundation.\
-\
- If the Program specifies that a proxy can decide which future\
-versions of the GNU General Public License can be used, that proxy's\
-public statement of acceptance of a version permanently authorizes you\
-to choose that version for the Program.\
-\
- Later license versions may give you additional or different\
-permissions. However, no additional obligations are imposed on any\
-author or copyright holder as a result of your choosing to follow a\
-later version.\
-\
- 15. Disclaimer of Warranty.\
-\
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\
-\
- 16. Limitation of Liability.\
-\
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\
-SUCH DAMAGES.\
-\
- 17. Interpretation of Sections 15 and 16.\
-\
- If the disclaimer of warranty and limitation of liability provided\
-above cannot be given local legal effect according to their terms,\
-reviewing courts shall apply local law that most closely approximates\
-an absolute waiver of all civil liability in connection with the\
-Program, unless a warranty or assumption of liability accompanies a\
-copy of the Program in return for a fee.\
-\
- END OF TERMS AND CONDITIONS\
-\
- How to Apply These Terms to Your New Programs\
-\
- If you develop a new program, and you want it to be of the greatest\
-possible use to the public, the best way to achieve this is to make it\
-free software which everyone can redistribute and change under these terms.\
-\
- To do so, attach the following notices to the program. It is safest\
-to attach them to the start of each source file to most effectively\
-state the exclusion of warranty; and each file should have at least\
-the "copyright" line and a pointer to where the full notice is found.\
-\
- <one line to give the program's name and a brief idea of what it does.>\
- Copyright (C) <year> <name of author>\
-\
- 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 3 of the License, or\
- (at your option) any later version.\
-\
- This program is distributed in the hope that it will be useful,\
- but WITHOUT ANY WARRANTY; without even the implied warranty of\
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
- GNU General Public License for more details.\
-\
- You should have received a copy of the GNU General Public License\
- along with this program. If not, see <http://www.gnu.org/licenses/>.\
-\
-Also add information on how to contact you by electronic and paper mail.\
-\
- If the program does terminal interaction, make it output a short\
-notice like this when it starts in an interactive mode:\
-\
- <program> Copyright (C) <year> <name of author>\
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\
- This is free software, and you are welcome to redistribute it\
- under certain conditions; type `show c' for details.\
-\
-The hypothetical commands `show w' and `show c' should show the appropriate\
-parts of the General Public License. Of course, your program's commands\
-might be different; for a GUI interface, you would use an "about box".\
-\
- You should also get your employer (if you work as a programmer) or school,\
-if any, to sign a "copyright disclaimer" for the program, if necessary.\
-For more information on this, and how to apply and follow the GNU GPL, see\
-<http://www.gnu.org/licenses/>.\
-\
- The GNU General Public License does not permit incorporating your program\
-into proprietary programs. If your program is a subroutine library, you\
-may consider it more useful to permit linking proprietary applications with\
-the library. If this is what you want to do, use the GNU Lesser General\
-Public License instead of this License. But first, please read\
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.\
-}
\ No newline at end of file
diff --git a/installers/osx/PkgResources_i386/ReadMe.rtf b/installers/osx/PkgResources_i386/ReadMe.rtf
deleted file mode 100755
index ab49df1..0000000
--- a/installers/osx/PkgResources_i386/ReadMe.rtf
+++ /dev/null
@@ -1,92 +0,0 @@
-{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
-{\fonttbl\f0\fnil\fcharset0 LucidaGrande;\f1\froman\fcharset0 Times-Roman;}
-{\colortbl;\red255\green255\blue255;}
-\margl1440\margr1440\vieww14120\viewh11700\viewkind0
-\deftab720
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720
-
-\f0\fs26 \cf0 pyo (version 0.6.6)
-\f1\fs24 \
-
-\f0\fs26 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural
-\cf0 System requirements : OS X 10.5 or higher
-\f1\fs24 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720
-
-\f0\fs26 \cf0 \
-This package installs all the required components to run pyo inside your current Python installation. Python 2.5, 2.6 (preferred) or 2.7 (32-bit Mac OS X Installer) must be already installed on your system.
-\f1\fs24 \
-
-\f0\fs26 \
-This package is divided into two separate installers. If you do not require one of them, please unselect the package in custom installation mode.
-\f1\fs24 \
-
-\f0\fs26 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720
-
-\b \cf0 1. pyo extension:
-\f1\b0\fs24 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720
-
-\f0\fs26 \cf0 The following components will be installed in the site-packages folder of the current Python Framework:
-\f1\fs24 \
-
-\f0\fs26 \
-_pyo.so
-\f1\fs24 \
-
-\f0\fs26 _pyo64.so
-\f1\fs24 \
-
-\f0\fs26 pyo.py
-\f1\fs24 \
-
-\f0\fs26 pyo64.py
-\f1\fs24 \
-
-\f0\fs26 pyolib (folder)
-\f1\fs24 \
-
-\f0\fs26 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720
-
-\b \cf0 2. Support libraries (i386):
-\f1\b0\fs24 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720
-
-\f0\fs26 \cf0 This component will install a number of dynamic libraries on which pyo depends. If you already have these, then you can skip this installation.
-\f1\fs24 \
-
-\f0\fs26 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720
-
-\b \cf0 Warning:
-\b0 this installation will overwrite any previously installed libraries. These are the libraries that will be installed in your /usr/local/lib directory:
-\f1\fs24 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720
-
-\f0\fs26 \cf0 \
-liblo.0.dylib
-\f1\fs24 \
-
-\f0\fs26 libportaudio.2.dylib
-\f1\fs24 \
-
-\f0\fs26 libportmidi.dylib
-\f1\fs24 \
-
-\f0\fs26 libsndfile.1.dylib
-\f1\fs24 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural
-
-\f0\fs26 \cf0 libFLAC.8.dylib\
-libvorbisenc.2.dylib\
-libvorbis.0.dylib\
-libogg.0.dylib\
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720
-\cf0 \
-\pard\pardeftab720\ql\qnatural
-\cf0 Olivier B\'e9langer, 2013
-\f1\fs24 \
-}
\ No newline at end of file
diff --git a/installers/osx/PkgResources_i386/Welcome.rtf b/installers/osx/PkgResources_i386/Welcome.rtf
deleted file mode 100755
index b8b9917..0000000
--- a/installers/osx/PkgResources_i386/Welcome.rtf
+++ /dev/null
@@ -1,7 +0,0 @@
-{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
-{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
-{\colortbl;\red255\green255\blue255;}
-\margl1440\margr1440\vieww10100\viewh11340\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
-
-\f0\fs26 \cf0 You are about to install pyo in your computer. This includes the pyo Python module and support libs.}
\ No newline at end of file
diff --git a/installers/osx/PkgResources_i386/postinstall b/installers/osx/PkgResources_i386/postinstall
deleted file mode 100755
index 21e721a..0000000
--- a/installers/osx/PkgResources_i386/postinstall
+++ /dev/null
@@ -1,106 +0,0 @@
-#! /bin/sh
-
-VERSION=`sw_vers -productVersion | sed -e 's/\.//g'`
-
-if [ $VERSION -ge '1070' ]; then
- echo "Install pyo on OSX 10.7";
-elif [ $VERSION -ge '1060' ]; then
- echo "Install pyo on OSX 10.6";
-else
- echo "Install pyo on OSX 10.5";
-fi
-
-# Removed older versions in the python site-packages builtin directories
-# Removed older versions in the python site-packages from python.org install directories
-PATHS=/Library/Python/2.5/site-packages/:/Library/Python/2.6/site-packages/:/Library/Python/2.7/site-packages/:/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
-for path in ${PATHS//:/ }; do
- if cd $path; then
- if [ -f pyo.py ]; then
- sudo rm pyo.py;
- fi
- if [ -f pyo64.py ]; then
- sudo rm pyo64.py;
- fi
- if [ -f pyo.pyc ]; then
- sudo rm pyo.pyc;
- fi
- if [ -f pyo64.pyc ]; then
- sudo rm pyo64.pyc;
- fi
- if [ -f _pyo.so ]; then
- sudo rm _pyo.so;
- fi
- if [ -f _pyo64.so ]; then
- sudo rm _pyo64.so;
- fi
- if [ -d pyolib ]; then
- sudo rm -rf pyolib/;
- fi
- ls -1 pyo*-info > /dev/null 2>&1
- if [ "$?" = "0" ]; then
- sudo rm pyo*-info;
- fi
- fi
-done
-
-# Install pyo in the python site-packages builtin directories
-if [ $VERSION -ge '1070' ]; then
- if cd /Library/Python/2.7/site-packages/; then
- sudo cp -r /tmp/python27/* .
- else
- sudo mkdir -p /Library/Python/2.7/site-packages/
- cd /Library/Python/2.7/site-packages/
- sudo cp -r /tmp/python27/* .
- fi
-else
- if cd /Library/Python/2.6/site-packages/; then
- sudo cp -r /tmp/python26/* .
- else
- sudo mkdir -p /Library/Python/2.6/site-packages/
- cd /Library/Python/2.6/site-packages/
- sudo cp -r /tmp/python26/* .
- fi
-fi
-
-# Install pyo in the python site-packages from python.org install directories
-if cd /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/; then
- sudo cp -r /tmp/python26/* .
-else
- sudo mkdir -p /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
- cd /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
- sudo cp -r /tmp/python26/* .
-fi
-
-if cd /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/; then
- sudo cp -r /tmp/python27/* .
-else
- sudo mkdir -p /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
- cd /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
- sudo cp -r /tmp/python27/* .
-fi
-
-sudo rm -rf /tmp/python2*
-
-# Add /usr/local/lib in .bash_profile if not already done
-searchString="/usr/local/lib"
-
-if [ -f ~/.bash_profile ]; then
- if `cat ~/.bash_profile | grep "${searchString}" 1>/dev/null 2>&1`; then
- echo "path already in PATH variable";
- else
- echo "adding path to .bash_profile..."
- echo "export PATH=/usr/local/lib:/usr/local/bin:\$PATH" >> ~/.bash_profile;
- fi
-else
- echo "creating .bash_profile and adding path to it..."
- echo "export PATH=/usr/local/lib:/usr/local/bin:\$PATH" > ~/.bash_profile;
-fi
-
-# Add VERSIONER_PYTHON_PREFER_32_BIT in .bash_profile if not already done
-searchString="VERSIONER_PYTHON_PREFER_32_BIT"
-
-if `cat ~/.bash_profile | grep "${searchString}" 1>/dev/null 2>&1`; then
- echo "Variable VERSIONER_PYTHON_PREFER_32_BIT already set.";
-else
- echo "export VERSIONER_PYTHON_PREFER_32_BIT=yes" >> ~/.bash_profile;
-fi
diff --git a/installers/osx/PkgResources_i386/postupgrade b/installers/osx/PkgResources_i386/postupgrade
deleted file mode 100755
index 21e721a..0000000
--- a/installers/osx/PkgResources_i386/postupgrade
+++ /dev/null
@@ -1,106 +0,0 @@
-#! /bin/sh
-
-VERSION=`sw_vers -productVersion | sed -e 's/\.//g'`
-
-if [ $VERSION -ge '1070' ]; then
- echo "Install pyo on OSX 10.7";
-elif [ $VERSION -ge '1060' ]; then
- echo "Install pyo on OSX 10.6";
-else
- echo "Install pyo on OSX 10.5";
-fi
-
-# Removed older versions in the python site-packages builtin directories
-# Removed older versions in the python site-packages from python.org install directories
-PATHS=/Library/Python/2.5/site-packages/:/Library/Python/2.6/site-packages/:/Library/Python/2.7/site-packages/:/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
-for path in ${PATHS//:/ }; do
- if cd $path; then
- if [ -f pyo.py ]; then
- sudo rm pyo.py;
- fi
- if [ -f pyo64.py ]; then
- sudo rm pyo64.py;
- fi
- if [ -f pyo.pyc ]; then
- sudo rm pyo.pyc;
- fi
- if [ -f pyo64.pyc ]; then
- sudo rm pyo64.pyc;
- fi
- if [ -f _pyo.so ]; then
- sudo rm _pyo.so;
- fi
- if [ -f _pyo64.so ]; then
- sudo rm _pyo64.so;
- fi
- if [ -d pyolib ]; then
- sudo rm -rf pyolib/;
- fi
- ls -1 pyo*-info > /dev/null 2>&1
- if [ "$?" = "0" ]; then
- sudo rm pyo*-info;
- fi
- fi
-done
-
-# Install pyo in the python site-packages builtin directories
-if [ $VERSION -ge '1070' ]; then
- if cd /Library/Python/2.7/site-packages/; then
- sudo cp -r /tmp/python27/* .
- else
- sudo mkdir -p /Library/Python/2.7/site-packages/
- cd /Library/Python/2.7/site-packages/
- sudo cp -r /tmp/python27/* .
- fi
-else
- if cd /Library/Python/2.6/site-packages/; then
- sudo cp -r /tmp/python26/* .
- else
- sudo mkdir -p /Library/Python/2.6/site-packages/
- cd /Library/Python/2.6/site-packages/
- sudo cp -r /tmp/python26/* .
- fi
-fi
-
-# Install pyo in the python site-packages from python.org install directories
-if cd /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/; then
- sudo cp -r /tmp/python26/* .
-else
- sudo mkdir -p /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
- cd /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
- sudo cp -r /tmp/python26/* .
-fi
-
-if cd /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/; then
- sudo cp -r /tmp/python27/* .
-else
- sudo mkdir -p /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
- cd /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
- sudo cp -r /tmp/python27/* .
-fi
-
-sudo rm -rf /tmp/python2*
-
-# Add /usr/local/lib in .bash_profile if not already done
-searchString="/usr/local/lib"
-
-if [ -f ~/.bash_profile ]; then
- if `cat ~/.bash_profile | grep "${searchString}" 1>/dev/null 2>&1`; then
- echo "path already in PATH variable";
- else
- echo "adding path to .bash_profile..."
- echo "export PATH=/usr/local/lib:/usr/local/bin:\$PATH" >> ~/.bash_profile;
- fi
-else
- echo "creating .bash_profile and adding path to it..."
- echo "export PATH=/usr/local/lib:/usr/local/bin:\$PATH" > ~/.bash_profile;
-fi
-
-# Add VERSIONER_PYTHON_PREFER_32_BIT in .bash_profile if not already done
-searchString="VERSIONER_PYTHON_PREFER_32_BIT"
-
-if `cat ~/.bash_profile | grep "${searchString}" 1>/dev/null 2>&1`; then
- echo "Variable VERSIONER_PYTHON_PREFER_32_BIT already set.";
-else
- echo "export VERSIONER_PYTHON_PREFER_32_BIT=yes" >> ~/.bash_profile;
-fi
diff --git a/installers/osx/PkgResources_x86_64/License.rtf b/installers/osx/PkgResources_x86_64/License.rtf
index 66b2d2a..50a49ab 100755
--- a/installers/osx/PkgResources_x86_64/License.rtf
+++ b/installers/osx/PkgResources_x86_64/License.rtf
@@ -1,681 +1,423 @@
-{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
-{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
-{\colortbl;\red255\green255\blue255;}
-\margl1440\margr1440\vieww10100\viewh11340\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
-
-\f0\fs26 \cf0 GNU GENERAL PUBLIC LICENSE\
- Version 3, 29 June 2007\
-\
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\
- Everyone is permitted to copy and distribute verbatim copies\
- of this license document, but changing it is not allowed.\
-\
- Preamble\
-\
- The GNU General Public License is a free, copyleft license for\
-software and other kinds of works.\
-\
- The licenses for most software and other practical works are designed\
-to take away your freedom to share and change the works. By contrast,\
-the GNU General Public License is intended to guarantee your freedom to\
-share and change all versions of a program--to make sure it remains free\
-software for all its users. We, the Free Software Foundation, use the\
-GNU General Public License for most of our software; it applies also to\
-any other work released this way by its authors. You can apply it to\
-your programs, too.\
-\
- When we speak of free software, we are referring to freedom, not\
-price. Our General Public Licenses are designed to make sure that you\
-have the freedom to distribute copies of free software (and charge for\
-them if you wish), that you receive source code or can get it if you\
-want it, that you can change the software or use pieces of it in new\
-free programs, and that you know you can do these things.\
-\
- To protect your rights, we need to prevent others from denying you\
-these rights or asking you to surrender the rights. Therefore, you have\
-certain responsibilities if you distribute copies of the software, or if\
-you modify it: responsibilities to respect the freedom of others.\
-\
- For example, if you distribute copies of such a program, whether\
-gratis or for a fee, you must pass on to the recipients the same\
-freedoms that you received. You must make sure that they, too, receive\
-or can get the source code. And you must show them these terms so they\
-know their rights.\
-\
- Developers that use the GNU GPL protect your rights with two steps:\
-(1) assert copyright on the software, and (2) offer you this License\
-giving you legal permission to copy, distribute and/or modify it.\
-\
- For the developers' and authors' protection, the GPL clearly explains\
-that there is no warranty for this free software. For both users' and\
-authors' sake, the GPL requires that modified versions be marked as\
-changed, so that their problems will not be attributed erroneously to\
-authors of previous versions.\
-\
- Some devices are designed to deny users access to install or run\
-modified versions of the software inside them, although the manufacturer\
-can do so. This is fundamentally incompatible with the aim of\
-protecting users' freedom to change the software. The systematic\
-pattern of such abuse occurs in the area of products for individuals to\
-use, which is precisely where it is most unacceptable. Therefore, we\
-have designed this version of the GPL to prohibit the practice for those\
-products. If such problems arise substantially in other domains, we\
-stand ready to extend this provision to those domains in future versions\
-of the GPL, as needed to protect the freedom of users.\
-\
- Finally, every program is threatened constantly by software patents.\
-States should not allow patents to restrict development and use of\
-software on general-purpose computers, but in those that do, we wish to\
-avoid the special danger that patents applied to a free program could\
-make it effectively proprietary. To prevent this, the GPL assures that\
-patents cannot be used to render the program non-free.\
-\
- The precise terms and conditions for copying, distribution and\
-modification follow.\
-\
- TERMS AND CONDITIONS\
-\
- 0. Definitions.\
-\
- "This License" refers to version 3 of the GNU General Public License.\
-\
- "Copyright" also means copyright-like laws that apply to other kinds of\
-works, such as semiconductor masks.\
-\
- "The Program" refers to any copyrightable work licensed under this\
-License. Each licensee is addressed as "you". "Licensees" and\
-"recipients" may be individuals or organizations.\
-\
- To "modify" a work means to copy from or adapt all or part of the work\
-in a fashion requiring copyright permission, other than the making of an\
-exact copy. The resulting work is called a "modified version" of the\
-earlier work or a work "based on" the earlier work.\
-\
- A "covered work" means either the unmodified Program or a work based\
-on the Program.\
-\
- To "propagate" a work means to do anything with it that, without\
-permission, would make you directly or secondarily liable for\
-infringement under applicable copyright law, except executing it on a\
-computer or modifying a private copy. Propagation includes copying,\
-distribution (with or without modification), making available to the\
-public, and in some countries other activities as well.\
-\
- To "convey" a work means any kind of propagation that enables other\
-parties to make or receive copies. Mere interaction with a user through\
-a computer network, with no transfer of a copy, is not conveying.\
-\
- An interactive user interface displays "Appropriate Legal Notices"\
-to the extent that it includes a convenient and prominently visible\
-feature that (1) displays an appropriate copyright notice, and (2)\
-tells the user that there is no warranty for the work (except to the\
-extent that warranties are provided), that licensees may convey the\
-work under this License, and how to view a copy of this License. If\
-the interface presents a list of user commands or options, such as a\
-menu, a prominent item in the list meets this criterion.\
-\
- 1. Source Code.\
-\
- The "source code" for a work means the preferred form of the work\
-for making modifications to it. "Object code" means any non-source\
-form of a work.\
-\
- A "Standard Interface" means an interface that either is an official\
-standard defined by a recognized standards body, or, in the case of\
-interfaces specified for a particular programming language, one that\
-is widely used among developers working in that language.\
-\
- The "System Libraries" of an executable work include anything, other\
-than the work as a whole, that (a) is included in the normal form of\
-packaging a Major Component, but which is not part of that Major\
-Component, and (b) serves only to enable use of the work with that\
-Major Component, or to implement a Standard Interface for which an\
-implementation is available to the public in source code form. A\
-"Major Component", in this context, means a major essential component\
-(kernel, window system, and so on) of the specific operating system\
-(if any) on which the executable work runs, or a compiler used to\
-produce the work, or an object code interpreter used to run it.\
-\
- The "Corresponding Source" for a work in object code form means all\
-the source code needed to generate, install, and (for an executable\
-work) run the object code and to modify the work, including scripts to\
-control those activities. However, it does not include the work's\
-System Libraries, or general-purpose tools or generally available free\
-programs which are used unmodified in performing those activities but\
-which are not part of the work. For example, Corresponding Source\
-includes interface definition files associated with source files for\
-the work, and the source code for shared libraries and dynamically\
-linked subprograms that the work is specifically designed to require,\
-such as by intimate data communication or control flow between those\
-subprograms and other parts of the work.\
-\
- The Corresponding Source need not include anything that users\
-can regenerate automatically from other parts of the Corresponding\
-Source.\
-\
- The Corresponding Source for a work in source code form is that\
-same work.\
-\
- 2. Basic Permissions.\
-\
- All rights granted under this License are granted for the term of\
-copyright on the Program, and are irrevocable provided the stated\
-conditions are met. This License explicitly affirms your unlimited\
-permission to run the unmodified Program. The output from running a\
-covered work is covered by this License only if the output, given its\
-content, constitutes a covered work. This License acknowledges your\
-rights of fair use or other equivalent, as provided by copyright law.\
-\
- You may make, run and propagate covered works that you do not\
-convey, without conditions so long as your license otherwise remains\
-in force. You may convey covered works to others for the sole purpose\
-of having them make modifications exclusively for you, or provide you\
-with facilities for running those works, provided that you comply with\
-the terms of this License in conveying all material for which you do\
-not control copyright. Those thus making or running the covered works\
-for you must do so exclusively on your behalf, under your direction\
-and control, on terms that prohibit them from making any copies of\
-your copyrighted material outside their relationship with you.\
-\
- Conveying under any other circumstances is permitted solely under\
-the conditions stated below. Sublicensing is not allowed; section 10\
-makes it unnecessary.\
-\
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\
-\
- No covered work shall be deemed part of an effective technological\
-measure under any applicable law fulfilling obligations under article\
-11 of the WIPO copyright treaty adopted on 20 December 1996, or\
-similar laws prohibiting or restricting circumvention of such\
-measures.\
-\
- When you convey a covered work, you waive any legal power to forbid\
-circumvention of technological measures to the extent such circumvention\
-is effected by exercising rights under this License with respect to\
-the covered work, and you disclaim any intention to limit operation or\
-modification of the work as a means of enforcing, against the work's\
-users, your or third parties' legal rights to forbid circumvention of\
-technological measures.\
-\
- 4. Conveying Verbatim Copies.\
-\
- You may convey verbatim copies of the Program's source code as you\
-receive it, in any medium, provided that you conspicuously and\
-appropriately publish on each copy an appropriate copyright notice;\
-keep intact all notices stating that this License and any\
-non-permissive terms added in accord with section 7 apply to the code;\
-keep intact all notices of the absence of any warranty; and give all\
-recipients a copy of this License along with the Program.\
-\
- You may charge any price or no price for each copy that you convey,\
-and you may offer support or warranty protection for a fee.\
-\
- 5. Conveying Modified Source Versions.\
-\
- You may convey a work based on the Program, or the modifications to\
-produce it from the Program, in the form of source code under the\
-terms of section 4, provided that you also meet all of these conditions:\
-\
- a) The work must carry prominent notices stating that you modified\
- it, and giving a relevant date.\
-\
- b) The work must carry prominent notices stating that it is\
- released under this License and any conditions added under section\
- 7. This requirement modifies the requirement in section 4 to\
- "keep intact all notices".\
-\
- c) You must license the entire work, as a whole, under this\
- License to anyone who comes into possession of a copy. This\
- License will therefore apply, along with any applicable section 7\
- additional terms, to the whole of the work, and all its parts,\
- regardless of how they are packaged. This License gives no\
- permission to license the work in any other way, but it does not\
- invalidate such permission if you have separately received it.\
-\
- d) If the work has interactive user interfaces, each must display\
- Appropriate Legal Notices; however, if the Program has interactive\
- interfaces that do not display Appropriate Legal Notices, your\
- work need not make them do so.\
-\
- A compilation of a covered work with other separate and independent\
-works, which are not by their nature extensions of the covered work,\
-and which are not combined with it such as to form a larger program,\
-in or on a volume of a storage or distribution medium, is called an\
-"aggregate" if the compilation and its resulting copyright are not\
-used to limit the access or legal rights of the compilation's users\
-beyond what the individual works permit. Inclusion of a covered work\
-in an aggregate does not cause this License to apply to the other\
-parts of the aggregate.\
-\
- 6. Conveying Non-Source Forms.\
-\
- You may convey a covered work in object code form under the terms\
-of sections 4 and 5, provided that you also convey the\
-machine-readable Corresponding Source under the terms of this License,\
-in one of these ways:\
-\
- a) Convey the object code in, or embodied in, a physical product\
- (including a physical distribution medium), accompanied by the\
- Corresponding Source fixed on a durable physical medium\
- customarily used for software interchange.\
-\
- b) Convey the object code in, or embodied in, a physical product\
- (including a physical distribution medium), accompanied by a\
- written offer, valid for at least three years and valid for as\
- long as you offer spare parts or customer support for that product\
- model, to give anyone who possesses the object code either (1) a\
- copy of the Corresponding Source for all the software in the\
- product that is covered by this License, on a durable physical\
- medium customarily used for software interchange, for a price no\
- more than your reasonable cost of physically performing this\
- conveying of source, or (2) access to copy the\
- Corresponding Source from a network server at no charge.\
-\
- c) Convey individual copies of the object code with a copy of the\
- written offer to provide the Corresponding Source. This\
- alternative is allowed only occasionally and noncommercially, and\
- only if you received the object code with such an offer, in accord\
- with subsection 6b.\
-\
- d) Convey the object code by offering access from a designated\
- place (gratis or for a charge), and offer equivalent access to the\
- Corresponding Source in the same way through the same place at no\
- further charge. You need not require recipients to copy the\
- Corresponding Source along with the object code. If the place to\
- copy the object code is a network server, the Corresponding Source\
- may be on a different server (operated by you or a third party)\
- that supports equivalent copying facilities, provided you maintain\
- clear directions next to the object code saying where to find the\
- Corresponding Source. Regardless of what server hosts the\
- Corresponding Source, you remain obligated to ensure that it is\
- available for as long as needed to satisfy these requirements.\
-\
- e) Convey the object code using peer-to-peer transmission, provided\
- you inform other peers where the object code and Corresponding\
- Source of the work are being offered to the general public at no\
- charge under subsection 6d.\
-\
- A separable portion of the object code, whose source code is excluded\
-from the Corresponding Source as a System Library, need not be\
-included in conveying the object code work.\
-\
- A "User Product" is either (1) a "consumer product", which means any\
-tangible personal property which is normally used for personal, family,\
-or household purposes, or (2) anything designed or sold for incorporation\
-into a dwelling. In determining whether a product is a consumer product,\
-doubtful cases shall be resolved in favor of coverage. For a particular\
-product received by a particular user, "normally used" refers to a\
-typical or common use of that class of product, regardless of the status\
-of the particular user or of the way in which the particular user\
-actually uses, or expects or is expected to use, the product. A product\
-is a consumer product regardless of whether the product has substantial\
-commercial, industrial or non-consumer uses, unless such uses represent\
-the only significant mode of use of the product.\
-\
- "Installation Information" for a User Product means any methods,\
-procedures, authorization keys, or other information required to install\
-and execute modified versions of a covered work in that User Product from\
-a modified version of its Corresponding Source. The information must\
-suffice to ensure that the continued functioning of the modified object\
-code is in no case prevented or interfered with solely because\
-modification has been made.\
-\
- If you convey an object code work under this section in, or with, or\
-specifically for use in, a User Product, and the conveying occurs as\
-part of a transaction in which the right of possession and use of the\
-User Product is transferred to the recipient in perpetuity or for a\
-fixed term (regardless of how the transaction is characterized), the\
-Corresponding Source conveyed under this section must be accompanied\
-by the Installation Information. But this requirement does not apply\
-if neither you nor any third party retains the ability to install\
-modified object code on the User Product (for example, the work has\
-been installed in ROM).\
-\
- The requirement to provide Installation Information does not include a\
-requirement to continue to provide support service, warranty, or updates\
-for a work that has been modified or installed by the recipient, or for\
-the User Product in which it has been modified or installed. Access to a\
-network may be denied when the modification itself materially and\
-adversely affects the operation of the network or violates the rules and\
-protocols for communication across the network.\
-\
- Corresponding Source conveyed, and Installation Information provided,\
-in accord with this section must be in a format that is publicly\
-documented (and with an implementation available to the public in\
-source code form), and must require no special password or key for\
-unpacking, reading or copying.\
-\
- 7. Additional Terms.\
-\
- "Additional permissions" are terms that supplement the terms of this\
-License by making exceptions from one or more of its conditions.\
-Additional permissions that are applicable to the entire Program shall\
-be treated as though they were included in this License, to the extent\
-that they are valid under applicable law. If additional permissions\
-apply only to part of the Program, that part may be used separately\
-under those permissions, but the entire Program remains governed by\
-this License without regard to the additional permissions.\
-\
- When you convey a copy of a covered work, you may at your option\
-remove any additional permissions from that copy, or from any part of\
-it. (Additional permissions may be written to require their own\
-removal in certain cases when you modify the work.) You may place\
-additional permissions on material, added by you to a covered work,\
-for which you have or can give appropriate copyright permission.\
-\
- Notwithstanding any other provision of this License, for material you\
-add to a covered work, you may (if authorized by the copyright holders of\
-that material) supplement the terms of this License with terms:\
-\
- a) Disclaiming warranty or limiting liability differently from the\
- terms of sections 15 and 16 of this License; or\
-\
- b) Requiring preservation of specified reasonable legal notices or\
- author attributions in that material or in the Appropriate Legal\
- Notices displayed by works containing it; or\
-\
- c) Prohibiting misrepresentation of the origin of that material, or\
- requiring that modified versions of such material be marked in\
- reasonable ways as different from the original version; or\
-\
- d) Limiting the use for publicity purposes of names of licensors or\
- authors of the material; or\
-\
- e) Declining to grant rights under trademark law for use of some\
- trade names, trademarks, or service marks; or\
-\
- f) Requiring indemnification of licensors and authors of that\
- material by anyone who conveys the material (or modified versions of\
- it) with contractual assumptions of liability to the recipient, for\
- any liability that these contractual assumptions directly impose on\
- those licensors and authors.\
-\
- All other non-permissive additional terms are considered "further\
-restrictions" within the meaning of section 10. If the Program as you\
-received it, or any part of it, contains a notice stating that it is\
-governed by this License along with a term that is a further\
-restriction, you may remove that term. If a license document contains\
-a further restriction but permits relicensing or conveying under this\
-License, you may add to a covered work material governed by the terms\
-of that license document, provided that the further restriction does\
-not survive such relicensing or conveying.\
-\
- If you add terms to a covered work in accord with this section, you\
-must place, in the relevant source files, a statement of the\
-additional terms that apply to those files, or a notice indicating\
-where to find the applicable terms.\
-\
- Additional terms, permissive or non-permissive, may be stated in the\
-form of a separately written license, or stated as exceptions;\
-the above requirements apply either way.\
-\
- 8. Termination.\
-\
- You may not propagate or modify a covered work except as expressly\
-provided under this License. Any attempt otherwise to propagate or\
-modify it is void, and will automatically terminate your rights under\
-this License (including any patent licenses granted under the third\
-paragraph of section 11).\
-\
- However, if you cease all violation of this License, then your\
-license from a particular copyright holder is reinstated (a)\
-provisionally, unless and until the copyright holder explicitly and\
-finally terminates your license, and (b) permanently, if the copyright\
-holder fails to notify you of the violation by some reasonable means\
-prior to 60 days after the cessation.\
-\
- Moreover, your license from a particular copyright holder is\
-reinstated permanently if the copyright holder notifies you of the\
-violation by some reasonable means, this is the first time you have\
-received notice of violation of this License (for any work) from that\
-copyright holder, and you cure the violation prior to 30 days after\
-your receipt of the notice.\
-\
- Termination of your rights under this section does not terminate the\
-licenses of parties who have received copies or rights from you under\
-this License. If your rights have been terminated and not permanently\
-reinstated, you do not qualify to receive new licenses for the same\
-material under section 10.\
-\
- 9. Acceptance Not Required for Having Copies.\
-\
- You are not required to accept this License in order to receive or\
-run a copy of the Program. Ancillary propagation of a covered work\
-occurring solely as a consequence of using peer-to-peer transmission\
-to receive a copy likewise does not require acceptance. However,\
-nothing other than this License grants you permission to propagate or\
-modify any covered work. These actions infringe copyright if you do\
-not accept this License. Therefore, by modifying or propagating a\
-covered work, you indicate your acceptance of this License to do so.\
-\
- 10. Automatic Licensing of Downstream Recipients.\
-\
- Each time you convey a covered work, the recipient automatically\
-receives a license from the original licensors, to run, modify and\
-propagate that work, subject to this License. You are not responsible\
-for enforcing compliance by third parties with this License.\
-\
- An "entity transaction" is a transaction transferring control of an\
-organization, or substantially all assets of one, or subdividing an\
-organization, or merging organizations. If propagation of a covered\
-work results from an entity transaction, each party to that\
-transaction who receives a copy of the work also receives whatever\
-licenses to the work the party's predecessor in interest had or could\
-give under the previous paragraph, plus a right to possession of the\
-Corresponding Source of the work from the predecessor in interest, if\
-the predecessor has it or can get it with reasonable efforts.\
-\
- You may not impose any further restrictions on the exercise of the\
-rights granted or affirmed under this License. For example, you may\
-not impose a license fee, royalty, or other charge for exercise of\
-rights granted under this License, and you may not initiate litigation\
-(including a cross-claim or counterclaim in a lawsuit) alleging that\
-any patent claim is infringed by making, using, selling, offering for\
-sale, or importing the Program or any portion of it.\
-\
- 11. Patents.\
-\
- A "contributor" is a copyright holder who authorizes use under this\
-License of the Program or a work on which the Program is based. The\
-work thus licensed is called the contributor's "contributor version".\
-\
- A contributor's "essential patent claims" are all patent claims\
-owned or controlled by the contributor, whether already acquired or\
-hereafter acquired, that would be infringed by some manner, permitted\
-by this License, of making, using, or selling its contributor version,\
-but do not include claims that would be infringed only as a\
-consequence of further modification of the contributor version. For\
-purposes of this definition, "control" includes the right to grant\
-patent sublicenses in a manner consistent with the requirements of\
-this License.\
-\
- Each contributor grants you a non-exclusive, worldwide, royalty-free\
-patent license under the contributor's essential patent claims, to\
-make, use, sell, offer for sale, import and otherwise run, modify and\
-propagate the contents of its contributor version.\
-\
- In the following three paragraphs, a "patent license" is any express\
-agreement or commitment, however denominated, not to enforce a patent\
-(such as an express permission to practice a patent or covenant not to\
-sue for patent infringement). To "grant" such a patent license to a\
-party means to make such an agreement or commitment not to enforce a\
-patent against the party.\
-\
- If you convey a covered work, knowingly relying on a patent license,\
-and the Corresponding Source of the work is not available for anyone\
-to copy, free of charge and under the terms of this License, through a\
-publicly available network server or other readily accessible means,\
-then you must either (1) cause the Corresponding Source to be so\
-available, or (2) arrange to deprive yourself of the benefit of the\
-patent license for this particular work, or (3) arrange, in a manner\
-consistent with the requirements of this License, to extend the patent\
-license to downstream recipients. "Knowingly relying" means you have\
-actual knowledge that, but for the patent license, your conveying the\
-covered work in a country, or your recipient's use of the covered work\
-in a country, would infringe one or more identifiable patents in that\
-country that you have reason to believe are valid.\
-\
- If, pursuant to or in connection with a single transaction or\
-arrangement, you convey, or propagate by procuring conveyance of, a\
-covered work, and grant a patent license to some of the parties\
-receiving the covered work authorizing them to use, propagate, modify\
-or convey a specific copy of the covered work, then the patent license\
-you grant is automatically extended to all recipients of the covered\
-work and works based on it.\
-\
- A patent license is "discriminatory" if it does not include within\
-the scope of its coverage, prohibits the exercise of, or is\
-conditioned on the non-exercise of one or more of the rights that are\
-specifically granted under this License. You may not convey a covered\
-work if you are a party to an arrangement with a third party that is\
-in the business of distributing software, under which you make payment\
-to the third party based on the extent of your activity of conveying\
-the work, and under which the third party grants, to any of the\
-parties who would receive the covered work from you, a discriminatory\
-patent license (a) in connection with copies of the covered work\
-conveyed by you (or copies made from those copies), or (b) primarily\
-for and in connection with specific products or compilations that\
-contain the covered work, unless you entered into that arrangement,\
-or that patent license was granted, prior to 28 March 2007.\
-\
- Nothing in this License shall be construed as excluding or limiting\
-any implied license or other defenses to infringement that may\
-otherwise be available to you under applicable patent law.\
-\
- 12. No Surrender of Others' Freedom.\
-\
- If conditions are imposed on you (whether by court order, agreement or\
-otherwise) that contradict the conditions of this License, they do not\
-excuse you from the conditions of this License. If you cannot convey a\
-covered work so as to satisfy simultaneously your obligations under this\
-License and any other pertinent obligations, then as a consequence you may\
-not convey it at all. For example, if you agree to terms that obligate you\
-to collect a royalty for further conveying from those to whom you convey\
-the Program, the only way you could satisfy both those terms and this\
-License would be to refrain entirely from conveying the Program.\
-\
- 13. Use with the GNU Affero General Public License.\
-\
- Notwithstanding any other provision of this License, you have\
-permission to link or combine any covered work with a work licensed\
-under version 3 of the GNU Affero General Public License into a single\
-combined work, and to convey the resulting work. The terms of this\
-License will continue to apply to the part which is the covered work,\
-but the special requirements of the GNU Affero General Public License,\
-section 13, concerning interaction through a network will apply to the\
-combination as such.\
-\
- 14. Revised Versions of this License.\
-\
- The Free Software Foundation may publish revised and/or new versions of\
-the GNU General Public License from time to time. Such new versions will\
-be similar in spirit to the present version, but may differ in detail to\
-address new problems or concerns.\
-\
- Each version is given a distinguishing version number. If the\
-Program specifies that a certain numbered version of the GNU General\
-Public License "or any later version" applies to it, you have the\
-option of following the terms and conditions either of that numbered\
-version or of any later version published by the Free Software\
-Foundation. If the Program does not specify a version number of the\
-GNU General Public License, you may choose any version ever published\
-by the Free Software Foundation.\
-\
- If the Program specifies that a proxy can decide which future\
-versions of the GNU General Public License can be used, that proxy's\
-public statement of acceptance of a version permanently authorizes you\
-to choose that version for the Program.\
-\
- Later license versions may give you additional or different\
-permissions. However, no additional obligations are imposed on any\
-author or copyright holder as a result of your choosing to follow a\
-later version.\
-\
- 15. Disclaimer of Warranty.\
-\
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\
-\
- 16. Limitation of Liability.\
-\
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\
-SUCH DAMAGES.\
-\
- 17. Interpretation of Sections 15 and 16.\
-\
- If the disclaimer of warranty and limitation of liability provided\
-above cannot be given local legal effect according to their terms,\
-reviewing courts shall apply local law that most closely approximates\
-an absolute waiver of all civil liability in connection with the\
-Program, unless a warranty or assumption of liability accompanies a\
-copy of the Program in return for a fee.\
-\
- END OF TERMS AND CONDITIONS\
-\
- How to Apply These Terms to Your New Programs\
-\
- If you develop a new program, and you want it to be of the greatest\
-possible use to the public, the best way to achieve this is to make it\
-free software which everyone can redistribute and change under these terms.\
-\
- To do so, attach the following notices to the program. It is safest\
-to attach them to the start of each source file to most effectively\
-state the exclusion of warranty; and each file should have at least\
-the "copyright" line and a pointer to where the full notice is found.\
-\
- <one line to give the program's name and a brief idea of what it does.>\
- Copyright (C) <year> <name of author>\
-\
- 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 3 of the License, or\
- (at your option) any later version.\
-\
- This program is distributed in the hope that it will be useful,\
- but WITHOUT ANY WARRANTY; without even the implied warranty of\
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
- GNU General Public License for more details.\
-\
- You should have received a copy of the GNU General Public License\
- along with this program. If not, see <http://www.gnu.org/licenses/>.\
-\
-Also add information on how to contact you by electronic and paper mail.\
-\
- If the program does terminal interaction, make it output a short\
-notice like this when it starts in an interactive mode:\
-\
- <program> Copyright (C) <year> <name of author>\
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\
- This is free software, and you are welcome to redistribute it\
- under certain conditions; type `show c' for details.\
-\
-The hypothetical commands `show w' and `show c' should show the appropriate\
-parts of the General Public License. Of course, your program's commands\
-might be different; for a GUI interface, you would use an "about box".\
-\
- You should also get your employer (if you work as a programmer) or school,\
-if any, to sign a "copyright disclaimer" for the program, if necessary.\
-For more information on this, and how to apply and follow the GNU GPL, see\
-<http://www.gnu.org/licenses/>.\
-\
- The GNU General Public License does not permit incorporating your program\
-into proprietary programs. If your program is a subroutine library, you\
-may consider it more useful to permit linking proprietary applications with\
-the library. If this is what you want to do, use the GNU Lesser General\
-Public License instead of this License. But first, please read\
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.\
-}
\ No newline at end of file
+{\rtf1\ansi\deff3\adeflang1025
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Liberation Serif{\*\falt Times New Roman};}{\f4\fswiss\fprq2\fcharset0 Liberation Sans{\*\falt Arial};}{\f5\froman\fprq2\fcharset0 LucidaGrande;}{\f6\fnil\fprq2\fcharset0 Droid Sans Fallback;}{\f7\fnil\fprq2\fcharset0 FreeSans;}{\f8\fswiss\fprq0\fcharset128 FreeSans;}}
+{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
+{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084 Normal;}
+{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbch\af6\dbch\af7\afs28\loch\f4\fs28 Heading;}
+{\s16\sbasedon0\snext16\sl288\slmult1\sb0\sa140 Text Body;}
+{\s17\sbasedon16\snext17\sl288\slmult1\sb0\sa140\dbch\af8 List;}
+{\s18\sbasedon0\snext18\sb120\sa120\noline\i\dbch\af8\afs24\ai\fs24 Caption;}
+{\s19\sbasedon0\snext19\noline\dbch\af8 Index;}
+}{\info{\creatim\yr0\mo0\dy0\hr0\min0}{\author olivier }{\revtim\yr2015\mo3\dy5\hr14\min36}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern67306242}}\deftab720
+\viewscale100
+{\*\pgdsctbl
+{\pgdsc0\pgdscuse451\pgwsxn12240\pghsxn15840\marglsxn1440\margrsxn1440\margtsxn1440\margbsxn1440\pgdscnxt0 Default Style;}}
+\formshade{\*\pgdscno0}\paperh15840\paperw12240\margl1440\margr1440\margt1440\margb1440\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn1440\margrsxn1440\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
+{\*\ftnsep}\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+GNU LESSER GENERAL PUBLIC LICENSE}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Version 3, 29 June 2007}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Everyone is permitted to copy and distribute verbatim copies}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+of this license document, but changing it is not allowed.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+This version of the GNU Lesser General Public License incorporates}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+the terms and conditions of version 3 of the GNU General Public}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+License, supplemented by the additional permissions listed below.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+0. Additional Definitions.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+As used herein, "this License" refers to version 3 of the GNU Lesser}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+General Public License, and the "GNU GPL" refers to version 3 of the GNU}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+General Public License.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+"The Library" refers to a covered work governed by this License,}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+other than an Application or a Combined Work as defined below.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+An "Application" is any work that makes use of an interface provided}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+by the Library, but which is not otherwise based on the Library.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Defining a subclass of a class defined by the Library is deemed a mode}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+of using an interface provided by the Library.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+A "Combined Work" is a work produced by combining or linking an}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Application with the Library. The particular version of the Library}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+with which the Combined Work was made is also called the "Linked}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Version".}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+The "Minimal Corresponding Source" for a Combined Work means the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Corresponding Source for the Combined Work, excluding any source code}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+for portions of the Combined Work that, considered in isolation, are}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+based on the Application, and not on the Linked Version.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+The "Corresponding Application Code" for a Combined Work means the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+object code and/or source code for the Application, including any data}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+and utility programs needed for reproducing the Combined Work from the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Application, but excluding the System Libraries of the Combined Work.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+1. Exception to Section 3 of the GNU GPL.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+You may convey a covered work under sections 3 and 4 of this License}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+without being bound by section 3 of the GNU GPL.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+2. Conveying Modified Versions.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+If you modify a copy of the Library, and, in your modifications, a}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+facility refers to a function or data to be supplied by an Application}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+that uses the facility (other than as an argument passed when the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+facility is invoked), then you may convey a copy of the modified}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+version:}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+a) under this License, provided that you make a good faith effort to}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+ensure that, in the event an Application does not supply the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+function or data, the facility still operates, and performs}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+whatever part of its purpose remains meaningful, or}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+b) under the GNU GPL, with none of the additional permissions of}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+this License applicable to that copy.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+3. Object Code Incorporating Material from Library Header Files.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+The object code form of an Application may incorporate material from}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+a header file that is part of the Library. You may convey such object}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+code under terms of your choice, provided that, if the incorporated}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+material is not limited to numerical parameters, data structure}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+layouts and accessors, or small macros, inline functions and templates}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+(ten or fewer lines in length), you do both of the following:}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+a) Give prominent notice with each copy of the object code that the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Library is used in it and that the Library and its use are}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+covered by this License.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+b) Accompany the object code with a copy of the GNU GPL and this license}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+document.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+4. Combined Works.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+You may convey a Combined Work under terms of your choice that,}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+taken together, effectively do not restrict modification of the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+portions of the Library contained in the Combined Work and reverse}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+engineering for debugging such modifications, if you also do each of}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+the following:}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+a) Give prominent notice with each copy of the Combined Work that}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+the Library is used in it and that the Library and its use are}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+covered by this License.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+b) Accompany the Combined Work with a copy of the GNU GPL and this license}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+document.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+c) For a Combined Work that displays copyright notices during}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+execution, include the copyright notice for the Library among}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+these notices, as well as a reference directing the user to the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+copies of the GNU GPL and this license document.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+d) Do one of the following:}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+0) Convey the Minimal Corresponding Source under the terms of this}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+License, and the Corresponding Application Code in a form}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+suitable for, and under terms that permit, the user to}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+recombine or relink the Application with a modified version of}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+the Linked Version to produce a modified Combined Work, in the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+manner specified by section 6 of the GNU GPL for conveying}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Corresponding Source.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+1) Use a suitable shared library mechanism for linking with the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Library. A suitable mechanism is one that (a) uses at run time}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+a copy of the Library already present on the user's computer}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+system, and (b) will operate properly with a modified version}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+of the Library that is interface-compatible with the Linked}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Version.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+e) Provide Installation Information, but only if you would otherwise}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+be required to provide such information under section 6 of the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+GNU GPL, and only to the extent that such information is}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+necessary to install and execute a modified version of the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Combined Work produced by recombining or relinking the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Application with a modified version of the Linked Version. (If}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+you use option 4d0, the Installation Information must accompany}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+the Minimal Corresponding Source and Corresponding Application}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Code. If you use option 4d1, you must provide the Installation}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Information in the manner specified by section 6 of the GNU GPL}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+for conveying Corresponding Source.)}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+5. Combined Libraries.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+You may place library facilities that are a work based on the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Library side by side in a single library together with other library}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+facilities that are not Applications and are not covered by this}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+License, and convey such a combined library under terms of your}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+choice, if you do both of the following:}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+a) Accompany the combined library with a copy of the same work based}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+on the Library, uncombined with any other library facilities,}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+conveyed under the terms of this License.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+b) Give prominent notice with the combined library that part of it}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+is a work based on the Library, and explaining where to find the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+accompanying uncombined form of the same work.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+6. Revised Versions of the GNU Lesser General Public License.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+The Free Software Foundation may publish revised and/or new versions}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+of the GNU Lesser General Public License from time to time. Such new}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+versions will be similar in spirit to the present version, but may}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+differ in detail to address new problems or concerns.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Each version is given a distinguishing version number. If the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Library as you received it specifies that a certain numbered version}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+of the GNU Lesser General Public License "or any later version"}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+applies to it, you have the option of following the terms and}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+conditions either of that published version or of any later version}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+published by the Free Software Foundation. If the Library as you}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+received it does not specify a version number of the GNU Lesser}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+General Public License, you may choose any version of the GNU Lesser}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+General Public License ever published by the Free Software Foundation.}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\rtlch \ltrch\loch
+
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\fs26\loch\f5
+ }{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+If the Library as you received it specifies that a proxy can decide}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+whether future versions of the GNU Lesser General Public License shall}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+apply, that proxy's public statement of acceptance of any version is}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+permanent authorization for you to choose that version for the}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang3084\ql\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\rtlch \ltrch\loch\fs26\loch\f5
+Library.}
+\par }
\ No newline at end of file
diff --git a/installers/osx/PkgResources_x86_64/ReadMe.rtf b/installers/osx/PkgResources_x86_64/ReadMe.rtf
index 511c18c..4d01517 100755
--- a/installers/osx/PkgResources_x86_64/ReadMe.rtf
+++ b/installers/osx/PkgResources_x86_64/ReadMe.rtf
@@ -1,88 +1,84 @@
-{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
-{\fonttbl\f0\fnil\fcharset0 LucidaGrande;\f1\froman\fcharset0 Times-Roman;}
-{\colortbl;\red255\green255\blue255;}
-\margl1440\margr1440\vieww13160\viewh13300\viewkind0
-\deftab720
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural
-
-\f0\fs26 \cf0 pyo (version 0.6.6)
-\f1\fs24 \
-
-\f0\fs26 \
-System requirements : OS X 10.6 to 10.8
-\f1\fs24 \
-
-\f0\fs26 \
-This package installs all the required components to run pyo inside your current Python installation. Python 2.6 or 2.7 (32/64 bit) must be already installed on your system.
-\f1\fs24 \
-
-\f0\fs26 \
-This package is divided into two separate installers. If you do not require one of them, please unselect the package in custom installation mode.
-\f1\fs24 \
-
-\f0\fs26 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural
-
-\b \cf0 1. pyo extension:
-\f1\b0\fs24 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural
-
-\f0\fs26 \cf0 The following components will be installed in the site-packages folder of the current Python Framework:
-\f1\fs24 \
-
-\f0\fs26 \
-_pyo.so
-\f1\fs24 \
-
-\f0\fs26 _pyo64.so
-\f1\fs24 \
-
-\f0\fs26 pyo.py
-\f1\fs24 \
-
-\f0\fs26 pyo64.py
-\f1\fs24 \
-
-\f0\fs26 pyolib (folder)
-\f1\fs24 \
-
-\f0\fs26 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural
-
-\b \cf0 2. Support libraries (i386 and x86_64):
-\f1\b0\fs24 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural
-
-\f0\fs26 \cf0 This component will install a number of dynamic libraries on which pyo depends. If you already have these, then you can skip this installation.
-\f1\fs24 \
-
-\f0\fs26 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural
-
-\b \cf0 Warning:
-\b0 this installation will overwrite any previously installed libraries. These are the libraries that will be installed in your /usr/local/lib directory:
-\f1\fs24 \
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardeftab720\ql\qnatural
-
-\f0\fs26 \cf0 \
-liblo.7.dylib
-\f1\fs24 \
-
-\f0\fs26 libportaudio.2.dylib
-\f1\fs24 \
-
-\f0\fs26 libportmidi.dylib
-\f1\fs24 \
-
-\f0\fs26 libsndfile.1.dylib
-\f1\fs24 \
-
-\f0\fs26 libFLAC.8.dylib\
-libvorbisenc.2.dylib\
-libvorbis.0.dylib\
-libogg.0.dylib\
-\
-\pard\pardeftab720\ql\qnatural
-\cf0 Olivier B\'e9langer, 2013
-\f1\fs24 \
-}
\ No newline at end of file
+{\rtf1\ansi\deff3\adeflang1025
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Liberation Serif{\*\falt Times New Roman};}{\f4\fswiss\fprq2\fcharset0 Liberation Sans{\*\falt Arial};}{\f5\froman\fprq2\fcharset0 LucidaGrande;}{\f6\fnil\fprq2\fcharset0 Liberation Serif{\*\falt Times New Roman};}{\f7\fnil\fprq2\fcharset0 FreeSans;}{\f8\fswiss\fprq0\fcharset128 FreeSans;}}
+{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
+{\stylesheet{\s0\snext0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084 Normal;}
+{\s15\sbasedon0\snext16\ql\nowidctlpar\sb240\sa120\keepn\ltrpar\cf1\kerning1\dbch\af7\langfe1081\dbch\af7\afs28\loch\f4\fs28\lang3084 Heading;}
+{\s16\sbasedon0\snext16\sl288\slmult1\ql\nowidctlpar\sb0\sa140\ltrpar\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\loch\f3\fs24\lang3084 Text Body;}
+{\s17\sbasedon16\snext17\sl288\slmult1\ql\nowidctlpar\sb0\sa140\ltrpar\cf1\kerning1\dbch\af7\langfe1081\dbch\af8\afs24\loch\f3\fs24\lang3084 List;}
+{\s18\sbasedon0\snext18\ql\nowidctlpar\sb120\sa120\noline\ltrpar\cf1\i\kerning1\dbch\af7\langfe1081\dbch\af8\afs24\ai\loch\f3\fs24\lang3084 Caption;}
+{\s19\sbasedon0\snext19\ql\nowidctlpar\noline\ltrpar\cf1\kerning1\dbch\af7\langfe1081\dbch\af8\afs24\loch\f3\fs24\lang3084 Index;}
+}{\info{\author olivier }{\creatim\yr0\mo0\dy0\hr0\min0}{\author olivier }{\revtim\yr2015\mo3\dy5\hr17\min29}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern67306242}}\deftab720
+\viewscale100
+{\*\pgdsctbl
+{\pgdsc0\pgdscuse451\pgwsxn12240\pghsxn15840\marglsxn1440\margrsxn1440\margtsxn1440\margbsxn1440\pgdscnxt0 Default Style;}}
+\formshade{\*\pgdscno0}\paperh15840\paperw12240\margl1440\margr1440\margt1440\margb1440\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn1440\margrsxn1440\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
+{\*\ftnsep}\pgndec\pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+Python-pyo (version 0.7.}{\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+5}{\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+)}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+System requirements : OS X 10.6 to 10.}{\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+10}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+This package installs all the required components to run pyo inside your current Python installation. Python 2.6 or 2.7 (32/64 bit) must be already installed on your system.}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+This package is divided into two separate installers. If you do not require one of them, please unselect the package in custom installation mode.}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\cf1\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+1. pyo extension:}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+The following components will be installed in the site-packages folder of the current Python Framework:}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+_pyo.so}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+_pyo64.so}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+pyo.py}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+pyo64.py}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+pyolib (folder)}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+2. Support libraries (i386 and x86_64):}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+This component will install a number of dynamic libraries on which pyo depends. If you already have these, then you can skip this installation.}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+Warning:}{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+ this installation will overwrite any previously installed libraries. These are the libraries that will be installed in your /usr/local/lib directory:}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+liblo.7.dylib}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+libportaudio.2.dylib}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+libportmidi.dylib}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+libsndfile.1.dylib}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+libFLAC.8.dylib}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+libvorbisenc.2.dylib}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+libvorbis.0.dylib}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+libogg.0.dylib}
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+
+\par \pard\plain \s0\ql\nowidctlpar\ltrpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf1\kerning1\dbch\af6\langfe1081\dbch\af6\afs24\alang1081\loch\f3\fs24\lang3084\ql\nowidctlpar{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+Olivier B\u233\'e9langer, 201}{\cf1\b0\kerning1\dbch\af6\langfe1081\rtlch \ltrch\loch\fs26\lang3084\loch\f5
+5}
+\par }
\ No newline at end of file
diff --git a/installers/osx/PkgResources_x86_64/postinstall b/installers/osx/PkgResources_x86_64/postinstall
index ade04c8..ddcb4ab 100755
--- a/installers/osx/PkgResources_x86_64/postinstall
+++ b/installers/osx/PkgResources_x86_64/postinstall
@@ -1,15 +1,6 @@
#! /bin/sh
-VERSION=`sw_vers -productVersion | sed -e 's/\.//g'`
-
-if [ $VERSION -ge '1070' ]; then
- echo "Install pyo on OSX 10.7";
-else
- echo "Install pyo on OSX 10.6";
-fi
-
-# Removed older versions in the python site-packages builtin directories
-# Removed older versions in the python site-packages from python.org install directories
+# Removed older versions in the python site-packages builtin and in the python site-packages from python.org directories
PATHS=/Library/Python/2.6/site-packages/:/Library/Python/2.7/site-packages/:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
for path in ${PATHS//:/ }; do
if cd $path; then
@@ -42,22 +33,20 @@ for path in ${PATHS//:/ }; do
done
# Install pyo in the python site-packages builtin directories
-if [ $VERSION -ge '1070' ]; then
- if cd /Library/Python/2.7/site-packages/; then
- sudo cp -r /tmp/python27/* .
- else
- sudo mkdir -p /Library/Python/2.7/site-packages/
- cd /Library/Python/2.7/site-packages/
- sudo cp -r /tmp/python27/* .
- fi
+if cd /Library/Python/2.7/site-packages/; then
+ sudo cp -r /tmp/python27/* .
else
- if cd /Library/Python/2.6/site-packages/; then
- sudo cp -r /tmp/python26/* .
- else
- sudo mkdir -p /Library/Python/2.6/site-packages/
- cd /Library/Python/2.6/site-packages/
- sudo cp -r /tmp/python26/* .
- fi
+ sudo mkdir -p /Library/Python/2.7/site-packages/
+ cd /Library/Python/2.7/site-packages/
+ sudo cp -r /tmp/python27/* .
+fi
+
+if cd /Library/Python/2.6/site-packages/; then
+ sudo cp -r /tmp/python26/* .
+else
+ sudo mkdir -p /Library/Python/2.6/site-packages/
+ cd /Library/Python/2.6/site-packages/
+ sudo cp -r /tmp/python26/* .
fi
# Install pyo in the python.org site-packages directories
@@ -77,6 +66,15 @@ else
sudo cp -r /tmp/python27/* .
fi
+# Check if anaconda is already installed and copy files to site-packages directory
+if cd ~/anaconda/lib/python2.6/site-packages/; then
+ sudo cp -r /tmp/python26/* .
+fi
+
+if cd ~/anaconda/lib/python2.7/site-packages/; then
+ sudo cp -r /tmp/python27/* .
+fi
+
sudo rm -rf /tmp/python2*
# Add /usr/local/lib in .bash_profile if not already done
diff --git a/installers/osx/PkgResources_x86_64/postupgrade b/installers/osx/PkgResources_x86_64/postupgrade
index ade04c8..ddcb4ab 100755
--- a/installers/osx/PkgResources_x86_64/postupgrade
+++ b/installers/osx/PkgResources_x86_64/postupgrade
@@ -1,15 +1,6 @@
#! /bin/sh
-VERSION=`sw_vers -productVersion | sed -e 's/\.//g'`
-
-if [ $VERSION -ge '1070' ]; then
- echo "Install pyo on OSX 10.7";
-else
- echo "Install pyo on OSX 10.6";
-fi
-
-# Removed older versions in the python site-packages builtin directories
-# Removed older versions in the python site-packages from python.org install directories
+# Removed older versions in the python site-packages builtin and in the python site-packages from python.org directories
PATHS=/Library/Python/2.6/site-packages/:/Library/Python/2.7/site-packages/:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
for path in ${PATHS//:/ }; do
if cd $path; then
@@ -42,22 +33,20 @@ for path in ${PATHS//:/ }; do
done
# Install pyo in the python site-packages builtin directories
-if [ $VERSION -ge '1070' ]; then
- if cd /Library/Python/2.7/site-packages/; then
- sudo cp -r /tmp/python27/* .
- else
- sudo mkdir -p /Library/Python/2.7/site-packages/
- cd /Library/Python/2.7/site-packages/
- sudo cp -r /tmp/python27/* .
- fi
+if cd /Library/Python/2.7/site-packages/; then
+ sudo cp -r /tmp/python27/* .
else
- if cd /Library/Python/2.6/site-packages/; then
- sudo cp -r /tmp/python26/* .
- else
- sudo mkdir -p /Library/Python/2.6/site-packages/
- cd /Library/Python/2.6/site-packages/
- sudo cp -r /tmp/python26/* .
- fi
+ sudo mkdir -p /Library/Python/2.7/site-packages/
+ cd /Library/Python/2.7/site-packages/
+ sudo cp -r /tmp/python27/* .
+fi
+
+if cd /Library/Python/2.6/site-packages/; then
+ sudo cp -r /tmp/python26/* .
+else
+ sudo mkdir -p /Library/Python/2.6/site-packages/
+ cd /Library/Python/2.6/site-packages/
+ sudo cp -r /tmp/python26/* .
fi
# Install pyo in the python.org site-packages directories
@@ -77,6 +66,15 @@ else
sudo cp -r /tmp/python27/* .
fi
+# Check if anaconda is already installed and copy files to site-packages directory
+if cd ~/anaconda/lib/python2.6/site-packages/; then
+ sudo cp -r /tmp/python26/* .
+fi
+
+if cd ~/anaconda/lib/python2.7/site-packages/; then
+ sudo cp -r /tmp/python27/* .
+fi
+
sudo rm -rf /tmp/python2*
# Add /usr/local/lib in .bash_profile if not already done
diff --git a/installers/osx/release_i386.sh b/installers/osx/release_i386.sh
deleted file mode 100644
index 3838604..0000000
--- a/installers/osx/release_i386.sh
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/bin/sh
-
-# Need Xcode 3.2.6 or later (pkgbuild and productbuild)
-# 1. install python (and wxpython) 2.6 and 2.7 (32-bit)
-# 2. update pyo sources
-# 3. compile and install pyo float and double
-# 4. cd utils and build E-Pyo
-# 5. cd installer/osx and build the realease
-
-export PACKAGE_NAME=pyo_0.6.9_i386.pkg
-export DMG_DIR="pyo 0.6.9 Intel"
-export DMG_NAME="pyo_0.6.9_OSX-Intel.dmg"
-export INSTALLER_DIR=`pwd`/installer
-export PYO_MODULE_DIR=$INSTALLER_DIR/PyoModule/Package_Contents/tmp
-export SUPPORT_LIBS_DIR=$INSTALLER_DIR/SupportLibs/Package_Contents/usr/local/lib
-export BUILD_RESOURCES=$INSTALLER_DIR/PkgResources/English.lproj
-export PKG_RESOURCES=$INSTALLER_DIR/../PkgResources_i386
-
-mkdir -p $PYO_MODULE_DIR
-mkdir -p $SUPPORT_LIBS_DIR
-mkdir -p $BUILD_RESOURCES
-
-cp $PKG_RESOURCES/License.rtf $BUILD_RESOURCES/License.rtf
-cp $PKG_RESOURCES/Welcome.rtf $BUILD_RESOURCES/Welcome.rtf
-cp $PKG_RESOURCES/ReadMe.rtf $BUILD_RESOURCES/ReadMe.rtf
-
-svn export ../.. installer/pyo-build
-cd installer/pyo-build
-
-echo "building pyo for python 2.6 (32-bit)..."
-sudo /usr/local/bin/python2.6 setup.py install --use-coreaudio --use-double
-
-sudo cp -R build/lib.macosx-10.3-fat-2.6 $PYO_MODULE_DIR/python26
-
-echo "building pyo for python 2.7 (32-bit)..."
-sudo /usr/local/bin/python2.7 setup.py install --use-coreaudio --use-double
-
-sudo cp -R build/lib.macosx-10.3-fat-2.7 $PYO_MODULE_DIR/python27
-
-sudo install_name_tool -change libportmidi.dylib /usr/local/lib/libportmidi.dylib $PYO_MODULE_DIR/python26/_pyo.so
-sudo install_name_tool -change libportmidi.dylib /usr/local/lib/libportmidi.dylib $PYO_MODULE_DIR/python26/_pyo64.so
-sudo install_name_tool -change libportmidi.dylib /usr/local/lib/libportmidi.dylib $PYO_MODULE_DIR/python27/_pyo.so
-sudo install_name_tool -change libportmidi.dylib /usr/local/lib/libportmidi.dylib $PYO_MODULE_DIR/python27/_pyo64.so
-
-cd ..
-
-echo "copying support libs..."
-sudo cp /usr/local/lib/liblo.7.dylib $SUPPORT_LIBS_DIR/liblo.7.dylib
-sudo cp /usr/local/lib/libportaudio.2.dylib $SUPPORT_LIBS_DIR/libportaudio.2.dylib
-sudo cp /usr/local/lib/libportmidi.dylib $SUPPORT_LIBS_DIR/libportmidi.dylib
-sudo cp /usr/local/lib/libsndfile.1.dylib $SUPPORT_LIBS_DIR/libsndfile.1.dylib
-sudo cp /usr/local/lib/libFLAC.8.dylib $SUPPORT_LIBS_DIR/libFLAC.8.dylib
-sudo cp /usr/local/lib/libvorbisenc.2.dylib $SUPPORT_LIBS_DIR/libvorbisenc.2.dylib
-sudo cp /usr/local/lib/libvorbis.0.dylib $SUPPORT_LIBS_DIR/libvorbis.0.dylib
-sudo cp /usr/local/lib/libogg.0.dylib $SUPPORT_LIBS_DIR/libogg.0.dylib
-
-echo "setting permissions..."
-
-sudo chgrp -R admin PyoModule/Package_Contents/tmp
-sudo chown -R root PyoModule/Package_Contents/tmp
-sudo chmod -R 755 PyoModule/Package_Contents/tmp
-
-sudo chgrp -R wheel SupportLibs/Package_Contents/usr
-sudo chown -R root SupportLibs/Package_Contents/usr
-sudo chmod -R 755 SupportLibs/Package_Contents/usr
-
-echo "building packages..."
-
-pkgbuild --identifier com.iact.umontreal.ca.pyo.tmp.pkg \
- --root PyoModule/Package_Contents/ \
- --version 1.0 \
- --scripts $PKG_RESOURCES \
- PyoModule.pkg
-
-pkgbuild --identifier com.iact.umontreal.ca.pyo.usr.pkg \
- --root SupportLibs/Package_Contents/ \
- --version 1.0 \
- SupportLibs.pkg
-
-echo "building product..."
-productbuild --distribution ../Distribution.dist --resources $BUILD_RESOURCES $PACKAGE_NAME
-
-echo "assembling DMG..."
-mkdir "$DMG_DIR"
-cd "$DMG_DIR"
-cp ../$PACKAGE_NAME .
-cp -R ../../../../utils/E-Pyo.app .
-ln -s /Applications .
-cd ..
-
-hdiutil create "$DMG_NAME" -srcfolder "$DMG_DIR"
-
-cd ..
-mv installer/$DMG_NAME .
-
-echo "clean up resources..."
-sudo rm -rf installer
-
-
diff --git a/installers/osx/release_x86_64.sh b/installers/osx/release_x86_64.sh
index 317badf..2275a10 100644
--- a/installers/osx/release_x86_64.sh
+++ b/installers/osx/release_x86_64.sh
@@ -1,8 +1,15 @@
#!/bin/sh
-export PACKAGE_NAME=pyo_0.6.9_x86_64.pkg
-export DMG_DIR="pyo 0.6.9 Universal"
-export DMG_NAME="pyo_0.6.9_OSX-universal.dmg"
+# Need Xcode 3.2.6 or later (pkgbuild and productbuild)
+# with python 2.7.8 (32/64-bit) and wxpython 3.0.1.1 (cocoa) installed
+# 1. update pyo sources
+# 2. compile and install pyo float and double
+# 3. cd utils and build E-Pyo
+# 4. cd installer/osx and build the realease, only x86_64 version
+
+export PACKAGE_NAME=pyo_0.7.6_x86_64.pkg
+export DMG_DIR="pyo 0.7.6 Universal"
+export DMG_NAME="pyo_0.7.6_OSX-universal.dmg"
export INSTALLER_DIR=`pwd`/installer
export PYO_MODULE_DIR=$INSTALLER_DIR/PyoModule/Package_Contents/tmp
export SUPPORT_LIBS_DIR=$INSTALLER_DIR/SupportLibs/Package_Contents/usr/local/lib
diff --git a/installers/win/README-win32-py26.txt b/installers/win/README-win32-py26.txt
index bbe9866..b974713 100644
--- a/installers/win/README-win32-py26.txt
+++ b/installers/win/README-win32-py26.txt
@@ -1,21 +1,21 @@
-Pyo is a Python module written in C to help digital signal processing script creation.
-
-* Python 2.6 must be installed on your system before running this installer. *
-
-http://www.python.org/download/releases/2.6.6/
-
-To use the WxPython toolkit for widgets, you need to install wxPython2.8-win32-unicode-py26:
-
-http://www.wxpython.org/download.php#stable
-
-This installer will leave a folder called pyo_examples on the Desktop,
-it's a good starting point to explore the library!
-
-In a Command Prompt:
-
-cd Desktop\pyo_examples
-python xnoise_example.py
-
-Please, send comments and bugs to:
-
-belangeo at gmail.com
+Pyo is a Python module written in C to help digital signal processing script creation.
+
+* Python 2.6 must be installed on your system before running this installer. *
+
+http://www.python.org/download/releases/2.6.6/
+
+To use the WxPython toolkit for widgets, you need to install wxPython 3.0 for python 2.6:
+
+http://www.wxpython.org/download.php#stable
+
+This installer will leave a folder called pyo_examples on the Desktop,
+it's a good starting point to explore the library!
+
+In a Command Prompt:
+
+cd Desktop\pyo_examples\algorithmic
+python 01_music_box.py
+
+Please, send comments and bugs to:
+
+belangeo at gmail.com
diff --git a/installers/win/README-win32-py27.txt b/installers/win/README-win32-py27.txt
index 872130e..e3f8d78 100644
--- a/installers/win/README-win32-py27.txt
+++ b/installers/win/README-win32-py27.txt
@@ -1,21 +1,21 @@
-Pyo is a Python module written in C to help digital signal processing script creation.
-
-* Python 2.7 must be installed on your system before running this installer. *
-
-http://www.python.org/download/
-
-To use the WxPython toolkit for widgets, you need to install wxPython2.8-win32-unicode-py27:
-
-http://www.wxpython.org/download.php#stable
-
-This installer will leave a folder called pyo_examples on the Desktop,
-it's a good starting point to explore the library!
-
-In a Command Prompt:
-
-cd Desktop\pyo_examples
-python xnoise_example.py
-
-Please, send comments and bugs to:
-
-belangeo at gmail.com
+Pyo is a Python module written in C to help digital signal processing script creation.
+
+* Python 2.7 must be installed on your system before running this installer. *
+
+http://www.python.org/download/
+
+To use the WxPython toolkit for widgets, you need to install wxPython 3.0 for python 2.7:
+
+http://www.wxpython.org/download.php#stable
+
+This installer will leave a folder called pyo_examples on the Desktop,
+it's a good starting point to explore the library!
+
+In a Command Prompt:
+
+cd Desktop\pyo_examples\algorithmic
+python 01_music_box.py
+
+Please, send comments and bugs to:
+
+belangeo at gmail.com
diff --git a/installers/win/build_installers_win.bat b/installers/win/build_installers_win.bat
index 0861ba3..cc60331 100644
--- a/installers/win/build_installers_win.bat
+++ b/installers/win/build_installers_win.bat
@@ -1,7 +1,7 @@
-echo off
-
-echo *** Build installer for python2.6 ***
-Compil32 /cc "win_installer_py26.iss"
-
-echo *** Build installer for python2.7 ***
-Compil32 /cc "win_installer_py27.iss"
+echo off
+
+echo *** Build installer for python2.6 ***
+Compil32 /cc "win_installer_py26.iss"
+
+echo *** Build installer for python2.7 ***
+Compil32 /cc "win_installer_py27.iss"
diff --git a/installers/win/win_installer_py26.iss b/installers/win/win_installer_py26.iss
index 759d3d1..969ccb3 100644
--- a/installers/win/win_installer_py26.iss
+++ b/installers/win/win_installer_py26.iss
@@ -1,91 +1,133 @@
-; Script generated by the Inno Setup Script Wizard.
-; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
-
-[Setup]
-; NOTE: The value of AppId uniquely identifies this application.
-; Do not use the same AppId value in installers for other applications.
-; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
-AppId={{4F72B6EF-CFA0-434F-A2B4-B130F94F54EB}
-AppName=Pyo
-AppVersion=0.6.9
-AppPublisher=iACT.umontreal.ca
-AppPublisherURL=http://code.google.com/p/pyo
-AppSupportURL=http://code.google.com/p/pyo
-AppUpdatesURL=http://code.google.com/p/pyo
-DefaultDirName={sd}\Python26
-DisableDirPage=yes
-DefaultGroupName=pyo
-AllowNoIcons=yes
-InfoBeforeFile=C:\Documents and Settings\user\svn\pyo\installers\win\\README-win32-py26.txt
-OutputBaseFilename=pyo_0.6.9_py2.6_setup
-Compression=lzma
-SolidCompression=yes
-ChangesAssociations=yes
-ChangesEnvironment=yes
-
-[Languages]
-Name: "english"; MessagesFile: "compiler:Default.isl"
-
-; should use PYTHONPATH variable
-[Files]
-Source: "C:\Python26\Lib\site-packages\pyo.py"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\pyo64.py"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\pyolib\*"; DestDir: "{sd}\Python26\Lib\site-packages\pyolib"; Flags: ignoreversion recursesubdirs createallsubdirs
-Source: "C:\Python26\Lib\site-packages\_pyo.pyd"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\_pyo64.pyd"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\libsndfile-1.dll"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\lo.dll"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\portaudio.dll"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\portmidi.dll"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\porttime.dll"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\pthreadVC2.dll"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\msvcr90.dll"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\MinGW\bin\libgcc_s_dw2-1.dll"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\MinGW\bin\libstdc++-6.dll"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python26\Lib\site-packages\pyo-0.6.9-py2.6.egg-info"; DestDir: "{sd}\Python26\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Documents and Settings\user\svn\pyo\examples\*"; DestDir: "{userdesktop}\pyo_examples\"; Flags: ignoreversion recursesubdirs createallsubdirs
-Source: "C:\Documents and Settings\user\svn\pyo\installers\win\README-win32-py26.txt"; DestDir: "{userdesktop}"; Flags: ignoreversion
-; NOTE: Don't use "Flags: ignoreversion" on any shared system files
-
-; E-Pyo stuff
-Source: "C:\Documents and Settings\user\svn\pyo\utils\E-Pyo_py26\E-Pyo.exe"; DestDir: "{pf}\E-Pyo"; Flags: ignoreversion
-Source: "C:\Documents and Settings\user\svn\pyo\utils\E-Pyo_py26\Resources\*"; DestDir: "{pf}\E-Pyo\Resources"; Flags: ignoreversion recursesubdirs createallsubdirs
-
-[Tasks]
-Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
-
-[Icons]
-Name: "{group}\E-Pyo"; Filename: "{pf}\E-Pyo\E-Pyo.exe"; WorkingDir: "{pf}\E-Pyo"
-Name: "{commondesktop}\E-Pyo"; Filename: "{pf}\E-Pyo\E-Pyo.exe"; Tasks: desktopicon
-
-[Run]
-Filename: "{pf}\E-Pyo\E-Pyo.exe"; Description: "{cm:LaunchProgram,E-Pyo}"; Flags: nowait postinstall skipifsilent
-
-[InstallDelete]
-Type: filesandordirs; Name: "{userdesktop}\pyo_examples";
-Type: filesandordirs; Name: "{userdocs}\.epyo";
-;;;;;;;;;;;;;
-
-[Registry]
-Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "C:\Python26;{olddata}"; Check: NeedsAddPath('C:\Python26')
-
-[Code]
-function NeedsAddPath(Param: string): boolean;
-var
- OrigPath: string;
-begin
- if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
- 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
- 'Path', OrigPath)
- then begin
- Result := True;
- exit;
- end;
- // look for the path with leading and trailing semicolon
- // Pos() returns 0 if not found
- Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
-end;
-
-
-
-
+; Script generated by the Inno Setup Script Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+#define appName "pyo"
+#define pyVer "2.6"
+#define appVer "0.7.6"
+
+[Setup]
+; NOTE: The value of AppId uniquely identifies this application.
+; Do not use the same AppId value in installers for other applications.
+; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+AppId={{AC79C5C4-BE36-419E-B94A-98C6D0DCF4B9}
+AppName={#appName}
+AppVersion={#appVer}
+AppPublisher=iACT.umontreal.ca
+AppPublisherURL=http://code.google.com/p/pyo
+AppSupportURL=http://code.google.com/p/pyo
+AppUpdatesURL=http://code.google.com/p/pyo
+DefaultDirName={code:GetDirName}
+DisableDirPage=no
+AlwaysShowDirOnReadyPage=yes
+DefaultGroupName={#appName}
+AllowNoIcons=yes
+InfoBeforeFile=C:\Users\olivier\svn\pyo\installers\win\\README-win32-py26.txt
+LicenseFile=C:\Users\olivier\svn\pyo\COPYING.txt
+OutputBaseFilename={#appName}_{#appVer}_py{#pyVer}_setup
+Compression=lzma
+SolidCompression=yes
+ChangesAssociations=yes
+ChangesEnvironment=yes
+DirExistsWarning=no
+SetupIconFile=C:\Users\olivier\svn\pyo\utils\E-PyoIcon.ico
+
+[Languages]
+Name: "english"; MessagesFile: "compiler:Default.isl"
+
+; should use PYTHONPATH variable
+[Files]
+Source: "C:\Python26\Lib\site-packages\pyo.py"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\pyo64.py"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\pyolib\*"; DestDir: "{app}\Lib\site-packages\pyolib"; Flags: ignoreversion recursesubdirs createallsubdirs
+Source: "C:\Python26\Lib\site-packages\_pyo.pyd"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\_pyo64.pyd"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\libsndfile-1.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\lo.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\portaudio.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\portmidi.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\porttime.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\pthreadVC2.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\msvcr90.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\MinGW\bin\libgcc_s_dw2-1.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\MinGW\bin\libstdc++-6.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python26\Lib\site-packages\pyo-{#appVer}-py{#pyVer}.egg-info"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Users\olivier\svn\pyo\examples\*"; DestDir: "{userdesktop}\pyo_examples\"; Flags: ignoreversion recursesubdirs createallsubdirs
+Source: "C:\Users\olivier\svn\pyo\installers\win\README-win32-py26.txt"; DestDir: "{userdesktop}"; Flags: ignoreversion
+; NOTE: Don't use "Flags: ignoreversion" on any shared system files
+
+; E-Pyo stuff
+Source: "C:\Users\olivier\svn\pyo\utils\E-Pyo_py26\E-Pyo.exe"; DestDir: "{pf}\E-Pyo"; Flags: ignoreversion
+Source: "C:\Users\olivier\svn\pyo\utils\E-Pyo_py26\Resources\*"; DestDir: "{pf}\E-Pyo\Resources"; Flags: ignoreversion recursesubdirs createallsubdirs
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
+
+[Icons]
+Name: "{group}\E-Pyo"; Filename: "{pf}\E-Pyo\E-Pyo.exe"; WorkingDir: "{pf}\E-Pyo"
+Name: "{commondesktop}\E-Pyo"; Filename: "{pf}\E-Pyo\E-Pyo.exe"; Tasks: desktopicon
+
+[Run]
+Filename: "{pf}\E-Pyo\E-Pyo.exe"; Description: "{cm:LaunchProgram,E-Pyo}"; Flags: nowait postinstall skipifsilent
+
+[InstallDelete]
+Type: filesandordirs; Name: "{userdesktop}\pyo_examples";
+Type: filesandordirs; Name: "{userdocs}\.epyo";
+;;;;;;;;;;;;;
+
+[Registry]
+Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "C:\Python26;{olddata}"; Check: NeedsAddPath('{app}')
+
+[Code]
+procedure ExitProcess(exitCode:integer);
+ external 'ExitProcess at kernel32.dll stdcall';
+
+function NeedsAddPath(Param: string): boolean;
+var
+ OrigPath: string;
+begin
+ if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
+ 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
+ 'Path', OrigPath)
+ then begin
+ Result := True;
+ exit;
+ end;
+ // look for the path with leading and trailing semicolon
+ // Pos() returns 0 if not found
+ Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
+end;
+
+function GetDirName(Value: string): string;
+var
+ InstallPath: string;
+ reg1 : string;
+ reg2 : string;
+ reg3 : string;
+ reg4 : string;
+begin
+ reg1 := 'SOFTWARE\Python\PythonCore\' + '{#PyVer}' + '\InstallPath';
+ reg2 := 'SOFTWARE\Wow6432Node\Python\PythonCore\' + '{#PyVer}' + '\InstallPath';
+ reg3 := 'Software\Python\PythonCore\' + '{#PyVer}' + '\InstallPath';
+ reg4 := 'Software\Wow6432Node\Python\PythonCore\' + '{#PyVer}' + '\InstallPath';
+ if RegQueryStringValue(HKLM, reg1, '', InstallPath) then
+ BEGIN
+ Result := InstallPath;
+ END else
+ if RegQueryStringValue(HKCU, reg3, '', InstallPath) then
+ BEGIN
+ Result := InstallPath;
+ END else
+ if RegQueryStringValue(HKLM, reg2, '', InstallPath) then
+ BEGIN
+ Result := InstallPath;
+ END else
+ if RegQueryStringValue(HKCU, reg4, '', InstallPath) then
+ BEGIN
+ Result := InstallPath;
+ END else
+ BEGIN
+ Result := 'C:\Python26';
+ END
+end;
+
+
diff --git a/installers/win/win_installer_py27.iss b/installers/win/win_installer_py27.iss
index e879227..797e6f4 100644
--- a/installers/win/win_installer_py27.iss
+++ b/installers/win/win_installer_py27.iss
@@ -1,89 +1,129 @@
-; Script generated by the Inno Setup Script Wizard.
-; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
-
-[Setup]
-; NOTE: The value of AppId uniquely identifies this application.
-; Do not use the same AppId value in installers for other applications.
-; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
-AppId={{244D309A-C251-481A-AD24-0602D392A634}
-AppName=Pyo
-AppVersion=0.6.9
-AppPublisher=iACT.umontreal.ca
-AppPublisherURL=http://code.google.com/p/pyo
-AppSupportURL=http://code.google.com/p/pyo
-AppUpdatesURL=http://code.google.com/p/pyo
-DefaultDirName={sd}\Python27
-DisableDirPage=yes
-DefaultGroupName=pyo
-AllowNoIcons=yes
-InfoBeforeFile=C:\Documents and Settings\user\svn\pyo\installers\win\\README-win32-py27.txt
-OutputBaseFilename=pyo_0.6.9_py2.7_setup
-Compression=lzma
-SolidCompression=yes
-ChangesAssociations=yes
-ChangesEnvironment=yes
-
-[Languages]
-Name: "english"; MessagesFile: "compiler:Default.isl"
-
-; One installer for both python version
-; functions to set which python directory in Setup section
-; Check: DirExists(ExpandConstant('{sd}\Python27'))
-[Files]
-Source: "C:\Python27\Lib\site-packages\pyo.py"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\pyo64.py"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\pyolib\*"; DestDir: "{sd}\Python27\Lib\site-packages\pyolib"; Flags: ignoreversion recursesubdirs createallsubdirs
-Source: "C:\Python27\Lib\site-packages\_pyo.pyd"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\_pyo64.pyd"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\libsndfile-1.dll"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\lo.dll"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\portaudio.dll"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\portmidi.dll"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\porttime.dll"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\pthreadVC2.dll"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\msvcr90.dll"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\MinGW\bin\libgcc_s_dw2-1.dll"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\MinGW\bin\libstdc++-6.dll"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Python27\Lib\site-packages\pyo-0.6.9-py2.7.egg-info"; DestDir: "{sd}\Python27\Lib\site-packages"; Flags: ignoreversion
-Source: "C:\Documents and Settings\user\svn\pyo\examples\*"; DestDir: "{userdesktop}\pyo_examples\"; Flags: ignoreversion recursesubdirs createallsubdirs
-Source: "C:\Documents and Settings\user\svn\pyo\installers\win\README-win32-py27.txt"; DestDir: "{userdesktop}"; Flags: ignoreversion
-; NOTE: Don't use "Flags: ignoreversion" on any shared system files
-
-; E-Pyo stuff
-Source: "C:\Documents and Settings\user\svn\pyo\utils\E-Pyo_py27\E-Pyo.exe"; DestDir: "{pf}\E-Pyo"; Flags: ignoreversion
-Source: "C:\Documents and Settings\user\svn\pyo\utils\E-Pyo_py27\Resources\*"; DestDir: "{pf}\E-Pyo\Resources"; Flags: ignoreversion recursesubdirs createallsubdirs
-
-[Tasks]
-Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
-
-[Icons]
-Name: "{group}\E-Pyo"; Filename: "{pf}\E-Pyo\E-Pyo.exe"; WorkingDir: "{pf}\E-Pyo"
-Name: "{commondesktop}\E-Pyo"; Filename: "{pf}\E-Pyo\E-Pyo.exe"; Tasks: desktopicon
-
-[Run]
-Filename: "{pf}\E-Pyo\E-Pyo.exe"; Description: "{cm:LaunchProgram,E-Pyo}"; Flags: nowait postinstall skipifsilent
-
-[InstallDelete]
-Type: filesandordirs; Name: "{userdesktop}\pyo_examples";
-Type: filesandordirs; Name: "{userdocs}\.epyo";
-;;;;;;;;;;;;;
-
-[Registry]
-Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "C:\Python27;{olddata}"; Check: NeedsAddPath('C:\Python27')
-
-[Code]
-function NeedsAddPath(Param: string): boolean;
-var
- OrigPath: string;
-begin
- if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
- 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
- 'Path', OrigPath)
- then begin
- Result := True;
- exit;
- end;
- // look for the path with leading and trailing semicolon
- // Pos() returns 0 if not found
- Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
-end;
+; Script generated by the Inno Setup Script Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+#define appName "pyo"
+#define pyVer "2.7"
+#define appVer "0.7.6"
+
+[Setup]
+; NOTE: The value of AppId uniquely identifies this application.
+; Do not use the same AppId value in installers for other applications.
+; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+AppId={{59447873-F994-4BC7-8B1D-0DDCA5B6AFFD}
+AppName={#appName}
+AppVersion={#appVer}
+AppPublisher=iACT.umontreal.ca
+AppPublisherURL=http://code.google.com/p/pyo
+AppSupportURL=http://code.google.com/p/pyo
+AppUpdatesURL=http://code.google.com/p/pyo
+DefaultDirName={code:GetDirName}
+DisableDirPage=no
+AlwaysShowDirOnReadyPage=yes
+DefaultGroupName={#appName}
+AllowNoIcons=yes
+InfoBeforeFile=C:\Users\olivier\svn\pyo\installers\win\\README-win32-py27.txt
+LicenseFile=C:\Users\olivier\svn\pyo\COPYING.txt
+OutputBaseFilename={#appName}_{#appVer}_py{#pyVer}_setup
+Compression=lzma
+SolidCompression=yes
+ChangesAssociations=yes
+ChangesEnvironment=yes
+DirExistsWarning=no
+SetupIconFile=C:\Users\olivier\svn\pyo\utils\E-PyoIcon.ico
+
+[Languages]
+Name: "english"; MessagesFile: "compiler:Default.isl"
+
+[Files]
+Source: "C:\Python27\Lib\site-packages\pyo.py"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\pyo64.py"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\pyolib\*"; DestDir: "{app}\Lib\site-packages\pyolib"; Flags: ignoreversion recursesubdirs createallsubdirs
+Source: "C:\Python27\Lib\site-packages\_pyo.pyd"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\_pyo64.pyd"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\libsndfile-1.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\lo.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\portaudio.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\portmidi.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\porttime.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\pthreadVC2.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\msvcr90.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\MinGW\bin\libgcc_s_dw2-1.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\MinGW\bin\libstdc++-6.dll"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Python27\Lib\site-packages\pyo-{#appVer}-py{#pyVer}.egg-info"; DestDir: "{app}\Lib\site-packages"; Flags: ignoreversion
+Source: "C:\Users\olivier\svn\pyo\examples\*"; DestDir: "{userdesktop}\pyo_examples\"; Flags: ignoreversion recursesubdirs createallsubdirs
+; NOTE: Don't use "Flags: ignoreversion" on any shared system files
+
+; E-Pyo stuff
+Source: "C:\Users\olivier\svn\pyo\utils\E-Pyo_py27\E-Pyo.exe"; DestDir: "{pf}\E-Pyo"; Flags: ignoreversion
+Source: "C:\Users\olivier\svn\pyo\utils\E-Pyo_py27\Resources\*"; DestDir: "{pf}\E-Pyo\Resources"; Flags: ignoreversion recursesubdirs createallsubdirs
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
+
+[Icons]
+Name: "{group}\E-Pyo"; Filename: "{pf}\E-Pyo\E-Pyo.exe"; WorkingDir: "{pf}\E-Pyo"
+Name: "{commondesktop}\E-Pyo"; Filename: "{pf}\E-Pyo\E-Pyo.exe"; Tasks: desktopicon
+
+[Run]
+Filename: "{pf}\E-Pyo\E-Pyo.exe"; Description: "{cm:LaunchProgram,E-Pyo}"; Flags: nowait postinstall skipifsilent
+
+[InstallDelete]
+Type: filesandordirs; Name: "{userdesktop}\pyo_examples";
+Type: filesandordirs; Name: "{userdocs}\.epyo";
+;;;;;;;;;;;;;
+
+[Registry]
+Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{app};{olddata}"; Check: NeedsAddPath('{app}')
+
+[Code]
+procedure ExitProcess(exitCode:integer);
+ external 'ExitProcess at kernel32.dll stdcall';
+
+function NeedsAddPath(Param: string): boolean;
+var
+ OrigPath: string;
+begin
+ if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
+ 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
+ 'Path', OrigPath)
+ then begin
+ Result := True;
+ exit;
+ end;
+ // look for the path with leading and trailing semicolon
+ // Pos() returns 0 if not found
+ Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
+end;
+
+function GetDirName(Value: string): string;
+var
+ InstallPath: string;
+ reg1 : string;
+ reg2 : string;
+ reg3 : string;
+ reg4 : string;
+begin
+ reg1 := 'SOFTWARE\Python\PythonCore\' + '{#PyVer}' + '\InstallPath';
+ reg2 := 'SOFTWARE\Wow6432Node\Python\PythonCore\' + '{#PyVer}' + '\InstallPath';
+ reg3 := 'Software\Python\PythonCore\' + '{#PyVer}' + '\InstallPath';
+ reg4 := 'Software\Wow6432Node\Python\PythonCore\' + '{#PyVer}' + '\InstallPath';
+ if RegQueryStringValue(HKLM, reg1, '', InstallPath) then
+ BEGIN
+ Result := InstallPath;
+ END else
+ if RegQueryStringValue(HKCU, reg3, '', InstallPath) then
+ BEGIN
+ Result := InstallPath;
+ END else
+ if RegQueryStringValue(HKLM, reg2, '', InstallPath) then
+ BEGIN
+ Result := InstallPath;
+ END else
+ if RegQueryStringValue(HKCU, reg4, '', InstallPath) then
+ BEGIN
+ Result := InstallPath;
+ END else
+ BEGIN
+ Result := 'C:\Python27';
+ END
+end;
\ No newline at end of file
diff --git a/pyo.py b/pyo.py
index 081056d..8c2eb72 100644
--- a/pyo.py
+++ b/pyo.py
@@ -1,57 +1,22 @@
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
-import os
-
-import sys
-import __builtin__
-from types import IntType, FloatType
-
-# For Python 2.5-, this will enable the simliar property mechanism as in
-# Python 2.6+/3.0+. The code is based on
-# http://bruynooghe.blogspot.com/2008/04/xsetter-syntax-in-python-25.html
-if sys.version_info[:2] <= (2, 5):
- class property(property):
- def __init__(self, fget, *args, **kwargs):
- self.__doc__ = fget.__doc__
- super(property, self).__init__(fget, *args, **kwargs)
-
- def setter(self, fset):
- cls_ns = sys._getframe(1).f_locals
- for k, v in cls_ns.iteritems():
- if v == self:
- propname = k
- break
- cls_ns[propname] = property(self.fget, fset, self.fdel, self.__doc__)
- return cls_ns[propname]
-
- def deleter(self, fdel):
- cls_ns = sys._getframe(1).f_locals
- for k, v in cls_ns.iteritems():
- if v == self:
- propname = k
- break
- cls_ns[propname] = property(self.fget, self.fset, fdel, self.__doc__)
- return cls_ns[propname]
-
- __builtin__.property = property
-
from pyolib._maps import *
import pyolib.analysis as analysis
from pyolib.analysis import *
@@ -99,266 +64,60 @@ if WITH_EXTERNALS:
import pyolib.external as external
from pyolib.external import *
-class FreqShift(PyoObject):
- """
- Frequency shifting using single sideband amplitude modulation.
-
- Shifting frequencies means that the input signal can be detuned,
- where the harmonic components of the signal are shifted out of
- harmonic alignment with each other, e.g. a signal with harmonics at
- 100, 200, 300, 400 and 500 Hz, shifted up by 50 Hz, will have harmonics
- at 150, 250, 350, 450, and 550 Hz.
-
- :Parent: :py:class:`PyoObject`
-
- :Args:
-
- input : PyoObject
- Input signal to process.
- shift : float or PyoObject, optional
- Amount of shifting in Hertz. Defaults to 100.
-
- >>> s = Server().boot()
- >>> s.start()
- >>> a = SineLoop(freq=300, feedback=.1, mul=.3)
- >>> lf1 = Sine(freq=.04, mul=10)
- >>> lf2 = Sine(freq=.05, mul=10)
- >>> b = FreqShift(a, shift=lf1, mul=.5).out()
- >>> c = FreqShift(a, shift=lf2, mul=.5).out(1)
-
- """
- def __init__(self, input, shift=100, mul=1, add=0):
- PyoObject.__init__(self, mul, add)
- self._input = input
- self._shift = shift
- self._in_fader = InputFader(input)
- in_fader, shift, mul, add, lmax = convertArgsToLists(self._in_fader, shift, mul, add)
-
- self._hilb_objs = []
- self._sin_objs = []
- self._cos_objs = []
- self._mod_objs = []
- self._base_objs = []
- for i in range(lmax):
- self._hilb_objs.append(Hilbert(wrap(in_fader,i)))
- self._sin_objs.append(Sine(freq=wrap(shift,i), mul=.707))
- self._cos_objs.append(Sine(freq=wrap(shift,i), phase=0.25, mul=.707))
- self._mod_objs.append(Mix(self._hilb_objs[-1]['real'] * self._sin_objs[-1] + self._hilb_objs[-1]['imag'] * self._cos_objs[-1],
- mul=wrap(mul,i), add=wrap(add,i)))
- self._base_objs.extend(self._mod_objs[-1].getBaseObjects())
-
- def play(self, dur=0, delay=0):
- dur, delay, lmax = convertArgsToLists(dur, delay)
- [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._hilb_objs)]
- [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._sin_objs)]
- [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._cos_objs)]
- [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._mod_objs)]
- return PyoObject.play(self, dur, delay)
-
- def stop(self):
- [obj.stop() for obj in self._hilb_objs]
- [obj.stop() for obj in self._sin_objs]
- [obj.stop() for obj in self._cos_objs]
- [obj.stop() for obj in self._mod_objs]
- return PyoObject.stop(self)
-
- def out(self, chnl=0, inc=1, dur=0, delay=0):
- dur, delay, lmax = convertArgsToLists(dur, delay)
- [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._hilb_objs)]
- [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._sin_objs)]
- [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._cos_objs)]
- [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._mod_objs)]
- return PyoObject.out(self, chnl, inc, dur, delay)
-
- def setInput(self, x, fadetime=0.05):
- """
- Replace the `input` attribute.
-
- Parameters:
-
- x : PyoObject
- New signal to process.
- fadetime : float, optional
- Crossfade time between old and new input. Defaults to 0.05.
-
- """
- self._input = x
- self._in_fader.setInput(x, fadetime)
-
- def setShift(self, x):
- """
- Replace the `shift` attribute.
-
- Parameters:
-
- x : float or PyoObject
- New `shift` attribute.
-
- """
- self._shift = x
- x, lmax = convertArgsToLists(x)
- [obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._sin_objs)]
- [obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._cos_objs)]
-
- def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(-2000., 2000., "lin", "shift", self._shift), SLMapMul(self._mul)]
- PyoObject.ctrl(self, map_list, title, wxnoserver)
-
- @property
- def input(self):
- """PyoObject. Input signal to pitch shift."""
- return self._input
- @input.setter
- def input(self, x): self.setInput(x)
-
- @property
- def shift(self):
- """float or PyoObject. Amount of pitch shift in Hertz."""
- return self._shift
- @shift.setter
- def shift(self, x): self.setShift(x)
-
-class PartialTable(PyoTableObject):
- """
- Inharmonic waveform generator.
-
- Generates waveforms made of inharmonic components. Partials are
- given as a list of 2-values tuple, where the first one is the
- partial number (can be float) and the second one is the strength
- of the partial.
-
- The object uses the first two decimal values of each partial to
- compute a higher harmonic at a multiple of 100 (so each component
- is in reality truly harmonic). If the oscillator has a frequency
- divided by 100, the real desired partials will be restituted.
-
- The list:
-
- [(1, 1), (1.1, 0.7), (1.15, 0.5)] will draw a table with:
-
- harmonic 100 : amplitude = 1
- harmonic 110 : amplitude = 0.7
- harmonic 115 : amplitude = 0.5
-
- To listen to a signal composed of 200, 220 and 230 Hz, one should
- declared an oscillator like this (frequency of 200Hz divided by 100):
-
- a = Osc(t, freq=2, mul=0.5).out()
-
- :Parent: :py:class:`PyoTableObject`
-
- :Args:
-
- list : list of tuple, optional
- List of 2-values tuples. First value is the partial number (float up
- to two decimal values) and second value is its amplitude (relative to
- the other harmonics). Defaults to [(1,1), (1.33,0.5),(1.67,0.3)].
- size : int, optional
- Table size in samples. Because computed harmonics are very high in
- frequency, the table size must be bigger than a classic HarmTable.
- Defaults to 65536.
-
- >>> s = Server().boot()
- >>> s.start()
- >>> t = PartialTable([(1,1), (2.37, 0.5), (4.55, 0.3)]).normalize()
- >>> # Play with fundamentals 199 and 200 Hz
- >>> a = Osc(table=t, freq=[1.99,2], mul=.2).out()
-
- """
- def __init__(self, list=[(1,1), (1.33,0.5),(1.67,0.3)], size=65536):
- PyoTableObject.__init__(self, size)
- self._list = list
- self._par_table = HarmTable(self._create_list(), size)
- self._base_objs = self._par_table.getBaseObjects()
- self.normalize()
-
- def _create_list(self):
- # internal method used to compute the harmonics's weight
- hrms = [(int(x*100.), y) for x, y in self._list]
- l = []
- ind = 0
- for i in range(10000):
- if i == hrms[ind][0]:
- l.append(hrms[ind][1])
- ind += 1
- if ind == len(hrms):
- break
- else:
- l.append(0)
- return l
-
- def replace(self, list):
- """
- Redraw the waveform according to a new set of harmonics
- relative strengths.
-
- :Args:
-
- list : list of tuples
- Each tuple contains the partial number, as a float,
- and its strength.
-
- """
- self._list = list
- [obj.replace(self._create_list()) for obj in self._base_objs]
- self.normalize()
- self.refreshView()
-
- @property
- def list(self):
- """list. List of partial numbers and strength."""
- return self._list
- @list.setter
- def list(self, x): self.replace(x)
-
OBJECTS_TREE = {'functions': sorted(['pa_count_devices', 'pa_get_default_input', 'pa_get_default_output', 'pm_get_input_devices',
- 'pa_list_devices', 'pa_count_host_apis', 'pa_list_host_apis', 'pa_get_default_host_api',
- 'pm_count_devices', 'pm_list_devices', 'sndinfo', 'savefile', 'pa_get_output_devices',
- 'pa_get_input_devices', 'midiToHz', 'sampsToSec', 'secToSamps', 'example', 'class_args',
+ 'pa_list_devices', 'pa_count_host_apis', 'pa_list_host_apis', 'pa_get_default_host_api',
+ 'pm_count_devices', 'pm_list_devices', 'sndinfo', 'savefile', 'pa_get_output_devices',
+ 'pa_get_input_devices', 'midiToHz', 'hzToMidi', 'sampsToSec', 'secToSamps', 'example', 'class_args',
'pm_get_default_input', 'pm_get_output_devices', 'pm_get_default_output', 'midiToTranspo',
'getVersion', 'reducePoints', 'serverCreated', 'serverBooted', 'distanceToSegment', 'rescale',
'upsamp', 'downsamp', 'linToCosCurve', 'convertStringToSysEncoding', 'savefileFromTable',
'pa_get_input_max_channels', 'pa_get_output_max_channels', 'pa_get_devices_infos', 'pa_get_version',
- 'pa_get_version_text']),
+ 'pa_get_version_text', 'floatmap']),
'PyoObjectBase': {
- 'PyoMatrixObject': sorted(['NewMatrix']),
- 'PyoTableObject': sorted(['LinTable', 'NewTable', 'SndTable', 'HannTable', 'HarmTable', 'SawTable', 'ParaTable', 'LogTable', 'CosLogTable',
- 'SquareTable', 'ChebyTable', 'CosTable', 'CurveTable', 'ExpTable', 'DataTable', 'WinTable', 'SincTable', 'PartialTable']),
- 'PyoPVObject' : sorted(['PVAnal', 'PVSynth', 'PVTranspose', 'PVVerb', 'PVGate', 'PVAddSynth', 'PVCross', 'PVMult', 'PVMorph', 'PVFilter', 'PVDelay', 'PVBuffer', 'PVShift', 'PVAmpMod', 'PVFreqMod', 'PVBufLoops', 'PVBufTabLoops', 'PVMix']),
- 'PyoObject': {'analysis': sorted(['Follower', 'Follower2', 'ZCross', 'Yin']),
- 'arithmetic': sorted(['Sin', 'Cos', 'Tan', 'Abs', 'Sqrt', 'Log', 'Log2', 'Log10', 'Pow', 'Atan2', 'Floor', 'Round',
- 'Ceil']),
+ 'PyoMatrixObject': sorted(['NewMatrix']),
+ 'PyoTableObject': sorted(['LinTable', 'NewTable', 'SndTable', 'HannTable', 'HarmTable', 'SawTable', 'ParaTable',
+ 'LogTable', 'CosLogTable', 'SquareTable', 'ChebyTable', 'CosTable', 'CurveTable', 'ExpTable',
+ 'DataTable', 'WinTable', 'SincTable', 'PartialTable', 'AtanTable']),
+ 'PyoPVObject' : sorted(['PVAnal', 'PVSynth', 'PVTranspose', 'PVVerb', 'PVGate', 'PVAddSynth', 'PVCross', 'PVMult',
+ 'PVMorph', 'PVFilter', 'PVDelay', 'PVBuffer', 'PVShift', 'PVAmpMod', 'PVFreqMod', 'PVBufLoops',
+ 'PVBufTabLoops', 'PVMix']),
+ 'PyoObject': {'analysis': sorted(['Follower', 'Follower2', 'ZCross', 'Yin', 'Centroid', 'AttackDetector', 'Scope',
+ 'Spectrum', 'PeakAmp']),
+ 'arithmetic': sorted(['Sin', 'Cos', 'Tan', 'Abs', 'Sqrt', 'Log', 'Log2', 'Log10', 'Pow', 'Atan2', 'Floor',
+ 'Round', 'Ceil', 'Tanh']),
'controls': sorted(['Fader', 'Sig', 'SigTo', 'Adsr', 'Linseg', 'Expseg']),
'dynamics': sorted(['Clip', 'Compress', 'Degrade', 'Mirror', 'Wrap', 'Gate', 'Balance', 'Min', 'Max']),
- 'effects': sorted(['Delay', 'SDelay', 'Disto', 'Freeverb', 'Waveguide', 'Convolve', 'WGVerb',
+ 'effects': sorted(['Delay', 'SDelay', 'Disto', 'Freeverb', 'Waveguide', 'Convolve', 'WGVerb', 'SmoothDelay',
'Harmonizer', 'Chorus', 'AllpassWG', 'FreqShift', 'Vocoder', 'Delay1', 'STRev']),
'filters': sorted(['Biquad', 'BandSplit', 'Port', 'Hilbert', 'Tone', 'DCBlock', 'EQ', 'Allpass',
- 'Allpass2', 'Phaser', 'Biquadx', 'IRWinSinc', 'IRAverage', 'IRPulse', 'IRFM', 'FourBand',
- 'Biquada', 'Atone', 'SVF', 'Average', 'Reson', 'Resonx', 'ButLP', 'ButHP', 'ButBP', 'ButBR', 'ComplexRes']),
+ 'Allpass2', 'Phaser', 'Biquadx', 'IRWinSinc', 'IRAverage', 'IRPulse', 'IRFM',
+ 'FourBand', 'Biquada', 'Atone', 'SVF', 'Average', 'Reson', 'Resonx', 'ButLP',
+ 'ButHP', 'ButBP', 'ButBR', 'ComplexRes']),
'generators': sorted(['Noise', 'Phasor', 'Sine', 'Input', 'FM', 'SineLoop', 'Blit', 'PinkNoise', 'CrossFM',
'BrownNoise', 'Rossler', 'Lorenz', 'LFO', 'SumOsc', 'SuperSaw', 'RCOsc']),
'internals': sorted(['Dummy', 'InputFader', 'Mix', 'VarPort']),
- 'midi': sorted(['Midictl', 'CtlScan', 'CtlScan2', 'Notein', 'MidiAdsr', 'MidiDelAdsr', 'Bendin', 'Touchin', 'Programin']),
+ 'midi': sorted(['Midictl', 'CtlScan', 'CtlScan2', 'Notein', 'MidiAdsr', 'MidiDelAdsr', 'Bendin',
+ 'Touchin', 'Programin', 'RawMidi']),
'opensndctrl': sorted(['OscReceive', 'OscSend', 'OscDataSend', 'OscDataReceive', 'OscListReceive']),
'pan': sorted(['Pan', 'SPan', 'Switch', 'Selector', 'Mixer', 'VoiceManager']),
'pattern': sorted(['Pattern', 'Score', 'CallAfter']),
'randoms': sorted(['Randi', 'Randh', 'Choice', 'RandInt', 'Xnoise', 'XnoiseMidi', 'RandDur', 'XnoiseDur', 'Urn']),
'players': sorted(['SfMarkerShuffler', 'SfPlayer', 'SfMarkerLooper']),
- 'tableprocess': sorted(['TableRec', 'Osc', 'Pointer', 'Pointer2', 'Lookup', 'Granulator', 'Pulsar', 'OscLoop', 'Granule',
- 'TableRead', 'TableMorph', 'Looper', 'TableIndex', 'OscBank', 'OscTrig', 'TablePut', 'TableScale']),
- 'matrixprocess': sorted(['MatrixRec', 'MatrixPointer', 'MatrixMorph', 'MatrixRecLoop']),
- 'triggers': sorted(['Metro', 'Beat', 'TrigEnv', 'TrigRand', 'TrigRandInt', 'Select', 'Counter', 'TrigChoice',
+ 'tableprocess': sorted(['TableRec', 'Osc', 'Pointer', 'Pointer2', 'Lookup', 'Granulator', 'Pulsar', 'OscLoop',
+ 'Granule', 'TableRead', 'TableMorph', 'Looper', 'TableIndex', 'OscBank', 'OscTrig',
+ 'TablePut', 'TableScale', 'Particle', 'TableWrite']),
+ 'matrixprocess': sorted(['MatrixRec', 'MatrixPointer', 'MatrixMorph', 'MatrixRecLoop']),
+ 'triggers': sorted(['Metro', 'Beat', 'TrigEnv', 'TrigRand', 'TrigRandInt', 'Select', 'Counter', 'TrigChoice',
'TrigFunc', 'Thresh', 'Cloud', 'Trig', 'TrigXnoise', 'TrigXnoiseMidi', 'Timer', 'Count',
'Change', 'TrigLinseg', 'TrigExpseg', 'Percent', 'Seq', 'TrigTableRec', 'Iter', 'NextTrig',
- 'TrigVal']),
+ 'TrigVal', 'Euclide', 'TrigBurst']),
'utils': sorted(['Clean_objects', 'Print', 'Snap', 'Interp', 'SampHold', 'Compare', 'Record', 'Between', 'Denorm',
'ControlRec', 'ControlRead', 'NoteinRec', 'NoteinRead', 'DBToA', 'AToDB', 'Scale', 'CentsToTranspo',
- 'TranspoToCents', 'MToF', 'MToT', 'TrackHold']),
- 'fourier': sorted(['FFT', 'IFFT', 'CarToPol', 'PolToCar', 'FrameDelta', 'FrameAccum', 'Vectral', 'CvlVerb', 'Spectrum'])}},
+ 'TranspoToCents', 'MToF', 'FToM', 'MToT', 'TrackHold']),
+ 'fourier': sorted(['FFT', 'IFFT', 'CarToPol', 'PolToCar', 'FrameDelta', 'FrameAccum', 'Vectral', 'CvlVerb'])}},
'Map': {'SLMap': sorted(['SLMapFreq', 'SLMapMul', 'SLMapPhase', 'SLMapQ', 'SLMapDur', 'SLMapPan'])},
- 'Server': [],
- 'Stream': [],
+ 'Server': [],
+ 'Stream': [],
'TableStream': []}
-DOC_KEYWORDS = ['Attributes', 'Examples', 'Parameters', 'Methods', 'Notes', 'Methods details', 'See also', 'Parentclass']
-DEMOS_PATH = SNDS_PATH
+DOC_KEYWORDS = ['Attributes', 'Examples', 'Parameters', 'Methods', 'Notes', 'Methods details', 'See also', 'Parentclass']
\ No newline at end of file
diff --git a/pyo64.py b/pyo64.py
index dbd5b17..04f100f 100644
--- a/pyo64.py
+++ b/pyo64.py
@@ -1,22 +1,22 @@
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
import __builtin__
__builtin__.pyo_use_double = True
-from pyo import *
+from pyo import *
\ No newline at end of file
diff --git a/pyolib/_core.py b/pyolib/_core.py
index aea4c02..5549858 100644
--- a/pyolib/_core.py
+++ b/pyolib/_core.py
@@ -1,36 +1,36 @@
# -*- coding: utf-8 -*-
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+GNU Lesser General Public License for more details.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
-from types import ListType, SliceType, FloatType, StringType, UnicodeType
+from types import BooleanType, ListType, TupleType, SliceType, LongType, IntType, FloatType, StringType, UnicodeType, NoneType
import random, os, sys, inspect, tempfile
from subprocess import call
+from weakref import proxy
import __builtin__
if hasattr(__builtin__, 'pyo_use_double'):
import pyo64 as current_pyo
from _pyo64 import *
-else:
+else:
import pyo as current_pyo
from _pyo import *
-
+
from _maps import *
from _widgets import createCtrlWindow, createViewTableWindow, createViewMatrixWindow
@@ -38,10 +38,8 @@ from _widgets import createCtrlWindow, createViewTableWindow, createViewMatrixWi
### Utilities
######################################################################
SNDS_PATH = os.path.join(os.path.dirname(current_pyo.__file__), "pyolib", "snds")
-XNOISE_DICT = {'uniform': 0, 'linear_min': 1, 'linear_max': 2, 'triangle': 3,
- 'expon_min': 4, 'expon_max': 5, 'biexpon': 6, 'cauchy': 7,
- 'weibull': 8, 'gaussian': 9, 'poisson': 10, 'walker': 11,
- 'loopseg': 12}
+XNOISE_DICT = {'uniform': 0, 'linear_min': 1, 'linear_max': 2, 'triangle': 3, 'expon_min': 4, 'expon_max': 5,
+ 'biexpon': 6, 'cauchy': 7, 'weibull': 8, 'gaussian': 9, 'poisson': 10, 'walker': 11, 'loopseg': 12}
FILE_FORMATS = {'wav': 0, 'wave': 0, 'aif': 1, 'aiff': 1, 'au': 2, '': 3, 'sd2': 4, 'flac': 5, 'caf': 6, 'ogg': 7}
FUNCTIONS_INIT_LINES = {"pa_count_host_apis": "pa_count_host_apis()", "pa_list_host_apis": "pa_list_host_apis()",
"pa_get_default_host_api": "pa_get_default_host_api()", "pa_count_devices": "pa_count_devices()",
@@ -56,24 +54,165 @@ FUNCTIONS_INIT_LINES = {"pa_count_host_apis": "pa_count_host_apis()", "pa_list_h
"sndinfo": "sndinfo(path, print=False)", "savefile": "savefile(samples, path, sr=44100, channels=1, fileformat=0, sampletype=0)",
"savefileFromTable": "savefileFromTable(table, path, fileformat=0, sampletype=0)",
"upsamp": "upsamp(path, outfile, up=4, order=128)", "downsamp": "downsamp(path, outfile, down=4, order=128)",
- "midiToHz": "midiToHz(x)", "midiToTranspo": "midiToTranspo(x)", "sampsToSec": "sampsToSec(x)",
+ "midiToHz": "midiToHz(x)", "hzToMidi": "hzToMidi(x)", "midiToTranspo": "midiToTranspo(x)", "sampsToSec": "sampsToSec(x)",
"secToSamps": "secToSamps(x)", "linToCosCurve": "linToCosCurve(data, yrange=[0, 1], totaldur=1, points=1024, log=False)",
"rescale": "rescale(data, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, xlog=False, ylog=False)",
"distanceToSegment": "distanceToSegment(p, p1, p2, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, xlog=False, ylog=False)",
"reducePoints": "reducePoints(pointlist, tolerance=0.02)", "serverCreated": "serverCreated()", "serverBooted": "serverBooted()",
"example": "example(cls, dur=5, toprint=True, double=False)", "class_args": "class_args(cls)", "getVersion": "getVersion()",
"convertStringToSysEncoding": "convertStringToSysEncoding(str)", "convertArgsToLists": "convertArgsToLists(*args)",
- "wrap": "wrap(arg, i)"
+ "wrap": "wrap(arg, i)", "floatmap": "floatmap(x, min=0, max=1, exp=1)"
}
+class PyoError(Exception):
+ """Base class for all pyo exceptions."""
+
+class PyoServerStateException(PyoError):
+ """Error raised when an operation requires the server to be booted."""
+
+class PyoArgumentTypeError(PyoError):
+ """Error raised when if an object got an invalid argument."""
+
+def isAudioObject(obj):
+ return isinstance(obj, PyoObject) or hasattr(obj, "stream")
+
+def isTableObject(obj):
+ return isinstance(obj, PyoTableObject) or hasattr(obj, "tablestream")
+
+def isMatrixObject(obj):
+ return isinstance(obj, PyoMatrixObject) or hasattr(obj, "matrixstream")
+
+def isPVObject(obj):
+ return isinstance(obj, PyoPVObject) or hasattr(obj, "pv_stream")
+
+def pyoArgsAssert(obj, format, *args):
+ """
+ Raise an Exception if an object got an invalid argument.
+
+ :Args:
+
+ obj : Pyo object on which method is called.
+ Usually "self" in the function call.
+ format :
+ String of length equal to the number of arguments. Each character
+ indicating the expected argument type.
+
+ - O : float or PyoObject
+ - o : PyoObject
+ - T : float or PyoTableObject
+ - t : PyoTableObject
+ - m : PyoMatrixObject
+ - p : PyoPVObject
+ - n : any number (int or float)
+ - N : any number (no list-expansion)
+ - f : float
+ - F : float (no list-expansion)
+ - i : integer
+ - I : integer (no list-expansion)
+ - s : string or unicode
+ - S : string or unicode (no list-expansion)
+ - b : boolean
+ - B : boolean (no list-expansion)
+ - l : list
+ - L : list or None
+ - u : tuple
+ - x : sequence (list or tuple)
+ - c : callable
+ - C : callable (no list-expansion)
+ - z : anything
+ *args : any
+ Arguments passed to the object's method.
+
+ """
+ expected = ""
+ for i in range(len(args)):
+ f = format[i]
+ argtype = type(args[i])
+ if f == "O":
+ if not isAudioObject(args[i]) and \
+ argtype not in [ListType, IntType, LongType, FloatType]:
+ expected = "float or PyoObject"
+ elif f == "o":
+ if not isAudioObject(args[i]) and argtype not in [ListType]:
+ expected = "PyoObject"
+ elif f == "T":
+ if not isTableObject(args[i]) and argtype not in [FloatType, ListType]:
+ expected = "float or PyoTableObject"
+ elif f == "t":
+ if not isTableObject(args[i]) and argtype not in [ListType]:
+ expected = "PyoTableObject"
+ elif f == "m":
+ if not isMatrixObject(args[i]) and argtype not in [ListType]:
+ expected = "PyoMatrixObject"
+ elif f == "p":
+ if not isPVObject(args[i]) and argtype not in [ListType]:
+ expected = "PyoPVObject"
+ elif f == "n":
+ if argtype not in [ListType, IntType, LongType, FloatType]:
+ expected = "any number"
+ elif f == "N":
+ if argtype not in [IntType, LongType, FloatType]:
+ expected = "any number - list not allowed"
+ elif f == "f":
+ if argtype not in [ListType, FloatType]:
+ expected = "float"
+ elif f == "F":
+ if argtype not in [FloatType]:
+ expected = "float - list not allowed"
+ elif f == "i":
+ if argtype not in [ListType, IntType, LongType]:
+ expected = "integer"
+ elif f == "I":
+ if argtype not in [IntType, LongType]:
+ expected = "integer - list not allowed"
+ elif f == "s":
+ if argtype not in [ListType, StringType, UnicodeType]:
+ expected = "string"
+ elif f == "S":
+ if argtype not in [StringType, UnicodeType]:
+ expected = "string - list not allowed"
+ elif f == "b":
+ if argtype not in [BooleanType, ListType, IntType, LongType]:
+ expected = "boolean"
+ elif f == "B":
+ if argtype not in [BooleanType, IntType, LongType]:
+ expected = "boolean - list not allowed"
+ elif f == "l":
+ if argtype not in [ListType]:
+ expected = "list"
+ elif f == "L":
+ if argtype not in [ListType, NoneType]:
+ expected = "list or None"
+ elif f == "u":
+ if argtype not in [TupleType]:
+ expected = "tuple"
+ elif f == "x":
+ if argtype not in [ListType, TupleType]:
+ expected = "list or tuple"
+ elif f == "c":
+ if not callable(args[i]) and argtype not in [ListType, TupleType, NoneType]:
+ expected = "callable"
+ elif f == "C":
+ if not callable(args[i]) and argtype not in [NoneType]:
+ expected = "callable - list not allowed"
+ elif f == "z":
+ pass
+
+ if expected:
+ break
+
+ if expected:
+ name = obj.__class__.__name__
+ raise PyoArgumentTypeError('bad argument at position %d to "%s" (%s expected, got %s)' % (i, name, expected, argtype))
+
def convertStringToSysEncoding(str):
"""
Convert a string to the current platform file system encoding.
-
+
Returns the new encoded string.
:Args:
-
+
str : string
String to convert.
@@ -82,12 +221,12 @@ def convertStringToSysEncoding(str):
str = str.decode("utf-8")
str = str.encode(sys.getfilesystemencoding())
return str
-
+
def convertArgsToLists(*args):
"""
- Convert all arguments to list if not already a list or a PyoObject.
+ Convert all arguments to list if not already a list or a PyoObject.
Return new args and maximum list length.
-
+
"""
converted = []
for i in args:
@@ -95,14 +234,14 @@ def convertArgsToLists(*args):
converted.append(i)
else:
converted.append([i])
-
+
max_length = max(len(i) for i in converted)
return tuple(converted + [max_length])
def wrap(arg, i):
"""
Return value at position `i` from `arg` with wrap around `arg` length.
-
+
"""
x = arg[i % len(arg)]
if isinstance(x, PyoObjectBase):
@@ -158,16 +297,13 @@ def example(cls, dur=5, toprint=True, double=False):
ex += line + "\n"
ex += "time.sleep(%f)\ns.stop()\ntime.sleep(0.25)\ns.shutdown()\n" % dur
- if sys.version_info[:2] <= (2, 5):
- f = open('/tmp/pyo_example.py', 'w')
- else:
- f = tempfile.NamedTemporaryFile(delete=False)
+ f = tempfile.NamedTemporaryFile(delete=False)
if toprint:
f.write('print """\n%s\n"""\n' % ex)
f.write(ex)
- f.close()
+ f.close()
p = call(["python", f.name])
-
+
def removeExtraDecimals(x):
if type(x) == FloatType:
return "=%.2f" % x
@@ -180,7 +316,7 @@ def class_args(cls):
"""
Returns the init line of a class reference.
- This function takes a class reference (not an instance of that class)
+ This function takes a class reference (not an instance of that class)
as input and returns the init line of that class with the default values.
:Args:
@@ -213,7 +349,7 @@ def getVersion():
Returns the version number of the current pyo installation.
This function returns the version number of the current pyo
- installation as a 3-ints tuple (major, minor, rev).
+ installation as a 3-ints tuple (major, minor, rev).
The returned tuple for version '0.4.1' will look like : (0, 4, 1)
@@ -224,14 +360,39 @@ def getVersion():
major, minor, rev = PYO_VERSION.split('.')
return (int(major), int(minor), int(rev))
-def dumpref():
- pass
-
-class PyoError(Exception):
- """Base class for all pyo exceptions."""
+def getWeakMethodRef(x):
+ if type(x) in [ListType, TupleType]:
+ tmp = []
+ for y in x:
+ if hasattr(y, "__self__"):
+ y = WeakMethod(y)
+ tmp.append(y)
+ x = tmp
+ else:
+ if hasattr(x, "__self__"):
+ x = WeakMethod(x)
+ return x
+
+class WeakMethod(object):
+ """A callable object. Takes one argument to init: 'object.method'.
+ Once created, call this object -- MyWeakMethod() --
+ and pass args/kwargs as you normally would.
+ """
+ def __init__(self, callobj):
+ if hasattr(callobj, "__self__"):
+ self.target = proxy(callobj.__self__)
+ self.method = proxy(callobj.__func__)
+ self.isMethod = True
+ else:
+ self.method = callobj
+ self.isMethod = False
-class PyoServerStateException(PyoError):
- """Error raised when an operation requires the server to be booted."""
+ def __call__(self, *args, **kwargs):
+ """Call the method with args and kwargs as needed."""
+ if self.isMethod:
+ return self.method(self.target, *args, **kwargs)
+ else:
+ return self.method(*args, **kwargs)
######################################################################
### PyoObjectBase -> abstract class for pyo objects
@@ -248,7 +409,7 @@ class PyoObjectBase(object):
.. note::
**Operations allowed on all PyoObjectBase**
-
+
>>> len(obj) # Return the number of streams managed by the object.
>>> obj[x] # Return stream `x` of the object. `x` is a number from 0 to len(obj)-1.
>>> dir(obj) # Return the list of attributes of the object.
@@ -258,7 +419,7 @@ class PyoObjectBase(object):
# Descriptive word for this kind of object, for use in printing
# descriptions of the object. Subclasses need to set this.
_STREAM_TYPE = ''
-
+
def __init__(self):
if not serverCreated():
raise PyoServerStateException("You must create and boot a Server before creating any audio object.")
@@ -269,7 +430,7 @@ class PyoObjectBase(object):
"""
Print infos about the current state of the object.
- Print the number of Stream objects managed by the instance
+ Print the number of Stream objects managed by the instance
and the current status of the object's attributes.
"""
@@ -290,19 +451,26 @@ class PyoObjectBase(object):
"""
return self._base_objs
- def cleanFuncRefs(self):
+ def getServer(self):
"""
- Method used to remove internal references to callback functions.
-
- An internal reference to a callback function (ex. the function
- called by the TrigFunc object) may prevent the object to be
- properly deleted when its reference count drop to zero. Calling
- this function just before deleting the last reference will replace
- the callback reference by a dump ref.
+ Return a reference to the current Server object.
+
+ """
+ return self._base_objs[0].getServer()
+ def getSamplingRate(self):
"""
- if hasattr(self, "_function"):
- self.setFunction(dumpref)
+ Return the current sampling rate (samples per second), as a float.
+
+ """
+ return self._base_objs[0].getServer().getSamplingRate()
+
+ def getBufferSize(self):
+ """
+ Return the current buffer size (samples per buffer), as an integer.
+
+ """
+ return self._base_objs[0].getServer().getBufferSize()
def __getitem__(self, i):
if i == 'trig':
@@ -332,11 +500,11 @@ class PyoObjectBase(object):
class PyoObject(PyoObjectBase):
"""
Base class for all pyo objects that manipulate vectors of samples.
-
+
The user should never instantiate an object of this class.
:Parent: :py:class:`PyoObjectBase`
-
+
:Args:
mul : float or PyoObject, optional
@@ -345,22 +513,22 @@ class PyoObject(PyoObjectBase):
Addition factor. Defaults to 0.
.. note::
-
+
**Arithmetics**
-
- Multiplication, addition, division and substraction can be applied
- between pyo objects or between pyo objects and numbers. Doing so
+
+ Multiplication, addition, division and substraction can be applied
+ between pyo objects or between pyo objects and numbers. Doing so
returns a Dummy object with the result of the operation.
-
+
>>> # creates a Dummy object `b` with `mul` set to 0.5 and leave `a` unchanged.
>>> b = a * 0.5
-
- Inplace multiplication, addition, division and substraction can be
- applied between pyo objects or between pyo objects and numbers.
- These operations will replace the `mul` or `add` factor of the object.
-
+
+ Inplace multiplication, addition, division and substraction can be
+ applied between pyo objects or between pyo objects and numbers.
+ These operations will replace the `mul` or `add` factor of the object.
+
>>> a *= 0.5 # replaces the `mul` attribute of `a`.
-
+
The next operators can be used with PyoObject (not with XXX_base objects).
**Exponent** and **modulo**
@@ -371,11 +539,11 @@ class PyoObject(PyoObjectBase):
>>> a % b # returns a Wrap object created as : Wrap(a, 0, b)
**Unary negative** (**-**)
-
+
>>> -a # returns a Dummy object with negative values of streams in `a`.
-
+
**Comparison operators**
-
+
>>> a < b # returns a Compare object created as : Compare(a, comp=b, mode="<")
>>> a <= b # returns a Compare object created as : Compare(a, comp=b, mode="<=")
>>> a == b # returns a Compare object created as : Compare(a, comp=b, mode="==")
@@ -387,7 +555,7 @@ class PyoObject(PyoObjectBase):
return False except `a != None`, which returns True.
"""
-
+
_STREAM_TYPE = 'audio'
def __init__(self, mul=1.0, add=0.0):
@@ -412,16 +580,16 @@ class PyoObject(PyoObjectBase):
_add_dummy = Dummy([wrap(self._base_objs,i) + obj for i, obj in enumerate(x)])
self._keep_trace.append(_add_dummy)
return _add_dummy
-
+
def __radd__(self, x):
x, lmax = convertArgsToLists(x)
if self.__len__() >= lmax:
_add_dummy = Dummy([obj + wrap(x,i/self._op_duplicate) for i, obj in enumerate(self._base_objs)])
else:
- _add_dummy = Dummy([wrap(self._base_objs,i) + obj for i, obj in enumerate(x)])
+ _add_dummy = Dummy([wrap(self._base_objs,i) + obj for i, obj in enumerate(x)])
self._keep_trace.append(_add_dummy)
return _add_dummy
-
+
def __iadd__(self, x):
self.setAdd(x)
return self
@@ -460,7 +628,7 @@ class PyoObject(PyoObjectBase):
def __isub__(self, x):
self.setSub(x)
return self
-
+
def __mul__(self, x):
x, lmax = convertArgsToLists(x)
if self.__len__() >= lmax:
@@ -469,23 +637,23 @@ class PyoObject(PyoObjectBase):
if isinstance(x, PyoObject):
_mul_dummy = x * self
else:
- _mul_dummy = Dummy([wrap(self._base_objs,i) * obj for i, obj in enumerate(x)])
+ _mul_dummy = Dummy([wrap(self._base_objs,i) * obj for i, obj in enumerate(x)])
self._keep_trace.append(_mul_dummy)
return _mul_dummy
-
+
def __rmul__(self, x):
x, lmax = convertArgsToLists(x)
if self.__len__() >= lmax:
_mul_dummy = Dummy([obj * wrap(x,i/self._op_duplicate) for i, obj in enumerate(self._base_objs)])
else:
- _mul_dummy = Dummy([wrap(self._base_objs,i) * obj for i, obj in enumerate(x)])
+ _mul_dummy = Dummy([wrap(self._base_objs,i) * obj for i, obj in enumerate(x)])
self._keep_trace.append(_mul_dummy)
return _mul_dummy
-
+
def __imul__(self, x):
self.setMul(x)
return self
-
+
def __div__(self, x):
x, lmax = convertArgsToLists(x)
if self.__len__() >= lmax:
@@ -529,7 +697,7 @@ class PyoObject(PyoObjectBase):
def __mod__(self, x):
return Wrap(self, 0, x)
-
+
def __neg__(self):
if self._zeros == None:
self._zeros = Sig(0)
@@ -568,11 +736,12 @@ class PyoObject(PyoObjectBase):
all : boolean, optional
If True, the object returns a list with the state of all
streams managed by the object.
-
- If False, it return a boolean corresponding to the state
+
+ If False, it return a boolean corresponding to the state
of the first stream.
"""
+ pyoArgsAssert(self, "B", all)
if all:
return [obj._getStream().isPlaying() for obj in self._base_objs]
else:
@@ -586,38 +755,40 @@ class PyoObject(PyoObjectBase):
all : boolean, optional
If True, the object returns a list with the state of all
- streams managed by the object.
-
- If False, it return a boolean corresponding to the state
+ streams managed by the object.
+
+ If False, it return a boolean corresponding to the state
of the first stream.
"""
+ pyoArgsAssert(self, "B", all)
if all:
return [obj._getStream().isOutputting() for obj in self._base_objs]
else:
return self._base_objs[0]._getStream().isOutputting()
-
+
def get(self, all=False):
"""
Return the first sample of the current buffer as a float.
-
+
Can be used to convert audio stream to usable Python data.
-
- Object that implements string identifier for specific audio
+
+ Object that implements string identifier for specific audio
streams must use the corresponding string to specify the stream
- from which to get the value. See get() method definition in these
+ from which to get the value. See get() method definition in these
object's man pages.
-
+
:Args:
all : boolean, optional
If True, the first value of each object's stream
- will be returned as a list.
-
- If False, only the value of the first object's stream
+ will be returned as a list.
+
+ If False, only the value of the first object's stream
will be returned as a float.
"""
+ pyoArgsAssert(self, "B", all)
if not all:
return self._base_objs[0]._getStream().getValue()
else:
@@ -625,24 +796,30 @@ class PyoObject(PyoObjectBase):
def play(self, dur=0, delay=0):
"""
- Start processing without sending samples to output.
+ Start processing without sending samples to output.
This method is called automatically at the object creation.
This method returns `self`, allowing it to be applied at the object
creation.
-
+
:Args:
-
+
dur : float, optional
Duration, in seconds, of the object's activation. The default is 0
and means infinite duration.
delay : float, optional
Delay, in seconds, before the object's activation. Defaults to 0.
-
+
"""
+ pyoArgsAssert(self, "nn", dur, delay)
dur, delay, lmax = convertArgsToLists(dur, delay)
if hasattr(self, "_trig_objs"):
- self._trig_objs.play(dur, delay)
+ if type(self._trig_objs) == ListType:
+ for i in range(lmax):
+ for obj in self._trig_objs:
+ obj.play(wrap(dur,i), wrap(delay,i))
+ else:
+ self._trig_objs.play(dur, delay)
if hasattr(self, "_base_players"):
[obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
[obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
@@ -654,11 +831,11 @@ class PyoObject(PyoObjectBase):
This method returns `self`, allowing it to be applied at the object
creation.
-
+
:Args:
chnl : int, optional
- Physical output assigned to the first audio stream of the object.
+ Physical output assigned to the first audio stream of the object.
Defaults to 0.
inc : int, optional
Output channel increment value. Defaults to 1.
@@ -667,42 +844,51 @@ class PyoObject(PyoObjectBase):
and means infinite duration.
delay : float, optional
Delay, in seconds, before the object's activation. Defaults to 0.
-
- If `chnl` >= 0, successive streams increment the output number by
+
+ If `chnl` >= 0, successive streams increment the output number by
`inc` and wrap around the global number of channels.
-
- If `chnl` is negative, streams begin at 0, increment
- the output number by `inc` and wrap around the global number of
+
+ If `chnl` is negative, streams begin at 0, increment
+ the output number by `inc` and wrap around the global number of
channels. Then, the list of streams is scrambled.
-
- If `chnl` is a list, successive values in the list will be
+
+ If `chnl` is a list, successive values in the list will be
assigned to successive streams.
"""
+ pyoArgsAssert(self, "iInn", chnl, inc, dur, delay)
dur, delay, lmax = convertArgsToLists(dur, delay)
if hasattr(self, "_trig_objs"):
- self._trig_objs.play(dur, delay)
+ if type(self._trig_objs) == ListType:
+ for i in range(lmax):
+ for obj in self._trig_objs:
+ obj.play(wrap(dur,i), wrap(delay,i))
+ else:
+ self._trig_objs.play(dur, delay)
if hasattr(self, "_base_players"):
[obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
if type(chnl) == ListType:
[obj.out(wrap(chnl,i), wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
else:
- if chnl < 0:
+ if chnl < 0:
[obj.out(i*inc, wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(random.sample(self._base_objs, len(self._base_objs)))]
else:
[obj.out(chnl+i*inc, wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
return self
-
+
def stop(self):
"""
Stop processing.
This method returns `self`, allowing it to be applied at the object
creation.
-
+
"""
if hasattr(self, "_trig_objs"):
- self._trig_objs.stop()
+ if type(self._trig_objs) == ListType:
+ [obj.stop() for obj in self._trig_objs]
+ else:
+ self._trig_objs.stop()
if hasattr(self, "_base_players"):
[obj.stop() for obj in self._base_players]
[obj.stop() for obj in self._base_objs]
@@ -710,18 +896,18 @@ class PyoObject(PyoObjectBase):
def mix(self, voices=1):
"""
- Mix the object's audio streams into `voices` streams and return
+ Mix the object's audio streams into `voices` streams and return
a Mix object.
-
+
:Args:
voices : int, optional
- Number of audio streams of the Mix object created by this method.
+ Number of audio streams of the Mix object created by this method.
Defaults to 1.
- If more than 1, object's streams are alternated and added into
+ If more than 1, object's streams are alternated and added into
Mix object's streams.
-
+
"""
return Mix(self, voices)
@@ -745,6 +931,7 @@ class PyoObject(PyoObjectBase):
Maximum value of the output signal.
"""
+ pyoArgsAssert(self, "nn", min, max)
min, max, lmax = convertArgsToLists(min, max)
if lmax > 1:
mul = [(wrap(max,i) - wrap(min,i)) * 0.5 for i in range(lmax)]
@@ -755,59 +942,63 @@ class PyoObject(PyoObjectBase):
self.setMul(mul)
self.setAdd(add)
return self
-
+
def setMul(self, x):
"""
Replace the `mul` attribute.
-
+
:Args:
x : float or PyoObject
New `mul` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._mul = x
x, lmax = convertArgsToLists(x)
[obj.setMul(wrap(x,i/self._op_duplicate)) for i, obj in enumerate(self._base_objs)]
-
+
def setAdd(self, x):
"""
Replace the `add` attribute.
-
+
:Args:
x : float or PyoObject
New `add` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._add = x
x, lmax = convertArgsToLists(x)
[obj.setAdd(wrap(x,i/self._op_duplicate)) for i, obj in enumerate(self._base_objs)]
def setSub(self, x):
"""
- Replace and inverse the `mul` attribute.
-
+ Replace and inverse the `add` attribute.
+
:Args:
x : float or PyoObject
- New inversed `mul` attribute.
-
+ New inversed `add` attribute.
+
"""
+ pyoArgsAssert(self, "O", x)
self._add = x
x, lmax = convertArgsToLists(x)
[obj.setSub(wrap(x,i/self._op_duplicate)) for i, obj in enumerate(self._base_objs)]
def setDiv(self, x):
"""
- Replace and inverse the `add` attribute.
-
+ Replace and inverse the `mul` attribute.
+
:Args:
x : float or PyoObject
- New inversed `add` attribute.
+ New inversed `mul` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._mul = x
x, lmax = convertArgsToLists(x)
[obj.setDiv(wrap(x,i/self._op_duplicate)) for i, obj in enumerate(self._base_objs)]
@@ -830,6 +1021,7 @@ class PyoObject(PyoObjectBase):
Time, in seconds, to reach the new value.
"""
+ pyoArgsAssert(self, "Snn", attr, value, port)
self._target_dict[attr] = value
init = getattr(self, attr)
if self._signal_dict.has_key(attr):
@@ -844,30 +1036,30 @@ class PyoObject(PyoObjectBase):
if isinstance(getattr(self, attr), VarPort):
setattr(self, attr, self._target_dict[attr])
self._signal_dict[attr].stop()
-
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
"""
- Opens a sliders window to control the parameters of the object.
- Only parameters that can be set to a PyoObject are allowed
+ Opens a sliders window to control the parameters of the object.
+ Only parameters that can be set to a PyoObject are allowed
to be mapped on a slider.
- If a list of values are given to a parameter, a multisliders
+ If a list of values are given to a parameter, a multisliders
will be used to control each stream independently.
:Args:
map_list : list of SLMap objects, optional
- Users defined set of parameters scaling. There is default
+ Users defined set of parameters scaling. There is default
scaling for each object that accept `ctrl` method.
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
if map_list == None:
@@ -879,55 +1071,56 @@ class PyoObject(PyoObjectBase):
@property
def mul(self):
- """float or PyoObject. Multiplication factor."""
+ """float or PyoObject. Multiplication factor."""
return self._mul
@mul.setter
def mul(self, x): self.setMul(x)
@property
def add(self):
- """float or PyoObject. Addition factor."""
+ """float or PyoObject. Addition factor."""
return self._add
@add.setter
def add(self, x): self.setAdd(x)
-
+
######################################################################
### PyoTableObject -> base class for pyo table objects
######################################################################
class PyoTableObject(PyoObjectBase):
"""
- Base class for all pyo table objects.
-
- A table object is a buffer memory to store precomputed samples.
-
+ Base class for all pyo table objects.
+
+ A table object is a buffer memory to store precomputed samples.
+
The user should never instantiate an object of this class.
-
+
:Parent: :py:class:`PyoObjectBase`
-
+
:Args:
size : int
Length of the table in samples. Usually provided by the child object.
"""
-
+
_STREAM_TYPE = 'table'
def __init__(self, size=0):
PyoObjectBase.__init__(self)
self._size = size
self.viewFrame = None
+ self.graphFrame = None
def save(self, path, format=0, sampletype=0):
"""
Writes the content of the table in an audio file.
-
+
The sampling rate of the file is the sampling rate of the server
and the number of channels is the number of table streams of the
object.
:Args:
-
+
path : string
Full path (including extension) of the new file.
format : int, optional
@@ -941,8 +1134,8 @@ class PyoTableObject(PyoObjectBase):
6. CAF - Core Audio File format {.caf}
7. OGG - Xiph OGG container {.ogg}
sampletype : int, optional
- Bit depth encoding of the audio file.
-
+ Bit depth encoding of the audio file.
+
SD2 and FLAC only support 16 or 24 bit int. Supported types are:
0. 16 bit int (default)
1. 24 bit int
@@ -953,22 +1146,23 @@ class PyoTableObject(PyoObjectBase):
6. A-Law encoded
"""
+ pyoArgsAssert(self, "SII", path, format, sampletype)
ext = path.rsplit('.')
if len(ext) >= 2:
ext = ext[-1].lower()
if FILE_FORMATS.has_key(ext):
format = FILE_FORMATS[ext]
savefileFromTable(self, path, format, sampletype)
-
+
def write(self, path, oneline=True):
"""
Writes the content of the table in a text file.
-
+
This function can be used to store the table data as a
list of floats into a text file.
-
+
:Args:
-
+
path : string
Full path of the generated file.
oneline : boolean, optional
@@ -978,6 +1172,7 @@ class PyoTableObject(PyoObjectBase):
per line.
"""
+ pyoArgsAssert(self, "SB", path, oneline)
f = open(path, "w")
if oneline:
f.write(str([obj.getTable() for obj in self._base_objs]))
@@ -998,21 +1193,22 @@ class PyoTableObject(PyoObjectBase):
"""
Reads the content of a text file and replaces the table data
with the values stored in the file.
-
+
:Args:
-
+
path : string
Full path of the file to read.
-
- The format is a list of lists of floats. For example, A two
+
+ The format is a list of lists of floats. For example, A two
tablestreams object must be given a content like this:
-
+
[ [ 0.0, 1.0, 0.5, ... ], [ 1.0, 0.99, 0.98, 0.97, ... ] ]
-
- Each object's tablestream will be resized according to the
+
+ Each object's tablestream will be resized according to the
length of the lists.
-
+
"""
+ pyoArgsAssert(self, "S", path)
f = open(path, "r")
f_list = eval(f.read())
f_len = len(f_list)
@@ -1022,16 +1218,17 @@ class PyoTableObject(PyoObjectBase):
def setSize(self, size):
"""
- Change the size of the table.
-
+ Change the size of the table.
+
This will erase the previously drawn waveform.
-
+
:Args:
-
+
size : int
New table size in samples.
-
+
"""
+ pyoArgsAssert(self, "I", size)
self._size = size
[obj.setSize(size) for obj in self._base_objs]
self.refreshView()
@@ -1039,15 +1236,16 @@ class PyoTableObject(PyoObjectBase):
def getSize(self, all=False):
"""
Return table size in samples.
-
+
:Args:
-
+
all : boolean
If the table contains more than one stream and `all` is True,
returns a list of all sizes. Otherwise, returns only the
first size as an int. Defaults to False.
-
+
"""
+ pyoArgsAssert(self, "B", all)
if all:
return [obj.getSize() for obj in self._base_objs]
else:
@@ -1059,36 +1257,38 @@ class PyoTableObject(PyoObjectBase):
def put(self, value, pos=0):
"""
Puts a value at specified sample position in the table.
-
+
If the object has more than 1 tablestream, the default is to
- record the value in each table. User can call obj[x].put()
+ record the value in each table. User can call obj[x].put()
to record into a specific table.
-
+
:Args:
-
+
value : float
Value, as floating-point, to record in the table.
pos : int, optional
Position, in samples, where to record value. Defaults to 0.
-
+
"""
+ pyoArgsAssert(self, "NI", value, pos)
[obj.put(value, pos) for obj in self._base_objs]
self.refreshView()
def get(self, pos):
"""
Returns the value, as float, stored at a specified position in the table.
-
+
If the object has more than 1 tablestream, the default is to
- return a list with the value of each tablestream. User can call
+ return a list with the value of each tablestream. User can call
obj[x].get() to get the value of a specific table.
-
+
:Args:
-
+
pos : int, optional
Position, in samples, where to read the value. Defaults to 0.
-
+
"""
+ pyoArgsAssert(self, "I", pos)
values = [obj.get(pos) for obj in self._base_objs]
if len(values) == 1: return values[0]
else: return values
@@ -1096,17 +1296,18 @@ class PyoTableObject(PyoObjectBase):
def getTable(self, all=False):
"""
Returns the content of the table as list of floats.
-
+
:Args:
all : boolean, optional
If True, all sub tables are retrieved and returned as a list
- of list of floats.
-
- If False, a single list containing the content of the first
+ of list of floats.
+
+ If False, a single list containing the content of the first
subtable (or the only one) is returned.
"""
+ pyoArgsAssert(self, "B", all)
if all:
return [obj.getTable() for obj in self._base_objs]
else:
@@ -1176,6 +1377,7 @@ class PyoTableObject(PyoObjectBase):
Exponent factor. Defaults to 10.
"""
+ pyoArgsAssert(self, "N", exp)
[obj.pow(exp) for obj in self._base_objs]
self.refreshView()
return self
@@ -1192,6 +1394,7 @@ class PyoTableObject(PyoObjectBase):
Gain factor for negative samples. Defaults to 1.
"""
+ pyoArgsAssert(self, "NN", gpos, gneg)
[obj.bipolarGain(gpos, gneg) for obj in self._base_objs]
self.refreshView()
return self
@@ -1206,6 +1409,7 @@ class PyoTableObject(PyoObjectBase):
Filter's cutoff, in Hertz. Defaults to 1000.
"""
+ pyoArgsAssert(self, "N", freq)
[obj.lowpass(freq) for obj in self._base_objs]
self.refreshView()
return self
@@ -1220,6 +1424,7 @@ class PyoTableObject(PyoObjectBase):
Fade in duration, in seconds. Defaults to 0.1.
"""
+ pyoArgsAssert(self, "N", dur)
[obj.fadein(dur) for obj in self._base_objs]
self.refreshView()
return self
@@ -1234,14 +1439,90 @@ class PyoTableObject(PyoObjectBase):
Fade out duration, in seconds. Defaults to 0.1.
"""
+ pyoArgsAssert(self, "N", dur)
[obj.fadeout(dur) for obj in self._base_objs]
self.refreshView()
return self
+ def add(self, x):
+ """
+ Performs addition on the table values.
+
+ Adds the argument to each table values, position by position
+ if the argument is a list or another PyoTableObject.
+
+ :Args:
+
+ x : float, list or PyoTableObject
+ value(s) to add.
+
+ """
+ pyoArgsAssert(self, "T", x)
+ if type(x) == ListType:
+ if type(x[0]) == ListType:
+ [obj.add(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ else:
+ [obj.add(x) for obj in self._base_objs]
+ else:
+ x, lmax = convertArgsToLists(x)
+ [obj.add(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ self.refreshView()
+ return self
+
+ def sub(self, x):
+ """
+ Performs substraction on the table values.
+
+ Substracts the argument to each table values, position by position
+ if the argument is a list or another PyoTableObject.
+
+ :Args:
+
+ x : float, list or PyoTableObject
+ value(s) to substract.
+
+ """
+ pyoArgsAssert(self, "T", x)
+ if type(x) == ListType:
+ if type(x[0]) == ListType:
+ [obj.sub(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ else:
+ [obj.sub(x) for obj in self._base_objs]
+ else:
+ x, lmax = convertArgsToLists(x)
+ [obj.sub(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ self.refreshView()
+ return self
+
+ def mul(self, x):
+ """
+ Performs multiplication on the table values.
+
+ Multiply each table values by the argument, position by position
+ if the argument is a list or another PyoTableObject.
+
+ :Args:
+
+ x : float, list or PyoTableObject
+ value(s) to multiply.
+
+ """
+ pyoArgsAssert(self, "T", x)
+ if type(x) == ListType:
+ if type(x[0]) == ListType:
+ [obj.mul(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ else:
+ [obj.mul(x) for obj in self._base_objs]
+ else:
+ x, lmax = convertArgsToLists(x)
+ [obj.mul(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ self.refreshView()
+ return self
+
def copy(self):
"""
Returns a deep copy of the object.
-
+
"""
args = [getattr(self, att) for att in self.__dir__()]
if self.__class__.__name__ == "SndTable":
@@ -1262,57 +1543,64 @@ class PyoTableObject(PyoObjectBase):
def view(self, title="Table waveform", wxnoserver=False):
"""
Opens a window showing the contents of the table.
-
+
:Args:
-
+
title : string, optional
- Window title. Defaults to "Table waveform".
+ Window title. Defaults to "Table waveform".
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
-
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
+
"""
- samples = self._base_objs[0].getViewTable()
+ pyoArgsAssert(self, "SB", title, wxnoserver)
+ samples = self._base_objs[0].getViewTable((500,200))
createViewTableWindow(samples, title, wxnoserver, self.__class__.__name__, self)
def _setViewFrame(self, frame):
self.viewFrame = frame
-
+
+ def _setGraphFrame(self, frame):
+ self.graphFrame = frame
+
def refreshView(self):
"""
Updates the graphical display of the table, if applicable.
"""
if self.viewFrame != None:
- samples = self._base_objs[0].getViewTable()
+ size = self.viewFrame.wavePanel.GetSize()
+ samples = self._base_objs[0].getViewTable((size[0], size[1]))
self.viewFrame.update(samples)
+ if self.graphFrame != None:
+ self.graphFrame.update(self.getTable())
@property
def size(self):
- """int. Table size in samples."""
+ """int. Table size in samples."""
return self._size
@size.setter
def size(self, x): self.setSize(x)
-
+
######################################################################
### PyoMatrixObject -> base class for pyo matrix objects
######################################################################
class PyoMatrixObject(PyoObjectBase):
"""
- Base class for all pyo matrix objects.
-
- A matrix object is a 2 dimensions buffer memory to store
- precomputed samples.
-
+ Base class for all pyo matrix objects.
+
+ A matrix object is a 2 dimensions buffer memory to store
+ precomputed samples.
+
The user should never instantiate an object of this class.
-
+
:Parent: :py:class:`PyoObjectBase`
"""
-
+
_STREAM_TYPE = 'matrix'
def __init__(self):
@@ -1322,16 +1610,17 @@ class PyoMatrixObject(PyoObjectBase):
def write(self, path):
"""
Writes the content of the matrix into a text file.
-
+
This function can be used to store the matrix data as a
list of list of floats into a text file.
:Args:
-
+
path : string
Full path of the generated file.
-
+
"""
+ pyoArgsAssert(self, "S", path)
f = open(path, "w")
f.write(str([obj.getData() for obj in self._base_objs]))
f.close()
@@ -1340,23 +1629,24 @@ class PyoMatrixObject(PyoObjectBase):
"""
Reads the content of a text file and replaces the matrix data
with the values in the file.
-
- Format is a list of lists of floats. For example, A two
+
+ Format is a list of lists of floats. For example, A two
matrixstreams object must be given a content like this:
-
+
[ [ [0.0 ,1.0, 0.5, ... ], [1.0, 0.99, 0.98, 0.97, ... ] ],
[ [0.0, 1.0, 0.5, ... ], [1.0, 0.99, 0.98, 0.97, ... ] ] ]
-
- Each object's matrixstream will be resized according to the
+
+ Each object's matrixstream will be resized according to the
length of the lists, but the number of matrixstreams must be
the same.
-
+
:Args:
-
+
path : string
Full path of the file to read.
-
+
"""
+ pyoArgsAssert(self, "S", path)
f = open(path, "r")
f_list = eval(f.read())
f_len = len(f_list)
@@ -1366,7 +1656,7 @@ class PyoMatrixObject(PyoObjectBase):
def getSize(self):
"""
Returns matrix size in samples. Size is a tuple (x, y).
-
+
"""
return self._size
@@ -1388,9 +1678,9 @@ class PyoMatrixObject(PyoObjectBase):
def boost(self, min=-1.0, max=1.0, boost=0.01):
"""
Boost the constrast of values in the matrix.
-
+
:Args:
-
+
min : float, optional
Minimum value. Defaults to -1.0.
max : float, optional
@@ -1399,44 +1689,47 @@ class PyoMatrixObject(PyoObjectBase):
Amount of boost applied on each value. Defaults to 0.01.
"""
+ pyoArgsAssert(self, "NNN", min, max, boost)
[obj.boost(min, max, boost) for obj in self._base_objs]
def put(self, value, x=0, y=0):
"""
Puts a value at specified position in the matrix.
-
+
If the object has more than 1 matrixstream, the default is to
- record the value in each matrix. User can call obj[x].put()
+ record the value in each matrix. User can call obj[x].put()
to record in a specific matrix.
-
+
:Args:
-
+
value : float
Value, as floating-point, to record in the matrix.
x : int, optional
X position where to record value. Defaults to 0.
y : int, optional
Y position where to record value. Defaults to 0.
-
+
"""
+ pyoArgsAssert(self, "NII", value, x, y)
[obj.put(value, x, y) for obj in self._base_objs]
def get(self, x, y):
"""
Returns the value, as float, at specified position in the matrix.
-
+
If the object has more than 1 matrixstream, the default is to
- return a list with the value of each matrixstream. User can call
+ return a list with the value of each matrixstream. User can call
obj[x].get() to get the value of a specific matrix.
-
+
:Args:
-
+
x : int, optional
X position where to get value. Defaults to 0.
y : int, optional
Y position where to get value. Defaults to 0.
-
+
"""
+ pyoArgsAssert(self, "II", x, y)
values = [obj.get(x, y) for obj in self._base_objs]
if len(values) == 1: return values[0]
else: return values
@@ -1444,25 +1737,26 @@ class PyoMatrixObject(PyoObjectBase):
def view(self, title="Matrix viewer", wxnoserver=False):
"""
Opens a window showing the contents of the matrix.
-
+
:Args:
-
+
title : string, optional
- Window title. Defaults to "Matrix viewer".
+ Window title. Defaults to "Matrix viewer".
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
-
- """
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
+
+ """
+ pyoArgsAssert(self, "SB", title, wxnoserver)
samples = self._base_objs[0].getViewData()
createViewMatrixWindow(samples, self.getSize(), title, wxnoserver, self)
def _setViewFrame(self, frame):
self.viewFrame = frame
-
+
def refreshView(self):
"""
Updates the graphical display of the matrix, if applicable.
@@ -1478,13 +1772,13 @@ class PyoMatrixObject(PyoObjectBase):
class PyoPVObject(PyoObjectBase):
"""
Base class for objects working with phase vocoder's magnitude and frequency streams.
-
+
The user should never instantiate an object of this class.
:Parent: :py:class:`PyoObjectBase`
"""
-
+
_STREAM_TYPE = 'pvoc'
def __init__(self):
@@ -1502,11 +1796,12 @@ class PyoPVObject(PyoObjectBase):
all : boolean, optional
If True, the object returns a list with the state of all
streams managed by the object.
-
- If False, it return a boolean corresponding to the state
+
+ If False, it return a boolean corresponding to the state
of the first stream.
"""
+ pyoArgsAssert(self, "B", all)
if all:
return [obj._getStream().isPlaying() for obj in self._base_objs]
else:
@@ -1514,21 +1809,22 @@ class PyoPVObject(PyoObjectBase):
def play(self, dur=0, delay=0):
"""
- Start processing without sending samples to output.
+ Start processing without sending samples to output.
This method is called automatically at the object creation.
This method returns `self`, allowing it to be applied at the object
creation.
-
+
:Args:
-
+
dur : float, optional
Duration, in seconds, of the object's activation. The default is 0
and means infinite duration.
delay : float, optional
Delay, in seconds, before the object's activation. Defaults to 0.
-
+
"""
+ pyoArgsAssert(self, "nn", dur, delay)
dur, delay, lmax = convertArgsToLists(dur, delay)
if hasattr(self, "_trig_objs"):
self._trig_objs.play(dur, delay)
@@ -1536,14 +1832,14 @@ class PyoPVObject(PyoObjectBase):
[obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
[obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
return self
-
+
def stop(self):
"""
Stop processing.
This method returns `self`, allowing it to be applied at the object
creation.
-
+
"""
if hasattr(self, "_trig_objs"):
self._trig_objs.stop()
@@ -1570,6 +1866,7 @@ class PyoPVObject(PyoObjectBase):
Time, in seconds, to reach the new value.
"""
+ pyoArgsAssert(self, "Snn", attr, value, port)
self._target_dict[attr] = value
init = getattr(self, attr)
if self._signal_dict.has_key(attr):
@@ -1584,30 +1881,30 @@ class PyoPVObject(PyoObjectBase):
if isinstance(getattr(self, attr), VarPort):
setattr(self, attr, self._target_dict[attr])
self._signal_dict[attr].stop()
-
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
"""
- Opens a sliders window to control the parameters of the object.
- Only parameters that can be set to a PyoObject are allowed
+ Opens a sliders window to control the parameters of the object.
+ Only parameters that can be set to a PyoObject are allowed
to be mapped on a slider.
- If a list of values are given to a parameter, a multisliders
+ If a list of values are given to a parameter, a multisliders
will be used to control each stream independently.
:Args:
map_list : list of SLMap objects, optional
- Users defined set of parameters scaling. There is default
+ Users defined set of parameters scaling. There is default
scaling for each object that accept `ctrl` method.
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
if map_list == None:
@@ -1616,7 +1913,7 @@ class PyoPVObject(PyoObjectBase):
print("There is no controls for %s object." % self.__class__.__name__)
return
createCtrlWindow(self, map_list, title, wxnoserver)
-
+
######################################################################
### Internal classes -> Used by pyo
######################################################################
@@ -1624,7 +1921,7 @@ class Mix(PyoObject):
"""
Mix audio streams to arbitrary number of streams.
- Mix the object's audio streams as `input` argument into `voices`
+ Mix the object's audio streams as `input` argument into `voices`
streams.
:Parent: :py:class:`PyoObject`
@@ -1634,8 +1931,8 @@ class Mix(PyoObject):
input : PyoObject or list of PyoObjects
Input signal(s) to mix the streams.
voices : int, optional
- Number of streams of the Mix object. If more than 1, input
- object's streams are alternated and added into Mix object's
+ Number of streams of the Mix object. If more than 1, input
+ object's streams are alternated and added into Mix object's
streams. Defaults to 1.
.. note::
@@ -1659,24 +1956,25 @@ class Mix(PyoObject):
"""
def __init__(self, input, voices=1, mul=1, add=0):
+ pyoArgsAssert(self, "oIOO", input, voices, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
mul, add, lmax = convertArgsToLists(mul, add)
if type(input) == ListType:
input_objs = []
input_objs = [obj for pyoObj in input for obj in pyoObj.getBaseObjects()]
- else:
+ else:
input_objs = input.getBaseObjects()
input_len = len(input_objs)
- if voices < 1:
+ if voices < 1:
voices = 1
num = 1
- elif voices > input_len and voices > lmax:
+ elif voices > input_len and voices > lmax:
num = voices
elif lmax > input_len:
- num = lmax
+ num = lmax
else:
- num = input_len
+ num = input_len
sub_lists = []
for i in range(voices):
sub_lists.append([])
@@ -1696,7 +1994,7 @@ class Dummy(PyoObject):
:Args:
objs_list : list of audio Stream objects
- List of Stream objects return by the PyoObject hidden method
+ List of Stream objects return by the PyoObject hidden method
getBaseObjects().
.. note::
@@ -1705,9 +2003,9 @@ class Dummy(PyoObject):
the PyoObject on which the operation is performed. A dummy object
is created, which is just a copy of the audio Streams of the object,
and the operation is applied on the Dummy, leaving the original
- object unchanged. This lets the user performs multiple different
+ object unchanged. This lets the user performs multiple different
arithmetic operations on an object without conficts. Here, `b` is
- a Dummy object with `a` as its input with a `mul` attribute of 0.5.
+ a Dummy object with `a` as its input with a `mul` attribute of 0.5.
attribute:
>>> a = Sine()
@@ -1724,7 +2022,7 @@ class Dummy(PyoObject):
>>> a = SineLoop(p, feedback=.05, mul=.1).mix(2).out()
>>> b = SineLoop(p*1.253, feedback=.05, mul=.06).mix(2).out()
>>> c = SineLoop(p*1.497, feedback=.05, mul=.03).mix(2).out()
-
+
"""
def __init__(self, objs_list):
PyoObject.__init__(self)
@@ -1736,7 +2034,7 @@ class Dummy(PyoObject):
else:
tmp_list.append(x)
self._base_objs = tmp_list
-
+
class InputFader(PyoObject):
"""
Audio streams crossfader.
@@ -1748,9 +2046,9 @@ class InputFader(PyoObject):
.. note::
- The setInput method, available to object with `input` attribute,
- uses an InputFader object internally to perform crossfade between
- the old and the new audio input assigned to the object.
+ The setInput method, available to object with `input` attribute,
+ uses an InputFader object internally to perform crossfade between
+ the old and the new audio input assigned to the object.
>>> s = Server().boot()
>>> s.start()
@@ -1762,6 +2060,7 @@ class InputFader(PyoObject):
"""
def __init__(self, input):
+ pyoArgsAssert(self, "o", input)
PyoObject.__init__(self)
self._input = input
input, lmax = convertArgsToLists(input)
@@ -1770,7 +2069,7 @@ class InputFader(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1779,13 +2078,14 @@ class InputFader(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i), fadetime) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Input signal."""
+ """PyoObject. Input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1793,14 +2093,14 @@ class InputFader(PyoObject):
class Sig(PyoObject):
"""
Convert numeric value to PyoObject signal.
-
+
:Parent: :py:class:`PyoObject`
:Args:
value : float or PyoObject
Numerical value to convert.
-
+
>>> import random
>>> s = Server().boot()
>>> s.start()
@@ -1814,6 +2114,7 @@ class Sig(PyoObject):
"""
def __init__(self, value, mul=1, add=0):
+ pyoArgsAssert(self, "OOO", value, mul, add)
PyoObject.__init__(self, mul, add)
self._value = value
value, mul ,add, lmax = convertArgsToLists(value, mul, add)
@@ -1829,6 +2130,7 @@ class Sig(PyoObject):
Numerical value to convert.
"""
+ pyoArgsAssert(self, "O", x)
self._value = x
x, lmax = convertArgsToLists(x)
[obj.setValue(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1836,10 +2138,10 @@ class Sig(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0, 1, "lin", "value", self._value)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def value(self):
- """float or PyoObject. Numerical value to convert."""
+ """float or PyoObject. Numerical value to convert."""
return self._value
@value.setter
def value(self, x): self.setValue(x)
@@ -1863,7 +2165,7 @@ class VarPort(PyoObject):
init : float, optional
Initial value of the internal memory. Defaults to 0.
function : Python callable, optional
- If provided, it will be called at the end of the line.
+ If provided, it will be called at the end of the line.
Defaults to None.
arg : any Python object, optional
Optional argument sent to the function called at the end of the line.
@@ -1878,18 +2180,19 @@ class VarPort(PyoObject):
>>> def callback(arg):
... print "end of line"
... print arg
- ...
+ ...
>>> fr = VarPort(value=500, time=2, init=250, function=callback, arg="YEP!")
>>> a = SineLoop(freq=[fr,fr*1.01], feedback=0.05, mul=.2).out()
"""
def __init__(self, value, time=0.025, init=0.0, function=None, arg=None, mul=1, add=0):
+ pyoArgsAssert(self, "nnnczOO", value, time, init, function, arg, mul, add)
PyoObject.__init__(self, mul, add)
self._value = value
self._time = time
- self._function = function
+ self._function = getWeakMethodRef(function)
value, time, init, function, arg, mul ,add, lmax = convertArgsToLists(value, time, init, function, arg, mul, add)
- self._base_objs = [VarPort_base(wrap(value,i), wrap(time,i), wrap(init,i), wrap(function,i), wrap(arg,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+ self._base_objs = [VarPort_base(wrap(value,i), wrap(time,i), wrap(init,i), WeakMethod(wrap(function,i)), wrap(arg,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setValue(self, x):
"""
@@ -1901,6 +2204,7 @@ class VarPort(PyoObject):
Numerical value to convert.
"""
+ pyoArgsAssert(self, "n", x)
self._value = x
x, lmax = convertArgsToLists(x)
[obj.setValue(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1915,6 +2219,7 @@ class VarPort(PyoObject):
New ramp time.
"""
+ pyoArgsAssert(self, "n", x)
self._time = x
x, lmax = convertArgsToLists(x)
[obj.setTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1922,33 +2227,34 @@ class VarPort(PyoObject):
def setFunction(self, x):
"""
Replace the `function` attribute.
-
+
:Args:
x : Python function
new `function` attribute.
-
+
"""
- self._function = x
+ pyoArgsAssert(self, "c", x)
+ self._function = getWeakMethodRef(x)
x, lmax = convertArgsToLists(x)
- [obj.setFunction(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ [obj.setFunction(WeakMethod(wrap(x,i))) for i, obj in enumerate(self._base_objs)]
@property
def value(self):
- """float. Numerical value to convert."""
+ """float. Numerical value to convert."""
return self._value
@value.setter
def value(self, x): self.setValue(x)
@property
def time(self):
- """float. Ramp time."""
+ """float. Ramp time."""
return self._time
@time.setter
def time(self, x): self.setTime(x)
@property
- def function(self):
+ def function(self):
"""Python callable. Function to be called."""
return self._function
@function.setter
@@ -1976,6 +2282,7 @@ class Pow(PyoObject):
"""
def __init__(self, base=10, exponent=1, mul=1, add=0):
+ pyoArgsAssert(self, "OOOO", base, exponent, mul, add)
PyoObject.__init__(self, mul, add)
self._base = base
self._exponent = exponent
@@ -1992,6 +2299,7 @@ class Pow(PyoObject):
new `base` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._base = x
x, lmax = convertArgsToLists(x)
[obj.setBase(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2006,29 +2314,30 @@ class Pow(PyoObject):
new `exponent` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._exponent = x
x, lmax = convertArgsToLists(x)
[obj.setExponent(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def base(self):
- """float or PyoObject. Base composant."""
+ """float or PyoObject. Base composant."""
return self._base
@base.setter
def base(self, x): self.setBase(x)
@property
def exponent(self):
- """float or PyoObject. Exponent composant."""
+ """float or PyoObject. Exponent composant."""
return self._exponent
@exponent.setter
def exponent(self, x): self.setExponent(x)
-
+
class Wrap(PyoObject):
"""
Wraps-around the signal that exceeds the `min` and `max` thresholds.
- This object is useful for table indexing, phase shifting or for
+ This object is useful for table indexing, phase shifting or for
clipping and modeling an audio signal.
:Parent: :py:class:`PyoObject`
@@ -2060,6 +2369,7 @@ class Wrap(PyoObject):
"""
def __init__(self, input, min=0.0, max=1.0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, min, max, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._min = min
@@ -2080,6 +2390,7 @@ class Wrap(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2093,6 +2404,7 @@ class Wrap(PyoObject):
New `min` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2107,6 +2419,7 @@ class Wrap(PyoObject):
New `max` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2119,21 +2432,21 @@ class Wrap(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def min(self):
- """float or PyoObject. Minimum possible value."""
+ """float or PyoObject. Minimum possible value."""
return self._min
@min.setter
def min(self, x): self.setMin(x)
@property
def max(self):
- """float or PyoObject. Maximum possible value."""
+ """float or PyoObject. Maximum possible value."""
return self._max
@max.setter
def max(self, x): self.setMax(x)
@@ -2168,6 +2481,7 @@ class Compare(PyoObject):
"""
def __init__(self, input, comp, mode="<", mul=1, add=0):
+ pyoArgsAssert(self, "oOsOO", input, comp, mode, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._comp = comp
@@ -2183,7 +2497,7 @@ class Compare(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -2192,56 +2506,59 @@ class Compare(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setComp(self, x):
"""
Replace the `comp` attribute.
-
+
:Args:
- x : PyoObject
+ x : float or PyoObject
New comparison signal.
"""
+ pyoArgsAssert(self, "O", x)
self._comp = x
x, lmax = convertArgsToLists(x)
[obj.setComp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setMode(self, x):
"""
- Replace the `mode` attribute.
-
+ Replace the `mode` attribute.
+
Allowed operator are "<", "<=", ">", ">=", "==", "!=".
-
+
:Args:
x : string
New `mode` attribute.
"""
+ pyoArgsAssert(self, "s", x)
self._mode = x
x, lmax = convertArgsToLists(x)
[obj.setMode(self.comp_dict[wrap(x,i)]) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Input signal."""
+ """PyoObject. Input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def comp(self):
- """PyoObject. Comparison signal."""
+ """PyoObject. Comparison signal."""
return self._comp
@comp.setter
def comp(self, x): self.setComp(x)
@property
def mode(self):
- """string. Comparison operator."""
+ """string. Comparison operator."""
return self._mode
@mode.setter
- def mode(self, x): self.setMode(x)
+ def mode(self, x): self.setMode(x)
\ No newline at end of file
diff --git a/pyolib/_maps.py b/pyolib/_maps.py
index 7005918..9687aa7 100644
--- a/pyolib/_maps.py
+++ b/pyolib/_maps.py
@@ -1,22 +1,22 @@
# -*- coding: utf-8 -*-
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from math import pow, log10
@@ -51,11 +51,11 @@ class Map:
def get(self, x):
"""
Takes `x` between 0 and 1 and returns scaled value.
-
+
"""
if x < 0: x = 0.0
- elif x > 1: x = 1.0
-
+ elif x > 1: x = 1.0
+
if self._scale == 'log':
return pow(10, x * log10(self._max/self._min) + log10(self._min))
else:
@@ -63,11 +63,11 @@ class Map:
def set(self, x):
"""
- Takes `x` in the real range and returns value unscaled
+ Takes `x` in the real range and returns value unscaled
(between 0 and 1).
-
+
"""
-
+
if self._scale == 'log':
return log10(x/self._min) / log10(self._max/self._min)
else:
@@ -76,7 +76,7 @@ class Map:
def setMin(self, x):
"""
Replace the `min` attribute.
-
+
:Args:
x : float
@@ -84,11 +84,11 @@ class Map:
"""
self._min = x
-
+
def setMax(self, x):
"""
Replace the `max` attribute.
-
+
:Args:
x : float
@@ -100,7 +100,7 @@ class Map:
def setScale(self, x):
"""
Replace the `scale` attribute.
-
+
:Args:
x : string
@@ -110,32 +110,32 @@ class Map:
self._scale = x
@property
- def min(self):
+ def min(self):
"""int or float. Lowest value of the range."""
return self._min
@min.setter
- def min(self, x):
- self.setMin(x)
+ def min(self, x):
+ self.setMin(x)
@property
- def max(self):
+ def max(self):
"""int or float. Highest value of the range."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
@property
- def scale(self):
+ def scale(self):
"""string. Method used to scale the input value."""
return self._scale
@scale.setter
- def scale(self, x):
+ def scale(self, x):
self.setScale(x)
class SLMap(Map):
"""
Base Map class used to manage control sliders.
- Derived from Map class, a few parameters are added for sliders
+ Derived from Map class, a few parameters are added for sliders
initialization.
:Parent: :py:class:`Map`
@@ -147,7 +147,7 @@ class SLMap(Map):
max : int or float
Highest value of the range.
scale : string {'lin', 'log'}
- Method used to scale the input value on the specified range.
+ Method used to scale the input value on the specified range.
name : string
Name of the attributes the slider is affected to.
init : int or float
@@ -156,12 +156,12 @@ class SLMap(Map):
res : string {'int', 'float'}, optional
Sets the resolution of the slider. Defaults to 'float'.
ramp : float, optional
- Ramp time, in seconds, used to smooth the signal sent from slider
+ Ramp time, in seconds, used to smooth the signal sent from slider
to object's attribute. Defaults to 0.025.
dataOnly : boolean, optional
- Set this argument to True if the parameter does not accept audio
- signal as control but discreet values. If True, label will be
- marked with a star symbol (*). Defaults to False.
+ Set this argument to True if the parameter does not accept audio
+ signal as control but discreet values. If True, label will be
+ marked with a star symbol (*). Defaults to False.
>>> s = Server().boot()
>>> s.start()
@@ -176,23 +176,23 @@ class SLMap(Map):
self._name, self._init, self._res, self._ramp, self._dataOnly = name, init, res, ramp, dataOnly
@property
- def name(self):
+ def name(self):
"""string. Name of the parameter to control."""
return self._name
@property
- def init(self):
+ def init(self):
"""float. Initial value of the slider."""
return self._init
@property
- def res(self):
+ def res(self):
"""string. Slider resolution {int or float}."""
return self._res
@property
- def ramp(self):
+ def ramp(self):
"""float. Ramp time in seconds."""
return self._ramp
@property
- def dataOnly(self):
+ def dataOnly(self):
"""boolean. True if argument does not accept audio stream."""
return self._dataOnly
@@ -210,7 +210,7 @@ class SLMapFreq(SLMap):
.. note::
- SLMapFreq values are:
+ SLMapFreq values are:
- min = 20.0
- max = 20000.0
@@ -264,7 +264,7 @@ class SLMapPhase(SLMap):
.. note::
- SLMapPhase values are:
+ SLMapPhase values are:
- min = 0.0
- max = 1.0
@@ -291,7 +291,7 @@ class SLMapPan(SLMap):
.. note::
- SLMapPhase values are:
+ SLMapPhase values are:
- min = 0.0
- max = 1.0
@@ -318,7 +318,7 @@ class SLMapQ(SLMap):
.. note::
- SLMapQ values are:
+ SLMapQ values are:
- min = 0.1
- max = 100.0
@@ -345,7 +345,7 @@ class SLMapDur(SLMap):
.. note::
- SLMapDur values are:
+ SLMapDur values are:
- min = 0.
- max = 60.0
@@ -356,4 +356,4 @@ class SLMapDur(SLMap):
"""
def __init__(self, init=1.):
- SLMap.__init__(self, 0., 60., 'lin', 'dur', init, 'float', 0.025)
+ SLMap.__init__(self, 0., 60., 'lin', 'dur', init, 'float', 0.025)
\ No newline at end of file
diff --git a/pyolib/_tkwidgets.py b/pyolib/_tkwidgets.py
index 8057194..f4b0f1c 100644
--- a/pyolib/_tkwidgets.py
+++ b/pyolib/_tkwidgets.py
@@ -1,20 +1,21 @@
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
-This file is part of pyo.
+This file is part of pyo, a python module to help digital signal
+processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from types import ListType, FloatType, IntType
import math, sys, os
@@ -24,7 +25,7 @@ try:
from PIL import Image, ImageDraw, ImageTk
except:
pass
-
+
# constants for platform displays with Tk
if sys.platform == 'linux2':
Y_OFFSET = 0
@@ -40,7 +41,7 @@ else:
### Multisliders
######################################################################
class MultiSlider(Frame):
- def __init__(self, master, init, key, command):
+ def __init__(self, master, init, key, command):
Frame.__init__(self, master, bd=0, relief=FLAT)
self._values = init
self._nchnls = len(init)
@@ -48,13 +49,13 @@ class MultiSlider(Frame):
self._command = command
self._lines = []
self._height = 16
- self.canvas = Canvas(self, height=self._height*self._nchnls+1,
+ self.canvas = Canvas(self, height=self._height*self._nchnls+1,
width=225, relief=FLAT, bd=0, bg="#BCBCAA")
w = self.canvas.winfo_width()
for i in range(self._nchnls):
x = int(self._values[i] * w)
y = self._height * i + Y_OFFSET
- self._lines.append(self.canvas.create_rectangle(0, y, x,
+ self._lines.append(self.canvas.create_rectangle(0, y, x,
y+self._height-1, width=0, fill="#121212"))
self.canvas.bind("<Button-1>", self.clicked)
self.canvas.bind("<Motion>", self.move)
@@ -69,10 +70,10 @@ class MultiSlider(Frame):
y = self._height * i + Y_OFFSET
x = self._values[i] * w
self.canvas.coords(self._lines[i], 0, y, x, y+self._height-1)
-
+
def clicked(self, event):
self.update(event)
-
+
def move(self, event):
if event.state == 0x0100:
slide = (event.y - Y_OFFSET) / self._height
@@ -87,7 +88,7 @@ class MultiSlider(Frame):
y = self._height * slide + Y_OFFSET
self.canvas.coords(self._lines[slide], 0, y, event.x, y+self._height-1)
self._command(self._key, self._values)
-
+
######################################################################
### Control window for PyoObject
######################################################################
@@ -117,7 +118,7 @@ class PyoObjectControl(Frame):
# filters PyoObjects
if type(init) not in [ListType, FloatType, IntType]:
self._excluded.append(key)
- else:
+ else:
self._maps[key] = m
# label (param name)
label = Label(self, height=1, width=10, highlightthickness=0, text=key)
@@ -125,13 +126,13 @@ class PyoObjectControl(Frame):
# create and pack slider
if type(init) != ListType:
self._sliders.append(Scale(self, command=Command(self.setval, key),
- orient=HORIZONTAL, relief=GROOVE, from_=0., to=1., showvalue=False,
+ orient=HORIZONTAL, relief=GROOVE, from_=0., to=1., showvalue=False,
resolution=.0001, bd=1, length=225, troughcolor="#BCBCAA", width=12))
self._sliders[-1].set(m.set(init))
disp_height = 1
else:
- self._sliders.append(MultiSlider(self, [m.set(x) for x in init], key, self.setval))
- disp_height = len(init)
+ self._sliders.append(MultiSlider(self, [m.set(x) for x in init], key, self.setval))
+ disp_height = len(init)
self._sliders[-1].grid(row=i, column=1, sticky=E+W)
# display of numeric values
textvar = StringVar(self)
@@ -142,7 +143,7 @@ class PyoObjectControl(Frame):
self._displays[key].set("%.4f" % init)
else:
self._displays[key].set("\n".join(["%.4f" % i for i in init]))
- # set obj attribute to PyoObject SigTo
+ # set obj attribute to PyoObject SigTo
self._sigs[key] = SigTo(init, .025, init)
refStream = self._obj.getBaseObjects()[0]._getStream()
server = self._obj.getBaseObjects()[0].getServer()
@@ -150,10 +151,10 @@ class PyoObjectControl(Frame):
curStream = self._sigs[key].getBaseObjects()[k]._getStream()
server.changeStreamPosition(refStream, curStream)
setattr(self._obj, key, self._sigs[key])
- # padding
+ # padding
top = self.winfo_toplevel()
top.rowconfigure(0, weight=1)
- top.columnconfigure(0, weight=1)
+ top.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=1)
self.grid(ipadx=5, ipady=5, sticky=E+W)
@@ -168,10 +169,10 @@ class PyoObjectControl(Frame):
if type(x) != ListType:
value = self._maps[key].get(float(x))
self._displays[key].set("%.4f" % value)
- else:
- value = [self._maps[key].get(float(y)) for y in x]
+ else:
+ value = [self._maps[key].get(float(y)) for y in x]
self._displays[key].set("\n".join(["%.4f" % i for i in value]))
-
+
self._values[key] = value
setattr(self._sigs[key], "value", value)
@@ -191,10 +192,10 @@ class ViewTable_withPIL(Frame):
draw.line(samples, fill=0, width=1)
self.img = ImageTk.PhotoImage(im)
self.canvas.create_image(self.width/2,self.height/2,image=self.img)
- self.canvas.create_line(0, self.half_height+2, self.width, self.half_height+2, fill='grey', dash=(4,2))
+ self.canvas.create_line(0, self.half_height+2, self.width, self.half_height+2, fill='grey', dash=(4,2))
self.canvas.grid()
self.grid(ipadx=10, ipady=10)
-
+
class ViewTable_withoutPIL(Frame):
def __init__(self, master=None, samples=None):
Frame.__init__(self, master, bd=1, relief=GROOVE)
@@ -202,7 +203,7 @@ class ViewTable_withoutPIL(Frame):
self.height = 200
self.half_height = self.height / 2
self.canvas = Canvas(self, height=self.height, width=self.width, relief=SUNKEN, bd=1, bg="#EFEFEF")
- self.canvas.create_line(0, self.half_height+Y_OFFSET, self.width, self.half_height+Y_OFFSET, fill='grey', dash=(4,2))
+ self.canvas.create_line(0, self.half_height+Y_OFFSET, self.width, self.half_height+Y_OFFSET, fill='grey', dash=(4,2))
self.canvas.create_line(*samples)
self.canvas.grid()
self.grid(ipadx=10, ipady=10)
@@ -247,7 +248,7 @@ class ViewMatrix_withoutPIL(Frame):
### Server Object User Interface (Tk)
######################################################################
class ServerGUI(Frame):
- def __init__(self, master=None, nchnls=2, startf=None, stopf=None, recstartf=None,
+ def __init__(self, master=None, nchnls=2, startf=None, stopf=None, recstartf=None,
recstopf=None, ampf=None, started=0, locals=None, shutdown=None, meter=True, timer=True, amp=1.):
Frame.__init__(self, master, padx=10, pady=10, bd=2, relief=GROOVE)
self.shutdown = shutdown
@@ -273,7 +274,7 @@ class ServerGUI(Frame):
self.createWidgets()
if started == 1:
self.start(True)
-
+
def createWidgets(self):
row = 0
@@ -290,14 +291,14 @@ class ServerGUI(Frame):
self.quitButton = Button(self, text='Quit', command=self.on_quit)
self.quitButton.grid(ipadx=5, row=row, column=2)
row += 1
-
+
self.ampScale = Scale(self, command=self.setAmp, digits=4, label='Amplitude (dB)',
- orient=HORIZONTAL, relief=GROOVE, from_=-60.0, to=18.0,
+ orient=HORIZONTAL, relief=GROOVE, from_=-60.0, to=18.0,
resolution=.01, bd=1, length=250, troughcolor="#BCBCAA", width=10)
self.ampScale.set(20.0 * math.log10(self.amp))
self.ampScale.grid(ipadx=5, ipady=5, row=row, column=0, columnspan=3)
row += 1
-
+
if self.meter:
self.vumeter = Canvas(self, height=5*self.nchnls+1, width=250, relief=FLAT, bd=0, bg="#323232")
self.green = []
@@ -330,8 +331,8 @@ class ServerGUI(Frame):
self.text.bind("<Return>", self.getText)
self.text.bind("<Up>", self.getPrev)
self.text.bind("<Down>", self.getNext)
-
-
+
+
def on_quit(self):
self.shutdown()
self.quit()
@@ -346,16 +347,16 @@ class ServerGUI(Frame):
def setTime(self, *args):
self.timer_strvar.set(" %02d : %02d : %02d : %03d" % (args[0], args[1], args[2], args[3]))
-
+
def getNext(self, event):
self.text.delete("1.0", END)
self._histo_count += 1
if self._histo_count >= len(self._history):
self._histo_count = len(self._history)
- else:
+ else:
self.text.insert("1.0", self._history[self._histo_count])
return "break"
-
+
def getText(self, event):
source = self.text.get("1.0", END)
self.text.delete("1.0", END)
@@ -363,7 +364,7 @@ class ServerGUI(Frame):
self._history.append(source)
self._histo_count = len(self._history)
return "break"
-
+
def start(self, justSet=False):
if self._started == False:
if not justSet:
@@ -403,7 +404,7 @@ class ServerGUI(Frame):
self.vumeter.coords(self.green[i], 0, y, self.B1, y)
self.vumeter.coords(self.yellow[i], self.B1, y, amp, y)
self.vumeter.coords(self.red[i], self.B2, y, self.B2, y)
- else:
+ else:
self.vumeter.coords(self.green[i], 0, y, self.B1, y)
self.vumeter.coords(self.yellow[i], self.B1, y, self.B2, y)
- self.vumeter.coords(self.red[i], self.B2, y, amp, y)
+ self.vumeter.coords(self.red[i], self.B2, y, amp, y)
\ No newline at end of file
diff --git a/pyolib/_widgets.py b/pyolib/_widgets.py
index 1eb1db9..912a041 100644
--- a/pyolib/_widgets.py
+++ b/pyolib/_widgets.py
@@ -1,22 +1,22 @@
# -*- coding: utf-8 -*-
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public Licensehack for OSX display
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from types import ListType, FloatType, IntType
import math, sys, os, random
@@ -28,28 +28,39 @@ except:
WITH_PIL = False
try:
- import wxversion
- if (wxversion.checkInstalled("2.8")):
- wxversion.ensureMinimal("2.8")
+ try:
+ import wxversion
+ if (wxversion.checkInstalled("2.8")):
+ wxversion.ensureMinimal("2.8")
+ except:
+ pass
import wx
from _wxwidgets import *
PYO_USE_WX = True
except:
PYO_USE_WX = False
+PYO_USE_TK = False
if not PYO_USE_WX:
try:
from Tkinter import *
from _tkwidgets import *
+ PYO_USE_TK = True
+ print """
+WxPython is not found for the current python version.
+Pyo will use a minimal GUI toolkit written with Tkinter.
+This toolkit has limited functionnalities and is no more
+maintained or updated. If you want to use all of pyo's
+GUI features, you should install WxPython, available here:
+http://www.wxpython.org/
+"""
except:
- if sys.platform == "linux2":
- response = raw_input("""python-tk package is missing! It is needed to use pyo graphical interfaces.
-Do you want to install it? (yes/no): """)
- if response == 'yes':
- os.system('sudo apt-get install python-tk')
- else:
- print "Tkinter is missing! It is needed to use pyo graphical interfaces. Please install it!"
- sys.exit()
+ PYO_USE_TK = False
+ print """
+Neither WxPython nor Tkinter are found for the current python version.
+Pyo's GUI features are disabled. For a complete GUI toolkit, you should
+consider installing WxPython, available here: http://www.wxpython.org/
+"""
X, Y, CURRENT_X, MAX_X, NEXT_Y = 800, 700, 30, 30, 30
WINDOWS = []
@@ -60,8 +71,11 @@ TABLEWINDOWS = []
SNDTABLEWINDOWS = []
MATRIXWINDOWS = []
SPECTRUMWINDOWS = []
+SCOPEWINDOWS = []
+WX_APP = False
def createRootWindow():
+ global WX_APP
if not PYO_USE_WX:
if len(WINDOWS) == 0:
root = Tk()
@@ -69,9 +83,10 @@ def createRootWindow():
return None
else:
return None
- else:
- if wx.GetApp() == None:
- win = wx.App(False)
+ else:
+ if not WX_APP:
+ win = wx.App(False)
+ WX_APP = True
return win
else:
return None
@@ -82,10 +97,10 @@ def tkCloseWindow(win):
def tkCloseWindowFromKeyboard(event):
win = event.widget
- if not isinstance(win, ServerGUI):
+ if not isinstance(win, ServerGUI):
win.destroy()
if win in WINDOWS: WINDOWS.remove(win)
-
+
def tkCreateToplevelWindow():
win = Toplevel()
WINDOWS.append(win)
@@ -116,7 +131,7 @@ def wxShowWindow(f, title, root):
f.Show()
if root != None:
root.MainLoop()
-
+
def wxCreateDelayedCtrlWindows():
for win in CTRLWINDOWS:
f = PyoObjectControl(None, win[0], win[1])
@@ -134,6 +149,7 @@ def wxCreateDelayedGraphWindows():
def wxCreateDelayedDataGraphWindows():
for win in DATAGRAPHWINDOWS:
f = DataTableGrapher(None, win[0], win[1])
+ win[0]._setGraphFrame(f)
if win[2] == None: title = win[0].__class__.__name__
else: title = win[2]
wxDisplayWindow(f, title)
@@ -142,8 +158,7 @@ def wxCreateDelayedTableWindows():
global CURRENT_X, MAX_X, NEXT_Y
for win in TABLEWINDOWS:
object = win[3]
- if WITH_PIL: f = ViewTable_withPIL(None, win[0], win[1], object)
- else: f = ViewTable_withoutPIL(None, win[0], win[1], object)
+ f = ViewTable(None, win[0], win[1], object)
if object != None:
object._setViewFrame(f)
wxDisplayWindow(f, win[2])
@@ -173,7 +188,16 @@ def wxCreateDelayedSpectrumWindows():
if win[0] != None:
win[0]._setViewFrame(f)
wxDisplayWindow(f, title)
-
+
+def wxCreateDelayedScopeWindows():
+ for win in SCOPEWINDOWS:
+ f = ScopeDisplay(None, win[0])
+ if win[1] == None: title = win[0].__class__.__name__
+ else: title = win[1]
+ if win[0] != None:
+ win[0]._setViewFrame(f)
+ wxDisplayWindow(f, title)
+
def createCtrlWindow(obj, map_list, title, wxnoserver=False):
if not PYO_USE_WX:
createRootWindow()
@@ -183,7 +207,7 @@ def createCtrlWindow(obj, map_list, title, wxnoserver=False):
if title == None: title = obj.__class__.__name__
win.title(title)
else:
- if wxnoserver or wx.GetApp() != None:
+ if wxnoserver or WX_APP:
root = createRootWindow()
f = PyoObjectControl(None, obj, map_list)
if title == None: title = obj.__class__.__name__
@@ -195,26 +219,27 @@ def createGraphWindow(obj, mode, xlen, yrange, title, wxnoserver=False):
if not PYO_USE_WX:
print "WxPython must be installed to use the 'graph()' method."
else:
- if wxnoserver or wx.GetApp() != None:
+ if wxnoserver or WX_APP:
root = createRootWindow()
f = TableGrapher(None, obj, mode, xlen, yrange)
if title == None: title = obj.__class__.__name__
wxShowWindow(f, title, root)
else:
- GRAPHWINDOWS.append([obj, mode, xlen, yrange, title])
+ GRAPHWINDOWS.append([obj, mode, xlen, yrange, title])
def createDataGraphWindow(obj, yrange, title, wxnoserver=False):
if not PYO_USE_WX:
print "WxPython must be installed to use the 'graph()' method."
else:
- if wxnoserver or wx.GetApp() != None:
+ if wxnoserver or WX_APP:
root = createRootWindow()
f = DataTableGrapher(None, obj, yrange)
if title == None: title = obj.__class__.__name__
wxShowWindow(f, title, root)
+ obj._setGraphFrame(f)
else:
- DATAGRAPHWINDOWS.append([obj, yrange, title])
-
+ DATAGRAPHWINDOWS.append([obj, yrange, title])
+
def createViewTableWindow(samples, title="Table waveform", wxnoserver=False, tableclass=None, object=None):
if not PYO_USE_WX:
createRootWindow()
@@ -224,15 +249,14 @@ def createViewTableWindow(samples, title="Table waveform", wxnoserver=False, tab
win.resizable(False, False)
win.title(title)
else:
- if wxnoserver or wx.GetApp() != None:
+ if wxnoserver or WX_APP:
root = createRootWindow()
- if WITH_PIL: f = ViewTable_withPIL(None, samples, tableclass, object)
- else: f = ViewTable_withoutPIL(None, samples, tableclass, object)
+ f = ViewTable(None, samples, tableclass, object)
wxShowWindow(f, title, root)
if object != None:
object._setViewFrame(f)
else:
- TABLEWINDOWS.append([samples, tableclass, title, object])
+ TABLEWINDOWS.append([samples, tableclass, title, object])
def createSndViewTableWindow(obj, title="Table waveform", wxnoserver=False, tableclass=None, mouse_callback=None):
if not PYO_USE_WX:
@@ -243,7 +267,7 @@ def createSndViewTableWindow(obj, title="Table waveform", wxnoserver=False, tabl
win.resizable(False, False)
win.title(title)
else:
- if wxnoserver or wx.GetApp() != None:
+ if wxnoserver or WX_APP:
root = createRootWindow()
f = SndViewTable(None, obj, tableclass, mouse_callback)
if title == None: title = obj.__class__.__name__
@@ -251,19 +275,19 @@ def createSndViewTableWindow(obj, title="Table waveform", wxnoserver=False, tabl
obj._setViewFrame(f)
else:
SNDTABLEWINDOWS.append([obj, tableclass, title, mouse_callback])
-
+
def createViewMatrixWindow(samples, size, title="Matrix viewer", wxnoserver=False, object=None):
- if not WITH_PIL: print """The Python Imaging Library is not installed.
+ if not WITH_PIL: print """The Python Imaging Library is not installed.
It helps a lot to speed up matrix drawing!"""
if not PYO_USE_WX:
- createRootWindow()
+ createRootWindow()
win = tkCreateToplevelWindow()
if WITH_PIL: f = ViewMatrix_withPIL(win, samples, size)
else: f = ViewMatrix_withoutPIL(win, samples, size)
win.resizable(False, False)
win.title(title)
else:
- if wxnoserver or wx.GetApp() != None:
+ if wxnoserver or WX_APP:
root = createRootWindow()
if WITH_PIL: f = ViewMatrix_withPIL(None, samples, size, object)
else: f = ViewMatrix_withoutPIL(None, samples, size, object)
@@ -271,13 +295,13 @@ It helps a lot to speed up matrix drawing!"""
if object != None:
object._setViewFrame(f)
else:
- MATRIXWINDOWS.append([samples,size,title, object])
+ MATRIXWINDOWS.append([samples,size,title, object])
def createSpectrumWindow(object, title, wxnoserver=False):
if not PYO_USE_WX:
print "WxPython must be installed to use the Spectrum display."
else:
- if wxnoserver or wx.GetApp() != None:
+ if wxnoserver or WX_APP:
root = createRootWindow()
f = SpectrumDisplay(None, object)
if title == None: title = object.__class__.__name__
@@ -285,9 +309,23 @@ def createSpectrumWindow(object, title, wxnoserver=False):
if object != None:
object._setViewFrame(f)
else:
- SPECTRUMWINDOWS.append([object, title])
-
-def createServerGUI(nchnls, start, stop, recstart, recstop, setAmp, started, locals, shutdown, meter, timer, amp):
+ SPECTRUMWINDOWS.append([object, title])
+
+def createScopeWindow(object, title, wxnoserver=False):
+ if not PYO_USE_WX:
+ print "WxPython must be installed to use the Scope display."
+ else:
+ if wxnoserver or WX_APP:
+ root = createRootWindow()
+ f = ScopeDisplay(None, object)
+ if title == None: title = object.__class__.__name__
+ wxShowWindow(f, title, root)
+ if object != None:
+ object._setViewFrame(f)
+ else:
+ SCOPEWINDOWS.append([object, title])
+
+def createServerGUI(nchnls, start, stop, recstart, recstop, setAmp, started, locals, shutdown, meter, timer, amp, exit):
global X, Y, MAX_X, NEXT_Y
if not PYO_USE_WX:
createRootWindow()
@@ -297,7 +335,7 @@ def createServerGUI(nchnls, start, stop, recstart, recstop, setAmp, started, loc
f.focus_set()
else:
win = createRootWindow()
- f = ServerGUI(None, nchnls, start, stop, recstart, recstop, setAmp, started, locals, shutdown, meter, timer, amp)
+ f = ServerGUI(None, nchnls, start, stop, recstart, recstop, setAmp, started, locals, shutdown, meter, timer, amp, exit)
f.SetTitle("pyo server")
f.SetPosition((30, 30))
f.Show()
@@ -313,6 +351,6 @@ def createServerGUI(nchnls, start, stop, recstart, recstop, setAmp, started, loc
wx.CallAfter(wxCreateDelayedMatrixWindows)
wx.CallAfter(wxCreateDelayedCtrlWindows)
wx.CallAfter(wxCreateDelayedSpectrumWindows)
+ wx.CallAfter(wxCreateDelayedScopeWindows)
wx.CallAfter(f.Raise)
return f, win
-
\ No newline at end of file
diff --git a/pyolib/_wxwidgets.py b/pyolib/_wxwidgets.py
index 5651072..137eb23 100644
--- a/pyolib/_wxwidgets.py
+++ b/pyolib/_wxwidgets.py
@@ -1,119 +1,31 @@
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
-This file is part of pyo.
+This file is part of pyo, a python module to help digital signal
+processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
-
import wx, os, sys, math, time, random
from types import ListType, FloatType, IntType
-from wx.lib.embeddedimage import PyEmbeddedImage
try:
from PIL import Image, ImageDraw, ImageTk
except:
pass
-
-BACKGROUND_COLOUR = "#EBEBEB"
-vu_metre = PyEmbeddedImage(
- "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAFCAIAAACPTDSjAAAAAXNSR0IArs4c6QAAACF0RVh0"
- "U29mdHdhcmUAR3JhcGhpY0NvbnZlcnRlciAoSW50ZWwpd4f6GQAAAMJJREFUeJxiYBgFo4BG"
- "wHWbO1bEKc6JS4pXiddxtTNWKTFLMYspVlilpFyk9WsNsUopR6toF+lglVJP0wDKYpUCmiYX"
- "II9VyqTTFOgSrFI28+0E9YSwSgE9hcfXLNwsZEgBDcQVVkBnAB2DKxi7qg13LHHERIEeMvWF"
- "ulilYoIUM2JUsUoVp2vGKyjsdbDHRH0G+u4SElilZpkYW4uIYJXaaGNtwMDwHxsaTVijCWs0"
- "YY0mrNGENZqwRhMWAAAA//8DAHGDnlocOW36AAAAAElFTkSuQmCC")
-
-vu_metre_dark = PyEmbeddedImage(
- "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAFCAYAAAAALqP0AAAAAXNSR0IArs4c6QAAAAlwSFlz"
- "AAALEgAACxIB0t1+/AAADst0RVh0Q29tbWVudABwclZXIGNodW5rbGVuIDMwMiBpZ25vcmVk"
- "Og1BU0NJSTogeJzt0U1WwjAuwPHpLohUKS5tibG3yM4ude11ei4u4OtdvIE4ky76cOVz+/9l"
- "LuYjaS68f759yKu8nMys6zTPc8rm9Exq1C6nLicuS7UwcS5ljHGMMopEyyQu0S5FJGUuLi4u"
- "Li5Xdb2pd/cuu1pj899y+6ixrTV+lufcktvvLl7p1ut+8C7r9efnUut2Kb/PhOshu5vK9I5l"
- "LtrQtiG0wdmmq3IuT7ffLp1vOt9rLnvfaVjprfSNdo69jvy+P5fPjZbDfunZuSYNSEVYOiA3"
- "ODlDRUREMTRENTZDMjMwMTBDMEYxRTkwNzg4NTQyOTBENkQ4OUIxQjdDOENFMDM3NUVENzU3"
- "QTE5MEZFMEVCNURCQzgxMzg5MzAyRkE3MEU1NzNGQkZGNjUxQUU2MjM2OTE3QkM3RkJFN0RD"
- "OEFCQkM5Q0NDQUNFQjM0Q0Y3M0NBRTZGNDRDNkFENDE4QTcxODI3MTE0QkI1MzA3MTFDNjU4"
- "QzcxOEMzMjhBNDRDQjI0MUFEMTE1NDUyNDY1MDAwMDAwMDAwMA1ta0JGIGNodW5rbGVuIDcy"
- "IGlnbm9yZWQ6DUFTQ0lJOiD63sr+Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u"
- "Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4NSEVYOiBGQURFQ0FGRTAwMDAw"
- "MDA0MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDANbWtUUyBjaHVua2xlbiA4ODg2IGlnbm9yZWQ6DUFT"
- "Q0lJOiB4nO1dWXPbSJLG9ozbLd/unph92C5FbGzsU2twLnwuRVHSWC6HpHy9OHjB1rSPLllW"
- "t5fB/76ZWVUgUCiAOChSni6rW0WiUC6+zPwqqyouOnnWup51ensuM2ve+8cpJKHfLobj+cvj"
- "vXBmzl+x5MVRO5zZtjk/PC6EM2/e2++Hs4Y97/XPLyC7dS4uhPRv3j0+vp61uvBrb3fweWZs"
- "LiNjbLwxusbU+C6fLoz386PTLsi5LjkuIccyfobcLuN3uOP9vNc+LmGVuw1IRVg6IDc4OUNF"
- "RDVENTk3M0RCNDg5MkM2RjY4Q0RCMkRERkVFOUU5ODdERDgxNzQ1NkM2Q0VDNTM2QjcwMTM3"
- "QzE0NDU1MUQyNTgwNzg3QTQ3Q0JEMzg3OEMxRDZCNDhGMUU1OTU2Qjc5N0MxRkZCRTk5NTk1"
- "NTIwNTAyODgwMzgyODUyOUUyRUFCNUI0NUEyNTAwN0JFQ0NGQzJBQUIyQTBCM0E3OUQ2QkE5"
- "RTc1N0E3QjE3MzM2QkRFRkJDNzI5MjRBMURGMDg4NkUzDW1rQlMgY2h1bmtsZW4gMTkwIGln"
- "bm9yZWQ6DUFTQ0lJOiB4nF1Oyy6CMC7szd/wLi6DwFHKq2GrLmoub2hswlWTJmaz/27Lw4Nz"
- "mcnMzmZknS4sLj6iTy5wjS71M11FpjEu91QupdGPLmryVqPj9jLag7S0Lb2AoC6DcOgupnV5"
- "t/GlLkdwlG9kLi5sYC72ZC+2ZT7Jdi452C7PXZPXzshBLi6y/C7dqZg2zfS38NzZ2Z5HlS7D"
- "g1R7LjH2SC77UYlsxEgnOopp0YOOnqvexY9w1WEuJ0SZOi6kLl+6Ll+mDUhFWDogNzg5QzVE"
- "NEVDQjBFODIzMDEwRUNDRERGRjAxMzAwODNDMDUxQ0FBQjYxQUIwNjZBMDQ2RjY4NkNDMjU1"
- "OTMyNjY2QjNGRjZFQ0JDMzgzNzM5OUM5Q0NDRTY2NjQ5RDFBMkMxQTNFQTI0RjFENzA4RDFF"
- "RjUzMzVENDVBNjMxMDhGNzU0MDlBNUQxOEYwMjZBRjI1NkEzRTNGNjMyREE4M0I0QjQyREJE"
- "ODBBMDA3ODM3MEU4MERBNjc1NzlCN0YxQTUwMTQ3NzANbWtCVCBjaHVua2xlbiAxMTQ1IGln"
- "bm9yZWQ6DUFTQ0lJOiD6zsr+Ln84xS4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u"
- "Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4ueJztmolt6zAuLl1ILkkhKSSN"
- "pJAukkZSiD82+GM8bEjZsWT4mi4udJDisctDIrXfK6WUUkoppZRSSv3X9/f3/uvra0qF34Oy"
- "LpdM+y7pX1NVn91uN+Xz83P/+vr6c37LdacuVdYtVb5/eXk52GPr9K+t9P/7+/svSnWseg1I"
- "RVg6IEZBQ0VDQUZFMDA3RjM4QzUwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwNzg5Q0VE"
- "OUE4OTZERUIzMDEwMDU1RDQ4MUE0OTIxMjkyNDhEQTQ5MDE0OTI0NjUyDW1rQlQgY2h1bmts"
- "ZW4gMzM5IGlnbm9yZWQ6DUFTQ0lJOiD6zsr+Ln9ViS4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u"
- "Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4ueJzt1uFpg2Au"
- "hlEucS4ucS4ucS4ucS4usbyBLremIf+KLueBQ5tP++tNbM5TkiRJkiRJkiRJkiRJkiRJkiRJ"
- "LtFxLue+70/nOcu1d/e/uk/3b13Xcy7Hc5qmx8/sLv0s99S9dS7LsjxexzAuf76HdO+yY5V9"
- "s2F2rc37PQ1IRVg6IEZBQ0VDQUZFMDA3RjU1ODkwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwNzg5Q0VERDZFMTY5ODM2MDE0ODY1MTA3NzExMTA3NzExMDE3NzExMDA3NzExMTA3DW1r"
- "QlQgY2h1bmtsZW4gMzc5OSBpZ25vcmVkOg1BU0NJSTog+s7K/i5/n3guLi4uLi4uLi4uLi4u"
- "Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u"
- "Lnic7Z2NkS4pLoUuiC5xIC7EiTguLuJELshe6eo+17tnSUDPz/5Yr2pqZ7tpLi4u0IOel5fB"
- "YDAuLi6DwWAwLi4ug8HgP/z69evl58+ff3ziOveq5+JzpawuZfj3wf9R6fmK/jN8//795dOn"
- "T3984jr3Mnz58uXfzy6+ffsNSEVYOiBGQUNFQ0FGRTAwN0Y5Rjc4MDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDc4OUNFRDlEOEQ5MTFDMjkwQzg1MUQ4ODEzNzEyMDBFQzQ4OTM4MTAw"
- "N0UyNDQxQw1ta0JUIGNodW5rbGVuIDI3NDEgaWdub3JlZDoNQVNDSUk6IPrOyv4uf69+Li4u"
- "Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u"
- "Li4uLi4uLi4uLi54nO2djZHbOC5GU0guSSEpJI2kkC6SRlJIbpCbd/PuLkjJWa8u23gzntXq"
- "h6QuLqIukPr5cy6GYS6GYS6GYS6GYXhJvn///tvvx48u/y67J1WOe5fh2fnw4cNvv69fv/6q"
- "99q+Z/1XOaouw/uBvM/i9vCW/rm7to7Vbyd/DUhFWDogRkFDRUNBRkUwMDdGQUY3RTAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA3ODlDRUQ5RDhEOTFEQjM4MEM0NjUzNDgxQTQ5MjEy"
- "OTI0OERBNDkwMTQ5MjQ2NTINbWtCVCBjaHVua2xlbiAxMDc3NSBpZ25vcmVkOg1BU0NJSTog"
- "+s7K/i5/1PAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u"
- "Li4uLi4uLi4uLi4uLi4uLi4uLi4uLnic7X0ruOwo1vaSSCwuicQikUgkLi6JxCIjkVgkLi6J"
- "jYyMjI0smX9R+5zunp7p+dT/1Ihac+k+VXvXLrAu77suVObnfTaeLtqzkS3G10Zgh6PDLnBd"
- "xS5rLt+FfsPzYi7ggS4uLrYuLtCeJMF33ZPZsYTB8c18c/zxQ28NSEVYOiBGQUNFQ0FGRTAw"
- "N0ZENEYwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
- "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDc4OUNFRDdEMkJCOEVDMjhENkY2"
- "OTI0ODJDMTI4OUM0MjI5MTQ4MjQxNjE5ODlDNIWzHPoAAAAhdEVYdFNvZnR3YXJlAEdyYXBo"
- "aWNDb252ZXJ0ZXIgKEludGVsKXeH+hkAAADWSURBVHic7JO7CsJAEEVH95UHpFBEhBUTJIpB"
- "I0GFFDYRBNHSxr/Zn/B/R9c+Ewvt5sLtDswwwwHgcDh06muAVE3Y62TipA+HM80MxgLKoyGZ"
- "kRWw3GmSsbmEealIJi2Ue3Mk4+dMUukopqj1Z2+KqRqDybBPMv4239xRqt8wflbXP/zOfveu"
- "n9VVgLcmam1mJew3hmQWmXJFrklmu9K41to94hjbegoCzKQEirmEIVohSOYeRWiVhud0hm1l"
- "QVgQFoQFYUFYEBaEBWFB/iLICwAA//8DAHqeTXUOgGpTAAAAAElFTkSuQmCC")
+BACKGROUND_COLOUR = "#EBEBEB"
def interpFloat(t, v1, v2):
"interpolator for a single value; interprets t in [0-1] between v1 and v2"
@@ -141,7 +53,7 @@ def powOfTwo(x):
def powOfTwoToInt(x):
return POWOFTWO[x]
-
+
def GetRoundBitmap( w, h, r ):
maskColor = wx.Color(0,0,0)
shownColor = wx.Color(5,5,5)
@@ -160,19 +72,29 @@ def GetRoundShape( w, h, r ):
return wx.RegionFromBitmap( GetRoundBitmap(w,h,r) )
class ControlSlider(wx.Panel):
- def __init__(self, parent, minvalue, maxvalue, init=None, pos=(0,0), size=(200,16), log=False, outFunction=None, integer=False, powoftwo=False, backColour=None):
- wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, pos=pos, size=size, style=wx.NO_BORDER | wx.WANTS_CHARS | wx.EXPAND)
+ def __init__(self, parent, minvalue, maxvalue, init=None, pos=(0,0), size=(200,16), log=False,
+ outFunction=None, integer=False, powoftwo=False, backColour=None, orient=wx.HORIZONTAL):
+ if size == (200,16) and orient == wx.VERTICAL:
+ size = (40, 200)
+ wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, pos=pos, size=size,
+ style=wx.NO_BORDER | wx.WANTS_CHARS | wx.EXPAND)
self.parent = parent
- if backColour:
+ if backColour:
self.backgroundColour = backColour
- else:
+ else:
self.backgroundColour = BACKGROUND_COLOUR
- self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
+ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.SetBackgroundColour(self.backgroundColour)
- self.SetMinSize(self.GetSize())
- self.knobSize = 40
- self.knobHalfSize = 20
- self.sliderHeight = size[1] - 5
+ self.orient = orient
+ # self.SetMinSize(self.GetSize())
+ if self.orient == wx.VERTICAL:
+ self.knobSize = 17
+ self.knobHalfSize = 8
+ self.sliderWidth = size[0] - 29
+ else:
+ self.knobSize = 40
+ self.knobHalfSize = 20
+ self.sliderHeight = size[1] - 5
self.outFunction = outFunction
self.integer = integer
self.log = log
@@ -187,10 +109,10 @@ class ControlSlider(wx.Panel):
self.propagate = True
self.midictl = None
self.new = ''
- if init != None:
+ if init != None:
self.SetValue(init)
self.init = init
- else:
+ else:
self.SetValue(minvalue)
self.init = minvalue
self.clampPos()
@@ -202,8 +124,11 @@ class ControlSlider(wx.Panel):
self.Bind(wx.EVT_SIZE, self.OnResize)
self.Bind(wx.EVT_KEY_DOWN, self.keyDown)
self.Bind(wx.EVT_KILL_FOCUS, self.LooseFocus)
- self.createSliderBitmap()
- self.createKnobBitmap()
+
+ if sys.platform == "win32":
+ self.dcref = wx.BufferedPaintDC
+ else:
+ self.dcref = wx.PaintDC
def setMidiCtl(self, x, propagate=True):
self.propagate = propagate
@@ -226,49 +151,18 @@ class ControlSlider(wx.Panel):
def Disable(self):
self._enable = False
self.Refresh()
-
+
def setSliderHeight(self, height):
self.sliderHeight = height
- self.createSliderBitmap()
- self.createKnobBitmap()
self.Refresh()
- def createSliderBitmap(self):
- w, h = self.GetSize()
- b = wx.EmptyBitmap(w,h)
- dc = wx.MemoryDC(b)
- dc.SetPen(wx.Pen(self.backgroundColour, width=1))
- dc.SetBrush(wx.Brush(self.backgroundColour))
- dc.DrawRectangle(0,0,w,h)
- dc.SetBrush(wx.Brush("#999999"))
- dc.SetPen(wx.Pen(self.backgroundColour, width=1))
- h2 = self.sliderHeight / 4
- dc.DrawRoundedRectangle(0,h2,w,self.sliderHeight,2)
- dc.SelectObject(wx.NullBitmap)
- b.SetMaskColour("#999999")
- self.sliderMask = b
-
- def createKnobBitmap(self):
- w, h = self.knobSize, self.GetSize()[1]
- b = wx.EmptyBitmap(w,h)
- dc = wx.MemoryDC(b)
- rec = wx.Rect(0, 0, w, h)
- dc.SetPen(wx.Pen(self.backgroundColour, width=1))
- dc.SetBrush(wx.Brush(self.backgroundColour))
- dc.DrawRectangleRect(rec)
- h2 = self.sliderHeight / 4
- rec = wx.Rect(0, h2, w, self.sliderHeight)
- dc.GradientFillLinear(rec, "#414753", "#99A7CC", wx.BOTTOM)
- dc.SetBrush(wx.Brush("#999999"))
- dc.DrawRoundedRectangle(0,0,w,h,2)
- dc.SelectObject(wx.NullBitmap)
- b.SetMaskColour("#999999")
- self.knobMask = b
+ def setSliderWidth(self, width):
+ self.sliderWidth = width
def getInit(self):
return self.init
- def SetRange(self, minvalue, maxvalue):
+ def SetRange(self, minvalue, maxvalue):
self.minvalue = minvalue
self.maxvalue = maxvalue
@@ -276,11 +170,15 @@ class ControlSlider(wx.Panel):
return [self.minvalue, self.maxvalue]
def scale(self):
- inter = tFromValue(self.pos, self.knobHalfSize, self.GetSize()[0]-self.knobHalfSize)
+ if self.orient == wx.VERTICAL:
+ h = self.GetSize()[1]
+ inter = tFromValue(h-self.pos, self.knobHalfSize, self.GetSize()[1]-self.knobHalfSize)
+ else:
+ inter = tFromValue(self.pos, self.knobHalfSize, self.GetSize()[0]-self.knobHalfSize)
if not self.integer:
return interpFloat(inter, self.minvalue, self.maxvalue)
elif self.powoftwo:
- return powOfTwo(int(interpFloat(inter, self.minvalue, self.maxvalue)))
+ return powOfTwo(int(interpFloat(inter, self.minvalue, self.maxvalue)))
else:
return int(interpFloat(inter, self.minvalue, self.maxvalue))
@@ -289,7 +187,7 @@ class ControlSlider(wx.Panel):
if self.HasCapture():
self.ReleaseMouse()
if self.powoftwo:
- value = powOfTwoToInt(value)
+ value = powOfTwoToInt(value)
value = clamp(value, self.minvalue, self.maxvalue)
if self.log:
t = toLog(value, self.minvalue, self.maxvalue)
@@ -300,7 +198,7 @@ class ControlSlider(wx.Panel):
if self.integer:
self.value = int(self.value)
if self.powoftwo:
- self.value = powOfTwo(self.value)
+ self.value = powOfTwo(self.value)
self.clampPos()
self.selected = False
self.Refresh()
@@ -348,7 +246,10 @@ class ControlSlider(wx.Panel):
return
if self._enable:
size = self.GetSize()
- self.pos = clamp(evt.GetPosition()[0], self.knobHalfSize, size[0]-self.knobHalfSize)
+ if self.orient == wx.VERTICAL:
+ self.pos = clamp(evt.GetPosition()[1], self.knobHalfSize, size[1]-self.knobHalfSize)
+ else:
+ self.pos = clamp(evt.GetPosition()[0], self.knobHalfSize, size[0]-self.knobHalfSize)
self.value = self.scale()
self.CaptureMouse()
self.selected = False
@@ -363,23 +264,29 @@ class ControlSlider(wx.Panel):
if self._enable:
w, h = self.GetSize()
pos = event.GetPosition()
- if wx.Rect(self.pos-self.knobHalfSize, 0, self.knobSize, h).Contains(pos):
- self.selected = True
+ if self.orient == wx.VERTICAL:
+ if wx.Rect(0, self.pos-self.knobHalfSize, w, self.knobSize).Contains(pos):
+ self.selected = True
+ else:
+ if wx.Rect(self.pos-self.knobHalfSize, 0, self.knobSize, h).Contains(pos):
+ self.selected = True
self.Refresh()
event.Skip()
-
+
def MouseMotion(self, evt):
if self._enable:
size = self.GetSize()
if self.HasCapture():
- self.pos = clamp(evt.GetPosition()[0], self.knobHalfSize, size[0]-self.knobHalfSize)
+ if self.orient == wx.VERTICAL:
+ self.pos = clamp(evt.GetPosition()[1], self.knobHalfSize, size[1]-self.knobHalfSize)
+ else:
+ self.pos = clamp(evt.GetPosition()[0], self.knobHalfSize, size[0]-self.knobHalfSize)
self.value = self.scale()
self.selected = False
self.Refresh()
def OnResize(self, evt):
- self.createSliderBitmap()
- self.clampPos()
+ self.clampPos()
self.Refresh()
def clampPos(self):
@@ -387,20 +294,23 @@ class ControlSlider(wx.Panel):
if self.powoftwo:
val = powOfTwoToInt(self.value)
else:
- val = self.value
- self.pos = tFromValue(val, self.minvalue, self.maxvalue) * (size[0] - self.knobSize) + self.knobHalfSize
- self.pos = clamp(self.pos, self.knobHalfSize, size[0]-self.knobHalfSize)
-
+ val = self.value
+ if self.orient == wx.VERTICAL:
+ self.pos = tFromValue(val, self.minvalue, self.maxvalue) * (size[1] - self.knobSize) + self.knobHalfSize
+ self.pos = clamp(size[1]-self.pos, self.knobHalfSize, size[1]-self.knobHalfSize)
+ else:
+ self.pos = tFromValue(val, self.minvalue, self.maxvalue) * (size[0] - self.knobSize) + self.knobHalfSize
+ self.pos = clamp(self.pos, self.knobHalfSize, size[0]-self.knobHalfSize)
+
def setBackgroundColour(self, colour):
self.backgroundColour = colour
self.SetBackgroundColour(self.backgroundColour)
- self.createSliderBitmap()
- self.createKnobBitmap()
self.Refresh()
def OnPaint(self, evt):
w,h = self.GetSize()
- dc = wx.AutoBufferedPaintDC(self)
+ dc = self.dcref(self)
+ gc = wx.GraphicsContext_Create(dc)
dc.SetBrush(wx.Brush(self.backgroundColour, wx.SOLID))
dc.Clear()
@@ -408,40 +318,57 @@ class ControlSlider(wx.Panel):
# Draw background
dc.SetPen(wx.Pen(self.backgroundColour, width=self.borderWidth, style=wx.SOLID))
dc.DrawRectangle(0, 0, w, h)
-
+
# Draw inner part
if self._enable: sliderColour = "#99A7CC"
else: sliderColour = "#BBBBBB"
- h2 = self.sliderHeight / 4
- rec = wx.Rect(0, h2, w, self.sliderHeight)
- dc.GradientFillLinear(rec, "#646986", sliderColour, wx.BOTTOM)
- dc.DrawBitmap(self.sliderMask, 0, 0, True)
+ if self.orient == wx.VERTICAL:
+ w2 = (w - self.sliderWidth) / 2
+ rec = wx.Rect(w2, 0, self.sliderWidth, h)
+ brush = gc.CreateLinearGradientBrush(w2, 0, w2+self.sliderWidth, 0, "#646986", sliderColour)
+ else:
+ h2 = self.sliderHeight / 4
+ rec = wx.Rect(0, h2, w, self.sliderHeight)
+ brush = gc.CreateLinearGradientBrush(0, h2, 0, h2+self.sliderHeight, "#646986", sliderColour)
+ gc.SetBrush(brush)
+ gc.DrawRoundedRectangle(rec[0], rec[1], rec[2], rec[3], 2)
if self.midictl != None:
if sys.platform in ['win32', 'linux2']:
dc.SetFont(wx.Font(6, wx.ROMAN, wx.NORMAL, wx.NORMAL))
- else:
+ else:
dc.SetFont(wx.Font(9, wx.ROMAN, wx.NORMAL, wx.NORMAL))
dc.SetTextForeground('#FFFFFF')
- dc.DrawLabel(str(self.midictl), wx.Rect(2,0,h,h), wx.ALIGN_CENTER)
- dc.DrawLabel(str(self.midictl), wx.Rect(w-h,0,h,h), wx.ALIGN_CENTER)
+ if self.orient == wx.VERTICAL:
+ dc.DrawLabel(str(self.midictl), wx.Rect(w2,2,self.sliderWidth,12), wx.ALIGN_CENTER)
+ dc.DrawLabel(str(self.midictl), wx.Rect(w2,h-12,self.sliderWidth,12), wx.ALIGN_CENTER)
+ else:
+ dc.DrawLabel(str(self.midictl), wx.Rect(2,0,h,h), wx.ALIGN_CENTER)
+ dc.DrawLabel(str(self.midictl), wx.Rect(w-h,0,h,h), wx.ALIGN_CENTER)
# Draw knob
if self._enable: knobColour = '#888888'
else: knobColour = "#DDDDDD"
- rec = wx.Rect(self.pos-self.knobHalfSize, 0, self.knobSize, h)
- dc.GradientFillLinear(rec, "#424864", knobColour, wx.RIGHT)
- dc.DrawBitmap(self.knobMask, rec[0], rec[1], True)
-
- if self.selected:
- rec2 = wx.Rect(self.pos-self.knobHalfSize, 0, self.knobSize, h)
- dc.SetBrush(wx.Brush('#333333', wx.SOLID))
- dc.SetPen(wx.Pen('#333333', width=self.borderWidth, style=wx.SOLID))
- dc.DrawRoundedRectangleRect(rec2, 3)
+ if self.orient == wx.VERTICAL:
+ rec = wx.Rect(0, self.pos-self.knobHalfSize, w, self.knobSize-1)
+ if self.selected:
+ brush = wx.Brush('#333333', wx.SOLID)
+ else:
+ brush = gc.CreateLinearGradientBrush(0, 0, w, 0, "#323854", knobColour)
+ gc.SetBrush(brush)
+ gc.DrawRoundedRectangle(rec[0], rec[1], rec[2], rec[3], 3)
+ else:
+ rec = wx.Rect(self.pos-self.knobHalfSize, 0, self.knobSize-1, h)
+ if self.selected:
+ brush = wx.Brush('#333333', wx.SOLID)
+ else:
+ brush = gc.CreateLinearGradientBrush(self.pos-self.knobHalfSize, 0, self.pos+self.knobHalfSize, 0, "#323854", knobColour)
+ gc.SetBrush(brush)
+ gc.DrawRoundedRectangle(rec[0], rec[1], rec[2], rec[3], 3)
if sys.platform in ['win32', 'linux2']:
dc.SetFont(wx.Font(7, wx.ROMAN, wx.NORMAL, wx.NORMAL))
- else:
+ else:
dc.SetFont(wx.Font(10, wx.ROMAN, wx.NORMAL, wx.NORMAL))
# Draw text
@@ -473,10 +400,10 @@ class ControlSlider(wx.Panel):
evt.Skip()
class MultiSlider(wx.Panel):
- def __init__(self, parent, init, key, command, slmap):
+ def __init__(self, parent, init, key, command, slmap):
wx.Panel.__init__(self, parent, size=(250,250))
self.backgroundColour = BACKGROUND_COLOUR
- self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
+ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.SetBackgroundColour(self.backgroundColour)
self.Bind(wx.EVT_SIZE, self.OnResize)
self.Bind(wx.EVT_PAINT, self.OnPaint)
@@ -492,16 +419,16 @@ class MultiSlider(wx.Panel):
self._height = 16
if sys.platform in ['win32', 'linux2']:
self._font = wx.Font(7, wx.ROMAN, wx.NORMAL, wx.NORMAL)
- else:
+ else:
self._font = wx.Font(10, wx.ROMAN, wx.NORMAL, wx.NORMAL)
-
+
self.SetSize((250, self._nchnls*16))
self.SetMinSize((250,self._nchnls*16))
def OnResize(self, event):
self.Layout()
self.Refresh()
-
+
def OnPaint(self, event):
w,h = self.GetSize()
dc = wx.AutoBufferedPaintDC(self)
@@ -524,7 +451,10 @@ class MultiSlider(wx.Panel):
slide = pos[1] / self._height
if 0 <= slide < self._nchnls:
self._values[slide] = pos[0] / float(w)
- self._labels = [self._slmap.get(x) for x in self._values]
+ if self._slmap._res == 'int':
+ self._labels = [int(self._slmap.get(x)) for x in self._values]
+ else:
+ self._labels = [self._slmap.get(x) for x in self._values]
self._command(self._key, self._labels)
self.CaptureMouse()
self.Refresh()
@@ -541,54 +471,112 @@ class MultiSlider(wx.Panel):
slide = pos[1] / self._height
if 0 <= slide < self._nchnls:
self._values[slide] = pos[0] / float(w)
- self._labels = [self._slmap.get(x) for x in self._values]
+ if self._slmap._res == 'int':
+ self._labels = [int(self._slmap.get(x)) for x in self._values]
+ else:
+ self._labels = [self._slmap.get(x) for x in self._values]
self._command(self._key, self._labels)
self.Refresh()
-
+
class VuMeter(wx.Panel):
- def __init__(self, parent, size=(200,11), numSliders=2):
+ def __init__(self, parent, size=(200,11), numSliders=2, orient=wx.HORIZONTAL):
+ if orient == wx.HORIZONTAL:
+ size = (size[0], numSliders * 5 + 1)
+ else:
+ size = (numSliders * 5 + 1, size[1])
wx.Panel.__init__(self, parent, -1, size=size)
self.parent = parent
+ self.orient = orient
self.SetBackgroundColour("#000000")
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.old_nchnls = numSliders
self.numSliders = numSliders
- self.SetMinSize((200,5*self.numSliders+1))
- self.SetSize((200, 5*self.numSliders+1))
- self.bitmap = vu_metre.GetBitmap()
- self.backBitmap = vu_metre_dark.GetBitmap()
self.amplitude = [0] * self.numSliders
+ self.createBitmaps()
self.Bind(wx.EVT_PAINT, self.OnPaint)
- self.Bind(wx.EVT_CLOSE, self.OnClose)
+ self.Bind(wx.EVT_SIZE, self.OnSize)
+ self.Bind(wx.EVT_CLOSE, self.OnClose)
+
+ def OnSize(self, evt):
+ self.createBitmaps()
+ wx.CallAfter(self.Refresh)
+
+ def createBitmaps(self):
+ w, h = self.GetSize()
+ b = wx.EmptyBitmap(w,h)
+ f = wx.EmptyBitmap(w,h)
+ dcb = wx.MemoryDC(b)
+ dcf = wx.MemoryDC(f)
+ dcb.SetPen(wx.Pen("#000000", width=1))
+ dcf.SetPen(wx.Pen("#000000", width=1))
+ if self.orient == wx.HORIZONTAL:
+ height = 6
+ steps = int(w / 10.0 + 0.5)
+ else:
+ width = 6
+ steps = int(h / 10.0 + 0.5)
+ bounds = int(steps / 6.0)
+ for i in range(steps):
+ if i == (steps - 1):
+ dcb.SetBrush(wx.Brush("#770000"))
+ dcf.SetBrush(wx.Brush("#FF0000"))
+ elif i >= (steps - bounds):
+ dcb.SetBrush(wx.Brush("#440000"))
+ dcf.SetBrush(wx.Brush("#CC0000"))
+ elif i >= (steps - (bounds*2)):
+ dcb.SetBrush(wx.Brush("#444400"))
+ dcf.SetBrush(wx.Brush("#CCCC00"))
+ else:
+ dcb.SetBrush(wx.Brush("#004400"))
+ dcf.SetBrush(wx.Brush("#00CC00"))
+ if self.orient == wx.HORIZONTAL:
+ dcb.DrawRectangle(i*10, 0, 11, height)
+ dcf.DrawRectangle(i*10, 0, 11, height)
+ else:
+ ii = steps - 1 - i
+ dcb.DrawRectangle(0, ii*10, width, 11)
+ dcf.DrawRectangle(0, ii*10, width, 11)
+ if self.orient == wx.HORIZONTAL:
+ dcb.DrawLine(w-1, 0, w-1, height)
+ dcf.DrawLine(w-1, 0, w-1, height)
+ else:
+ dcb.DrawLine(0, 0, width, 0)
+ dcf.DrawLine(0, 0, width, 0)
+ dcb.SelectObject(wx.NullBitmap)
+ dcf.SelectObject(wx.NullBitmap)
+ self.backBitmap = b
+ self.bitmap = f
def setNumSliders(self, numSliders):
+ w, h = self.GetSize()
oldChnls = self.old_nchnls
self.numSliders = numSliders
self.amplitude = [0] * self.numSliders
gap = (self.numSliders - oldChnls) * 5
parentSize = self.parent.GetSize()
- if sys.platform == 'linux2':
- self.SetSize((200, 5*self.numSliders+1))
- self.SetMinSize((200, 5*self.numSliders+1))
+ if self.orient == wx.HORIZONTAL:
+ self.SetSize((w, self.numSliders * 5 + 1))
+ self.SetMinSize((w, 5*self.numSliders+1))
self.parent.SetSize((parentSize[0], parentSize[1]+gap))
self.parent.SetMinSize((parentSize[0], parentSize[1]+gap))
else:
- self.SetSize((200, 5*self.numSliders+1))
- self.SetMinSize((200, 5*self.numSliders+1))
- self.parent.SetSize((parentSize[0], parentSize[1]+gap))
- self.parent.SetMinSize((parentSize[0], parentSize[1]+gap))
- self.Refresh()
- self.parent.Layout()
+ self.SetSize((self.numSliders * 5 + 1, h))
+ self.SetMinSize((5*self.numSliders+1, h))
+ self.parent.SetSize((parentSize[0]+gap, parentSize[1]))
+ self.parent.SetMinSize((parentSize[0]+gap, parentSize[1]))
+ wx.CallAfter(self.Refresh)
+ wx.CallAfter(self.parent.Layout)
+ wx.CallAfter(self.parent.Refresh)
def setRms(self, *args):
- if args[0] < 0:
+ if args[0] < 0:
return
if not args:
- self.amplitude = [0 for i in range(self.numSliders)]
+ self.amplitude = [0 for i in range(self.numSliders)]
else:
self.amplitude = args
- wx.CallAfter(self.Refresh)
+ wx.CallAfter(self.Refresh)
def OnPaint(self, event):
w,h = self.GetSize()
@@ -596,23 +584,38 @@ class VuMeter(wx.Panel):
dc.SetBrush(wx.Brush("#000000"))
dc.Clear()
dc.DrawRectangle(0,0,w,h)
- for i in range(self.numSliders):
- db = math.log10(self.amplitude[i]+0.00001) * 0.2 + 1.
- width = int(db*w)
- dc.DrawBitmap(self.backBitmap, 0, i*5)
- dc.SetClippingRegion(0, i*5, width, 5)
- dc.DrawBitmap(self.bitmap, 0, i*5)
- dc.DestroyClippingRegion()
+ if self.orient == wx.HORIZONTAL:
+ height = 6
+ for i in range(self.numSliders):
+ y = i * (height - 1)
+ db = math.log10(self.amplitude[i]+0.00001) * 0.2 + 1.
+ width = int(db*w)
+ dc.DrawBitmap(self.backBitmap, 0, y)
+ if width > 0:
+ dc.SetClippingRegion(0, y, width, height)
+ dc.DrawBitmap(self.bitmap, 0, y)
+ dc.DestroyClippingRegion()
+ else:
+ width = 6
+ for i in range(self.numSliders):
+ y = i * (width - 1)
+ db = math.log10(self.amplitude[i]+0.00001) * 0.2 + 1.
+ height = int(db*h)
+ dc.DrawBitmap(self.backBitmap, y, 0)
+ if height > 0:
+ dc.SetClippingRegion(y, h-height, width, height)
+ dc.DrawBitmap(self.bitmap, y, 0)
+ dc.DestroyClippingRegion()
event.Skip()
-
+
def OnClose(self, evt):
self.Destroy()
class RangeSlider(wx.Panel):
- def __init__(self, parent, minvalue, maxvalue, init=None, pos=(0,0), size=(200,15),
+ def __init__(self, parent, minvalue, maxvalue, init=None, pos=(0,0), size=(200,15),
valtype='int', log=False, function=None):
wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, pos=pos, size=size, style=wx.NO_BORDER)
- self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
+ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.SetBackgroundColour(BACKGROUND_COLOUR)
self.SetMinSize(self.GetSize())
self.sliderHeight = 15
@@ -632,10 +635,10 @@ class RangeSlider(wx.Panel):
if len(init) == 1:
self.SetValue([init[0],init[0]])
else:
- self.SetValue([init[0],init[1]])
- else:
+ self.SetValue([init[0],init[1]])
+ else:
self.SetValue([minvalue,maxvalue])
- else:
+ else:
self.SetValue([minvalue,maxvalue])
self.Bind(wx.EVT_LEFT_DOWN, self.MouseDown)
self.Bind(wx.EVT_RIGHT_DOWN, self.MouseRightDown)
@@ -666,7 +669,7 @@ class RangeSlider(wx.Panel):
self.handlecolor = wx.Colour(self.knobcolor[0]*0.35, self.knobcolor[1]*0.35, self.knobcolor[2]*0.35)
self.createSliderBitmap()
- def SetRange(self, minvalue, maxvalue):
+ def SetRange(self, minvalue, maxvalue):
self.minvalue = minvalue
self.maxvalue = maxvalue
@@ -688,7 +691,7 @@ class RangeSlider(wx.Panel):
self.handles = self.scale(self.handlePos)
self.CaptureMouse()
self.Refresh()
-
+
def MouseDown(self, evt):
size = self.GetSize()
xpos = evt.GetPosition()[0]
@@ -715,7 +718,7 @@ class RangeSlider(wx.Panel):
if self.action == 'drag':
off = xpos - self.lastpos
self.lastpos = xpos
- self.handlePos[0] = clamp(self.handlePos[0] + off, 1, size[0]-self.length)
+ self.handlePos[0] = clamp(self.handlePos[0] + off, 1, size[0]-self.length)
self.handlePos[1] = clamp(self.handlePos[1] + off, self.length, size[0]-1)
if self.action == 'left':
self.handlePos[0] = clamp(xpos, 1, self.handlePos[1]-20)
@@ -744,7 +747,7 @@ class RangeSlider(wx.Panel):
self.handlePos = tmp
class HRangeSlider(RangeSlider):
- def __init__(self, parent, minvalue, maxvalue, init=None, pos=(0,0), size=(200,15),
+ def __init__(self, parent, minvalue, maxvalue, init=None, pos=(0,0), size=(200,15),
valtype='int', log=False, function=None):
RangeSlider.__init__(self, parent, minvalue, maxvalue, init, pos, size, valtype, log, function)
self.SetMinSize((50, 15))
@@ -805,7 +808,7 @@ class HRangeSlider(RangeSlider):
if self.myType == IntType:
value = int(value)
tmp.append(value)
- self.handles = tmp
+ self.handles = tmp
self.OnResize(None)
def GetValue(self):
@@ -819,7 +822,7 @@ class HRangeSlider(RangeSlider):
if self.myType == IntType:
val = int(val)
tmp.append(val)
- tmp = [min(tmp), max(tmp)]
+ tmp = [min(tmp), max(tmp)]
return tmp
def OnPaint(self, evt):
@@ -831,14 +834,14 @@ class HRangeSlider(RangeSlider):
dc.Clear()
dc.SetPen(wx.Pen(BACKGROUND_COLOUR))
dc.DrawRectangle(0, 0, w, h)
-
+
#dc.DrawBitmap(self.backgroundBitmap, 0, 0)
# Draw handles
dc.SetPen(wx.Pen(self.handlecolor, width=1, style=wx.SOLID))
dc.SetBrush(wx.Brush(self.handlecolor))
-
- rec = wx.Rect(self.handlePos[0], 3, self.handlePos[1]-self.handlePos[0], h-7)
+
+ rec = wx.Rect(self.handlePos[0], 3, self.handlePos[1]-self.handlePos[0], h-7)
dc.DrawRoundedRectangleRect(rec, 4)
dc.SetPen(wx.Pen(self.fillcolor, width=1, style=wx.SOLID))
dc.SetBrush(wx.Brush(self.fillcolor))
@@ -865,7 +868,7 @@ class PyoObjectControl(wx.Frame):
def __init__(self, parent=None, obj=None, map_list=None):
wx.Frame.__init__(self, parent)
from controls import SigTo
- self.menubar = wx.MenuBar()
+ self.menubar = wx.MenuBar()
self.fileMenu = wx.Menu()
self.fileMenu.Append(-1, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
self.fileMenu.Bind(wx.EVT_MENU, self._destroy)
@@ -880,18 +883,18 @@ class PyoObjectControl(wx.Frame):
self._displays = {}
self._maps = {}
self._sigs = {}
-
+
panel = wx.Panel(self)
panel.SetBackgroundColour(BACKGROUND_COLOUR)
mainBox = wx.BoxSizer(wx.VERTICAL)
self.box = wx.FlexGridSizer(10,2,5,5)
-
+
for i, m in enumerate(self._map_list):
key, init, mini, maxi, scl, res, dataOnly = m.name, m.init, m.min, m.max, m.scale, m.res, m.dataOnly
# filters PyoObjects
if type(init) not in [ListType, FloatType, IntType]:
self._excluded.append(key)
- else:
+ else:
self._maps[key] = m
# label (param name)
if dataOnly:
@@ -906,10 +909,10 @@ class PyoObjectControl(wx.Frame):
else: res = False
self._sliders.append(ControlSlider(panel, mini, maxi, init, log=scl, size=(300,16),
outFunction=Command(self.setval, key), integer=res))
- self.box.AddMany([(label, 0, wx.LEFT, 5), (self._sliders[-1], 1, wx.EXPAND | wx.LEFT, 5)])
+ self.box.AddMany([(label, 0, wx.LEFT, 5), (self._sliders[-1], 1, wx.EXPAND | wx.LEFT, 5)])
else:
self._sliders.append(MultiSlider(panel, init, key, self.setval, m))
- self.box.AddMany([(label, 0, wx.LEFT, 5), (self._sliders[-1], 1, wx.EXPAND | wx.LEFT, 5)])
+ self.box.AddMany([(label, 0, wx.LEFT, 5), (self._sliders[-1], 1, wx.EXPAND | wx.LEFT, 5)])
# set obj attribute to PyoObject SigTo
if not dataOnly:
self._values[key] = init
@@ -920,21 +923,21 @@ class PyoObjectControl(wx.Frame):
curStream = self._sigs[key].getBaseObjects()[k]._getStream()
server.changeStreamPosition(refStream, curStream)
setattr(self._obj, key, self._sigs[key])
- self.box.AddGrowableCol(1, 1)
+ self.box.AddGrowableCol(1, 1)
mainBox.Add(self.box, 1, wx.EXPAND | wx.TOP | wx.BOTTOM | wx.RIGHT, 10)
panel.SetSizerAndFit(mainBox)
self.SetClientSize(panel.GetSize())
self.SetMinSize(self.GetSize())
self.SetMaxSize((-1, self.GetSize()[1]))
-
+
def _destroy(self, event):
for m in self._map_list:
key = m.name
if key not in self._excluded and key in self._values:
setattr(self._obj, key, self._values[key])
del self._sigs[key]
- self.Destroy()
+ self.Destroy()
def setval(self, key, x):
if key in self._values:
@@ -948,9 +951,9 @@ class PyoObjectControl(wx.Frame):
######################################################################
class ViewTable(wx.Frame):
def __init__(self, parent, samples=None, tableclass=None, object=None):
- wx.Frame.__init__(self, parent)
- self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
- menubar = wx.MenuBar()
+ wx.Frame.__init__(self, parent, size=(500,200))
+ self.SetMinSize((300, 150))
+ menubar = wx.MenuBar()
fileMenu = wx.Menu()
closeItem = fileMenu.Append(-1, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
self.Bind(wx.EVT_MENU, self._destroy, closeItem)
@@ -958,78 +961,62 @@ class ViewTable(wx.Frame):
self.SetMenuBar(menubar)
self.tableclass = tableclass
self.object = object
- self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_CLOSE, self._destroy)
- self.width, self.height = 500, 200
- self.half_height = self.height / 2
- self.SetClientSize((self.width+10, self.height+10))
- self.SetMinSize(self.GetSize())
- self.SetMaxSize(self.GetSize())
- self.draw(samples)
+ self.panel = wx.Panel(self)
+ self.panel.SetBackgroundColour(BACKGROUND_COLOUR)
+ self.box = wx.BoxSizer(wx.VERTICAL)
+ self.wavePanel = ViewTablePanel(self.panel, object)
+ self.box.Add(self.wavePanel, 1, wx.EXPAND|wx.ALL, 5)
+ self.panel.SetSizerAndFit(self.box)
+ self.update(samples)
def update(self, samples):
- wx.CallAfter(self.draw, samples)
+ wx.CallAfter(self.wavePanel.draw, samples)
def _destroy(self, evt):
self.object._setViewFrame(None)
self.Destroy()
-
-class ViewTable_withPIL(ViewTable):
- _WITH_PIL = True
- def __init__(self, parent, samples=None, tableclass=None, object=None):
- ViewTable.__init__(self, parent, samples, tableclass, object)
- def draw(self, samples):
- im = Image.new("L", (self.width, self.height), 255)
- draw = ImageDraw.Draw(im)
- draw.line(samples, fill=0, width=1)
- image = wx.EmptyImage(self.width, self.height)
- image.SetData(im.convert("RGB").tostring())
- self.img = wx.BitmapFromImage(image)
- self.Refresh()
+class ViewTablePanel(wx.Panel):
+ def __init__(self, parent, obj):
+ wx.Panel.__init__(self, parent)
+ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
+ self.obj = obj
+ self.samples = []
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
+ self.Bind(wx.EVT_SIZE, self.OnSize)
+ if sys.platform == "win32":
+ self.dcref = wx.BufferedPaintDC
+ else:
+ self.dcref = wx.PaintDC
- def OnPaint(self, evt):
- dc = wx.PaintDC(self)
- dc.DrawBitmap(self.img, 0, 0)
- dc.SetPen(wx.Pen('#BBBBBB', width=1, style=wx.SOLID))
- dc.DrawLine(0, self.half_height+1, self.width, self.half_height+1)
-class ViewTable_withoutPIL(ViewTable):
- _WITH_PIL = False
- def __init__(self, parent, samples=None, tableclass=None, object=None):
- ViewTable.__init__(self, parent, samples, tableclass, object)
-
def draw(self, samples):
- if sys.platform == 'win32':
- if self.tableclass == 'SndTable':
- self.samples = [(samples[i], samples[i+1], samples[i+2], samples[i+3]) for i in range(0, len(samples), 4)]
- else:
- self.samples = [(samples[i], samples[i+1]) for i in range(0, len(samples), 2)]
- else:
- self.samples = [(samples[i], samples[i+1], samples[i+2], samples[i+3]) for i in range(0, len(samples), 4)]
+ self.samples = samples
self.Refresh()
def OnPaint(self, evt):
w,h = self.GetSize()
- dc = wx.AutoBufferedPaintDC(self)
+ dc = self.dcref(self)
+ gc = wx.GraphicsContext_Create(dc)
dc.SetBrush(wx.Brush("#FFFFFF"))
+ dc.SetPen(wx.Pen('#BBBBBB', width=1, style=wx.SOLID))
dc.Clear()
dc.DrawRectangle(0,0,w,h)
- if sys.platform == 'win32':
- if self.tableclass == 'SndTable':
- dc.DrawLineList(self.samples)
- else:
- dc.DrawPointList(self.samples)
- else:
- dc.DrawLineList(self.samples)
- dc.SetPen(wx.Pen('#BBBBBB', width=1, style=wx.SOLID))
- dc.DrawLine(0, self.half_height+1, self.width, self.half_height+1)
+ gc.SetPen(wx.Pen('#000000', width=1, style=wx.SOLID))
+ gc.SetBrush(wx.Brush("#FFFFFF"))
+ if len(self.samples) > 1:
+ gc.DrawLines(self.samples)
+ dc.DrawLine(0, h/2+1, w, h/2+1)
+
+ def OnSize(self, evt):
+ wx.CallAfter(self.obj.refreshView)
class SndViewTable(wx.Frame):
def __init__(self, parent, obj=None, tableclass=None, mouse_callback=None):
wx.Frame.__init__(self, parent, size=(500,250))
self.SetMinSize((300, 150))
- self.menubar = wx.MenuBar()
+ self.menubar = wx.MenuBar()
self.fileMenu = wx.Menu()
closeItem = self.fileMenu.Append(-1, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
self.Bind(wx.EVT_MENU, self._destroy, closeItem)
@@ -1044,7 +1031,7 @@ class SndViewTable(wx.Frame):
self.box = wx.BoxSizer(wx.VERTICAL)
self.wavePanel = SndViewTablePanel(self.panel, obj, mouse_callback)
self.box.Add(self.wavePanel, 1, wx.EXPAND|wx.ALL, 5)
- self.zoomH = HRangeSlider(self.panel, minvalue=0, maxvalue=1, init=None, pos=(0,0), size=(200,15),
+ self.zoomH = HRangeSlider(self.panel, minvalue=0, maxvalue=1, init=None, pos=(0,0), size=(200,15),
valtype='float', log=False, function=self.setZoomH)
self.box.Add(self.zoomH, 0, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
self.panel.SetSizer(self.box)
@@ -1162,14 +1149,14 @@ class SndViewTablePanel(wx.Panel):
y = h/self.chnls*i
if len(samples):
gc.DrawLines(samples)
- dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
+ dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
dc.DrawLine(0, y+off, w, y+off)
for j in range(10):
- dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
+ dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
dc.DrawLine(j*tickstep, 0, j*tickstep, h)
dc.DrawText(timelabel % (self.begin+j*timestep), j*tickstep+2, h-y-12)
- dc.SetPen(wx.Pen('#000000', width=1))
- dc.DrawLine(0, h-y, w, h-y)
+ dc.SetPen(wx.Pen('#000000', width=1))
+ dc.DrawLine(0, h-y, w, h-y)
def OnSize(self, evt):
wx.CallAfter(self.setImage)
@@ -1181,7 +1168,7 @@ class ViewMatrix(wx.Frame):
def __init__(self, parent, size=None, object=None):
wx.Frame.__init__(self, parent)
self.object = object
- self.menubar = wx.MenuBar()
+ self.menubar = wx.MenuBar()
self.fileMenu = wx.Menu()
closeItem = self.fileMenu.Append(-1, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
self.Bind(wx.EVT_MENU, self._destroy, closeItem)
@@ -1206,7 +1193,7 @@ class ViewMatrix_withPIL(ViewMatrix):
ViewMatrix.__init__(self, parent, size, object)
self.size = size
self.setImage(samples)
-
+
def setImage(self, samples):
im = Image.new("L", self.size, None)
im.putdata(samples)
@@ -1226,7 +1213,7 @@ class ViewMatrix_withoutPIL(ViewMatrix):
self.width = size[0]
self.height = size[1]
self.setImage(samples)
-
+
def setImage(self, samples):
self.samples = samples
self.Refresh()
@@ -1241,7 +1228,7 @@ class ViewMatrix_withoutPIL(ViewMatrix):
if len(amp) == 1:
amp = "0%s" % amp
amp = "#%s%s%s" % (amp, amp, amp)
- dc.SetPen(wx.Pen(amp, width=1, style=wx.SOLID))
+ dc.SetPen(wx.Pen(amp, width=1, style=wx.SOLID))
dc.DrawPoint(x, y)
######################################################################
@@ -1251,7 +1238,7 @@ class SpectrumDisplay(wx.Frame):
def __init__(self, parent, obj=None):
wx.Frame.__init__(self, parent, size=(600,350))
self.SetMinSize((400,240))
- self.menubar = wx.MenuBar()
+ self.menubar = wx.MenuBar()
self.fileMenu = wx.Menu()
closeItem = self.fileMenu.Append(-1, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
self.Bind(wx.EVT_MENU, self._destroy, closeItem)
@@ -1291,7 +1278,7 @@ class SpectrumDisplay(wx.Frame):
self.magTog = wx.ToggleButton(self.panel, -1, label="Mag Log", size=(tw+X_OFF, th+10))
self.magTog.SetValue(1)
self.magTog.Bind(wx.EVT_TOGGLEBUTTON, self.setMagScale)
- self.toolBox.Add(self.magTog, 0, wx.TOP|wx.LEFT, 5)
+ self.toolBox.Add(self.magTog, 0, wx.TOP|wx.LEFT, 5)
tw, th = self.GetTextExtent("Blackman 3-term")
self.winPopup = wx.Choice(self.panel, -1, choices=["Rectangular", "Hamming", "Hanning", "Bartlett", "Blackman 3-term",
"Blackman-Harris 4-term", "Blackman-Harris 7-term", "Tuckey", "Half-sine"], size=(tw+X_OFF, th+10))
@@ -1310,15 +1297,14 @@ class SpectrumDisplay(wx.Frame):
self.spectrumPanel = SpectrumPanel(self.panel, len(self.obj), self.obj.getLowfreq(), self.obj.getHighfreq(),
self.obj.getFscaling(), self.obj.getMscaling())
self.box.Add(self.spectrumPanel, 1, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
- self.zoomH = HRangeSlider(self.panel, minvalue=0, maxvalue=0.5, init=None, pos=(0,0), size=(200,15),
+ self.zoomH = HRangeSlider(self.panel, minvalue=0, maxvalue=0.5, init=None, pos=(0,0), size=(200,15),
valtype='float', log=False, function=self.setZoomH)
self.box.Add(self.zoomH, 0, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
self.dispBox.Add(self.box, 1, wx.EXPAND, 0)
- self.gainSlider = wx.Slider(self.panel, -1, 0, -24, 24, style=wx.SL_VERTICAL|wx.SL_INVERSE)
- self.gainSlider.Bind(wx.EVT_SLIDER, self.setGain)
- self.dispBox.Add(self.gainSlider, 0, wx.EXPAND|wx.BOTTOM, 15)
- self.dispBox.AddSpacer(5)
- self.mainBox.Add(self.dispBox, 1, wx.EXPAND)
+ self.gainSlider = ControlSlider(self.panel, -24, 24, 0, outFunction=self.setGain, orient=wx.VERTICAL)
+ self.dispBox.Add(self.gainSlider, 0, wx.EXPAND|wx.TOP, 5)
+ self.dispBox.AddSpacer(5)
+ self.mainBox.Add(self.dispBox, 1, wx.EXPAND)
self.panel.SetSizer(self.mainBox)
def activate(self, evt):
@@ -1350,8 +1336,8 @@ class SpectrumDisplay(wx.Frame):
size = 1 << (evt.GetInt() + 6)
self.obj.size = size
- def setGain(self, evt):
- self.obj.setGain(pow(10.0, evt.GetInt() * 0.05))
+ def setGain(self, gain):
+ self.obj.setGain(pow(10.0, gain * 0.05))
def setZoomH(self, values):
self.spectrumPanel.setLowFreq(self.obj.setLowbound(values[0]))
@@ -1361,7 +1347,7 @@ class SpectrumDisplay(wx.Frame):
def setDisplaySize(self, size):
self.obj.setWidth(size[0])
self.obj.setHeight(size[1])
-
+
def update(self, points):
wx.CallAfter(self.spectrumPanel.setImage, points)
@@ -1459,7 +1445,7 @@ class SpectrumPanel(wx.Panel):
lf = math.log10(20)
else:
lf = math.log10(self.lowfreq)
-
+
hf = math.log10(self.highfreq)
lrange = hf - lf
mag = pow(10.0, math.floor(lf))
@@ -1554,11 +1540,168 @@ class SpectrumPanel(wx.Panel):
# spectrum
if self.img != None:
for i, samples in enumerate(self.img):
- gc.SetPen(self.pens[i])
+ gc.SetPen(self.pens[i])
gc.SetBrush(self.brushes[i])
gc.DrawLines(samples)
######################################################################
+## Spectrum Display
+######################################################################
+class ScopeDisplay(wx.Frame):
+ def __init__(self, parent, obj=None):
+ wx.Frame.__init__(self, parent, size=(600,350))
+ self.SetMinSize((400,240))
+ self.menubar = wx.MenuBar()
+ self.fileMenu = wx.Menu()
+ closeItem = self.fileMenu.Append(-1, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
+ self.Bind(wx.EVT_MENU, self._destroy, closeItem)
+ self.menubar.Append(self.fileMenu, "&File")
+ self.SetMenuBar(self.menubar)
+ self.Bind(wx.EVT_CLOSE, self._destroy)
+ self.obj = obj
+ gain = self.obj.gain
+ length = self.obj.length
+ self.panel = wx.Panel(self)
+ self.panel.SetBackgroundColour(BACKGROUND_COLOUR)
+ self.mainBox = wx.BoxSizer(wx.VERTICAL)
+ self.toolBox = wx.BoxSizer(wx.HORIZONTAL)
+ if sys.platform == "darwin":
+ X_OFF = 24
+ else:
+ X_OFF = 16
+ tw, th = self.GetTextExtent("Start")
+ self.activeTog = wx.ToggleButton(self.panel, -1, label="Start", size=(tw+X_OFF, th+10))
+ self.activeTog.SetValue(1)
+ self.activeTog.Bind(wx.EVT_TOGGLEBUTTON, self.activate)
+ self.toolBox.Add(self.activeTog, 0, wx.TOP|wx.LEFT|wx.RIGHT, 5)
+ self.toolBox.AddSpacer(10)
+ self.toolBox.Add(wx.StaticText(self.panel, -1, label="Window length (ms):"), 0, wx.TOP, 11)
+ self.lenSlider = ControlSlider(self.panel, 10, 1000, length * 1000, log=True, outFunction=self.setLength)
+ self.toolBox.Add(self.lenSlider, 1, wx.TOP|wx.LEFT|wx.RIGHT, 11)
+ self.toolBox.AddSpacer(40)
+ self.mainBox.Add(self.toolBox, 0, wx.EXPAND)
+ self.dispBox = wx.BoxSizer(wx.HORIZONTAL)
+ self.box = wx.BoxSizer(wx.VERTICAL)
+ self.scopePanel = ScopePanel(self.panel, self.obj)
+ self.box.Add(self.scopePanel, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
+ self.dispBox.Add(self.box, 1, wx.EXPAND|wx.BOTTOM, 5)
+ self.gainSlider = ControlSlider(self.panel, -24, 24, 20.0 * math.log10(gain), outFunction=self.setGain, orient=wx.VERTICAL)
+ self.dispBox.Add(self.gainSlider, 0, wx.EXPAND|wx.BOTTOM, 5)
+ self.dispBox.AddSpacer(5)
+ self.mainBox.Add(self.dispBox, 1, wx.EXPAND)
+ self.panel.SetSizer(self.mainBox)
+
+ def activate(self, evt):
+ self.obj.poll(evt.GetInt())
+
+ def setLength(self, length):
+ length *= 0.001
+ self.obj.setLength(length)
+ self.scopePanel.setLength(length)
+
+ def setGain(self, gain):
+ gain = pow(10.0, gain * 0.05)
+ self.scopePanel.setGain(gain)
+ self.obj.setGain(gain)
+
+ def update(self, points):
+ wx.CallAfter(self.scopePanel.setImage, points)
+
+ def _destroy(self, evt):
+ self.obj._setViewFrame(None)
+ self.Destroy()
+
+class ScopePanel(wx.Panel):
+ def __init__(self, parent, obj):
+ wx.Panel.__init__(self, parent)
+ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
+ self.Bind(wx.EVT_SIZE, self.OnSize)
+ self.img = [[]]
+ self.obj = obj
+ self.gain = self.obj.gain
+ self.length = self.obj.length
+ self.chnls = len(self.obj)
+ if self.chnls == 1:
+ self.pens = [wx.Pen(wx.Colour(100,0,0), width=2)]
+ else:
+ self.pens = [wx.Pen(wx.Colour(166,4,0), width=2), wx.Pen(wx.Colour(8,11,116), width=2), wx.Pen(wx.Colour(0,204,0), width=2),
+ wx.Pen(wx.Colour(255,167,0), width=2), wx.Pen(wx.Colour(133,0,75), width=2), wx.Pen(wx.Colour(255,236,0), width=2),
+ wx.Pen(wx.Colour(1,147,154), width=2), wx.Pen(wx.Colour(162,239,0), width=2)]
+
+ if sys.platform == "win32":
+ self.dcref = wx.BufferedPaintDC
+ else:
+ self.dcref = wx.PaintDC
+
+ def OnSize(self, evt):
+ size = self.GetSize()
+ self.obj.setWidth(size[0])
+ self.obj.setHeight(size[1])
+
+ def setGain(self, gain):
+ self.gain = gain
+
+ def setLength(self, length):
+ self.length = length
+
+ def setImage(self, points):
+ self.img = points
+ self.Refresh()
+
+ def OnPaint(self, evt):
+ w,h = self.GetSize()
+ dc = self.dcref(self)
+ gc = wx.GraphicsContext_Create(dc)
+ tw, th = dc.GetTextExtent("0")
+ dc.SetBrush(wx.Brush("#FFFFFF"))
+ dc.Clear()
+ dc.DrawRectangle(0,0,w,h)
+ gc.SetPen(wx.Pen('#000000', width=1, style=wx.SOLID))
+ gc.SetBrush(wx.Brush("#FFFFFF", style=wx.TRANSPARENT))
+ dc.SetTextForeground("#444444")
+ if sys.platform in "darwin":
+ font, ptsize = dc.GetFont(), dc.GetFont().GetPointSize()
+ font.SetPointSize(ptsize - 3)
+ dc.SetFont(font)
+ elif sys.platform == "win32":
+ font = dc.GetFont()
+ font.SetPointSize(8)
+ dc.SetFont(font)
+
+ dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
+ # horizontal grid
+ step = h / 6
+ ampstep = 1.0 / 3.0 / self.gain
+ for i in range(1, 6):
+ pos = int(h - i * step)
+ npos = i - 3
+ text = "%.2f" % (ampstep * npos)
+ tw, th = dc.GetTextExtent(text)
+ dc.DrawText(text, w-tw-2, pos-th/2)
+ dc.DrawLine(0, pos, w-tw-10, pos)
+
+ # vertical grid
+ tickstep = w / 4
+ timestep = self.length * 0.25
+ for j in range(4):
+ dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
+ dc.DrawLine(j*tickstep, 0, j*tickstep, h)
+ dc.DrawText("%.3f" % (j*timestep), j*tickstep+2, h-12)
+ # draw waveforms
+ for i, samples in enumerate(self.img):
+ gc.SetPen(self.pens[i])
+ if len(samples):
+ gc.DrawLines(samples)
+
+ # legend
+ last_tw = tw
+ tw, th = dc.GetTextExtent("chan 8")
+ for i in range(self.chnls):
+ dc.SetTextForeground(self.pens[i].GetColour())
+ dc.DrawText("chan %d" % (i+1), w-tw-20-last_tw, i*th+10)
+
+######################################################################
## Grapher window for PyoTableObject control
######################################################################
OFF = 15
@@ -1568,11 +1711,11 @@ RAD2 = RAD*2
AREA = RAD+2
AREA2 = AREA*2
class Grapher(wx.Panel):
- def __init__(self, parent, xlen=8192, yrange=(0.0, 1.0), init=[(0.0,0.0),(1.0,1.0)], mode=0,
- exp=10.0, inverse=True, tension=0.0, bias=0.0, outFunction=None):
+ def __init__(self, parent, xlen=8192, yrange=(0.0, 1.0), init=[(0.0,0.0),(1.0,1.0)], mode=0,
+ exp=10.0, inverse=True, tension=0.0, bias=0.0, outFunction=None):
wx.Panel.__init__(self, parent, size=(500,250), style=wx.SUNKEN_BORDER)
self.backgroundColour = BACKGROUND_COLOUR
- self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
+ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.SetBackgroundColour(self.backgroundColour)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
self.Bind(wx.EVT_PAINT, self.OnPaint)
@@ -1594,7 +1737,12 @@ class Grapher(wx.Panel):
self.init = [tup for tup in init]
self.points = init
self.outFunction = outFunction
-
+
+ if sys.platform == "win32":
+ self.dcref = wx.BufferedPaintDC
+ else:
+ self.dcref = wx.PaintDC
+
self.SetFocus()
def setInitPoints(self, pts):
@@ -1641,7 +1789,7 @@ class Grapher(wx.Panel):
leftclip = x
if self.selected == (len(self.points) - 1):
rightclip = w-OFF-RAD
- else:
+ else:
x,y = self.pointToPixels(self.points[self.selected+1])
rightclip = x
@@ -1692,6 +1840,7 @@ class Grapher(wx.Panel):
self.points = [(pt[0], pt[1]-0.002) for pt in self.points]
self.sendValues()
self.Refresh()
+ evt.Skip()
def MouseDown(self, evt):
self.CaptureMouse()
@@ -1715,7 +1864,7 @@ class Grapher(wx.Panel):
self.Refresh()
def MouseUp(self, evt):
- if self.HasCapture():
+ if self.HasCapture():
self.ReleaseMouse()
self.sendValues()
@@ -1730,7 +1879,7 @@ class Grapher(wx.Panel):
if self.mode == 4 and y <= 0:
y = 0.000001
self.points[self.selected] = (x, y)
- self.Refresh()
+ self.Refresh()
def getLogPoints(self, pt1, pt2):
tmp = []
@@ -1744,7 +1893,7 @@ class Grapher(wx.Panel):
else:
low = pt1[1]
high = pt2[1]
-
+
steps = pt2[0] - pt1[0]
if steps > 0:
lrange = high - low
@@ -1798,7 +1947,7 @@ class Grapher(wx.Panel):
mu = float(i) / steps
mu2 = (1. - math.cos(mu*math.pi)) * 0.5
tmp.append((pt1[0]+i, pt1[1] * (1. - mu2) + pt2[1] * mu2))
- return tmp
+ return tmp
def getExpPoints(self, pt1, pt2):
tmp = []
@@ -1861,12 +2010,15 @@ class Grapher(wx.Panel):
a2 = mu3 - mu2
a3 = -2.0 * mu3 + 3.0 * mu2
tmp.append((pt1[0]+i, a0*y1 + a1*m0 + a2*m1 + a3*y2))
- return tmp
-
+ return tmp
+
def OnPaint(self, evt):
w,h = self.GetSize()
corners = [(OFF,OFF),(w-OFF,OFF),(w-OFF,h-OFF),(OFF,h-OFF)]
- dc = wx.AutoBufferedPaintDC(self)
+ dc = self.dcref(self)
+ gc = wx.GraphicsContext_Create(dc)
+ gc.SetBrush(wx.Brush("#000000"))
+ gc.SetPen(wx.Pen("#000000"))
if sys.platform == "darwin":
font, ptsize = dc.GetFont(), dc.GetFont().GetPointSize()
else:
@@ -1892,15 +2044,15 @@ class Grapher(wx.Panel):
t = "%.2f" % (self.xlen * i * 0.1)
dc.DrawText(t, xpos+2, h-OFF-10)
if i < 9:
- t = "%.2f" % ((9-i) * 0.1 * (self.yrange[1]-self.yrange[0]) + self.yrange[0])
+ t = "%.2f" % ((9-i) * 0.1 * (self.yrange[1]-self.yrange[0]) + self.yrange[0])
dc.DrawText(t, OFF+1, ypos+ystep-10)
else:
- t = "%.2f" % ((9-i) * 0.1 * (self.yrange[1]-self.yrange[0]) + self.yrange[0])
+ t = "%.2f" % ((9-i) * 0.1 * (self.yrange[1]-self.yrange[0]) + self.yrange[0])
dc.DrawText(t, OFF+1, h-OFF-10)
dc.SetPen(wx.Pen("#000000", 1))
dc.SetBrush(wx.Brush("#000000"))
- # Draw bounding box
+ # Draw bounding box
for i in range(4):
dc.DrawLinePoint(corners[i], corners[(i+1)%4])
@@ -1920,44 +2072,44 @@ class Grapher(wx.Panel):
if len(tmp) > 1:
if self.mode == 0:
for i in range(len(tmp)-1):
- dc.DrawLinePoint(tmp[i], tmp[i+1])
+ gc.DrawLines([tmp[i], tmp[i+1]])
elif self.mode == 1:
for i in range(len(tmp)-1):
tmp2 = self.getCosPoints(tmp[i], tmp[i+1])
if i == 0 and len(tmp2) < 2:
- dc.DrawLinePoint(tmp[i], tmp[i+1])
+ gc.DrawLines([tmp[i], tmp[i+1]])
if last_p != None:
- dc.DrawLinePoint(last_p, tmp[i])
+ gc.DrawLines([last_p, tmp[i]])
for j in range(len(tmp2)-1):
- dc.DrawLinePoint(tmp2[j], tmp2[j+1])
+ gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
if last_p != None:
- dc.DrawLinePoint(last_p, tmp[-1])
+ gc.DrawLines([last_p, tmp[-1]])
elif self.mode == 2:
for i in range(len(tmp)-1):
tmp2 = self.getExpPoints(tmp[i], tmp[i+1])
if i == 0 and len(tmp2) < 2:
- dc.DrawLinePoint(tmp[i], tmp[i+1])
+ gc.DrawLines([tmp[i], tmp[i+1]])
if last_p != None:
- dc.DrawLinePoint(last_p, tmp[i])
+ gc.DrawLines([last_p, tmp[i]])
for j in range(len(tmp2)-1):
- dc.DrawLinePoint(tmp2[j], tmp2[j+1])
+ gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
if last_p != None:
- dc.DrawLinePoint(last_p, tmp[-1])
+ gc.DrawLines([last_p, tmp[-1]])
elif self.mode == 3:
curvetmp = self.addImaginaryPoints(tmp)
for i in range(1, len(curvetmp)-2):
tmp2 = self.getCurvePoints(curvetmp[i-1], curvetmp[i], curvetmp[i+1], curvetmp[i+2])
if i == 1 and len(tmp2) < 2:
- dc.DrawLinePoint(curvetmp[i], curvetmp[i+1])
+ gc.DrawLines([curvetmp[i], curvetmp[i+1]])
if last_p != None:
- dc.DrawLinePoint(last_p, curvetmp[i])
+ gc.DrawLines([last_p, curvetmp[i]])
for j in range(len(tmp2)-1):
- dc.DrawLinePoint(tmp2[j], tmp2[j+1])
+ gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
if last_p != None:
- dc.DrawLinePoint(last_p, tmp[-1])
+ gc.DrawLines([last_p, tmp[-1]])
elif self.mode == 4:
back_tmp = [p for p in tmp]
for i in range(len(tmp)):
@@ -1967,14 +2119,14 @@ class Grapher(wx.Panel):
for j in range(len(tmp2)):
tmp2[j] = (tmp2[j][0], int(round((1.0-tmp2[j][1]) * h)) + OFF + RAD)
if i == 0 and len(tmp2) < 2:
- dc.DrawLinePoint(back_tmp[i], back_tmp[i+1])
+ gc.DrawLines([back_tmp[i], back_tmp[i+1]])
if last_p != None:
- dc.DrawLinePoint(last_p, back_tmp[i])
+ gc.DrawLines([last_p, back_tmp[i]])
for j in range(len(tmp2)-1):
- dc.DrawLinePoint(tmp2[j], tmp2[j+1])
+ gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
if last_p != None:
- dc.DrawLinePoint(last_p, back_tmp[-1])
+ gc.DrawLines([last_p, back_tmp[-1]])
tmp = [p for p in back_tmp]
elif self.mode == 5:
back_tmp = [p for p in tmp]
@@ -1985,24 +2137,26 @@ class Grapher(wx.Panel):
for j in range(len(tmp2)):
tmp2[j] = (tmp2[j][0], int(round((1.0-tmp2[j][1]) * h)) + OFF + RAD)
if i == 0 and len(tmp2) < 2:
- dc.DrawLinePoint(back_tmp[i], back_tmp[i+1])
+ gc.DrawLines([back_tmp[i], back_tmp[i+1]])
if last_p != None:
- dc.DrawLinePoint(last_p, back_tmp[i])
+ gc.DrawLines([last_p, back_tmp[i]])
for j in range(len(tmp2)-1):
- dc.DrawLinePoint(tmp2[j], tmp2[j+1])
+ gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
if last_p != None:
- dc.DrawLinePoint(last_p, back_tmp[-1])
+ gc.DrawLines([last_p, back_tmp[-1]])
tmp = [p for p in back_tmp]
# Draw points
for i,p in enumerate(tmp):
if i == self.selected:
+ gc.SetBrush(wx.Brush("#FFFFFF"))
dc.SetBrush(wx.Brush("#FFFFFF"))
else:
+ gc.SetBrush(wx.Brush("#000000"))
dc.SetBrush(wx.Brush("#000000"))
- dc.DrawCircle(p[0],p[1],RAD)
-
+ gc.DrawEllipse(p[0]-RAD,p[1]-RAD,RAD2,RAD2)
+
# Draw position values
font.SetPointSize(ptsize-3)
dc.SetFont(font)
@@ -2030,7 +2184,7 @@ class TableGrapher(wx.Frame):
else:
self.graph = Grapher(self, xlen=xlen, yrange=yrange, init=pts, mode=mode, outFunction=obj.replace)
- self.menubar = wx.MenuBar()
+ self.menubar = wx.MenuBar()
self.fileMenu = wx.Menu()
self.fileMenu.Append(9999, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
self.Bind(wx.EVT_MENU, self.close, id=9999)
@@ -2061,9 +2215,9 @@ class TableGrapher(wx.Frame):
pstr += "%.4f)" % pt[1]
if i < (len(pts)-1):
pstr += ","
- pstr += "]"
+ pstr += "]"
else:
- pstr = str(pts)
+ pstr = str(pts)
data = wx.TextDataObject(pstr)
if wx.TheClipboard.Open():
wx.TheClipboard.Clear()
@@ -2074,10 +2228,10 @@ class TableGrapher(wx.Frame):
self.graph.reset()
class DataMultiSlider(wx.Panel):
- def __init__(self, parent, init, yrange=(0,1), outFunction=None):
+ def __init__(self, parent, init, yrange=(0,1), outFunction=None):
wx.Panel.__init__(self, parent, size=(250,250), style=wx.SUNKEN_BORDER)
self.backgroundColour = BACKGROUND_COLOUR
- self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
+ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.SetBackgroundColour(self.backgroundColour)
self.Bind(wx.EVT_SIZE, self.OnResize)
self.Bind(wx.EVT_PAINT, self.OnPaint)
@@ -2096,7 +2250,11 @@ class DataMultiSlider(wx.Panel):
def OnResize(self, event):
self.Layout()
self.Refresh()
-
+
+ def update(self, points):
+ self.values = points
+ self.Refresh()
+
def OnPaint(self, event):
w,h = self.GetSize()
dc = self.dcref(self)
@@ -2172,13 +2330,13 @@ class DataMultiSlider(wx.Panel):
if step > 1:
inc = (y2 - y1) / step
if x2 > x1:
- for i in range(0, step):
+ for i in range(0, step):
self.values[x1+i] = y1 + inc * i
else:
- for i in range(1, step):
+ for i in range(1, step):
self.values[x1-i] = y1 + inc * i
if x2 >= 0 and x2 < self.len:
- self.values[x2] = y2
+ self.values[x2] = y2
self.lastpos = pos
self.Refresh()
@@ -2187,7 +2345,7 @@ class DataTableGrapher(wx.Frame):
wx.Frame.__init__(self, parent, size=(500,250))
self.obj = obj
self.multi = DataMultiSlider(self, self.obj.getTable(), yrange, outFunction=self.obj.replace)
- self.menubar = wx.MenuBar()
+ self.menubar = wx.MenuBar()
self.fileMenu = wx.Menu()
self.fileMenu.Append(9999, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
self.Bind(wx.EVT_MENU, self.close, id=9999)
@@ -2197,18 +2355,21 @@ class DataTableGrapher(wx.Frame):
def close(self, evt):
self.Destroy()
+ def update(self, samples):
+ wx.CallAfter(self.multi.update, samples)
+
class ServerGUI(wx.Frame):
- def __init__(self, parent=None, nchnls=2, startf=None, stopf=None, recstartf=None,
- recstopf=None, ampf=None, started=0, locals=None, shutdown=None, meter=True, timer=True, amp=1.):
- wx.Frame.__init__(self, parent)
+ def __init__(self, parent=None, nchnls=2, startf=None, stopf=None, recstartf=None,
+ recstopf=None, ampf=None, started=0, locals=None, shutdown=None, meter=True, timer=True, amp=1., exit=True):
+ wx.Frame.__init__(self, parent, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
self.SetTitle("pyo server")
-
+
self.menubar = wx.MenuBar()
self.menu = wx.Menu()
self.menu.Append(22999, 'Start/Stop\tCtrl+R', kind=wx.ITEM_NORMAL)
self.Bind(wx.EVT_MENU, self.start, id=22999)
- quit_item = self.menu.Append(wx.ID_EXIT, "Quit\tCtrl+Q")
+ quit_item = self.menu.Append(wx.ID_EXIT, "Quit\tCtrl+Q")
self.Bind(wx.EVT_MENU, self.on_quit, id=wx.ID_EXIT)
self.menubar.Append(self.menu, "&File")
self.SetMenuBar(self.menubar)
@@ -2221,6 +2382,7 @@ class ServerGUI(wx.Frame):
self.recstartf = recstartf
self.recstopf = recstopf
self.ampf = ampf
+ self.exit = exit
self._started = False
self._recstarted = False
self._history = []
@@ -2253,10 +2415,10 @@ class ServerGUI(wx.Frame):
box.Add(wx.StaticText(panel, -1, "Amplitude (dB)"), 0, wx.LEFT, leftMargin)
ampBox = wx.BoxSizer(wx.HORIZONTAL)
- self.ampScale = ControlSlider(panel, -60, 18, 20.0 * math.log10(amp), size=(203, 16), outFunction=self.setAmp)
+ self.ampScale = ControlSlider(panel, -60, 18, 20.0 * math.log10(amp), size=(202, 16), outFunction=self.setAmp)
ampBox.Add(self.ampScale, 0, wx.LEFT, leftMargin-10)
box.Add(ampBox, 0, wx.LEFT | wx.RIGHT, 8)
-
+
if meter:
box.AddSpacer(10)
self.meter = VuMeter(panel, size=(200,5*self.nchnls+1), numSliders=self.nchnls)
@@ -2275,35 +2437,36 @@ class ServerGUI(wx.Frame):
box.AddSpacer(10)
t = wx.StaticText(panel, -1, "Interpreter")
box.Add(t, 0, wx.LEFT, leftMargin)
- self.text = wx.TextCtrl(panel, -1, "", size=(200, -1), style=wx.TE_PROCESS_ENTER)
+ tw, th = self.GetTextExtent("|")
+ self.text = wx.TextCtrl(panel, -1, "", size=(202, th+8), style=wx.TE_PROCESS_ENTER)
self.text.Bind(wx.EVT_TEXT_ENTER, self.getText)
self.text.Bind(wx.EVT_CHAR, self.onChar)
- box.Add(self.text, 0, wx.LEFT, leftMargin)
+ box.Add(self.text, 0, wx.LEFT, leftMargin-1)
box.AddSpacer(10)
panel.SetSizerAndFit(box)
self.SetClientSize(panel.GetSize())
- self.SetMinSize(self.GetSize())
- self.SetMaxSize(self.GetSize())
if started == 1:
self.start(None, True)
def setTime(self, *args):
wx.CallAfter(self.timetext.SetLabel, "%02d : %02d : %02d : %03d" % (args[0], args[1], args[2], args[3]))
-
+
def start(self, evt=None, justSet=False):
if self._started == False:
if not justSet:
self.startf()
self._started = True
wx.CallAfter(self.startButton.SetLabel, 'Stop')
- wx.CallAfter(self.quitButton.Disable)
+ if self.exit:
+ wx.CallAfter(self.quitButton.Disable)
else:
- self.stopf()
+ wx.CallLater(100, self.stopf)
self._started = False
wx.CallAfter(self.startButton.SetLabel, 'Start')
- wx.CallAfter(self.quitButton.Enable)
+ if self.exit:
+ wx.CallAfter(self.quitButton.Enable)
def record(self, evt):
if self._recstarted == False:
@@ -2316,9 +2479,11 @@ class ServerGUI(wx.Frame):
self.recButton.SetLabel('Rec Start')
def on_quit(self, evt):
- self.shutdown()
+ if self.exit:
+ self.shutdown()
self.Destroy()
- sys.exit()
+ if self.exit:
+ sys.exit()
def getPrev(self):
self.text.Clear()
@@ -2333,7 +2498,7 @@ class ServerGUI(wx.Frame):
self._histo_count += 1
if self._histo_count >= len(self._history):
self._histo_count = len(self._history)
- else:
+ else:
self.text.SetValue(self._history[self._histo_count])
self.text.SetInsertionPointEnd()
@@ -2348,22 +2513,15 @@ class ServerGUI(wx.Frame):
key = evt.GetKeyCode()
if key == 315:
self.getPrev()
+ evt.StopPropagation()
elif key == 317:
- self.getNext()
- evt.Skip()
+ self.getNext()
+ evt.StopPropagation()
+ else:
+ evt.Skip()
def setAmp(self, value):
self.ampf(math.pow(10.0, float(value) * 0.05))
def setRms(self, *args):
self.meter.setRms(*args)
-
-if __name__ == "__main__":
- def pprint(values):
- print values
-
- app = wx.App(False)
- values = [random.uniform(10, 25) for i in range(10)]
- f = DataTableGrapher(init=values, yrange=(2, 50))
- f.Show()
- app.MainLoop()
diff --git a/pyolib/analysis.py b/pyolib/analysis.py
index 7ba6fd8..81f1db6 100644
--- a/pyolib/analysis.py
+++ b/pyolib/analysis.py
@@ -2,44 +2,46 @@
Tools to analyze audio signals.
These objects are designed to retrieve specific informations
-from an audio stream. Analysis are sent at audio rate, user
+from an audio stream. Analysis are sent at audio rate, user
can use them for controlling parameters of others objects.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
+from _widgets import createSpectrumWindow, createScopeWindow
+from pattern import Pattern
class Follower(PyoObject):
"""
Envelope follower.
-
+
Output signal is the continuous mean amplitude of an input signal.
:Parent: :py:class:`PyoObject`
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
@@ -47,9 +49,9 @@ class Follower(PyoObject):
.. note::
- The out() method is bypassed. Follower's signal can not be sent to
+ The out() method is bypassed. Follower's signal can not be sent to
audio outs.
-
+
>>> s = Server().boot()
>>> s.start()
>>> sf = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True, mul=.4).out()
@@ -58,6 +60,7 @@ class Follower(PyoObject):
"""
def __init__(self, input, freq=20, mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -68,7 +71,7 @@ class Follower(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -77,19 +80,21 @@ class Follower(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -100,7 +105,7 @@ class Follower(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(1., 500., 'log', 'freq', self._freq)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
"""PyoObject. Input signal to process."""
@@ -134,7 +139,7 @@ class Follower2(PyoObject):
.. note::
- The out() method is bypassed. Follower's signal can not be sent to
+ The out() method is bypassed. Follower's signal can not be sent to
audio outs.
>>> s = Server().boot()
@@ -145,6 +150,7 @@ class Follower2(PyoObject):
"""
def __init__(self, input, risetime=0.01, falltime=0.1, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, risetime, falltime, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._risetime = risetime
@@ -165,6 +171,7 @@ class Follower2(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -178,6 +185,7 @@ class Follower2(PyoObject):
New `risetime` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._risetime = x
x, lmax = convertArgsToLists(x)
[obj.setRisetime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -192,6 +200,7 @@ class Follower2(PyoObject):
New `falltime` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._falltime = x
x, lmax = convertArgsToLists(x)
[obj.setFalltime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -205,21 +214,21 @@ class Follower2(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def risetime(self):
- """float or PyoObject. Time to reach upward value in seconds."""
+ """float or PyoObject. Time to reach upward value in seconds."""
return self._risetime
@risetime.setter
def risetime(self, x): self.setRisetime(x)
@property
def falltime(self):
- """float or PyoObject. Time to reach downward value in seconds."""
+ """float or PyoObject. Time to reach downward value in seconds."""
return self._falltime
@falltime.setter
def falltime(self, x): self.setFalltime(x)
@@ -227,25 +236,25 @@ class Follower2(PyoObject):
class ZCross(PyoObject):
"""
Zero-crossing counter.
-
- Output signal is the number of zero-crossing occured during each
+
+ Output signal is the number of zero-crossing occured during each
buffer size, normalized between 0 and 1.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
thresh : float, optional
- Minimum amplitude difference allowed between adjacent samples
+ Minimum amplitude difference allowed between adjacent samples
to be included in the zeros count.
.. note::
- The out() method is bypassed. ZCross's signal can not be sent to
+ The out() method is bypassed. ZCross's signal can not be sent to
audio outs.
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True, mul=.4).out()
@@ -254,6 +263,7 @@ class ZCross(PyoObject):
"""
def __init__(self, input, thresh=0., mul=1, add=0):
+ pyoArgsAssert(self, "onOO", input, thresh, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._thresh = thresh
@@ -264,7 +274,7 @@ class ZCross(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -273,19 +283,21 @@ class ZCross(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setThresh(self, x):
"""
Replace the `thresh` attribute.
-
+
:Args:
x : float
New amplitude difference threshold.
"""
+ pyoArgsAssert(self, "n", x)
self._thresh = x
x, lmax = convertArgsToLists(x)
[obj.setThresh(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -296,17 +308,17 @@ class ZCross(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0., 0.5, 'lin', 'thresh', self._thresh)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def thresh(self):
- """float. Amplitude difference threshold."""
+ """float. Amplitude difference threshold."""
return self._thresh
@thresh.setter
def thresh(self, x): self.setThresh(x)
@@ -314,41 +326,41 @@ class ZCross(PyoObject):
class Yin(PyoObject):
"""
Pitch tracker using the Yin algorithm.
-
+
Pitch tracker using the Yin algorithm based on the implementation in C of aubio.
This algorithm was developped by A. de Cheveigne and H. Kawahara and published in
-
+
de Cheveigne, A., Kawahara, H. (2002) 'YIN, a fundamental frequency estimator for
speech and music', J. Acoust. Soc. Am. 111, 1917-1930.
-
+
The audio output of the object is the estimated frequency, in Hz, of the input sound.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
tolerance : float, optional
Parameter for minima selection, between 0 and 1. Defaults to 0.2.
minfreq : float, optional
- Minimum estimated frequency in Hz. Frequency below this threshold will
+ Minimum estimated frequency in Hz. Frequency below this threshold will
be ignored. Defaults to 40.
maxfreq : float, optional
- Maximum estimated frequency in Hz. Frequency above this threshold will
+ Maximum estimated frequency in Hz. Frequency above this threshold will
be ignored. Defaults to 1000.
cutoff : float, optional
Cutoff frequency, in Hz, of the lowpass filter applied on the input sound.
Defaults to 1000.
-
+
The lowpass filter helps the algorithm to detect the fundamental frequency by filtering
- higher harmonics.
+ higher harmonics.
winsize : int, optional
Size, in samples, of the analysis window. Must be higher that two period
of the lowest desired frequency.
-
+
Available at initialization time only. Defaults to 1024.
-
+
>>> s = Server(duplex=1).boot()
>>> s.start()
@@ -361,6 +373,7 @@ class Yin(PyoObject):
"""
def __init__(self, input, tolerance=0.2, minfreq=40, maxfreq=1000, cutoff=1000, winsize=1024, mul=1, add=0):
+ pyoArgsAssert(self, "onnnniOO", input, tolerance, minfreq, maxfreq, cutoff, winsize, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._tolerance = tolerance
@@ -374,7 +387,7 @@ class Yin(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -383,19 +396,21 @@ class Yin(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setTolerance(self, x):
"""
Replace the `tolerance` attribute.
-
+
:Args:
x : float
New parameter for minima selection, between 0 and 1.
"""
+ pyoArgsAssert(self, "n", x)
self._tolerance = x
x, lmax = convertArgsToLists(x)
[obj.setTolerance(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -403,13 +418,14 @@ class Yin(PyoObject):
def setMinfreq(self, x):
"""
Replace the `minfreq` attribute.
-
+
:Args:
x : float
New minimum frequency detected.
"""
+ pyoArgsAssert(self, "n", x)
self._minfreq = x
x, lmax = convertArgsToLists(x)
[obj.setMinfreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -417,13 +433,14 @@ class Yin(PyoObject):
def setMaxfreq(self, x):
"""
Replace the `maxfreq` attribute.
-
+
:Args:
x : float
New maximum frequency detected.
"""
+ pyoArgsAssert(self, "n", x)
self._maxfreq = x
x, lmax = convertArgsToLists(x)
[obj.setMaxfreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -431,13 +448,14 @@ class Yin(PyoObject):
def setCutoff(self, x):
"""
Replace the `cutoff` attribute.
-
- :Args:
+
+ :Args:
x : float
New input lowpass filter cutoff frequency.
"""
+ pyoArgsAssert(self, "n", x)
self._cutoff = x
x, lmax = convertArgsToLists(x)
[obj.setCutoff(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -451,38 +469,1057 @@ class Yin(PyoObject):
SLMap(500, 5000, 'log', 'maxfreq', self._maxfreq, dataOnly=True),
SLMap(200, 15000, 'log', 'cutoff', self._cutoff, dataOnly=True)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def tolerance(self):
- """float. Parameter for minima selection."""
+ """float. Parameter for minima selection."""
return self._tolerance
@tolerance.setter
def tolerance(self, x): self.setTolerance(x)
@property
def minfreq(self):
- """float. Minimum frequency detected."""
+ """float. Minimum frequency detected."""
return self._minfreq
@minfreq.setter
def minfreq(self, x): self.setMinfreq(x)
@property
def maxfreq(self):
- """float. Maximum frequency detected."""
+ """float. Maximum frequency detected."""
return self._maxfreq
@maxfreq.setter
def maxfreq(self, x): self.setMaxfreq(x)
@property
def cutoff(self):
- """float. Input lowpass filter cutoff frequency."""
+ """float. Input lowpass filter cutoff frequency."""
+ return self._cutoff
+ @cutoff.setter
+ def cutoff(self, x): self.setCutoff(x)
+
+class Centroid(PyoObject):
+ """
+ Computes the spectral centroid of an input signal.
+
+ Output signal is the spectral centroid, in Hz, of the input signal.
+ It indicates where the "center of mass" of the spectrum is. Perceptually,
+ it has a robust connection with the impression of "brightness" of a sound.
+
+ Centroid does its computation with two overlaps, so a new output value
+ comes every half of the FFT window size.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal to process.
+ size : int, optional
+ Size, as a power-of-two, of the FFT used to compute the centroid.
+
+ Available at initialization time only. Defaults to 1024.
+
+
+ .. note::
+
+ The out() method is bypassed. Centroid's signal can not be sent to
+ audio outs.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> a = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True, mul=.4).out()
+ >>> b = Centroid(a, 1024)
+ >>> c = Port(b, 0.05, 0.05)
+ >>> d = ButBP(Noise(0.2), freq=c, q=5).out(1)
+
+ """
+ def __init__(self, input, size=1024, mul=1, add=0):
+ pyoArgsAssert(self, "oiOO", input, size, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._input = input
+ self._size = size
+ self._in_fader = InputFader(input)
+ in_fader, size, mul, add, lmax = convertArgsToLists(self._in_fader, size, mul, add)
+ self._base_objs = [Centroid_base(wrap(in_fader,i), wrap(size,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Default to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ def out(self, chnl=0, inc=1, dur=0, delay=0):
+ return self.play(dur, delay)
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = []
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to process."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+class AttackDetector(PyoObject):
+ """
+ Audio signal onset detection.
+
+ AttackDetector analyses an audio signal in input and output a trigger each
+ time an onset is detected. An onset is a sharp amplitude rising while the
+ signal had previously fall below a minimum threshold. Parameters must be
+ carefully tuned depending on the nature of the analysed signal and the level
+ of the background noise.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal to process.
+ deltime : float, optional
+ Delay time, in seconds, between previous and current rms analysis to compare.
+ Defaults to 0.005.
+ cutoff : float, optional
+ Cutoff frequency, in Hz, of the amplitude follower's lowpass filter.
+ Defaults to 10.
+
+ Higher values are more responsive and also more likely to give false onsets.
+ maxthresh : float, optional
+ Attack threshold in positive dB (current rms must be higher than previous
+ rms + maxthresh to be reported as an attack). Defaults to 3.0.
+ minthresh : float, optional
+ Minimum threshold in dB (signal must fall below this threshold to allow
+ a new attack to be detected). Defaults to -30.0.
+ reltime : float, optional
+ Time, in seconds, to wait before reporting a new attack. Defaults to 0.1.
+
+
+ >>> s = Server(duplex=1).boot()
+ >>> s.start()
+ >>> a = Input()
+ >>> d = AttackDetector(a, deltime=0.005, cutoff=10, maxthresh=4, minthresh=-20, reltime=0.05)
+ >>> exc = TrigEnv(d, HannTable(), dur=0.005, mul=BrownNoise(0.3))
+ >>> wgs = Waveguide(exc, freq=[100,200.1,300.3,400.5], dur=30).out()
+
+ """
+ def __init__(self, input, deltime=0.005, cutoff=10, maxthresh=3, minthresh=-30, reltime=0.1, mul=1, add=0):
+ pyoArgsAssert(self, "onnnnnOO", input, deltime, cutoff, maxthresh, minthresh, reltime, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._input = input
+ self._deltime = deltime
+ self._cutoff = cutoff
+ self._maxthresh = maxthresh
+ self._minthresh = minthresh
+ self._reltime = reltime
+ self._in_fader = InputFader(input)
+ in_fader, deltime, cutoff, maxthresh, minthresh, reltime, mul, add, lmax = convertArgsToLists(self._in_fader, deltime, cutoff, maxthresh, minthresh, reltime, mul, add)
+ self._base_objs = [AttackDetector_base(wrap(in_fader,i), wrap(deltime,i), wrap(cutoff,i), wrap(maxthresh,i), wrap(minthresh,i), wrap(reltime,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Default to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ def setDeltime(self, x):
+ """
+ Replace the `deltime` attribute.
+
+ :Args:
+
+ x : float
+ New delay between rms analysis.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._deltime = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setDeltime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setCutoff(self, x):
+ """
+ Replace the `cutoff` attribute.
+
+ :Args:
+
+ x : float
+ New cutoff for the follower lowpass filter.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._cutoff = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setCutoff(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setMaxthresh(self, x):
+ """
+ Replace the `maxthresh` attribute.
+
+ :Args:
+
+ x : float
+ New attack threshold in dB.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._maxthresh = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setMaxthresh(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setMinthresh(self, x):
+ """
+ Replace the `minthresh` attribute.
+
+ :Args:
+
+ x : float
+ New minimum threshold in dB.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._minthresh = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setMinthresh(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setReltime(self, x):
+ """
+ Replace the `reltime` attribute.
+
+ :Args:
+
+ x : float
+ Time, in seconds, to wait before reporting a new attack.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._reltime = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setReltime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def out(self, chnl=0, inc=1, dur=0, delay=0):
+ return self.play(dur, delay)
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = [SLMap(0.001, 0.05, 'lin', 'deltime', self._deltime, dataOnly=True),
+ SLMap(1.0, 1000.0, 'log', 'cutoff', self._cutoff, dataOnly=True),
+ SLMap(0.0, 18.0, 'lin', 'maxthresh', self._maxthresh, dataOnly=True),
+ SLMap(-90.0, 0.0, 'lin', 'minthresh', self._minthresh, dataOnly=True),
+ SLMap(0.001, 1.0, 'log', 'reltime', self._reltime, dataOnly=True)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to process."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+ @property
+ def deltime(self):
+ """float. Delay between rms analysis."""
+ return self._deltime
+ @deltime.setter
+ def deltime(self, x): self.setDeltime(x)
+
+ @property
+ def cutoff(self):
+ """float. Cutoff for the follower lowpass filter."""
return self._cutoff
@cutoff.setter
def cutoff(self, x): self.setCutoff(x)
+
+ @property
+ def maxthresh(self):
+ """float. Attack threshold in dB."""
+ return self._maxthresh
+ @maxthresh.setter
+ def maxthresh(self, x): self.setMaxthresh(x)
+
+ @property
+ def minthresh(self):
+ """float. Minimum threshold in dB."""
+ return self._minthresh
+ @minthresh.setter
+ def minthresh(self, x): self.setMinthresh(x)
+
+ @property
+ def reltime(self):
+ """float. Time to wait before reporting a new attack."""
+ return self._reltime
+ @reltime.setter
+ def reltime(self, x): self.setReltime(x)
+
+class Spectrum(PyoObject):
+ """
+ Spectrum analyzer and display.
+
+ Spectrum measures the magnitude of an input signal versus frequency
+ within a user defined range. It can show both magnitude and frequency
+ on linear or logarithmic scale.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal to process.
+ size : int {pow-of-two > 4}, optional
+ FFT size. Must be a power of two greater than 4.
+ The FFT size is the number of samples used in each
+ analysis frame. Defaults to 1024.
+ wintype : int, optional
+ Shape of the envelope used to filter each input frame.
+ Possible shapes are :
+ 0. rectangular (no windowing)
+ 1. Hamming
+ 2. Hanning
+ 3. Bartlett (triangular)
+ 4. Blackman 3-term
+ 5. Blackman-Harris 4-term
+ 6. Blackman-Harris 7-term
+ 7. Tuckey (alpha = 0.66)
+ 8. Sine (half-sine window)
+ function : python callable, optional
+ If set, this function will be called with magnitudes (as
+ list of lists, one list per channel). Useful if someone
+ wants to save the analysis data into a text file.
+ Defaults to None.
+
+ .. note::
+
+ Spectrum has no `out` method.
+
+ Spectrum has no `mul` and `add` attributes.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> a = SuperSaw(freq=[500,750], detune=0.6, bal=0.7, mul=0.5).out()
+ >>> spec = Spectrum(a, size=1024)
+
+ """
+ def __init__(self, input, size=1024, wintype=2, function=None):
+ pyoArgsAssert(self, "oiiC", input, size, wintype, function)
+ PyoObject.__init__(self)
+ self.points = None
+ self.viewFrame = None
+ self._input = input
+ self._size = size
+ self._wintype = wintype
+ self._function = getWeakMethodRef(function)
+ self._fscaling = 0
+ self._mscaling = 1
+ self._lowbound = 0
+ self._highbound = 0.5
+ self._width = 500
+ self._height = 400
+ self._gain = 1
+ self._in_fader = InputFader(input)
+ in_fader, size, wintype, lmax = convertArgsToLists(self._in_fader, size, wintype)
+ self._base_objs = [Spectrum_base(wrap(in_fader,i), wrap(size,i), wrap(wintype,i)) for i in range(lmax)]
+ if function == None:
+ self.view()
+ self._timer = Pattern(self.refreshView, 0.05).play()
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Default to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ def setSize(self, x):
+ """
+ Replace the `size` attribute.
+
+ :Args:
+
+ x : int
+ new `size` attribute.
+
+ """
+ pyoArgsAssert(self, "i", x)
+ self._size = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setSize(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setWinType(self, x):
+ """
+ Replace the `wintype` attribute.
+
+ :Args:
+
+ x : int
+ new `wintype` attribute.
+
+ """
+ pyoArgsAssert(self, "i", x)
+ self._wintype = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setWinType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setFunction(self, function):
+ """
+ Sets the function to be called to retrieve the analysis data.
+
+ :Args:
+
+ function : python callable
+ The function called by the internal timer to retrieve the
+ analysis data. The function must be created with one argument
+ and will receive the data as a list of lists (one list per channel).
+
+ """
+ pyoArgsAssert(self, "C", function)
+ self._function = getWeakMethodRef(function)
+
+ def poll(self, active):
+ """
+ Turns on and off the analysis polling.
+
+ :Args:
+
+ active : boolean
+ If True, starts the analysis polling, False to stop it.
+ defaults to True.
+
+ """
+ pyoArgsAssert(self, "B", active)
+ if active:
+ self._timer.play()
+ else:
+ self._timer.stop()
+
+ def polltime(self, time):
+ """
+ Sets the polling time in seconds.
+
+ :Args:
+
+ time : float
+ Adjusts the frequency of the internal timer used to
+ retrieve the current analysis frame. defaults to 0.05.
+
+ """
+ pyoArgsAssert(self, "N", time)
+ self._timer.time = time
+
+ def setLowbound(self, x):
+ """
+ Sets the lower frequency, as multiplier of sr, returned by the analysis.
+
+ Returns the real low frequency en Hz.
+
+ :Args:
+
+ x : float {0 <= x <= 0.5}
+ new `lowbound` attribute.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._lowbound = x
+ x, lmax = convertArgsToLists(x)
+ tmp = [obj.setLowbound(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ return tmp[0]
+
+ def setHighbound(self, x):
+ """
+ Sets the higher frequency, as multiplier of sr, returned by the analysis.
+
+ Returns the real high frequency en Hz.
+
+ :Args:
+
+ x : float {0 <= x <= 0.5}
+ new `highbound` attribute.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._highbound = x
+ x, lmax = convertArgsToLists(x)
+ tmp = [obj.setHighbound(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ return tmp[0]
+
+ def getLowfreq(self):
+ """
+ Returns the current lower frequency, in Hz, used by the analysis.
+
+ """
+
+ return self._base_objs[0].getLowfreq()
+
+ def getHighfreq(self):
+ """
+ Returns the current higher frequency, in Hz, used by the analysis.
+
+ """
+ return self._base_objs[0].getHighfreq()
+
+ def setWidth(self, x):
+ """
+ Sets the width, in pixels, of the current display.
+
+ Used internally to build the list of points to draw.
+
+ :Args:
+
+ x : int
+ new `width` attribute.
+
+ """
+ pyoArgsAssert(self, "i", x)
+ self._width = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setWidth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setHeight(self, x):
+ """
+ Sets the height, in pixels, of the current display.
+
+ Used internally to build the list of points to draw.
+
+ :Args:
+
+ x : int
+ new `height` attribute.
+
+ """
+ pyoArgsAssert(self, "i", x)
+ self._height = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setHeight(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setFscaling(self, x):
+ """
+ Sets the frequency display to linear or logarithmic.
+
+ :Args:
+
+ x : boolean
+ If True, the frequency display is logarithmic. False turns
+ it back to linear. Defaults to False.
+
+ """
+ pyoArgsAssert(self, "b", x)
+ self._fscaling = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setFscaling(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ if self.viewFrame != None:
+ self.viewFrame.setFscaling(self._fscaling)
+
+ def setMscaling(self, x):
+ """
+ Sets the magnitude display to linear or logarithmic.
+
+ :Args:
+
+ x : boolean
+ If True, the magnitude display is logarithmic (which means in dB).
+ False turns it back to linear. Defaults to True.
+
+ """
+ pyoArgsAssert(self, "b", x)
+ self._mscaling = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setMscaling(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ if self.viewFrame != None:
+ self.viewFrame.setMscaling(self._mscaling)
+
+ def getFscaling(self):
+ """
+ Returns the scaling of the frequency display.
+
+ Returns True for logarithmic or False for linear.
+
+ """
+ return self._fscaling
+
+ def getMscaling(self):
+ """
+ Returns the scaling of the magnitude display.
+
+ Returns True for logarithmic or False for linear.
+
+ """
+ return self._mscaling
+
+ def setGain(self, x):
+ """
+ Set the gain of the analysis data. For drawing purpose.
+
+ :Args:
+
+ x : float
+ new `gain` attribute, as linear values.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._gain = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setGain(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def view(self, title="Spectrum", wxnoserver=False):
+ """
+ Opens a window showing the result of the analysis.
+
+ :Args:
+
+ title : string, optional
+ Window title. Defaults to "Spectrum".
+ wxnoserver : boolean, optional
+ With wxPython graphical toolkit, if True, tells the
+ interpreter that there will be no server window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
+
+ """
+ pyoArgsAssert(self, "SB", title, wxnoserver)
+ createSpectrumWindow(self, title, wxnoserver)
+
+ def _setViewFrame(self, frame):
+ self.viewFrame = frame
+
+ def refreshView(self):
+ """
+ Updates the graphical display of the spectrum.
+
+ Called automatically by the internal timer.
+
+ """
+ self.points = [obj.display() for obj in self._base_objs]
+ if self._function != None:
+ self._function(self.points)
+ if self.viewFrame != None:
+ self.viewFrame.update(self.points)
+
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to process."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+ @property
+ def size(self):
+ """int. FFT size."""
+ return self._size
+ @size.setter
+ def size(self, x): self.setSize(x)
+
+ @property
+ def wintype(self):
+ """int. Windowing method."""
+ return self._wintype
+ @wintype.setter
+ def wintype(self, x): self.setWinType(x)
+
+ @property
+ def gain(self):
+ """float. Sets the gain of the analysis data."""
+ return self._gain
+ @gain.setter
+ def gain(self, x): self.setGain(x)
+
+ @property
+ def lowbound(self):
+ """float. Lowest frequency (multiplier of sr) to output."""
+ return self._lowbound
+ @lowbound.setter
+ def lowbound(self, x): self.setLowbound(x)
+
+ @property
+ def highbound(self):
+ """float. Highest frequency (multiplier of sr) to output."""
+ return self._highbound
+ @highbound.setter
+ def highbound(self, x): self.setHighbound(x)
+
+ @property
+ def width(self):
+ """int. Width, in pixels, of the current display."""
+ return self._width
+ @width.setter
+ def width(self, x): self.setWidth(x)
+
+ @property
+ def height(self):
+ """int. Height, in pixels, of the current display."""
+ return self._height
+ @height.setter
+ def height(self, x): self.setHeight(x)
+
+ @property
+ def fscaling(self):
+ """boolean. Scaling of the frequency display."""
+ return self._fscaling
+ @fscaling.setter
+ def fscaling(self, x): self.setFscaling(x)
+
+ @property
+ def mscaling(self):
+ """boolean. Scaling of the magnitude display."""
+ return self._mscaling
+ @mscaling.setter
+ def mscaling(self, x): self.setMscaling(x)
+
+class Scope(PyoObject):
+ """
+ Oscilloscope - audio waveform display.
+
+ Oscilloscopes are used to observe the change of an electrical
+ signal over time.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal to process.
+ length : float, optional
+ Length, in seconds, of the displayed window. Can't be a list.
+ Defaults to 0.05.
+ gain : float, optional
+ Linear gain applied to the signal to be displayed.
+ Can't be a list. Defaults to 0.67.
+
+ .. note::
+
+ Scope has no `out` method.
+
+ Scope has no `mul` and `add` attributes.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> a = Sine([100,100.2], mul=0.7)
+ >>> b = Noise(0.1)
+ >>> scope = Scope(a+b)
+
+ """
+ def __init__(self, input, length=0.05, gain=0.67):
+ pyoArgsAssert(self, "oNN", input, length, gain)
+ PyoObject.__init__(self)
+ self.points = None
+ self.viewFrame = None
+ self._input = input
+ self._length = length
+ self._gain = gain
+ self._width = 500
+ self._height = 400
+ self._in_fader = InputFader(input)
+ in_fader, lmax = convertArgsToLists(self._in_fader)
+ self._base_objs = [Scope_base(wrap(in_fader,i), length) for i in range(lmax)]
+ self.view()
+ self._timer = Pattern(self.refreshView, length).play()
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Default to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ def setLength(self, x):
+ """
+ Replace the `length` attribute.
+
+ :Args:
+
+ x : float
+ new `length` attribute.
+
+ """
+ pyoArgsAssert(self, "N", x)
+ self._length = x
+ self._timer.time = x
+ [obj.setLength(x) for obj in self._base_objs]
+
+ def setGain(self, x):
+ """
+ Set the gain boost applied to the analysed data. For drawing purpose.
+
+ :Args:
+
+ x : float
+ new `gain` attribute, as linear values.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._gain = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setGain(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def poll(self, active):
+ """
+ Turns on and off the analysis polling.
+
+ :Args:
+
+ active : boolean
+ If True, starts the analysis polling, False to stop it.
+ defaults to True.
+
+ """
+ pyoArgsAssert(self, "B", active)
+ if active:
+ self._timer.play()
+ else:
+ self._timer.stop()
+
+ def setWidth(self, x):
+ """
+ Gives the width of the display to the analyzer.
+
+ The analyzer needs this value to construct the list
+ of points to draw on the display.
+
+ :Args:
+
+ x : int
+ Width of the display in pixel value. The default
+ width is 500.
+
+ """
+ pyoArgsAssert(self, "I", x)
+ self._width = x
+ [obj.setWidth(x) for obj in self._base_objs]
+
+ def setHeight(self, x):
+ """
+ Gives the height of the display to the analyzer.
+
+ The analyzer needs this value to construct the list
+ of points to draw on the display.
+
+ :Args:
+
+ x : int
+ Height of the display in pixel value. The default
+ height is 400.
+
+ """
+ pyoArgsAssert(self, "I", x)
+ self._height = x
+ [obj.setHeight(x) for obj in self._base_objs]
+
+ def view(self, title="Scope", wxnoserver=False):
+ """
+ Opens a window showing the result of the analysis.
+
+ :Args:
+
+ title : string, optional
+ Window title. Defaults to "Spectrum".
+ wxnoserver : boolean, optional
+ With wxPython graphical toolkit, if True, tells the
+ interpreter that there will be no server window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
+
+ """
+ pyoArgsAssert(self, "SB", title, wxnoserver)
+ createScopeWindow(self, title, wxnoserver)
+
+ def _setViewFrame(self, frame):
+ self.viewFrame = frame
+
+ def refreshView(self):
+ """
+ Updates the graphical display of the scope.
+
+ Called automatically by the internal timer.
+
+ """
+ self.points = [obj.display() for obj in self._base_objs]
+ if self.viewFrame != None:
+ self.viewFrame.update(self.points)
+
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to process."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+ @property
+ def length(self):
+ """float. Window length."""
+ return self._length
+ @length.setter
+ def length(self, x): self.setLength(x)
+
+ @property
+ def gain(self):
+ """float. Sets the gain of the analysis data."""
+ return self._gain
+ @gain.setter
+ def gain(self, x): self.setGain(x)
+
+class PeakAmp(PyoObject):
+ """
+ Peak amplitude follower.
+
+ Output signal is the continuous peak amplitude of an input signal.
+ A new peaking value is computed every buffer size. If `function`
+ argument is not None, it should be a function that will be called
+ every buffer size with a variable-length argument list containing
+ the peaking values of all object's streams. Useful for meter drawing.
+ Function definition must look like this:
+
+ >>> def getValues(*args)
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal to process.
+ function : callable, optional
+ Function that will be called with amplitude values in arguments.
+ Default to None.
+
+ .. note::
+
+ The out() method is bypassed. PeakAmp's signal can not be sent to
+ audio outs.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> sf = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True, mul=.4).out()
+ >>> amp = PeakAmp(sf)
+ >>> n = Noise(mul=Port(amp)).out(1)
+
+ """
+ def __init__(self, input, function=None, mul=1, add=0):
+ pyoArgsAssert(self, "oCOO", input, function, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._input = input
+ if callable(function):
+ self._function = getWeakMethodRef(function)
+ else:
+ self._function = None
+ self._in_fader = InputFader(input)
+ in_fader, mul, add, lmax = convertArgsToLists(self._in_fader, mul, add)
+ self._base_objs = [PeakAmp_base(wrap(in_fader,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+ sr = self.getSamplingRate()
+ bs = self.getBufferSize()
+ self._timer = Pattern(self._buildList, 0.06).play()
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Default to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ def setFunction(self, x):
+ """
+ Replace the `function` attribute.
+
+ :Args:
+
+ x : callable
+ New function to call with amplitude values in arguments.
+
+ """
+ pyoArgsAssert(self, "C", x)
+ if callable(x):
+ self._function = getWeakMethodRef(x)
+
+ def polltime(self, x):
+ """
+ Sets the delay, in seconds, between each call of the function.
+
+ :Args:
+
+ x : float
+ New polling time in seconds.
+
+ """
+ pyoArgsAssert(self, "N", x)
+ self._timer.time = x
+
+ def out(self, chnl=0, inc=1, dur=0, delay=0):
+ return self.play(dur, delay)
+
+ def _buildList(self):
+ if self._function != None:
+ values = [obj.getValue() for obj in self._base_objs]
+ self._function(*values)
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = []
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to process."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+ @property
+ def function(self):
+ """PyoObject. function signal to process."""
+ return self._function
+ @function.setter
+ def function(self, x): self.setFunction(x)
\ No newline at end of file
diff --git a/pyolib/arithmetic.py b/pyolib/arithmetic.py
index bf10013..f1a476b 100644
--- a/pyolib/arithmetic.py
+++ b/pyolib/arithmetic.py
@@ -3,23 +3,23 @@ Tools to perform arithmetic operations on audio signals.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
@@ -37,7 +37,7 @@ class Sin(PyoObject):
input : PyoObject
Input signal, angle in radians.
-
+
>>> s = Server().boot()
>>> s.start()
>>> import math
@@ -47,6 +47,7 @@ class Sin(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -56,7 +57,7 @@ class Sin(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -65,12 +66,13 @@ class Sin(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -96,6 +98,7 @@ class Cos(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -114,12 +117,13 @@ class Cos(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -152,6 +156,7 @@ class Tan(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -170,12 +175,13 @@ class Tan(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -203,6 +209,7 @@ class Abs(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -221,12 +228,13 @@ class Abs(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -259,6 +267,7 @@ class Sqrt(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -277,12 +286,13 @@ class Sqrt(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -291,7 +301,7 @@ class Log(PyoObject):
"""
Performs a natural log function on audio signal.
- Returns the natural log value of of audio signal as input.
+ Returns the natural log value of of audio signal as input.
Values less than 0.0 return 0.0.
:Parent: :py:class:`PyoObject`
@@ -311,6 +321,7 @@ class Log(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -329,12 +340,13 @@ class Log(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -343,7 +355,7 @@ class Log2(PyoObject):
"""
Performs a base 2 log function on audio signal.
- Returns the base 2 log value of audio signal as input.
+ Returns the base 2 log value of audio signal as input.
Values less than 0.0 return 0.0.
:Parent: :py:class:`PyoObject`
@@ -363,6 +375,7 @@ class Log2(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -381,12 +394,13 @@ class Log2(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -395,7 +409,7 @@ class Log10(PyoObject):
"""
Performs a base 10 log function on audio signal.
- Returns the base 10 log value of audio signal as input.
+ Returns the base 10 log value of audio signal as input.
Values less than 0.0 return 0.0.
:Parent: :py:class:`PyoObject`
@@ -415,6 +429,7 @@ class Log10(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -433,12 +448,13 @@ class Log10(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -447,8 +463,8 @@ class Atan2(PyoObject):
"""
Computes the principal value of the arc tangent of b/a.
- Computes the principal value of the arc tangent of b/a,
- using the signs of both arguments to determine the quadrant
+ Computes the principal value of the arc tangent of b/a,
+ using the signs of both arguments to determine the quadrant
of the return value.
:Parent: :py:class:`PyoObject`
@@ -470,6 +486,7 @@ class Atan2(PyoObject):
"""
def __init__(self, b=1, a=1, mul=1, add=0):
+ pyoArgsAssert(self, "OOOO", b, a, mul, add)
PyoObject.__init__(self, mul, add)
self._b = b
self._a = a
@@ -486,6 +503,7 @@ class Atan2(PyoObject):
new `b` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._b = x
x, lmax = convertArgsToLists(x)
[obj.setB(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -500,20 +518,21 @@ class Atan2(PyoObject):
new `a` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._a = x
x, lmax = convertArgsToLists(x)
[obj.setA(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def b(self):
- """float or PyoObject. Numerator."""
+ """float or PyoObject. Numerator."""
return self._b
@b.setter
def b(self, x): self.setB(x)
@property
def a(self):
- """float or PyoObject. Denominator."""
+ """float or PyoObject. Denominator."""
return self._a
@a.setter
def a(self, x): self.setA(x)
@@ -522,7 +541,7 @@ class Floor(PyoObject):
"""
Rounds to largest integral value not greater than audio signal.
- For each samples in the input signal, rounds to the largest integral
+ For each samples in the input signal, rounds to the largest integral
value not greater than the sample value.
:Parent: :py:class:`PyoObject`
@@ -542,6 +561,7 @@ class Floor(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -560,12 +580,13 @@ class Floor(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -574,7 +595,7 @@ class Ceil(PyoObject):
"""
Rounds to smallest integral value greater than or equal to the input signal.
- For each samples in the input signal, rounds to the smallest integral
+ For each samples in the input signal, rounds to the smallest integral
value greater than or equal to the sample value.
:Parent: :py:class:`PyoObject`
@@ -594,6 +615,7 @@ class Ceil(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -612,12 +634,13 @@ class Ceil(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -626,7 +649,7 @@ class Round(PyoObject):
"""
Rounds to the nearest integer value in a floating-point format.
- For each samples in the input signal, rounds to the nearest integer
+ For each samples in the input signal, rounds to the nearest integer
value of the sample value.
:Parent: :py:class:`PyoObject`
@@ -646,6 +669,7 @@ class Round(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -664,12 +688,65 @@ class Round(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
+
+class Tanh(PyoObject):
+ """
+ Performs a hyperbolic tangent function on audio signal.
+
+ Returns the hyperbolic tangent of audio signal as input.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal, angle in radians.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> import math
+ >>> a = Phasor(250, mul=math.pi*2)
+ >>> b = Tanh(Sin(a, mul=10), mul=0.3).mix(2).out()
+
+ """
+
+ def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._input = input
+ self._in_fader = InputFader(input)
+ in_fader, mul, add, lmax = convertArgsToLists(self._in_fader, mul, add)
+ self._base_objs = [M_Tanh_base(wrap(in_fader,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Default to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to process."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
\ No newline at end of file
diff --git a/pyolib/controls.py b/pyolib/controls.py
index 28dca81..7385c01 100644
--- a/pyolib/controls.py
+++ b/pyolib/controls.py
@@ -1,32 +1,32 @@
"""
-Objects designed to create parameter's control at audio rate.
+Objects designed to create parameter's control at audio rate.
-These objects can be used to create envelopes, line segments
-and conversion from python number to audio signal.
+These objects can be used to create envelopes, line segments
+and conversion from python number to audio signal.
-The audio streams of these objects can't be sent to the output
+The audio streams of these objects can't be sent to the output
soundcard.
-
+
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
from _core import *
@@ -40,13 +40,13 @@ from types import ListType, TupleType
class Fader(PyoObject):
"""
Fadein - fadeout envelope generator.
-
- Generate an amplitude envelope between 0 and 1 with control on fade
+
+ Generate an amplitude envelope between 0 and 1 with control on fade
times and total duration of the envelope.
-
- The play() method starts the envelope and is not called at the
+
+ The play() method starts the envelope and is not called at the
object creation time.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -56,15 +56,15 @@ class Fader(PyoObject):
fadeout : float, optional
Falling time of the envelope in seconds. Defaults to 0.1.
dur : float, optional
- Total duration of the envelope. Defaults to 0, which means wait
+ Total duration of the envelope. Defaults to 0, which means wait
for the stop() method to start the fadeout.
.. note::
The out() method is bypassed. Fader's signal can not be sent to audio outs.
-
+
The play() method starts the envelope.
-
+
The stop() calls the envelope's release phase if `dur` = 0.
>>> s = Server().boot()
@@ -74,9 +74,10 @@ class Fader(PyoObject):
>>> def repeat():
... f.play()
>>> pat = Pattern(function=repeat, time=2).play()
-
+
"""
def __init__(self, fadein=0.01, fadeout=0.1, dur=0, mul=1, add=0):
+ pyoArgsAssert(self, "nnnOO", fadein, fadeout, dur, mul, add)
PyoObject.__init__(self, mul, add)
self._fadein = fadein
self._fadeout = fadeout
@@ -90,13 +91,14 @@ class Fader(PyoObject):
def setFadein(self, x):
"""
Replace the `fadein` attribute.
-
+
:Args:
x : float
new `fadein` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._fadein = x
x, lmax = convertArgsToLists(x)
[obj.setFadein(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -104,13 +106,14 @@ class Fader(PyoObject):
def setFadeout(self, x):
"""
Replace the `fadeout` attribute.
-
+
:Args:
x : float
new `fadeout` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._fadeout = x
x, lmax = convertArgsToLists(x)
[obj.setFadeout(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -118,13 +121,14 @@ class Fader(PyoObject):
def setDur(self, x):
"""
Replace the `dur` attribute.
-
+
:Args:
x : float
new `dur` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._dur = x
x, lmax = convertArgsToLists(x)
[obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -137,21 +141,21 @@ class Fader(PyoObject):
@property
def fadein(self):
- """float. Rising time of the envelope in seconds."""
+ """float. Rising time of the envelope in seconds."""
return self._fadein
@fadein.setter
def fadein(self, x): self.setFadein(x)
@property
def fadeout(self):
- """float. Falling time of the envelope in seconds."""
+ """float. Falling time of the envelope in seconds."""
return self._fadeout
@fadeout.setter
def fadeout(self, x): self.setFadeout(x)
@property
def dur(self):
- """float. Total duration of the envelope."""
+ """float. Total duration of the envelope."""
return self._dur
@dur.setter
def dur(self, x): self.setDur(x)
@@ -160,14 +164,14 @@ class Fader(PyoObject):
class Adsr(PyoObject):
"""
Attack - Decay - Sustain - Release envelope generator.
-
- Calculates the classical ADSR envelope using linear segments.
- Duration can be set to 0 to give an infinite sustain. In this
+
+ Calculates the classical ADSR envelope using linear segments.
+ Duration can be set to 0 to give an infinite sustain. In this
case, the stop() method calls the envelope release part.
-
- The play() method starts the envelope and is not called at the
+
+ The play() method starts the envelope and is not called at the
object creation time.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -181,19 +185,17 @@ class Adsr(PyoObject):
release : float, optional
Duration of the release in seconds. Defaults to 0.1.
dur : float, optional
- Total duration of the envelope. Defaults to 0, which means wait
+ Total duration of the envelope. Defaults to 0, which means wait
for the stop() method to start the release phase.
-
-
+
+
.. note::
The out() method is bypassed. Adsr's signal can not be sent to audio outs.
The play() method starts the envelope.
-
+
The stop() calls the envelope's release phase if `dur` = 0.
-
- Shape of a classical Adsr:
>>> s = Server().boot()
>>> s.start()
@@ -202,9 +204,10 @@ class Adsr(PyoObject):
>>> def repeat():
... f.play()
>>> pat = Pattern(function=repeat, time=2).play()
-
+
"""
def __init__(self, attack=0.01, decay=0.05, sustain=0.707, release=0.1, dur=0, mul=1, add=0):
+ pyoArgsAssert(self, "nnnnnOO", attack, decay, sustain, release, dur, mul, add)
PyoObject.__init__(self, mul, add)
self._attack = attack
self._decay = decay
@@ -220,13 +223,14 @@ class Adsr(PyoObject):
def setAttack(self, x):
"""
Replace the `attack` attribute.
-
+
:Args:
x : float
new `attack` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._attack = x
x, lmax = convertArgsToLists(x)
[obj.setAttack(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -234,13 +238,14 @@ class Adsr(PyoObject):
def setDecay(self, x):
"""
Replace the `decay` attribute.
-
+
:Args:
x : float
new `decay` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._decay = x
x, lmax = convertArgsToLists(x)
[obj.setDecay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -248,13 +253,14 @@ class Adsr(PyoObject):
def setSustain(self, x):
"""
Replace the `sustain` attribute.
-
+
:Args:
x : float
new `sustain` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._sustain = x
x, lmax = convertArgsToLists(x)
[obj.setSustain(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -262,13 +268,14 @@ class Adsr(PyoObject):
def setRelease(self, x):
"""
Replace the `sustain` attribute.
-
+
:Args:
x : float
new `sustain` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._release = x
x, lmax = convertArgsToLists(x)
[obj.setRelease(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -276,13 +283,14 @@ class Adsr(PyoObject):
def setDur(self, x):
"""
Replace the `dur` attribute.
-
+
:Args:
x : float
new `dur` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._dur = x
x, lmax = convertArgsToLists(x)
[obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -297,54 +305,54 @@ class Adsr(PyoObject):
@property
def attack(self):
- """float. Duration of the attack phase in seconds."""
+ """float. Duration of the attack phase in seconds."""
return self._attack
@attack.setter
def attack(self, x): self.setAttack(x)
@property
def decay(self):
- """float. Duration of the decay phase in seconds."""
+ """float. Duration of the decay phase in seconds."""
return self._decay
@decay.setter
def decay(self, x): self.setDecay(x)
@property
def sustain(self):
- """float. Amplitude of the sustain phase."""
+ """float. Amplitude of the sustain phase."""
return self._sustain
@sustain.setter
def sustain(self, x): self.setSustain(x)
@property
def release(self):
- """float. Duration of the release phase in seconds."""
+ """float. Duration of the release phase in seconds."""
return self._release
@release.setter
def release(self, x): self.setRelease(x)
@property
def dur(self):
- """float. Total duration of the envelope."""
+ """float. Total duration of the envelope."""
return self._dur
@dur.setter
def dur(self, x): self.setDur(x)
class Linseg(PyoObject):
"""
- Trace a series of line segments between specified break-points.
-
- The play() method starts the envelope and is not called at the
+ Trace a series of line segments between specified break-points.
+
+ The play() method starts the envelope and is not called at the
object creation time.
-
+
:Parent: :py:class:`PyoObject`
:Args:
list : list of tuples
Points used to construct the line segments. Each tuple is a
- new point in the form (time, value).
-
+ new point in the form (time, value).
+
Times are given in seconds and must be in increasing order.
loop : boolean, optional
Looping mode. Defaults to False.
@@ -362,16 +370,11 @@ class Linseg(PyoObject):
>>> a = Sine(freq=l, mul=.3).mix(2).out()
>>> # then call:
>>> l.play()
-
+
"""
def __init__(self, list, loop=False, initToFirstVal=False, mul=1, add=0):
+ pyoArgsAssert(self, "lbbOO", list, loop, initToFirstVal, mul, add)
PyoObject.__init__(self, mul, add)
- if type(list) != ListType:
- print >> sys.stderr, 'TypeError: "list" argument of %s must be a list of tuples.\n' % self.__class__.__name__
- exit()
- if type(list[0]) != TupleType:
- print >> sys.stderr, 'TypeError: "list" argument of %s must be a list of tuples.\n' % self.__class__.__name__
- exit()
self._list = list
self._loop = loop
initToFirstVal, loop, mul, add, lmax = convertArgsToLists(initToFirstVal, loop, mul, add)
@@ -388,13 +391,14 @@ class Linseg(PyoObject):
def setList(self, x):
"""
Replace the `list` attribute.
-
+
:Args:
x : list of tuples
new `list` attribute.
-
+
"""
+ pyoArgsAssert(self, "l", x)
self._list = x
if type(x[0]) != ListType:
[obj.setList(x) for i, obj in enumerate(self._base_objs)]
@@ -409,7 +413,7 @@ class Linseg(PyoObject):
x : list of tuples
new `list` attribute.
-
+
"""
self.setList(x)
@@ -419,13 +423,14 @@ class Linseg(PyoObject):
def setLoop(self, x):
"""
Replace the `loop` attribute.
-
+
:Args:
x : boolean
new `loop` attribute.
-
+
"""
+ pyoArgsAssert(self, "b", x)
self._loop = x
x, lmax = convertArgsToLists(x)
[obj.setLoop(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -435,9 +440,9 @@ class Linseg(PyoObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
+ will be send to the object on mouse up.
- Ctrl+C with focus on the grapher will copy the list of points to the
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -449,14 +454,14 @@ class Linseg(PyoObject):
Set the min and max values of the Y axis of the graph. If
None, min and max are retrieve from the current list of points.
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for the
- server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for the
+ server GUI before showing the controller window.
"""
if xlen == None:
@@ -474,23 +479,23 @@ class Linseg(PyoObject):
@property
def list(self):
- """float. List of points (time, value)."""
+ """float. List of points (time, value)."""
return self._list
@list.setter
def list(self, x): self.setList(x)
@property
def loop(self):
- """boolean. Looping mode."""
+ """boolean. Looping mode."""
return self._loop
@loop.setter
def loop(self, x): self.setLoop(x)
class Expseg(PyoObject):
"""
- Trace a series of exponential segments between specified break-points.
+ Trace a series of exponential segments between specified break-points.
- The play() method starts the envelope and is not called at the
+ The play() method starts the envelope and is not called at the
object creation time.
:Parent: :py:class:`PyoObject`
@@ -499,8 +504,8 @@ class Expseg(PyoObject):
list : list of tuples
Points used to construct the line segments. Each tuple is a
- new point in the form (time, value).
-
+ new point in the form (time, value).
+
Times are given in seconds and must be in increasing order.
loop : boolean, optional
Looping mode. Defaults to False.
@@ -508,7 +513,7 @@ class Expseg(PyoObject):
Exponent factor. Used to control the slope of the curves.
Defaults to 10.
inverse : boolean, optional
- If True, downward slope will be inversed. Useful to create
+ If True, downward slope will be inversed. Useful to create
biexponential curves. Defaults to True.
initToFirstVal : boolean, optional
If True, audio buffer will be filled at initialization with the
@@ -527,13 +532,8 @@ class Expseg(PyoObject):
"""
def __init__(self, list, loop=False, exp=10, inverse=True, initToFirstVal=False, mul=1, add=0):
+ pyoArgsAssert(self, "lbnbbOO", list, loop, exp, inverse, initToFirstVal, mul, add)
PyoObject.__init__(self, mul, add)
- if type(list) != ListType:
- print >> sys.stderr, 'TypeError: "list" argument of %s must be a list of tuples.\n' % self.__class__.__name__
- exit()
- if type(list[0]) != TupleType:
- print >> sys.stderr, 'TypeError: "list" argument of %s must be a list of tuples.\n' % self.__class__.__name__
- exit()
self._list = list
self._loop = loop
self._exp = exp
@@ -559,6 +559,7 @@ class Expseg(PyoObject):
new `list` attribute.
"""
+ pyoArgsAssert(self, "l", x)
self._list = x
if type(x[0]) != ListType:
[obj.setList(x) for i, obj in enumerate(self._base_objs)]
@@ -575,6 +576,7 @@ class Expseg(PyoObject):
new `loop` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._loop = x
x, lmax = convertArgsToLists(x)
[obj.setLoop(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -589,6 +591,7 @@ class Expseg(PyoObject):
new `exp` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._exp = x
x, lmax = convertArgsToLists(x)
[obj.setExp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -603,6 +606,7 @@ class Expseg(PyoObject):
new `inverse` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._inverse = x
x, lmax = convertArgsToLists(x)
[obj.setInverse(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -627,9 +631,9 @@ class Expseg(PyoObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
+ will be send to the object on mouse up.
- Ctrl+C with focus on the grapher will copy the list of points to the
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -643,14 +647,14 @@ class Expseg(PyoObject):
None, min and max are retrieve from the current list of points.
Defaults to None.
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for the
- server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for the
+ server GUI before showing the controller window.
"""
if xlen == None:
@@ -668,28 +672,28 @@ class Expseg(PyoObject):
@property
def list(self):
- """float. List of points (time, value)."""
+ """float. List of points (time, value)."""
return self._list
@list.setter
def list(self, x): self.setList(x)
@property
def loop(self):
- """boolean. Looping mode."""
+ """boolean. Looping mode."""
return self._loop
@loop.setter
def loop(self, x): self.setLoop(x)
@property
def exp(self):
- """float. Exponent factor."""
+ """float. Exponent factor."""
return self._exp
@exp.setter
def exp(self, x): self.setExp(x)
@property
def inverse(self):
- """boolean. Inverse downward slope."""
+ """boolean. Inverse downward slope."""
return self._inverse
@inverse.setter
def inverse(self, x): self.setInverse(x)
@@ -697,11 +701,11 @@ class Expseg(PyoObject):
class SigTo(PyoObject):
"""
Convert numeric value to PyoObject signal with portamento.
-
- When `value` is changed, a ramp is applied from the current
+
+ When `value` is changed, a ramp is applied from the current
value to the new value. Can be used with PyoObject to apply
a linear portamento on an audio signal.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -712,7 +716,7 @@ class SigTo(PyoObject):
Ramp time, in seconds, to reach the new value. Defaults to 0.025.
init : float, optional
Initial value of the internal memory. Defaults to 0.
-
+
.. note::
The out() method is bypassed. SigTo's signal can not be sent to audio outs.
@@ -729,6 +733,7 @@ class SigTo(PyoObject):
"""
def __init__(self, value, time=0.025, init=0.0, mul=1, add=0):
+ pyoArgsAssert(self, "OnnOO", value, time, init, mul, add)
PyoObject.__init__(self, mul, add)
self._value = value
self._time = time
@@ -745,6 +750,7 @@ class SigTo(PyoObject):
Numerical value to convert.
"""
+ pyoArgsAssert(self, "O", x)
self._value = x
x, lmax = convertArgsToLists(x)
[obj.setValue(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -759,6 +765,7 @@ class SigTo(PyoObject):
New ramp time.
"""
+ pyoArgsAssert(self, "n", x)
self._time = x
x, lmax = convertArgsToLists(x)
[obj.setTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -769,14 +776,14 @@ class SigTo(PyoObject):
@property
def value(self):
- """float or PyoObject. Numerical value to convert."""
+ """float or PyoObject. Numerical value to convert."""
return self._value
@value.setter
- def value(self, x): self.setValue(x)
+ def value(self, x): self.setValue(x)
@property
def time(self):
- """float. Ramp time."""
+ """float. Ramp time."""
return self._time
@time.setter
- def time(self, x): self.setTime(x)
+ def time(self, x): self.setTime(x)
\ No newline at end of file
diff --git a/pyolib/dynamics.py b/pyolib/dynamics.py
index f4d6a88..5867977 100644
--- a/pyolib/dynamics.py
+++ b/pyolib/dynamics.py
@@ -4,23 +4,23 @@ Objects to modify the dynamic range and sample quality of audio signals.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
@@ -28,18 +28,18 @@ from _maps import *
class Clip(PyoObject):
"""
Clips a signal to a predefined limit.
-
+
:Parent: :py:class:`PyoObject`
:Args:
-
+
input : PyoObject
Input signal to process.
min : float or PyoObject, optional
Minimum possible value. Defaults to -1.
max : float or PyoObject, optional
Maximum possible value. Defaults to 1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True)
@@ -49,6 +49,7 @@ class Clip(PyoObject):
"""
def __init__(self, input, min=-1.0, max=1.0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, min, max, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._min = min
@@ -60,7 +61,7 @@ class Clip(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -69,19 +70,21 @@ class Clip(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setMin(self, x):
"""
Replace the `min` attribute.
-
+
:Args:
x : float or PyoObject
New `min` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -89,13 +92,14 @@ class Clip(PyoObject):
def setMax(self, x):
"""
Replace the `max` attribute.
-
+
:Args:
x : float or PyoObject
New `max` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -108,21 +112,21 @@ class Clip(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def min(self):
- """float or PyoObject. Minimum possible value."""
+ """float or PyoObject. Minimum possible value."""
return self._min
@min.setter
def min(self, x): self.setMin(x)
@property
def max(self):
- """float or PyoObject. Maximum possible value."""
+ """float or PyoObject. Maximum possible value."""
return self._max
@max.setter
def max(self, x): self.setMax(x)
@@ -146,7 +150,7 @@ class Mirror(PyoObject):
Maximum possible value. Defaults to 1.
.. note::
-
+
If `min` is higher than `max`, then the output will be the average of the two.
>>> s = Server().boot()
@@ -159,6 +163,7 @@ class Mirror(PyoObject):
"""
def __init__(self, input, min=0.0, max=1.0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, min, max, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._min = min
@@ -179,6 +184,7 @@ class Mirror(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -192,6 +198,7 @@ class Mirror(PyoObject):
New `min` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -206,6 +213,7 @@ class Mirror(PyoObject):
New `max` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -218,21 +226,21 @@ class Mirror(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def min(self):
- """float or PyoObject. Minimum possible value."""
+ """float or PyoObject. Minimum possible value."""
return self._min
@min.setter
def min(self, x): self.setMin(x)
@property
def max(self):
- """float or PyoObject. Maximum possible value."""
+ """float or PyoObject. Maximum possible value."""
return self._max
@max.setter
def max(self, x): self.setMax(x)
@@ -240,14 +248,14 @@ class Mirror(PyoObject):
class Degrade(PyoObject):
"""
Signal quality reducer.
-
- Degrade takes an audio signal and reduces the sampling rate and/or
+
+ Degrade takes an audio signal and reduces the sampling rate and/or
bit-depth as specified.
-
+
:Parent: :py:class:`PyoObject`
:Args:
-
+
input : PyoObject
Input signal to process.
bitdepth : float or PyoObject, optional
@@ -256,7 +264,7 @@ class Degrade(PyoObject):
srscale : float or PyoObject, optional
Sampling rate multiplier. Must be in range 0.0009765625 -> 1.
Defaults to 1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> t = SquareTable()
@@ -264,9 +272,10 @@ class Degrade(PyoObject):
>>> lfo = Sine(freq=.2, mul=6, add=8)
>>> lfo2 = Sine(freq=.25, mul=.45, add=.55)
>>> b = Degrade(a, bitdepth=lfo, srscale=lfo2, mul=.3).out()
-
+
"""
def __init__(self, input, bitdepth=16, srscale=1.0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, bitdepth, srscale, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._bitdepth = bitdepth
@@ -278,7 +287,7 @@ class Degrade(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -287,19 +296,21 @@ class Degrade(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setBitdepth(self, x):
"""
Replace the `bitdepth` attribute.
-
+
:Args:
x : float or PyoObject
New `bitdepth` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._bitdepth = x
x, lmax = convertArgsToLists(x)
[obj.setBitdepth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -307,13 +318,14 @@ class Degrade(PyoObject):
def setSrscale(self, x):
"""
Replace the `srscale` attribute.
-
+
:Args:
x : float or PyoObject
New `srscale` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._srscale = x
x, lmax = convertArgsToLists(x)
[obj.setSrscale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -326,21 +338,21 @@ class Degrade(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def bitdepth(self):
- """float or PyoObject. Signal quantization in bits."""
+ """float or PyoObject. Signal quantization in bits."""
return self._bitdepth
@bitdepth.setter
def bitdepth(self, x): self.setBitdepth(x)
@property
def srscale(self):
- """float or PyoObject. Sampling rate multiplier."""
+ """float or PyoObject. Sampling rate multiplier."""
return self._srscale
@srscale.setter
def srscale(self, x): self.setSrscale(x)
@@ -349,7 +361,7 @@ class Compress(PyoObject):
"""
Reduces the dynamic range of an audio signal.
- Compress reduces the volume of loud sounds or amplifies quiet sounds by
+ Compress reduces the volume of loud sounds or amplifies quiet sounds by
narrowing or compressing an audio signal's dynamic range.
:Parent: :py:class:`PyoObject`
@@ -359,42 +371,43 @@ class Compress(PyoObject):
input : PyoObject
Input signal to process.
thresh : float or PyoObject, optional
- Level, expressed in dB, above which the signal is reduced.
+ Level, expressed in dB, above which the signal is reduced.
Reference level is 0dB. Defaults to -20.
ratio : float or PyoObject, optional
- Determines the input/output ratio for signals above the
+ Determines the input/output ratio for signals above the
threshold. Defaults to 2.
risetime : float or PyoObject, optional
- Used in amplitude follower, time to reach upward value in
+ Used in amplitude follower, time to reach upward value in
seconds. Defaults to 0.01.
falltime : float or PyoObject, optional
- Used in amplitude follower, time to reach downward value in
+ Used in amplitude follower, time to reach downward value in
seconds. Defaults to 0.1.
lookahead : float, optional
Delay length, in ms, for the "look-ahead" buffer. Range is
0 -> 25 ms. Defaults to 5.0.
knee : float optional
Shape of the transfert function around the threshold, specified
- in the range 0 -> 1.
-
- A value of 0 means a hard knee and a value of 1.0 means a softer
+ in the range 0 -> 1.
+
+ A value of 0 means a hard knee and a value of 1.0 means a softer
knee. Defaults to 0.
outputAmp : boolean, optional
If True, the object's output signal will be the compression level
- alone, not the compressed signal.
-
- It can be useful if 2 or more channels need to linked on the same
+ alone, not the compressed signal.
+
+ It can be useful if 2 or more channels need to linked on the same
compression slope. Defaults to False.
-
- Available at initialization only.
+
+ Available at initialization only.
>>> s = Server().boot()
>>> s.start()
>>> a = SfPlayer(SNDS_PATH + '/transparent.aif', loop=True)
>>> b = Compress(a, thresh=-24, ratio=6, risetime=.01, falltime=.2, knee=0.5).mix(2).out()
-
+
"""
def __init__(self, input, thresh=-20, ratio=2, risetime=0.01, falltime=0.1, lookahead=5.0, knee=0, outputAmp=False, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOnnbOO", input, thresh, ratio, risetime, falltime, lookahead, knee, outputAmp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._thresh = thresh
@@ -410,7 +423,7 @@ class Compress(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -419,47 +432,51 @@ class Compress(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setThresh(self, x):
"""
Replace the `thresh` attribute.
-
+
:Args:
x : float or PyoObject
New `thresh` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._thresh = x
x, lmax = convertArgsToLists(x)
[obj.setThresh(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setRatio(self, x):
"""
Replace the `ratio` attribute.
-
+
:Args:
x : float or PyoObject
New `ratio` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._ratio = x
x, lmax = convertArgsToLists(x)
[obj.setRatio(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setRiseTime(self, x):
"""
Replace the `risetime` attribute.
-
+
:Args:
x : float or PyoObject
New `risetime` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._risetime = x
x, lmax = convertArgsToLists(x)
[obj.setRiseTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -467,13 +484,14 @@ class Compress(PyoObject):
def setFallTime(self, x):
"""
Replace the `falltime` attribute.
-
+
:Args:
x : float or PyoObject
New `falltime` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._falltime = x
x, lmax = convertArgsToLists(x)
[obj.setFallTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -488,6 +506,7 @@ class Compress(PyoObject):
New `lookahead` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._lookahead = x
x, lmax = convertArgsToLists(x)
[obj.setLookAhead(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -502,6 +521,7 @@ class Compress(PyoObject):
New `knee` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._knee = x
x, lmax = convertArgsToLists(x)
[obj.setKnee(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -518,28 +538,28 @@ class Compress(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def thresh(self):
- """float or PyoObject. Level above which the signal is reduced."""
+ """float or PyoObject. Level above which the signal is reduced."""
return self._thresh
@thresh.setter
def thresh(self, x): self.setThresh(x)
@property
def ratio(self):
- """float or PyoObject. in/out ratio for signals above the threshold."""
+ """float or PyoObject. in/out ratio for signals above the threshold."""
return self._ratio
@ratio.setter
def ratio(self, x): self.setRatio(x)
@property
def risetime(self):
- """float or PyoObject. Time to reach upward value in seconds."""
+ """float or PyoObject. Time to reach upward value in seconds."""
return self._risetime
@risetime.setter
def risetime(self, x): self.setRiseTime(x)
@@ -550,7 +570,7 @@ class Compress(PyoObject):
return self._falltime
@falltime.setter
def falltime(self, x): self.setFallTime(x)
-
+
@property
def lookahead(self):
"""float. Delay length, in ms, of the "look-ahead" buffer."""
@@ -569,12 +589,12 @@ class Gate(PyoObject):
"""
Allows a signal to pass only when its amplitude is above a set threshold.
- A noise gate is used when the level of the signal is below the level of
- the noise floor. The threshold is set above the level of the noise and so when
- there is no signal the gate is closed. A noise gate does not remove noise
- from the signal. When the gate is open both the signal and the noise will
+ A noise gate is used when the level of the signal is below the level of
+ the noise floor. The threshold is set above the level of the noise and so when
+ there is no signal the gate is closed. A noise gate does not remove noise
+ from the signal. When the gate is open both the signal and the noise will
pass through.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -582,7 +602,7 @@ class Gate(PyoObject):
input : PyoObject
Input signal to process.
thresh : float or PyoObject, optional
- Level, expressed in dB, below which the gate is closed.
+ Level, expressed in dB, below which the gate is closed.
Reference level is 0dB. Defaults to -70.
risetime : float or PyoObject, optional
Time to open the gate in seconds. Defaults to 0.01.
@@ -593,11 +613,11 @@ class Gate(PyoObject):
0 -> 25 ms. Defaults to 5.0.
outputAmp : boolean, optional
If True, the object's output signal will be the gating level
- alone, not the gated signal.
-
- It can be useful if 2 or more channels need to linked on the
+ alone, not the gated signal.
+
+ It can be useful if 2 or more channels need to linked on the
same gating slope. Defaults to False.
-
+
Available at initialization only.
>>> s = Server().boot()
@@ -607,6 +627,7 @@ class Gate(PyoObject):
"""
def __init__(self, input, thresh=-70, risetime=0.01, falltime=0.05, lookahead=5.0, outputAmp=False, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOnbOO", input, thresh, risetime, falltime, lookahead, outputAmp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._thresh = thresh
@@ -629,6 +650,7 @@ class Gate(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -642,6 +664,7 @@ class Gate(PyoObject):
New `thresh` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._thresh = x
x, lmax = convertArgsToLists(x)
[obj.setThresh(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -656,6 +679,7 @@ class Gate(PyoObject):
New `risetime` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._risetime = x
x, lmax = convertArgsToLists(x)
[obj.setRiseTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -670,6 +694,7 @@ class Gate(PyoObject):
New `falltime` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._falltime = x
x, lmax = convertArgsToLists(x)
[obj.setFallTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -684,6 +709,7 @@ class Gate(PyoObject):
New `lookahead` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._lookahead = x
x, lmax = convertArgsToLists(x)
[obj.setLookAhead(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -698,21 +724,21 @@ class Gate(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def thresh(self):
- """float or PyoObject. Level below which the gate is closed."""
+ """float or PyoObject. Level below which the gate is closed."""
return self._thresh
@thresh.setter
def thresh(self, x): self.setThresh(x)
@property
def risetime(self):
- """float or PyoObject. Time to open the gate in seconds."""
+ """float or PyoObject. Time to open the gate in seconds."""
return self._risetime
@risetime.setter
def risetime(self, x): self.setRiseTime(x)
@@ -756,6 +782,7 @@ class Balance(PyoObject):
"""
def __init__(self, input, input2, freq=10, mul=1, add=0):
+ pyoArgsAssert(self, "ooOOO", input, input2, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._input2 = input2
@@ -768,7 +795,7 @@ class Balance(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
Input signal to process.
:Args:
@@ -779,13 +806,14 @@ class Balance(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setInput2(self, x, fadetime=0.05):
"""
Replace the `input2` attribute.
-
+
Comparator signal.
:Args:
@@ -796,13 +824,14 @@ class Balance(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input2 = x
self._in_fader2.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
Cutoff frequency of the lowpass filter, in Hertz.
:Args:
@@ -811,6 +840,7 @@ class Balance(PyoObject):
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -821,21 +851,21 @@ class Balance(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def input2(self):
- """PyoObject. Comparator signal."""
+ """PyoObject. Comparator signal."""
return self._input2
@input2.setter
def input2(self, x): self.setInput2(x)
@property
def freq(self):
- """float or PyoObject. Cutoff frequency of the lowpass filter."""
+ """float or PyoObject. Cutoff frequency of the lowpass filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@@ -843,17 +873,17 @@ class Balance(PyoObject):
class Min(PyoObject):
"""
Outputs the minimum of two values.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
comp : float or PyoObject, optional
Comparison value. If `input` is lower than this value,
`input` is send to the output, otherwise, `comp` is outputted.
-
+
>>> s = Server().boot()
>>> s.start()
>>> # Triangle wave
@@ -863,6 +893,7 @@ class Min(PyoObject):
"""
def __init__(self, input, comp=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, comp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._comp = comp
@@ -873,7 +904,7 @@ class Min(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -882,19 +913,21 @@ class Min(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setComp(self, x):
"""
Replace the `comp` attribute.
-
+
:Args:
x : float or PyoObject
New `comp` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._comp = x
x, lmax = convertArgsToLists(x)
[obj.setComp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -902,17 +935,17 @@ class Min(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0,1,"lin", "comp", self._comp), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def comp(self):
- """float or PyoObject. Comparison value."""
+ """float or PyoObject. Comparison value."""
return self._comp
@comp.setter
def comp(self, x): self.setComp(x)
@@ -920,17 +953,17 @@ class Min(PyoObject):
class Max(PyoObject):
"""
Outputs the maximum of two values.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
comp : float or PyoObject, optional
Comparison value. If `input` is higher than this value,
`input` is send to the output, otherwise, `comp` is outputted.
-
+
>>> s = Server().boot()
>>> s.start()
>>> # Assimetrical clipping
@@ -940,6 +973,7 @@ class Max(PyoObject):
"""
def __init__(self, input, comp=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, comp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._comp = comp
@@ -950,7 +984,7 @@ class Max(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -959,19 +993,21 @@ class Max(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setComp(self, x):
"""
Replace the `comp` attribute.
-
+
:Args:
x : float or PyoObject
New `comp` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._comp = x
x, lmax = convertArgsToLists(x)
[obj.setComp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -979,17 +1015,17 @@ class Max(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0,1,"lin", "comp", self._comp), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def comp(self):
- """float or PyoObject. Comparison value."""
+ """float or PyoObject. Comparison value."""
return self._comp
@comp.setter
def comp(self, x): self.setComp(x)
diff --git a/pyolib/effects.py b/pyolib/effects.py
index 068206c..0e4e915 100644
--- a/pyolib/effects.py
+++ b/pyolib/effects.py
@@ -5,32 +5,34 @@ as distortions, delays, chorus and reverbs.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
+from generators import Sine
+from filters import Hilbert
class Disto(PyoObject):
"""
Arc tangent distortion.
- Apply an arc tangent distortion with controllable drive to the input signal.
+ Apply an arc tangent distortion with controllable drive to the input signal.
:Parent: :py:class:`PyoObject`
@@ -39,10 +41,10 @@ class Disto(PyoObject):
input : PyoObject
Input signal to process.
drive : float or PyoObject, optional
- Amount of distortion applied to the signal, between 0 and 1.
+ Amount of distortion applied to the signal, between 0 and 1.
Defaults to 0.75.
slope : float or PyoObject, optional
- Slope of the lowpass filter applied after distortion,
+ Slope of the lowpass filter applied after distortion,
between 0 and 1. Defaults to 0.5.
>>> s = Server().boot()
@@ -53,6 +55,7 @@ class Disto(PyoObject):
"""
def __init__(self, input, drive=.75, slope=.5, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, drive, slope, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._drive = drive
@@ -64,7 +67,7 @@ class Disto(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -73,19 +76,21 @@ class Disto(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setDrive(self, x):
"""
Replace the `drive` attribute.
-
+
:Args:
x : float or PyoObject
New `drive` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._drive = x
x, lmax = convertArgsToLists(x)
[obj.setDrive(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -93,13 +98,14 @@ class Disto(PyoObject):
def setSlope(self, x):
"""
Replace the `slope` attribute.
-
+
:Args:
x : float or PyoObject
New `slope` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._slope = x
x, lmax = convertArgsToLists(x)
[obj.setSlope(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -112,21 +118,21 @@ class Disto(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def drive(self):
- """float or PyoObject. Amount of distortion."""
+ """float or PyoObject. Amount of distortion."""
return self._drive
@drive.setter
def drive(self, x): self.setDrive(x)
@property
def slope(self):
- """float or PyoObject. Slope of the lowpass filter."""
+ """float or PyoObject. Slope of the lowpass filter."""
return self._slope
@slope.setter
def slope(self, x): self.setSlope(x)
@@ -147,18 +153,18 @@ class Delay(PyoObject):
Amount of output signal sent back into the delay line.
Defaults to 0.
maxdelay : float, optional
- Maximum delay length in seconds. Available only at initialization.
+ Maximum delay length in seconds. Available only at initialization.
Defaults to 1.
.. note::
The minimum delay time allowed with Delay is one sample. It can be computed
with :
-
+
onesamp = 1.0 / s.getSamplingRate()
-
+
.. seealso::
-
+
:py:class:`SDelay`, :py:class:`Waveguide`
>>> s = Server().boot()
@@ -168,6 +174,7 @@ class Delay(PyoObject):
"""
def __init__(self, input, delay=0.25, feedback=0, maxdelay=1, mul=1, add=0):
+ pyoArgsAssert(self, "oOOnOO", input, delay, feedback, maxdelay, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._delay = delay
@@ -180,7 +187,7 @@ class Delay(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -189,19 +196,21 @@ class Delay(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setDelay(self, x):
"""
Replace the `delay` attribute.
-
+
:Args:
x : float or PyoObject
New `delay` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._delay = x
x, lmax = convertArgsToLists(x)
[obj.setDelay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -209,13 +218,14 @@ class Delay(PyoObject):
def setFeedback(self, x):
"""
Replace the `feedback` attribute.
-
+
:Args:
x : float or PyoObject
New `feedback` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -223,7 +233,7 @@ class Delay(PyoObject):
def reset(self):
"""
Reset the memory buffer to zeros.
-
+
"""
[obj.reset() for obj in self._base_objs]
@@ -235,21 +245,21 @@ class Delay(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to delayed."""
+ """PyoObject. Input signal to delayed."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
-
+
@property
def delay(self):
- """float or PyoObject. Delay time in seconds."""
+ """float or PyoObject. Delay time in seconds."""
return self._delay
@delay.setter
def delay(self, x): self.setDelay(x)
@property
def feedback(self):
- """float or PyoObject. Amount of output signal sent back into the delay line."""
+ """float or PyoObject. Amount of output signal sent back into the delay line."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
@@ -267,11 +277,11 @@ class SDelay(PyoObject):
delay : float or PyoObject, optional
Delay time in seconds. Defaults to 0.25.
maxdelay : float, optional
- Maximum delay length in seconds. Available only at initialization.
+ Maximum delay length in seconds. Available only at initialization.
Defaults to 1.
.. seealso::
-
+
:py:class:`Delay`, :py:class:`Delay1`
>>> s = Server().boot()
@@ -283,6 +293,7 @@ class SDelay(PyoObject):
"""
def __init__(self, input, delay=0.25, maxdelay=1, mul=1, add=0):
+ pyoArgsAssert(self, "oOnOO", input, delay, maxdelay, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._delay = delay
@@ -303,6 +314,7 @@ class SDelay(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -316,6 +328,7 @@ class SDelay(PyoObject):
New `delay` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._delay = x
x, lmax = convertArgsToLists(x)
[obj.setDelay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -323,7 +336,7 @@ class SDelay(PyoObject):
def reset(self):
"""
Reset the memory buffer to zeros.
-
+
"""
[obj.reset() for obj in self._base_objs]
@@ -334,14 +347,14 @@ class SDelay(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to delayed."""
+ """PyoObject. Input signal to delayed."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def delay(self):
- """float or PyoObject. Delay time in seconds."""
+ """float or PyoObject. Delay time in seconds."""
return self._delay
@delay.setter
def delay(self, x): self.setDelay(x)
@@ -350,7 +363,7 @@ class Waveguide(PyoObject):
"""
Basic waveguide model.
- This waveguide model consisting of one delay-line with a simple
+ This waveguide model consisting of one delay-line with a simple
lowpass filtering and lagrange interpolation.
:Parent: :py:class:`PyoObject`
@@ -360,13 +373,13 @@ class Waveguide(PyoObject):
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
- Frequency, in cycle per second, of the waveguide (i.e. the inverse
+ Frequency, in cycle per second, of the waveguide (i.e. the inverse
of delay time). Defaults to 100.
dur : float or PyoObject, optional
- Duration, in seconds, for the waveguide to drop 40 dB below it's
+ Duration, in seconds, for the waveguide to drop 40 dB below it's
maxima. Defaults to 10.
minfreq : float, optional
- Minimum possible frequency, used to initialized delay length.
+ Minimum possible frequency, used to initialized delay length.
Available only at initialization. Defaults to 20.
>>> s = Server().boot()
@@ -377,6 +390,7 @@ class Waveguide(PyoObject):
"""
def __init__(self, input, freq=100, dur=10, minfreq=20, mul=1, add=0):
+ pyoArgsAssert(self, "oOOnOO", input, freq, dur, minfreq, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -388,7 +402,7 @@ class Waveguide(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -397,19 +411,21 @@ class Waveguide(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -417,13 +433,14 @@ class Waveguide(PyoObject):
def setDur(self, x):
"""
Replace the `dur` attribute.
-
+
:Args:
x : float or PyoObject
New `dur` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._dur = x
x, lmax = convertArgsToLists(x)
[obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -436,21 +453,21 @@ class Waveguide(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
-
+
@property
def freq(self):
- """float or PyoObject. Frequency in cycle per second."""
+ """float or PyoObject. Frequency in cycle per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def dur(self):
- """float or PyoObject. Resonance duration in seconds."""
+ """float or PyoObject. Resonance duration in seconds."""
return self._dur
@dur.setter
def dur(self, x): self.setDur(x)
@@ -469,16 +486,16 @@ class AllpassWG(PyoObject):
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
- Frequency, in cycle per second, of the waveguide (i.e. the inverse
+ Frequency, in cycle per second, of the waveguide (i.e. the inverse
of delay time). Defaults to 100.
feed : float or PyoObject, optional
Amount of output signal (between 0 and 1) sent back into the delay line.
Defaults to 0.95.
detune : float or PyoObject, optional
- Control the depth of the allpass delay-line filter, i.e. the depth of
+ Control the depth of the allpass delay-line filter, i.e. the depth of
the detuning. Should be in the range 0 to 1. Defaults to 0.5.
minfreq : float, optional
- Minimum possible frequency, used to initialized delay length.
+ Minimum possible frequency, used to initialized delay length.
Available only at initialization. Defaults to 20.
>>> s = Server().boot()
@@ -491,6 +508,7 @@ class AllpassWG(PyoObject):
"""
def __init__(self, input, freq=100, feed=0.95, detune=0.5, minfreq=20, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOnOO", input, freq, feed, detune, minfreq, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -512,6 +530,7 @@ class AllpassWG(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -525,6 +544,7 @@ class AllpassWG(PyoObject):
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -539,6 +559,7 @@ class AllpassWG(PyoObject):
New `feed` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._feed = x
x, lmax = convertArgsToLists(x)
[obj.setFeed(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -553,6 +574,7 @@ class AllpassWG(PyoObject):
New `detune` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._detune = x
x, lmax = convertArgsToLists(x)
[obj.setDetune(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -566,28 +588,28 @@ class AllpassWG(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Frequency in cycle per second."""
+ """float or PyoObject. Frequency in cycle per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def feed(self):
- """float or PyoObject. Amount of output signal sent back into the delay line."""
+ """float or PyoObject. Amount of output signal sent back into the delay line."""
return self._feed
@feed.setter
def feed(self, x): self.setFeed(x)
@property
def detune(self):
- """float or PyoObject. Depth of the detuning."""
+ """float or PyoObject. Depth of the detuning."""
return self._detune
@detune.setter
def detune(self, x): self.setDetune(x)
@@ -596,9 +618,9 @@ class Freeverb(PyoObject):
"""
Implementation of Jezar's Freeverb.
- Freeverb is a reverb unit generator based on Jezar's public domain
- C++ sources, composed of eight parallel comb filters, followed by four
- allpass units in series. Filters on each stream are slightly detuned
+ Freeverb is a reverb unit generator based on Jezar's public domain
+ C++ sources, composed of eight parallel comb filters, followed by four
+ allpass units in series. Filters on each stream are slightly detuned
in order to create multi-channel effects.
:Parent: :py:class:`PyoObject`
@@ -608,14 +630,14 @@ class Freeverb(PyoObject):
input : PyoObject
Input signal to process.
size : float or PyoObject, optional
- Controls the length of the reverb, between 0 and 1. A higher
+ Controls the length of the reverb, between 0 and 1. A higher
value means longer reverb. Defaults to 0.5.
damp : float or PyoObject, optional
- High frequency attenuation, between 0 and 1. A higher value
- will result in a faster decay of the high frequency range.
+ High frequency attenuation, between 0 and 1. A higher value
+ will result in a faster decay of the high frequency range.
Defaults to 0.5.
bal : float or PyoObject, optional
- Balance between wet and dry signal, between 0 and 1. 0 means no
+ Balance between wet and dry signal, between 0 and 1. 0 means no
reverb. Defaults to 0.5.
>>> s = Server().boot()
@@ -625,6 +647,7 @@ class Freeverb(PyoObject):
"""
def __init__(self, input, size=.5, damp=.5, bal=.5, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOO", input, size, damp, bal, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._size = size
@@ -637,7 +660,7 @@ class Freeverb(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -646,19 +669,21 @@ class Freeverb(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setSize(self, x):
"""
Replace the `size` attribute.
-
+
:Args:
x : float or PyoObject
New `size` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._size = x
x, lmax = convertArgsToLists(x)
[obj.setSize(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -666,13 +691,14 @@ class Freeverb(PyoObject):
def setDamp(self, x):
"""
Replace the `damp` attribute.
-
+
:Args:
x : float or PyoObject
New `damp` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._damp = x
x, lmax = convertArgsToLists(x)
[obj.setDamp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -680,13 +706,14 @@ class Freeverb(PyoObject):
def setBal(self, x):
"""
Replace the `bal` attribute.
-
+
:Args:
x : float or PyoObject
New `bal` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._bal = x
x, lmax = convertArgsToLists(x)
[obj.setMix(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -700,28 +727,28 @@ class Freeverb(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def size(self):
- """float or PyoObject. Room size."""
+ """float or PyoObject. Room size."""
return self._size
@size.setter
def size(self, x): self.setSize(x)
@property
def damp(self):
- """float or PyoObject. High frequency damping."""
+ """float or PyoObject. High frequency damping."""
return self._damp
@damp.setter
def damp(self, x): self.setDamp(x)
@property
def bal(self):
- """float or PyoObject. Balance between wet and dry signal."""
+ """float or PyoObject. Balance between wet and dry signal."""
return self._bal
@bal.setter
def bal(self, x): self.setBal(x)
@@ -730,7 +757,7 @@ class Convolve(PyoObject):
"""
Implements filtering using circular convolution.
- A circular convolution is defined as the integral of the product of two
+ A circular convolution is defined as the integral of the product of two
functions after one is reversed and shifted.
:Parent: :py:class:`PyoObject`
@@ -742,12 +769,12 @@ class Convolve(PyoObject):
table : PyoTableObject
Table containning the impulse response.
size : int
- Length, in samples, of the convolution. Available at initialization
- time only.
-
- If the table changes during the performance, its size must egal or
- greater than this value.
-
+ Length, in samples, of the convolution. Available at initialization
+ time only.
+
+ If the table changes during the performance, its size must egal or
+ greater than this value.
+
If greater only the first `size` samples will be used.
.. note::
@@ -757,9 +784,9 @@ class Convolve(PyoObject):
Usually convolution generates a high amplitude level, take care of the
`mul` parameter!
-
+
.. seealso::
-
+
:py:class:`Follower`
>>> s = Server().boot()
@@ -770,18 +797,19 @@ class Convolve(PyoObject):
"""
def __init__(self, input, table, size, mul=1, add=0):
+ pyoArgsAssert(self, "otiOO", input, table, size, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._table = table
self._size = size
self._in_fader = InputFader(input)
- in_fader, table, size, mul, add, lmax = convertArgsToLists(self._in_fader, table, size, mul, add)
+ in_fader, table, size, mul, add, lmax = convertArgsToLists(self._in_fader, table, size, mul, add)
self._base_objs = [Convolve_base(wrap(in_fader,i), wrap(table,i), wrap(size,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -790,43 +818,45 @@ class Convolve(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Input signal to filter."""
+ """PyoObject. Input signal to filter."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def table(self):
- """PyoTableObject. Table containing the impulse response."""
+ """PyoTableObject. Table containing the impulse response."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
class WGVerb(PyoObject):
"""
- 8 delay line mono FDN reverb.
+ 8 delay lines mono FDN reverb.
- 8 delay line FDN reverb, with feedback matrix based upon physical
- modeling scattering junction of 8 lossless waveguides of equal
+ 8 delay lines FDN reverb, with feedback matrix based upon physical
+ modeling scattering junction of 8 lossless waveguides of equal
characteristic impedance.
:Parent: :py:class:`PyoObject`
@@ -839,13 +869,13 @@ class WGVerb(PyoObject):
Amount of output signal sent back into the delay lines.
Defaults to 0.5.
- 0.6 gives a good small "live" room sound, 0.8 a small hall,
+ 0.6 gives a good small "live" room sound, 0.8 a small hall,
and 0.9 a large hall.
cutoff : float or PyoObject, optional
- cutoff frequency of simple first order lowpass filters in the
+ cutoff frequency of simple first order lowpass filters in the
feedback loop of delay lines, in Hz. Defaults to 5000.
bal : float or PyoObject, optional
- Balance between wet and dry signal, between 0 and 1. 0 means no
+ Balance between wet and dry signal, between 0 and 1. 0 means no
reverb. Defaults to 0.5.
>>> s = Server().boot()
@@ -855,6 +885,7 @@ class WGVerb(PyoObject):
"""
def __init__(self, input, feedback=0.5, cutoff=5000, bal=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOO", input, feedback, cutoff, bal, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._feedback = feedback
@@ -867,7 +898,7 @@ class WGVerb(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -876,19 +907,21 @@ class WGVerb(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setFeedback(self, x):
"""
Replace the `feedback` attribute.
-
+
:Args:
x : float or PyoObject
New `feedback` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -896,13 +929,14 @@ class WGVerb(PyoObject):
def setCutoff(self, x):
"""
Replace the `cutoff` attribute.
-
+
:Args:
x : float or PyoObject
New `cutoff` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._cutoff = x
x, lmax = convertArgsToLists(x)
[obj.setCutoff(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -910,13 +944,14 @@ class WGVerb(PyoObject):
def setBal(self, x):
"""
Replace the `bal` attribute.
-
+
:Args:
x : float or PyoObject
New `bal` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._bal = x
x, lmax = convertArgsToLists(x)
[obj.setMix(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -930,28 +965,28 @@ class WGVerb(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def feedback(self):
- """float or PyoObject. Amount of output signal sent back into the delay lines."""
+ """float or PyoObject. Amount of output signal sent back into the delay lines."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
@property
def cutoff(self):
- """float or PyoObject. Lowpass filter cutoff in Hz."""
+ """float or PyoObject. Lowpass filter cutoff in Hz."""
return self._cutoff
@cutoff.setter
def cutoff(self, x): self.setCutoff(x)
@property
def bal(self):
- """float or PyoObject. wet - dry balance."""
+ """float or PyoObject. wet - dry balance."""
return self._bal
@bal.setter
def bal(self, x): self.setBal(x)
@@ -960,9 +995,9 @@ class Chorus(PyoObject):
"""
8 modulated delay lines chorus processor.
- A chorus effect occurs when individual sounds with roughly the same timbre and
+ A chorus effect occurs when individual sounds with roughly the same timbre and
nearly (but never exactly) the same pitch converge and are perceived as one.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -975,7 +1010,7 @@ class Chorus(PyoObject):
Amount of output signal sent back into the delay lines.
Defaults to 0.25.
bal : float or PyoObject, optional
- Balance between wet and dry signals, between 0 and 1. 0 means no
+ Balance between wet and dry signals, between 0 and 1. 0 means no
chorus. Defaults to 0.5.
>>> s = Server().boot()
@@ -985,6 +1020,7 @@ class Chorus(PyoObject):
"""
def __init__(self, input, depth=1, feedback=0.25, bal=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOO", input, depth, feedback, bal, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._depth = depth
@@ -1006,6 +1042,7 @@ class Chorus(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1019,6 +1056,7 @@ class Chorus(PyoObject):
New `depth` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._depth = x
x, lmax = convertArgsToLists(x)
[obj.setDepth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1033,6 +1071,7 @@ class Chorus(PyoObject):
New `feedback` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1047,6 +1086,7 @@ class Chorus(PyoObject):
New `bal` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._bal = x
x, lmax = convertArgsToLists(x)
[obj.setMix(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1060,28 +1100,28 @@ class Chorus(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def depth(self):
- """float or PyoObject. Chorus depth, between 0 and 5."""
+ """float or PyoObject. Chorus depth, between 0 and 5."""
return self._depth
@depth.setter
def depth(self, x): self.setDepth(x)
@property
def feedback(self):
- """float or PyoObject. Amount of output signal sent back into the delay lines."""
+ """float or PyoObject. Amount of output signal sent back into the delay lines."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
@property
def bal(self):
- """float or PyoObject. wet - dry balance."""
+ """float or PyoObject. wet - dry balance."""
return self._bal
@bal.setter
def bal(self, x): self.setBal(x)
@@ -1102,7 +1142,7 @@ class Harmonizer(PyoObject):
Amount of output signal sent back into the delay line.
Defaults to 0.
winsize : float, optional
- Window size in seconds (max = 1.0).
+ Window size in seconds (max = 1.0).
Defaults to 0.1.
>>> s = Server().boot()
@@ -1112,6 +1152,7 @@ class Harmonizer(PyoObject):
"""
def __init__(self, input, transpo=-7.0, feedback=0, winsize=0.1, mul=1, add=0):
+ pyoArgsAssert(self, "oOOnOO", input, transpo, feedback, winsize, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._transpo = transpo
@@ -1133,6 +1174,7 @@ class Harmonizer(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1146,6 +1188,7 @@ class Harmonizer(PyoObject):
New `transpo` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._transpo = x
x, lmax = convertArgsToLists(x)
[obj.setTranspo(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1160,6 +1203,7 @@ class Harmonizer(PyoObject):
New `feedback` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1174,6 +1218,7 @@ class Harmonizer(PyoObject):
New `winsize` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._winsize = x
x, lmax = convertArgsToLists(x)
[obj.setWinsize(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1187,28 +1232,28 @@ class Harmonizer(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to delayed."""
+ """PyoObject. Input signal to delayed."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def transpo(self):
- """float or PyoObject. Transposition factor in semitone."""
+ """float or PyoObject. Transposition factor in semitone."""
return self._transpo
@transpo.setter
def transpo(self, x): self.setTranspo(x)
@property
def feedback(self):
- """float or PyoObject. Amount of output signal sent back into the delay line."""
+ """float or PyoObject. Amount of output signal sent back into the delay line."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
@property
def winsize(self):
- """float. Window size in seconds (max = 1.0)."""
+ """float. Window size in seconds (max = 1.0)."""
return self._winsize
@winsize.setter
def winsize(self, x): self.setWinsize(x)
@@ -1216,14 +1261,14 @@ class Harmonizer(PyoObject):
class Delay1(PyoObject):
"""
Delays a signal by one sample.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
-
+
>>> s = Server().boot()
>>> s.start()
>>> # 50th order FIR lowpass filter
@@ -1231,11 +1276,12 @@ class Delay1(PyoObject):
>>> objs = [Noise(.3)]
>>> for i in range(order):
... objs.append(Delay1(objs[-1], add=objs[-1]))
- ... objs.append(objs[-1] * 0.5)
+ ... objs.append(objs[-1] * 0.5)
>>> out = Sig(objs[-1]).out()
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -1245,7 +1291,7 @@ class Delay1(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1254,12 +1300,13 @@ class Delay1(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to delayed."""
+ """PyoObject. Input signal to delayed."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1271,11 +1318,11 @@ class STRev(PyoObject):
Stereo reverb based on WGVerb (8 delay line FDN reverb). A mono
input will produce two audio streams, left and right channels.
Therefore, a stereo input will produce four audio streams, left
- and right channels for each input channel. Position of input
+ and right channels for each input channel. Position of input
streams can be set with the `inpos` argument. To achieve a stereo
reverb, delay line lengths are slightly differents on both channels,
- but also, pre-delays length and filter cutoff of both channels will
- be affected to reflect the input position.
+ but also, pre-delays length and filter cutoff of both channels will
+ be affected to reflect the input position.
:Parent: :py:class:`PyoObject`
@@ -1287,14 +1334,14 @@ class STRev(PyoObject):
Position of the source, between 0 and 1. 0 means fully left
and 1 means fully right. Defaults to 0.5.
revtime : float or PyoObject, optional
- Duration, in seconds, of the reverberated sound, defined as
- the time needed to the sound to drop 40 dB below its peak.
+ Duration, in seconds, of the reverberated sound, defined as
+ the time needed to the sound to drop 40 dB below its peak.
Defaults to 1.
cutoff : float or PyoObject, optional
- cutoff frequency, in Hz, of a first order lowpass filters in the
+ cutoff frequency, in Hz, of a first order lowpass filters in the
feedback loop of delay lines. Defaults to 5000.
bal : float or PyoObject, optional
- Balance between wet and dry signal, between 0 and 1. 0 means no
+ Balance between wet and dry signal, between 0 and 1. 0 means no
reverb. Defaults to 0.5.
roomSize : float, optional
Delay line length scaler, between 0.25 and 4. Values higher than
@@ -1310,6 +1357,7 @@ class STRev(PyoObject):
"""
def __init__(self, input, inpos=0.5, revtime=1, cutoff=5000, bal=.5, roomSize=1, firstRefGain=-3, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOnnOO", input, inpos, revtime, cutoff, bal, roomSize, firstRefGain, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._inpos = inpos
@@ -1326,7 +1374,7 @@ class STRev(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1335,33 +1383,36 @@ class STRev(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setInpos(self, x):
"""
Replace the `inpos` attribute.
-
+
:Args:
x : float or PyoObject
New `inpos` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._inpos = x
x, lmax = convertArgsToLists(x)
[obj.setInpos(wrap(x,i)) for i, obj in enumerate(self._base_players)]
-
+
def setRevtime(self, x):
"""
Replace the `revtime` attribute.
-
+
:Args:
x : float or PyoObject
New `revtime` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._revtime = x
x, lmax = convertArgsToLists(x)
[obj.setRevtime(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1369,13 +1420,14 @@ class STRev(PyoObject):
def setCutoff(self, x):
"""
Replace the `cutoff` attribute.
-
+
:Args:
x : float or PyoObject
New `cutoff` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._cutoff = x
x, lmax = convertArgsToLists(x)
[obj.setCutoff(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1383,13 +1435,14 @@ class STRev(PyoObject):
def setBal(self, x):
"""
Replace the `bal` attribute.
-
+
:Args:
x : float or PyoObject
New `bal` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._bal = x
x, lmax = convertArgsToLists(x)
[obj.setMix(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1397,13 +1450,14 @@ class STRev(PyoObject):
def setRoomSize(self, x):
"""
Set the room size scaler, between 0.25 and 4.
-
+
:Args:
x : float
Room size scaler, between 0.25 and 4.0.
"""
+ pyoArgsAssert(self, "n", x)
self._roomSize = x
x, lmax = convertArgsToLists(x)
[obj.setRoomSize(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1411,13 +1465,14 @@ class STRev(PyoObject):
def setFirstRefGain(self, x):
"""
Set the gain of the first reflexions.
-
+
:Args:
x : float
Gain, in dB, of the first reflexions.
"""
+ pyoArgsAssert(self, "n", x)
self._firstRefGain = x
x, lmax = convertArgsToLists(x)
[obj.setFirstRefGain(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1434,49 +1489,329 @@ class STRev(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def inpos(self):
- """float or PyoObject. Position of the source."""
+ """float or PyoObject. Position of the source."""
return self._inpos
@inpos.setter
def inpos(self, x): self.setInpos(x)
@property
def revtime(self):
- """float or PyoObject. Room size."""
+ """float or PyoObject. Room size."""
return self._revtime
@revtime.setter
def revtime(self, x): self.setRevtime(x)
@property
def cutoff(self):
- """float or PyoObject. High frequency damping."""
+ """float or PyoObject. High frequency damping."""
return self._cutoff
@cutoff.setter
def cutoff(self, x): self.setCutoff(x)
@property
def bal(self):
- """float or PyoObject. Balance between wet and dry signal."""
+ """float or PyoObject. Balance between wet and dry signal."""
return self._bal
@bal.setter
def bal(self, x): self.setBal(x)
@property
def roomSize(self):
- """float. Room size scaler, between 0.25 and 4.0."""
+ """float. Room size scaler, between 0.25 and 4.0."""
return self._roomSize
@roomSize.setter
def roomSize(self, x): self.setRoomSize(x)
@property
def firstRefGain(self):
- """float. Gain, in dB, of the first reflexions."""
+ """float. Gain, in dB, of the first reflexions."""
return self._firstRefGain
@firstRefGain.setter
def firstRefGain(self, x): self.setFirstRefGain(x)
+
+class SmoothDelay(PyoObject):
+ """
+ Artifact free sweepable recursive delay.
+
+ SmoothDelay implements a delay line that does not produce
+ clicks or pitch shifting when the delay time is changing.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal to delayed.
+ delay : float or PyoObject, optional
+ Delay time in seconds. Defaults to 0.25.
+ feedback : float or PyoObject, optional
+ Amount of output signal sent back into the delay line.
+ Defaults to 0.
+ crossfade : float, optional
+ Crossfade time, in seconds, between overlaped readers.
+ Defaults to 0.05.
+ maxdelay : float, optional
+ Maximum delay length in seconds. Available only at initialization.
+ Defaults to 1.
+
+ .. note::
+
+ The minimum delay time allowed with SmoothDelay is one sample.
+ It can be computed with :
+
+ onesamp = 1.0 / s.getSamplingRate()
+
+ .. seealso::
+
+ :py:class:`Delay`, :py:class:`Waveguide`
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> sf = SfPlayer(SNDS_PATH+"/transparent.aif", loop=True, mul=0.3).mix(2).out()
+ >>> lf = Sine(freq=0.1, mul=0.24, add=0.25)
+ >>> sd = SmoothDelay(sf, delay=lf, feedback=0.5, crossfade=0.05, mul=0.7).out()
+
+ """
+ def __init__(self, input, delay=0.25, feedback=0, crossfade=0.05, maxdelay=1, mul=1, add=0):
+ pyoArgsAssert(self, "oOOnnOO", input, delay, feedback, crossfade, maxdelay, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._input = input
+ self._delay = delay
+ self._feedback = feedback
+ self._crossfade = crossfade
+ self._maxdelay = maxdelay
+ self._in_fader = InputFader(input)
+ in_fader, delay, feedback, crossfade, maxdelay, mul, add, lmax = convertArgsToLists(self._in_fader, delay, feedback, crossfade, maxdelay, mul, add)
+ self._base_objs = [SmoothDelay_base(wrap(in_fader,i), wrap(delay,i), wrap(feedback,i), wrap(crossfade,i), wrap(maxdelay,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to delayed.
+ fadetime : float, optional
+ Crossfade time between old and new input. Defaults to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ def setDelay(self, x):
+ """
+ Replace the `delay` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ New `delay` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._delay = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setDelay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setFeedback(self, x):
+ """
+ Replace the `feedback` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ New `feedback` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._feedback = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setCrossfade(self, x):
+ """
+ Replace the `crossfade` attribute.
+
+ :Args:
+
+ x : float
+ New `crossfade` attribute.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._crossfade = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setCrossfade(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def reset(self):
+ """
+ Reset the memory buffer to zeros.
+
+ """
+ [obj.reset() for obj in self._base_objs]
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = [SLMap(0.001, self._maxdelay, 'log', 'delay', self._delay),
+ SLMap(0., 1., 'lin', 'feedback', self._feedback),
+ SLMap(0., self._maxdelay, 'lin', 'crossfade', self._crossfade, dataOnly=True),
+ SLMapMul(self._mul)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to delayed."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+ @property
+ def delay(self):
+ """float or PyoObject. Delay time in seconds."""
+ return self._delay
+ @delay.setter
+ def delay(self, x): self.setDelay(x)
+
+ @property
+ def feedback(self):
+ """float or PyoObject. Amount of output signal sent back into the delay line."""
+ return self._feedback
+ @feedback.setter
+ def feedback(self, x): self.setFeedback(x)
+
+ @property
+ def crossfade(self):
+ """float. Crossfade time, in seconds, between overlaps."""
+ return self._crossfade
+ @crossfade.setter
+ def crossfade(self, x): self.setCrossfade(x)
+
+class FreqShift(PyoObject):
+ """
+ Frequency shifting using single sideband amplitude modulation.
+
+ Shifting frequencies means that the input signal can be detuned,
+ where the harmonic components of the signal are shifted out of
+ harmonic alignment with each other, e.g. a signal with harmonics at
+ 100, 200, 300, 400 and 500 Hz, shifted up by 50 Hz, will have harmonics
+ at 150, 250, 350, 450, and 550 Hz.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal to process.
+ shift : float or PyoObject, optional
+ Amount of shifting in Hertz. Defaults to 100.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> a = SineLoop(freq=300, feedback=.1, mul=.3)
+ >>> lf1 = Sine(freq=.04, mul=10)
+ >>> lf2 = Sine(freq=.05, mul=10)
+ >>> b = FreqShift(a, shift=lf1, mul=.5).out()
+ >>> c = FreqShift(a, shift=lf2, mul=.5).out(1)
+
+ """
+ def __init__(self, input, shift=100, mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, shift, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._input = input
+ self._shift = shift
+ self._in_fader = InputFader(input)
+ in_fader, shift, mul, add, lmax = convertArgsToLists(self._in_fader, shift, mul, add)
+
+ self._hilb_objs = []
+ self._sin_objs = []
+ self._cos_objs = []
+ self._mod_objs = []
+ self._base_objs = []
+ for i in range(lmax):
+ self._hilb_objs.append(Hilbert(wrap(in_fader,i)))
+ self._sin_objs.append(Sine(freq=wrap(shift,i), mul=.707))
+ self._cos_objs.append(Sine(freq=wrap(shift,i), phase=0.25, mul=.707))
+ self._mod_objs.append(Mix(self._hilb_objs[-1]['real'] * self._sin_objs[-1] + self._hilb_objs[-1]['imag'] * self._cos_objs[-1],
+ mul=wrap(mul,i), add=wrap(add,i)))
+ self._base_objs.extend(self._mod_objs[-1].getBaseObjects())
+
+ def play(self, dur=0, delay=0):
+ dur, delay, lmax = convertArgsToLists(dur, delay)
+ [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._hilb_objs)]
+ [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._sin_objs)]
+ [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._cos_objs)]
+ [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._mod_objs)]
+ return PyoObject.play(self, dur, delay)
+
+ def stop(self):
+ [obj.stop() for obj in self._hilb_objs]
+ [obj.stop() for obj in self._sin_objs]
+ [obj.stop() for obj in self._cos_objs]
+ [obj.stop() for obj in self._mod_objs]
+ return PyoObject.stop(self)
+
+ def out(self, chnl=0, inc=1, dur=0, delay=0):
+ dur, delay, lmax = convertArgsToLists(dur, delay)
+ [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._hilb_objs)]
+ [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._sin_objs)]
+ [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._cos_objs)]
+ [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._mod_objs)]
+ return PyoObject.out(self, chnl, inc, dur, delay)
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ Parameters:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Defaults to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ def setShift(self, x):
+ """
+ Replace the `shift` attribute.
+
+ Parameters:
+
+ x : float or PyoObject
+ New `shift` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._shift = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._sin_objs)]
+ [obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._cos_objs)]
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = [SLMap(-2000., 2000., "lin", "shift", self._shift), SLMapMul(self._mul)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to pitch shift."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+ @property
+ def shift(self):
+ """float or PyoObject. Amount of pitch shift in Hertz."""
+ return self._shift
+ @shift.setter
+ def shift(self, x): self.setShift(x)
\ No newline at end of file
diff --git a/pyolib/filters.py b/pyolib/filters.py
index 89d60cb..507be15 100644
--- a/pyolib/filters.py
+++ b/pyolib/filters.py
@@ -1,57 +1,57 @@
"""
Different kinds of audio filtering operations.
-An audio filter is designed to amplify, pass or attenuate (negative amplification)
-some frequency ranges. Common types include low-pass, which pass through
-frequencies below their cutoff frequencies, and progressively attenuates
-frequencies above the cutoff frequency. A high-pass filter does the opposite,
-passing high frequencies above the cutoff frequency, and progressively
-attenuating frequencies below the cutoff frequency. A bandpass filter passes
-frequencies between its two cutoff frequencies, while attenuating those outside
-the range. A band-reject filter, attenuates frequencies between its two cutoff
+An audio filter is designed to amplify, pass or attenuate (negative amplification)
+some frequency ranges. Common types include low-pass, which pass through
+frequencies below their cutoff frequencies, and progressively attenuates
+frequencies above the cutoff frequency. A high-pass filter does the opposite,
+passing high frequencies above the cutoff frequency, and progressively
+attenuating frequencies below the cutoff frequency. A bandpass filter passes
+frequencies between its two cutoff frequencies, while attenuating those outside
+the range. A band-reject filter, attenuates frequencies between its two cutoff
frequencies, while passing those outside the 'reject' range.
-An all-pass filter, passes all frequencies, but affects the phase of any given
+An all-pass filter, passes all frequencies, but affects the phase of any given
sinusoidal component according to its frequency.
-
+
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
class Biquad(PyoObject):
"""
- A sweepable general purpose biquadratic digital filter.
-
+ A sweepable general purpose biquadratic digital filter.
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff or center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
- Q of the filter, defined (for bandpass filters) as freq/bandwidth.
+ Q of the filter, defined (for bandpass filters) as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
type : int, optional
Filter type. Five possible values :
@@ -60,7 +60,7 @@ class Biquad(PyoObject):
2. bandpass
3. bandstop
4. allpass
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(mul=.7)
@@ -69,6 +69,7 @@ class Biquad(PyoObject):
"""
def __init__(self, input, freq=1000, q=1, type=0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOiOO", input, freq, q, type, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -81,7 +82,7 @@ class Biquad(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -90,19 +91,21 @@ class Biquad(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -110,13 +113,14 @@ class Biquad(PyoObject):
def setQ(self, x):
"""
Replace the `q` attribute. Should be between 1 and 500.
-
+
:Args:
x : float or PyoObject
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -124,63 +128,64 @@ class Biquad(PyoObject):
def setType(self, x):
"""
Replace the `type` attribute.
-
+
:Args:
x : int
- New `type` attribute.
+ New `type` attribute.
0.lowpass
1. highpass
- 2. bandpass
- 3. bandstop
+ 2. bandpass
+ 3. bandstop
4. allpass
"""
+ pyoArgsAssert(self, "i", x)
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMapFreq(self._freq), SLMapQ(self._q),
+ self._map_list = [SLMapFreq(self._freq), SLMapQ(self._q),
SLMap(0, 4, 'lin', 'type', self._type, res="int", dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff or center frequency of the filter."""
+ """float or PyoObject. Cutoff or center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
- """float or PyoObject. Q of the filter."""
+ """float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def type(self):
- """int. Filter type."""
+ """int. Filter type."""
return self._type
@type.setter
def type(self, x): self.setType(x)
class Biquadx(PyoObject):
"""
- A multi-stages sweepable general purpose biquadratic digital filter.
-
+ A multi-stages sweepable general purpose biquadratic digital filter.
+
Biquadx is equivalent to a filter consisting of more layers of Biquad
with the same arguments, serially connected. It is faster than using
- a large number of instances of the Biquad object, It uses less memory
+ a large number of instances of the Biquad object, It uses less memory
and allows filters with sharper cutoff.
:Parent: :py:class:`PyoObject`
@@ -192,7 +197,7 @@ class Biquadx(PyoObject):
freq : float or PyoObject, optional
Cutoff or center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
- Q of the filter, defined (for bandpass filters) as freq/bandwidth.
+ Q of the filter, defined (for bandpass filters) as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
type : int, optional
Filter type. Five possible values :
@@ -212,6 +217,7 @@ class Biquadx(PyoObject):
"""
def __init__(self, input, freq=1000, q=1, type=0, stages=4, mul=1, add=0):
+ pyoArgsAssert(self, "oOOiiOO", input, freq, q, type, stages, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -234,6 +240,7 @@ class Biquadx(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -247,6 +254,7 @@ class Biquadx(PyoObject):
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -261,6 +269,7 @@ class Biquadx(PyoObject):
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -272,7 +281,7 @@ class Biquadx(PyoObject):
:Args:
x : int
- New `type` attribute.
+ New `type` attribute.
0. lowpass
1. highpass
2. bandpass
@@ -280,6 +289,7 @@ class Biquadx(PyoObject):
4. allpass
"""
+ pyoArgsAssert(self, "i", x)
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -291,50 +301,51 @@ class Biquadx(PyoObject):
:Args:
x : int
- New `stages` attribute.
+ New `stages` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._stages = x
x, lmax = convertArgsToLists(x)
[obj.setStages(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMapFreq(self._freq), SLMapQ(self._q),
+ self._map_list = [SLMapFreq(self._freq), SLMapQ(self._q),
SLMap(0, 4, 'lin', 'type', self._type, res="int", dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff or center frequency of the filter."""
+ """float or PyoObject. Cutoff or center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
- """float or PyoObject. Q of the filter."""
+ """float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def type(self):
- """int. Filter type."""
+ """int. Filter type."""
return self._type
@type.setter
def type(self, x): self.setType(x)
@property
def stages(self):
- """int. The number of filtering stages."""
+ """int. The number of filtering stages."""
return self._stages
@stages.setter
def stages(self, x): self.setStages(x)
@@ -344,14 +355,14 @@ class Biquada(PyoObject):
A general purpose biquadratic digital filter (floating-point arguments).
A digital biquad filter is a second-order recursive linear filter, containing
- two poles and two zeros. Biquadi is a "Direct Form 1" implementation of a Biquad
+ two poles and two zeros. Biquadi is a "Direct Form 1" implementation of a Biquad
filter:
y[n] = ( b0*x[n] + b1*x[n-1] + b2*x[n-2] - a1*y[n-1] - a2*y[n-2] ) / a0
This object is directly controlled via the six coefficients, as floating-point
- values or audio stream, of the filter. There is no clipping of the values given as
- coefficients, so, unless you know what you do, it is recommended to use the Biquad
+ values or audio stream, of the filter. There is no clipping of the values given as
+ coefficients, so, unless you know what you do, it is recommended to use the Biquad
object, which is controlled with frequency, Q and type arguments.
The default values of the object give a lowpass filter with a 1000 Hz cutoff frequency.
@@ -383,6 +394,7 @@ class Biquada(PyoObject):
"""
def __init__(self, input, b0=0.005066, b1=0.010132, b2=0.005066, a0=1.070997, a1=-1.979735, a2=0.929003, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOOOOO", input, b0, b1, b2, a0, a1, a2, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._b0 = Sig(b0)
@@ -407,6 +419,7 @@ class Biquada(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -420,6 +433,7 @@ class Biquada(PyoObject):
New `b0` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._b0.value = x
def setB1(self, x):
@@ -432,6 +446,7 @@ class Biquada(PyoObject):
New `b1` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._b1.value = x
def setB2(self, x):
@@ -444,6 +459,7 @@ class Biquada(PyoObject):
New `b2` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._b2.value = x
def setA0(self, x):
@@ -456,6 +472,7 @@ class Biquada(PyoObject):
New `a0` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._a0.value = x
def setA1(self, x):
@@ -468,6 +485,7 @@ class Biquada(PyoObject):
New `a1` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._a1.value = x
def setA2(self, x):
@@ -480,14 +498,15 @@ class Biquada(PyoObject):
New `a2` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._a2.value = x
def setCoeffs(self, *args, **kwds):
"""
Replace all filter coefficients.
-
+
:Args:
-
+
b0 : float or PyoObject, optional
New `b0` attribute.
b1 : float or PyoObject, optional
@@ -500,7 +519,7 @@ class Biquada(PyoObject):
New `a1` attribute.
a2 : float or PyoObject, optional
New `a2` attribute.
-
+
"""
for i, val in enumerate(args):
attr = getattr(self, ["_b0", "_b1", "_b2", "_a0", "_a1", "_a2"][i])
@@ -516,81 +535,81 @@ class Biquada(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def b0(self):
- """float or PyoObject. `b0` coefficient."""
+ """float or PyoObject. `b0` coefficient."""
return self._b0
@b0.setter
def b0(self, x): self.setB0(x)
@property
def b1(self):
- """float or PyoObject. `b1` coefficient."""
+ """float or PyoObject. `b1` coefficient."""
return self._b1
@b1.setter
def b1(self, x): self.setB1(x)
@property
def b2(self):
- """float or PyoObject. `b2` coefficient."""
+ """float or PyoObject. `b2` coefficient."""
return self._b2
@b2.setter
def b2(self, x): self.setB2(x)
@property
def a0(self):
- """float or PyoObject. `a0` coefficient."""
+ """float or PyoObject. `a0` coefficient."""
return self._a0
@a0.setter
def a0(self, x): self.setA0(x)
@property
def a1(self):
- """float or PyoObject. `a1` coefficient."""
+ """float or PyoObject. `a1` coefficient."""
return self._a1
@a1.setter
def a1(self, x): self.setA1(x)
@property
def a2(self):
- """float or PyoObject. `a2` coefficient."""
+ """float or PyoObject. `a2` coefficient."""
return self._a2
@a2.setter
def a2(self, x): self.setA2(x)
class EQ(PyoObject):
"""
- Equalizer filter.
-
- EQ is a biquadratic digital filter designed for equalization. It
- provides peak/notch and lowshelf/highshelf filters for building
+ Equalizer filter.
+
+ EQ is a biquadratic digital filter designed for equalization. It
+ provides peak/notch and lowshelf/highshelf filters for building
parametric equalizers.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff or center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
- Q of the filter, defined as freq/bandwidth.
+ Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
boost : float or PyoObject, optional
- Gain, expressed in dB, to add or remove at the center frequency.
+ Gain, expressed in dB, to add or remove at the center frequency.
Default to -3.
type : int, optional
Filter type. Three possible values :
0. peak/notch (default)
1. lowshelf
2. highshelf
-
+
>>> s = Server().boot()
>>> s.start()
>>> amp = Fader(1, 1, mul=.15).play()
@@ -601,6 +620,7 @@ class EQ(PyoObject):
"""
def __init__(self, input, freq=1000, q=1, boost=-3.0, type=0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOiOO", input, freq, q, boost, type, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -614,7 +634,7 @@ class EQ(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -623,19 +643,21 @@ class EQ(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -643,13 +665,14 @@ class EQ(PyoObject):
def setQ(self, x):
"""
Replace the `q` attribute. Should be between 1 and 500.
-
+
:Args:
x : float or PyoObject
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -657,13 +680,14 @@ class EQ(PyoObject):
def setBoost(self, x):
"""
Replace the `boost` attribute, expressed in dB.
-
+
:Args:
x : float or PyoObject
New `boost` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._boost = x
x, lmax = convertArgsToLists(x)
[obj.setBoost(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -671,58 +695,59 @@ class EQ(PyoObject):
def setType(self, x):
"""
Replace the `type` attribute.
-
+
:Args:
x : int
- New `type` attribute.
+ New `type` attribute.
0. peak
1. lowshelf
2. highshelf
"""
+ pyoArgsAssert(self, "i", x)
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMapFreq(self._freq), SLMapQ(self._q),
- SLMap(-40.0, 40.0, "lin", "boost", self._boost),
+ self._map_list = [SLMapFreq(self._freq), SLMapQ(self._q),
+ SLMap(-40.0, 40.0, "lin", "boost", self._boost),
SLMap(0, 2, 'lin', 'type', self._type, res="int", dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff or center frequency of the filter."""
+ """float or PyoObject. Cutoff or center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
- """float or PyoObject. Q of the filter."""
+ """float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def boost(self):
- """float or PyoObject. Boost factor of the filter."""
+ """float or PyoObject. Boost factor of the filter."""
return self._boost
@boost.setter
def boost(self, x): self.setBoost(x)
@property
def type(self):
- """int. Filter type."""
+ """int. Filter type."""
return self._type
@type.setter
def type(self, x): self.setType(x)
@@ -730,16 +755,16 @@ class EQ(PyoObject):
class Tone(PyoObject):
"""
A first-order recursive low-pass filter with variable frequency response.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 1000.
-
+
>>> s = Server().boot()
>>> s.start()
>>> n = Noise(.3)
@@ -748,6 +773,7 @@ class Tone(PyoObject):
"""
def __init__(self, input, freq=1000, mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -758,7 +784,7 @@ class Tone(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -767,19 +793,21 @@ class Tone(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -787,17 +815,17 @@ class Tone(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff frequency of the filter."""
+ """float or PyoObject. Cutoff frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@@ -805,16 +833,16 @@ class Tone(PyoObject):
class Atone(PyoObject):
"""
A first-order recursive high-pass filter with variable frequency response.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 1000.
-
+
>>> s = Server().boot()
>>> s.start()
>>> n = Noise(.3)
@@ -823,6 +851,7 @@ class Atone(PyoObject):
"""
def __init__(self, input, freq=1000, mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -833,7 +862,7 @@ class Atone(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -842,19 +871,21 @@ class Atone(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -862,17 +893,17 @@ class Atone(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff frequency of the filter."""
+ """float or PyoObject. Cutoff frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@@ -880,12 +911,12 @@ class Atone(PyoObject):
class Port(PyoObject):
"""
Exponential portamento.
-
- Perform an exponential portamento on an audio signal with
+
+ Perform an exponential portamento on an audio signal with
different rising and falling times.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
input : PyoObject
@@ -895,7 +926,7 @@ class Port(PyoObject):
falltime : float or PyoObject, optional
Time to reach downward value in seconds. Defaults to 0.05.
init : float, optional
- Initial state of the internal memory. Available at intialization
+ Initial state of the internal memory. Available at intialization
time only. Defaults to 0.
>>> from random import uniform
@@ -907,9 +938,10 @@ class Port(PyoObject):
>>> def new_freq():
... x.value = uniform(400, 800)
>>> pat = Pattern(function=new_freq, time=1).play()
-
+
"""
def __init__(self, input, risetime=0.05, falltime=0.05, init=0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOnOO", input, risetime, falltime, init, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._risetime = risetime
@@ -921,7 +953,7 @@ class Port(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -930,19 +962,21 @@ class Port(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setRiseTime(self, x):
"""
Replace the `risetime` attribute.
-
+
:Args:
x : float or PyoObject
New `risetime` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._risetime = x
x, lmax = convertArgsToLists(x)
[obj.setRiseTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -950,13 +984,14 @@ class Port(PyoObject):
def setFallTime(self, x):
"""
Replace the `falltime` attribute.
-
+
:Args:
x : float or PyoObject
New `falltime` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._falltime = x
x, lmax = convertArgsToLists(x)
[obj.setFallTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -968,14 +1003,14 @@ class Port(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def risetime(self):
- """float or PyoObject. Time to reach upward value in seconds."""
+ """float or PyoObject. Time to reach upward value in seconds."""
return self._risetime
@risetime.setter
def risetime(self, x): self.setRiseTime(x)
@@ -990,14 +1025,14 @@ class Port(PyoObject):
class DCBlock(PyoObject):
"""
Implements the DC blocking filter.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
-
+
>>> s = Server().boot()
>>> s.start()
>>> n = Noise(.01)
@@ -1006,6 +1041,7 @@ class DCBlock(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -1015,7 +1051,7 @@ class DCBlock(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1024,12 +1060,13 @@ class DCBlock(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1037,31 +1074,31 @@ class DCBlock(PyoObject):
class BandSplit(PyoObject):
"""
Splits an input signal into multiple frequency bands.
-
- The input signal will be separated into `num` bands between `min`
- and `max` frequencies using second-order bandpass filters. Each
- band will then be assigned to an independent audio stream.
+
+ The input signal will be separated into `num` bands between `min`
+ and `max` frequencies using second-order bandpass filters. Each
+ band will then be assigned to an independent audio stream.
Useful for multiband processing.
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
num : int, optional
- Number of frequency bands created. Available at initialization
+ Number of frequency bands created. Available at initialization
time only. Defaults to 6.
min : float, optional
- Lowest frequency. Available at initialization time only.
+ Lowest frequency. Available at initialization time only.
Defaults to 20.
max : float, optional
- Highest frequency. Available at initialization time only.
+ Highest frequency. Available at initialization time only.
Defaults to 20000.
q : float or PyoObject, optional
- Q of the filters, defined as center frequency / bandwidth.
+ Q of the filters, defined as center frequency / bandwidth.
Should be between 1 and 500. Defaults to 1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> lfos = Sine(freq=[.3,.4,.5,.6,.7,.8], mul=.5, add=.5)
@@ -1070,6 +1107,7 @@ class BandSplit(PyoObject):
"""
def __init__(self, input, num=6, min=20, max=20000, q=1, mul=1, add=0):
+ pyoArgsAssert(self, "oINNOOO", input, num, min, max, q, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._num = num
@@ -1089,7 +1127,7 @@ class BandSplit(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1098,19 +1136,21 @@ class BandSplit(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setQ(self, x):
"""
Replace the `q` attribute.
-
+
:Args:
x : float or PyoObject
new `q` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1121,26 +1161,26 @@ class BandSplit(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
- def q(self):
+ def q(self):
"""float or PyoObject. Q of the filters."""
return self._q
@q.setter
- def q(self, x): self.setQ(x)
+ def q(self, x): self.setQ(x)
class FourBand(PyoObject):
"""
Splits an input signal into four frequency bands.
- The input signal will be separated into 4 bands around `freqs`
- arguments using fourth-order Linkwitz-Riley lowpass and highpass
- filters. Each band will then be assigned to an independent audio
- stream. The sum of the four bands reproduces the same signal as
+ The input signal will be separated into 4 bands around `freqs`
+ arguments using fourth-order Linkwitz-Riley lowpass and highpass
+ filters. Each band will then be assigned to an independent audio
+ stream. The sum of the four bands reproduces the same signal as
the `input`. Useful for multiband processing.
:Parent: :py:class:`PyoObject`
@@ -1169,6 +1209,7 @@ class FourBand(PyoObject):
"""
def __init__(self, input, freq1=150, freq2=500, freq3=2000, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOO", input, freq1, freq2, freq3, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq1 = freq1
@@ -1196,6 +1237,7 @@ class FourBand(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1209,6 +1251,7 @@ class FourBand(PyoObject):
new `freq1` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq1 = x
x, lmax = convertArgsToLists(x)
[obj.setFreq1(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1223,6 +1266,7 @@ class FourBand(PyoObject):
new `freq2` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq2 = x
x, lmax = convertArgsToLists(x)
[obj.setFreq2(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1237,6 +1281,7 @@ class FourBand(PyoObject):
new `freq3` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq3 = x
x, lmax = convertArgsToLists(x)
[obj.setFreq3(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1250,63 +1295,63 @@ class FourBand(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
- def freq1(self):
+ def freq1(self):
"""float or PyoObject. First crossover frequency."""
return self._freq1
@freq1.setter
- def freq1(self, x): self.setFreq1(x)
+ def freq1(self, x): self.setFreq1(x)
@property
- def freq2(self):
+ def freq2(self):
"""float or PyoObject. Second crossover frequency."""
return self._freq2
@freq2.setter
- def freq2(self, x): self.setFreq2(x)
+ def freq2(self, x): self.setFreq2(x)
@property
- def freq3(self):
+ def freq3(self):
"""float or PyoObject. Third crossover frequency."""
return self._freq3
@freq3.setter
- def freq3(self, x): self.setFreq3(x)
+ def freq3(self, x): self.setFreq3(x)
class Hilbert(PyoObject):
"""
Hilbert transform.
-
- Hilbert is an IIR filter based implementation of a broad-band 90 degree
- phase difference network. The outputs of hilbert have an identical
- frequency response to the input (i.e. they sound the same), but the two
- outputs have a constant phase difference of 90 degrees, plus or minus some
- small amount of error, throughout the entire frequency range. The outputs
+
+ Hilbert is an IIR filter based implementation of a broad-band 90 degree
+ phase difference network. The outputs of hilbert have an identical
+ frequency response to the input (i.e. they sound the same), but the two
+ outputs have a constant phase difference of 90 degrees, plus or minus some
+ small amount of error, throughout the entire frequency range. The outputs
are in quadrature.
- Hilbert is useful in the implementation of many digital signal processing
- techniques that require a signal in phase quadrature. The real part corresponds
- to the cosine output of hilbert, while the imaginary part corresponds to the
- sine output. The two outputs have a constant phase difference throughout the
+ Hilbert is useful in the implementation of many digital signal processing
+ techniques that require a signal in phase quadrature. The real part corresponds
+ to the cosine output of hilbert, while the imaginary part corresponds to the
+ sine output. The two outputs have a constant phase difference throughout the
audio range that corresponds to the phase relationship between cosine and sine waves.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
-
+
.. note::
-
- Real and imaginary parts are two separated set of streams.
+
+ Real and imaginary parts are two separated set of streams.
The user should call :
-
- Hilbert['real'] to retrieve the real part.
- Hilbert['imag'] to retrieve the imaginary part.
+
+ | Hilbert['real'] to retrieve the real part.
+ | Hilbert['imag'] to retrieve the imaginary part.
>>> s = Server().boot()
>>> s.start()
@@ -1321,6 +1366,7 @@ class Hilbert(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._real_dummy = []
self._imag_dummy = []
@@ -1346,12 +1392,12 @@ class Hilbert(PyoObject):
def get(self, identifier="real", all=False):
"""
Return the first sample of the current buffer as a float.
-
+
Can be used to convert audio stream to usable Python data.
-
+
"real" or "imag" must be given to `identifier` to specify
which stream to get value from.
-
+
:Args:
identifier : string {"real", "imag"}
@@ -1362,17 +1408,17 @@ class Hilbert(PyoObject):
will be returned as a list. Otherwise, only the value
of the first object's stream will be returned as a float.
Defaults to False.
-
+
"""
if not all:
return self.__getitem__(identifier)[0]._getStream().getValue()
else:
return [obj._getStream().getValue() for obj in self.__getitem__(identifier).getBaseObjects()]
-
+
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1381,12 +1427,13 @@ class Hilbert(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1394,7 +1441,7 @@ class Hilbert(PyoObject):
class Allpass(PyoObject):
"""
Delay line based allpass filter.
-
+
Allpass is based on the combination of feedforward and feedback comb
filter. This kind of filter is often used in simple digital reverb
implementations.
@@ -1411,7 +1458,7 @@ class Allpass(PyoObject):
Amount of output signal sent back into the delay line.
Defaults to 0.
maxdelay : float, optional
- Maximum delay length in seconds. Available only at initialization.
+ Maximum delay length in seconds. Available only at initialization.
Defaults to 1.
>>> # SIMPLE REVERB
@@ -1426,9 +1473,10 @@ class Allpass(PyoObject):
>>> c2 = Tone(b2, 3000, mul=0.2).out()
>>> c3 = Tone(b3, 1500, mul=0.2).out()
>>> c4 = Tone(b4, 500, mul=0.2).out()
-
+
"""
def __init__(self, input, delay=0.01, feedback=0, maxdelay=1, mul=1, add=0):
+ pyoArgsAssert(self, "oOOnOO", input, delay, feedback, maxdelay, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._delay = delay
@@ -1450,6 +1498,7 @@ class Allpass(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1463,6 +1512,7 @@ class Allpass(PyoObject):
New `delay` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._delay = x
x, lmax = convertArgsToLists(x)
[obj.setDelay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1477,6 +1527,7 @@ class Allpass(PyoObject):
New `feedback` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1489,44 +1540,44 @@ class Allpass(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def delay(self):
- """float or PyoObject. Delay time in seconds."""
+ """float or PyoObject. Delay time in seconds."""
return self._delay
@delay.setter
def delay(self, x): self.setDelay(x)
@property
def feedback(self):
- """float or PyoObject. Amount of output signal sent back into the delay line."""
+ """float or PyoObject. Amount of output signal sent back into the delay line."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
class Allpass2(PyoObject):
"""
- Second-order phase shifter allpass.
-
+ Second-order phase shifter allpass.
+
This kind of filter is used in phaser implementation. The signal
of this filter, when added to original sound, creates a notch in
the spectrum at frequencies that are in phase opposition.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
bw : float or PyoObject, optional
Bandwidth of the filter in Hertz. Defaults to 100.
-
+
>>> s = Server().boot()
>>> s.start()
>>> # 3 STAGES PHASER
@@ -1540,6 +1591,7 @@ class Allpass2(PyoObject):
"""
def __init__(self, input, freq=1000, bw=100, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, freq, bw, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -1551,7 +1603,7 @@ class Allpass2(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1560,19 +1612,21 @@ class Allpass2(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1580,46 +1634,47 @@ class Allpass2(PyoObject):
def setBw(self, x):
"""
Replace the `bw` attribute.
-
+
:Args:
x : float or PyoObject
New `bw` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._bw = x
x, lmax = convertArgsToLists(x)
[obj.setBw(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMapFreq(self._freq), SLMap(10, 1000, "lin", "bw", self._bw),
+ self._map_list = [SLMapFreq(self._freq), SLMap(10, 1000, "lin", "bw", self._bw),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
- """PyoObject. Input signal to filter."""
+ """PyoObject. Input signal to filter."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Center frequency of the filter."""
+ """float or PyoObject. Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def bw(self):
- """float or PyoObject. Bandwidth of the filter."""
+ """float or PyoObject. Bandwidth of the filter."""
return self._bw
@bw.setter
def bw(self, x): self.setBw(x)
class Phaser(PyoObject):
"""
- Multi-stages second-order phase shifter allpass filters.
+ Multi-stages second-order phase shifter allpass filters.
Phaser implements `num` number of second-order allpass filters.
@@ -1641,7 +1696,7 @@ class Phaser(PyoObject):
num : int, optional
The number of allpass stages in series. Defines the number of
notches in the spectrum. Defaults to 8.
-
+
Available at initialization only.
>>> s = Server().boot()
@@ -1654,6 +1709,7 @@ class Phaser(PyoObject):
"""
def __init__(self, input, freq=1000, spread=1.1, q=10, feedback=0, num=8, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOiOO", input, freq, spread, q, feedback, num, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -1677,6 +1733,7 @@ class Phaser(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1690,6 +1747,7 @@ class Phaser(PyoObject):
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1704,6 +1762,7 @@ class Phaser(PyoObject):
New `spread` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._spread = x
x, lmax = convertArgsToLists(x)
[obj.setSpread(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1718,6 +1777,7 @@ class Phaser(PyoObject):
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1732,62 +1792,63 @@ class Phaser(PyoObject):
New `feedback` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(20, 2000, "log", "freq", self._freq),
+ self._map_list = [SLMap(20, 2000, "log", "freq", self._freq),
SLMap(0.5, 2, "lin", "spread", self._spread),
- SLMap(0.5, 100, "log", "q", self._q),
+ SLMap(0.5, 100, "log", "q", self._q),
SLMap(0, 1, "lin", "feedback", self._feedback),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Center frequency of the first notch."""
+ """float or PyoObject. Center frequency of the first notch."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def spread(self):
- """float or PyoObject. Spreading factor for upper notch frequencies."""
+ """float or PyoObject. Spreading factor for upper notch frequencies."""
return self._spread
@spread.setter
def spread(self, x): self.setSpread(x)
@property
def q(self):
- """float or PyoObject. Q factor of the filter."""
+ """float or PyoObject. Q factor of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def feedback(self):
- """float or PyoObject. Feedback factor of the filter."""
+ """float or PyoObject. Feedback factor of the filter."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
class Vocoder(PyoObject):
"""
- Applies the spectral envelope of a first sound to the spectrum of a second sound.
+ Applies the spectral envelope of a first sound to the spectrum of a second sound.
- The vocoder is an analysis/synthesis system, historically used to reproduce
- human speech. In the encoder, the first input (spectral envelope) is passed
- through a multiband filter, each band is passed through an envelope follower,
- and the control signals from the envelope followers are communicated to the
- decoder. The decoder applies these (amplitude) control signals to corresponding
+ The vocoder is an analysis/synthesis system, historically used to reproduce
+ human speech. In the encoder, the first input (spectral envelope) is passed
+ through a multiband filter, each band is passed through an envelope follower,
+ and the control signals from the envelope followers are communicated to the
+ decoder. The decoder applies these (amplitude) control signals to corresponding
filters modifying the second source (exciter).
:Parent: :py:class:`PyoObject`
@@ -1802,10 +1863,10 @@ class Vocoder(PyoObject):
Exciter. Spectrum to filter. For best results, this signal must have a
broadband spectrum with few amplitude variations.
freq : float or PyoObject, optional
- Center frequency of the first band. This is the base frequency used to
+ Center frequency of the first band. This is the base frequency used to
compute the upper bands. Defaults to 60.
spread : float or PyoObject, optional
- Spreading factor for upper band frequencies. Each band is
+ Spreading factor for upper band frequencies. Each band is
`freq * pow(order, spread)`, where order is the harmonic rank of the band.
Defaults to 1.25.
q : float or PyoObject, optional
@@ -1815,12 +1876,12 @@ class Vocoder(PyoObject):
Time response of the envelope follower. Lower values mean smoother changes,
while higher values mean a better time accuracy. Defaults to 0.5.
stages : int, optional
- The number of bands in the filter bank. Defines the number of notches in
+ The number of bands in the filter bank. Defines the number of notches in
the spectrum. Defaults to 24.
.. note::
- Altough parameters can be audio signals, values are sampled only four times
+ Altough parameters can be audio signals, values are sampled only four times
per buffer size. To avoid artefacts, it is recommended to keep variations
at low rate (< 20 Hz).
@@ -1833,6 +1894,7 @@ class Vocoder(PyoObject):
"""
def __init__(self, input, input2, freq=60, spread=1.25, q=20, slope=0.5, stages=24, mul=1, add=0):
+ pyoArgsAssert(self, "ooOOOOiOO", input, input2, freq, spread, q, slope, stages, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._input2 = input2
@@ -1858,6 +1920,7 @@ class Vocoder(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1873,6 +1936,7 @@ class Vocoder(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input2 = x
self._in_fader2.setInput(x, fadetime)
@@ -1886,6 +1950,7 @@ class Vocoder(PyoObject):
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1900,6 +1965,7 @@ class Vocoder(PyoObject):
New `spread` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._spread = x
x, lmax = convertArgsToLists(x)
[obj.setSpread(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1914,6 +1980,7 @@ class Vocoder(PyoObject):
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1928,6 +1995,7 @@ class Vocoder(PyoObject):
New `slope` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._slope = x
x, lmax = convertArgsToLists(x)
[obj.setSlope(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1942,14 +2010,15 @@ class Vocoder(PyoObject):
New `stages` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._stages = x
x, lmax = convertArgsToLists(x)
[obj.setStages(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(10, 1000, "log", "freq", self._freq),
+ self._map_list = [SLMap(10, 1000, "log", "freq", self._freq),
SLMap(0.25, 2, "lin", "spread", self._spread),
- SLMap(0.5, 200, "log", "q", self._q),
+ SLMap(0.5, 200, "log", "q", self._q),
SLMap(0, 1, "lin", "slope", self._slope),
SLMap(2, 64, 'lin', 'stages', self._stages, res="int", dataOnly=True),
SLMapMul(self._mul)]
@@ -1957,49 +2026,49 @@ class Vocoder(PyoObject):
@property
def input(self):
- """PyoObject. The spectral envelope."""
+ """PyoObject. The spectral envelope."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def input2(self):
- """PyoObject. The exciter."""
+ """PyoObject. The exciter."""
return self._input2
@input2.setter
def input2(self, x): self.setInput2(x)
@property
def freq(self):
- """float or PyoObject. Center frequency of the first band."""
+ """float or PyoObject. Center frequency of the first band."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def spread(self):
- """float or PyoObject. Spreading factor for upper band frequencies."""
+ """float or PyoObject. Spreading factor for upper band frequencies."""
return self._spread
@spread.setter
def spread(self, x): self.setSpread(x)
@property
def q(self):
- """float or PyoObject. Q factor of the filters."""
+ """float or PyoObject. Q factor of the filters."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def slope(self):
- """float or PyoObject. Time response of the envelope follower."""
+ """float or PyoObject. Time response of the envelope follower."""
return self._slope
@slope.setter
def slope(self, x): self.setSlope(x)
@property
def stages(self):
- """int. The number of bands in the filter bank."""
+ """int. The number of bands in the filter bank."""
return self._stages
@stages.setter
def stages(self, x): self.setStages(x)
@@ -2007,9 +2076,9 @@ class Vocoder(PyoObject):
class IRWinSinc(PyoObject):
"""
Windowed-sinc filter using circular convolution.
-
- IRWinSinc uses circular convolution to implement standard filters like
- lowpass, highpass, bandreject and bandpass with very flat passband
+
+ IRWinSinc uses circular convolution to implement standard filters like
+ lowpass, highpass, bandreject and bandpass with very flat passband
response and sharp roll-off. User can defined the length, in samples,
of the impulse response, also known as the filter kernel.
@@ -2032,17 +2101,17 @@ class IRWinSinc(PyoObject):
2. bandreject
3. bandpass
order : int {even number}, optional
- Length, in samples, of the filter kernel used for convolution. Available
+ Length, in samples, of the filter kernel used for convolution. Available
at initialization time only. Defaults to 256.
-
- This value must be even. Higher is the order and sharper is the roll-off
- of the filter, but it is also more expensive to compute.
+
+ This value must be even. Higher is the order and sharper is the roll-off
+ of the filter, but it is also more expensive to compute.
.. note::
- Convolution is very expensive to compute, so the length of the impulse
+ Convolution is very expensive to compute, so the length of the impulse
response (the `order` parameter) must be kept very short to run in real time.
-
+
Note that although `freq` and `bw` can be PyoObjects, the impulse response of
the filter is only updated once per buffer size.
@@ -2055,6 +2124,7 @@ class IRWinSinc(PyoObject):
"""
def __init__(self, input, freq=1000, bw=500, type=0, order=256, mul=1, add=0):
+ pyoArgsAssert(self, "oOOiiOO", input, freq, bw, type, order, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -2065,7 +2135,7 @@ class IRWinSinc(PyoObject):
print "order argument of IRWinSinc must be even, set to %i" % order
self._order = order
self._in_fader = InputFader(input)
- in_fader, freq, bw, type, order, mul, add, lmax = convertArgsToLists(self._in_fader, freq, bw, type, order, mul, add)
+ in_fader, freq, bw, type, order, mul, add, lmax = convertArgsToLists(self._in_fader, freq, bw, type, order, mul, add)
self._base_objs = [IRWinSinc_base(wrap(in_fader,i), wrap(freq,i), wrap(bw,i), wrap(type,i), wrap(order,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setInput(self, x, fadetime=0.05):
@@ -2080,6 +2150,7 @@ class IRWinSinc(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2093,6 +2164,7 @@ class IRWinSinc(PyoObject):
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2107,6 +2179,7 @@ class IRWinSinc(PyoObject):
New `bw` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._bw = x
x, lmax = convertArgsToLists(x)
[obj.setBandwidth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2118,13 +2191,14 @@ class IRWinSinc(PyoObject):
:Args:
x : int
- New `type` attribute.
+ New `type` attribute.
0. lowpass
1. highpass
2. bandreject
3. bandpass
"""
+ pyoArgsAssert(self, "i", x)
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2137,28 +2211,28 @@ class IRWinSinc(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff or Center frequency of the filter."""
+ """float or PyoObject. Cutoff or Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def bw(self):
- """float or PyoObject. Bandwidth for bandreject and bandpass filters."""
+ """float or PyoObject. Bandwidth for bandreject and bandpass filters."""
return self._bw
@bw.setter
def bw(self, x): self.setBw(x)
@property
def type(self):
- """int. Filter type {0 = lowpass, 1 = highpass, 2 = bandreject, 3 = bandpass}."""
+ """int. Filter type {0 = lowpass, 1 = highpass, 2 = bandreject, 3 = bandpass}."""
return self._type
@type.setter
def type(self, x): self.setType(x)
@@ -2169,8 +2243,8 @@ class IRAverage(PyoObject):
IRAverage uses circular convolution to implement an average filter. This
filter is designed to reduce the noise in the input signal while keeping
- as much as possible the step response of the original signal. User can
- defined the length, in samples, of the impulse response, also known as
+ as much as possible the step response of the original signal. User can
+ defined the length, in samples, of the impulse response, also known as
the filter kernel. This controls the ratio of removed noise vs the fidelity
of the original step response.
@@ -2181,16 +2255,16 @@ class IRAverage(PyoObject):
input : PyoObject
Input signal to process.
order : int {even number}, optional
- Length, in samples, of the filter kernel used for convolution. Available
- at initialization time only. Defaults to 256.
-
- This value must be even. A high order will reduced more noise and will
- have a higher damping effect on the step response, but it is also more
- expensive to compute.
+ Length, in samples, of the filter kernel used for convolution. Available
+ at initialization time only. Defaults to 256.
+
+ This value must be even. A high order will reduced more noise and will
+ have a higher damping effect on the step response, but it is also more
+ expensive to compute.
.. note::
- Convolution is very expensive to compute, so the length of the impulse
+ Convolution is very expensive to compute, so the length of the impulse
response (the `order` parameter) must be kept very short to run in real time.
>>> s = Server().boot()
@@ -2201,6 +2275,7 @@ class IRAverage(PyoObject):
"""
def __init__(self, input, order=256, mul=1, add=0):
+ pyoArgsAssert(self, "oiOO", input, order, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
if (order % 2) != 0:
@@ -2208,7 +2283,7 @@ class IRAverage(PyoObject):
print "order argument of IRAverage must be even, set to %i" % order
self._order = order
self._in_fader = InputFader(input)
- in_fader, order, mul, add, lmax = convertArgsToLists(self._in_fader, order, mul, add)
+ in_fader, order, mul, add, lmax = convertArgsToLists(self._in_fader, order, mul, add)
self._base_objs = [IRAverage_base(wrap(in_fader,i), wrap(order,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setInput(self, x, fadetime=0.05):
@@ -2223,12 +2298,13 @@ class IRAverage(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -2237,10 +2313,10 @@ class IRPulse(PyoObject):
"""
Comb-like filter using circular convolution.
- IRPulse uses circular convolution to implement standard comb-like
- filters consisting of an harmonic series with fundamental `freq` and
- a comb filter with the first notch at `bw` frequency. The `type`
- parameter defines variations of this pattern. User can defined the length,
+ IRPulse uses circular convolution to implement standard comb-like
+ filters consisting of an harmonic series with fundamental `freq` and
+ a comb filter with the first notch at `bw` frequency. The `type`
+ parameter defines variations of this pattern. User can defined the length,
in samples, of the impulse response, also known as the filter kernel.
:Parent: :py:class:`PyoObject`
@@ -2250,7 +2326,7 @@ class IRPulse(PyoObject):
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
- Fundamental frequency of the spikes in the filter's spectrum, expressed
+ Fundamental frequency of the spikes in the filter's spectrum, expressed
in Hertz. Defaults to 500.
bw : float or PyoObject, optional
Frequency, expressed in Hertz, of the first notch in the comb filtering.
@@ -2262,15 +2338,15 @@ class IRPulse(PyoObject):
2. Pulse (odd harmonics) & comb
3. Pulse (odd harmonics) & comb & lowpass
order : int {even number}, optional
- Length, in samples, of the filter kernel used for convolution. Available
+ Length, in samples, of the filter kernel used for convolution. Available
at initialization time only. Defaults to 256.
-
- This value must be even. Higher is the order and sharper is the roll-off
- of the filter, but it is also more expensive to compute.
+
+ This value must be even. Higher is the order and sharper is the roll-off
+ of the filter, but it is also more expensive to compute.
.. note::
- Convolution is very expensive to compute, so the length of the impulse
+ Convolution is very expensive to compute, so the length of the impulse
response (the `order` parameter) must be kept very short to run in real time.
Note that although `freq` and `bw` can be PyoObjects, the impulse response of
@@ -2283,6 +2359,7 @@ class IRPulse(PyoObject):
"""
def __init__(self, input, freq=500, bw=2500, type=0, order=256, mul=1, add=0):
+ pyoArgsAssert(self, "oOOiiOO", input, freq, bw, type, order, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -2293,7 +2370,7 @@ class IRPulse(PyoObject):
print "order argument of IRPulse must be even, set to %i" % order
self._order = order
self._in_fader = InputFader(input)
- in_fader, freq, bw, type, order, mul, add, lmax = convertArgsToLists(self._in_fader, freq, bw, type, order, mul, add)
+ in_fader, freq, bw, type, order, mul, add, lmax = convertArgsToLists(self._in_fader, freq, bw, type, order, mul, add)
self._base_objs = [IRPulse_base(wrap(in_fader,i), wrap(freq,i), wrap(bw,i), wrap(type,i), wrap(order,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setInput(self, x, fadetime=0.05):
@@ -2308,6 +2385,7 @@ class IRPulse(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2321,6 +2399,7 @@ class IRPulse(PyoObject):
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2335,6 +2414,7 @@ class IRPulse(PyoObject):
New `bw` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._bw = x
x, lmax = convertArgsToLists(x)
[obj.setBandwidth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2353,6 +2433,7 @@ class IRPulse(PyoObject):
3. Pulse (odd harmonics) & comb & lowpass
"""
+ pyoArgsAssert(self, "i", x)
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2365,28 +2446,28 @@ class IRPulse(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff or Center frequency of the filter."""
+ """float or PyoObject. Cutoff or Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def bw(self):
- """float or PyoObject. Bandwidth for bandreject and bandpass filters."""
+ """float or PyoObject. Bandwidth for bandreject and bandpass filters."""
return self._bw
@bw.setter
def bw(self, x): self.setBw(x)
@property
def type(self):
- """int. Filter type {0 = pulse, 1 = pulse_lp, 2 = pulse_odd, 3 = pulse_odd_lp}."""
+ """int. Filter type {0 = pulse, 1 = pulse_lp, 2 = pulse_odd, 3 = pulse_odd_lp}."""
return self._type
@type.setter
def type(self, x): self.setType(x)
@@ -2395,8 +2476,8 @@ class IRFM(PyoObject):
"""
Filters a signal with a frequency modulation spectrum using circular convolution.
- IRFM uses circular convolution to implement filtering with a frequency
- modulation spectrum. User can defined the length, in samples, of the
+ IRFM uses circular convolution to implement filtering with a frequency
+ modulation spectrum. User can defined the length, in samples, of the
impulse response, also known as the filter kernel. The higher the `order`,
the narrower the bandwidth around each of the FM components.
@@ -2409,24 +2490,24 @@ class IRFM(PyoObject):
carrier : float or PyoObject, optional
Carrier frequency in cycles per second. Defaults to 1000.
ratio : float or PyoObject, optional
- A factor that, when multiplied by the `carrier` parameter,
+ A factor that, when multiplied by the `carrier` parameter,
gives the modulator frequency. Defaults to 0.5.
index : float or PyoObject, optional
The modulation index. This value multiplied by the modulator
frequency gives the modulator amplitude. Defaults to 3.
order : int {even number}, optional
- Length, in samples, of the filter kernel used for convolution.
+ Length, in samples, of the filter kernel used for convolution.
Available at initialization time only. Defaults to 256.
-
- This value must be even. Higher is the order and sharper is the
+
+ This value must be even. Higher is the order and sharper is the
roll-off of the filter, but it is also more expensive to compute.
.. note::
- Convolution is very expensive to compute, so the length of the impulse
+ Convolution is very expensive to compute, so the length of the impulse
response (the `order` parameter) must be kept very short to run in real time.
- Note that although `carrier`, `ratio` and `index` can be PyoObjects, the
+ Note that although `carrier`, `ratio` and `index` can be PyoObjects, the
impulse response of the filter is only updated once per buffer size.
>>> s = Server().boot()
@@ -2437,6 +2518,7 @@ class IRFM(PyoObject):
"""
def __init__(self, input, carrier=1000, ratio=0.5, index=3, order=256, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOiOO", input, carrier, ratio, index, order, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._carrier = carrier
@@ -2447,7 +2529,7 @@ class IRFM(PyoObject):
print "order argument of IRFM must be even, set to %i" % order
self._order = order
self._in_fader = InputFader(input)
- in_fader, carrier, ratio, index, order, mul, add, lmax = convertArgsToLists(self._in_fader, carrier, ratio, index, order, mul, add)
+ in_fader, carrier, ratio, index, order, mul, add, lmax = convertArgsToLists(self._in_fader, carrier, ratio, index, order, mul, add)
self._base_objs = [IRFM_base(wrap(in_fader,i), wrap(carrier,i), wrap(ratio,i), wrap(index,i), wrap(order,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setInput(self, x, fadetime=0.05):
@@ -2462,6 +2544,7 @@ class IRFM(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2475,6 +2558,7 @@ class IRFM(PyoObject):
New `carrier` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._carrier = x
x, lmax = convertArgsToLists(x)
[obj.setCarrier(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2489,6 +2573,7 @@ class IRFM(PyoObject):
New `ratio` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._ratio = x
x, lmax = convertArgsToLists(x)
[obj.setRatio(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2503,6 +2588,7 @@ class IRFM(PyoObject):
New `index` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._index = x
x, lmax = convertArgsToLists(x)
[obj.setIndex(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2515,58 +2601,58 @@ class IRFM(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def carrier(self):
- """float or PyoObject. Carrier frequency in Hz."""
+ """float or PyoObject. Carrier frequency in Hz."""
return self._carrier
@carrier.setter
def carrier(self, x): self.setCarrier(x)
@property
def ratio(self):
- """float or PyoObject. Modulator/carrier ratio."""
+ """float or PyoObject. Modulator/carrier ratio."""
return self._ratio
@ratio.setter
def ratio(self, x): self.setRatio(x)
@property
def index(self):
- """float or PyoObject. Modulation index."""
+ """float or PyoObject. Modulation index."""
return self._index
@index.setter
def index(self, x): self.setIndex(x)
class SVF(PyoObject):
"""
- Fourth-order state variable filter allowing continuous change of the filter type.
-
+ Fourth-order state variable filter allowing continuous change of the filter type.
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
- Cutoff or center frequency of the filter. Defaults to 1000.
-
- Because this filter becomes unstable at higher frequencies,
+ Cutoff or center frequency of the filter. Defaults to 1000.
+
+ Because this filter becomes unstable at higher frequencies,
the `freq` parameter is limited to one-sixth of the sampling rate.
q : float or PyoObject, optional
- Q of the filter, defined (for bandpass filters) as freq/bandwidth.
+ Q of the filter, defined (for bandpass filters) as freq/bandwidth.
Should be between 0.5 and 50. Defaults to 1.
type : float or PyoObject, optional
- This value, in the range 0 to 1, controls the filter type crossfade
+ This value, in the range 0 to 1, controls the filter type crossfade
on the continuum lowpass-bandpass-highpass.
- 0.0 = lowpass (default)
- 0.5 = bandpass
- 1.0 = highpass
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(.2)
@@ -2577,6 +2663,7 @@ class SVF(PyoObject):
"""
def __init__(self, input, freq=1000, q=1, type=0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOO", input, freq, q, type, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -2589,7 +2676,7 @@ class SVF(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -2598,20 +2685,22 @@ class SVF(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute. Limited in the upper bound to
one-sixth of the sampling rate.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2619,13 +2708,14 @@ class SVF(PyoObject):
def setQ(self, x):
"""
Replace the `q` attribute. Should be between 0.5 and 50.
-
+
:Args:
x : float or PyoObject
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2633,22 +2723,23 @@ class SVF(PyoObject):
def setType(self, x):
"""
Replace the `type` attribute. Must be in the range 0 to 1.
-
- This value allows the filter type to sweep from a lowpass (0)
- to a bandpass (0.5) and then, from the bandpass to a highpass (1).
-
+
+ This value allows the filter type to sweep from a lowpass (0)
+ to a bandpass (0.5) and then, from the bandpass to a highpass (1).
+
:Args:
x : float or PyoObject
- New `type` attribute.
+ New `type` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(20, 7350, "log", "freq", self._freq),
+ self._map_list = [SLMap(20, 7350, "log", "freq", self._freq),
SLMap(0.5, 10, "log", "q", self._q),
SLMap(0, 1, "lin", "type", self._type),
SLMapMul(self._mul)]
@@ -2656,28 +2747,28 @@ class SVF(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff or center frequency of the filter."""
+ """float or PyoObject. Cutoff or center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
- """float or PyoObject. Q of the filter."""
+ """float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def type(self):
- """float or PyoObject. Crossfade between filter types."""
+ """float or PyoObject. Crossfade between filter types."""
return self._type
@type.setter
def type(self, x): self.setType(x)
@@ -2685,22 +2776,22 @@ class SVF(PyoObject):
class Average(PyoObject):
"""
Moving average filter.
-
+
As the name implies, the moving average filter operates by averaging a number
of points from the input signal to produce each point in the output signal.
In spite of its simplicity, the moving average filter is optimal for
a common task: reducing random noise while retaining a sharp step response.
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
size : int, optional
- Filter kernel size, which is the number of samples used in the
+ Filter kernel size, which is the number of samples used in the
moving average. Default to 10.
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(.025)
@@ -2709,6 +2800,7 @@ class Average(PyoObject):
"""
def __init__(self, input, size=10, mul=1, add=0):
+ pyoArgsAssert(self, "oiOO", input, size, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._size = size
@@ -2719,7 +2811,7 @@ class Average(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -2728,19 +2820,21 @@ class Average(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setSize(self, x):
"""
Replace the `size` attribute.
-
+
:Args:
x : int
New `size` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._size = x
x, lmax = convertArgsToLists(x)
[obj.setSize(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2749,43 +2843,43 @@ class Average(PyoObject):
self._map_list = [SLMap(2, 256, 'lin', 'size', self._size, res="int", dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def size(self):
- """int. Filter kernel size in samples."""
+ """int. Filter kernel size in samples."""
return self._size
@size.setter
def size(self, x): self.setSize(x)
class Reson(PyoObject):
"""
- A second-order resonant bandpass filter.
-
+ A second-order resonant bandpass filter.
+
Reson implements a classic resonant bandpass filter, as described in:
-
+
Dodge, C., Jerse, T., "Computer Music, Synthesis, Composition and Performance".
-
+
Reson uses less CPU than the equivalent filter with a Biquad object.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
- Q of the filter, defined as freq/bandwidth.
+ Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(mul=.7)
@@ -2794,6 +2888,7 @@ class Reson(PyoObject):
"""
def __init__(self, input, freq=1000, q=1, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, freq, q, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -2805,7 +2900,7 @@ class Reson(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -2814,19 +2909,21 @@ class Reson(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2834,13 +2931,14 @@ class Reson(PyoObject):
def setQ(self, x):
"""
Replace the `q` attribute. Should be between 1 and 500.
-
+
:Args:
x : float or PyoObject
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2851,36 +2949,36 @@ class Reson(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Center frequency of the filter."""
+ """float or PyoObject. Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
- """float or PyoObject. Q of the filter."""
+ """float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
class Resonx(PyoObject):
"""
- A multi-stages second-order resonant bandpass filter.
-
+ A multi-stages second-order resonant bandpass filter.
+
Resonx implements a stack of the classic resonant bandpass filter, as described in:
-
+
Dodge, C., Jerse, T., "Computer Music, Synthesis, Composition and Performance".
-
+
Resonx is equivalent to a filter consisting of more layers of Reson
with the same arguments, serially connected. It is faster than using
- a large number of instances of the Reson object, it uses less memory
+ a large number of instances of the Reson object, it uses less memory
and allows filters with sharper cutoff.
:Parent: :py:class:`PyoObject`
@@ -2892,7 +2990,7 @@ class Resonx(PyoObject):
freq : float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
- Q of the filter, defined as freq/bandwidth.
+ Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
stages : int, optional
The number of filtering stages in the filter stack. Defaults to 4.
@@ -2905,6 +3003,7 @@ class Resonx(PyoObject):
"""
def __init__(self, input, freq=1000, q=1, stages=4, mul=1, add=0):
+ pyoArgsAssert(self, "oOOiOO", input, freq, q, stages, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -2926,6 +3025,7 @@ class Resonx(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2939,6 +3039,7 @@ class Resonx(PyoObject):
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2953,6 +3054,7 @@ class Resonx(PyoObject):
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2964,9 +3066,10 @@ class Resonx(PyoObject):
:Args:
x : int
- New `stages` attribute.
+ New `stages` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._stages = x
x, lmax = convertArgsToLists(x)
[obj.setStages(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2977,28 +3080,28 @@ class Resonx(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Center frequency of the filter."""
+ """float or PyoObject. Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
- """float or PyoObject. Q of the filter."""
+ """float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@property
def stages(self):
- """int. The number of filtering stages."""
+ """int. The number of filtering stages."""
return self._stages
@stages.setter
def stages(self, x): self.setStages(x)
@@ -3006,20 +3109,20 @@ class Resonx(PyoObject):
class ButLP(PyoObject):
"""
A second-order Butterworth lowpass filter.
-
+
ButLP implements a second-order IIR Butterworth lowpass filter,
- which has a maximally flat passband and a very good precision and
+ which has a maximally flat passband and a very good precision and
stopband attenuation.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 1000.
-
+
>>> s = Server().boot()
>>> s.start()
>>> n = Noise(.3)
@@ -3028,6 +3131,7 @@ class ButLP(PyoObject):
"""
def __init__(self, input, freq=1000, mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -3038,7 +3142,7 @@ class ButLP(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -3047,19 +3151,21 @@ class ButLP(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -3067,17 +3173,17 @@ class ButLP(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff frequency of the filter."""
+ """float or PyoObject. Cutoff frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@@ -3085,20 +3191,20 @@ class ButLP(PyoObject):
class ButHP(PyoObject):
"""
A second-order Butterworth highpass filter.
-
+
ButHP implements a second-order IIR Butterworth highpass filter,
- which has a maximally flat passband and a very good precision and
+ which has a maximally flat passband and a very good precision and
stopband attenuation.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 1000.
-
+
>>> s = Server().boot()
>>> s.start()
>>> n = Noise(.2)
@@ -3107,6 +3213,7 @@ class ButHP(PyoObject):
"""
def __init__(self, input, freq=1000, mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -3117,7 +3224,7 @@ class ButHP(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -3126,19 +3233,21 @@ class ButHP(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -3146,17 +3255,17 @@ class ButHP(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Cutoff frequency of the filter."""
+ """float or PyoObject. Cutoff frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@@ -3164,23 +3273,23 @@ class ButHP(PyoObject):
class ButBP(PyoObject):
"""
A second-order Butterworth bandpass filter.
-
+
ButBP implements a second-order IIR Butterworth bandpass filter,
- which has a maximally flat passband and a very good precision and
+ which has a maximally flat passband and a very good precision and
stopband attenuation.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
- Q of the filter, defined as freq/bandwidth.
+ Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(mul=.7)
@@ -3189,6 +3298,7 @@ class ButBP(PyoObject):
"""
def __init__(self, input, freq=1000, q=1, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, freq, q, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -3200,7 +3310,7 @@ class ButBP(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -3209,19 +3319,21 @@ class ButBP(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -3229,39 +3341,40 @@ class ButBP(PyoObject):
def setQ(self, x):
"""
Replace the `q` attribute. Should be between 1 and 500.
-
+
:Args:
x : float or PyoObject
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMapFreq(self._freq),
+ self._map_list = [SLMapFreq(self._freq),
SLMap(1, 100, "log", "q", self._q), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Center frequency of the filter."""
+ """float or PyoObject. Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
- """float or PyoObject. Q of the filter."""
+ """float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
@@ -3269,23 +3382,23 @@ class ButBP(PyoObject):
class ButBR(PyoObject):
"""
A second-order Butterworth band-reject filter.
-
+
ButBR implements a second-order IIR Butterworth band-reject filter,
- which has a maximally flat passband and a very good precision and
+ which has a maximally flat passband and a very good precision and
stopband attenuation.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
q : float or PyoObject, optional
- Q of the filter, defined as freq/bandwidth.
+ Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(mul=.2)
@@ -3294,6 +3407,7 @@ class ButBR(PyoObject):
"""
def __init__(self, input, freq=1000, q=1, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, freq, q, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -3305,7 +3419,7 @@ class ButBR(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -3314,19 +3428,21 @@ class ButBR(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -3334,54 +3450,55 @@ class ButBR(PyoObject):
def setQ(self, x):
"""
Replace the `q` attribute. Should be between 1 and 500.
-
+
:Args:
x : float or PyoObject
New `q` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._q = x
x, lmax = convertArgsToLists(x)
[obj.setQ(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMapFreq(self._freq),
+ self._map_list = [SLMapFreq(self._freq),
SLMap(1, 100, "log", "q", self._q), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Center frequency of the filter."""
+ """float or PyoObject. Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def q(self):
- """float or PyoObject. Q of the filter."""
+ """float or PyoObject. Q of the filter."""
return self._q
@q.setter
def q(self, x): self.setQ(x)
class ComplexRes(PyoObject):
"""
- Complex one-pole resonator filter.
-
- ComplexRes implements a resonator derived from a complex
+ Complex one-pole resonator filter.
+
+ ComplexRes implements a resonator derived from a complex
multiplication, which is very similar to a digital filter.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
freq : float or PyoObject, optional
@@ -3389,7 +3506,7 @@ class ComplexRes(PyoObject):
decay : float or PyoObject, optional
Decay time, in seconds, for the filter's response.
Defaults to 0.25.
-
+
>>> s = Server().boot()
>>> s.start()
>>> env = HannTable()
@@ -3400,6 +3517,7 @@ class ComplexRes(PyoObject):
"""
def __init__(self, input, freq=1000, decay=.25, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, freq, decay, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._freq = freq
@@ -3411,7 +3529,7 @@ class ComplexRes(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -3420,19 +3538,21 @@ class ComplexRes(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
New `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -3440,39 +3560,40 @@ class ComplexRes(PyoObject):
def setDecay(self, x):
"""
Replace the `decay` attribute.
-
+
:Args:
x : float or PyoObject
New `decay` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._decay = x
x, lmax = convertArgsToLists(x)
[obj.setDecay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMapFreq(self._freq), SLMap(0.0001, 10, "log", "decay", self._decay),
+ self._map_list = [SLMapFreq(self._freq), SLMap(0.0001, 10, "log", "decay", self._decay),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def input(self):
- """PyoObject. Input signal to filter."""
+ """PyoObject. Input signal to filter."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def freq(self):
- """float or PyoObject. Center frequency of the filter."""
+ """float or PyoObject. Center frequency of the filter."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def decay(self):
- """float or PyoObject. Decay time of the filter's response."""
+ """float or PyoObject. Decay time of the filter's response."""
return self._decay
@decay.setter
- def decay(self, x): self.setDecay(x)
+ def decay(self, x): self.setDecay(x)
\ No newline at end of file
diff --git a/pyolib/fourier.py b/pyolib/fourier.py
index d48b223..b30b25f 100644
--- a/pyolib/fourier.py
+++ b/pyolib/fourier.py
@@ -1,37 +1,35 @@
"""
Fast Fourier Transform.
-A Fast Fourier Transform (FFT) is an efficient algorithm to compute
+A Fast Fourier Transform (FFT) is an efficient algorithm to compute
the discrete Fourier transform (DFT) and its inverse (IFFT).
-The objects below can be used to perform sound processing in the
+The objects below can be used to perform sound processing in the
spectral domain.
"""
"""
-Copyright 2011 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
-from _widgets import createSpectrumWindow
-from pattern import Pattern
class FFT(PyoObject):
"""
@@ -39,17 +37,17 @@ class FFT(PyoObject):
FFT analyses an input signal and converts it into the spectral
domain. Three audio signals are sent out of the object, the
- `real` part, from bin 0 (DC) to bin size/2 (Nyquist), the
- `imaginary` part, from bin 0 to bin size/2-1, and the bin
- number, an increasing count from 0 to size-1. `real` and
- `imaginary` buffer's left samples up to size-1 are filled
- with zeros. See notes below for an example of how to retrieve
+ `real` part, from bin 0 (DC) to bin size/2 (Nyquist), the
+ `imaginary` part, from bin 0 to bin size/2-1, and the bin
+ number, an increasing count from 0 to size-1. `real` and
+ `imaginary` buffer's left samples up to size-1 are filled
+ with zeros. See notes below for an example of how to retrieve
each signal component.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
size : int {pow-of-two > 4}, optional
@@ -75,18 +73,18 @@ class FFT(PyoObject):
8. Sine (half-sine window)
.. note::
-
- FFT has no `out` method. Signal must be converted back to time domain,
+
+ FFT has no `out` method. Signal must be converted back to time domain,
with IFFT, before being sent to output.
FFT has no `mul` and `add` attributes.
-
- Real, imaginary and bin_number parts are three separated set
+
+ Real, imaginary and bin_number parts are three separated set
of audio streams. The user should call :
-
- FFT['real'] to retrieve the real part.
- FFT['imag'] to retrieve the imaginary part.
- FFT['bin'] to retrieve the bin number part.
+
+ | FFT['real'] to retrieve the real part.
+ | FFT['imag'] to retrieve the imaginary part.
+ | FFT['bin'] to retrieve the bin number part.
>>> s = Server().boot()
>>> s.start()
@@ -100,6 +98,7 @@ class FFT(PyoObject):
"""
def __init__(self, input, size=1024, overlaps=4, wintype=2):
+ pyoArgsAssert(self, "oiIi", input, size, overlaps, wintype)
PyoObject.__init__(self)
self._real_dummy = []
self._imag_dummy = []
@@ -122,7 +121,7 @@ class FFT(PyoObject):
self._real_objs.append(FFT_base(wrap(self._base_players,j), 0, self._mul, self._add))
self._imag_objs.append(FFT_base(wrap(self._base_players,j), 1, self._mul, self._add))
self._bin_objs.append(FFT_base(wrap(self._base_players,j), 2, self._mul, self._add))
-
+
def __len__(self):
return len(self._real_objs)
@@ -140,12 +139,12 @@ class FFT(PyoObject):
def get(self, identifier="real", all=False):
"""
Return the first sample of the current buffer as a float.
-
+
Can be used to convert audio stream to usable Python data.
-
+
"real", "imag" or "bin" must be given to `identifier` to specify
which stream to get value from.
-
+
:Args:
identifier : string {"real", "imag", "bin"}
@@ -156,17 +155,17 @@ class FFT(PyoObject):
will be returned as a list. Otherwise, only the value
of the first object's stream will be returned as a float.
Defaults to False.
-
+
"""
if not all:
return self.__getitem__(identifier)[0]._getStream().getValue()
else:
return [obj._getStream().getValue() for obj in self.__getitem__(identifier).getBaseObjects()]
-
+
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -175,9 +174,10 @@ class FFT(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def play(self, dur=0, delay=0):
dur, delay, lmax = convertArgsToLists(dur, delay)
self._base_players = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_players)]
@@ -185,7 +185,7 @@ class FFT(PyoObject):
self._imag_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._imag_objs)]
self._bin_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._bin_objs)]
return self
-
+
def stop(self):
[obj.stop() for obj in self._base_players]
[obj.stop() for obj in self._real_objs]
@@ -199,13 +199,14 @@ class FFT(PyoObject):
def setSize(self, x):
"""
Replace the `size` attribute.
-
+
:Args:
x : int
new `size` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._size = x
x, lmax = convertArgsToLists(x)
poly = len(self._base_players) / self._overlaps
@@ -217,20 +218,21 @@ class FFT(PyoObject):
def setWinType(self, x):
"""
Replace the `wintype` attribute.
-
+
:Args:
x : int
new `wintype` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._wintype = x
x, lmax = convertArgsToLists(x)
[obj.setWinType(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -253,17 +255,17 @@ class IFFT(PyoObject):
"""
Inverse Fast Fourier Transform.
- IFFT takes a signal in the spectral domain and converts it to a
- real audio signal using an inverse fast fourier transform.
+ IFFT takes a signal in the spectral domain and converts it to a
+ real audio signal using an inverse fast fourier transform.
IFFT takes two signals in input, the `real` and `imaginary` parts
of an FFT analysis and returns the corresponding real signal.
These signals must correspond to `real` and `imaginary` parts
from an FFT object.
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
inreal : PyoObject
Input `real` signal.
inimag : PyoObject
@@ -271,13 +273,13 @@ class IFFT(PyoObject):
size : int {pow-of-two > 4}, optional
FFT size. Must be a power of two greater than 4.
The FFT size is the number of samples used in each
- analysis frame. This value must match the `size`
+ analysis frame. This value must match the `size`
attribute of the former FFT object. Defaults to 1024.
overlaps : int, optional
The number of overlaped analysis block. Must be a
positive integer. More overlaps can greatly improved
sound quality synthesis but it is also more CPU
- expensive. This value must match the `overlaps`
+ expensive. This value must match the `overlaps`
atribute of the former FFT object. Defaults to 4.
wintype : int, optional
Shape of the envelope used to filter each output frame.
@@ -293,7 +295,7 @@ class IFFT(PyoObject):
8. Sine (half-sine window)
.. note::
-
+
The number of streams in `inreal` and `inimag` attributes
must be egal to the output of the former FFT object. In
most case, it will be `channels of processed sound` * `overlaps`.
@@ -302,7 +304,7 @@ class IFFT(PyoObject):
signal from the overlapped streams. It is left to the user
to call the mix(channels of the processed sound) method on
an IFFT object.
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(.25).mix(2)
@@ -315,6 +317,7 @@ class IFFT(PyoObject):
"""
def __init__(self, inreal, inimag, size=1024, overlaps=4, wintype=2, mul=1, add=0):
+ pyoArgsAssert(self, "ooiIiOO", inreal, inimag, size, overlaps, wintype, mul, add)
PyoObject.__init__(self, mul, add)
self._inreal = inreal
self._inimag = inimag
@@ -332,11 +335,11 @@ class IFFT(PyoObject):
def __len__(self):
return len(self._inreal)
-
+
def setInReal(self, x, fadetime=0.05):
"""
Replace the `inreal` attribute.
-
+
:Args:
x : PyoObject
@@ -345,13 +348,14 @@ class IFFT(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._inreal = x
self._in_fader.setInput(x, fadetime)
def setInImag(self, x, fadetime=0.05):
"""
Replace the `inimag` attribute.
-
+
:Args:
x : PyoObject
@@ -360,19 +364,21 @@ class IFFT(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._inimag = x
self._in_fader2.setInput(x, fadetime)
def setSize(self, x):
"""
Replace the `size` attribute.
-
+
:Args:
x : int
new `size` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._size = x
x, lmax = convertArgsToLists(x)
ratio = len(self._base_objs) / self._overlaps
@@ -383,13 +389,14 @@ class IFFT(PyoObject):
def setWinType(self, x):
"""
Replace the `wintype` attribute.
-
+
:Args:
x : int
new `wintype` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._wintype = x
x, lmax = convertArgsToLists(x)
[obj.setWinType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -397,17 +404,17 @@ class IFFT(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def inreal(self):
- """PyoObject. Real input signal."""
+ """PyoObject. Real input signal."""
return self._inreal
@inreal.setter
def inreal(self, x): self.setInReal(x)
@property
def inimag(self):
- """PyoObject. Imaginary input signal."""
+ """PyoObject. Imaginary input signal."""
return self._inimag
@inimag.setter
def inimag(self, x): self.setInImag(x)
@@ -430,12 +437,12 @@ class CarToPol(PyoObject):
"""
Performs the cartesian to polar conversion.
- The Cartesian system locates points on a plane by measuring the horizontal and
- vertical distances from an arbitrary origin to a point. These are usually denoted
+ The Cartesian system locates points on a plane by measuring the horizontal and
+ vertical distances from an arbitrary origin to a point. These are usually denoted
as a pair of values (X,Y).
- The Polar system locates the point by measuring the straight line distance, usually
- denoted by R, from the origin to the point and the angle of an imaginary line from
+ The Polar system locates the point by measuring the straight line distance, usually
+ denoted by R, from the origin to the point and the angle of an imaginary line from
the origin to the point measured counterclockwise from the positive X axis.
:Parent: :py:class:`PyoObject`
@@ -448,13 +455,13 @@ class CarToPol(PyoObject):
Imaginary input signal.
.. note::
-
+
Polar coordinates can be retrieve by calling :
-
- CarToPol['mag'] to retrieve the magnitude part.
- CarToPol['ang'] to retrieve the angle part.
- CarToPol has no `out` method. Signal must be converted back to time domain,
+ | CarToPol['mag'] to retrieve the magnitude part.
+ | CarToPol['ang'] to retrieve the angle part.
+
+ CarToPol has no `out` method. Signal must be converted back to time domain,
with IFFT, before being sent to output.
>>> s = Server().boot()
@@ -475,6 +482,7 @@ class CarToPol(PyoObject):
"""
def __init__(self, inreal, inimag, mul=1, add=0):
+ pyoArgsAssert(self, "ooOO", inreal, inimag, mul, add)
PyoObject.__init__(self, mul, add)
self._mag_dummy = []
self._ang_dummy = []
@@ -537,6 +545,7 @@ class CarToPol(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._inreal = x
self._in_fader.setInput(x, fadetime)
@@ -552,19 +561,20 @@ class CarToPol(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._inimag = x
self._in_fader2.setInput(x, fadetime)
@property
def inreal(self):
- """PyoObject. Real input signal."""
+ """PyoObject. Real input signal."""
return self._inreal
@inreal.setter
def inreal(self, x): self.setInReal(x)
@property
def inimag(self):
- """PyoObject. Imaginary input signal."""
+ """PyoObject. Imaginary input signal."""
return self._inimag
@inimag.setter
def inimag(self, x): self.setInImag(x)
@@ -573,12 +583,12 @@ class PolToCar(PyoObject):
"""
Performs the polar to cartesian conversion.
- The Polar system locates the point by measuring the straight line distance, usually
- denoted by R, from the origin to the point and the angle of an imaginary line from
+ The Polar system locates the point by measuring the straight line distance, usually
+ denoted by R, from the origin to the point and the angle of an imaginary line from
the origin to the point measured counterclockwise from the positive X axis.
- The Cartesian system locates points on a plane by measuring the horizontal and
- vertical distances from an arbitrary origin to a point. These are usually denoted
+ The Cartesian system locates points on a plane by measuring the horizontal and
+ vertical distances from an arbitrary origin to a point. These are usually denoted
as a pair of values (X,Y).
:Parent: :py:class:`PyoObject`
@@ -593,11 +603,11 @@ class PolToCar(PyoObject):
.. note::
Cartesians coordinates can be retrieve by calling :
-
- PolToCar['real'] to retrieve the real part.
- CarToPol['imag'] to retrieve the imaginary part.
- PolToCar has no `out` method. Signal must be converted back to time domain,
+ | PolToCar['real'] to retrieve the real part.
+ | CarToPol['imag'] to retrieve the imaginary part.
+
+ PolToCar has no `out` method. Signal must be converted back to time domain,
with IFFT, before being sent to output.
>>> s = Server().boot()
@@ -618,6 +628,7 @@ class PolToCar(PyoObject):
"""
def __init__(self, inmag, inang, mul=1, add=0):
+ pyoArgsAssert(self, "ooOO", inmag, inang, mul, add)
PyoObject.__init__(self, mul, add)
self._real_dummy = []
self._imag_dummy = []
@@ -680,6 +691,7 @@ class PolToCar(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._inmag = x
self._in_fader.setInput(x, fadetime)
@@ -695,19 +707,20 @@ class PolToCar(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._inang = x
self._in_fader2.setInput(x, fadetime)
@property
def inmag(self):
- """PyoObject. Magnitude input signal."""
+ """PyoObject. Magnitude input signal."""
return self._inmag
@inmag.setter
def inmag(self, x): self.setInMag(x)
@property
def inang(self):
- """PyoObject. Angle input signal."""
+ """PyoObject. Angle input signal."""
return self._inang
@inang.setter
def inang(self, x): self.setInAng(x)
@@ -716,14 +729,14 @@ class FrameDelta(PyoObject):
"""
Computes the phase differences between successive frames.
- The difference between the phase values of successive FFT frames for a given bin
- determines the exact frequency of the energy centered in that bin. This is often
- known as the phase difference (and sometimes also referred to as phase derivative
+ The difference between the phase values of successive FFT frames for a given bin
+ determines the exact frequency of the energy centered in that bin. This is often
+ known as the phase difference (and sometimes also referred to as phase derivative
or instantaneous frequency if it's been subjected to a few additional calculations).
- In order to reconstruct a plausible playback of re-ordered FFT frames, we need to
- calculate the phase difference between successive frames and use it to construct a
- `running phase` (by simply summing the successive differences with FrameAccum) for
+ In order to reconstruct a plausible playback of re-ordered FFT frames, we need to
+ calculate the phase difference between successive frames and use it to construct a
+ `running phase` (by simply summing the successive differences with FrameAccum) for
the output FFT frames.
:Parent: :py:class:`PyoObject`
@@ -741,7 +754,7 @@ class FrameDelta(PyoObject):
.. note::
- FrameDelta has no `out` method. Signal must be converted back to time domain,
+ FrameDelta has no `out` method. Signal must be converted back to time domain,
with IFFT, before being sent to output.
>>> s = Server().boot()
@@ -766,6 +779,7 @@ class FrameDelta(PyoObject):
"""
def __init__(self, input, framesize=1024, overlaps=4, mul=1, add=0):
+ pyoArgsAssert(self, "oiiOO", input, framesize, overlaps, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._framesize = framesize
@@ -801,6 +815,7 @@ class FrameDelta(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -814,20 +829,21 @@ class FrameDelta(PyoObject):
new `framesize` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._framesize = x
x, lmax = convertArgsToLists(x)
[obj.setFrameSize(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@property
def input(self):
- """PyoObject. Phase input signal."""
+ """PyoObject. Phase input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def framesize(self):
- """PyoObject. Frame size in samples."""
+ """PyoObject. Frame size in samples."""
return self._framesize
@framesize.setter
def framesize(self, x): self.setFrameSize(x)
@@ -836,14 +852,14 @@ class FrameAccum(PyoObject):
"""
Accumulates the phase differences between successive frames.
- The difference between the phase values of successive FFT frames for a given bin
- determines the exact frequency of the energy centered in that bin. This is often
- known as the phase difference (and sometimes also referred to as phase derivative
+ The difference between the phase values of successive FFT frames for a given bin
+ determines the exact frequency of the energy centered in that bin. This is often
+ known as the phase difference (and sometimes also referred to as phase derivative
or instantaneous frequency if it's been subjected to a few additional calculations).
- In order to reconstruct a plausible playback of re-ordered FFT frames, we need to
- calculate the phase difference between successive frames, with FrameDelta, and use
- it to construct a `running phase` (by simply summing the successive differences) for
+ In order to reconstruct a plausible playback of re-ordered FFT frames, we need to
+ calculate the phase difference between successive frames, with FrameDelta, and use
+ it to construct a `running phase` (by simply summing the successive differences) for
the output FFT frames.
:Parent: :py:class:`PyoObject`
@@ -861,7 +877,7 @@ class FrameAccum(PyoObject):
.. note::
- FrameAccum has no `out` method. Signal must be converted back to time domain,
+ FrameAccum has no `out` method. Signal must be converted back to time domain,
with IFFT, before being sent to output.
>>> s = Server().boot()
@@ -886,6 +902,7 @@ class FrameAccum(PyoObject):
"""
def __init__(self, input, framesize=1024, overlaps=4, mul=1, add=0):
+ pyoArgsAssert(self, "oiiOO", input, framesize, overlaps, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._framesize = framesize
@@ -921,6 +938,7 @@ class FrameAccum(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -934,20 +952,21 @@ class FrameAccum(PyoObject):
new `framesize` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._framesize = x
x, lmax = convertArgsToLists(x)
[obj.setFrameSize(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@property
def input(self):
- """PyoObject. Phase input signal."""
+ """PyoObject. Phase input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def framesize(self):
- """PyoObject. Frame size in samples."""
+ """PyoObject. Frame size in samples."""
return self._framesize
@framesize.setter
def framesize(self, x): self.setFrameSize(x)
@@ -985,7 +1004,7 @@ class Vectral(PyoObject):
.. note::
- Vectral has no `out` method. Signal must be converted back to time domain,
+ Vectral has no `out` method. Signal must be converted back to time domain,
with IFFT, before being sent to output.
>>> s = Server().boot()
@@ -1001,6 +1020,7 @@ class Vectral(PyoObject):
"""
def __init__(self, input, framesize=1024, overlaps=4, up=1.0, down=0.7, damp=0.9, mul=1, add=0):
+ pyoArgsAssert(self, "oiiOOOOO", input, framesize, overlaps, up, down, damp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._framesize = framesize
@@ -1039,6 +1059,7 @@ class Vectral(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1052,6 +1073,7 @@ class Vectral(PyoObject):
new `framesize` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._framesize = x
x, lmax = convertArgsToLists(x)
[obj.setFrameSize(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1066,6 +1088,7 @@ class Vectral(PyoObject):
new `up` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._up = x
x, lmax = convertArgsToLists(x)
[obj.setUp(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1080,6 +1103,7 @@ class Vectral(PyoObject):
new `down` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._down = x
x, lmax = convertArgsToLists(x)
[obj.setDown(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1094,6 +1118,7 @@ class Vectral(PyoObject):
new `damp` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._damp = x
x, lmax = convertArgsToLists(x)
[obj.setDamp(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -1107,57 +1132,57 @@ class Vectral(PyoObject):
@property
def input(self):
- """PyoObject. Magnitude input signal."""
+ """PyoObject. Magnitude input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def framesize(self):
- """int. Frame size in samples."""
+ """int. Frame size in samples."""
return self._framesize
@framesize.setter
def framesize(self, x): self.setFrameSize(x)
@property
def up(self):
- """float or PyoObject. Filter coefficient for increasing bins."""
+ """float or PyoObject. Filter coefficient for increasing bins."""
return self._up
@up.setter
def up(self, x): self.setUp(x)
@property
def down(self):
- """float or PyoObject. Filter coefficient for decreasing bins."""
+ """float or PyoObject. Filter coefficient for decreasing bins."""
return self._down
@down.setter
def down(self, x): self.setDown(x)
@property
def damp(self):
- """float or PyoObject. High frequencies damping factor."""
+ """float or PyoObject. High frequencies damping factor."""
return self._damp
@damp.setter
def damp(self, x): self.setDamp(x)
-
+
class CvlVerb(PyoObject):
"""
Convolution based reverb.
- CvlVerb implements convolution based on a uniformly partitioned overlap-save
- algorithm. This object can be used to convolve an input signal with an
+ CvlVerb implements convolution based on a uniformly partitioned overlap-save
+ algorithm. This object can be used to convolve an input signal with an
impulse response soundfile to simulate real acoustic spaces.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
impulse : string, optional
- Path to the impulse response soundfile. The file must have the same
+ Path to the impulse response soundfile. The file must have the same
sampling rate as the server to get the proper convolution. Available at
- initialization time only. Defaults to 'IRMediumHallStereo.wav', located
+ initialization time only. Defaults to 'IRMediumHallStereo.wav', located
in pyolib SNDS_PATH folder.
size : int {pow-of-two}, optional
The size in samples of each partition of the impulse file. Small size means
@@ -1166,9 +1191,9 @@ class CvlVerb(PyoObject):
This value must also be greater or equal than the server's buffer size.
Available at initialization time only. Defaults to 1024.
bal : float or PyoObject, optional
- Balance between wet and dry signal, between 0 and 1. 0 means no
+ Balance between wet and dry signal, between 0 and 1. 0 means no
reverb. Defaults to 0.25.
-
+
>>> s = Server().boot()
>>> s.start()
>>> sf = SfPlayer(SNDS_PATH+"/transparent.aif", loop=True, mul=0.5)
@@ -1176,6 +1201,7 @@ class CvlVerb(PyoObject):
"""
def __init__(self, input, impulse=SNDS_PATH+"/IRMediumHallStereo.wav", bal=0.25, size=1024, mul=1, add=0):
+ pyoArgsAssert(self, "osOiOO", input, impulse, bal, size, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._impulse = impulse
@@ -1193,7 +1219,7 @@ class CvlVerb(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1202,6 +1228,7 @@ class CvlVerb(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1215,6 +1242,7 @@ class CvlVerb(PyoObject):
new `bal` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._bal = x
x, lmax = convertArgsToLists(x)
[obj.setBal(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1226,421 +1254,14 @@ class CvlVerb(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def bal(self):
- """float or PyoObject. Wet / dry balance."""
+ """float or PyoObject. Wet / dry balance."""
return self._bal
@bal.setter
- def bal(self, x): self.setBal(x)
-
-class Spectrum(PyoObject):
- """
- Spectrum analyzer and display.
-
- Spectrum measures the magnitude of an input signal versus frequency
- within a user defined range. It can show both magnitude and frequency
- on linear or logarithmic scale.
-
- :Parent: :py:class:`PyoObject`
-
- :Args:
-
- input : PyoObject
- Input signal to process.
- size : int {pow-of-two > 4}, optional
- FFT size. Must be a power of two greater than 4.
- The FFT size is the number of samples used in each
- analysis frame. Defaults to 1024.
- wintype : int, optional
- Shape of the envelope used to filter each input frame.
- Possible shapes are :
- 0. rectangular (no windowing)
- 1. Hamming
- 2. Hanning
- 3. Bartlett (triangular)
- 4. Blackman 3-term
- 5. Blackman-Harris 4-term
- 6. Blackman-Harris 7-term
- 7. Tuckey (alpha = 0.66)
- 8. Sine (half-sine window)
- function : python callable, optional
- If set, this function will be called with magnitudes (as
- list of lists, one list per channel). Useful if someone
- wants to save the analysis data into a text file.
- Defaults to None.
-
- .. note::
-
- Spectrum has no `out` method.
- Spectrum has no `mul` and `add` attributes.
-
- >>> s = Server().boot()
- >>> s.start()
- >>> a = SuperSaw(freq=[500,750], detune=0.6, bal=0.7, mul=0.5).out()
- >>> spec = Spectrum(a, size=1024)
-
- """
- def __init__(self, input, size=1024, wintype=2, function=None):
- PyoObject.__init__(self)
- self.points = None
- self.viewFrame = None
- self._input = input
- self._size = size
- self._wintype = wintype
- self._function = function
- self._fscaling = 0
- self._mscaling = 1
- self._lowbound = 0
- self._highbound = 0.5
- self._width = 500
- self._height = 400
- self._gain = 1
- self._in_fader = InputFader(input)
- in_fader, size, wintype, lmax = convertArgsToLists(self._in_fader, size, wintype)
- self._base_objs = [Spectrum_base(wrap(in_fader,i), wrap(size,i), wrap(wintype,i)) for i in range(lmax)]
- if function == None:
- self.view()
- self._timer = Pattern(self.refreshView, 0.05).play()
-
- def setInput(self, x, fadetime=0.05):
- """
- Replace the `input` attribute.
-
- :Args:
-
- x : PyoObject
- New signal to process.
- fadetime : float, optional
- Crossfade time between old and new input. Default to 0.05.
-
- """
- self._input = x
- self._in_fader.setInput(x, fadetime)
-
- def setSize(self, x):
- """
- Replace the `size` attribute.
-
- :Args:
-
- x : int
- new `size` attribute.
-
- """
- self._size = x
- x, lmax = convertArgsToLists(x)
- [obj.setSize(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
- def setWinType(self, x):
- """
- Replace the `wintype` attribute.
-
- :Args:
-
- x : int
- new `wintype` attribute.
-
- """
- self._wintype = x
- x, lmax = convertArgsToLists(x)
- [obj.setWinType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
- def setFunction(self, function):
- """
- Sets the function to be called to retrieve the analysis data.
-
- :Args:
-
- function : python callable
- The function called by the internal timer to retrieve the
- analysis data. The function must be created with one argument
- and will receive the data as a list of lists (one list per channel).
-
- """
- self._function = function
-
- def poll(self, active):
- """
- Turns on and off the analysis polling.
-
- :Args:
-
- active : boolean
- If True, starts the analysis polling, False to stop it.
- defaults to True.
-
- """
- if active:
- self._timer.play()
- else:
- self._timer.stop()
-
- def polltime(self, time):
- """
- Sets the polling time in seconds.
-
- :Args:
-
- time : float
- Adjusts the frequency of the internal timer used to
- retrieve the current analysis frame. defaults to 0.05.
-
- """
- self._timer.time = time
-
- def setLowbound(self, x):
- """
- Sets the lower frequency, as multiplier of sr, returned by the analysis.
-
- Returns the real low frequency en Hz.
-
- :Args:
-
- x : float {0 <= x <= 0.5}
- new `lowbound` attribute.
-
- """
- self._lowbound = x
- x, lmax = convertArgsToLists(x)
- tmp = [obj.setLowbound(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
- return tmp[0]
-
- def setHighbound(self, x):
- """
- Sets the higher frequency, as multiplier of sr, returned by the analysis.
-
- Returns the real high frequency en Hz.
-
- :Args:
-
- x : float {0 <= x <= 0.5}
- new `highbound` attribute.
-
- """
- self._highbound = x
- x, lmax = convertArgsToLists(x)
- tmp = [obj.setHighbound(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
- return tmp[0]
-
- def getLowfreq(self):
- """
- Returns the current lower frequency, in Hz, used by the analysis.
-
- """
-
- return self._base_objs[0].getLowfreq()
-
- def getHighfreq(self):
- """
- Returns the current higher frequency, in Hz, used by the analysis.
-
- """
- return self._base_objs[0].getHighfreq()
-
- def setWidth(self, x):
- """
- Sets the width, in pixels, of the current display.
-
- Used internally to build the list of points to draw.
-
- :Args:
-
- x : int
- new `width` attribute.
-
- """
- self._width = x
- x, lmax = convertArgsToLists(x)
- [obj.setWidth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
- def setHeight(self, x):
- """
- Sets the height, in pixels, of the current display.
-
- Used internally to build the list of points to draw.
-
- :Args:
-
- x : int
- new `height` attribute.
-
- """
- self._height = x
- x, lmax = convertArgsToLists(x)
- [obj.setHeight(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
- def setFscaling(self, x):
- """
- Sets the frequency display to linear or logarithmic.
-
- :Args:
-
- x : boolean
- If True, the frequency display is logarithmic. False turns
- it back to linear. Defaults to False.
-
- """
- self._fscaling = x
- x, lmax = convertArgsToLists(x)
- [obj.setFscaling(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
- if self.viewFrame != None:
- self.viewFrame.setFscaling(self._fscaling)
-
- def setMscaling(self, x):
- """
- Sets the magnitude display to linear or logarithmic.
-
- :Args:
-
- x : boolean
- If True, the magnitude display is logarithmic (which means in dB).
- False turns it back to linear. Defaults to True.
-
- """
- self._mscaling = x
- x, lmax = convertArgsToLists(x)
- [obj.setMscaling(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
- if self.viewFrame != None:
- self.viewFrame.setMscaling(self._mscaling)
-
- def getFscaling(self):
- """
- Returns the scaling of the frequency display.
-
- Returns True for logarithmic or False for linear.
-
- """
- return self._fscaling
-
- def getMscaling(self):
- """
- Returns the scaling of the magnitude display.
-
- Returns True for logarithmic or False for linear.
-
- """
- return self._mscaling
-
- def setGain(self, x):
- """
- Set the gain of the anaysis data. For drawing purpose.
-
- :Args:
-
- x : float
- new `gain` attribute, as linear values.
-
- """
- self._gain = x
- x, lmax = convertArgsToLists(x)
- [obj.setGain(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
- def view(self, title="Spectrum", wxnoserver=False):
- """
- Opens a window showing the result of the analysis.
-
- :Args:
-
- title : string, optional
- Window title. Defaults to "Spectrum".
- wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
- interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
-
- """
- createSpectrumWindow(self, title, wxnoserver)
-
- def _setViewFrame(self, frame):
- self.viewFrame = frame
-
- def refreshView(self):
- """
- Updates the graphical display of the spectrum.
-
- Called automatically by the internal timer.
-
- """
- self.points = [obj.display() for obj in self._base_objs]
- if self._function != None:
- self._function(self.points)
- if self.viewFrame != None:
- self.viewFrame.update(self.points)
-
-
- @property
- def input(self):
- """PyoObject. Input signal to process."""
- return self._input
- @input.setter
- def input(self, x): self.setInput(x)
-
- @property
- def size(self):
- """int. FFT size."""
- return self._size
- @size.setter
- def size(self, x): self.setSize(x)
-
- @property
- def wintype(self):
- """int. Windowing method."""
- return self._wintype
- @wintype.setter
- def wintype(self, x): self.setWinType(x)
-
- @property
- def gain(self):
- """float. Sets the gain of the analysis data."""
- return self._gain
- @gain.setter
- def gain(self, x): self.setGain(x)
-
- @property
- def lowbound(self):
- """float. Lowest frequency (multiplier of sr) to output."""
- return self._lowbound
- @lowbound.setter
- def lowbound(self, x): self.setLowbound(x)
-
- @property
- def highbound(self):
- """float. Highest frequency (multiplier of sr) to output."""
- return self._highbound
- @highbound.setter
- def highbound(self, x): self.setHighbound(x)
-
- @property
- def width(self):
- """int. Width, in pixels, of the current display."""
- return self._width
- @width.setter
- def width(self, x): self.setWidth(x)
-
- @property
- def height(self):
- """int. Height, in pixels, of the current display."""
- return self._height
- @height.setter
- def height(self, x): self.setHeight(x)
-
- @property
- def fscaling(self):
- """boolean. Scaling of the frequency display."""
- return self._fscaling
- @fscaling.setter
- def fscaling(self, x): self.setFscaling(x)
-
- @property
- def mscaling(self):
- """boolean. Scaling of the magnitude display."""
- return self._mscaling
- @mscaling.setter
- def mscaling(self, x): self.setMscaling(x)
+ def bal(self, x): self.setBal(x)
\ No newline at end of file
diff --git a/pyolib/generators.py b/pyolib/generators.py
index d4731ca..db2fa97 100644
--- a/pyolib/generators.py
+++ b/pyolib/generators.py
@@ -7,23 +7,23 @@ processing chain or as parameter's modifiers.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
@@ -34,27 +34,28 @@ from _maps import *
class Sine(PyoObject):
"""
A simple sine wave oscillator.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
phase : float or PyoObject, optional
Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Osc`, :py:class:`Phasor`
>>> s = Server().boot()
>>> s.start()
>>> sine = Sine(freq=[400,500], mul=.2).out()
-
+
"""
def __init__(self, freq=1000, phase=0, mul=1, add=0):
+ pyoArgsAssert(self, "OOOO", freq, phase, mul, add)
PyoObject.__init__(self, mul, add)
self._freq = freq
self._phase = phase
@@ -64,27 +65,29 @@ class Sine(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setPhase(self, x):
"""
Replace the `phase` attribute.
-
+
:Args:
x : float or PyoObject
new `phase` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._phase = x
x, lmax = convertArgsToLists(x)
[obj.setPhase(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -100,17 +103,17 @@ class Sine(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapPhase(self._phase), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def phase(self):
- """float or PyoObject. Phase of sampling."""
+ """float or PyoObject. Phase of sampling."""
return self._phase
@phase.setter
def phase(self, x): self.setPhase(x)
@@ -118,7 +121,7 @@ class Sine(PyoObject):
class SineLoop(PyoObject):
"""
A simple sine wave oscillator with feedback.
-
+
The oscillator output, multiplied by `feedback`, is added to the position
increment and can be used to control the brightness of the oscillator.
@@ -129,11 +132,11 @@ class SineLoop(PyoObject):
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
feedback : float or PyoObject, optional
- Amount of the output signal added to position increment, between 0 and 1.
+ Amount of the output signal added to position increment, between 0 and 1.
Controls the brightness. Defaults to 0.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Sine`, :py:class:`OscLoop`
>>> s = Server().boot()
@@ -143,6 +146,7 @@ class SineLoop(PyoObject):
"""
def __init__(self, freq=1000, feedback=0, mul=1, add=0):
+ pyoArgsAssert(self, "OOOO", freq, feedback, mul, add)
PyoObject.__init__(self, mul, add)
self._freq = freq
self._feedback = feedback
@@ -159,6 +163,7 @@ class SineLoop(PyoObject):
new `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -173,6 +178,7 @@ class SineLoop(PyoObject):
new `feedback` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -183,14 +189,14 @@ class SineLoop(PyoObject):
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def feedback(self):
- """float or PyoObject. Brightness control."""
+ """float or PyoObject. Brightness control."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
@@ -198,30 +204,31 @@ class SineLoop(PyoObject):
class Phasor(PyoObject):
"""
A simple phase incrementor.
-
+
Output is a periodic ramp from 0 to 1.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 100.
phase : float or PyoObject, optional
- Phase of sampling, expressed as a fraction of a cycle (0 to 1).
+ Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Osc`, :py:class:`Sine`
-
+
>>> s = Server().boot()
>>> s.start()
>>> f = Phasor(freq=[1, 1.5], mul=1000, add=500)
>>> sine = Sine(freq=f, mul=.2).out()
-
+
"""
def __init__(self, freq=100, phase=0, mul=1, add=0):
+ pyoArgsAssert(self, "OOOO", freq, phase, mul, add)
PyoObject.__init__(self, mul, add)
self._freq = freq
self._phase = phase
@@ -231,27 +238,29 @@ class Phasor(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setPhase(self, x):
"""
Replace the `phase` attribute.
-
+
:Args:
x : float or PyoObject
new `phase` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._phase = x
x, lmax = convertArgsToLists(x)
[obj.setPhase(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -267,17 +276,17 @@ class Phasor(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMapPhase(self._phase), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def phase(self):
- """float or PyoObject. Phase of sampling."""
+ """float or PyoObject. Phase of sampling."""
return self._phase
@phase.setter
def phase(self, x): self.setPhase(x)
@@ -289,21 +298,22 @@ class Input(PyoObject):
:Parent: :py:class:`PyoObject`
:Args:
-
+
chnl : int, optional
Input channel to read from. Defaults to 0.
.. note::
-
- Requires that the Server's duplex mode is set to 1.
-
+
+ Requires that the Server's duplex mode is set to 1.
+
>>> s = Server(duplex=1).boot()
>>> s.start()
>>> a = Input(chnl=0, mul=.7)
>>> b = Delay(a, delay=.25, feedback=.5, mul=.5).out()
-
+
"""
def __init__(self, chnl=0, mul=1, add=0):
+ pyoArgsAssert(self, "iOO", chnl, mul, add)
PyoObject.__init__(self, mul, add)
self._chnl = chnl
chnl, mul, add, lmax = convertArgsToLists(chnl, mul, add)
@@ -316,15 +326,16 @@ class Input(PyoObject):
class Noise(PyoObject):
"""
A white noise generator.
-
+
:Parent: :py:class:`PyoObject`
>>> s = Server().boot()
>>> s.start()
>>> a = Noise(.1).mix(2).out()
-
+
"""
def __init__(self, mul=1, add=0):
+ pyoArgsAssert(self, "OO", mul, add)
PyoObject.__init__(self, mul, add)
self._type = 0
mul, add, lmax = convertArgsToLists(mul, add)
@@ -341,6 +352,7 @@ class Noise(PyoObject):
1 uses a simple linear congruential generator, cheaper than rand().
"""
+ pyoArgsAssert(self, "i", x)
self._type = x
x, lmax = convertArgsToLists(x)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -351,7 +363,7 @@ class Noise(PyoObject):
@property
def type(self):
- """int {0, 1}. Sets the generation algorithm."""
+ """int {0, 1}. Sets the generation algorithm."""
return self._type
@type.setter
def type(self, x): self.setType(x)
@@ -365,7 +377,7 @@ class PinkNoise(PyoObject):
This is an approximation to a -10dB/decade filter using a weighted sum
of first order filters. It is accurate to within +/-0.05dB above 9.2Hz
(44100Hz sampling rate).
-
+
:Parent: :py:class:`PyoObject`
>>> s = Server().boot()
@@ -374,6 +386,7 @@ class PinkNoise(PyoObject):
"""
def __init__(self, mul=1, add=0):
+ pyoArgsAssert(self, "OO", mul, add)
PyoObject.__init__(self, mul, add)
mul, add, lmax = convertArgsToLists(mul, add)
self._base_objs = [PinkNoise_base(wrap(mul,i), wrap(add,i)) for i in range(lmax)]
@@ -386,9 +399,9 @@ class BrownNoise(PyoObject):
"""
A brown noise generator.
- The spectrum of a brown noise has a power density which decreases 6 dB
+ The spectrum of a brown noise has a power density which decreases 6 dB
per octave with increasing frequency (density proportional to 1/f^2).
-
+
:Parent: :py:class:`PyoObject`
>>> s = Server().boot()
@@ -397,6 +410,7 @@ class BrownNoise(PyoObject):
"""
def __init__(self, mul=1, add=0):
+ pyoArgsAssert(self, "OO", mul, add)
PyoObject.__init__(self, mul, add)
mul, add, lmax = convertArgsToLists(mul, add)
self._base_objs = [BrownNoise_base(wrap(mul,i), wrap(add,i)) for i in range(lmax)]
@@ -408,17 +422,17 @@ class BrownNoise(PyoObject):
class FM(PyoObject):
"""
A simple frequency modulation generator.
-
+
Implements frequency modulation synthesis based on Chowning's algorithm.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
carrier : float or PyoObject, optional
Carrier frequency in cycles per second. Defaults to 100.
ratio : float or PyoObject, optional
- A factor that, when multiplied by the `carrier` parameter,
+ A factor that, when multiplied by the `carrier` parameter,
gives the modulator frequency. Defaults to 0.5.
index : float or PyoObject, optional
The modulation index. This value multiplied by the modulator
@@ -430,9 +444,10 @@ class FM(PyoObject):
>>> m = Metro(4).play()
>>> tr = TrigEnv(m, table=ind, dur=4)
>>> f = FM(carrier=[251,250], ratio=[.2498,.2503], index=tr, mul=.2).out()
-
+
"""
def __init__(self, carrier=100, ratio=0.5, index=5, mul=1, add=0):
+ pyoArgsAssert(self, "OOOOO", carrier, ratio, index, mul, add)
PyoObject.__init__(self, mul, add)
self._carrier = carrier
self._ratio = ratio
@@ -443,27 +458,29 @@ class FM(PyoObject):
def setCarrier(self, x):
"""
Replace the `carrier` attribute.
-
+
:Args:
x : float or PyoObject
new `carrier` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._carrier = x
x, lmax = convertArgsToLists(x)
[obj.setCarrier(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setRatio(self, x):
"""
Replace the `ratio` attribute.
-
+
:Args:
x : float or PyoObject
new `ratio` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._ratio = x
x, lmax = convertArgsToLists(x)
[obj.setRatio(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -471,13 +488,14 @@ class FM(PyoObject):
def setIndex(self, x):
"""
Replace the `index` attribute.
-
+
:Args:
x : float or PyoObject
new `index` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._index = x
x, lmax = convertArgsToLists(x)
[obj.setIndex(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -488,24 +506,24 @@ class FM(PyoObject):
SLMap(0, 20, "lin", "index", self._index),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def carrier(self):
- """float or PyoObject. Carrier frequency in cycles per second."""
+ """float or PyoObject. Carrier frequency in cycles per second."""
return self._carrier
@carrier.setter
def carrier(self, x): self.setCarrier(x)
@property
def ratio(self):
- """float or PyoObject. Modulator/Carrier ratio."""
+ """float or PyoObject. Modulator/Carrier ratio."""
return self._ratio
@ratio.setter
def ratio(self, x): self.setRatio(x)
@property
def index(self):
- """float or PyoObject. Modulation index."""
+ """float or PyoObject. Modulation index."""
return self._index
@index.setter
def index(self, x): self.setIndex(x)
@@ -524,17 +542,17 @@ class CrossFM(PyoObject):
carrier : float or PyoObject, optional
Carrier frequency in cycles per second. Defaults to 100.
ratio : float or PyoObject, optional
- A factor that, when multiplied by the `carrier` parameter,
+ A factor that, when multiplied by the `carrier` parameter,
gives the modulator frequency. Defaults to 0.5.
ind1 : float or PyoObject, optional
The carrier index. This value multiplied by the carrier
frequency gives the carrier amplitude for modulating the
- modulation oscillator frequency.
+ modulation oscillator frequency.
Defaults to 2.
ind1 : float or PyoObject, optional
The modulation index. This value multiplied by the modulation
- frequency gives the modulation amplitude for modulating the
- carrier oscillator frequency.
+ frequency gives the modulation amplitude for modulating the
+ carrier oscillator frequency.
Defaults to 2.
>>> s = Server().boot()
@@ -546,6 +564,7 @@ class CrossFM(PyoObject):
"""
def __init__(self, carrier=100, ratio=0.5, ind1=2, ind2=2, mul=1, add=0):
+ pyoArgsAssert(self, "OOOOOO", carrier, ratio, ind1, ind2, mul, add)
PyoObject.__init__(self, mul, add)
self._carrier = carrier
self._ratio = ratio
@@ -564,6 +583,7 @@ class CrossFM(PyoObject):
new `carrier` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._carrier = x
x, lmax = convertArgsToLists(x)
[obj.setCarrier(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -578,6 +598,7 @@ class CrossFM(PyoObject):
new `ratio` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._ratio = x
x, lmax = convertArgsToLists(x)
[obj.setRatio(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -592,6 +613,7 @@ class CrossFM(PyoObject):
new `ind1` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._ind1 = x
x, lmax = convertArgsToLists(x)
[obj.setInd1(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -606,6 +628,7 @@ class CrossFM(PyoObject):
new `ind2` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._ind2 = x
x, lmax = convertArgsToLists(x)
[obj.setInd2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -620,28 +643,28 @@ class CrossFM(PyoObject):
@property
def carrier(self):
- """float or PyoObject. Carrier frequency in cycles per second."""
+ """float or PyoObject. Carrier frequency in cycles per second."""
return self._carrier
@carrier.setter
def carrier(self, x): self.setCarrier(x)
@property
def ratio(self):
- """float or PyoObject. Modulator/Carrier ratio."""
+ """float or PyoObject. Modulator/Carrier ratio."""
return self._ratio
@ratio.setter
def ratio(self, x): self.setRatio(x)
@property
def ind1(self):
- """float or PyoObject. Carrier index."""
+ """float or PyoObject. Carrier index."""
return self._ind1
@ind1.setter
def ind1(self, x): self.setInd1(x)
@property
def ind2(self):
- """float or PyoObject. Modulation index."""
+ """float or PyoObject. Modulation index."""
return self._ind2
@ind2.setter
def ind2(self, x): self.setInd2(x)
@@ -650,7 +673,7 @@ class Blit(PyoObject):
"""
Band limited impulse train synthesis.
- Impulse train generator with control over the number of harmonics
+ Impulse train generator with control over the number of harmonics
in the spectrum, which gives oscillators with very low aliasing.
:Parent: :py:class:`PyoObject`
@@ -670,6 +693,7 @@ class Blit(PyoObject):
"""
def __init__(self, freq=100, harms=40, mul=1, add=0):
+ pyoArgsAssert(self, "OOOO", freq, harms, mul, add)
PyoObject.__init__(self, mul, add)
self._freq = freq
self._harms = harms
@@ -686,6 +710,7 @@ class Blit(PyoObject):
new `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -700,6 +725,7 @@ class Blit(PyoObject):
new `harms` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._harms = x
x, lmax = convertArgsToLists(x)
[obj.setHarms(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -712,14 +738,14 @@ class Blit(PyoObject):
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def harms(self):
- """float or PyoObject. Number of harmonics."""
+ """float or PyoObject. Number of harmonics."""
return self._harms
@harms.setter
def harms(self, x): self.setHarms(x)
@@ -728,32 +754,32 @@ class Rossler(PyoObject):
"""
Chaotic attractor for the Rossler system.
- The Rossler attractor is a system of three non-linear ordinary differential
- equations. These differential equations define a continuous-time dynamical
- system that exhibits chaotic dynamics associated with the fractal properties
+ The Rossler attractor is a system of three non-linear ordinary differential
+ equations. These differential equations define a continuous-time dynamical
+ system that exhibits chaotic dynamics associated with the fractal properties
of the attractor.
-
+
:Parent: :py:class:`PyoObject`
:Args:
pitch : float or PyoObject, optional
- Controls the speed, in the range 0 -> 1, of the variations. With values
- below 0.2, this object can be used as a low frequency oscillator (LFO)
- and above 0.2, it will generate a broad spectrum noise with harmonic peaks.
+ Controls the speed, in the range 0 -> 1, of the variations. With values
+ below 0.2, this object can be used as a low frequency oscillator (LFO)
+ and above 0.2, it will generate a broad spectrum noise with harmonic peaks.
Defaults to 0.25.
chaos : float or PyoObject, optional
- Controls the chaotic behavior, in the range 0 -> 1, of the oscillator.
+ Controls the chaotic behavior, in the range 0 -> 1, of the oscillator.
0 means nearly periodic while 1 is totally chaotic. Defaults to 0.5.
stereo, boolean, optional
- If True, 2 streams will be generated, one with the X variable signal of
+ If True, 2 streams will be generated, one with the X variable signal of
the algorithm and a second composed of the Y variable signal of the algorithm.
- These two signal are strongly related in their frequency spectrum but
+ These two signal are strongly related in their frequency spectrum but
the Y signal is out-of-phase by approximatly 180 degrees. Useful to create
alternating LFOs. Available at initialization only. Defaults to False.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Lorenz`
>>> s = Server().boot()
@@ -763,6 +789,7 @@ class Rossler(PyoObject):
"""
def __init__(self, pitch=0.25, chaos=0.5, stereo=False, mul=1, add=0):
+ pyoArgsAssert(self, "OObOO", pitch, chaos, stereo, mul, add)
PyoObject.__init__(self, mul, add)
self._pitch = pitch
self._chaos = chaos
@@ -785,6 +812,7 @@ class Rossler(PyoObject):
new `pitch` attribute. {0. -> 1.}
"""
+ pyoArgsAssert(self, "O", x)
self._pitch = x
x, lmax = convertArgsToLists(x)
if self._stereo:
@@ -802,6 +830,7 @@ class Rossler(PyoObject):
new `chaos` attribute. {0. -> 1.}
"""
+ pyoArgsAssert(self, "O", x)
self._chaos = x
x, lmax = convertArgsToLists(x)
if self._stereo:
@@ -810,20 +839,20 @@ class Rossler(PyoObject):
[obj.setChaos(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(0., 1., "lin", "pitch", self._pitch),
+ self._map_list = [SLMap(0., 1., "lin", "pitch", self._pitch),
SLMap(0., 1., "lin", "chaos", self._chaos), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def pitch(self):
- """float or PyoObject. Speed of the variations."""
+ """float or PyoObject. Speed of the variations."""
return self._pitch
@pitch.setter
def pitch(self, x): self.setPitch(x)
@property
def chaos(self):
- """float or PyoObject. Chaotic behavior."""
+ """float or PyoObject. Chaotic behavior."""
return self._chaos
@chaos.setter
def chaos(self, x): self.setChaos(x)
@@ -832,9 +861,9 @@ class Lorenz(PyoObject):
"""
Chaotic attractor for the Lorenz system.
- The Lorenz attractor is a system of three non-linear ordinary differential
- equations. These differential equations define a continuous-time dynamical
- system that exhibits chaotic dynamics associated with the fractal properties
+ The Lorenz attractor is a system of three non-linear ordinary differential
+ equations. These differential equations define a continuous-time dynamical
+ system that exhibits chaotic dynamics associated with the fractal properties
of the attractor.
:Parent: :py:class:`PyoObject`
@@ -842,22 +871,22 @@ class Lorenz(PyoObject):
:Args:
pitch : float or PyoObject, optional
- Controls the speed, in the range 0 -> 1, of the variations. With values
- below 0.2, this object can be used as a low frequency oscillator (LFO)
- and above 0.2, it will generate a broad spectrum noise with harmonic peaks.
+ Controls the speed, in the range 0 -> 1, of the variations. With values
+ below 0.2, this object can be used as a low frequency oscillator (LFO)
+ and above 0.2, it will generate a broad spectrum noise with harmonic peaks.
Defaults to 0.25.
chaos : float or PyoObject, optional
- Controls the chaotic behavior, in the range 0 -> 1, of the oscillator.
+ Controls the chaotic behavior, in the range 0 -> 1, of the oscillator.
0 means nearly periodic while 1 is totally chaotic. Defaults to 0.5
stereo, boolean, optional
- If True, 2 streams will be generated, one with the X variable signal of
+ If True, 2 streams will be generated, one with the X variable signal of
the algorithm and a second composed of the Y variable signal of the algorithm.
- These two signal are strongly related in their frequency spectrum but
+ These two signal are strongly related in their frequency spectrum but
the Y signal is out-of-phase by approximatly 180 degrees. Useful to create
alternating LFOs. Available at initialization only. Defaults to False.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Rossler`
>>> s = Server().boot()
@@ -867,6 +896,7 @@ class Lorenz(PyoObject):
"""
def __init__(self, pitch=0.25, chaos=0.5, stereo=False, mul=1, add=0):
+ pyoArgsAssert(self, "OObOO", pitch, chaos, stereo, mul, add)
PyoObject.__init__(self, mul, add)
self._pitch = pitch
self._chaos = chaos
@@ -889,6 +919,7 @@ class Lorenz(PyoObject):
new `pitch` attribute. {0. -> 1.}
"""
+ pyoArgsAssert(self, "O", x)
self._pitch = x
x, lmax = convertArgsToLists(x)
if self._stereo:
@@ -906,6 +937,7 @@ class Lorenz(PyoObject):
new `chaos` attribute. {0. -> 1.}
"""
+ pyoArgsAssert(self, "O", x)
self._chaos = x
x, lmax = convertArgsToLists(x)
if self._stereo:
@@ -914,20 +946,20 @@ class Lorenz(PyoObject):
[obj.setChaos(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(0., 1., "lin", "pitch", self._pitch),
+ self._map_list = [SLMap(0., 1., "lin", "pitch", self._pitch),
SLMap(0., 1., "lin", "chaos", self._chaos), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def pitch(self):
- """float or PyoObject. Speed of the variations."""
+ """float or PyoObject. Speed of the variations."""
return self._pitch
@pitch.setter
def pitch(self, x): self.setPitch(x)
@property
def chaos(self):
- """float or PyoObject. Chaotic behavior."""
+ """float or PyoObject. Chaotic behavior."""
return self._chaos
@chaos.setter
def chaos(self, x): self.setChaos(x)
@@ -965,6 +997,7 @@ class LFO(PyoObject):
"""
def __init__(self, freq=100, sharp=0.5, type=0, mul=1, add=0):
+ pyoArgsAssert(self, "OOiOO", freq, sharp, type, mul, add)
PyoObject.__init__(self, mul, add)
self._freq = freq
self._sharp = sharp
@@ -982,6 +1015,7 @@ class LFO(PyoObject):
New `freq` attribute, in cycles per seconds.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -996,6 +1030,7 @@ class LFO(PyoObject):
New `sharp` attribute, in the range 0 -> 1.
"""
+ pyoArgsAssert(self, "O", x)
self._sharp = x
x, lmax = convertArgsToLists(x)
[obj.setSharp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1016,13 +1051,13 @@ class LFO(PyoObject):
5. Bipolar pulse
6. Sample and hold
7. Modulated Sine
-
+
"""
- if x >= 0 and x < 8:
- self._type = x
- x, lmax = convertArgsToLists(x)
- [obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ pyoArgsAssert(self, "i", x)
+ self._type = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def reset(self):
"""
@@ -1033,29 +1068,29 @@ class LFO(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMapFreq(self._freq),
- SLMap(0., 1., "lin", "sharp", self._sharp),
- SLMap(0, 7, "lin", "type", self._type, "int", dataOnly=True),
+ self._map_list = [SLMapFreq(self._freq),
+ SLMap(0., 1., "lin", "sharp", self._sharp),
+ SLMap(0, 7, "lin", "type", self._type, "int", dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
def freq(self):
- """float or PyoObject. Oscillator frequency in cycles per second."""
+ """float or PyoObject. Oscillator frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def sharp(self):
- """float or PyoObject. Sharpness factor {0 -> 1}."""
+ """float or PyoObject. Sharpness factor {0 -> 1}."""
return self._sharp
@sharp.setter
def sharp(self, x): self.setSharp(x)
@property
def type(self):
- """int. Waveform type."""
+ """int. Waveform type."""
return self._type
@type.setter
def type(self, x): self.setType(x)
@@ -1063,46 +1098,47 @@ class LFO(PyoObject):
class SumOsc(PyoObject):
"""
Discrete summation formulae to produce complex spectra.
-
+
This object implements a discrete summation formulae taken from
- the paper 'The synthesis of complex audio spectra by means of
+ the paper 'The synthesis of complex audio spectra by means of
discrete summation formulae' by James A. Moorer. The formulae
used is of this form:
-
+
(sin(theta) - a * sin(theta - beta)) / (1 + a**2 - 2 * a * cos(beta))
-
- where 'theta' and 'beta' are periodic functions and 'a' is
- the modulation index, providing control over the damping of
+
+ where 'theta' and 'beta' are periodic functions and 'a' is
+ the modulation index, providing control over the damping of
the partials.
-
+
The resulting sound is related to the family of modulation
techniques but this formulae express 'one-sided' spectra,
useful to avoid aliasing from the negative frequencies.
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
freq : float or PyoObject, optional
Base frequency in cycles per second. Defaults to 100.
ratio : float or PyoObject, optional
- A factor used to stretch or compress the partial serie by
- manipulating the frequency of the modulation oscillator.
+ A factor used to stretch or compress the partial serie by
+ manipulating the frequency of the modulation oscillator.
Integer ratios give harmonic spectra. Defaults to 0.5.
index : float or PyoObject, optional
- Damping of successive partials, between 0 and 1. With a
+ Damping of successive partials, between 0 and 1. With a
value of 0.5, each partial is 6dB lower than the previous
partial. Defaults to 5.
-
+
>>> s = Server().boot()
>>> s.start()
>>> ind = LinTable([(0,.3), (20,.85), (300,.7), (1000,.5), (8191,.3)])
>>> m = Metro(4).play()
>>> tr = TrigEnv(m, table=ind, dur=4)
>>> f = SumOsc(freq=[301,300], ratio=[.2498,.2503], index=tr, mul=.2).out()
-
+
"""
def __init__(self, freq=100, ratio=0.5, index=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "OOOOO", freq, ratio, index, mul, add)
PyoObject.__init__(self, mul, add)
self._freq = freq
self._ratio = ratio
@@ -1113,27 +1149,29 @@ class SumOsc(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setRatio(self, x):
"""
Replace the `ratio` attribute.
-
+
:Args:
x : float or PyoObject
new `ratio` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._ratio = x
x, lmax = convertArgsToLists(x)
[obj.setRatio(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1141,13 +1179,14 @@ class SumOsc(PyoObject):
def setIndex(self, x):
"""
Replace the `index` attribute.
-
+
:Args:
x : float or PyoObject
new `index` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._index = x
x, lmax = convertArgsToLists(x)
[obj.setIndex(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1158,24 +1197,24 @@ class SumOsc(PyoObject):
SLMap(0, 1, "lin", "index", self._index),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def freq(self):
- """float or PyoObject. Base frequency in cycles per second."""
+ """float or PyoObject. Base frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def ratio(self):
- """float or PyoObject. Base/modulator frequency ratio."""
+ """float or PyoObject. Base/modulator frequency ratio."""
return self._ratio
@ratio.setter
def ratio(self, x): self.setRatio(x)
@property
def index(self):
- """float or PyoObject. Index, high frequency damping."""
+ """float or PyoObject. Index, high frequency damping."""
return self._index
@index.setter
def index(self, x): self.setIndex(x)
@@ -1183,39 +1222,40 @@ class SumOsc(PyoObject):
class SuperSaw(PyoObject):
"""
Roland JP-8000 Supersaw emulator.
-
+
This object implements an emulation of the Roland JP-8000 Supersaw algorithm.
- The shape of the waveform is produced from 7 sawtooth oscillators detuned
+ The shape of the waveform is produced from 7 sawtooth oscillators detuned
against each other over a period of time. It allows control over the depth
of the detuning and the balance between central and sideband oscillators.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 100.
detune : float or PyoObject, optional
Depth of the detuning, between 0 and 1. 0 means all oscillators are
tuned to the same frequency and 1 means sideband oscillators are at
- maximum detuning regarding the central frequency. Defaults to 0.5.
+ maximum detuning regarding the central frequency. Defaults to 0.5.
bal : float or PyoObject, optional
- Balance between central oscillator and sideband oscillators. A value
+ Balance between central oscillator and sideband oscillators. A value
of 0 outputs only the central oscillator while a value of 1 gives a
mix of all oscillators with the central one lower than the sidebands.
Defaults to 0.7.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Phasor`, :py:class:`SineLoop`
>>> s = Server().boot()
>>> s.start()
>>> lfd = Sine([.4,.3], mul=.2, add=.5)
>>> a = SuperSaw(freq=[49,50], detune=lfd, bal=0.7, mul=0.2).out()
-
+
"""
def __init__(self, freq=100, detune=0.5, bal=0.7, mul=1, add=0):
+ pyoArgsAssert(self, "OOOOO", freq, detune, bal, mul, add)
PyoObject.__init__(self, mul, add)
self._freq = freq
self._detune = detune
@@ -1226,27 +1266,29 @@ class SuperSaw(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setDetune(self, x):
"""
Replace the `detune` attribute.
-
+
:Args:
x : float or PyoObject
new `detune` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._detune = x
x, lmax = convertArgsToLists(x)
[obj.setDetune(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1254,40 +1296,41 @@ class SuperSaw(PyoObject):
def setBal(self, x):
"""
Replace the `bal` attribute.
-
+
:Args:
x : float or PyoObject
new `bal` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._bal = x
x, lmax = convertArgsToLists(x)
[obj.setBal(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMapFreq(self._freq),
- SLMap(0, 1, "lin", "detune", self._detune),
+ self._map_list = [SLMapFreq(self._freq),
+ SLMap(0, 1, "lin", "detune", self._detune),
SLMap(0, 1, "lin", "bal", self._bal), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def detune(self):
- """float or PyoObject. Depth of the detuning."""
+ """float or PyoObject. Depth of the detuning."""
return self._detune
@detune.setter
def detune(self, x): self.setDetune(x)
@property
def bal(self):
- """float or PyoObject. Balance between central and sideband oscillators."""
+ """float or PyoObject. Balance between central and sideband oscillators."""
return self._bal
@bal.setter
def bal(self, x): self.setBal(x)
@@ -1295,14 +1338,14 @@ class SuperSaw(PyoObject):
class RCOsc(PyoObject):
"""
Waveform aproximation of a RC circuit.
-
+
A RC circuit is a capacitor and a resistor in series, giving a logarithmic
growth followed by an exponential decay.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 100.
sharp : float or PyoObject, optional
@@ -1310,17 +1353,18 @@ class RCOsc(PyoObject):
A value of 0 gives a triangular waveform and 1 gives almost a
square wave. Defaults to 0.25.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Osc`, :py:class:`LFO`, :py:class:`SineLoop`, :py:class:`SumOsc`
-
+
>>> s = Server().boot()
>>> s.start()
>>> fr = RCOsc(freq=[.48,.5], sharp=.2, mul=300, add=600)
>>> a = RCOsc(freq=fr, sharp=.1, mul=.2).out()
-
+
"""
def __init__(self, freq=100, sharp=0.25, mul=1, add=0):
+ pyoArgsAssert(self, "OOOO", freq, sharp, mul, add)
PyoObject.__init__(self, mul, add)
self._freq = freq
self._sharp = sharp
@@ -1330,27 +1374,29 @@ class RCOsc(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setSharp(self, x):
"""
Replace the `sharp` attribute.
-
+
:Args:
x : float or PyoObject
new `sharp` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._sharp = x
x, lmax = convertArgsToLists(x)
[obj.setSharp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1365,17 +1411,17 @@ class RCOsc(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMapFreq(self._freq), SLMap(0,1,"lin","sharp",self._sharp), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def sharp(self):
- """float or PyoObject. Sharpness of the waveform."""
+ """float or PyoObject. Sharpness of the waveform."""
return self._sharp
@sharp.setter
- def sharp(self, x): self.setSharp(x)
+ def sharp(self, x): self.setSharp(x)
\ No newline at end of file
diff --git a/pyolib/matrix.py b/pyolib/matrix.py
index 1fea8c5..3ddee00 100644
--- a/pyolib/matrix.py
+++ b/pyolib/matrix.py
@@ -1,22 +1,21 @@
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+GNU Lesser General Public License for more details.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
@@ -28,7 +27,7 @@ class NewMatrix(PyoMatrixObject):
"""
Create a new matrix ready for recording.
- Optionally, the matrix can be filled with the contents of the
+ Optionally, the matrix can be filled with the contents of the
`init` parameter.
See :py:class:`MatrixRec` to write samples in the matrix.
@@ -44,8 +43,8 @@ class NewMatrix(PyoMatrixObject):
init : list of list of floats, optional
Initial matrix. Defaults to None.
- .. seealso::
-
+ .. seealso::
+
:py:class:`MatrixRec`
>>> s = Server().boot()
@@ -61,31 +60,33 @@ class NewMatrix(PyoMatrixObject):
"""
def __init__(self, width, height, init=None):
+ pyoArgsAssert(self, "IIL", width, height, init)
PyoMatrixObject.__init__(self)
self._size = (width, height)
if init == None:
self._base_objs = [NewMatrix_base(width, height)]
else:
self._base_objs = [NewMatrix_base(width, height, init)]
-
+
def replace(self, x):
"""
Replaces the actual matrix.
-
+
:Args:
-
+
x : list of list of floats
New matrix. Must be of the same size as the actual matrix.
"""
+ pyoArgsAssert(self, "l", x)
[obj.setMatrix(x) for obj in self._base_objs]
self.refreshView()
def getRate(self):
"""
- Returns the frequency (cycle per second) to give to an
+ Returns the frequency (cycle per second) to give to an
oscillator to read the sound at its original pitch.
-
+
"""
return self._base_objs[0].getRate()
@@ -103,5 +104,6 @@ class NewMatrix(PyoMatrixObject):
the range 0 -> 1. Defaults to 0.0625.
"""
+ pyoArgsAssert(self, "NN", freq, phase)
[obj.genSineTerrain(freq, phase) for obj in self._base_objs]
- self.refreshView()
+ self.refreshView()
\ No newline at end of file
diff --git a/pyolib/matrixprocess.py b/pyolib/matrixprocess.py
index 3fa4037..9b721a0 100644
--- a/pyolib/matrixprocess.py
+++ b/pyolib/matrixprocess.py
@@ -8,23 +8,23 @@ are done by giving row and column positions.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
@@ -37,9 +37,9 @@ class MatrixRec(PyoObject):
See :py:class:`NewMatrix` to create an empty matrix.
The play method is not called at the object creation time. It starts
- the recording into the matrix, row after row, until the matrix is full.
- Calling the play method again restarts the recording and overwrites
- previously recorded samples. The stop method stops the recording.
+ the recording into the matrix, row after row, until the matrix is full.
+ Calling the play method again restarts the recording and overwrites
+ previously recorded samples. The stop method stops the recording.
Otherwise, the default behaviour is to record through the end of the matrix.
:Parent: :py:class:`PyoObject`
@@ -51,10 +51,10 @@ class MatrixRec(PyoObject):
matrix : PyoMatrixObject
The matrix where to write samples.
fadetime : float, optional
- Fade time at the beginning and the end of the recording
+ Fade time at the beginning and the end of the recording
in seconds. Defaults to 0.
delay : int, optional
- Delay time, in samples, before the recording begins.
+ Delay time, in samples, before the recording begins.
Available at initialization time only. Defaults to 0.
.. note::
@@ -63,12 +63,12 @@ class MatrixRec(PyoObject):
MatrixRec has no `mul` and `add` attributes.
- MatrixRec will sends a trigger signal at the end of the recording.
+ MatrixRec will sends a trigger signal at the end of the recording.
User can retreive the trigger streams by calling obj['trig']. See
`TableRec` documentation for an example.
- .. seealso::
-
+ .. seealso::
+
:py:class:`NewMatrix`
>>> s = Server().boot()
@@ -87,6 +87,7 @@ class MatrixRec(PyoObject):
"""
def __init__(self, input, matrix, fadetime=0, delay=0):
+ pyoArgsAssert(self, "omni", input, matrix, fadetime, delay)
PyoObject.__init__(self)
self._input = input
self._matrix = matrix
@@ -100,14 +101,14 @@ class MatrixRec(PyoObject):
def setMul(self, x):
pass
-
+
def setAdd(self, x):
- pass
+ pass
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -116,26 +117,28 @@ class MatrixRec(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setMatrix(self, x):
"""
Replace the `matrix` attribute.
-
+
:Args:
x : NewMatrix
new `matrix` attribute.
-
+
"""
+ pyoArgsAssert(self, "m", x)
self._matrix = x
x, lmax = convertArgsToLists(x)
[obj.setMatrix(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Audio signal to record in the matrix."""
+ """PyoObject. Audio signal to record in the matrix."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -153,8 +156,8 @@ class MatrixRecLoop(PyoObject):
See :py:class:`NewMatrix` to create an empty matrix.
- MatrixRecLoop records samples into the matrix, row after row, until
- the matrix is full and then loop back to the beginning.
+ MatrixRecLoop records samples into the matrix, row after row, until
+ the matrix is full and then loop back to the beginning.
:Parent: :py:class:`PyoObject`
@@ -171,12 +174,12 @@ class MatrixRecLoop(PyoObject):
MatrixRecLoop has no `mul` and `add` attributes.
- MatrixRecLoop will sends a trigger signal when reaching the end
- of the matrix. User can retreive the trigger streams by calling
+ MatrixRecLoop will sends a trigger signal when reaching the end
+ of the matrix. User can retreive the trigger streams by calling
obj['trig']. See `TableRec` documentation for an example.
- .. seealso::
-
+ .. seealso::
+
:py:class:`NewMatrix`
>>> s = Server().boot()
@@ -194,6 +197,7 @@ class MatrixRecLoop(PyoObject):
"""
def __init__(self, input, matrix):
+ pyoArgsAssert(self, "om", input, matrix)
PyoObject.__init__(self)
self._input = input
self._matrix = matrix
@@ -209,7 +213,7 @@ class MatrixRecLoop(PyoObject):
pass
def setAdd(self, x):
- pass
+ pass
def setInput(self, x, fadetime=0.05):
"""
@@ -223,6 +227,7 @@ class MatrixRecLoop(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -236,13 +241,14 @@ class MatrixRecLoop(PyoObject):
new `matrix` attribute.
"""
+ pyoArgsAssert(self, "m", x)
self._matrix = x
x, lmax = convertArgsToLists(x)
[obj.setMatrix(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Audio signal to record in the matrix."""
+ """PyoObject. Audio signal to record in the matrix."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -285,6 +291,7 @@ class MatrixPointer(PyoObject):
"""
def __init__(self, matrix, x, y, mul=1, add=0):
+ pyoArgsAssert(self, "mooOO", matrix, x, y, mul, add)
PyoObject.__init__(self, mul, add)
self._matrix = matrix
self._x = x
@@ -295,13 +302,14 @@ class MatrixPointer(PyoObject):
def setMatrix(self, x):
"""
Replace the `matrix` attribute.
-
+
:Args:
x : PyoTableObject
new `matrix` attribute.
-
+
"""
+ pyoArgsAssert(self, "m", x)
self._matrix = x
x, lmax = convertArgsToLists(x)
[obj.setMatrix(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -309,13 +317,14 @@ class MatrixPointer(PyoObject):
def setX(self, x):
"""
Replace the `x` attribute.
-
+
:Args:
x : PyoObject
new `x` attribute.
-
+
"""
+ pyoArgsAssert(self, "o", x)
self._x = x
x, lmax = convertArgsToLists(x)
[obj.setX(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -323,13 +332,14 @@ class MatrixPointer(PyoObject):
def setY(self, x):
"""
Replace the `y` attribute.
-
+
:Args:
y : PyoObject
new `y` attribute.
-
+
"""
+ pyoArgsAssert(self, "o", x)
self._y = x
x, lmax = convertArgsToLists(x)
[obj.setY(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -340,21 +350,21 @@ class MatrixPointer(PyoObject):
@property
def matrix(self):
- """PyoMatrixObject. Matrix containing the samples."""
+ """PyoMatrixObject. Matrix containing the samples."""
return self._matrix
@matrix.setter
def matrix(self, x): self.setMatrix(x)
@property
def x(self):
- """PyoObject. Normalized X position in the matrix."""
+ """PyoObject. Normalized X position in the matrix."""
return self._x
@x.setter
def x(self, x): self.setX(x)
@property
def y(self):
- """PyoObject. Normalized Y position in the matrix."""
+ """PyoObject. Normalized Y position in the matrix."""
return self._y
@y.setter
def y(self, x): self.setY(x)
@@ -363,9 +373,9 @@ class MatrixMorph(PyoObject):
"""
Morphs between multiple PyoMatrixObjects.
- Uses an index into a list of PyoMatrixObjects to morph between adjacent
- matrices in the list. The resulting morphed function is written into the
- `matrix` object at the beginning of each buffer size. The matrices in the
+ Uses an index into a list of PyoMatrixObjects to morph between adjacent
+ matrices in the list. The resulting morphed function is written into the
+ `matrix` object at the beginning of each buffer size. The matrices in the
list and the resulting matrix must be equal in size.
:Parent: :py:class:`PyoObject`
@@ -373,7 +383,7 @@ class MatrixMorph(PyoObject):
:Args:
input : PyoObject
- Morphing index between 0 and 1. 0 is the first matrix in the list
+ Morphing index between 0 and 1. 0 is the first matrix in the list
and 1 is the last.
matrix : NewMatrix
The matrix where to write morphed function.
@@ -401,6 +411,7 @@ class MatrixMorph(PyoObject):
"""
def __init__(self, input, matrix, sources):
+ pyoArgsAssert(self, "oml", input, matrix, sources)
PyoObject.__init__(self)
self._input = input
self._matrix = matrix
@@ -417,7 +428,7 @@ class MatrixMorph(PyoObject):
pass
def setAdd(self, x):
- pass
+ pass
def setInput(self, x, fadetime=0.05):
"""
@@ -431,6 +442,7 @@ class MatrixMorph(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -444,6 +456,7 @@ class MatrixMorph(PyoObject):
new `matrix` attribute.
"""
+ pyoArgsAssert(self, "m", x)
self._matrix = x
x, lmax = convertArgsToLists(x)
[obj.setMatrix(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -458,13 +471,14 @@ class MatrixMorph(PyoObject):
new `sources` attribute.
"""
+ pyoArgsAssert(self, "l", x)
self._sources = x
self._base_sources = [source[0] for source in x]
[obj.setSources(self._base_sources) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Morphing index between 0 and 1."""
+ """PyoObject. Morphing index between 0 and 1."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -481,4 +495,4 @@ class MatrixMorph(PyoObject):
"""list of PyoMatrixObject. List of matrices to interpolate from."""
return self._sources
@sources.setter
- def sources(self, x): self.setSources(x)
+ def sources(self, x): self.setSources(x)
\ No newline at end of file
diff --git a/pyolib/midi.py b/pyolib/midi.py
index e305ba4..588fc88 100644
--- a/pyolib/midi.py
+++ b/pyolib/midi.py
@@ -9,23 +9,23 @@ used as controls and can't be sent to the output soundcard.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
from _core import *
@@ -33,18 +33,18 @@ from _maps import *
######################################################################
### MIDI
-######################################################################
+######################################################################
class Midictl(PyoObject):
"""
Get the current value of a Midi controller.
-
- Get the current value of a controller and optionally map it
+
+ Get the current value of a controller and optionally map it
inside a specified range.
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
ctlnumber : int
Controller number.
minscale : float, optional
@@ -58,9 +58,9 @@ class Midictl(PyoObject):
.. note::
- The out() method is bypassed. Midictl's signal can not be sent
+ The out() method is bypassed. Midictl's signal can not be sent
to audio outs.
-
+
>>> s = Server().boot()
>>> s.start()
>>> m = Midictl(ctlnumber=[107,102], minscale=250, maxscale=1000)
@@ -68,9 +68,10 @@ class Midictl(PyoObject):
>>> a = Sine(freq=p, mul=.3).out()
>>> a1 = Sine(freq=p*1.25, mul=.3).out()
>>> a2 = Sine(freq=p*1.5, mul=.3).out()
-
+
"""
def __init__(self, ctlnumber, minscale=0, maxscale=1, init=0, channel=0, mul=1, add=0):
+ pyoArgsAssert(self, "innniOO", ctlnumber, minscale, maxscale, init, channel, mul, add)
PyoObject.__init__(self, mul, add)
self._ctlnumber = ctlnumber
self._minscale = minscale
@@ -92,6 +93,7 @@ class Midictl(PyoObject):
new `ctlnumber` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._ctlnumber = x
x, lmax = convertArgsToLists(x)
[obj.setCtlNumber(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -102,10 +104,11 @@ class Midictl(PyoObject):
:Args:
- x : int
+ x : float
new `minscale` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._minscale = x
x, lmax = convertArgsToLists(x)
[obj.setMinScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -116,10 +119,11 @@ class Midictl(PyoObject):
:Args:
- x : int
+ x : float
new `maxscale` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._maxscale = x
x, lmax = convertArgsToLists(x)
[obj.setMaxScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -134,6 +138,7 @@ class Midictl(PyoObject):
new `channel` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._channel = x
x, lmax = convertArgsToLists(x)
[obj.setChannel(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -148,6 +153,7 @@ class Midictl(PyoObject):
new current value.
"""
+ pyoArgsAssert(self, "n", x)
x, lmax = convertArgsToLists(x)
[obj.setValue(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -161,67 +167,68 @@ class Midictl(PyoObject):
True activates the interpolation, False deactivates it.
"""
+ pyoArgsAssert(self, "b", x)
x, lmax = convertArgsToLists(x)
[obj.setInterpolation(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def ctlnumber(self):
+ def ctlnumber(self):
"""int. Controller number."""
return self._ctlnumber
@ctlnumber.setter
- def ctlnumber(self, x):
- self.setCtlNumber(x)
+ def ctlnumber(self, x):
+ self.setCtlNumber(x)
@property
- def minscale(self):
+ def minscale(self):
"""float. Minimum value for scaling."""
return self._minscale
@minscale.setter
- def minscale(self, x):
- self.setMinScale(x)
+ def minscale(self, x):
+ self.setMinScale(x)
@property
- def maxscale(self):
+ def maxscale(self):
"""float. Maximum value for scaling."""
return self._maxscale
@maxscale.setter
- def maxscale(self, x):
- self.setMaxScale(x)
+ def maxscale(self, x):
+ self.setMaxScale(x)
@property
- def channel(self):
+ def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
- def channel(self, x):
- self.setChannel(x)
+ def channel(self, x):
+ self.setChannel(x)
class CtlScan(PyoObject):
"""
Scan the Midi controller's number in input.
-
+
Scan the Midi controller's number in input and send it to
a standard python `function`. Useful to implement a MidiLearn
algorithm.
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
- function : Python function
+
+ function : Python function (can't be a list)
Function to be called. The function must be declared
- with an argument for the controller number in input. Ex.:
-
+ with an argument for the controller number in input. Ex.:
+
def ctl_scan(ctlnum):
print ctlnum
-
+
toprint : boolean, optional
- If True, controller number and value will be print to
+ If True, controller number and value will be print to
the console.
.. note::
- The out() method is bypassed. CtlScan's signal can not be sent
+ The out() method is bypassed. CtlScan's signal can not be sent
to audio outs.
>>> s = Server()
@@ -231,14 +238,12 @@ class CtlScan(PyoObject):
>>> def ctl_scan(ctlnum):
... print ctlnum
>>> a = CtlScan(ctl_scan)
-
+
"""
def __init__(self, function, toprint=True):
+ pyoArgsAssert(self, "CB", function, toprint)
PyoObject.__init__(self)
- if not callable(function):
- print >> sys.stderr, 'TypeError: "function" argument of %s must be callable.\n' % self.__class__.__name__
- exit()
- self._function = function
+ self._function = WeakMethod(function)
self._toprint = toprint
self._base_objs = [CtlScan_base(self._function, self._toprint)]
@@ -257,6 +262,13 @@ class CtlScan(PyoObject):
def setDiv(self, x):
pass
+ def reset(self):
+ """
+ Resets the scanner.
+
+ """
+ [obj.reset() for obj in self._base_objs]
+
def setFunction(self, x):
"""
Replace the `function` attribute.
@@ -267,9 +279,9 @@ class CtlScan(PyoObject):
new `function` attribute.
"""
- self._function = x
- x, lmax = convertArgsToLists(x)
- [obj.setFunction(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ pyoArgsAssert(self, "C", x)
+ self._function = WeakMethod(x)
+ [obj.setFunction(self._function) for i, obj in enumerate(self._base_objs)]
def setToprint(self, x):
"""
@@ -281,52 +293,53 @@ class CtlScan(PyoObject):
new `toprint` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._toprint = x
x, lmax = convertArgsToLists(x)
[obj.setToprint(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def function(self):
+ def function(self):
"""Python function. Function to be called."""
return self._function
@function.setter
- def function(self, x):
- self.setFunction(x)
+ def function(self, x):
+ self.setFunction(x)
@property
- def toprint(self):
+ def toprint(self):
"""boolean. If True, print values to the console."""
return self._toprint
@toprint.setter
- def toprint(self, x):
- self.setToprint(x)
+ def toprint(self, x):
+ self.setToprint(x)
class CtlScan2(PyoObject):
"""
Scan the Midi channel and controller number in input.
- Scan the Midi channel and controller number in input and send them
- to a standard python `function`. Useful to implement a MidiLearn
+ Scan the Midi channel and controller number in input and send them
+ to a standard python `function`. Useful to implement a MidiLearn
algorithm.
:Parent: :py:class:`PyoObject`
:Args:
- function : Python function
+ function : Python function (can't be a list)
Function to be called. The function must be declared
- with two arguments, one for the controller number and
- one for the midi channel. Ex.:
+ with two arguments, one for the controller number and
+ one for the midi channel. Ex.:
def ctl_scan(ctlnum, midichnl):
print ctlnum, midichnl
toprint : boolean, optional
- If True, controller number and value will be print to
+ If True, controller number and value will be print to
the console.
.. note::
- The out() method is bypassed. CtlScan2's signal can not be sent
+ The out() method is bypassed. CtlScan2's signal can not be sent
to audio outs.
>>> s = Server()
@@ -339,11 +352,9 @@ class CtlScan2(PyoObject):
"""
def __init__(self, function, toprint=True):
+ pyoArgsAssert(self, "CB", function, toprint)
PyoObject.__init__(self)
- if not callable(function):
- print >> sys.stderr, 'TypeError: "function" argument of %s must be callable.\n' % self.__class__.__name__
- exit()
- self._function = function
+ self._function = WeakMethod(function)
self._toprint = toprint
self._base_objs = [CtlScan2_base(self._function, self._toprint)]
@@ -362,6 +373,13 @@ class CtlScan2(PyoObject):
def setDiv(self, x):
pass
+ def reset(self):
+ """
+ Resets the scanner.
+
+ """
+ [obj.reset() for obj in self._base_objs]
+
def setFunction(self, x):
"""
Replace the `function` attribute.
@@ -372,9 +390,9 @@ class CtlScan2(PyoObject):
new `function` attribute.
"""
- self._function = x
- x, lmax = convertArgsToLists(x)
- [obj.setFunction(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ pyoArgsAssert(self, "C", x)
+ self._function = WeakMethod(x)
+ [obj.setFunction(self._function) for i, obj in enumerate(self._base_objs)]
def setToprint(self, x):
"""
@@ -386,49 +404,50 @@ class CtlScan2(PyoObject):
new `toprint` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._toprint = x
x, lmax = convertArgsToLists(x)
[obj.setToprint(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def function(self):
+ def function(self):
"""Python function. Function to be called."""
return self._function
@function.setter
- def function(self, x):
- self.setFunction(x)
+ def function(self, x):
+ self.setFunction(x)
@property
- def toprint(self):
+ def toprint(self):
"""boolean. If True, print values to the console."""
return self._toprint
@toprint.setter
- def toprint(self, x):
- self.setToprint(x)
+ def toprint(self, x):
+ self.setToprint(x)
class Notein(PyoObject):
"""
Generates Midi note messages.
-
- From a Midi device, takes the notes in the range defined with
- `first` and `last` parameters, and outputs up to `poly`
- noteon - noteoff streams in the `scale` format (Midi, hertz
+
+ From a Midi device, takes the notes in the range defined with
+ `first` and `last` parameters, and outputs up to `poly`
+ noteon - noteoff streams in the `scale` format (Midi, hertz
or transpo).
-
+
:Parent: :py:class:`PyoObject`
:Args:
-
+
poly : int, optional
Number of streams of polyphony generated. Defaults to 10.
scale : int, optional
- Pitch output format.
+ Pitch output format.
0. Midi
1. Hertz
- 2. transpo
+ 2. transpo
+
+ In the transpo mode, the default central key (the key where
+ there is no transposition) is (`first` + `last`) / 2.
- In the transpo mode, the default central key (the key where
- there is no transposition) is (`first` + `last`) / 2.
-
The central key can be changed with the setCentralKey method.
first : int, optional
Lowest Midi value. Defaults to 0.
@@ -438,18 +457,24 @@ class Notein(PyoObject):
Midi channel. 0 means all channels. Defaults to 0.
.. note::
-
- Pitch and velocity are two separated set of streams.
+
+ Pitch and velocity are two separated set of streams.
The user should call :
-
- Notein['pitch'] to retrieve pitch streams.
- Notein['velocity'] to retrieve velocity streams.
+
+ | Notein['pitch'] to retrieve pitch streams.
+ | Notein['velocity'] to retrieve velocity streams.
Velocity is automatically scaled between 0 and 1.
-
- The out() method is bypassed. Notein's signal can not be sent
+
+ Notein also outputs trigger streams on noteon and noteoff.
+ These streams can be retrieved with :
+
+ | Notein['trigon'] to retrieve noteon trigger streams.
+ | Notein['trigoff'] to retrieve noteoff trigger streams.
+
+ The out() method is bypassed. Notein's signal can not be sent
to audio outs.
-
+
>>> s = Server().boot()
>>> s.start()
>>> notes = Notein(poly=10, scale=1, mul=.5)
@@ -457,12 +482,15 @@ class Notein(PyoObject):
>>> b = Sine(freq=notes['pitch'], mul=p).out()
>>> c = Sine(freq=notes['pitch'] * 0.997, mul=p).out()
>>> d = Sine(freq=notes['pitch'] * 1.005, mul=p).out()
-
+
"""
def __init__(self, poly=10, scale=0, first=0, last=127, channel=0, mul=1, add=0):
+ pyoArgsAssert(self, "IIIIIOO", poly, scale, first, last, channel, mul, add)
PyoObject.__init__(self, mul, add)
self._pitch_dummy = []
self._velocity_dummy = []
+ self._trigon_dummy = []
+ self._trigoff_dummy = []
self._poly = poly
self._scale = scale
self._first = first
@@ -471,17 +499,26 @@ class Notein(PyoObject):
mul, add, lmax = convertArgsToLists(mul, add)
self._base_handler = MidiNote_base(self._poly, self._scale, self._first, self._last, self._channel)
self._base_objs = []
+ self._trig_objs = []
for i in range(lmax * poly):
self._base_objs.append(Notein_base(self._base_handler, i, 0, 1, 0))
self._base_objs.append(Notein_base(self._base_handler, i, 1, wrap(mul,i), wrap(add,i)))
+ self._trig_objs.append(NoteinTrig_base(self._base_handler, i, 0, 1, 0))
+ self._trig_objs.append(NoteinTrig_base(self._base_handler, i, 1, 1, 0))
def __getitem__(self, str):
if str == 'pitch':
self._pitch_dummy.append(Dummy([self._base_objs[i*2] for i in range(self._poly)]))
return self._pitch_dummy[-1]
- if str == 'velocity':
+ elif str == 'velocity':
self._velocity_dummy.append(Dummy([self._base_objs[i*2+1] for i in range(self._poly)]))
return self._velocity_dummy[-1]
+ elif str == 'trigon':
+ self._trigon_dummy.append(Dummy([self._trig_objs[i*2] for i in range(self._poly)]))
+ return self._trigon_dummy[-1]
+ elif str == 'trigoff':
+ self._trigoff_dummy.append(Dummy([self._trig_objs[i*2+1] for i in range(self._poly)]))
+ return self._trigoff_dummy[-1]
def setChannel(self, x):
"""
@@ -493,13 +530,14 @@ class Notein(PyoObject):
new `channel` attribute.
"""
+ pyoArgsAssert(self, "I", x)
self._channel = x
self._base_handler.setChannel(x)
def setCentralKey(self, x):
"""
Set the midi key where there is no transposition.
-
+
Used for transpo conversion. This value must be greater than or
equal to `first` and lower than or equal to `last`.
@@ -509,12 +547,13 @@ class Notein(PyoObject):
new centralkey value.
"""
+ pyoArgsAssert(self, "I", x)
self._base_handler.setCentralKey(x)
def setStealing(self, x):
"""
Activates the stealing mode if True. Defaults to False.
-
+
In stealing mode, a new note will overwrite the oldest one
according to the polyphony. In non-stealing mode, if the
polyphony is already full, the new notes will be ignored.
@@ -525,17 +564,18 @@ class Notein(PyoObject):
True for stealing mode, False for non-stealing.
"""
+ pyoArgsAssert(self, "B", x)
self._base_handler.setStealing(x)
def get(self, identifier="pitch", all=False):
"""
Return the first sample of the current buffer as a float.
-
+
Can be used to convert audio stream to usable Python data.
-
+
"pitch" or "velocity" must be given to `identifier` to specify
which stream to get value from.
-
+
:Args:
identifier : string {"pitch", "velocity"}
@@ -543,17 +583,17 @@ class Notein(PyoObject):
Defaults to "pitch".
all : boolean, optional
If True, the first value of each object's stream
- will be returned as a list.
-
- Otherwise, only the value of the first object's
+ will be returned as a list.
+
+ Otherwise, only the value of the first object's
stream will be returned as a float.
-
+
"""
if not all:
return self.__getitem__(identifier)[0]._getStream().getValue()
else:
return [obj._getStream().getValue() for obj in self.__getitem__(identifier).getBaseObjects()]
-
+
def play(self, dur=0, delay=0):
self._base_handler.play()
return PyoObject.play(self, dur, delay)
@@ -566,18 +606,18 @@ class Notein(PyoObject):
return PyoObject.stop(self)
@property
- def channel(self):
+ def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
- def channel(self, x):
- self.setChannel(x)
+ def channel(self, x):
+ self.setChannel(x)
class Bendin(PyoObject):
"""
Get the current value of the pitch bend controller.
- Get the current value of the pitch bend controller and optionally
+ Get the current value of the pitch bend controller and optionally
maps it inside a specified range.
:Parent: :py:class:`PyoObject`
@@ -591,15 +631,15 @@ class Bendin(PyoObject):
Output format. Defaults to 0.
0. Midi
1. transpo.
-
- The transpo mode is useful if you want to transpose values that
+
+ The transpo mode is useful if you want to transpose values that
are in a frequency (Hz) format.
channel : int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
- The out() method is bypassed. Bendin's signal can not be sent
+ The out() method is bypassed. Bendin's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -613,6 +653,7 @@ class Bendin(PyoObject):
"""
def __init__(self, brange=2, scale=0, channel=0, mul=1, add=0):
+ pyoArgsAssert(self, "niiOO", brange, scale, channel, mul, add)
PyoObject.__init__(self, mul, add)
self._brange = brange
self._scale = scale
@@ -629,10 +670,11 @@ class Bendin(PyoObject):
:Args:
- x : int
+ x : float
new `brange` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._brange = x
x, lmax = convertArgsToLists(x)
[obj.setBrange(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -647,6 +689,7 @@ class Bendin(PyoObject):
new `scale` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._scale = x
x, lmax = convertArgsToLists(x)
[obj.setScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -661,36 +704,37 @@ class Bendin(PyoObject):
new `channel` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._channel = x
x, lmax = convertArgsToLists(x)
[obj.setChannel(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def brange(self):
+ def brange(self):
"""float. Bipolar range of the pitch bend in semitones."""
return self._brange
@brange.setter
- def brange(self, x): self.setBrange(x)
+ def brange(self, x): self.setBrange(x)
@property
- def scale(self):
+ def scale(self):
"""int. Output format. 0 = Midi, 1 = transpo."""
return self._scale
@scale.setter
- def scale(self, x): self.setScale(x)
+ def scale(self, x): self.setScale(x)
@property
- def channel(self):
+ def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
- def channel(self, x): self.setChannel(x)
+ def channel(self, x): self.setChannel(x)
class Touchin(PyoObject):
"""
Get the current value of an after-touch Midi controller.
- Get the current value of an after-touch Midi controller and optionally
+ Get the current value of an after-touch Midi controller and optionally
maps it inside a specified range.
:Parent: :py:class:`PyoObject`
@@ -708,7 +752,7 @@ class Touchin(PyoObject):
.. note::
- The out() method is bypassed. Touchin's signal can not be sent
+ The out() method is bypassed. Touchin's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -722,6 +766,7 @@ class Touchin(PyoObject):
"""
def __init__(self, minscale=0, maxscale=1, init=0, channel=0, mul=1, add=0):
+ pyoArgsAssert(self, "nnniOO", minscale, maxscale, init, channel, mul, add)
PyoObject.__init__(self, mul, add)
self._minscale = minscale
self._maxscale = maxscale
@@ -738,10 +783,11 @@ class Touchin(PyoObject):
:Args:
- x : int
+ x : float
new `minscale` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._minscale = x
x, lmax = convertArgsToLists(x)
[obj.setMinScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -752,10 +798,11 @@ class Touchin(PyoObject):
:Args:
- x : int
+ x : float
new `maxscale` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._maxscale = x
x, lmax = convertArgsToLists(x)
[obj.setMaxScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -770,33 +817,34 @@ class Touchin(PyoObject):
new `channel` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._channel = x
x, lmax = convertArgsToLists(x)
[obj.setChannel(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def minscale(self):
+ def minscale(self):
"""float. Minimum value for scaling."""
return self._minscale
@minscale.setter
- def minscale(self, x):
- self.setMinScale(x)
+ def minscale(self, x):
+ self.setMinScale(x)
@property
- def maxscale(self):
+ def maxscale(self):
"""float. Maximum value for scaling."""
return self._maxscale
@maxscale.setter
def maxscale(self, x):
- self.setMaxScale(x)
+ self.setMaxScale(x)
@property
- def channel(self):
+ def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
- def channel(self, x):
- self.setChannel(x)
+ def channel(self, x):
+ self.setChannel(x)
class Programin(PyoObject):
"""
@@ -813,7 +861,7 @@ class Programin(PyoObject):
.. note::
- The out() method is bypassed. Programin's signal can not be sent
+ The out() method is bypassed. Programin's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -827,6 +875,7 @@ class Programin(PyoObject):
"""
def __init__(self, channel=0, mul=1, add=0):
+ pyoArgsAssert(self, "iOO", channel, mul, add)
PyoObject.__init__(self, mul, add)
self._channel = channel
channel, mul, add, lmax = convertArgsToLists(channel, mul, add)
@@ -845,23 +894,24 @@ class Programin(PyoObject):
new `channel` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._channel = x
x, lmax = convertArgsToLists(x)
[obj.setChannel(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def channel(self):
+ def channel(self):
"""int. Midi channel. 0 means all channels."""
return self._channel
@channel.setter
- def channel(self, x):
- self.setChannel(x)
+ def channel(self, x):
+ self.setChannel(x)
class MidiAdsr(PyoObject):
"""
Midi triggered ADSR envelope generator.
- Calculates the classical ADSR envelope using linear segments.
+ Calculates the classical ADSR envelope using linear segments.
The envelope starts when it receives a positive value in input,
this value is used as the peak amplitude of the envelope. The
`sustain` parameter is a fraction of the peak value and sets
@@ -899,6 +949,7 @@ class MidiAdsr(PyoObject):
"""
def __init__(self, input, attack=0.01, decay=0.05, sustain=0.7, release=0.1, mul=1, add=0):
+ pyoArgsAssert(self, "onnnnOO", input, attack, decay, sustain, release, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._attack = attack
@@ -924,6 +975,7 @@ class MidiAdsr(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -937,6 +989,7 @@ class MidiAdsr(PyoObject):
new `attack` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._attack = x
x, lmax = convertArgsToLists(x)
[obj.setAttack(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -951,6 +1004,7 @@ class MidiAdsr(PyoObject):
new `decay` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._decay = x
x, lmax = convertArgsToLists(x)
[obj.setDecay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -965,6 +1019,7 @@ class MidiAdsr(PyoObject):
new `sustain` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._sustain = x
x, lmax = convertArgsToLists(x)
[obj.setSustain(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -979,34 +1034,35 @@ class MidiAdsr(PyoObject):
new `sustain` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._release = x
x, lmax = convertArgsToLists(x)
[obj.setRelease(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def attack(self):
- """float. Duration of the attack phase in seconds."""
+ """float. Duration of the attack phase in seconds."""
return self._attack
@attack.setter
def attack(self, x): self.setAttack(x)
@property
def decay(self):
- """float. Duration of the decay phase in seconds."""
+ """float. Duration of the decay phase in seconds."""
return self._decay
@decay.setter
def decay(self, x): self.setDecay(x)
@property
def sustain(self):
- """float. Amplitude of the sustain phase, as fraction of the peak amplitude."""
+ """float. Amplitude of the sustain phase, as fraction of the peak amplitude."""
return self._sustain
@sustain.setter
def sustain(self, x): self.setSustain(x)
@property
def release(self):
- """float. Duration of the release phase in seconds."""
+ """float. Duration of the release phase in seconds."""
return self._release
@release.setter
def release(self, x): self.setRelease(x)
@@ -1015,11 +1071,11 @@ class MidiDelAdsr(PyoObject):
"""
Midi triggered ADSR envelope generator with pre-delay.
- Calculates the classical ADSR envelope using linear segments.
- The envelope starts after `delay` seconds when it receives a
- positive value in input, this value is used as the peak amplitude
- of the envelope. The `sustain` parameter is a fraction of the
- peak value and sets the real sustain value. A 0 in input (note off)
+ Calculates the classical ADSR envelope using linear segments.
+ The envelope starts after `delay` seconds when it receives a
+ positive value in input, this value is used as the peak amplitude
+ of the envelope. The `sustain` parameter is a fraction of the
+ peak value and sets the real sustain value. A 0 in input (note off)
starts the release part of the envelope.
:Parent: :py:class:`PyoObject`
@@ -1031,7 +1087,7 @@ class MidiDelAdsr(PyoObject):
sets the peak amplitude and starts the envelope. A 0 starts
the release part of the envelope.
delay : float, optional
- Duration of the delay phase, before calling the envelope
+ Duration of the delay phase, before calling the envelope
in seconds. Defaults to 0.
attack : float, optional
Duration of the attack phase in seconds. Defaults to 0.01.
@@ -1045,7 +1101,7 @@ class MidiDelAdsr(PyoObject):
.. note::
- The out() method is bypassed. MidiDelAdsr's signal can not be sent
+ The out() method is bypassed. MidiDelAdsr's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -1057,6 +1113,7 @@ class MidiDelAdsr(PyoObject):
"""
def __init__(self, input, delay=0, attack=0.01, decay=0.05, sustain=0.7, release=0.1, mul=1, add=0):
+ pyoArgsAssert(self, "onnnnnOO", input, delay, attack, decay, sustain, release, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._delay = delay
@@ -1083,6 +1140,7 @@ class MidiDelAdsr(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1096,6 +1154,7 @@ class MidiDelAdsr(PyoObject):
new `delay` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._delay = x
x, lmax = convertArgsToLists(x)
[obj.setDelay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1110,6 +1169,7 @@ class MidiDelAdsr(PyoObject):
new `attack` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._attack = x
x, lmax = convertArgsToLists(x)
[obj.setAttack(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1124,6 +1184,7 @@ class MidiDelAdsr(PyoObject):
new `decay` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._decay = x
x, lmax = convertArgsToLists(x)
[obj.setDecay(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1138,6 +1199,7 @@ class MidiDelAdsr(PyoObject):
new `sustain` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._sustain = x
x, lmax = convertArgsToLists(x)
[obj.setSustain(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1152,41 +1214,118 @@ class MidiDelAdsr(PyoObject):
new `sustain` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._release = x
x, lmax = convertArgsToLists(x)
[obj.setRelease(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def delay(self):
- """float. Duration of the delay phase in seconds."""
+ """float. Duration of the delay phase in seconds."""
return self._delay
@delay.setter
def delay(self, x): self.setDelay(x)
@property
def attack(self):
- """float. Duration of the attack phase in seconds."""
+ """float. Duration of the attack phase in seconds."""
return self._attack
@attack.setter
def attack(self, x): self.setAttack(x)
@property
def decay(self):
- """float. Duration of the decay phase in seconds."""
+ """float. Duration of the decay phase in seconds."""
return self._decay
@decay.setter
def decay(self, x): self.setDecay(x)
@property
def sustain(self):
- """float. Amplitude of the sustain phase, as fraction of the peak amplitude."""
+ """float. Amplitude of the sustain phase, as fraction of the peak amplitude."""
return self._sustain
@sustain.setter
def sustain(self, x): self.setSustain(x)
@property
def release(self):
- """float. Duration of the release phase in seconds."""
+ """float. Duration of the release phase in seconds."""
return self._release
@release.setter
def release(self, x): self.setRelease(x)
+
+class RawMidi(PyoObject):
+ """
+ Raw Midi handler.
+
+ This object calls a python function for each raw midi data
+ (status, data1, data2) event for further processing in Python.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ function : Python function (can't be a list)
+ Function to be called. The function must be declared
+ with three arguments, one for the status byte and two
+ for the data bytes. Ex.:
+
+ def event(status, data1, data2):
+ print status, data1, data2
+
+ .. note::
+
+ The out() method is bypassed. RawMidi's signal can not be sent
+ to audio outs.
+
+ >>> s = Server()
+ >>> s.setMidiInputDevice(99) # opens all devices
+ >>> s.boot()
+ >>> s.start()
+ >>> def event(status, data1, data2):
+ ... print status, data1, data2
+ >>> a = RawMidi(event)
+
+ """
+ def __init__(self, function):
+ pyoArgsAssert(self, "C", function)
+ PyoObject.__init__(self)
+ self._function = WeakMethod(function)
+ self._base_objs = [RawMidi_base(self._function)]
+
+ def out(self, chnl=0, inc=1, dur=0, delay=0):
+ return self.play(dur, delay)
+
+ def setMul(self, x):
+ pass
+
+ def setAdd(self, x):
+ pass
+
+ def setSub(self, x):
+ pass
+
+ def setDiv(self, x):
+ pass
+
+ def setFunction(self, x):
+ """
+ Replace the `function` attribute.
+
+ :Args:
+
+ x : Python function
+ new `function` attribute.
+
+ """
+ pyoArgsAssert(self, "C", x)
+ self._function = WeakMethod(x)
+ [obj.setFunction(self._function) for i, obj in enumerate(self._base_objs)]
+
+ @property
+ def function(self):
+ """Python function. Function to be called."""
+ return self._function
+ @function.setter
+ def function(self, x):
+ self.setFunction(x)
diff --git a/pyolib/opensndctrl.py b/pyolib/opensndctrl.py
index 2c27ba0..163cd94 100644
--- a/pyolib/opensndctrl.py
+++ b/pyolib/opensndctrl.py
@@ -4,7 +4,7 @@ Objects to manage values on an Open Sound Control port.
OscSend takes the first value of each buffersize and send it on an
OSC port.
-OscReceive creates and returns audio streams from the value in its
+OscReceive creates and returns audio streams from the value in its
input port.
The audio streams of these objects are essentially intended to be
@@ -13,28 +13,27 @@ controls and can't be sent to the output soundcard.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
-import sys
from _core import *
from _maps import *
-from types import IntType, ListType
+from types import ListType
######################################################################
### Open Sound Control
@@ -43,8 +42,8 @@ class OscSend(PyoObject):
"""
Sends values over a network via the Open Sound Control protocol.
- Uses the OSC protocol to share values to other softwares or other
- computers. Only the first value of each input buffersize will be
+ Uses the OSC protocol to share values to other softwares or other
+ computers. Only the first value of each input buffersize will be
sent on the OSC port.
:Parent: :py:class:`PyoObject`
@@ -54,29 +53,30 @@ class OscSend(PyoObject):
input : PyoObject
Input signal.
port : int
- Port on which values are sent. Receiver should listen on the
+ Port on which values are sent. Receiver should listen on the
same port.
address : string
- Address used on the port to identify values. Address is in
+ Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
host : string, optional
- IP address of the target computer. The default, '127.0.0.1',
+ IP address of the target computer. The default, '127.0.0.1',
is the localhost.
.. note::
- The out() method is bypassed. OscSend's signal can not be sent
+ The out() method is bypassed. OscSend's signal can not be sent
to audio outs.
-
+
OscSend has no `mul` and `add` attributes.
>>> s = Server().boot()
>>> s.start()
>>> a = Sine(freq=[1,1.5], mul=[100,.1], add=[600, .1])
>>> b = OscSend(a, port=10001, address=['/pitch','/amp'])
-
+
"""
def __init__(self, input, port, address, host="127.0.0.1"):
+ pyoArgsAssert(self, "oiss", input, port, address, host)
PyoObject.__init__(self)
self._input = input
self._in_fader = InputFader(input)
@@ -95,22 +95,23 @@ class OscSend(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setMul(self, x):
pass
-
+
def setAdd(self, x):
- pass
+ pass
def setBufferRate(self, x):
"""
Sets how many buffers to wait before sending a new value.
-
+
:Args:
x : int
@@ -118,21 +119,22 @@ class OscSend(PyoObject):
Should be greater or equal to 1.
"""
+ pyoArgsAssert(self, "I", x)
[obj.setBufferRate(x) for obj in self._base_objs]
@property
def input(self):
- """PyoObject. Input signal."""
+ """PyoObject. Input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
-
+
class OscReceive(PyoObject):
"""
Receives values over a network via the Open Sound Control protocol.
- Uses the OSC protocol to receive values from other softwares or
- other computers. Get a value at the beginning of each buffersize
+ Uses the OSC protocol to receive values from other softwares or
+ other computers. Get a value at the beginning of each buffersize
and fill its buffer with it.
:Parent: :py:class:`PyoObject`
@@ -140,25 +142,25 @@ class OscReceive(PyoObject):
:Args:
port : int
- Port on which values are received. Sender should output on
- the same port.
-
- Unlike OscSend object, there can be only one port per OscReceive
- object.
-
+ Port on which values are received. Sender should output on
+ the same port.
+
+ Unlike OscSend object, there can be only one port per OscReceive
+ object.
+
Available at initialization time only.
address : string
- Address used on the port to identify values. Address is in
+ Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
.. note::
- Audio streams are accessed with the `address` string parameter.
+ Audio streams are accessed with the `address` string parameter.
The user should call :
OscReceive['/pitch'] to retreive stream named '/pitch'.
- The out() method is bypassed. OscReceive's signal can not be sent
+ The out() method is bypassed. OscReceive's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -169,10 +171,8 @@ class OscReceive(PyoObject):
"""
def __init__(self, port, address, mul=1, add=0):
+ pyoArgsAssert(self, "IsOO", port, address, mul, add)
PyoObject.__init__(self, mul, add)
- if type(port) != IntType:
- print >> sys.stderr, 'TypeError: "port" argument of %s must be an integer.\n' % self.__class__.__name__
- exit()
address, mul, add, lmax = convertArgsToLists(address, mul, add)
self._address = address
self._mainReceiver = OscReceiver_base(port, address)
@@ -207,6 +207,7 @@ class OscReceive(PyoObject):
Addition factor. Defaults to 0.
"""
+ pyoArgsAssert(self, "sOO", path, mul, add)
path, lmax = convertArgsToLists(path)
mul, add, lmax2 = convertArgsToLists(mul, add)
for i, p in enumerate(path):
@@ -225,6 +226,7 @@ class OscReceive(PyoObject):
Path(s) to remove.
"""
+ pyoArgsAssert(self, "s", path)
path, lmax = convertArgsToLists(path)
self._mainReceiver.delAddress(path)
indexes = [self._address.index(p) for p in path]
@@ -240,29 +242,31 @@ class OscReceive(PyoObject):
x : boolean
True activates the interpolation, False deactivates it.
-
+
"""
+ pyoArgsAssert(self, "B", x)
[obj.setInterpolation(x) for obj in self._base_objs]
def setValue(self, path, value):
"""
Sets value for a given address.
-
+
:Args:
-
+
path : string
Address to which the value should be attributed.
value : float
Value to attribute to the given address.
"""
+ pyoArgsAssert(self, "sn", path, value)
path, value, lmax = convertArgsToLists(path, value)
for i in range(lmax):
p = wrap(path,i)
if p in self._address:
self._mainReceiver.setValue(p, wrap(value,i))
else:
- print 'Error: OscReceive.setValue, Illegal address "%s"' % p
+ print 'Error: OscReceive.setValue, Illegal address "%s"' % p
def get(self, identifier=None, all=False):
"""
@@ -277,7 +281,7 @@ class OscReceive(PyoObject):
identifier : string
Address string parameter identifying audio stream.
- Defaults to None, useful when `all` is True to
+ Defaults to None, useful when `all` is True to
retreive all streams values.
all : boolean, optional
If True, the first value of each object's stream
@@ -290,7 +294,7 @@ class OscReceive(PyoObject):
return self._base_objs[self._address.index(identifier)]._getStream().getValue()
else:
return [obj._getStream().getValue() for obj in self._base_objs]
-
+
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
@@ -298,7 +302,7 @@ class OscDataSend(PyoObject):
"""
Sends data values over a network via the Open Sound Control protocol.
- Uses the OSC protocol to share values to other softwares or other
+ Uses the OSC protocol to share values to other softwares or other
computers. Values are sent on the form of a list containing `types`
elements.
@@ -309,22 +313,28 @@ class OscDataSend(PyoObject):
types : str
String specifying the types sequence of the message to be sent.
Possible values are:
- - integer : "i"
- - long integer : "h"
- - float : "f"
- - double : "d"
- - string : "s"
-
+ - "i" : integer
+ - "h" : long integer
+ - "f" : float
+ - "d" : double
+ - "s" ; string
+ - "b" : blob (list of chars)
+ - "m" : MIDI packet (list of 4 bytes: [midi port, status, data1, data2])
+ - "c" : char
+ - "T" : True
+ - "F" : False
+ - "N" : None (nil)
+
The string "ssfi" indicates that the value to send will be a list
containing two strings followed by a float and an integer.
port : int
- Port on which values are sent. Receiver should listen on the
+ Port on which values are sent. Receiver should listen on the
same port.
address : string
- Address used on the port to identify values. Address is in
+ Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
host : string, optional
- IP address of the target computer. The default, '127.0.0.1',
+ IP address of the target computer. The default, '127.0.0.1',
is the localhost.
.. note::
@@ -335,23 +345,33 @@ class OscDataSend(PyoObject):
>>> s = Server().boot()
>>> s.start()
- >>> a = OscDataSend("fissif", 9900, "/data/test")
>>> def pp(address, *args):
... print address
... print args
- >>> b = OscDataReceive(9900, "/data/test", pp)
+ >>> r = OscDataReceive(9900, "/data/test", pp)
+ >>> # Send various types
+ >>> a = OscDataSend("fissif", 9900, "/data/test")
>>> msg = [3.14159, 1, "Hello", "world!", 2, 6.18]
>>> a.send(msg)
+ >>> # Send a blob
+ >>> b = OscDataSend("b", 9900, "/data/test")
+ >>> msg = [[chr(i) for i in range(10)]]
+ >>> b.send(msg)
+ >>> # Send a MIDI noteon on port 0
+ >>> c = OscDataSend("m", 9900, "/data/test")
+ >>> msg = [[0, 144, 60, 100]]
+ >>> c.send(msg)
"""
- def __init__(self, types, port, address, host="127.0.0.1"):
+ def __init__(self, types, port, address, host="127.0.0.1"):
+ pyoArgsAssert(self, "siss", types, port, address, host)
PyoObject.__init__(self)
types, port, address, host, lmax = convertArgsToLists(types, port, address, host)
self._base_objs = [OscDataSend_base(wrap(types,i), wrap(port,i), wrap(address,i), wrap(host,i)) for i in range(lmax)]
self._addresses = {}
for i, adr in enumerate(address):
self._addresses[adr] = self._base_objs[i]
-
+
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
@@ -359,7 +379,7 @@ class OscDataSend(PyoObject):
pass
def setAdd(self, x):
- pass
+ pass
def getAddresses(self):
"""
@@ -386,16 +406,17 @@ class OscDataSend(PyoObject):
The string "ssfi" indicates that the value to send will be a list
containing two strings followed by a float and an integer.
port : int
- Port on which values are sent. Receiver should listen on the
+ Port on which values are sent. Receiver should listen on the
same port.
address : string
- Address used on the port to identify values. Address is in
+ Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
host : string, optional
- IP address of the target computer. The default, '127.0.0.1',
+ IP address of the target computer. The default, '127.0.0.1',
is the localhost.
"""
+ pyoArgsAssert(self, "siss", types, port, address, host)
types, port, address, host, lmax = convertArgsToLists(types, port, address, host)
objs = [OscDataSend_base(wrap(types,i), wrap(port,i), wrap(address,i), wrap(host,i)) for i in range(lmax)]
self._base_objs.extend(objs)
@@ -412,6 +433,7 @@ class OscDataSend(PyoObject):
Path(s) to remove.
"""
+ pyoArgsAssert(self, "s", path)
path, lmax = convertArgsToLists(path)
for p in path:
self._base_objs.remove(self._addresses[p])
@@ -420,9 +442,9 @@ class OscDataSend(PyoObject):
def send(self, msg, address=None):
"""
Method used to send `msg` values as a list.
-
+
:Args:
-
+
msg : list
List of values to send. Types of values in list
must be of the kind defined of `types` argument
@@ -430,20 +452,22 @@ class OscDataSend(PyoObject):
address : string, optional
Address destination to send values. If None, values
will be sent to all addresses managed by the object.
-
+
"""
if address == None:
+ pyoArgsAssert(self, "l", msg)
[obj.send(msg) for obj in self._base_objs]
else:
+ pyoArgsAssert(self, "lS", msg, address)
self._addresses[address].send(msg)
class OscDataReceive(PyoObject):
"""
Receives data values over a network via the Open Sound Control protocol.
- Uses the OSC protocol to receive data values from other softwares or
+ Uses the OSC protocol to receive data values from other softwares or
other computers. When a message is received, the function given at the
- argument `function` is called with the current address destination in
+ argument `function` is called with the current address destination in
argument followed by a tuple of values.
:Parent: :py:class:`PyoObject`
@@ -451,17 +475,17 @@ class OscDataReceive(PyoObject):
:Args:
port : int
- Port on which values are received. Sender should output on
- the same port. Unlike OscDataSend object, there can be only
- one port per OscDataReceive object. Available at initialization
+ Port on which values are received. Sender should output on
+ the same port. Unlike OscDataSend object, there can be only
+ one port per OscDataReceive object. Available at initialization
time only.
address : string
- Address used on the port to identify values. Address is in
+ Address used on the port to identify values. Address is in
the form of a Unix path (ex.: "/pitch"). There can be as many
addresses as needed on a single port.
- function : callable
+ function : callable (can't be a list)
This function will be called whenever a message with a known
- address is received. there can be only one function per
+ address is received. there can be only one function per
OscDataReceive object. Available at initialization time only.
.. note::
@@ -477,33 +501,37 @@ class OscDataReceive(PyoObject):
>>> s = Server().boot()
>>> s.start()
- >>> a = OscDataSend("fissif", 9900, "/data/test")
>>> def pp(address, *args):
... print address
... print args
- >>> b = OscDataReceive(9900, "/data/test", pp)
+ >>> r = OscDataReceive(9900, "/data/test", pp)
+ >>> # Send various types
+ >>> a = OscDataSend("fissif", 9900, "/data/test")
>>> msg = [3.14159, 1, "Hello", "world!", 2, 6.18]
>>> a.send(msg)
+ >>> # Send a blob
+ >>> b = OscDataSend("b", 9900, "/data/test")
+ >>> msg = [[chr(i) for i in range(10)]]
+ >>> b.send(msg)
+ >>> # Send a MIDI noteon on port 0
+ >>> c = OscDataSend("m", 9900, "/data/test")
+ >>> msg = [[0, 144, 60, 100]]
+ >>> c.send(msg)
"""
def __init__(self, port, address, function):
+ pyoArgsAssert(self, "IsC", port, address, function)
PyoObject.__init__(self)
- if type(port) != IntType:
- print >> sys.stderr, 'TypeError: "port" argument of %s must be an integer.\n' % self.__class__.__name__
- exit()
self._port = port
- if not callable(function):
- print >> sys.stderr, 'TypeError: "function" argument of %s must be callable.\n' % self.__class__.__name__
- exit()
- self._function = function
+ self._function = WeakMethod(function)
self._address, lmax = convertArgsToLists(address)
# self._address is linked with list at C level
- self._base_objs = [OscDataReceive_base(port, self._address, function)]
+ self._base_objs = [OscDataReceive_base(port, self._address, self._function)]
def setMul(self, x):
pass
-
+
def setAdd(self, x):
pass
@@ -513,20 +541,21 @@ class OscDataReceive(PyoObject):
def getAddresses(self):
"""
Returns the addresses managed by the object.
-
+
"""
return self._address
def addAddress(self, path):
"""
Adds new address(es) to the object's handler.
-
+
:Args:
-
+
path : string or list of strings
New path(s) to receive from.
"""
+ pyoArgsAssert(self, "s", path)
path, lmax = convertArgsToLists(path)
for p in path:
if p not in self._address:
@@ -542,6 +571,7 @@ class OscDataReceive(PyoObject):
Path(s) to remove.
"""
+ pyoArgsAssert(self, "s", path)
path, lmax = convertArgsToLists(path)
for p in path:
index = self._address.index(p)
@@ -551,7 +581,7 @@ class OscListReceive(PyoObject):
"""
Receives list of values over a network via the Open Sound Control protocol.
- Uses the OSC protocol to receive list of floating-point values from other
+ Uses the OSC protocol to receive list of floating-point values from other
softwares or other computers. The list are converted into audio streams.
Get values at the beginning of each buffersize and fill buffers with them.
@@ -560,27 +590,27 @@ class OscListReceive(PyoObject):
:Args:
port : int
- Port on which values are received. Sender should output on
- the same port. Unlike OscSend object, there can be only one
- port per OscListReceive object. Available at initialization time
+ Port on which values are received. Sender should output on
+ the same port. Unlike OscSend object, there can be only one
+ port per OscListReceive object. Available at initialization time
only.
address : string
- Address used on the port to identify values. Address is in
+ Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
num : int, optional
Length of the lists in input. The object will generate `num` audio
streams per given address. Available at initialization time only.
- This value can't be a list. That means all addresses managed by an
+ This value can't be a list. That means all addresses managed by an
OscListReceive object are of the same length. Defaults to 8.
.. note::
- Audio streams are accessed with the `address` string parameter.
+ Audio streams are accessed with the `address` string parameter.
The user should call :
OscReceive['/pitch'] to retreive list of streams named '/pitch'.
- The out() method is bypassed. OscReceive's signal can not be sent
+ The out() method is bypassed. OscReceive's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -592,20 +622,15 @@ class OscListReceive(PyoObject):
"""
def __init__(self, port, address, num=8, mul=1, add=0):
+ pyoArgsAssert(self, "IsIOO", port, address, num, mul, add)
PyoObject.__init__(self, mul, add)
- if type(port) != IntType:
- print >> sys.stderr, 'TypeError: "port" argument of %s must be an integer.\n' % self.__class__.__name__
- exit()
- if type(num) != IntType:
- print >> sys.stderr, 'TypeError: "num" argument of %s must be an integer.\n' % self.__class__.__name__
- exit()
self._num = num
self._op_duplicate = self._num
address, mul, add, lmax = convertArgsToLists(address, mul, add)
self._address = address
self._mainReceiver = OscListReceiver_base(port, address, num)
self._base_objs = [OscListReceive_base(self._mainReceiver, wrap(address,i), j, wrap(mul,i), wrap(add,i)) for i in range(lmax) for j in range(self._num)]
-
+
def __getitem__(self, i):
if type(i) == type(''):
first = self._address.index(i) * self._num
@@ -637,6 +662,7 @@ class OscListReceive(PyoObject):
Addition factor. Defaults to 0.
"""
+ pyoArgsAssert(self, "sOO", path, mul, add)
path, lmax = convertArgsToLists(path)
mul, add, lmax2 = convertArgsToLists(mul, add)
for i, p in enumerate(path):
@@ -655,6 +681,7 @@ class OscListReceive(PyoObject):
Path(s) to remove.
"""
+ pyoArgsAssert(self, "s", path)
path, lmax = convertArgsToLists(path)
self._mainReceiver.delAddress(path)
indexes = [self._address.index(p) for p in path]
@@ -674,20 +701,22 @@ class OscListReceive(PyoObject):
True activates the interpolation, False deactivates it.
"""
+ pyoArgsAssert(self, "B", x)
[obj.setInterpolation(x) for obj in self._base_objs]
def setValue(self, path, value):
"""
Sets value for a given address.
-
+
:Args:
-
+
path : string
Address to which the value should be attributed.
value : list of floats
List of values to attribute to the given address.
"""
+ pyoArgsAssert(self, "sl", path, value)
path, lmax = convertArgsToLists(path)
for i in range(lmax):
p = wrap(path,i)
@@ -701,7 +730,7 @@ class OscListReceive(PyoObject):
else:
print 'Error: OscListReceive.setValue, value must be of the same length as the `num` attribute.'
else:
- print 'Error: OscListReceive.setValue, Illegal address "%s"' % p
+ print 'Error: OscListReceive.setValue, Illegal address "%s"' % p
def get(self, identifier=None, all=False):
"""
@@ -716,12 +745,12 @@ class OscListReceive(PyoObject):
identifier : string
Address string parameter identifying audio stream.
- Defaults to None, useful when `all` is True to
+ Defaults to None, useful when `all` is True to
retreive all streams values.
all : boolean, optional
If True, the first list of values of each object's stream
- will be returned as a list of lists. Otherwise, only the
- the list of the object's identifier will be returned as a
+ will be returned as a list of lists. Otherwise, only the
+ the list of the object's identifier will be returned as a
list of floats. Defaults to False.
"""
@@ -737,4 +766,4 @@ class OscListReceive(PyoObject):
return outlist
def out(self, chnl=0, inc=1, dur=0, delay=0):
- return self.play(dur, delay)
+ return self.play(dur, delay)
\ No newline at end of file
diff --git a/pyolib/pan.py b/pyolib/pan.py
index f66eb18..9bf4900 100644
--- a/pyolib/pan.py
+++ b/pyolib/pan.py
@@ -1,32 +1,32 @@
"""
-Set of objects to manage audio voice routing and spread of a sound
+Set of objects to manage audio voice routing and spread of a sound
signal into a new stereo or multi-channel sound field.
-
+
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
import sys, random
from _core import *
from _maps import *
-from types import SliceType, IntType
+from types import SliceType
class Pan(PyoObject):
"""
@@ -39,13 +39,13 @@ class Pan(PyoObject):
input : PyoObject
Input signal to process.
outs : int, optional
- Number of channels on the panning circle. Available at
+ Number of channels on the panning circle. Available at
initialization time only. Defaults to 2.
pan : float or PyoObject
- Position of the sound on the panning circle, between 0 and 1.
+ Position of the sound on the panning circle, between 0 and 1.
Defaults to 0.5.
spread : float or PyoObject
- Amount of sound leaking to the surrounding channels,
+ Amount of sound leaking to the surrounding channels,
between 0 and 1. Defaults to 0.5.
>>> s = Server(nchnls=2).boot()
@@ -53,9 +53,10 @@ class Pan(PyoObject):
>>> a = Noise(mul=.2)
>>> lfo = Sine(freq=1, mul=.5, add=.5)
>>> p = Pan(a, outs=2, pan=lfo).out()
-
- """
+
+ """
def __init__(self, input, outs=2, pan=0.5, spread=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "oIOOOO", input, outs, pan, spread, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._pan = pan
@@ -72,7 +73,7 @@ class Pan(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -81,19 +82,21 @@ class Pan(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setPan(self, x):
"""
Replace the `pan` attribute.
-
+
:Args:
x : float or PyoObject
new `pan` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._pan = x
x, lmax = convertArgsToLists(x)
[obj.setPan(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -101,13 +104,14 @@ class Pan(PyoObject):
def setSpread(self, x):
"""
Replace the `spread` attribute.
-
+
:Args:
x : float or PyoObject
new `spread` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._spread = x
x, lmax = convertArgsToLists(x)
[obj.setSpread(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -124,17 +128,17 @@ class Pan(PyoObject):
return self._input
@input.setter
def input(self, x): self.setInput(x)
-
+
@property
def pan(self):
"""float or PyoObject. Position of the sound on the panning circle."""
return self._pan
@pan.setter
- def pan(self, x): self.setPan(x)
+ def pan(self, x): self.setPan(x)
@property
def spread(self):
- """float or PyoObject. Amount of sound leaking to the surrounding channels."""
+ """float or PyoObject. Amount of sound leaking to the surrounding channels."""
return self._spread
@spread.setter
def spread(self, x): self.setSpread(x)
@@ -150,10 +154,10 @@ class SPan(PyoObject):
input : PyoObject
Input signal to process.
outs : int, optional
- Number of channels on the panning circle. Available at
+ Number of channels on the panning circle. Available at
initialization time only. Defaults to 2.
pan : float or PyoObject
- Position of the sound on the panning circle, between 0 and 1.
+ Position of the sound on the panning circle, between 0 and 1.
Defaults to 0.5.
>>> s = Server(nchnls=2).boot()
@@ -164,6 +168,7 @@ class SPan(PyoObject):
"""
def __init__(self, input, outs=2, pan=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "oIOOO", input, outs, pan, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._outs = outs
@@ -179,7 +184,7 @@ class SPan(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -188,19 +193,21 @@ class SPan(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setPan(self, x):
"""
Replace the `pan` attribute.
-
+
:Args:
x : float or PyoObject
new `pan` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._pan = x
x, lmax = convertArgsToLists(x)
[obj.setPan(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -210,14 +217,14 @@ class SPan(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
- def pan(self):
+ def pan(self):
"""float or PyoObject. Position of the sound on the panning circle."""
return self._pan
@pan.setter
@@ -240,10 +247,10 @@ class Switch(PyoObject):
input : PyoObject
Input signal to process.
outs : int, optional
- Number of outputs. Available at initialization time only.
+ Number of outputs. Available at initialization time only.
Defaults to 2.
voice : float or PyoObject
- Voice position pointer, between 0 and (outs-1) / len(input).
+ Voice position pointer, between 0 and (outs-1) / len(input).
Defaults to 0.
>>> s = Server(nchnls=2).boot()
@@ -257,6 +264,7 @@ class Switch(PyoObject):
"""
def __init__(self, input, outs=2, voice=0., mul=1, add=0):
+ pyoArgsAssert(self, "oIOOO", input, outs, voice, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._outs = outs
@@ -281,6 +289,7 @@ class Switch(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -294,6 +303,7 @@ class Switch(PyoObject):
new `voice` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._voice = x
x, lmax = convertArgsToLists(x)
[obj.setVoice(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -303,14 +313,14 @@ class Switch(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
- def voice(self):
+ def voice(self):
"""float or PyoObject. Voice position pointer."""
return self._voice
@voice.setter
@@ -320,7 +330,7 @@ class Selector(PyoObject):
"""
Audio selector.
- Selector takes multiple PyoObjects in input and interpolates between
+ Selector takes multiple PyoObjects in input and interpolates between
them to generate a single output.
:Parent: :py:class:`PyoObject`
@@ -330,7 +340,7 @@ class Selector(PyoObject):
inputs : list of PyoObject
Audio objects to interpolate from.
voice : float or PyoObject, optional
- Voice position pointer, between 0 and len(inputs)-1.
+ Voice position pointer, between 0 and len(inputs)-1.
Defaults to 0.
>>> s = Server().boot()
@@ -343,6 +353,7 @@ class Selector(PyoObject):
"""
def __init__(self, inputs, voice=0., mul=1, add=0):
+ pyoArgsAssert(self, "lOOO", inputs, voice, mul, add)
PyoObject.__init__(self, mul, add)
self._inputs = inputs
self._voice = voice
@@ -352,8 +363,8 @@ class Selector(PyoObject):
try:
if len(obj) > self._length: self._length = len(obj)
except:
- pass
- self._base_objs = []
+ pass
+ self._base_objs = []
for i in range(self._lmax):
for j in range(self._length):
choice = []
@@ -361,40 +372,42 @@ class Selector(PyoObject):
try:
choice.append(obj[j%len(obj)])
except:
- choice.append(obj)
+ choice.append(obj)
self._base_objs.append(Selector_base(choice, wrap(voice,i), wrap(mul,i), wrap(add,i)))
def setInputs(self, x):
"""
Replace the `inputs` attribute.
-
+
:Args:
x : list of PyoObject
new `inputs` attribute.
-
+
"""
+ pyoArgsAssert(self, "l", x)
self._inputs = x
- for i in range(self._lmax):
+ for i in range(self._lmax):
for j in range(self._length):
choice = []
for obj in self._inputs:
try:
choice.append(obj[j%len(obj)])
except:
- choice.append(obj)
+ choice.append(obj)
self._base_objs[i+j*self._lmax].setInputs(choice)
def setVoice(self, x):
"""
Replace the `voice` attribute.
-
+
:Args:
x : float or PyoObject
new `voice` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._voice = x
x, lmax = convertArgsToLists(x)
for i, obj in enumerate(self._base_objs):
@@ -405,18 +418,18 @@ class Selector(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def inputs(self):
+ def inputs(self):
"""List of PyoObjects. Audio objects to interpolate from."""
return self._inputs
@inputs.setter
- def inputs(self, x):
+ def inputs(self, x):
self.setInputs(x)
@property
- def voice(self):
+ def voice(self):
"""float or PyoObject. Voice position pointer."""
return self._voice
@voice.setter
- def voice(self, x):
+ def voice(self, x):
self.setVoice(x)
class VoiceManager(PyoObject):
@@ -428,7 +441,7 @@ class VoiceManager(PyoObject):
the same position in the list of triggers given at the argument `triggers`.
Usually, the trigger enabling the voice number will come from the process
- started with the object output. So, it's common to leave the `triggers`
+ started with the object output. So, it's common to leave the `triggers`
argument to None and set the list of triggers afterward with the `setTriggers`
method. The maximum number of voices generated by the object is the length
of the trigger list.
@@ -443,8 +456,8 @@ class VoiceManager(PyoObject):
Trigger stream asking for new voice numbers.
triggers : PyoObject or list of PyoObject, optional
List of mono PyoObject sending triggers. Can be a multi-streams
- PyoObject but not a mix of both.
-
+ PyoObject but not a mix of both.
+
Ordering in the list corresponds to voice numbers. Defaults to None.
>>> s = Server().boot()
@@ -457,9 +470,10 @@ class VoiceManager(PyoObject):
>>> amp = TrigEnv(sel, table=env, dur=.5, mul=.25)
>>> synth1 = SineLoop(pit, feedback=.07, mul=amp).out()
>>> vm.setTriggers(amp["trig"])
-
+
"""
def __init__(self, input, triggers=None, mul=1, add=0):
+ #pyoArgsAssert(self, "ooOO", input, triggers, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._triggers = triggers
@@ -482,7 +496,7 @@ class VoiceManager(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -491,19 +505,21 @@ class VoiceManager(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setTriggers(self, x):
"""
Replace the `triggers` attribute.
-
+
:Args:
- x : PyoObject or list of PyoObject
+ x : PyoObject or list of PyoObject
New `triggers` attribute.
"""
+ #pyoArgsAssert(self, "o", x)
self._triggers = x
if x != None:
if type(x) == ListType:
@@ -519,25 +535,25 @@ class VoiceManager(PyoObject):
@property
def input(self):
- """PyoObject. Trigger stream asking for new voice numbers."""
+ """PyoObject. Trigger stream asking for new voice numbers."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def triggers(self):
+ def triggers(self):
"""list of PyoObject. Trigger streams enabling voices."""
return self._triggers
@triggers.setter
- def triggers(self, x):
+ def triggers(self, x):
self.setTriggers(x)
class Mixer(PyoObject):
"""
Audio mixer.
- Mixer mixes multiple inputs to an arbitrary number of outputs
- with independant amplitude values per mixing channel and a
+ Mixer mixes multiple inputs to an arbitrary number of outputs
+ with independant amplitude values per mixing channel and a
user defined portamento applied on amplitude changes.
:Parent: :py:class:`PyoObject`
@@ -577,13 +593,8 @@ class Mixer(PyoObject):
"""
def __init__(self, outs=2, chnls=1, time=0.025, mul=1, add=0):
+ pyoArgsAssert(self, "IInOO", outs, chnls, time, mul, add)
PyoObject.__init__(self, mul, add)
- if type(outs) != IntType:
- print >> sys.stderr, 'TypeError: "outs" argument of %s must be an integer.\n' % self.__class__.__name__
- exit()
- if type(chnls) != IntType:
- print >> sys.stderr, 'TypeError: "chnls" argument of %s must be an integer.\n' % self.__class__.__name__
- exit()
self._outs = outs
self._chnls = chnls
self._time = time
@@ -591,14 +602,14 @@ class Mixer(PyoObject):
time, mul, add, lmax = convertArgsToLists(time, mul, add)
self._base_players = [Mixer_base(outs, wrap(time,i)) for i in range(chnls)]
self._base_objs = [MixerVoice_base(self._base_players[j], i, wrap(mul,i), wrap(add,i)) for i in range(outs) for j in range(chnls)]
-
+
def __getitem__(self, x):
if type(x) == SliceType:
return [self._base_objs[j*self._chnls+i] for j in range(x.start or 0, x.stop or sys.maxint, x.step or 1) for i in range(self._chnls)]
elif x < len(self._base_objs):
return [self._base_objs[x*self._chnls+i] for i in range(self._chnls)]
else:
- print "'x' too large!"
+ print "'x' too large!"
def setTime(self, x):
"""
@@ -610,6 +621,7 @@ class Mixer(PyoObject):
New portamento duration.
"""
+ pyoArgsAssert(self, "n", x)
self._time = x
x, lmax = convertArgsToLists(x)
[obj.setTime(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -623,12 +635,13 @@ class Mixer(PyoObject):
:Args:
voice : int or string
- Key in the mixer dictionary for this input. If None, a unique key
+ Key in the mixer dictionary for this input. If None, a unique key
between 0 and 32767 will be automatically generated.
input : PyoObject
Audio object to add to the mixer.
"""
+ pyoArgsAssert(self, "o", input)
if voice == None:
voice = random.randint(0, 32767)
while self._inputs.has_key(voice):
@@ -675,7 +688,7 @@ class Mixer(PyoObject):
def getChannels(self):
"""
Returns the Mixer's channels dictionary.
-
+
"""
return self._inputs
@@ -685,7 +698,7 @@ class Mixer(PyoObject):
"""
return self._inputs.keys()
-
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0, 10, 'lin', 'time', self._time, dataOnly=True),
SLMapMul(self._mul)]
@@ -693,7 +706,7 @@ class Mixer(PyoObject):
@property
def time(self):
- """float. Portamento."""
+ """float. Portamento."""
return self._time
@time.setter
- def time(self, x): self.setTime(x)
+ def time(self, x): self.setTime(x)
\ No newline at end of file
diff --git a/pyolib/pattern.py b/pyolib/pattern.py
index 851ad20..8147c41 100644
--- a/pyolib/pattern.py
+++ b/pyolib/pattern.py
@@ -1,42 +1,40 @@
"""
-Set of objects that call Python functions from triggers or number counts.
+Set of objects that call Python functions from triggers or number counts.
Useful for event sequencing.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
-import sys
from _core import *
from _maps import *
-from types import ListType, TupleType
class Pattern(PyoObject):
"""
Periodically calls a Python function.
- The play() method starts the pattern timer and is not called
+ The play() method starts the pattern timer and is not called
at the object creation time.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
function : Python function
@@ -47,7 +45,7 @@ class Pattern(PyoObject):
.. note::
The out() method is bypassed. Pattern doesn't return signal.
-
+
Pattern has no `mul` and `add` attributes.
>>> s = Server().boot()
@@ -59,22 +57,15 @@ class Pattern(PyoObject):
... a.freq = [f, f+1]
>>> p = Pattern(pat, .125)
>>> p.play()
-
+
"""
def __init__(self, function, time=1):
+ pyoArgsAssert(self, "cO", function, time)
PyoObject.__init__(self)
- if type(function) == ListType or type(function) == TupleType:
- if not callable(function[0]):
- print >> sys.stderr, 'TypeError: "function" argument of %s must be callable.\n' % self.__class__.__name__
- exit()
- else:
- if not callable(function):
- print >> sys.stderr, 'TypeError: "function" argument of %s must be callable.\n' % self.__class__.__name__
- exit()
- self._function = function
+ self._function = getWeakMethodRef(function)
self._time = time
function, time, lmax = convertArgsToLists(function, time)
- self._base_objs = [Pattern_base(wrap(function,i), wrap(time,i)) for i in range(lmax)]
+ self._base_objs = [Pattern_base(WeakMethod(wrap(function,i)), wrap(time,i)) for i in range(lmax)]
def setFunction(self, x):
"""
@@ -86,27 +77,29 @@ class Pattern(PyoObject):
new `function` attribute.
"""
- self._function = x
+ pyoArgsAssert(self, "c", x)
+ self._function = getWeakMethodRef(x)
x, lmax = convertArgsToLists(x)
- [obj.setFunction(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ [obj.setFunction(WeakMethod(wrap(x,i))) for i, obj in enumerate(self._base_objs)]
def setTime(self, x):
"""
Replace the `time` attribute.
-
+
:Args:
-
+
x : float or PyoObject
New `time` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._time = x
x, lmax = convertArgsToLists(x)
[obj.setTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def out(self, x=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
-
+
def setMul(self, x):
pass
@@ -122,17 +115,17 @@ class Pattern(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.125, 4., 'lin', 'time', self._time)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def function(self):
- """Python function. Function to be called."""
+ """Python function. Function to be called."""
return self._function
@function.setter
- def function(self, x):
- self.setFunction(x)
+ def function(self, x):
+ self.setFunction(x)
@property
def time(self):
- """float or PyoObject. Time, in seconds, between each call."""
+ """float or PyoObject. Time, in seconds, between each call."""
return self._time
@time.setter
def time(self, x): self.setTime(x)
@@ -140,13 +133,13 @@ class Pattern(PyoObject):
class Score(PyoObject):
"""
Calls functions by incrementation of a preformatted name.
-
+
Score takes audio stream containning integers in input and calls
- a function whose name is the concatenation of `fname` and the changing
+ a function whose name is the concatenation of `fname` and the changing
integer.
-
- Can be used to sequence events, first by creating functions p0, p1,
- p2, etc. and then, by passing a counter to a Score object with "p"
+
+ Can be used to sequence events, first by creating functions p0, p1,
+ p2, etc. and then, by passing a counter to a Score object with "p"
as `fname` argument. Functions are called without parameters.
:Parent: :py:class:`PyoObject`
@@ -160,16 +153,16 @@ class Score(PyoObject):
Name of the functions to be called. Defaults to "event_", meaning
that the object will call the function "event_0", "event_1", "event_2",
and so on... Available at initialization time only.
-
+
.. note::
- The out() method is bypassed. Score's signal can not be sent
+ The out() method is bypassed. Score's signal can not be sent
to audio outs.
Score has no `mul` and `add` attributes.
.. seealso:: :py:class:`Pattern`, :py:class:`TrigFunc`
-
+
>>> s = Server().boot()
>>> s.start()
>>> a = SineLoop(freq=[200,300,400,500], feedback=0.05, mul=.1).out()
@@ -182,9 +175,10 @@ class Score(PyoObject):
>>> m = Metro(1).play()
>>> c = Counter(m, min=0, max=3)
>>> sc = Score(c)
-
+
"""
def __init__(self, input, fname="event_"):
+ pyoArgsAssert(self, "os", input, fname)
PyoObject.__init__(self)
self._input = input
self._fname = fname
@@ -197,14 +191,14 @@ class Score(PyoObject):
def setMul(self, x):
pass
-
+
def setAdd(self, x):
- pass
+ pass
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -213,23 +207,24 @@ class Score(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio signal sending integer numbers."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
class CallAfter(PyoObject):
"""
Calls a Python function after a given time.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
function : Python function
@@ -238,14 +233,14 @@ class CallAfter(PyoObject):
Time, in seconds, before the call. Default to 1.
arg : any Python object, optional
Argument sent to the called function. Default to None.
-
+
.. note::
The out() method is bypassed. CallAfter doesn't return signal.
-
+
CallAfter has no `mul` and `add` attributes.
-
- The object is not deleted after the call. The User must delete it himself.
+
+ The object is not deleted after the call. The user must delete it himself.
>>> s = Server().boot()
>>> s.start()
@@ -258,22 +253,15 @@ class CallAfter(PyoObject):
"""
def __init__(self, function, time=1, arg=None):
+ pyoArgsAssert(self, "cn", function, time)
PyoObject.__init__(self)
- if type(function) == ListType or type(function) == TupleType:
- if not callable(function[0]):
- print >> sys.stderr, 'TypeError: "function" argument of %s must be callable.\n' % self.__class__.__name__
- exit()
- else:
- if not callable(function):
- print >> sys.stderr, 'TypeError: "function" argument of %s must be callable.\n' % self.__class__.__name__
- exit()
- self._function = function
+ self._function = getWeakMethodRef(function)
function, time, arg, lmax = convertArgsToLists(function, time, arg)
- self._base_objs = [CallAfter_base(wrap(function,i), wrap(time,i), wrap(arg,i)) for i in range(lmax)]
+ self._base_objs = [CallAfter_base(WeakMethod(wrap(function,i)), wrap(time,i), wrap(arg,i)) for i in range(lmax)]
def out(self, x=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
-
+
def setMul(self, x):
pass
@@ -284,4 +272,4 @@ class CallAfter(PyoObject):
pass
def setDiv(self, x):
- pass
+ pass
\ No newline at end of file
diff --git a/pyolib/phasevoc.py b/pyolib/phasevoc.py
index 379b934..ae988d2 100644
--- a/pyolib/phasevoc.py
+++ b/pyolib/phasevoc.py
@@ -1,30 +1,30 @@
"""
Phase vocoder.
-The phase vocoder is a digital signal processing technique of potentially
-great musical significance. It can be used to perform very high fidelity
+The phase vocoder is a digital signal processing technique of potentially
+great musical significance. It can be used to perform very high fidelity
time scaling, pitch transposition, and myriad other modifications of sounds.
"""
"""
-Copyright 2011 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
@@ -36,17 +36,17 @@ class PVAnal(PyoPVObject):
Phase Vocoder analysis object.
PVAnal takes an input sound and performs the phase vocoder
- analysis on it. This results in two streams, one for the bin's
- magnitudes and the other for the bin's true frequencies. These
- two streams are used by the PVxxx object family to transform
+ analysis on it. This results in two streams, one for the bin's
+ magnitudes and the other for the bin's true frequencies. These
+ two streams are used by the PVxxx object family to transform
the input signal using spectral domain algorithms. The last
object in the phase vocoder chain must be a PVSynth to perform
the spectral to time domain conversion.
-
+
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoObject
Input signal to process.
size : int {pow-of-two > 4}, optional
@@ -54,12 +54,12 @@ class PVAnal(PyoPVObject):
Defaults to 1024.
The FFT size is the number of samples used in each
- analysis frame.
+ analysis frame.
overlaps : int, optional
The number of overlaped analysis block. Must be a
power of two. Defaults to 4.
-
- More overlaps can greatly improved sound quality
+
+ More overlaps can greatly improved sound quality
synthesis but it is also more CPU expensive.
wintype : int, optional
Shape of the envelope used to filter each input frame.
@@ -82,6 +82,7 @@ class PVAnal(PyoPVObject):
"""
def __init__(self, input, size=1024, overlaps=4, wintype=2):
+ pyoArgsAssert(self, "oiii", input, size, overlaps, wintype)
PyoPVObject.__init__(self)
self._input = input
self._size = size
@@ -90,11 +91,11 @@ class PVAnal(PyoPVObject):
self._in_fader = InputFader(input)
in_fader, size, overlaps, wintype, lmax = convertArgsToLists(self._in_fader, size, overlaps, wintype)
self._base_objs = [PVAnal_base(wrap(in_fader,i), wrap(size,i), wrap(overlaps,i), wrap(wintype,i)) for i in range(lmax)]
-
+
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -103,19 +104,21 @@ class PVAnal(PyoPVObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setSize(self, x):
"""
Replace the `size` attribute.
-
+
:Args:
x : int
new `size` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._size = x
x, lmax = convertArgsToLists(x)
[obj.setSize(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -123,13 +126,14 @@ class PVAnal(PyoPVObject):
def setOverlaps(self, x):
"""
Replace the `overlaps` attribute.
-
+
:Args:
x : int
new `overlaps` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._overlaps = x
x, lmax = convertArgsToLists(x)
[obj.setOverlaps(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -137,12 +141,12 @@ class PVAnal(PyoPVObject):
def setWinType(self, x):
"""
Replace the `wintype` attribute.
-
+
:Args:
x : int
new `wintype` attribute.
-
+
"""
self._wintype = x
x, lmax = convertArgsToLists(x)
@@ -150,7 +154,7 @@ class PVAnal(PyoPVObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -184,15 +188,15 @@ class PVSynth(PyoObject):
the spectral to time domain conversion on it. This step
converts phase vocoder magnitude and true frequency's
streams back to a real signal.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process.
wintype : int, optional
- Shape of the envelope used to filter each input frame.
+ Shape of the envelope used to filter each input frame.
Possible shapes are:
0. rectangular (no windowing)
1. Hamming
@@ -212,22 +216,24 @@ class PVSynth(PyoObject):
"""
def __init__(self, input, wintype=2, mul=1, add=0):
+ pyoArgsAssert(self, "piOO", input, wintype, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._wintype = wintype
input, wintype, mul, add, lmax = convertArgsToLists(self._input, wintype, mul, add)
self._base_objs = [PVSynth_base(wrap(input,i), wrap(wintype,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -235,13 +241,14 @@ class PVSynth(PyoObject):
def setWinType(self, x):
"""
Replace the `wintype` attribute.
-
+
:Args:
x : int
new `wintype` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._wintype = x
x, lmax = convertArgsToLists(x)
[obj.setWinType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -252,7 +259,7 @@ class PVSynth(PyoObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -269,14 +276,14 @@ class PVAddSynth(PyoObject):
Phase Vocoder additive synthesis object.
PVAddSynth takes a PyoPVObject as its input and resynthesize
- the real signal using the magnitude and true frequency's
- streams to control amplitude and frequency envelopes of an
+ the real signal using the magnitude and true frequency's
+ streams to control amplitude and frequency envelopes of an
oscillator bank.
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process.
pitch : float or PyoObject, optional
@@ -285,12 +292,12 @@ class PVAddSynth(PyoObject):
Number of oscillators used to synthesize the
output sound. Defaults to 100.
first : int, optional
- The first bin to synthesize, starting from 0.
+ The first bin to synthesize, starting from 0.
Defaults to 0.
inc : int, optional
- Starting from bin `first`, resynthesize bins
- `inc` apart. Defaults to 1.
-
+ Starting from bin `first`, resynthesize bins
+ `inc` apart. Defaults to 1.
+
>>> s = Server().boot()
>>> s.start()
@@ -300,6 +307,7 @@ class PVAddSynth(PyoObject):
"""
def __init__(self, input, pitch=1, num=100, first=0, inc=1, mul=1, add=0):
+ pyoArgsAssert(self, "pOiiiOO", input, pitch, num, first, inc, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._pitch = pitch
@@ -308,17 +316,18 @@ class PVAddSynth(PyoObject):
self._inc = inc
input, pitch, num, first, inc, mul, add, lmax = convertArgsToLists(self._input, pitch, num, first, inc, mul, add)
self._base_objs = [PVAddSynth_base(wrap(input,i), wrap(pitch,i), wrap(num,i), wrap(first,i), wrap(inc,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -326,13 +335,14 @@ class PVAddSynth(PyoObject):
def setPitch(self, x):
"""
Replace the `pitch` attribute.
-
+
:Args:
x : float or PyoObject
new `pitch` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._pitch = x
x, lmax = convertArgsToLists(x)
[obj.setPitch(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -340,13 +350,14 @@ class PVAddSynth(PyoObject):
def setNum(self, x):
"""
Replace the `num` attribute.
-
+
:Args:
x : int
new `num` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._num = x
x, lmax = convertArgsToLists(x)
[obj.setNum(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -354,13 +365,14 @@ class PVAddSynth(PyoObject):
def setFirst(self, x):
"""
Replace the `first` attribute.
-
+
:Args:
x : int
new `first` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._first = x
x, lmax = convertArgsToLists(x)
[obj.setFirst(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -368,13 +380,14 @@ class PVAddSynth(PyoObject):
def setInc(self, x):
"""
Replace the `inc` attribute.
-
+
:Args:
x : int
new `inc` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._inc = x
x, lmax = convertArgsToLists(x)
[obj.setInc(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -386,7 +399,7 @@ class PVAddSynth(PyoObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -422,11 +435,11 @@ class PVAddSynth(PyoObject):
class PVTranspose(PyoPVObject):
"""
Transpose the frequency components of a pv stream.
-
+
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process.
transpo : float or PyoObject, optional
@@ -442,22 +455,24 @@ class PVTranspose(PyoPVObject):
"""
def __init__(self, input, transpo=1):
+ pyoArgsAssert(self, "pO", input, transpo)
PyoPVObject.__init__(self)
self._input = input
self._transpo = transpo
input, transpo, lmax = convertArgsToLists(self._input, transpo)
self._base_objs = [PVTranspose_base(wrap(input,i), wrap(transpo,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -465,13 +480,14 @@ class PVTranspose(PyoPVObject):
def setTranspo(self, x):
"""
Replace the `transpo` attribute.
-
+
:Args:
x : int
new `transpo` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._transpo = x
x, lmax = convertArgsToLists(x)
[obj.setTranspo(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -482,7 +498,7 @@ class PVTranspose(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -505,10 +521,10 @@ class PVVerb(PyoPVObject):
input : PyoPVObject
Phase vocoder streaming object to process.
revtime : float or PyoObject, optional
- Reverberation factor, between 0 and 1.
+ Reverberation factor, between 0 and 1.
Defaults to 0.75.
damp : float or PyoObject, optional
- High frequency damping factor, between 0 and 1.
+ High frequency damping factor, between 0 and 1.
1 means no damping and 0 is the most damping.
Defaults to 0.75.
@@ -523,23 +539,25 @@ class PVVerb(PyoPVObject):
"""
def __init__(self, input, revtime=0.75, damp=0.75):
+ pyoArgsAssert(self, "pOO", input, revtime, damp)
PyoPVObject.__init__(self)
self._input = input
self._revtime = revtime
self._damp = damp
input, revtime, damp, lmax = convertArgsToLists(self._input, revtime, damp)
self._base_objs = [PVVerb_base(wrap(input,i), wrap(revtime,i), wrap(damp,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -547,13 +565,14 @@ class PVVerb(PyoPVObject):
def setRevtime(self, x):
"""
Replace the `revtime` attribute.
-
+
:Args:
x : int
new `revtime` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._revtime = x
x, lmax = convertArgsToLists(x)
[obj.setRevtime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -561,13 +580,14 @@ class PVVerb(PyoPVObject):
def setDamp(self, x):
"""
Replace the `damp` attribute.
-
+
:Args:
x : int
new `damp` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._damp = x
x, lmax = convertArgsToLists(x)
[obj.setDamp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -579,7 +599,7 @@ class PVVerb(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -590,7 +610,7 @@ class PVVerb(PyoPVObject):
return self._revtime
@revtime.setter
def revtime(self, x): self.setRevtime(x)
-
+
@property
def damp(self):
"""float or PyoObject. High frequency damping factor."""
@@ -623,23 +643,25 @@ class PVGate(PyoPVObject):
"""
def __init__(self, input, thresh=-20, damp=0.):
+ pyoArgsAssert(self, "pOO", input, thresh, damp)
PyoPVObject.__init__(self)
self._input = input
self._thresh = thresh
self._damp = damp
input, thresh, damp, lmax = convertArgsToLists(self._input, thresh, damp)
self._base_objs = [PVGate_base(wrap(input,i), wrap(thresh,i), wrap(damp,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -647,13 +669,14 @@ class PVGate(PyoPVObject):
def setThresh(self, x):
"""
Replace the `thresh` attribute.
-
+
:Args:
x : int
new `thresh` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._thresh = x
x, lmax = convertArgsToLists(x)
[obj.setThresh(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -661,13 +684,14 @@ class PVGate(PyoPVObject):
def setDamp(self, x):
"""
Replace the `damp` attribute.
-
+
:Args:
x : int
new `damp` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._damp = x
x, lmax = convertArgsToLists(x)
[obj.setDamp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -679,7 +703,7 @@ class PVGate(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -690,7 +714,7 @@ class PVGate(PyoPVObject):
return self._thresh
@thresh.setter
def thresh(self, x): self.setThresh(x)
-
+
@property
def damp(self):
"""float or PyoObject. Damping factor for low amplitude bins."""
@@ -701,14 +725,14 @@ class PVGate(PyoPVObject):
class PVCross(PyoPVObject):
"""
Performs cross-synthesis between two phase vocoder streaming object.
-
+
The amplitudes from `input` and `input2` (scaled by `fade` argument)
are applied to the frequencies of `input`.
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process. Frequencies from
this pv stream are used to compute the output signal.
@@ -716,12 +740,12 @@ class PVCross(PyoPVObject):
Phase vocoder streaming object which gives the second set of
magnitudes. Frequencies from this pv stream are not used.
fade : float or PyoObject, optional
- Scaling factor for the output amplitudes, between 0 and 1.
- 0 means amplitudes from `input` and 1 means amplitudes from `input2`.
+ Scaling factor for the output amplitudes, between 0 and 1.
+ 0 means amplitudes from `input` and 1 means amplitudes from `input2`.
Defaults to 1.
.. note::
-
+
The two input pv stream must have the same size and overlaps. It is
the responsibility of the user to be sure they are consistent. To change
the size (or the overlaps) of the phase vocoder process, one must
@@ -746,23 +770,25 @@ class PVCross(PyoPVObject):
"""
def __init__(self, input, input2, fade=1):
+ pyoArgsAssert(self, "ppO", input, input2, fade)
PyoPVObject.__init__(self)
self._input = input
self._input2 = input2
self._fade = fade
input, input2, fade, lmax = convertArgsToLists(self._input, self._input2, fade)
self._base_objs = [PVCross_base(wrap(input,i), wrap(input2,i), wrap(fade,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -770,13 +796,14 @@ class PVCross(PyoPVObject):
def setInput2(self, x):
"""
Replace the `input2` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input2 = x
x, lmax = convertArgsToLists(x)
[obj.setInput2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -784,13 +811,14 @@ class PVCross(PyoPVObject):
def setFade(self, x):
"""
Replace the `fade` attribute.
-
+
:Args:
- x : int
+ x : float or PyoObject
new `fade` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._fade = x
x, lmax = convertArgsToLists(x)
[obj.setFade(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -801,14 +829,14 @@ class PVCross(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def input2(self):
- """PyoPVObject. Second set of amplitudes."""
+ """PyoPVObject. Second set of amplitudes."""
return self._input2
@input2.setter
def input2(self, x): self.setInput2(x)
@@ -825,9 +853,9 @@ class PVMult(PyoPVObject):
Multiply magnitudes from two phase vocoder streaming object.
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process. Frequencies from
this pv stream are used to compute the output signal.
@@ -836,7 +864,7 @@ class PVMult(PyoPVObject):
magnitudes. Frequencies from this pv stream are not used.
.. note::
-
+
The two input pv stream must have the same size and overlaps. It is
the responsibility of the user to be sure they are consistent. To change
the size (or the overlaps) of the phase vocoder process, one must
@@ -861,22 +889,24 @@ class PVMult(PyoPVObject):
"""
def __init__(self, input, input2):
+ pyoArgsAssert(self, "pp", input, input2)
PyoPVObject.__init__(self)
self._input = input
self._input2 = input2
input, input2, lmax = convertArgsToLists(self._input, self._input2)
self._base_objs = [PVMult_base(wrap(input,i), wrap(input2,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -884,27 +914,28 @@ class PVMult(PyoPVObject):
def setInput2(self, x):
"""
Replace the `input2` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input2 = x
x, lmax = convertArgsToLists(x)
[obj.setInput2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def input2(self):
- """PyoPVObject. Second set of magnitudes."""
+ """PyoPVObject. Second set of magnitudes."""
return self._input2
@input2.setter
def input2(self, x): self.setInput2(x)
@@ -912,15 +943,15 @@ class PVMult(PyoPVObject):
class PVMorph(PyoPVObject):
"""
Performs spectral morphing between two phase vocoder streaming object.
-
- According to `fade` argument, the amplitudes from `input` and `input2`
+
+ According to `fade` argument, the amplitudes from `input` and `input2`
are interpolated linearly while the frequencies are interpolated
exponentially.
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object which gives the first set of
magnitudes and frequencies.
@@ -928,11 +959,11 @@ class PVMorph(PyoPVObject):
Phase vocoder streaming object which gives the second set of
magnitudes and frequencies.
fade : float or PyoObject, optional
- Scaling factor for the output amplitudes and frequencies,
+ Scaling factor for the output amplitudes and frequencies,
between 0 and 1. 0 is `input` and 1 in `input2`. Defaults to 0.5.
.. note::
-
+
The two input pv stream must have the same size and overlaps. It is
the responsibility of the user to be sure they are consistent. To change
the size (or the overlaps) of the phase vocoder process, one must
@@ -957,23 +988,25 @@ class PVMorph(PyoPVObject):
"""
def __init__(self, input, input2, fade=0.5):
+ pyoArgsAssert(self, "ppO", input, input2, fade)
PyoPVObject.__init__(self)
self._input = input
self._input2 = input2
self._fade = fade
input, input2, fade, lmax = convertArgsToLists(self._input, self._input2, fade)
self._base_objs = [PVMorph_base(wrap(input,i), wrap(input2,i), wrap(fade,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -981,13 +1014,14 @@ class PVMorph(PyoPVObject):
def setInput2(self, x):
"""
Replace the `input2` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input2 = x
x, lmax = convertArgsToLists(x)
[obj.setInput2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -995,13 +1029,14 @@ class PVMorph(PyoPVObject):
def setFade(self, x):
"""
Replace the `fade` attribute.
-
+
:Args:
- x : int
+ x : float or PyoObject
new `fade` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._fade = x
x, lmax = convertArgsToLists(x)
[obj.setFade(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1012,14 +1047,14 @@ class PVMorph(PyoPVObject):
@property
def input(self):
- """PyoPVObject. First input signal."""
+ """PyoPVObject. First input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def input2(self):
- """PyoPVObject. Second input signal."""
+ """PyoPVObject. Second input signal."""
return self._input2
@input2.setter
def input2(self, x): self.setInput2(x)
@@ -1034,28 +1069,28 @@ class PVMorph(PyoPVObject):
class PVFilter(PyoPVObject):
"""
Spectral filter.
-
+
PVFilter filters frequency components of a pv stream
according to the shape drawn in the table given in
argument.
-
+
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process.
table : PyoTableObject
- Table containing the filter shape. If the
+ Table containing the filter shape. If the
table length is smaller than fftsize/2,
remaining bins will be set to 0.
gain : float or PyoObject, optional
- Gain of the filter applied to the input spectrum.
+ Gain of the filter applied to the input spectrum.
Defaults to 1.
mode : int, optional
Table scanning mode. Defaults to 0.
-
- If 0, bin indexes outside table size are set to 0.
+
+ If 0, bin indexes outside table size are set to 0.
If 1, bin indexes are scaled over table length.
>>> s = Server().boot()
@@ -1068,6 +1103,7 @@ class PVFilter(PyoPVObject):
"""
def __init__(self, input, table, gain=1, mode=0):
+ pyoArgsAssert(self, "ptOi", input, table, gain, mode)
PyoPVObject.__init__(self)
self._input = input
self._table = table
@@ -1075,17 +1111,18 @@ class PVFilter(PyoPVObject):
self._mode = mode
input, table, gain, mode, lmax = convertArgsToLists(self._input, table, gain, mode)
self._base_objs = [PVFilter_base(wrap(input,i), wrap(table,i), wrap(gain,i), wrap(mode,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1093,13 +1130,14 @@ class PVFilter(PyoPVObject):
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1107,13 +1145,14 @@ class PVFilter(PyoPVObject):
def setGain(self, x):
"""
Replace the `gain` attribute.
-
+
:Args:
x : float or PyoObject
new `gain` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._gain = x
x, lmax = convertArgsToLists(x)
[obj.setGain(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1121,13 +1160,14 @@ class PVFilter(PyoPVObject):
def setMode(self, x):
"""
Replace the `mode` attribute.
-
+
:Args:
x : int
new `mode` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._mode = x
x, lmax = convertArgsToLists(x)
[obj.setMode(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1138,14 +1178,14 @@ class PVFilter(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def table(self):
- """PyoTableObject. Table containing the filter shape."""
+ """PyoTableObject. Table containing the filter shape."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@@ -1167,35 +1207,35 @@ class PVFilter(PyoPVObject):
class PVDelay(PyoPVObject):
"""
Spectral delays.
-
+
PVDelay applies different delay times and feedbacks for
- each bin of a phase vocoder analysis. Delay times and
+ each bin of a phase vocoder analysis. Delay times and
feedbacks are specified with PyoTableObjects.
-
+
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process.
deltable : PyoTableObject
Table containing delay times, as integer multipliers
- of the FFT hopsize (fftsize / overlaps).
-
+ of the FFT hopsize (fftsize / overlaps).
+
If the table length is smaller than fftsize/2,
remaining bins will be set to 0.
feedtable : PyoTableObject
- Table containing feedback values, between -1 and 1.
-
+ Table containing feedback values, between -1 and 1.
+
If the table length is smaller than fftsize/2,
remaining bins will be set to 0.
maxdelay : float, optional
- Maximum delay time in seconds. Available at initialization
+ Maximum delay time in seconds. Available at initialization
time only. Defaults to 1.0.
mode : int, optional
Tables scanning mode. Defaults to 0.
-
- If 0, bin indexes outside table size are set to 0.
+
+ If 0, bin indexes outside table size are set to 0.
If 1, bin indexes are scaled over table length.
>>> s = Server().boot()
@@ -1215,6 +1255,7 @@ class PVDelay(PyoPVObject):
"""
def __init__(self, input, deltable, feedtable, maxdelay=1.0, mode=0):
+ pyoArgsAssert(self, "pttni", input, deltable, feedtable, maxdelay, mode)
PyoPVObject.__init__(self)
self._input = input
self._deltable = deltable
@@ -1223,17 +1264,18 @@ class PVDelay(PyoPVObject):
self._mode = mode
input, deltable, feedtable, maxdelay, mode, lmax = convertArgsToLists(self._input, deltable, feedtable, maxdelay, mode)
self._base_objs = [PVDelay_base(wrap(input,i), wrap(deltable,i), wrap(feedtable,i), wrap(maxdelay,i), wrap(mode,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1241,13 +1283,14 @@ class PVDelay(PyoPVObject):
def setDeltable(self, x):
"""
Replace the `deltable` attribute.
-
+
:Args:
x : PyoTableObject
new `deltable` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._deltable = x
x, lmax = convertArgsToLists(x)
[obj.setDeltable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1255,13 +1298,14 @@ class PVDelay(PyoPVObject):
def setFeedtable(self, x):
"""
Replace the `feedtable` attribute.
-
+
:Args:
x : PyoTableObject
new `feedtable` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._feedtable = x
x, lmax = convertArgsToLists(x)
[obj.setFeedtable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1269,27 +1313,28 @@ class PVDelay(PyoPVObject):
def setMode(self, x):
"""
Replace the `mode` attribute.
-
+
:Args:
x : int
new `mode` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._mode = x
x, lmax = convertArgsToLists(x)
[obj.setMode(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def deltable(self):
- """PyoTableObject. Table containing the delay times."""
+ """PyoTableObject. Table containing the delay times."""
return self._deltable
@deltable.setter
def deltable(self, x): self.setDeltable(x)
@@ -1311,28 +1356,28 @@ class PVDelay(PyoPVObject):
class PVBuffer(PyoPVObject):
"""
Phase vocoder buffer and playback with transposition.
-
+
PVBuffer keeps `length` seconds of pv analysis in memory
and gives control on playback position and transposition.
-
+
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process.
index : PyoObject
- Playback position, as audio stream, normalized
- between 0 and 1.
+ Playback position, as audio stream, normalized
+ between 0 and 1.
pitch : float or PyoObject, optional
Transposition factor. Defaults to 1.
length : float, optional
- Memory length in seconds. Available at initialization
+ Memory length in seconds. Available at initialization
time only. Defaults to 1.0.
.. note::
-
- The play() method can be called to start a new recording of
+
+ The play() method can be called to start a new recording of
the current pv input.
>>> s = Server().boot()
@@ -1347,6 +1392,7 @@ class PVBuffer(PyoPVObject):
"""
def __init__(self, input, index, pitch=1.0, length=1.0):
+ pyoArgsAssert(self, "poOn", input, index, pitch, length)
PyoPVObject.__init__(self)
self._input = input
self._index = index
@@ -1354,17 +1400,18 @@ class PVBuffer(PyoPVObject):
self._length = length
input, index, pitch, length, lmax = convertArgsToLists(self._input, index, pitch, length)
self._base_objs = [PVBuffer_base(wrap(input,i), wrap(index,i), wrap(pitch,i), wrap(length,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1372,13 +1419,14 @@ class PVBuffer(PyoPVObject):
def setIndex(self, x):
"""
Replace the `index` attribute.
-
+
:Args:
x : PyoObject
new `index` attribute.
-
+
"""
+ pyoArgsAssert(self, "o", x)
self._index = x
x, lmax = convertArgsToLists(x)
[obj.setIndex(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1386,13 +1434,14 @@ class PVBuffer(PyoPVObject):
def setPitch(self, x):
"""
Replace the `pitch` attribute.
-
+
:Args:
x : float or PyoObject
new `pitch` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._pitch = x
x, lmax = convertArgsToLists(x)
[obj.setPitch(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1403,14 +1452,14 @@ class PVBuffer(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def index(self):
- """PyoObject. Reader's normalized position."""
+ """PyoObject. Reader's normalized position."""
return self._index
@index.setter
def index(self, x): self.setIndex(x)
@@ -1425,14 +1474,14 @@ class PVBuffer(PyoPVObject):
class PVShift(PyoPVObject):
"""
Spectral domain frequency shifter.
-
+
PVShift linearly moves the analysis bins by the amount, in Hertz,
- specified by the the `shift` argument.
-
+ specified by the the `shift` argument.
+
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process.
shift : float or PyoObject, optional
@@ -1447,22 +1496,24 @@ class PVShift(PyoPVObject):
"""
def __init__(self, input, shift=0):
+ pyoArgsAssert(self, "pO", input, shift)
PyoPVObject.__init__(self)
self._input = input
self._shift = shift
input, shift, lmax = convertArgsToLists(self._input, shift)
self._base_objs = [PVShift_base(wrap(input,i), wrap(shift,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1470,13 +1521,14 @@ class PVShift(PyoPVObject):
def setShift(self, x):
"""
Replace the `shift` attribute.
-
+
:Args:
- x : int
+ x : float or PyoObject
new `shift` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._shift = x
x, lmax = convertArgsToLists(x)
[obj.setShift(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1487,7 +1539,7 @@ class PVShift(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1502,15 +1554,15 @@ class PVShift(PyoPVObject):
class PVAmpMod(PyoPVObject):
"""
Performs frequency independent amplitude modulations.
-
- PVAmpMod modulates the magnitude of each bin of a pv
- stream with an independent oscillator. `basefreq` and
- `spread` are used to derive the frequency of each
+
+ PVAmpMod modulates the magnitude of each bin of a pv
+ stream with an independent oscillator. `basefreq` and
+ `spread` are used to derive the frequency of each
modulating oscillator.
-
+
Internally, the following operations are applied to
derive oscillator frequencies (`i` is the bin number):
-
+
spread = spread * 0.001 + 1.0
f_i = basefreq * pow(spread, i)
@@ -1522,7 +1574,7 @@ class PVAmpMod(PyoPVObject):
input : PyoPVObject
Phase vocoder streaming object to process.
basefreq : float or PyoObject, optional
- Base modulation frequency, in Hertz.
+ Base modulation frequency, in Hertz.
Defaults to 1.
spread : float or PyoObject, optional
Spreading factor for oscillator frequencies, between
@@ -1537,23 +1589,25 @@ class PVAmpMod(PyoPVObject):
"""
def __init__(self, input, basefreq=1, spread=0):
+ pyoArgsAssert(self, "pOO", input, basefreq, spread)
PyoPVObject.__init__(self)
self._input = input
self._basefreq = basefreq
self._spread = spread
input, basefreq, spread, lmax = convertArgsToLists(self._input, basefreq, spread)
self._base_objs = [PVAmpMod_base(wrap(input,i), wrap(basefreq,i), wrap(spread,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1561,13 +1615,14 @@ class PVAmpMod(PyoPVObject):
def setBasefreq(self, x):
"""
Replace the `basefreq` attribute.
-
+
:Args:
- x : int
+ x : float or PyoObject
new `basefreq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._basefreq = x
x, lmax = convertArgsToLists(x)
[obj.setBasefreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1575,13 +1630,14 @@ class PVAmpMod(PyoPVObject):
def setSpread(self, x):
"""
Replace the `spread` attribute.
-
+
:Args:
- x : int
+ x : float or PyoObject
new `spread` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._spread = x
x, lmax = convertArgsToLists(x)
[obj.setSpread(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1592,7 +1648,7 @@ class PVAmpMod(PyoPVObject):
"""
[obj.reset() for obj in self._base_objs]
-
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.1, 20, "log", "basefreq", self._basefreq),
SLMap(-1, 1, "lin", "spread", self._spread)]
@@ -1600,7 +1656,7 @@ class PVAmpMod(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1611,7 +1667,7 @@ class PVAmpMod(PyoPVObject):
return self._basefreq
@basefreq.setter
def basefreq(self, x): self.setBasefreq(x)
-
+
@property
def spread(self):
"""float or PyoObject. Modulator's frequency spreading factor."""
@@ -1622,15 +1678,15 @@ class PVAmpMod(PyoPVObject):
class PVFreqMod(PyoPVObject):
"""
Performs frequency independent frequency modulations.
-
- PVFreqMod modulates the frequency of each bin of a pv
- stream with an independent oscillator. `basefreq` and
- `spread` are used to derive the frequency of each
+
+ PVFreqMod modulates the frequency of each bin of a pv
+ stream with an independent oscillator. `basefreq` and
+ `spread` are used to derive the frequency of each
modulating oscillator.
-
+
Internally, the following operations are applied to
derive oscillator frequencies (`i` is the bin number):
-
+
spread = spread * 0.001 + 1.0
f_i = basefreq * pow(spread, i)
@@ -1642,13 +1698,13 @@ class PVFreqMod(PyoPVObject):
input : PyoPVObject
Phase vocoder streaming object to process.
basefreq : float or PyoObject, optional
- Base modulation frequency, in Hertz.
+ Base modulation frequency, in Hertz.
Defaults to 1.
spread : float or PyoObject, optional
Spreading factor for oscillator frequencies, between
-1 and 1. 0 means every oscillator has the same frequency.
depth : float or PyoObject, optional
- Amplitude of the modulating oscillators, between 0 and 1.
+ Amplitude of the modulating oscillators, between 0 and 1.
Defaults to 0.1.
>>> s = Server().boot()
@@ -1660,6 +1716,7 @@ class PVFreqMod(PyoPVObject):
"""
def __init__(self, input, basefreq=1, spread=0, depth=0.1):
+ pyoArgsAssert(self, "pOOO", input, basefreq, spread, depth)
PyoPVObject.__init__(self)
self._input = input
self._basefreq = basefreq
@@ -1667,17 +1724,18 @@ class PVFreqMod(PyoPVObject):
self._depth = depth
input, basefreq, spread, depth, lmax = convertArgsToLists(self._input, basefreq, spread, depth)
self._base_objs = [PVFreqMod_base(wrap(input,i), wrap(basefreq,i), wrap(spread,i), wrap(depth,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1685,13 +1743,14 @@ class PVFreqMod(PyoPVObject):
def setBasefreq(self, x):
"""
Replace the `basefreq` attribute.
-
+
:Args:
- x : int
+ x : float or PyoObject
new `basefreq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._basefreq = x
x, lmax = convertArgsToLists(x)
[obj.setBasefreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1699,13 +1758,14 @@ class PVFreqMod(PyoPVObject):
def setSpread(self, x):
"""
Replace the `spread` attribute.
-
+
:Args:
- x : int
+ x : float or PyoObject
new `spread` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._spread = x
x, lmax = convertArgsToLists(x)
[obj.setSpread(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1713,13 +1773,14 @@ class PVFreqMod(PyoPVObject):
def setDepth(self, x):
"""
Replace the `depth` attribute.
-
+
:Args:
- x : int
+ x : float or PyoObject
new `depth` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._depth = x
x, lmax = convertArgsToLists(x)
[obj.setDepth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1730,7 +1791,7 @@ class PVFreqMod(PyoPVObject):
"""
[obj.reset() for obj in self._base_objs]
-
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.1, 20, "log", "basefreq", self._basefreq),
SLMap(-1, 1, "lin", "spread", self._spread),
@@ -1739,7 +1800,7 @@ class PVFreqMod(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1750,7 +1811,7 @@ class PVFreqMod(PyoPVObject):
return self._basefreq
@basefreq.setter
def basefreq(self, x): self.setBasefreq(x)
-
+
@property
def spread(self):
"""float or PyoObject. Modulator's frequencies spreading factor."""
@@ -1768,21 +1829,21 @@ class PVFreqMod(PyoPVObject):
class PVBufLoops(PyoPVObject):
"""
Phase vocoder buffer with bin independent speed playback.
-
+
PVBufLoops keeps `length` seconds of pv analysis in memory
- and gives control on playback position independently for
+ and gives control on playback position independently for
every frequency bin.
-
+
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process.
low : float or PyoObject, optional
- Lowest bin speed factor. Defaults to 1.0.
+ Lowest bin speed factor. Defaults to 1.0.
high : float or PyoObject, optional
- Highest bin speed factor. Defaults to 1.0.
+ Highest bin speed factor. Defaults to 1.0.
mode : int, optional
Speed distribution algorithm. Available algorithms are:
0. linear, line between `low` and `high` (default)
@@ -1794,12 +1855,12 @@ class PVBufLoops(PyoPVObject):
6. rand bi-expon, bipolar exponential random between `low` and `high`
length : float, optional
- Memory length in seconds. Available at initialization
+ Memory length in seconds. Available at initialization
time only. Defaults to 1.0.
.. note::
-
- The play() method can be called to start a new recording of
+
+ The play() method can be called to start a new recording of
the current pv input.
>>> s = Server().boot()
@@ -1813,6 +1874,7 @@ class PVBufLoops(PyoPVObject):
"""
def __init__(self, input, low=1.0, high=1.0, mode=0, length=1.0):
+ pyoArgsAssert(self, "pOOin", input, low, high, mode, length)
PyoPVObject.__init__(self)
self._input = input
self._low = low
@@ -1821,17 +1883,18 @@ class PVBufLoops(PyoPVObject):
self._length = length
input, low, high, mode, length, lmax = convertArgsToLists(self._input, low, high, mode, length)
self._base_objs = [PVBufLoops_base(wrap(input,i), wrap(low,i), wrap(high,i), wrap(mode,i), wrap(length,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1839,13 +1902,14 @@ class PVBufLoops(PyoPVObject):
def setLow(self, x):
"""
Replace the `low` attribute.
-
+
:Args:
x : float or PyoObject
new `low` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._low = x
x, lmax = convertArgsToLists(x)
[obj.setLow(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1853,13 +1917,14 @@ class PVBufLoops(PyoPVObject):
def setHigh(self, x):
"""
Replace the `high` attribute.
-
+
:Args:
x : float or PyoObject
new `high` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._high = x
x, lmax = convertArgsToLists(x)
[obj.setHigh(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1867,13 +1932,14 @@ class PVBufLoops(PyoPVObject):
def setMode(self, x):
"""
Replace the `mode` attribute.
-
+
:Args:
x : int
new `mode` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._mode = x
x, lmax = convertArgsToLists(x)
[obj.setMode(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1881,7 +1947,7 @@ class PVBufLoops(PyoPVObject):
def reset(self):
"""
Reset pointer positions to 0.
-
+
"""
[obj.reset() for obj in self._base_objs]
@@ -1892,14 +1958,14 @@ class PVBufLoops(PyoPVObject):
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def low(self):
- """float or PyoObject. Lowest bin speed factor."""
+ """float or PyoObject. Lowest bin speed factor."""
return self._low
@low.setter
def low(self, x): self.setLow(x)
@@ -1921,26 +1987,26 @@ class PVBufLoops(PyoPVObject):
class PVBufTabLoops(PyoPVObject):
"""
Phase vocoder buffer with bin independent speed playback.
-
+
PVBufTabLoops keeps `length` seconds of pv analysis in memory
and gives control on playback position, using a PyoTableObject,
independently for every frequency bin.
-
+
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object to process.
speed : PyoTableObject
- Table which specify the speed of bin playback readers.
+ Table which specify the speed of bin playback readers.
length : float, optional
- Memory length in seconds. Available at initialization
+ Memory length in seconds. Available at initialization
time only. Defaults to 1.0.
.. note::
-
- The play() method can be called to start a new recording of
+
+ The play() method can be called to start a new recording of
the current pv input.
>>> s = Server().boot()
@@ -1955,23 +2021,25 @@ class PVBufTabLoops(PyoPVObject):
"""
def __init__(self, input, speed, length=1.0):
+ pyoArgsAssert(self, "ptn", input, speed, length)
PyoPVObject.__init__(self)
self._input = input
self._speed = speed
self._length = length
input, speed, length, lmax = convertArgsToLists(self._input, speed, length)
self._base_objs = [PVBufTabLoops_base(wrap(input,i), wrap(speed,i), wrap(length,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1979,13 +2047,14 @@ class PVBufTabLoops(PyoPVObject):
def setSpeed(self, x):
"""
Replace the `speed` attribute.
-
+
:Args:
x : PyoTableObject
new `speed` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._speed = x
x, lmax = convertArgsToLists(x)
[obj.setSpeed(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1993,39 +2062,39 @@ class PVBufTabLoops(PyoPVObject):
def reset(self):
"""
Reset pointer positions to 0.
-
+
"""
[obj.reset() for obj in self._base_objs]
@property
def input(self):
- """PyoPVObject. Input signal to process."""
+ """PyoPVObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def speed(self):
- """PyoTableObject. Table which specify the speed of bin playback readers."""
+ """PyoTableObject. Table which specify the speed of bin playback readers."""
return self._speed
@speed.setter
def speed(self, x): self.setSpeed(x)
-
+
class PVMix(PyoPVObject):
"""
Mix the most prominent components from two phase vocoder streaming objects.
:Parent: :py:class:`PyoPVObject`
-
+
:Args:
-
+
input : PyoPVObject
Phase vocoder streaming object 1.
input2 : PyoPVObject
Phase vocoder streaming object 2.
.. note::
-
+
The two input pv stream must have the same size and overlaps. It is
the responsibility of the user to be sure they are consistent. To change
the size (or the overlaps) of the phase vocoder process, one must
@@ -2050,22 +2119,24 @@ class PVMix(PyoPVObject):
"""
def __init__(self, input, input2):
+ pyoArgsAssert(self, "pp", input, input2)
PyoPVObject.__init__(self)
self._input = input
self._input2 = input2
input, input2, lmax = convertArgsToLists(self._input, self._input2)
self._base_objs = [PVMix_base(wrap(input,i), wrap(input2,i)) for i in range(lmax)]
-
+
def setInput(self, x):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input = x
x, lmax = convertArgsToLists(x)
[obj.setInput(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2073,27 +2144,28 @@ class PVMix(PyoPVObject):
def setInput2(self, x):
"""
Replace the `input2` attribute.
-
+
:Args:
x : PyoPVObject
New signal to process.
"""
+ pyoArgsAssert(self, "p", x)
self._input2 = x
x, lmax = convertArgsToLists(x)
[obj.setInput2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoPVObject. Phase vocoder streaming object 1."""
+ """PyoPVObject. Phase vocoder streaming object 1."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def input2(self):
- """PyoPVObject. Phase vocoder streaming object 2."""
+ """PyoPVObject. Phase vocoder streaming object 2."""
return self._input2
@input2.setter
- def input2(self, x): self.setInput2(x)
+ def input2(self, x): self.setInput2(x)
\ No newline at end of file
diff --git a/pyolib/players.py b/pyolib/players.py
index 3a1f7a4..3b5da47 100644
--- a/pyolib/players.py
+++ b/pyolib/players.py
@@ -1,28 +1,28 @@
"""
Play soundfiles from the disk.
-SfMarkerXXX objects use markers features (store in the header) from
+SfMarkerXXX objects use markers features (store in the header) from
an AIFF file to create more specific reading patterns.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
@@ -32,33 +32,33 @@ from types import ListType
class SfPlayer(PyoObject):
"""
Soundfile player.
-
- Reads audio data from a file using one of several available interpolation
+
+ Reads audio data from a file using one of several available interpolation
types. User can alter its pitch with the `speed` attribute. The object
- takes care of sampling rate conversion to match the Server sampling
+ takes care of sampling rate conversion to match the Server sampling
rate setting.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
path : string
Full path name of the sound to read.
speed : float or PyoObject, optional
- Transpose the pitch of input sound by this factor.
+ Transpose the pitch of input sound by this factor.
Defaults to 1.
-
- 1 is the original pitch, lower values play sound slower, and higher
- values play sound faster.
-
- Negative values results in playing sound backward.
-
+
+ 1 is the original pitch, lower values play sound slower, and higher
+ values play sound faster.
+
+ Negative values results in playing sound backward.
+
Although the `speed` attribute accepts audio
rate signal, its value is updated only once per buffer size.
loop : bool, optional
If set to True, sound will play in loop. Defaults to False.
- offset : float, optional
- Time in seconds of input sound to be skipped, assuming speed = 1.
+ offset : float, optional
+ Time in seconds of input sound to be skipped, assuming speed = 1.
Defaults to 0.
interp : int, optional
Interpolation type. Defaults to 2.
@@ -68,21 +68,22 @@ class SfPlayer(PyoObject):
4. cubic
.. note::
-
- SfPlayer will sends a trigger signal at the end of the playback if
- loop is off or any time it wraps around if loop is on. User can
+
+ SfPlayer will sends a trigger signal at the end of the playback if
+ loop is off or any time it wraps around if loop is on. User can
retrieve the trigger streams by calling obj['trig']:
-
+
>>> sf = SfPlayer(SNDS_PATH + "/transparent.aif").out()
>>> trig = TrigRand(sf['trig'])
-
+
>>> s = Server().boot()
>>> s.start()
>>> snd = SNDS_PATH + "/transparent.aif"
>>> sf = SfPlayer(snd, speed=[.75,.8], loop=True, mul=.3).out()
-
+
"""
def __init__(self, path, speed=1, loop=False, offset=0, interp=2, mul=1, add=0):
+ pyoArgsAssert(self, "sObniOO", path, speed, loop, offset, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._path = path
self._speed = speed
@@ -104,16 +105,17 @@ class SfPlayer(PyoObject):
def setPath(self, path):
"""
Sets a new sound to read.
-
- The number of channels of the new sound must match those
+
+ The number of channels of the new sound must match those
of the sound loaded at initialization time.
-
+
:Args:
-
+
path : string
Full path of the new sound.
"""
+ pyoArgsAssert(self, "s", path)
if type(self._path) == ListType:
curNchnls = sndinfo(self._path[0])[3]
else:
@@ -129,7 +131,7 @@ class SfPlayer(PyoObject):
if _snd_chnls != curNchnls:
print "Soundfile must contains exactly %d channels." % curNchnls
return
-
+
self._path = path
path, lmax = convertArgsToLists(path)
[obj.setSound(wrap(path,i)) for i, obj in enumerate(self._base_players)]
@@ -137,12 +139,12 @@ class SfPlayer(PyoObject):
def setSound(self, path):
"""
Sets a new sound to read.
-
- The number of channels of the new sound must match those
+
+ The number of channels of the new sound must match those
of the sound loaded at initialization time.
-
+
:Args:
-
+
path : string
Full path of the new sound.
@@ -152,13 +154,14 @@ class SfPlayer(PyoObject):
def setSpeed(self, x):
"""
Replace the `speed` attribute.
-
+
:Args:
x : float or PyoObject
new `speed` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._speed = x
x, lmax = convertArgsToLists(x)
[obj.setSpeed(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -166,13 +169,14 @@ class SfPlayer(PyoObject):
def setLoop(self, x):
"""
Replace the `loop` attribute.
-
+
:Args:
x : bool {True, False}
new `loop` attribute.
-
+
"""
+ pyoArgsAssert(self, "b", x)
self._loop = x
x, lmax = convertArgsToLists(x)
for i, obj in enumerate(self._base_players):
@@ -182,13 +186,14 @@ class SfPlayer(PyoObject):
def setOffset(self, x):
"""
Replace the `offset` attribute.
-
+
:Args:
x : float
new `offset` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._offset = x
x, lmax = convertArgsToLists(x)
[obj.setOffset(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -196,60 +201,61 @@ class SfPlayer(PyoObject):
def setInterp(self, x):
"""
Replace the `interp` attribute.
-
+
:Args:
x : int {1, 2, 3, 4}
new `interp` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_players)]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(-2., 2., 'lin', 'speed', self._speed),
+ self._map_list = [SLMap(-2., 2., 'lin', 'speed', self._speed),
SLMap(1, 4, 'lin', 'interp', self._interp, res="int", dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def path(self):
+ def path(self):
"""string. Full path of the sound."""
return self._path
@path.setter
def path(self, x): self.setPath(x)
-
+
@property
- def sound(self):
+ def sound(self):
"""string. Alias to the `path` attribute."""
return self._path
@sound.setter
def sound(self, x): self.setPath(x)
-
+
@property
- def speed(self):
+ def speed(self):
"""float or PyoObject. Transposition factor."""
return self._speed
@speed.setter
def speed(self, x): self.setSpeed(x)
@property
- def loop(self):
+ def loop(self):
"""bool. Looping mode."""
return self._loop
@loop.setter
def loop(self, x): self.setLoop(x)
@property
- def offset(self):
+ def offset(self):
"""float. Time, in seconds, of the first sample to read."""
return self._offset
@offset.setter
def offset(self, x): self.setOffset(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
@@ -258,33 +264,33 @@ class SfPlayer(PyoObject):
class SfMarkerShuffler(PyoObject):
"""
AIFF with markers soundfile shuffler.
-
- Reads audio data from a AIFF file using one of several available
- interpolation types. User can alter its pitch with the `speed`
- attribute. The object takes care of sampling rate conversion to
- match the Server sampling rate setting.
-
+
+ Reads audio data from a AIFF file using one of several available
+ interpolation types. User can alter its pitch with the `speed`
+ attribute. The object takes care of sampling rate conversion to
+ match the Server sampling rate setting.
+
The reading pointer randomly choose a marker (from the MARK chunk
- in the header of the AIFF file) as its starting point and reads
- the samples until it reaches the following marker. Then, it choose
+ in the header of the AIFF file) as its starting point and reads
+ the samples until it reaches the following marker. Then, it choose
another marker and reads from the new position and so on...
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
path : string
Full path name of the sound to read. Can't e changed after
initialization.
speed : float or PyoObject, optional
- Transpose the pitch of input sound by this factor.
+ Transpose the pitch of input sound by this factor.
Defaults to 1.
-
- 1 is the original pitch, lower values play sound slower, and higher
- values play sound faster.
-
- Negative values results in playing sound backward.
-
+
+ 1 is the original pitch, lower values play sound slower, and higher
+ values play sound faster.
+
+ Negative values results in playing sound backward.
+
Although the `speed` attribute accepts audio
rate signal, its value is updated only once per buffer size.
interp : int, optional
@@ -297,9 +303,10 @@ class SfMarkerShuffler(PyoObject):
>>> s = Server().boot()
>>> s.start()
>>> sf = SfMarkerShuffler(SNDS_PATH + "/transparent.aif", speed=[1,1], mul=.3).out()
-
+
"""
def __init__(self, path, speed=1, interp=2, mul=1, add=0):
+ pyoArgsAssert(self, "sOiOO", path, speed, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._speed = speed
self._interp = interp
@@ -314,7 +321,7 @@ class SfMarkerShuffler(PyoObject):
sf.close()
self._markers = [m[1] for m in markerstmp]
except:
- self._markers = []
+ self._markers = []
self._base_players.append(SfMarkerShuffler_base(wrap(path,i), self._markers, wrap(speed,i), wrap(interp,i)))
for i in range(lmax * self._snd_chnls):
j = i / self._snd_chnls
@@ -323,13 +330,14 @@ class SfMarkerShuffler(PyoObject):
def setSpeed(self, x):
"""
Replace the `speed` attribute.
-
+
:Args:
x : float or PyoObject
new `speed` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._speed = x
x, lmax = convertArgsToLists(x)
[obj.setSpeed(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -337,13 +345,14 @@ class SfMarkerShuffler(PyoObject):
def setInterp(self, x):
"""
Replace the `interp` attribute.
-
+
:Args:
x : int {1, 2, 3, 4}
new `interp` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -351,25 +360,25 @@ class SfMarkerShuffler(PyoObject):
def getMarkers(self):
"""
Returns a list of marker time values in samples.
-
+
"""
return self._markers
-
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(0.01, 2., 'lin', 'speed', self._speed),
+ self._map_list = [SLMap(0.01, 2., 'lin', 'speed', self._speed),
SLMap(1, 4, 'lin', 'interp', self._interp, res="int", dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
- def speed(self):
+ def speed(self):
"""float or PyoObject. Transposition factor."""
return self._speed
@speed.setter
def speed(self, x): self.setSpeed(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
@@ -379,13 +388,13 @@ class SfMarkerLooper(PyoObject):
"""
AIFF with markers soundfile looper.
- Reads audio data from a AIFF file using one of several available
+ Reads audio data from a AIFF file using one of several available
interpolation types. User can alter its pitch with the `speed`
- attribute. The object takes care of sampling rate conversion to
- match the Server sampling rate setting.
-
+ attribute. The object takes care of sampling rate conversion to
+ match the Server sampling rate setting.
+
The reading pointer loops a specific marker (from the MARK chunk
- in the header of the AIFF file) until it received a new integer
+ in the header of the AIFF file) until it received a new integer
in the `mark` attribute.
:Parent: :py:class:`PyoObject`
@@ -395,18 +404,18 @@ class SfMarkerLooper(PyoObject):
path : string
Full path name of the sound to read.
speed : float or PyoObject, optional
- Transpose the pitch of input sound by this factor.
+ Transpose the pitch of input sound by this factor.
Defaults to 1.
-
- 1 is the original pitch, lower values play sound slower, and higher
- values play sound faster.
-
- Negative values results in playing sound backward.
-
+
+ 1 is the original pitch, lower values play sound slower, and higher
+ values play sound faster.
+
+ Negative values results in playing sound backward.
+
Although the `speed` attribute accepts audio
rate signal, its value is updated only once per buffer size.
mark : float or PyoObject, optional
- Integer denoting the marker to loop, in the range
+ Integer denoting the marker to loop, in the range
0 -> len(getMarkers()). Defaults to 0.
interp : int, optional
Choice of the interpolation method. Defaults to 2.
@@ -423,6 +432,7 @@ class SfMarkerLooper(PyoObject):
"""
def __init__(self, path, speed=1, mark=0, interp=2, mul=1, add=0):
+ pyoArgsAssert(self, "sOOiOO", path, speed, mark, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._speed = speed
self._mark = mark
@@ -438,7 +448,7 @@ class SfMarkerLooper(PyoObject):
sf.close()
self._markers = [m[1] for m in markerstmp]
except:
- self._markers = []
+ self._markers = []
self._base_players.append(SfMarkerLooper_base(wrap(path,i), self._markers, wrap(speed,i), wrap(mark,i), wrap(interp,i)))
for i in range(lmax * self._snd_chnls):
j = i / self._snd_chnls
@@ -454,6 +464,7 @@ class SfMarkerLooper(PyoObject):
new `speed` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._speed = x
x, lmax = convertArgsToLists(x)
[obj.setSpeed(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -468,6 +479,7 @@ class SfMarkerLooper(PyoObject):
new `mark` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._mark = x
x, lmax = convertArgsToLists(x)
[obj.setMark(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -482,6 +494,7 @@ class SfMarkerLooper(PyoObject):
new `interp` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -494,29 +507,29 @@ class SfMarkerLooper(PyoObject):
return self._markers
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(0.01, 2., 'lin', 'speed', self._speed),
+ self._map_list = [SLMap(0.01, 2., 'lin', 'speed', self._speed),
SLMap(0, len(self._markers)-1, 'lin', 'mark', self._mark, 'int'),
SLMap(1, 4, 'lin', 'interp', self._interp, res="int", dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def speed(self):
+ def speed(self):
"""float or PyoObject. Transposition factor."""
return self._speed
@speed.setter
def speed(self, x): self.setSpeed(x)
@property
- def mark(self):
+ def mark(self):
"""float or PyoObject. Marker to loop."""
return self._marker
@mark.setter
def mark(self, x): self.setMark(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
- def interp(self, x): self.setInterp(x)
+ def interp(self, x): self.setInterp(x)
\ No newline at end of file
diff --git a/pyolib/randoms.py b/pyolib/randoms.py
index 737a0e6..f3e3f68 100644
--- a/pyolib/randoms.py
+++ b/pyolib/randoms.py
@@ -3,25 +3,24 @@ Set of objects that implement different kinds of random noise generators.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
-import sys
from _core import *
from _maps import *
from types import StringType, ListType
@@ -29,11 +28,11 @@ from types import StringType, ListType
class Randi(PyoObject):
"""
Periodic pseudo-random generator with interpolation.
-
- Randi generates a pseudo-random number between `min` and `max`
- values at a frequency specified by `freq` parameter. Randi will
+
+ Randi generates a pseudo-random number between `min` and `max`
+ values at a frequency specified by `freq` parameter. Randi will
produce straight-line interpolation between current number and the next.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -44,15 +43,16 @@ class Randi(PyoObject):
Maximum value for the random generation. Defaults to 1.
freq : float or PyoObject, optional
Polling frequency. Defaults to 1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> freq = Randi(500, 3000, 4)
>>> noze = Noise().mix(2)
>>> a = Biquad(noze, freq=freq, q=5, type=2, mul=.5).out()
-
+
"""
def __init__(self, min=0., max=1., freq=1., mul=1, add=0):
+ pyoArgsAssert(self, "OOOOO", min, max, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._min = min
self._max = max
@@ -63,13 +63,14 @@ class Randi(PyoObject):
def setMin(self, x):
"""
Replace the `min` attribute.
-
+
:Args:
x : float or PyoObject
new `min` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -77,13 +78,14 @@ class Randi(PyoObject):
def setMax(self, x):
"""
Replace the `max` attribute.
-
+
:Args:
x : float or PyoObject
new `max` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -91,14 +93,15 @@ class Randi(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
- self._port = x
+ pyoArgsAssert(self, "O", x)
+ self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -110,35 +113,35 @@ class Randi(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def min(self):
+ def min(self):
"""float or PyoObject. Minimum value."""
return self._min
@min.setter
- def min(self, x):
+ def min(self, x):
self.setMin(x)
@property
- def max(self):
+ def max(self):
"""float or PyoObject. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
@property
- def freq(self):
+ def freq(self):
"""float or PyoObject. Polling frequency."""
return self._freq
@freq.setter
- def freq(self, x):
+ def freq(self, x):
self.setFreq(x)
class Randh(PyoObject):
"""
Periodic pseudo-random generator.
-
- Randh generates a pseudo-random number between `min` and `max`
- values at a frequency specified by `freq` parameter. Randh will
+
+ Randh generates a pseudo-random number between `min` and `max`
+ values at a frequency specified by `freq` parameter. Randh will
hold generated value until next generation.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -149,15 +152,16 @@ class Randh(PyoObject):
Maximum value for the random generation. Defaults to 1.
freq : float or PyoObject, optional
Polling frequency. Defaults to 1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> freq = Randh(500, 3000, 4)
>>> noze = Noise().mix(2)
>>> a = Biquad(noze, freq=freq, q=5, type=2, mul=.5).out()
-
+
"""
def __init__(self, min=0., max=1., freq=1., mul=1, add=0):
+ pyoArgsAssert(self, "OOOOO", min, max, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._min = min
self._max = max
@@ -168,13 +172,14 @@ class Randh(PyoObject):
def setMin(self, x):
"""
Replace the `min` attribute.
-
+
:Args:
x : float or PyoObject
new `min` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -182,13 +187,14 @@ class Randh(PyoObject):
def setMax(self, x):
"""
Replace the `max` attribute.
-
+
:Args:
x : float or PyoObject
new `max` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -196,14 +202,15 @@ class Randh(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
- self._port = x
+ pyoArgsAssert(self, "O", x)
+ self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -215,35 +222,35 @@ class Randh(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def min(self):
+ def min(self):
"""float or PyoObject. Minimum value."""
return self._min
@min.setter
- def min(self, x):
+ def min(self, x):
self.setMin(x)
@property
- def max(self):
+ def max(self):
"""float or PyoObject. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
@property
- def freq(self):
+ def freq(self):
"""float or PyoObject. Polling frequency."""
return self._freq
@freq.setter
- def freq(self, x):
+ def freq(self, x):
self.setFreq(x)
class Choice(PyoObject):
"""
Periodically choose a new value from a user list.
-
+
Choice chooses a new value from a predefined list of floats `choice`
- at a frequency specified by `freq` parameter. Choice will
+ at a frequency specified by `freq` parameter. Choice will
hold choosen value until next generation.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -258,13 +265,11 @@ class Choice(PyoObject):
>>> freqs = midiToHz([60,62,64,65,67,69,71,72])
>>> rnd = Choice(choice=freqs, freq=[3,4])
>>> a = SineLoop(rnd, feedback=0.05, mul=.2).out()
-
+
"""
def __init__(self, choice, freq=1., mul=1, add=0):
+ pyoArgsAssert(self, "lOOO", choice, freq, mul, add)
PyoObject.__init__(self, mul, add)
- if type(choice) != ListType:
- print >> sys.stderr, 'TypeError: "choice" argument of %s must be a list.\n' % self.__class__.__name__
- exit()
self._choice = choice
self._freq = freq
freq, mul, add, lmax = convertArgsToLists(freq, mul, add)
@@ -274,33 +279,35 @@ class Choice(PyoObject):
choicelen = len(choice)
lmax = max(choicelen, lmax)
self._base_objs = [Choice_base(wrap(choice,i), wrap(freq,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
-
+
def setChoice(self, x):
"""
Replace the `choice` attribute.
-
+
:Args:
x : list of floats or list of lists of floats
new `choice` attribute.
-
+
"""
+ pyoArgsAssert(self, "l", x)
self._choice = x
if type(x[0]) != ListType:
[obj.setChoice(self._choice) for i, obj in enumerate(self._base_objs)]
else:
[obj.setChoice(wrap(self._choice,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -310,28 +317,28 @@ class Choice(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def choice(self):
+ def choice(self):
"""list of floats or list of lists of floats. Possible choices."""
return self._choice
@choice.setter
- def choice(self, x):
+ def choice(self, x):
self.setChoice(x)
@property
- def freq(self):
+ def freq(self):
"""float or PyoObject. Polling frequency."""
return self._freq
@freq.setter
- def freq(self, x):
+ def freq(self, x):
self.setFreq(x)
class RandInt(PyoObject):
"""
Periodic pseudo-random integer generator.
-
- RandInt generates a pseudo-random integer number between 0 and `max`
- values at a frequency specified by `freq` parameter. RandInt will
+
+ RandInt generates a pseudo-random integer number between 0 and `max`
+ values at a frequency specified by `freq` parameter. RandInt will
hold generated value until the next generation.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -346,9 +353,10 @@ class RandInt(PyoObject):
>>> freq = RandInt(max=10, freq=5, mul=100, add=500)
>>> jit = Randi(min=0.99, max=1.01, freq=[2.33,3.41])
>>> a = SineLoop(freq*jit, feedback=0.03, mul=.2).out()
-
+
"""
def __init__(self, max=100, freq=1., mul=1, add=0):
+ pyoArgsAssert(self, "OOOO", max, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._max = max
self._freq = freq
@@ -358,13 +366,14 @@ class RandInt(PyoObject):
def setMax(self, x):
"""
Replace the `max` attribute.
-
+
:Args:
x : float or PyoObject
new `max` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -372,13 +381,14 @@ class RandInt(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -390,26 +400,26 @@ class RandInt(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def max(self):
+ def max(self):
"""float or PyoObject. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
@property
- def freq(self):
+ def freq(self):
"""float or PyoObject. Polling frequency."""
return self._freq
@freq.setter
- def freq(self, x):
+ def freq(self, x):
self.setFreq(x)
class RandDur(PyoObject):
"""
Recursive time varying pseudo-random generator.
- RandDur generates a pseudo-random number between `min` and `max`
- arguments and uses that number to set the delay time before the next
+ RandDur generates a pseudo-random number between `min` and `max`
+ arguments and uses that number to set the delay time before the next
generation. RandDur will hold the generated value until next generation.
:Parent: :py:class:`PyoObject`
@@ -432,6 +442,7 @@ class RandDur(PyoObject):
"""
def __init__(self, min=0., max=1., mul=1, add=0):
+ pyoArgsAssert(self, "OOOO", min, max, mul, add)
PyoObject.__init__(self, mul, add)
self._min = min
self._max = max
@@ -448,6 +459,7 @@ class RandDur(PyoObject):
new `min` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -462,6 +474,7 @@ class RandDur(PyoObject):
new `max` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -473,18 +486,18 @@ class RandDur(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def min(self):
+ def min(self):
"""float or PyoObject. Minimum value."""
return self._min
@min.setter
- def min(self, x):
+ def min(self, x):
self.setMin(x)
@property
- def max(self):
+ def max(self):
"""float or PyoObject. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
class Xnoise(PyoObject):
@@ -506,9 +519,9 @@ class Xnoise(PyoObject):
First parameter. Defaults to 0.5.
x2 : float or PyoObject, optional
Second parameter. Defaults to 0.5.
-
+
.. note::
-
+
Available distributions are:
0. uniform
1. linear minimum
@@ -523,7 +536,7 @@ class Xnoise(PyoObject):
10. poisson
11. walker (drunk)
12. loopseg (drunk with looped segments)
-
+
Depending on the distribution, `x1` and `x2` parameters are applied
as follow (names as string, or associated number can be used as `dist`
parameter):
@@ -564,7 +577,7 @@ class Xnoise(PyoObject):
11. walker
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
- 12. loopseg
+ 12. loopseg
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
@@ -577,6 +590,7 @@ class Xnoise(PyoObject):
"""
def __init__(self, dist=0, freq=1., x1=0.5, x2=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "OOOOO", freq, x1, x2, mul, add)
PyoObject.__init__(self, mul, add)
self._dist = dist
self._freq = freq
@@ -593,7 +607,7 @@ class Xnoise(PyoObject):
:Args:
- x : int
+ x : string or int
new `dist` attribute.
"""
@@ -613,6 +627,7 @@ class Xnoise(PyoObject):
new `x1` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._x1 = x
x, lmax = convertArgsToLists(x)
[obj.setX1(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -627,6 +642,7 @@ class Xnoise(PyoObject):
new `x2` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._x2 = x
x, lmax = convertArgsToLists(x)
[obj.setX2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -641,7 +657,8 @@ class Xnoise(PyoObject):
new `freq` attribute.
"""
- self._port = x
+ pyoArgsAssert(self, "O", x)
+ self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -655,32 +672,32 @@ class Xnoise(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def dist(self):
+ def dist(self):
"""string or int. Distribution type."""
return self._dist
@dist.setter
- def dist(self, x):
+ def dist(self, x):
self.setDist(x)
@property
- def freq(self):
+ def freq(self):
"""float or PyoObject. Polling frequency."""
return self._freq
@freq.setter
- def freq(self, x):
+ def freq(self, x):
self.setFreq(x)
@property
- def x1(self):
+ def x1(self):
"""float or PyoObject. First parameter."""
return self._x1
@x1.setter
- def x1(self, x):
+ def x1(self, x):
self.setX1(x)
@property
- def x2(self):
+ def x2(self):
"""float or PyoObject. Second parameter."""
return self._x2
@x2.setter
- def x2(self, x):
+ def x2(self, x):
self.setX2(x)
class XnoiseMidi(PyoObject):
@@ -689,8 +706,8 @@ class XnoiseMidi(PyoObject):
XnoiseMidi implements a few of the most common noise distributions.
Each distribution generates integer values in the range defined with
- `mrange` parameter and output can be scaled on midi notes, hertz or
- transposition factor.
+ `mrange` parameter and output can be scaled on midi notes, hertz or
+ transposition factor.
:Parent: :py:class:`PyoObject`
@@ -705,16 +722,16 @@ class XnoiseMidi(PyoObject):
x2 : float or PyoObject, optional
Second parameter. Defaults to 0.5.
scale : int {0, 1, 2}, optional
- Output format. 0 = Midi, 1 = Hertz, 2 = transposition factor.
- In the transposition mode, the central key (the key where there
+ Output format. 0 = Midi, 1 = Hertz, 2 = transposition factor.
+ In the transposition mode, the central key (the key where there
is no transposition) is (`minrange` + `maxrange`) / 2. Defaults
to 0.
mrange : tuple of int, optional
Minimum and maximum possible values, in Midi notes. Available
only at initialization time. Defaults to (0, 127).
-
+
.. note::
-
+
Available distributions are:
0. uniform
1. linear minimum
@@ -729,7 +746,7 @@ class XnoiseMidi(PyoObject):
10. poisson
11. walker (drunk)
12. loopseg (drunk with looped segments)
-
+
Depending on the distribution, `x1` and `x2` parameters are applied
as follow (names as string, or associated number can be used as `dist`
parameter):
@@ -770,7 +787,7 @@ class XnoiseMidi(PyoObject):
11. walker
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
- 12. loopseg
+ 12. loopseg
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
@@ -784,6 +801,7 @@ class XnoiseMidi(PyoObject):
"""
def __init__(self, dist=0, freq=1., x1=0.5, x2=0.5, scale=0, mrange=(0,127), mul=1, add=0):
+ pyoArgsAssert(self, "OOOixOO", freq, x1, x2, scale, mrange, mul, add)
PyoObject.__init__(self, mul, add)
self._dist = dist
self._freq = freq
@@ -815,8 +833,8 @@ class XnoiseMidi(PyoObject):
def setScale(self, x):
"""
Replace the `scale` attribute.
-
- Possible values are:
+
+ Possible values are:
0. Midi notes
1. Hertz
2. transposition factor (centralkey is (`minrange` + `maxrange`) / 2
@@ -827,6 +845,7 @@ class XnoiseMidi(PyoObject):
new `scale` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._scale = x
x, lmax = convertArgsToLists(x)
[obj.setScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -843,6 +862,7 @@ class XnoiseMidi(PyoObject):
maximum output midi range.
"""
+ pyoArgsAssert(self, "ii", mini, maxi)
self._mrange = (mini, maxi)
mini, maxi, lmax = convertArgsToLists(mini, maxi)
[obj.setRange(wrap(mini,i), wrap(maxi,i)) for i, obj in enumerate(self._base_objs)]
@@ -857,6 +877,7 @@ class XnoiseMidi(PyoObject):
new `x1` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._x1 = x
x, lmax = convertArgsToLists(x)
[obj.setX1(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -871,7 +892,8 @@ class XnoiseMidi(PyoObject):
new `x2` attribute.
"""
- self._x2= x
+ pyoArgsAssert(self, "O", x)
+ self._x2 = x
x, lmax = convertArgsToLists(x)
[obj.setX2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -885,7 +907,8 @@ class XnoiseMidi(PyoObject):
new `freq` attribute.
"""
- self._port = x
+ pyoArgsAssert(self, "O", x)
+ self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -898,39 +921,39 @@ class XnoiseMidi(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def dist(self):
+ def dist(self):
"""string or int. Distribution type."""
return self._dist
@dist.setter
- def dist(self, x):
+ def dist(self, x):
self.setDist(x)
@property
- def freq(self):
+ def freq(self):
"""float or PyoObject. Polling frequency."""
return self._freq
@freq.setter
- def freq(self, x):
+ def freq(self, x):
self.setFreq(x)
@property
- def x1(self):
+ def x1(self):
"""float or PyoObject. First parameter."""
return self._x1
@x1.setter
- def x1(self, x):
+ def x1(self, x):
self.setX1(x)
@property
- def x2(self):
+ def x2(self):
"""float or PyoObject. Second parameter."""
return self._x2
@x2.setter
- def x2(self, x):
+ def x2(self, x):
self.setX2(x)
@property
- def scale(self):
+ def scale(self):
"""int. Output format."""
return self._scale
@scale.setter
- def scale(self, x):
+ def scale(self, x):
self.setScale(x)
class XnoiseDur(PyoObject):
@@ -939,8 +962,8 @@ class XnoiseDur(PyoObject):
Xnoise implements a few of the most common noise distributions.
Each distribution generates values in the range 0 to 1, which are
- then rescaled between `min` and `max` arguments. The object uses
- the generated value to set the delay time before the next generation.
+ then rescaled between `min` and `max` arguments. The object uses
+ the generated value to set the delay time before the next generation.
XnoiseDur will hold the value until next generation.
:Parent: :py:class:`PyoObject`
@@ -975,7 +998,7 @@ class XnoiseDur(PyoObject):
10. poisson
11. walker (drunk)
12. loopseg (drunk with looped segments)
-
+
Depending on the distribution, `x1` and `x2` parameters are applied
as follow (names as string, or associated number can be used as `dist`
parameter):
@@ -1016,7 +1039,7 @@ class XnoiseDur(PyoObject):
11. walker
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
- 12. loopseg
+ 12. loopseg
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
@@ -1031,6 +1054,7 @@ class XnoiseDur(PyoObject):
"""
def __init__(self, dist=0, min=0., max=1., x1=0.5, x2=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "OOOOOO", min, max, x1, x2, mul, add)
PyoObject.__init__(self, mul, add)
self._dist = dist
self._min = min
@@ -1048,7 +1072,7 @@ class XnoiseDur(PyoObject):
:Args:
- x : int
+ x : string or int
new `dist` attribute.
"""
@@ -1068,6 +1092,7 @@ class XnoiseDur(PyoObject):
new `min` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1082,6 +1107,7 @@ class XnoiseDur(PyoObject):
new `max` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1096,6 +1122,7 @@ class XnoiseDur(PyoObject):
new `x1` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._x1 = x
x, lmax = convertArgsToLists(x)
[obj.setX1(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1110,7 +1137,8 @@ class XnoiseDur(PyoObject):
new `x2` attribute.
"""
- self._x2= x
+ pyoArgsAssert(self, "O", x)
+ self._x2 = x
x, lmax = convertArgsToLists(x)
[obj.setX2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1123,52 +1151,52 @@ class XnoiseDur(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def dist(self):
+ def dist(self):
"""string or int. Distribution type."""
return self._dist
@dist.setter
- def dist(self, x):
+ def dist(self, x):
self.setDist(x)
@property
- def min(self):
+ def min(self):
"""float or PyoObject. Minimum value."""
return self._min
@min.setter
- def min(self, x):
+ def min(self, x):
self.setMin(x)
@property
- def max(self):
+ def max(self):
"""float or PyoObject. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
@property
- def x1(self):
+ def x1(self):
"""float or PyoObject. First parameter."""
return self._x1
@x1.setter
- def x1(self, x):
+ def x1(self, x):
self.setX1(x)
@property
- def x2(self):
+ def x2(self):
"""float or PyoObject. Second parameter."""
return self._x2
@x2.setter
- def x2(self, x):
+ def x2(self, x):
self.setX2(x)
class Urn(PyoObject):
"""
Periodic pseudo-random integer generator without duplicates.
- Urn generates a pseudo-random integer number between 0 and `max`
- values at a frequency specified by `freq` parameter. Urn will
- hold generated value until the next generation. Urn works like RandInt,
+ Urn generates a pseudo-random integer number between 0 and `max`
+ values at a frequency specified by `freq` parameter. Urn will
+ hold generated value until the next generation. Urn works like RandInt,
except that it keeps track of each number which has been generated. After
all numbers have been outputed, the pool is reseted and the object send
a trigger signal.
-
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -1180,9 +1208,9 @@ class Urn(PyoObject):
.. note::
- Urn will sends a trigger signal when the pool is empty.
- User can retreive the trigger streams by calling obj['trig'].
- Useful to synchronize other processes.
+ Urn will sends a trigger signal when the pool is empty.
+ User can retreive the trigger streams by calling obj['trig'].
+ Useful to synchronize other processes.
>>> s = Server().boot()
>>> s.start()
@@ -1191,9 +1219,10 @@ class Urn(PyoObject):
>>> sigL = SineLoop(freq=fr, feedback=.08, mul=0.3).out()
>>> amp = TrigExpseg(mid["trig"], [(0,0),(.01,.25),(1,0)])
>>> sigR = SineLoop(midiToHz(84), feedback=0.05, mul=amp).out(1)
-
+
"""
def __init__(self, max=100, freq=1., mul=1, add=0):
+ pyoArgsAssert(self, "iOOO", max, freq, mul, add)
PyoObject.__init__(self, mul, add)
self._max = max
self._freq = freq
@@ -1207,13 +1236,14 @@ class Urn(PyoObject):
def setMax(self, x):
"""
Replace the `max` attribute.
-
+
:Args:
x : int
new `max` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1221,13 +1251,14 @@ class Urn(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1239,16 +1270,16 @@ class Urn(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def max(self):
+ def max(self):
"""int. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
@property
- def freq(self):
+ def freq(self):
"""float or PyoObject. Polling frequency."""
return self._freq
@freq.setter
- def freq(self, x):
- self.setFreq(x)
+ def freq(self, x):
+ self.setFreq(x)
\ No newline at end of file
diff --git a/pyolib/server.py b/pyolib/server.py
index 73af2ba..148da73 100644
--- a/pyolib/server.py
+++ b/pyolib/server.py
@@ -1,76 +1,79 @@
# -*- coding: utf-8 -*-
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
import os, time
from _core import *
from _widgets import createServerGUI
-
+
######################################################################
### Proxy of Server object
######################################################################
class Server(object):
"""
Main processing audio loop callback handler.
-
- The Server object handles all communications with Portaudio and
+
+ The Server object handles all communications with Portaudio and
Portmidi. It keeps track of all audio streams created as well as
- connections between them.
-
- An instance of the Server must be booted before defining any
+ connections between them.
+
+ An instance of the Server must be booted before defining any
signal processing chain.
:Args:
sr : int, optional
- Sampling rate used by Portaudio and the Server to compute samples.
+ Sampling rate used by Portaudio and the Server to compute samples.
Defaults to 44100.
nchnls : int, optional
- Number of input and output channels. Defaults to 2.
+ Number of output channels. The number of input channels will be the
+ same if `ichnls` argument is not defined. Defaults to 2.
buffersize : int, optional
- Number of samples that Portaudio will request from the callback loop.
+ Number of samples that Portaudio will request from the callback loop.
Defaults to 256.
- This value has an impact on CPU use (a small buffer size is harder
- to compute) and on the latency of the system.
-
- Latency is `buffer size / sampling rate` in seconds.
+ This value has an impact on CPU use (a small buffer size is harder
+ to compute) and on the latency of the system.
+
+ Latency is `buffer size / sampling rate` in seconds.
duplex : int {0, 1}, optional
- Input - output mode. 0 is output only and 1 is both ways.
+ Input - output mode. 0 is output only and 1 is both ways.
Defaults to 1.
audio : string {'portaudio', 'pa', 'jack', 'coreaudio', 'offline', 'offline_nb}, optional
Audio backend to use. 'pa' is equivalent to 'portaudio'. Default is 'portaudio'.
-
- 'offline' save the audio output in a soundfile as fast as possible in blocking mode,
+
+ 'offline' save the audio output in a soundfile as fast as possible in blocking mode,
ie. the main program doesn't respond until the end of the computation.
-
- 'offline_nb' save the audio output in a soundfile as fast as possible in non-blocking
- mode,
-
+
+ 'offline_nb' save the audio output in a soundfile as fast as possible in non-blocking
+ mode,
+
ie. the computation is executed in a separated thread, allowing the program to
- respond while the computation goes on.
+ respond while the computation goes on.
- It is the responsibility of the user to make sure that the program doesn't exit before
+ It is the responsibility of the user to make sure that the program doesn't exit before
the computation is done.
jackname : string, optional
Name of jack client. Defaults to 'pyo'
+ ichnls : int, optional
+ Number of input channels if different of output channels. If None (default), ichnls = nchnls.
.. note::
@@ -86,7 +89,8 @@ class Server(object):
- setMidiOutputDevice(x) : Set the MIDI output device number. See `pm_list_devices()`.
- setSamplingRate(x) : Set the sampling rate used by the server.
- setBufferSize(x) : Set the buffer size used by the server.
- - setNchnls(x) : Set the number of channels used by the server.
+ - setNchnls(x) : Set the number of output (and input if `ichnls` = None) channels used by the server.
+ - setIchnls(x) : Set the number of input channels (if different of output channels) used by the server.
- setDuplex(x) : Set the duplex mode used by the server.
- setVerbosity(x) : Set the server's verbosity.
- reinit(sr, nchnls, buffersize, duplex, audio, jackname) : Reinit the server's settings.
@@ -95,13 +99,18 @@ class Server(object):
>>> # a sampling rate of 48000 Hz and buffer size of 512
>>> s = Server(sr=48000, nchnls=8, buffersize=512, duplex=1).boot()
>>> s.start()
-
+
"""
- def __init__(self, sr=44100, nchnls=2, buffersize=256, duplex=1, audio='portaudio', jackname='pyo'):
+ def __init__(self, sr=44100, nchnls=2, buffersize=256, duplex=1,
+ audio='portaudio', jackname='pyo', ichnls=None):
if os.environ.has_key("PYO_SERVER_AUDIO") and "offline" not in audio and "embedded" not in audio:
audio = os.environ["PYO_SERVER_AUDIO"]
self._time = time
self._nchnls = nchnls
+ if ichnls == None:
+ self._ichnls = nchnls
+ else:
+ self._ichnls = ichnls
self._amp = 1.
self._verbosity = 7
self._startoffset = 0
@@ -109,10 +118,12 @@ class Server(object):
self._filename = None
self._fileformat = 0
self._sampletype = 0
- self._server = Server_base(sr, nchnls, buffersize, duplex, audio, jackname)
+ self._server = Server_base(sr, nchnls, buffersize, duplex, audio, jackname, self._ichnls)
self._server._setDefaultRecPath(os.path.join(os.path.expanduser("~"), "pyo_rec.wav"))
def __del__(self):
+ self.setTime = None
+ self.setRms = None
if self.getIsBooted():
if self.getIsStarted():
self.stop()
@@ -120,16 +131,21 @@ class Server(object):
self.shutdown()
self._time.sleep(.25)
- def reinit(self, sr=44100, nchnls=2, buffersize=256, duplex=1, audio='portaudio', jackname='pyo'):
+ def reinit(self, sr=44100, nchnls=2, buffersize=256, duplex=1,
+ audio='portaudio', jackname='pyo', ichnls=None):
"""
Reinit the server'settings. Useful to alternate between real-time and offline server.
-
+
:Args:
-
+
Same as in the __init__ method.
-
+
"""
self._nchnls = nchnls
+ if ichnls == None:
+ self._ichnls = nchnls
+ else:
+ self._ichnls = ichnls
self._amp = 1.
self._verbosity = 7
self._startoffset = 0
@@ -138,27 +154,31 @@ class Server(object):
self._fileformat = 0
self._sampletype = 0
self._globalseed = 0
- self._server.__init__(sr, nchnls, buffersize, duplex, audio, jackname)
+ self._server.__init__(sr, nchnls, buffersize, duplex, audio, jackname, self._ichnls)
- def gui(self, locals=None, meter=True, timer=True):
+ def gui(self, locals=None, meter=True, timer=True, exit=True):
"""
Show the server's user interface.
-
+
:Args:
-
+
locals : locals namespace {locals(), None}, optional
If locals() is given, the interface will show an interpreter extension,
giving a way to interact with the running script. Defaults to None.
meter : boolean, optinal
- If True, the interface will show a vumeter of the global output signal.
+ If True, the interface will show a vumeter of the global output signal.
Defaults to True.
timer : boolean, optional
If True, the interface will show a clock of the current time.
Defaults to True.
-
+ exit : boolean, optional
+ If True, the python interpreter will exit when the 'Quit' button is pressed,
+ Otherwise, the GUI will be closed leaving the interpreter alive.
+ Defaults to True.
+
"""
f, win = createServerGUI(self._nchnls, self.start, self.stop, self.recstart, self.recstop,
- self.setAmp, self.getIsStarted(), locals, self.shutdown, meter, timer, self._amp)
+ self.setAmp, self.getIsStarted(), locals, self.shutdown, meter, timer, self._amp, exit)
if meter:
self._server.setAmpCallable(f)
if timer:
@@ -170,13 +190,55 @@ class Server(object):
win.MainLoop()
def setTimeCallable(self, func):
+ """
+ Set a function callback that will receive the current time as argument.
+
+ The function will receive four integers in this format:
+ hours, minutes, seconds, milliseconds
+
+ :Args:
+
+ func : python callable
+ Python function or method to call with current time as argument.
+
+ """
self.setTime = func
self._server.setTimeCallable(self)
+
+ def setMeterCallable(self, func):
+ """
+ Set a function callback that will receive the current rms values as argument.
+
+ The function will receive a list containing the rms value for each audio channel.
+
+ :Args:
+
+ func : python callable
+ Python function or method to call with current rms values as argument.
+
+ """
+ self.setRms = func
+ self._server.setAmpCallable(self)
+
+ def setMeter(self, meter):
+ """
+ Registers a meter object to the server.
+ The object must have a method named `setRms`. This method will be called
+ with the rms values of each audio channel as argument.
+
+ :Args:
+
+ meter : python object
+ Python object with a `setRms` method.
+
+ """
+ self._server.setAmpCallable(meter)
+
def setInOutDevice(self, x):
"""
Set both input and output audio devices. See `pa_list_devices()`.
-
+
:Args:
x : int
@@ -184,11 +246,11 @@ class Server(object):
"""
self._server.setInOutDevice(x)
-
+
def setInputDevice(self, x):
"""
Set the audio input device number. See `pa_list_devices()`.
-
+
:Args:
x : int
@@ -200,7 +262,7 @@ class Server(object):
def setOutputDevice(self, x):
"""
Set the audio output device number. See `pa_list_devices()`.
-
+
:Args:
x : int
@@ -212,11 +274,11 @@ class Server(object):
def setInputOffset(self, x):
"""
Set the first physical input channel.
-
+
Channel number `x` from the soundcard will be assigned to
server's channel one, channel number `x` + 1 to server's
- channel two and so on.
-
+ channel two and so on.
+
:Args:
x : int
@@ -229,10 +291,10 @@ class Server(object):
"""
Set the first physical output channel.
- Server's channel one will be assigned to soundcard's channel
+ Server's channel one will be assigned to soundcard's channel
number `x`, server's channel two will be assigned to soundcard's
- channel number `x` + 1 and so on.
-
+ channel number `x` + 1 and so on.
+
:Args:
x : int
@@ -260,7 +322,10 @@ class Server(object):
def setMidiInputDevice(self, x):
"""
Set the Midi input device number. See `pm_list_devices()`.
-
+
+ A number greater than the highest portmidi device index
+ will opened all available input devices.
+
:Args:
x : int
@@ -272,7 +337,7 @@ class Server(object):
def setMidiOutputDevice(self, x):
"""
Set the Midi output device number. See `pm_list_devices()`.
-
+
:Args:
x : int
@@ -280,35 +345,35 @@ class Server(object):
"""
self._server.setMidiOutputDevice(x)
-
+
def setSamplingRate(self, x):
"""
Set the sampling rate used by the server.
-
+
:Args:
x : int
New sampling rate, must be supported by the soundcard.
- """
+ """
self._server.setSamplingRate(x)
-
+
def setBufferSize(self, x):
"""
Set the buffer size used by the server.
-
+
:Args:
x : int
New buffer size.
- """
+ """
self._server.setBufferSize(x)
-
+
def setNchnls(self, x):
"""
- Set the number of channels used by the server.
-
+ Set the number of output (and input if `ichnls` = None) channels used by the server.
+
:Args:
x : int
@@ -318,28 +383,41 @@ class Server(object):
self._nchnls = x
self._server.setNchnls(x)
+ def setIchnls(self, x):
+ """
+ Set the number of input channels (if different of output channels) used by the server.
+
+ :Args:
+
+ x : int
+ New number of input channels.
+
+ """
+ self._ichnls = x
+ self._server.setIchnls(x)
+
def setDuplex(self, x):
"""
Set the duplex mode used by the server.
-
+
:Args:
x : int {0 or 1}
New mode. 0 is output only, 1 is both ways.
- """
+ """
self._server.setDuplex(x)
def setVerbosity(self, x):
"""
Set the server's verbosity.
-
+
:Args:
x : int
- A sum of values to display different levels:
+ A sum of values to display different levels:
- 1 = error
- - 2 = message
+ - 2 = message
- 4 = warning
- 8 = debug
@@ -349,8 +427,8 @@ class Server(object):
def setJackAuto(self, xin=True, xout=True):
"""
- Tells the server to auto-connect (or not) Jack ports.
-
+ Tells the server to auto-connect (or not) Jack ports to System ports.
+
:Args:
xin : boolean
@@ -358,9 +436,35 @@ class Server(object):
xout : boolean
Output Auto-connection switch. True is enabled (default) and False is disabled.
- """
+ """
self._server.setJackAuto(xin, xout)
+ def setJackAutoConnectInputPorts(self, ports):
+ """
+ Tells the server to auto-connect Jack input ports to pre-defined Jack ports.
+
+ :Args:
+
+ ports : string or list of strings
+ Name of the Jack port(s) to auto-connect. Regular Expressions are allowed.
+
+ """
+ ports, lmax = convertArgsToLists(ports)
+ self._server.setJackAutoConnectInputPorts(ports)
+
+ def setJackAutoConnectOutputPorts(self, ports):
+ """
+ Tells the server to auto-connect Jack output ports to pre-defined Jack ports.
+
+ :Args:
+
+ ports : string or list of strings
+ Name of the Jack port(s) to auto-connect. Regular Expressions are allowed.
+
+ """
+ ports, lmax = convertArgsToLists(ports)
+ self._server.setJackAutoConnectOutputPorts(ports)
+
def setGlobalSeed(self, x):
"""
Set the server's global seed used by random objects.
@@ -372,7 +476,7 @@ class Server(object):
If zero, randoms will be seeded with the system clock current value.
- """
+ """
self._globalseed = x
self._server.setGlobalSeed(x)
@@ -385,15 +489,15 @@ class Server(object):
x : float
Starting time of the real-time processing.
-
- """
+
+ """
self._startoffset = x
self._server.setStartOffset(x)
def setAmp(self, x):
"""
Set the overall amplitude.
-
+
:Args:
x : float
@@ -402,50 +506,50 @@ class Server(object):
"""
self._amp = x
self._server.setAmp(x)
-
+
def shutdown(self):
"""
Shut down and clear the server. This method will erase all objects
- from the callback loop. This method need to be called before changing
+ from the callback loop. This method need to be called before changing
server's parameters like `samplingrate`, `buffersize`, `nchnls`, ...
"""
self._server.shutdown()
-
+
def boot(self, newBuffer=True):
"""
- Boot the server. Must be called before defining any signal processing
- chain. Server's parameters like `samplingrate`, `buffersize` or
- `nchnls` will be effective after a call to this method.
-
+ Boot the server. Must be called before defining any signal processing
+ chain. Server's parameters like `samplingrate`, `buffersize` or
+ `nchnls` will be effective after a call to this method.
+
:Args:
-
+
newBuffer : bool
- Specify if the buffers need to be allocated or not. Useful to limit
- the allocation of new buffers when the buffer size hasn't change.
-
- Therefore, this is useful to limit calls to the Python interpreter
- to get the buffers addresses when using Pyo inside a
- C/C++ application with the embedded server.
-
+ Specify if the buffers need to be allocated or not. Useful to limit
+ the allocation of new buffers when the buffer size hasn't change.
+
+ Therefore, this is useful to limit calls to the Python interpreter
+ to get the buffers addresses when using Pyo inside a
+ C/C++ application with the embedded server.
+
Defaults to True.
"""
self._server.boot(newBuffer)
return self
-
+
def start(self):
"""
Start the audio callback loop and begin processing.
-
+
"""
self._server.start()
return self
-
+
def stop(self):
"""
Stop the audio callback loop.
-
+
"""
self._server.stop()
@@ -464,8 +568,8 @@ class Server(object):
Defaults to None.
fileformat : int, optional
Format type of the audio file. This function will first try to
- set the format from the filename extension.
-
+ set the format from the filename extension.
+
If it's not possible, it uses the fileformat parameter. Supported formats are:
0. WAV - Microsoft WAV format (little endian) {.wav, .wave} (default)
1. AIFF - Apple/SGI AIFF format (big endian) {.aif, .aiff}
@@ -476,8 +580,8 @@ class Server(object):
6. CAF - Core Audio File format {.caf}
7. OGG - Xiph OGG container {.ogg}
sampletype : int, optional
- Bit depth encoding of the audio file.
-
+ Bit depth encoding of the audio file.
+
SD2 and FLAC only support 16 or 24 bit int. Supported types are:
0. 16 bits int (default)
1. 24 bits int
@@ -488,7 +592,7 @@ class Server(object):
6. A-Law encoded
"""
-
+
self._dur = dur
if filename == None:
filename = os.path.join(os.path.expanduser("~"), "pyo_rec.wav")
@@ -505,20 +609,20 @@ class Server(object):
self._fileformat = fileformat
self._sampletype = sampletype
self._server.recordOptions(dur, filename, fileformat, sampletype)
-
+
def recstart(self, filename=None):
"""
Begins a default recording of the sound that is sent to the
- soundcard. This will create a file called `pyo_rec.wav` in
+ soundcard. This will create a file called `pyo_rec.wav` in
the user's home directory if no path is supplied or defined
- with recordOptions method. Uses file format and sample type
- defined with recordOptions method.
-
+ with recordOptions method. Uses file format and sample type
+ defined with recordOptions method.
+
:Args:
-
+
filename : string, optional
Name of the file to be created. Defaults to None.
-
+
"""
if filename == None:
if self._filename != None:
@@ -534,58 +638,186 @@ class Server(object):
self._fileformat = fileformat
self._server.recordOptions(self._dur, filename, self._fileformat, self._sampletype)
- self._server.recstart(filename)
-
+ self._server.recstart(filename)
+
def recstop(self):
"""
Stop the previously started recording.
-
+
"""
self._server.recstop()
- def sendMidiNote(self, pitch, velocity, channel=0, timestamp=0):
+ def noteout(self, pitch, velocity, channel=0, timestamp=0):
"""
- Send a MIDI note message to the selected output device.
-
+ Send a MIDI note message to the selected midi output device.
+
+ Arguments can be list of values to generate multiple events
+ in one call.
+
:Args:
-
+
pitch : int
Midi pitch, between 0 and 127.
velocity : int
Amplitude of the note, between 0 and 127. A note
with a velocity of 0 is equivalent to a note off.
channel : int, optional
- The Midi channel, between 1 and 16, on which the
- note is sent. A channel of 0 means all channels.
+ The Midi channel, between 1 and 16, on which the
+ note is sent. A channel of 0 means all channels.
+ Defaults to 0.
+ timestamp : int, optional
+ The delay time, in milliseconds, before the note
+ is sent on the portmidi stream. A value of 0 means
+ to play the note now. Defaults to 0.
+ """
+ pitch, velocity, channel, timestamp, lmax = convertArgsToLists(pitch, velocity, channel, timestamp)
+ [self._server.noteout(wrap(pitch,i), wrap(velocity,i), wrap(channel,i), wrap(timestamp,i)) for i in range(lmax)]
+
+ def afterout(self, pitch, velocity, channel=0, timestamp=0):
+ """
+ Send an aftertouch message to the selected midi output device.
+
+ Arguments can be list of values to generate multiple events
+ in one call.
+
+ :Args:
+
+ pitch : int
+ Midi key pressed down, between 0 and 127.
+ velocity : int
+ Velocity of the pressure, between 0 and 127.
+ channel : int, optional
+ The Midi channel, between 1 and 16, on which the
+ note is sent. A channel of 0 means all channels.
+ Defaults to 0.
+ timestamp : int, optional
+ The delay time, in milliseconds, before the note
+ is sent on the portmidi stream. A value of 0 means
+ to play the note now. Defaults to 0.
+ """
+ pitch, velocity, channel, timestamp, lmax = convertArgsToLists(pitch, velocity, channel, timestamp)
+ [self._server.afterout(wrap(pitch,i), wrap(velocity,i), wrap(channel,i), wrap(timestamp,i)) for i in range(lmax)]
+
+ def ctlout(self, ctlnum, value, channel=0, timestamp=0):
+ """
+ Send a control change message to the selected midi output device.
+
+ Arguments can be list of values to generate multiple events
+ in one call.
+
+ :Args:
+
+ ctlnum : int
+ Controller number, between 0 and 127.
+ value : int
+ Value of the controller, between 0 and 127.
+ channel : int, optional
+ The Midi channel, between 1 and 16, on which the
+ message is sent. A channel of 0 means all channels.
+ Defaults to 0.
+ timestamp : int, optional
+ The delay time, in milliseconds, before the message
+ is sent on the portmidi stream. A value of 0 means
+ to play the message now. Defaults to 0.
+ """
+ ctlnum, value, channel, timestamp, lmax = convertArgsToLists(ctlnum, value, channel, timestamp)
+ [self._server.ctlout(wrap(ctlnum,i), wrap(value,i), wrap(channel,i), wrap(timestamp,i)) for i in range(lmax)]
+ def programout(self, value, channel=0, timestamp=0):
"""
- self._server.sendMidiNote(pitch, velocity, channel, timestamp)
+ Send a program change message to the selected midi output device.
+
+ Arguments can be list of values to generate multiple events
+ in one call.
+
+ :Args:
+
+ value : int
+ New program number, between 0 and 127.
+ channel : int, optional
+ The Midi channel, between 1 and 16, on which the
+ message is sent. A channel of 0 means all channels.
+ Defaults to 0.
+ timestamp : int, optional
+ The delay time, in milliseconds, before the message
+ is sent on the portmidi stream. A value of 0 means
+ to play the message now. Defaults to 0.
+ """
+ value, channel, timestamp, lmax = convertArgsToLists(value, channel, timestamp)
+ [self._server.programout(wrap(value,i), wrap(channel,i), wrap(timestamp,i)) for i in range(lmax)]
+
+ def pressout(self, value, channel=0, timestamp=0):
+ """
+ Send a channel pressure message to the selected midi output device.
+
+ Arguments can be list of values to generate multiple events
+ in one call.
+
+ :Args:
+
+ value : int
+ Single greatest pressure value, between 0 and 127.
+ channel : int, optional
+ The Midi channel, between 1 and 16, on which the
+ message is sent. A channel of 0 means all channels.
+ Defaults to 0.
+ timestamp : int, optional
+ The delay time, in milliseconds, before the message
+ is sent on the portmidi stream. A value of 0 means
+ to play the message now. Defaults to 0.
+ """
+ value, channel, timestamp, lmax = convertArgsToLists(value, channel, timestamp)
+ [self._server.pressout(wrap(value,i), wrap(channel,i), wrap(timestamp,i)) for i in range(lmax)]
+
+ def bendout(self, value, channel=0, timestamp=0):
+ """
+ Send a pitch bend message to the selected midi output device.
+
+ Arguments can be list of values to generate multiple events
+ in one call.
+
+ :Args:
+
+ value : int
+ 14 bits pitch bend value. 8192 is where there is no
+ bending, 0 is full down and 16383 is full up bending.
+ channel : int, optional
+ The Midi channel, between 1 and 16, on which the
+ message is sent. A channel of 0 means all channels.
+ Defaults to 0.
+ timestamp : int, optional
+ The delay time, in milliseconds, before the message
+ is sent on the portmidi stream. A value of 0 means
+ to play the message now. Defaults to 0.
+ """
+ value, channel, timestamp, lmax = convertArgsToLists(value, channel, timestamp)
+ [self._server.bendout(wrap(value,i), wrap(channel,i), wrap(timestamp,i)) for i in range(lmax)]
def getStreams(self):
"""
Return the list of streams loaded in the server.
-
+
"""
return self._server.getStreams()
-
+
def getSamplingRate(self):
"""
Return the current sampling rate.
-
+
"""
return self._server.getSamplingRate()
-
+
def getNchnls(self):
"""
Return the current number of channels.
-
+
"""
return self._server.getNchnls()
-
+
def getBufferSize(self):
"""
Return the current buffer size.
-
+
"""
return self._server.getBufferSize()
@@ -599,97 +831,97 @@ class Server(object):
def getIsStarted(self):
"""
Returns 1 if the server is started, otherwise returns 0.
-
+
"""
return self._server.getIsStarted()
def getIsBooted(self):
"""
Returns 1 if the server is booted, otherwise returns 0.
-
+
"""
return self._server.getIsBooted()
def getMidiActive(self):
"""
Returns 1 if Midi callback is active, otherwise returns 0.
-
+
"""
return self._server.getMidiActive()
def getStreams(self):
"""
Returns the list of Stream objects currently in the Server memory.
-
+
"""
return self._server.getStreams()
def getNumberOfStreams(self):
"""
Returns the number of streams currently in the Server memory.
-
+
"""
return len(self._server.getStreams())
def setServer(self):
"""
Sets this server as the one to use for new objects when using the embedded device
-
+
"""
return self._server.setServer()
-
+
def getInputAddr(self):
"""
Return the address of the input buffer
-
+
"""
return self._server.getInputAddr()
-
+
def getOutputAddr(self):
"""
Return the address of the output buffer
-
+
"""
return self._server.getOutputAddr()
-
+
def getServerID(self):
"""
Return the server ID
-
+
"""
return self._server.getServerID()
-
+
def getServerAddr(self):
"""
Return the address of the server
-
+
"""
return self._server.getServerAddr()
-
+
def getEmbedICallbackAddr(self):
"""
Return the address of the interleaved embedded callback function
-
+
"""
return self._server.getEmbedICallbackAddr()
@property
def amp(self):
- """float. Overall amplitude."""
+ """float. Overall amplitude."""
return self._amp
@amp.setter
- def amp(self, x): self.setAmp(x)
+ def amp(self, x): self.setAmp(x)
@property
def startoffset(self):
- """float. Starting time of the real-time processing."""
+ """float. Starting time of the real-time processing."""
return self._startoffset
@startoffset.setter
- def startoffset(self, x): self.setStartOffset(x)
+ def startoffset(self, x): self.setStartOffset(x)
@property
def verbosity(self):
- """int. Server verbosity."""
+ """int. Server verbosity."""
return self._verbosity
@verbosity.setter
def verbosity(self, x):
@@ -700,11 +932,11 @@ class Server(object):
@property
def globalseed(self):
- """int. Server global seed."""
+ """int. Server global seed."""
return self._globalseed
@globalseed.setter
def globalseed(self, x):
if (type(x) == int):
self.setGlobalSeed(x)
else:
- raise Exception("global seed must be an integer")
+ raise Exception("global seed must be an integer")
\ No newline at end of file
diff --git a/pyolib/tableprocess.py b/pyolib/tableprocess.py
index 042d01e..88ba328 100644
--- a/pyolib/tableprocess.py
+++ b/pyolib/tableprocess.py
@@ -1,48 +1,48 @@
"""
Set of objects to perform operations on PyoTableObjects.
-PyoTableObjects are 1 dimension containers. They can be used to
+PyoTableObjects are 1 dimension containers. They can be used to
store audio samples or algorithmic sequences for future uses.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
from types import SliceType
-
+
class Osc(PyoObject):
"""
A simple oscillator reading a waveform table.
-
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
table : PyoTableObject
Table containing the waveform samples.
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
phase : float or PyoObject, optional
- Phase of sampling, expressed as a fraction of a cycle (0 to 1).
+ Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
interp : int, optional
Choice of the interpolation method. Defaults to 2.
@@ -51,17 +51,18 @@ class Osc(PyoObject):
3. cosinus
4. cubic
- .. seealso::
-
+ .. seealso::
+
:py:class:`Phasor`, :py:class:`Sine`
>>> s = Server().boot()
>>> s.start()
>>> t = HarmTable([1,0,.33,0,.2,0,.143,0,.111,0,.091])
>>> a = Osc(table=t, freq=[100,99.2], mul=.2).out()
-
+
"""
def __init__(self, table, freq=1000, phase=0, interp=2, mul=1, add=0):
+ pyoArgsAssert(self, "tOOiOO", table, freq, phase, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._freq = freq
@@ -73,13 +74,14 @@ class Osc(PyoObject):
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -87,13 +89,14 @@ class Osc(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -101,13 +104,14 @@ class Osc(PyoObject):
def setPhase(self, x):
"""
Replace the `phase` attribute.
-
+
:Args:
x : float or PyoObject
new `phase` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._phase = x
x, lmax = convertArgsToLists(x)
[obj.setPhase(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -115,13 +119,14 @@ class Osc(PyoObject):
def setInterp(self, x):
"""
Replace the `interp` attribute.
-
+
:Args:
x : int {1, 2, 3, 4}
new `interp` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -129,7 +134,7 @@ class Osc(PyoObject):
def reset(self):
"""
Resets current phase to 0.
-
+
"""
[obj.reset() for i, obj in enumerate(self._base_objs)]
@@ -142,27 +147,27 @@ class Osc(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the waveform samples."""
+ """PyoTableObject. Table containing the waveform samples."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
- def phase(self):
- """float or PyoObject. Phase of sampling."""
+ def phase(self):
+ """float or PyoObject. Phase of sampling."""
return self._phase
@phase.setter
def phase(self, x): self.setPhase(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
@@ -175,8 +180,8 @@ class OscLoop(PyoObject):
OscLoop reads a waveform table with linear interpolation and feedback control.
The oscillator output, multiplied by `feedback`, is added to the position
increment and can be used to control the brightness of the oscillator.
-
-
+
+
:Parent: :py:class:`PyoObject`
:Args:
@@ -186,21 +191,22 @@ class OscLoop(PyoObject):
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
feedback : float or PyoObject, optional
- Amount of the output signal added to position increment, between 0 and 1.
+ Amount of the output signal added to position increment, between 0 and 1.
Controls the brightness. Defaults to 0.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Osc`, :py:class:`SineLoop`
>>> s = Server().boot()
>>> s.start()
>>> t = HarmTable([1,0,.33,0,.2,0,.143])
>>> lfo = Sine(.5, 0, .05, .05)
- >>> a = OscLoop(table=t, freq=[100,99.3], feedback=lfo, mul=.2).out()
+ >>> a = OscLoop(table=t, freq=[100,99.3], feedback=lfo, mul=.2).out()
"""
def __init__(self, table, freq=1000, feedback=0, mul=1, add=0):
+ pyoArgsAssert(self, "tOOOO", table, freq, feedback, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._freq = freq
@@ -218,6 +224,7 @@ class OscLoop(PyoObject):
new `table` attribute.
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -232,6 +239,7 @@ class OscLoop(PyoObject):
new `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -246,6 +254,7 @@ class OscLoop(PyoObject):
new `feedback` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._feedback = x
x, lmax = convertArgsToLists(x)
[obj.setFeedback(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -258,21 +267,21 @@ class OscLoop(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the waveform samples."""
+ """PyoTableObject. Table containing the waveform samples."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
- def feedback(self):
- """float or PyoObject. Brightness control."""
+ def feedback(self):
+ """float or PyoObject. Brightness control."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
@@ -293,7 +302,7 @@ class OscTrig(PyoObject):
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
phase : float or PyoObject, optional
- Phase of sampling, expressed as a fraction of a cycle (0 to 1).
+ Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
interp : int, optional
Choice of the interpolation method. Defaults to 2.
@@ -302,8 +311,8 @@ class OscTrig(PyoObject):
3. cosinus
4. cubic
- .. seealso::
-
+ .. seealso::
+
:py:class:`Osc`, :py:class:`Phasor`, :py:class:`Sine`
>>> s = Server().boot()
@@ -315,6 +324,7 @@ class OscTrig(PyoObject):
"""
def __init__(self, table, trig, freq=1000, phase=0, interp=2, mul=1, add=0):
+ pyoArgsAssert(self, "toOOiOO", table, trig, freq, phase, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._trig = trig
@@ -334,6 +344,7 @@ class OscTrig(PyoObject):
new `table` attribute.
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -348,6 +359,7 @@ class OscTrig(PyoObject):
new `trig` attribute.
"""
+ pyoArgsAssert(self, "o", x)
self._trig = x
x, lmax = convertArgsToLists(x)
[obj.setTrig(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -362,6 +374,7 @@ class OscTrig(PyoObject):
new `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -376,6 +389,7 @@ class OscTrig(PyoObject):
new `phase` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._phase = x
x, lmax = convertArgsToLists(x)
[obj.setPhase(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -390,6 +404,7 @@ class OscTrig(PyoObject):
new `interp` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -410,34 +425,34 @@ class OscTrig(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the waveform samples."""
+ """PyoTableObject. Table containing the waveform samples."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def trig(self):
- """PyoObject. Trigger signal. Reset pointer position to zero"""
+ """PyoObject. Trigger signal. Reset pointer position to zero"""
return self._trig
@trig.setter
def trig(self, x): self.setTrig(x)
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
- def phase(self):
- """float or PyoObject. Phase of sampling."""
+ def phase(self):
+ """float or PyoObject. Phase of sampling."""
return self._phase
@phase.setter
def phase(self, x): self.setPhase(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
@@ -448,13 +463,13 @@ class OscBank(PyoObject):
Any number of oscillators reading a waveform table.
OscBank mixes the output of any number of oscillators. The frequencies
- of each oscillator is controlled with two parameters, the base frequency
- `freq` and a coefficient of expansion `spread`. Frequencies are computed
+ of each oscillator is controlled with two parameters, the base frequency
+ `freq` and a coefficient of expansion `spread`. Frequencies are computed
with the following formula (`n` is the order of the partial):
f_n = freq + freq * spread * n
- The frequencies and amplitudes can be modulated by two random generators
+ The frequencies and amplitudes can be modulated by two random generators
with interpolation (each partial have a different set of randoms).
:Parent: :py:class:`PyoObject`
@@ -466,29 +481,29 @@ class OscBank(PyoObject):
freq : float or PyoObject, optional
Base frequency in cycles per second. Defaults to 100.
spread : float or PyoObject, optional
- Coefficient of expansion used to compute partial frequencies.
- If `spread` is 0, all partials will be at the base frequency.
+ Coefficient of expansion used to compute partial frequencies.
+ If `spread` is 0, all partials will be at the base frequency.
A value of 1 will generate integer harmonics, a value of 2
will skip even harmonics and non-integer values will generate
different series of inharmonic frequencies. Defaults to 1.
slope : float or PyoObject, optional
- specifies the multiplier in the series of amplitude coefficients.
- This is a power series: the nth partial will have an amplitude of
+ specifies the multiplier in the series of amplitude coefficients.
+ This is a power series: the nth partial will have an amplitude of
(slope ** n), i.e. strength values trace an exponential curve.
Defaults to 1.
frndf : float or PyoObject, optional
- Frequency, in cycle per second, of the frequency modulations.
+ Frequency, in cycle per second, of the frequency modulations.
Defaults to 1.
frnda : float or PyoObject, optional
- Maximum frequency deviation (positive and negative) in portion of
+ Maximum frequency deviation (positive and negative) in portion of
the partial frequency. A value of 1 means that the frequency can
- drift from 0 Hz to twice the partial frequency. A value of 0
+ drift from 0 Hz to twice the partial frequency. A value of 0
deactivates the frequency deviations. Defaults to 0.
arndf : float or PyoObject, optional
- Frequency, in cycle per second, of the amplitude modulations.
+ Frequency, in cycle per second, of the amplitude modulations.
Defaults to 1.
arnda : float or PyoObject, optional
- Amount of amplitude deviation. 0 deactivates the amplitude
+ Amount of amplitude deviation. 0 deactivates the amplitude
modulations and 1 gives full amplitude modulations.
Defaults to 0.
num : int, optional
@@ -500,13 +515,13 @@ class OscBank(PyoObject):
periodicity between partial frequencies can cause very strange
artefact. Adding a jitter breaks the periodicity. Defaults to False.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Osc`
.. note::
- Altough parameters can be audio signals, values are sampled only once
+ Altough parameters can be audio signals, values are sampled only once
per buffer size. To avoid artefacts, it is recommended to keep variations
at low rate (< 20 Hz).
@@ -520,6 +535,7 @@ class OscBank(PyoObject):
"""
def __init__(self, table, freq=100, spread=1, slope=.9, frndf=1, frnda=0, arndf=1, arnda=0, num=24, fjit=False, mul=1, add=0):
+ pyoArgsAssert(self, "tOOOOOOOibOO", table, freq, spread, slope, frndf, frnda, arndf, arnda, num, fjit, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._freq = freq
@@ -544,6 +560,7 @@ class OscBank(PyoObject):
new `table` attribute.
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -558,6 +575,7 @@ class OscBank(PyoObject):
new `freq` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -572,6 +590,7 @@ class OscBank(PyoObject):
new `spread` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._spread = x
x, lmax = convertArgsToLists(x)
[obj.setSpread(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -586,6 +605,7 @@ class OscBank(PyoObject):
new `slope` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._slope = x
x, lmax = convertArgsToLists(x)
[obj.setSlope(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -600,6 +620,7 @@ class OscBank(PyoObject):
new `frndf` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._frndf = x
x, lmax = convertArgsToLists(x)
[obj.setFrndf(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -614,6 +635,7 @@ class OscBank(PyoObject):
new `frnda` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._frnda = x
x, lmax = convertArgsToLists(x)
[obj.setFrnda(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -628,6 +650,7 @@ class OscBank(PyoObject):
new `arndf` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._arndf = x
x, lmax = convertArgsToLists(x)
[obj.setArndf(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -642,6 +665,7 @@ class OscBank(PyoObject):
new `arnda` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._arnda = x
x, lmax = convertArgsToLists(x)
[obj.setArnda(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -656,6 +680,7 @@ class OscBank(PyoObject):
new `fjit` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._fjit = x
x, lmax = convertArgsToLists(x)
[obj.setFjit(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -673,63 +698,63 @@ class OscBank(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the waveform samples."""
+ """PyoTableObject. Table containing the waveform samples."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
- def spread(self):
- """float or PyoObject. Frequency expansion factor."""
+ def spread(self):
+ """float or PyoObject. Frequency expansion factor."""
return self._spread
@spread.setter
def spread(self, x): self.setSpread(x)
@property
- def slope(self):
- """float or PyoObject. Multiplier in the series of amplitudes."""
+ def slope(self):
+ """float or PyoObject. Multiplier in the series of amplitudes."""
return self._slope
@slope.setter
def slope(self, x): self.setSlope(x)
@property
- def frndf(self):
- """float or PyoObject. Frequency of the frequency modulations."""
+ def frndf(self):
+ """float or PyoObject. Frequency of the frequency modulations."""
return self._frndf
@frndf.setter
def frndf(self, x): self.setFrndf(x)
@property
- def frnda(self):
- """float or PyoObject. Maximum frequency deviation from 0 to 1."""
+ def frnda(self):
+ """float or PyoObject. Maximum frequency deviation from 0 to 1."""
return self._frnda
@frnda.setter
def frnda(self, x): self.setFrnda(x)
@property
- def arndf(self):
- """float or PyoObject. Frequency of the amplitude modulations."""
+ def arndf(self):
+ """float or PyoObject. Frequency of the amplitude modulations."""
return self._arndf
@arndf.setter
def arndf(self, x): self.setArndf(x)
@property
- def arnda(self):
- """float or PyoObject. Amount of amplitude deviation from 0 to 1."""
+ def arnda(self):
+ """float or PyoObject. Amount of amplitude deviation from 0 to 1."""
return self._arnda
@arnda.setter
def arnda(self, x): self.setArnda(x)
@property
- def fjit(self):
- """boolean. Jitter added to the parial frequencies."""
+ def fjit(self):
+ """boolean. Jitter added to the parial frequencies."""
return self._fjit
@fjit.setter
def fjit(self, x): self.setFjit(x)
@@ -740,7 +765,7 @@ class TableRead(PyoObject):
Read sampled sound from a table, with optional looping mode.
- The play() method starts the playback and is not called at the
+ The play() method starts the playback and is not called at the
object creation time.
:Parent: :py:class:`PyoObject`
@@ -752,7 +777,7 @@ class TableRead(PyoObject):
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 1.
loop : int {0, 1}, optional
- Looping mode, 0 means off, 1 means on.
+ Looping mode, 0 means off, 1 means on.
Defaults to 0.
interp : int, optional
Choice of the interpolation method. Defaults to 2.
@@ -763,25 +788,26 @@ class TableRead(PyoObject):
.. note::
- TableRead will sends a trigger signal at the end of the playback if
- loop is off or any time it wraps around if loop is on. User can
+ TableRead will sends a trigger signal at the end of the playback if
+ loop is off or any time it wraps around if loop is on. User can
retreive the trigger streams by calling obj['trig']:
>>> tabr = TableRead(SNDS_PATH + "/transparent.aif").out()
>>> trig = TrigRand(tab['trig'])
- .. seealso::
-
+ .. seealso::
+
:py:class:`Osc`
>>> s = Server().boot()
>>> s.start()
>>> snd = SndTable(SNDS_PATH + '/transparent.aif')
>>> freq = snd.getRate()
- >>> a = TableRead(table=snd, freq=[freq,freq*.99], loop=True, mul=.3).out()
+ >>> a = TableRead(table=snd, freq=[freq,freq*.99], loop=True, mul=.3).out()
"""
def __init__(self, table, freq=1, loop=0, interp=2, mul=1, add=0):
+ pyoArgsAssert(self, "tObiOO", table, freq, loop, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._freq = freq
@@ -794,13 +820,14 @@ class TableRead(PyoObject):
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -808,13 +835,14 @@ class TableRead(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -822,13 +850,14 @@ class TableRead(PyoObject):
def setLoop(self, x):
"""
Replace the `loop` attribute.
-
+
:Args:
x : int {0, 1}
new `loop` attribute.
-
+
"""
+ pyoArgsAssert(self, "b", x)
self._loop = x
x, lmax = convertArgsToLists(x)
[obj.setLoop(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -836,13 +865,14 @@ class TableRead(PyoObject):
def setInterp(self, x):
"""
Replace the `interp` attribute.
-
+
:Args:
x : int {1, 2, 3, 4}
new `interp` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -856,7 +886,7 @@ class TableRead(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(0.0001, 1000, 'log', 'freq', self._freq),
+ self._map_list = [SLMap(0.0001, 1000, 'log', 'freq', self._freq),
SLMap(0, 1, 'lin', 'loop', self._loop, res="int", dataOnly=True),
SLMap(1, 4, 'lin', 'interp', self._interp, res="int", dataOnly=True),
SLMapMul(self._mul)]
@@ -864,27 +894,27 @@ class TableRead(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the waveform samples."""
+ """PyoTableObject. Table containing the waveform samples."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
- def loop(self):
- """int. Looping mode."""
+ def loop(self):
+ """int. Looping mode."""
return self._loop
@loop.setter
def loop(self, x): self.setLoop(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
@@ -894,15 +924,15 @@ class Pulsar(PyoObject):
"""
Pulsar synthesis oscillator.
- Pulsar synthesis produces a train of sound particles called pulsars
- that can make rhythms or tones, depending on the fundamental frequency
+ Pulsar synthesis produces a train of sound particles called pulsars
+ that can make rhythms or tones, depending on the fundamental frequency
of the train. Varying the `frac` parameter changes the portion of the
- period assigned to the waveform and the portion of the period assigned
- to its following silence, but maintain the overall pulsar period. This
+ period assigned to the waveform and the portion of the period assigned
+ to its following silence, but maintain the overall pulsar period. This
results in an effect much like a sweeping band-pass filter.
:Parent: :py:class:`PyoObject`
-
+
:Args:
table : PyoTableObject
@@ -912,10 +942,10 @@ class Pulsar(PyoObject):
freq : float or PyoObject, optional
Frequency in cycles per second. Defaults to 100.
frac : float or PyoObject, optional
- Fraction of the whole period (0 -> 1) given to the waveform.
+ Fraction of the whole period (0 -> 1) given to the waveform.
The rest will be filled with zeros. Defaults to 0.5.
phase : float or PyoObject, optional
- Phase of sampling, expressed as a fraction of a cycle (0 to 1).
+ Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
interp : int, optional
Choice of the interpolation method. Defaults to 2.
@@ -924,8 +954,8 @@ class Pulsar(PyoObject):
3. cosinus
4. cubic
- .. seealso::
-
+ .. seealso::
+
:py:class:`Osc`
>>> s = Server().boot()
@@ -934,9 +964,10 @@ class Pulsar(PyoObject):
>>> e = HannTable()
>>> lfo = Sine([.1,.15], mul=.2, add=.5)
>>> a = Pulsar(table=w, env=e, freq=80, frac=lfo, mul=.08).out()
-
+
"""
def __init__(self, table, env, freq=100, frac=0.5, phase=0, interp=2, mul=1, add=0):
+ pyoArgsAssert(self, "ttOOOiOO", table, env, freq, frac, phase, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._env = env
@@ -950,13 +981,14 @@ class Pulsar(PyoObject):
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -964,13 +996,14 @@ class Pulsar(PyoObject):
def setEnv(self, x):
"""
Replace the `env` attribute.
-
+
:Args:
x : PyoTableObject
new `env` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._env = x
x, lmax = convertArgsToLists(x)
[obj.setEnv(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -978,13 +1011,14 @@ class Pulsar(PyoObject):
def setFreq(self, x):
"""
Replace the `freq` attribute.
-
+
:Args:
x : float or PyoObject
new `freq` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._freq = x
x, lmax = convertArgsToLists(x)
[obj.setFreq(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -992,13 +1026,14 @@ class Pulsar(PyoObject):
def setFrac(self, x):
"""
Replace the `frac` attribute.
-
+
:Args:
x : float or PyoObject
new `frac` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._frac = x
x, lmax = convertArgsToLists(x)
[obj.setFrac(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1006,13 +1041,14 @@ class Pulsar(PyoObject):
def setPhase(self, x):
"""
Replace the `phase` attribute.
-
+
:Args:
x : float or PyoObject
new `phase` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._phase = x
x, lmax = convertArgsToLists(x)
[obj.setPhase(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1020,7 +1056,7 @@ class Pulsar(PyoObject):
def setInterp(self, x):
"""
Replace the `interp` attribute.
-
+
:Args:
x : int {1, 2, 3, 4}
@@ -1029,8 +1065,9 @@ class Pulsar(PyoObject):
2. linear
3. cosinus
4. cubic
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1045,41 +1082,41 @@ class Pulsar(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the waveform samples."""
+ """PyoTableObject. Table containing the waveform samples."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def env(self):
- """PyoTableObject. Table containing the envelope samples."""
+ """PyoTableObject. Table containing the envelope samples."""
return self._env
@env.setter
def env(self, x): self.setEnv(x)
@property
def freq(self):
- """float or PyoObject. Frequency in cycles per second."""
+ """float or PyoObject. Frequency in cycles per second."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
def frac(self):
- """float or PyoObject. Fraction of the period assigned to waveform."""
+ """float or PyoObject. Fraction of the period assigned to waveform."""
return self._frac
@frac.setter
def frac(self, x): self.setFrac(x)
@property
- def phase(self):
- """float or PyoObject. Phase of sampling."""
+ def phase(self):
+ """float or PyoObject. Phase of sampling."""
return self._phase
@phase.setter
def phase(self, x): self.setPhase(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
@@ -1107,6 +1144,7 @@ class Pointer(PyoObject):
"""
def __init__(self, table, index, mul=1, add=0):
+ pyoArgsAssert(self, "toOO", table, index, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._index = index
@@ -1116,13 +1154,14 @@ class Pointer(PyoObject):
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1130,13 +1169,14 @@ class Pointer(PyoObject):
def setIndex(self, x):
"""
Replace the `index` attribute.
-
+
:Args:
x : PyoObject
new `index` attribute.
-
+
"""
+ pyoArgsAssert(self, "o", x)
self._index = x
x, lmax = convertArgsToLists(x)
[obj.setIndex(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1147,14 +1187,14 @@ class Pointer(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the waveform samples."""
+ """PyoTableObject. Table containing the waveform samples."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def index(self):
- """PyoObject. Index pointer position in the table."""
+ """PyoObject. Index pointer position in the table."""
return self._index
@index.setter
def index(self, x): self.setIndex(x)
@@ -1178,10 +1218,10 @@ class Pointer2(PyoObject):
3. cosinus
4. cubic
autosmooth : boolean, optional
- If True, a lowpass filter, following the pitch, is applied on
-
- the output signal to reduce the quantization noise produced
-
+ If True, a lowpass filter, following the pitch, is applied on
+
+ the output signal to reduce the quantization noise produced
+
by very low transpositions. Defaults to True.
>>> s = Server().boot()
@@ -1193,6 +1233,7 @@ class Pointer2(PyoObject):
"""
def __init__(self, table, index, interp=4, autosmooth=True, mul=1, add=0):
+ pyoArgsAssert(self, "toibOO", table, index, interp, autosmooth, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._index = index
@@ -1204,13 +1245,14 @@ class Pointer2(PyoObject):
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1218,13 +1260,14 @@ class Pointer2(PyoObject):
def setIndex(self, x):
"""
Replace the `index` attribute.
-
+
:Args:
x : PyoObject
new `index` attribute.
-
+
"""
+ pyoArgsAssert(self, "o", x)
self._index = x
x, lmax = convertArgsToLists(x)
[obj.setIndex(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1232,7 +1275,7 @@ class Pointer2(PyoObject):
def setInterp(self, x):
"""
Replace the `interp` attribute.
-
+
:Args:
x : int {1, 2, 3, 4}
@@ -1241,8 +1284,9 @@ class Pointer2(PyoObject):
2. linear interpolation
3. cosine interpolation
4. cubic interpolation (default)
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1250,17 +1294,18 @@ class Pointer2(PyoObject):
def setAutoSmooth(self, x):
"""
Replace the `autosmooth` attribute.
-
- If True, a lowpass filter, following the playback speed, is applied on
- the output signal to reduce the quantization noise produced by very
+
+ If True, a lowpass filter, following the playback speed, is applied on
+ the output signal to reduce the quantization noise produced by very
low transpositions.
-
+
:Args:
x : boolean
new `autosmooth` attribute.
-
+
"""
+ pyoArgsAssert(self, "b", x)
self._autosmooth = x
x, lmax = convertArgsToLists(x)
[obj.setAutoSmooth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1271,27 +1316,27 @@ class Pointer2(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the waveform samples."""
+ """PyoTableObject. Table containing the waveform samples."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def index(self):
- """PyoObject. Index pointer position in the table."""
+ """PyoObject. Index pointer position in the table."""
return self._index
@index.setter
def index(self, x): self.setIndex(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
def interp(self, x): self.setInterp(x)
@property
- def autosmooth(self):
+ def autosmooth(self):
"""boolean. Quantization noise filter."""
return self._autosmooth
@autosmooth.setter
@@ -1308,7 +1353,7 @@ class TableIndex(PyoObject):
table : PyoTableObject
Table containing the samples.
index : PyoObject
- Position in the table, as integer audio stream,
+ Position in the table, as integer audio stream,
between 0 and table's size - 1.
>>> s = Server().boot()
@@ -1322,6 +1367,7 @@ class TableIndex(PyoObject):
"""
def __init__(self, table, index, mul=1, add=0):
+ pyoArgsAssert(self, "toOO", table, index, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._index = index
@@ -1338,6 +1384,7 @@ class TableIndex(PyoObject):
new `table` attribute.
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1352,6 +1399,7 @@ class TableIndex(PyoObject):
new `index` attribute.
"""
+ pyoArgsAssert(self, "o", x)
self._index = x
x, lmax = convertArgsToLists(x)
[obj.setIndex(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1362,14 +1410,14 @@ class TableIndex(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the samples."""
+ """PyoTableObject. Table containing the samples."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def index(self):
- """PyoObject. Position in the table."""
+ """PyoObject. Position in the table."""
return self._index
@index.setter
def index(self, x): self.setIndex(x)
@@ -1377,22 +1425,22 @@ class TableIndex(PyoObject):
class Lookup(PyoObject):
"""
Uses table to do waveshaping on an audio signal.
-
+
Lookup uses a table to apply waveshaping on an input signal
`index`. The index must be between -1 and 1, it is automatically
scaled between 0 and len(table)-1 and is used as a position
- pointer in the table.
-
+ pointer in the table.
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
-
+
table : PyoTableObject
Table containing the transfert function.
index : PyoObject
Audio signal, between -1 and 1, internally converted to be
used as the index position in the table.
-
+
>>> s = Server().boot()
>>> s.start()
>>> lfo = Sine(freq=[.15,.2], mul=.2, add=.25)
@@ -1402,6 +1450,7 @@ class Lookup(PyoObject):
"""
def __init__(self, table, index, mul=1, add=0):
+ pyoArgsAssert(self, "toOO", table, index, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._index = index
@@ -1411,13 +1460,14 @@ class Lookup(PyoObject):
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1425,13 +1475,14 @@ class Lookup(PyoObject):
def setIndex(self, x):
"""
Replace the `index` attribute.
-
+
:Args:
x : PyoObject
new `index` attribute.
-
+
"""
+ pyoArgsAssert(self, "o", x)
self._index = x
x, lmax = convertArgsToLists(x)
[obj.setIndex(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1442,14 +1493,14 @@ class Lookup(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the transfert function."""
+ """PyoTableObject. Table containing the transfert function."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def index(self):
- """PyoObject. Audio input used as the table index."""
+ """PyoObject. Audio input used as the table index."""
return self._index
@index.setter
def index(self, x): self.setIndex(x)
@@ -1461,7 +1512,7 @@ class TableRec(PyoObject):
See `NewTable` to create an empty table.
The play method is not called at the object creation time. It starts
- the recording into the table until the table is full. Calling the
+ the recording into the table until the table is full. Calling the
play method again restarts the recording and overwrites previously
recorded samples. The stop method stops the recording. Otherwise, the
default behaviour is to record through the end of the table.
@@ -1475,7 +1526,7 @@ class TableRec(PyoObject):
table : NewTable
The table where to write samples.
fadetime : float, optional
- Fade time at the beginning and the end of the recording
+ Fade time at the beginning and the end of the recording
in seconds. Defaults to 0.
.. note::
@@ -1484,7 +1535,7 @@ class TableRec(PyoObject):
TableRec has no `mul` and `add` attributes.
- TableRec will sends a trigger signal at the end of the recording.
+ TableRec will sends a trigger signal at the end of the recording.
User can retrieve the trigger streams by calling obj['trig']. In
this example, the recorded table will be read automatically after
a recording:
@@ -1493,12 +1544,12 @@ class TableRec(PyoObject):
>>> t = NewTable(length=1, chnls=1)
>>> rec = TableRec(a, table=t, fadetime=0.01)
>>> tr = TrigEnv(rec['trig'], table=t, dur=1).out()
-
- obj['time'] outputs an audio stream of the current recording time,
+
+ obj['time'] outputs an audio stream of the current recording time,
in samples.
- .. seealso::
-
+ .. seealso::
+
:py:class:`NewTable`, :py:class:`TrigTableRec`
>>> s = Server(duplex=1).boot()
@@ -1514,6 +1565,7 @@ class TableRec(PyoObject):
"""
def __init__(self, input, table, fadetime=0):
+ pyoArgsAssert(self, "otn", input, table, fadetime)
PyoObject.__init__(self)
self._time_dummy = []
self._input = input
@@ -1535,14 +1587,122 @@ class TableRec(PyoObject):
def setMul(self, x):
pass
-
+
+ def setAdd(self, x):
+ pass
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Defaults to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ def setTable(self, x):
+ """
+ Replace the `table` attribute.
+
+ :Args:
+
+ x : NewTable
+ new `table` attribute.
+
+ """
+ pyoArgsAssert(self, "t", x)
+ self._table = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ @property
+ def input(self):
+ """PyoObject. Audio signal to write in the table."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+ @property
+ def table(self):
+ """NewTable. The table where to write samples."""
+ return self._table
+ @table.setter
+ def table(self, x): self.setTable(x)
+
+class TableWrite(PyoObject):
+ """
+ TableWrite writes samples into a previously created NewTable.
+
+ See `NewTable` to create an empty table.
+
+ TableWrite takes samples from its `input` stream and writes
+ them at a normalized position given by the `pos` stream.
+ Position must be an audio stream, ie. a PyoObject. This
+ object allows fast recording of values coming from an X-Y
+ pad into a table object.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Audio signal to write in the table.
+ pos : PyoObject
+ Audio signal specifying the normalized position (in the
+ range 0 to 1) where to write the `input` samples.
+ table : NewTable
+ The table where to write samples.
+
+ .. note::
+
+ The out() method is bypassed. TableWrite returns no signal.
+
+ TableWrite has no `mul` and `add` attributes.
+
+ .. seealso::
+
+ :py:class:`NewTable`, :py:class:`TableRec`
+
+ >>> s = Server(duplex=1).boot()
+ >>> s.start()
+ >>> tab = NewTable(8192/s.getSamplingRate())
+ >>> tab.view()
+ >>> pos = Phasor(.5)
+ >>> val = Sine(.25)
+ >>> rec = TableWrite(val, pos, tab)
+ >>> pat = Pattern(tab.refreshView, 0.05).play()
+
+ """
+ def __init__(self, input, pos, table):
+ pyoArgsAssert(self, "oot", input, pos, table)
+ PyoObject.__init__(self)
+ self._input = input
+ self._pos = pos
+ self._table = table
+ self._in_fader = InputFader(input)
+ in_fader, pos, table, lmax = convertArgsToLists(self._in_fader, pos, table)
+ self._base_objs = [TableWrite_base(wrap(in_fader,i), wrap(pos,i), wrap(table,i)) for i in range(len(table))]
+
+ def out(self, chnl=0, inc=1, dur=0, delay=0):
+ return self.play(dur, delay)
+
+ def setMul(self, x):
+ pass
+
def setAdd(self, x):
- pass
+ pass
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1551,26 +1711,43 @@ class TableRec(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : NewTable
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ def setPos(self, x):
+ """
+ Replace the `pos` attribute.
+
+ :Args:
+
+ x : PyoObject
+ new `pos` attribute.
+
+ """
+ pyoArgsAssert(self, "o", x)
+ self._pos = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setPos(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
@property
def input(self):
- """PyoObject. Audio signal to write in the table."""
+ """PyoObject. Audio signal to write in the table."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1582,13 +1759,20 @@ class TableRec(PyoObject):
@table.setter
def table(self, x): self.setTable(x)
+ @property
+ def pos(self):
+ """PyoObject. Normalized position, as audio stream, where to write samples."""
+ return self._pos
+ @pos.setter
+ def pos(self, x): self.setPos(x)
+
class TableMorph(PyoObject):
"""
Morphs between multiple PyoTableObjects.
- Uses an index into a list of PyoTableObjects to morph between adjacent
- tables in the list. The resulting morphed function is written into the
- `table` object at the beginning of each buffer size. The tables in the
+ Uses an index into a list of PyoTableObjects to morph between adjacent
+ tables in the list. The resulting morphed function is written into the
+ `table` object at the beginning of each buffer size. The tables in the
list and the resulting table must be equal in size.
:Parent: :py:class:`PyoObject`
@@ -1596,7 +1780,7 @@ class TableMorph(PyoObject):
:Args:
input : PyoObject
- Morphing index between 0 and 1. 0 is the first table in the list
+ Morphing index between 0 and 1. 0 is the first table in the list
and 1 is the last.
table : NewTable
The table where to write morphed waveform.
@@ -1620,6 +1804,7 @@ class TableMorph(PyoObject):
"""
def __init__(self, input, table, sources):
+ pyoArgsAssert(self, "otl", input, table, sources)
PyoObject.__init__(self)
self._input = input
self._table = table
@@ -1634,14 +1819,14 @@ class TableMorph(PyoObject):
def setMul(self, x):
pass
-
+
def setAdd(self, x):
- pass
+ pass
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1650,19 +1835,21 @@ class TableMorph(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : NewTable
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1670,20 +1857,21 @@ class TableMorph(PyoObject):
def setSources(self, x):
"""
Replace the `sources` attribute.
-
+
:Args:
x : list of PyoTableObject
new `sources` attribute.
-
+
"""
+ pyoArgsAssert(self, "l", x)
self._sources = x
self._base_sources = [source[0] for source in x]
[obj.setSources(self._base_sources) for i, obj in enumerate(self._base_objs)]
-
+
@property
def input(self):
- """PyoObject. Morphing index between 0 and 1."""
+ """PyoObject. Morphing index between 0 and 1."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1707,7 +1895,7 @@ class Granulator(PyoObject):
Granular synthesis generator.
:Parent: :py:class:`PyoObject`
-
+
:Args:
table : PyoTableObject
@@ -1715,25 +1903,25 @@ class Granulator(PyoObject):
env : PyoTableObject
Table containing the grain envelope.
pitch : float or PyoObject, optional
- Overall pitch of the granulator. This value transpose the
+ Overall pitch of the granulator. This value transpose the
pitch of all grains. Defaults to 1.
pos : float or PyoObject, optional
- Pointer position, in samples, in the waveform table. Each
- grain sampled the current value of this stream at the beginning
- of its envelope and hold it until the end of the grain.
+ Pointer position, in samples, in the waveform table. Each
+ grain sampled the current value of this stream at the beginning
+ of its envelope and hold it until the end of the grain.
Defaults to 0.
dur : float or PyoObject, optional
- Duration, in seconds, of the grain. Each grain sampled the
- current value of this stream at the beginning of its envelope
+ Duration, in seconds, of the grain. Each grain sampled the
+ current value of this stream at the beginning of its envelope
and hold it until the end of the grain. Defaults to 0.1.
grains : int, optional
Number of grains. Defaults to 8.
basedur : float, optional
- Base duration used to calculate the speed of the pointer to
- read the grain at its original pitch. By changing the value of
+ Base duration used to calculate the speed of the pointer to
+ read the grain at its original pitch. By changing the value of
the `dur` parameter, transposition per grain can be generated.
Defaults to 0.1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> snd = SndTable(SNDS_PATH + "/transparent.aif")
@@ -1744,6 +1932,7 @@ class Granulator(PyoObject):
"""
def __init__(self, table, env, pitch=1, pos=0, dur=.1, grains=8, basedur=.1, mul=1, add=0):
+ pyoArgsAssert(self, "ttOOOinOO", table, env, pitch, pos, dur, grains, basedur, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._env = env
@@ -1752,21 +1941,22 @@ class Granulator(PyoObject):
self._dur = dur
self._grains = grains
self._basedur = basedur
- table, env, pitch, pos, dur, grains, basedur, mul, add, lmax = convertArgsToLists(table, env, pitch,
+ table, env, pitch, pos, dur, grains, basedur, mul, add, lmax = convertArgsToLists(table, env, pitch,
pos, dur, grains, basedur, mul, add)
- self._base_objs = [Granulator_base(wrap(table,i), wrap(env,i), wrap(pitch,i), wrap(pos,i), wrap(dur,i),
+ self._base_objs = [Granulator_base(wrap(table,i), wrap(env,i), wrap(pitch,i), wrap(pos,i), wrap(dur,i),
wrap(grains,i), wrap(basedur,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1774,13 +1964,14 @@ class Granulator(PyoObject):
def setEnv(self, x):
"""
Replace the `env` attribute.
-
+
:Args:
x : PyoTableObject
new `env` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._env = x
x, lmax = convertArgsToLists(x)
[obj.setEnv(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1788,13 +1979,14 @@ class Granulator(PyoObject):
def setPitch(self, x):
"""
Replace the `pitch` attribute.
-
+
:Args:
x : float or PyoObject
new `pitch` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._pitch = x
x, lmax = convertArgsToLists(x)
[obj.setPitch(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1802,13 +1994,14 @@ class Granulator(PyoObject):
def setPos(self, x):
"""
Replace the `pos` attribute.
-
+
:Args:
x : float or PyoObject
new `pos` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._pos = x
x, lmax = convertArgsToLists(x)
[obj.setPos(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1816,13 +2009,14 @@ class Granulator(PyoObject):
def setDur(self, x):
"""
Replace the `dur` attribute.
-
+
:Args:
x : float or PyoObject
new `dur` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._dur = x
x, lmax = convertArgsToLists(x)
[obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1830,13 +2024,14 @@ class Granulator(PyoObject):
def setGrains(self, x):
"""
Replace the `grains` attribute.
-
+
:Args:
x : int
new `grains` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._grains = x
x, lmax = convertArgsToLists(x)
[obj.setGrains(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1844,13 +2039,14 @@ class Granulator(PyoObject):
def setBaseDur(self, x):
"""
Replace the `basedur` attribute.
-
+
:Args:
x : float
new `basedur` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._basedur = x
x, lmax = convertArgsToLists(x)
[obj.setBaseDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1932,7 +2128,7 @@ class TrigTableRec(PyoObject):
table : NewTable
The table where to write samples.
fadetime : float, optional
- Fade time at the beginning and the end of the recording
+ Fade time at the beginning and the end of the recording
in seconds. Defaults to 0.
.. note::
@@ -1941,14 +2137,14 @@ class TrigTableRec(PyoObject):
TrigTableRec has no `mul` and `add` attributes.
- TrigTableRec will sends a trigger signal at the end of the recording.
+ TrigTableRec will sends a trigger signal at the end of the recording.
User can retrieve the trigger streams by calling obj['trig'].
- obj['time'] outputs an audio stream of the current recording time,
+ obj['time'] outputs an audio stream of the current recording time,
in samples.
- .. seealso::
-
+ .. seealso::
+
:py:class:`NewTable`, :py:class:`TableRec`
>>> s = Server().boot()
@@ -1962,6 +2158,7 @@ class TrigTableRec(PyoObject):
"""
def __init__(self, input, trig, table, fadetime=0):
+ pyoArgsAssert(self, "ootn", input, trig, table, fadetime)
PyoObject.__init__(self)
self._time_dummy = []
self._input = input
@@ -1987,7 +2184,7 @@ class TrigTableRec(PyoObject):
pass
def setAdd(self, x):
- pass
+ pass
def setInput(self, x, fadetime=0.05):
"""
@@ -2001,6 +2198,7 @@ class TrigTableRec(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2016,6 +2214,7 @@ class TrigTableRec(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._trig = x
self._in_fader2.setInput(x, fadetime)
@@ -2029,20 +2228,21 @@ class TrigTableRec(PyoObject):
new `table` attribute.
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Audio signal to write in the table."""
+ """PyoObject. Audio signal to write in the table."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def trig(self):
- """PyoObject. Audio signal sending triggers."""
+ """PyoObject. Audio signal sending triggers."""
return self._trig
@trig.setter
def trig(self, x): self.setTrig(x)
@@ -2058,7 +2258,7 @@ class Looper(PyoObject):
"""
Crossfading looper.
- Looper reads audio from a PyoTableObject and plays it back in a loop with
+ Looper reads audio from a PyoTableObject and plays it back in a loop with
user-defined pitch, start time, duration and crossfade time. The `mode`
argument allows the user to choose different looping modes.
@@ -2069,25 +2269,25 @@ class Looper(PyoObject):
table : PyoTableObject
Table containing the waveform samples.
pitch : float or PyoObject, optional
- Transposition factor. 1 is normal pitch, 0.5 is one octave lower, 2 is
+ Transposition factor. 1 is normal pitch, 0.5 is one octave lower, 2 is
one octave higher. Negative values are not allowed. Defaults to 1.
start : float or PyoObject, optional
- Starting point, in seconds, of the loop, updated only once per loop cycle.
+ Starting point, in seconds, of the loop, updated only once per loop cycle.
Defaults to 0.
dur : float or PyoObject, optional
- Duration, in seconds, of the loop, updated only once per loop cycle.
+ Duration, in seconds, of the loop, updated only once per loop cycle.
Defaults to 1.
xfade : float or PyoObject {0 -> 50}, optional
- Percent of the loop time used to crossfade readers, updated only once per
+ Percent of the loop time used to crossfade readers, updated only once per
loop cycle and clipped between 0 and 50. Defaults to 20.
mode : int {0, 1, 2, 3}, optional
- Loop modes. Defaults to 1.
+ Loop modes. Defaults to 1.
0. no loop
- 1. forward
+ 1. forward
2. backward
3. back-and-forth
xfadeshape : int {0, 1, 2}, optional
- Crossfade envelope shape. Defaults to 0.
+ Crossfade envelope shape. Defaults to 0.
0. linear
1. equal power
2. sigmoid
@@ -2105,8 +2305,8 @@ class Looper(PyoObject):
to reduce the quantization noise produced by very low transpositions.
Defaults to False.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Granulator`, :py:class:`Pointer`
>>> s = Server().boot()
@@ -2119,6 +2319,7 @@ class Looper(PyoObject):
"""
def __init__(self, table, pitch=1, start=0, dur=1., xfade=20, mode=1, xfadeshape=0, startfromloop=False, interp=2, autosmooth=False, mul=1, add=0):
+ pyoArgsAssert(self, "tOOOOiibibOO", table, pitch, start, dur, xfade, mode, xfadeshape, startfromloop, interp, autosmooth, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._pitch = pitch
@@ -2132,7 +2333,7 @@ class Looper(PyoObject):
self._autosmooth = autosmooth
table, pitch, start, dur, xfade, mode, xfadeshape, startfromloop, interp, autosmooth, mul, add, lmax = convertArgsToLists(
table, pitch, start, dur, xfade, mode, xfadeshape, startfromloop, interp, autosmooth, mul, add)
- self._base_objs = [Looper_base(wrap(table,i), wrap(pitch,i), wrap(start,i), wrap(dur,i), wrap(xfade,i), wrap(mode,i),
+ self._base_objs = [Looper_base(wrap(table,i), wrap(pitch,i), wrap(start,i), wrap(dur,i), wrap(xfade,i), wrap(mode,i),
wrap(xfadeshape,i), wrap(startfromloop,i), wrap(interp,i), wrap(autosmooth,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setTable(self, x):
@@ -2145,6 +2346,7 @@ class Looper(PyoObject):
new `table` attribute.
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2159,6 +2361,7 @@ class Looper(PyoObject):
new `pitch` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._pitch = x
x, lmax = convertArgsToLists(x)
[obj.setPitch(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2173,6 +2376,7 @@ class Looper(PyoObject):
new `start` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._start = x
x, lmax = convertArgsToLists(x)
[obj.setStart(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2187,6 +2391,7 @@ class Looper(PyoObject):
new `dur` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._dur = x
x, lmax = convertArgsToLists(x)
[obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2201,6 +2406,7 @@ class Looper(PyoObject):
new `xfade` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._xfade = x
x, lmax = convertArgsToLists(x)
[obj.setXfade(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2215,6 +2421,7 @@ class Looper(PyoObject):
new `xfadeshape` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._xfadeshape = x
x, lmax = convertArgsToLists(x)
[obj.setXfadeShape(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2229,6 +2436,7 @@ class Looper(PyoObject):
new `startfromloop` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._startfromloop = x
x, lmax = convertArgsToLists(x)
[obj.setStartFromLoop(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2243,6 +2451,7 @@ class Looper(PyoObject):
new `mode` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._mode = x
x, lmax = convertArgsToLists(x)
[obj.setMode(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2257,6 +2466,7 @@ class Looper(PyoObject):
new `interp` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2271,14 +2481,24 @@ class Looper(PyoObject):
new `autosmooth` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._autosmooth = x
x, lmax = convertArgsToLists(x)
[obj.setAutoSmooth(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ def reset(self):
+ """
+ Resets internal reading pointers to 0.
+
+ """
+ [obj.reset() for obj in self._base_objs]
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.1, 2., 'lin', 'pitch', self._pitch),
SLMap(0., self._table.getDur(), 'lin', 'start', self._start),
SLMap(0.01, self._table.getDur(), 'lin', 'dur', self._dur),
+ SLMap(1, 50, 'lin', 'xfade', self._xfade),
+ SLMap(0, 3, 'lin', 'mode', self._mode, res="int", dataOnly=True),
SLMap(0, 2, 'lin', 'xfadeshape', self._xfadeshape, res="int", dataOnly=True),
SLMap(1, 4, 'lin', 'interp', self._interp, res="int", dataOnly=True),
SLMapMul(self._mul)]
@@ -2353,7 +2573,7 @@ class Looper(PyoObject):
return self._autosmooth
@autosmooth.setter
def autosmooth(self, x): self.setAutoSmooth(x)
-
+
class TablePut(PyoObject):
"""
Writes values, without repetitions, from an audio stream into a DataTable.
@@ -2365,7 +2585,7 @@ class TablePut(PyoObject):
repetitions.
The play method is not called at the object creation time. It starts
- the recording into the table until the table is full. Calling the
+ the recording into the table until the table is full. Calling the
play method again restarts the recording and overwrites previously
recorded values. The stop method stops the recording. Otherwise, the
default behaviour is to record through the end of the table.
@@ -2385,11 +2605,11 @@ class TablePut(PyoObject):
TablePut has no `mul` and `add` attributes.
- TablePut will sends a trigger signal at the end of the recording.
+ TablePut will sends a trigger signal at the end of the recording.
User can retrieve the trigger streams by calling obj['trig'].
- .. seealso::
-
+ .. seealso::
+
:py:class:`DataTable`, :py:class:`NewTable`, :py:class:`TableRec`
>>> s = Server().boot()
@@ -2404,6 +2624,7 @@ class TablePut(PyoObject):
"""
def __init__(self, input, table):
+ pyoArgsAssert(self, "ot", input, table)
PyoObject.__init__(self)
self._input = input
self._table = table
@@ -2417,14 +2638,14 @@ class TablePut(PyoObject):
def setMul(self, x):
pass
-
+
def setAdd(self, x):
- pass
+ pass
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -2433,26 +2654,28 @@ class TablePut(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : DataTable
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Audio signal to write in the table."""
+ """PyoObject. Audio signal to write in the table."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -2463,13 +2686,16 @@ class TablePut(PyoObject):
return self._table
@table.setter
def table(self, x): self.setTable(x)
-
+
class Granule(PyoObject):
"""
Another granular synthesis generator.
+ As of pyo 0.7.4, users can call the `setSync` method to change the
+ granulation mode (either synchronous or asynchronous) of the object.
+
:Parent: :py:class:`PyoObject`
-
+
:Args:
table : PyoTableObject
@@ -2482,15 +2708,15 @@ class Granule(PyoObject):
Pitch of the grains. A new grain gets the current value
of `pitch` as its reading speed. Defaults to 1.
pos : float or PyoObject, optional
- Pointer position, in samples, in the waveform table. Each
- grain sampled the current value of this stream at the beginning
- of its envelope and hold it until the end of the grain.
+ Pointer position, in samples, in the waveform table. Each
+ grain sampled the current value of this stream at the beginning
+ of its envelope and hold it until the end of the grain.
Defaults to 0.
dur : float or PyoObject, optional
- Duration, in seconds, of the grain. Each grain sampled the
- current value of this stream at the beginning of its envelope
+ Duration, in seconds, of the grain. Each grain sampled the
+ current value of this stream at the beginning of its envelope
and hold it until the end of the grain. Defaults to 0.1.
-
+
>>> s = Server().boot()
>>> s.start()
>>> snd = SndTable(SNDS_PATH+"/transparent.aif")
@@ -2503,6 +2729,7 @@ class Granule(PyoObject):
"""
def __init__(self, table, env, dens=50, pitch=1, pos=0, dur=.1, mul=1, add=0):
+ pyoArgsAssert(self, "ttOOOOOO", table, env, dens, pitch, pos, dur, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._env = env
@@ -2510,20 +2737,22 @@ class Granule(PyoObject):
self._pitch = pitch
self._pos = pos
self._dur = dur
+ self._sync = 1
table, env, dens, pitch, pos, dur, mul, add, lmax = convertArgsToLists(table, env, dens, pitch, pos, dur, mul, add)
- self._base_objs = [Granule_base(wrap(table,i), wrap(env,i), wrap(dens,i), wrap(pitch,i), wrap(pos,i), wrap(dur,i),
+ self._base_objs = [Granule_base(wrap(table,i), wrap(env,i), wrap(dens,i), wrap(pitch,i), wrap(pos,i), wrap(dur,i),
wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2531,13 +2760,14 @@ class Granule(PyoObject):
def setEnv(self, x):
"""
Replace the `env` attribute.
-
+
:Args:
x : PyoTableObject
new `env` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._env = x
x, lmax = convertArgsToLists(x)
[obj.setEnv(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2545,13 +2775,14 @@ class Granule(PyoObject):
def setDens(self, x):
"""
Replace the `dens` attribute.
-
+
:Args:
x : float or PyoObject
new `dens` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._dens = x
x, lmax = convertArgsToLists(x)
[obj.setDens(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2559,13 +2790,14 @@ class Granule(PyoObject):
def setPitch(self, x):
"""
Replace the `pitch` attribute.
-
+
:Args:
x : float or PyoObject
new `pitch` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._pitch = x
x, lmax = convertArgsToLists(x)
[obj.setPitch(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2573,13 +2805,14 @@ class Granule(PyoObject):
def setPos(self, x):
"""
Replace the `pos` attribute.
-
+
:Args:
x : float or PyoObject
new `pos` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._pos = x
x, lmax = convertArgsToLists(x)
[obj.setPos(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2587,17 +2820,34 @@ class Granule(PyoObject):
def setDur(self, x):
"""
Replace the `dur` attribute.
-
+
:Args:
x : float or PyoObject
new `dur` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._dur = x
x, lmax = convertArgsToLists(x)
[obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ def setSync(self, x):
+ """
+ Sets the granulation mode, synchronous or asynchronous.
+
+ :Args:
+
+ x : boolean
+ True means synchronous granulation (the default)
+ while False means asynchronous.
+
+ """
+ pyoArgsAssert(self, "b", x)
+ self._sync = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setSync(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(1, 250, 'lin', 'dens', self._dens),
SLMap(0.25, 2., 'lin', 'pitch', self._pitch),
@@ -2678,6 +2928,7 @@ class TableScale(PyoObject):
"""
def __init__(self, table, outtable, mul=1, add=0):
+ pyoArgsAssert(self, "ttOO", table, outtable, mul, add)
PyoObject.__init__(self, mul, add)
self._table = table
self._outtable = outtable
@@ -2687,13 +2938,14 @@ class TableScale(PyoObject):
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2701,13 +2953,14 @@ class TableScale(PyoObject):
def setOuttable(self, x):
"""
Replace the `outtable` attribute.
-
+
:Args:
x : PyoTableObject
new `outtable` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._outtable = x
x, lmax = convertArgsToLists(x)
[obj.setOuttable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2718,14 +2971,280 @@ class TableScale(PyoObject):
@property
def table(self):
- """PyoTableObject. Table containing the original values."""
+ """PyoTableObject. Table containing the original values."""
return self._table
@table.setter
def table(self, x): self.setTable(x)
@property
def outtable(self):
- """PyoTableObject. Scaled output table."""
+ """PyoTableObject. Scaled output table."""
return self._outtable
@outtable.setter
def outtable(self, x): self.setOuttable(x)
+
+class Particle(PyoObject):
+ """
+ A full control granular synthesis generator.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ table : PyoTableObject
+ Table containing the waveform samples.
+ env : PyoTableObject
+ Table containing the grain envelope.
+ dens : float or PyoObject, optional
+ Density of grains per second. Defaults to 50.
+ pitch : float or PyoObject, optional
+ Pitch of the grains. Each grain sampled the current value
+ of this stream at the beginning of its envelope and hold
+ it until the end of the grain. Defaults to 1.
+ pos : float or PyoObject, optional
+ Pointer position, in samples, in the waveform table. Each
+ grain sampled the current value of this stream at the beginning
+ of its envelope and hold it until the end of the grain.
+ Defaults to 0.
+ dur : float or PyoObject, optional
+ Duration, in seconds, of the grain. Each grain sampled the
+ current value of this stream at the beginning of its envelope
+ and hold it until the end of the grain. Defaults to 0.1.
+ dev : float or PyoObject, optional
+ Maximum deviation of the starting time of the grain, between 0 and
+ 1 (relative to the current duration of the grain). Each grain sampled
+ the current value of this stream at the beginning of its envelope
+ and hold it until the end of the grain. Defaults to 0.01.
+ pan : float or PyoObject, optional
+ Panning factor of the grain (if chnls=1, this value is skipped).
+ Each grain sampled the current value of this stream at the beginning
+ of its envelope and hold it until the end of the grain. Defaults to 0.5.
+ chnls : integer, optional
+ Number of output channels per audio stream (if chnls=2 and a stereo sound
+ table is given at the table argument, the objet will create 4 output
+ streams, 2 per table channel). Available at initialization only. Defaults to 1.
+
+ .. note::
+
+ Particle object compensate for the difference between sampling rate of the
+ loaded sound and the current sampling rate of the Server.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> snd = SndTable(SNDS_PATH+"/transparent.aif")
+ >>> end = snd.getSize() - s.getSamplingRate() * 0.25
+ >>> env = HannTable()
+ >>> dns = Randi(min=5, max=100, freq=.1)
+ >>> pit = Randh(min=0.99, max=1.01, freq=100)
+ >>> pos = Randi(min=0, max=1, freq=0.25, mul=end)
+ >>> dur = Randi(min=0.01, max=0.25, freq=0.15)
+ >>> dev = Randi(min=0, max=1, freq=0.2)
+ >>> pan = Noise(0.5, 0.5)
+ >>> grn = Particle(snd, env, dns, pit, pos, dur, dev, pan, chnls=2, mul=.2).out()
+
+ """
+ def __init__(self, table, env, dens=50, pitch=1, pos=0, dur=.1, dev=0.01, pan=0.5, chnls=1, mul=1, add=0):
+ pyoArgsAssert(self, "ttOOOOOOIOO", table, env, dens, pitch, pos, dur, dev, pan, chnls, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._table = table
+ self._env = env
+ self._dens = dens
+ self._pitch = pitch
+ self._pos = pos
+ self._dur = dur
+ self._dev = dev
+ self._pan = pan
+ self._chnls = chnls
+ table, env, dens, pitch, pos, dur, dev, pan, mul, add, lmax = convertArgsToLists(table, env, dens, pitch, pos, dur, dev, pan, mul, add)
+ self._base_players = [MainParticle_base(wrap(table,i), wrap(env,i), wrap(dens,i), wrap(pitch,i), wrap(pos,i), wrap(dur,i), wrap(dev,i), wrap(pan,i), chnls) for i in range(lmax)]
+ self._base_objs = []
+ for i in range(lmax):
+ for j in range(chnls):
+ self._base_objs.append(Particle_base(wrap(self._base_players,i), j, wrap(mul,i), wrap(add,i)))
+
+ def setTable(self, x):
+ """
+ Replace the `table` attribute.
+
+ :Args:
+
+ x : PyoTableObject
+ new `table` attribute.
+
+ """
+ pyoArgsAssert(self, "t", x)
+ self._table = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setEnv(self, x):
+ """
+ Replace the `env` attribute.
+
+ :Args:
+
+ x : PyoTableObject
+ new `env` attribute.
+
+ """
+ pyoArgsAssert(self, "t", x)
+ self._env = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setEnv(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setDens(self, x):
+ """
+ Replace the `dens` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ new `dens` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._dens = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setDens(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setPitch(self, x):
+ """
+ Replace the `pitch` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ new `pitch` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._pitch = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setPitch(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setPos(self, x):
+ """
+ Replace the `pos` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ new `pos` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._pos = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setPos(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setDur(self, x):
+ """
+ Replace the `dur` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ new `dur` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._dur = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setDev(self, x):
+ """
+ Replace the `dev` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ new `dev` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._dev = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setDev(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setPan(self, x):
+ """
+ Replace the `pan` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ new `pan` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._pan = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setPan(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ tablesize = self._table.getSize(False)
+ self._map_list = [SLMap(1, 250, 'lin', 'dens', self._dens),
+ SLMap(0.25, 2., 'lin', 'pitch', self._pitch),
+ SLMap(0, tablesize, 'lin', 'pos', self._pos),
+ SLMap(0.001, 1., 'lin', 'dur', self._dur),
+ SLMap(0., 1., 'lin', 'dev', self._dev),
+ SLMap(0., 1., 'lin', 'pan', self._pan),
+ SLMapMul(self._mul)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def table(self):
+ """PyoTableObject. Table containing the waveform samples."""
+ return self._table
+ @table.setter
+ def table(self, x): self.setTable(x)
+
+ @property
+ def env(self):
+ """PyoTableObject. Table containing the grain envelope."""
+ return self._env
+ @env.setter
+ def env(self, x): self.setEnv(x)
+
+ @property
+ def dens(self):
+ """float or PyoObject. Density of grains per second."""
+ return self._dens
+ @dens.setter
+ def dens(self, x): self.setDens(x)
+
+ @property
+ def pitch(self):
+ """float or PyoObject. Transposition factor of the grain."""
+ return self._pitch
+ @pitch.setter
+ def pitch(self, x): self.setPitch(x)
+
+ @property
+ def pos(self):
+ """float or PyoObject. Position of the pointer in the sound table."""
+ return self._pos
+ @pos.setter
+ def pos(self, x): self.setPos(x)
+
+ @property
+ def dur(self):
+ """float or PyoObject. Duration, in seconds, of the grain."""
+ return self._dur
+ @dur.setter
+ def dur(self, x): self.setDur(x)
+
+ @property
+ def dev(self):
+ """float or PyoObject. Deviation of the starting point of the grain in the table."""
+ return self._dev
+ @dev.setter
+ def dev(self, x): self.setDev(x)
+
+ @property
+ def pan(self):
+ """float or PyoObject.Panning of the grain."""
+ return self._pan
+ @pan.setter
+ def pan(self, x): self.setPan(x)
\ No newline at end of file
diff --git a/pyolib/tables.py b/pyolib/tables.py
index 4fc552a..aeed3c1 100644
--- a/pyolib/tables.py
+++ b/pyolib/tables.py
@@ -1,27 +1,28 @@
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
from _widgets import createGraphWindow, createDataGraphWindow, createSndViewTableWindow
from types import ListType
from math import pi
+import copy
######################################################################
### Tables
@@ -30,7 +31,7 @@ class HarmTable(PyoTableObject):
"""
Harmonic waveform generator.
- Generates composite waveforms made up of weighted sums
+ Generates composite waveforms made up of weighted sums
of simple sinusoids.
:Parent: :py:class:`PyoTableObject`
@@ -38,7 +39,7 @@ class HarmTable(PyoTableObject):
:Args:
list : list, optional
- Relative strengths of the fixed harmonic partial numbers 1,2,3, etc.
+ Relative strengths of the fixed harmonic partial numbers 1,2,3, etc.
Defaults to [1].
size : int, optional
Table size in samples. Defaults to 8192.
@@ -51,28 +52,30 @@ class HarmTable(PyoTableObject):
"""
def __init__(self, list=[1., 0.], size=8192):
+ pyoArgsAssert(self, "lI", list, size)
PyoTableObject.__init__(self, size)
- self._list = list
- self._base_objs = [HarmTable_base(list, size)]
-
+ self._list = copy.deepcopy(list)
+ self._base_objs = [HarmTable_base(self._list, size)]
+
def replace(self, list):
"""
- Redraw the waveform according to a new set of harmonics
+ Redraw the waveform according to a new set of harmonics
relative strengths.
-
+
:Args:
-
+
list : list
- Relative strengths of the fixed harmonic partial
+ Relative strengths of the fixed harmonic partial
numbers 1,2,3, etc.
- """
+ """
+ pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@property
- def list(self):
+ def list(self):
"""list. Relative strengths of the fixed harmonic partial numbers."""
return self._list
@list.setter
@@ -89,7 +92,7 @@ class SawTable(PyoTableObject):
:Args:
order : int, optional
- Number of harmonics sawtooth is made of.
+ Number of harmonics sawtooth is made of.
Defaults to 10.
size : int, optional
Table size in samples. Defaults to 8192.
@@ -101,28 +104,30 @@ class SawTable(PyoTableObject):
"""
def __init__(self, order=10, size=8192):
+ pyoArgsAssert(self, "II", order, size)
PyoTableObject.__init__(self, size)
self._order = order
list = [1./i for i in range(1,(order+1))]
self._base_objs = [HarmTable_base(list, size)]
-
+
def setOrder(self, x):
"""
Change the `order` attribute and redraw the waveform.
-
+
:Args:
-
+
x : int
New number of harmonics
- """
+ """
+ pyoArgsAssert(self, "I", x)
self._order = x
list = [1./i for i in range(1,(self._order+1))]
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@property
- def order(self):
+ def order(self):
"""int. Number of harmonics sawtooth is made of."""
return self._order
@order.setter
@@ -139,7 +144,7 @@ class SquareTable(PyoTableObject):
:Args:
order : int, optional
- Number of harmonics square waveform is made of. The waveform will
+ Number of harmonics square waveform is made of. The waveform will
contains `order` odd harmonics. Defaults to 10.
size : int, optional
Table size in samples. Defaults to 8192.
@@ -151,6 +156,7 @@ class SquareTable(PyoTableObject):
"""
def __init__(self, order=10, size=8192):
+ pyoArgsAssert(self, "II", order, size)
PyoTableObject.__init__(self, size)
self._order = order
list = []
@@ -158,31 +164,32 @@ class SquareTable(PyoTableObject):
if i%2 == 1:
list.append(1./i)
else:
- list.append(0.)
+ list.append(0.)
self._base_objs = [HarmTable_base(list, size)]
-
+
def setOrder(self, x):
"""
Change the `order` attribute and redraw the waveform.
-
+
:Args:
-
+
x : int
New number of harmonics
- """
+ """
+ pyoArgsAssert(self, "I", x)
self._order = x
list = []
for i in range(1,(self._order*2)):
if i%2 == 1:
list.append(1./i)
else:
- list.append(0.)
+ list.append(0.)
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@property
- def order(self):
+ def order(self):
"""int. Number of harmonics square waveform is made of."""
return self._order
@order.setter
@@ -192,17 +199,17 @@ class ChebyTable(PyoTableObject):
"""
Chebyshev polynomials of the first kind.
- Uses Chebyshev coefficients to generate stored polynomial functions
- which, under waveshaping, can be used to split a sinusoid into
- harmonic partials having a pre-definable spectrum.
+ Uses Chebyshev coefficients to generate stored polynomial functions
+ which, under waveshaping, can be used to split a sinusoid into
+ harmonic partials having a pre-definable spectrum.
:Parent: :py:class:`PyoTableObject`
:Args:
list : list, optional
- Relative strengths of partials numbers 1,2,3, ..., 12 that will
- result when a sinusoid of amplitude 1 is waveshaped using this
+ Relative strengths of partials numbers 1,2,3, ..., 12 that will
+ result when a sinusoid of amplitude 1 is waveshaped using this
function table. Up to 12 partials can be specified. Defaults to [1].
size : int, optional
Table size in samples. Defaults to 8192.
@@ -216,32 +223,34 @@ class ChebyTable(PyoTableObject):
"""
def __init__(self, list=[1., 0.], size=8192):
+ pyoArgsAssert(self, "lI", list, size)
PyoTableObject.__init__(self, size)
- self._list = list
- self._base_objs = [ChebyTable_base(list, size)]
-
+ self._list = copy.deepcopy(list)
+ self._base_objs = [ChebyTable_base(self._list, size)]
+
def replace(self, list):
"""
- Redraw the waveform according to a new set of harmonics
- relative strengths that will result when a sinusoid of
+ Redraw the waveform according to a new set of harmonics
+ relative strengths that will result when a sinusoid of
amplitude 1 is waveshaped using this function table.
-
+
:Args:
-
+
list : list
- Relative strengths of the fixed harmonic partial
+ Relative strengths of the fixed harmonic partial
numbers 1,2,3, ..., 12. Up to 12 partials can be specified.
- """
+ """
+ pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
def getNormTable(self):
"""
- Return a DataTable filled with the normalization function
+ Return a DataTable filled with the normalization function
corresponding to the current polynomial.
-
+
"""
if sum(self._list[1::2]) == 0:
data = self._base_objs[0].getNormTable(0)
@@ -250,15 +259,15 @@ class ChebyTable(PyoTableObject):
return DataTable(size=len(data), init=data).normalize()
@property
- def list(self):
+ def list(self):
"""list. Relative strengths of the fixed harmonic partial numbers."""
return self._list
@list.setter
def list(self, x): self.replace(x)
-
+
class HannTable(PyoTableObject):
"""
- Generates Hanning window function.
+ Generates Hanning window function.
:Parent: :py:class:`PyoTableObject`
@@ -276,12 +285,13 @@ class HannTable(PyoTableObject):
"""
def __init__(self, size=8192):
+ pyoArgsAssert(self, "I", size)
PyoTableObject.__init__(self, size)
self._base_objs = [HannTable_base(size)]
class SincTable(PyoTableObject):
"""
- Generates sinc window function.
+ Generates sinc window function.
:Parent: :py:class:`PyoTableObject`
@@ -302,6 +312,7 @@ class SincTable(PyoTableObject):
"""
def __init__(self, freq=pi*2, windowed=False, size=8192):
+ pyoArgsAssert(self, "NBI", freq, windowed, size)
PyoTableObject.__init__(self, size)
self._freq = freq
self._windowed = windowed
@@ -317,6 +328,7 @@ class SincTable(PyoTableObject):
New frequency in radians.
"""
+ pyoArgsAssert(self, "N", x)
self._freq = x
[obj.setFreq(x) for obj in self._base_objs]
self.refreshView()
@@ -331,18 +343,19 @@ class SincTable(PyoTableObject):
New windowed flag.
"""
+ pyoArgsAssert(self, "B", x)
self._windowed = x
[obj.setWindowed(x) for obj in self._base_objs]
self.refreshView()
@property
- def freq(self):
+ def freq(self):
"""float. Frequency of the sinc function."""
return self._freq
@freq.setter
def freq(self, x): self.setFreq(x)
@property
- def windowed(self):
+ def windowed(self):
"""boolean. Windowed flag."""
return self._windowed
@windowed.setter
@@ -350,7 +363,7 @@ class SincTable(PyoTableObject):
class WinTable(PyoTableObject):
"""
- Generates different kind of windowing functions.
+ Generates different kind of windowing functions.
:Parent: :py:class:`PyoTableObject`
@@ -379,6 +392,7 @@ class WinTable(PyoTableObject):
"""
def __init__(self, type=2, size=8192):
+ pyoArgsAssert(self, "II", type, size)
PyoTableObject.__init__(self, size)
self._type = type
self._base_objs = [WinTable_base(type, size)]
@@ -393,12 +407,13 @@ class WinTable(PyoTableObject):
Windowing function.
"""
+ pyoArgsAssert(self, "I", type)
self._type = type
[obj.setType(type) for obj in self._base_objs]
self.refreshView()
@property
- def type(self):
+ def type(self):
"""int. Windowing function."""
return self._type
@type.setter
@@ -406,9 +421,9 @@ class WinTable(PyoTableObject):
class ParaTable(PyoTableObject):
"""
- Generates parabola window function.
+ Generates parabola window function.
- The parabola is a conic section, the intersection of a right circular conical
+ The parabola is a conic section, the intersection of a right circular conical
surface and a plane parallel to a generating straight line of that surface.
:Parent: :py:class:`PyoTableObject`
@@ -427,6 +442,7 @@ class ParaTable(PyoTableObject):
"""
def __init__(self, size=8192):
+ pyoArgsAssert(self, "I", size)
PyoTableObject.__init__(self, size)
self._base_objs = [ParaTable_base(size)]
@@ -439,17 +455,17 @@ class LinTable(PyoTableObject):
:Args:
list : list, optional
- List of tuples indicating location and value of each points
- in the table. The default, [(0,0.), (8191, 1.)], creates a
- straight line from 0.0 at location 0 to 1.0 at the end of the
+ List of tuples indicating location and value of each points
+ in the table. The default, [(0,0.), (8191, 1.)], creates a
+ straight line from 0.0 at location 0 to 1.0 at the end of the
table (size - 1). Location must be an integer.
size : int, optional
Table size in samples. Defaults to 8192.
.. note::
- Locations in the list must be in increasing order. If the last value
- is less than size, the rest of the table will be filled with zeros.
+ Locations in the list must be in increasing order. If the last value
+ is less than size, the rest of the table will be filled with zeros.
>>> s = Server().boot()
>>> s.start()
@@ -460,25 +476,27 @@ class LinTable(PyoTableObject):
"""
def __init__(self, list=[(0, 0.), (8191, 1.)], size=8192):
+ pyoArgsAssert(self, "lI", list, size)
PyoTableObject.__init__(self, size)
if size < list[-1][0]:
print "LinTable warning : size smaller than last point position."
print " Increased size to last point position + 1"
size = list[-1][0] + 1
self._size = size
- self._base_objs = [LinTable_base(list, size)]
-
+ self._base_objs = [LinTable_base(copy.deepcopy(list), size)]
+
def replace(self, list):
"""
Draw a new envelope according to the new `list` parameter.
-
+
:Args:
-
+
list : list
- List of tuples indicating location and value of each points
+ List of tuples indicating location and value of each points
in the table. Location must be integer.
- """
+ """
+ pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@@ -486,14 +504,14 @@ class LinTable(PyoTableObject):
def loadRecFile(self, filename, tolerance=0.02):
"""
Import an automation recording file in the table.
-
+
loadRecFile takes a recording file, usually from a ControlRec object,
as `filename` parameter, applies a filtering pre-processing to eliminate
- redundancies and loads the result in the table as a list of points.
- Filtering process can be controled with the `tolerance` parameter.
-
+ redundancies and loads the result in the table as a list of points.
+ Filtering process can be controled with the `tolerance` parameter.
+
:Args:
-
+
filename : string
Full path of an automation recording file.
tolerance : float, optional
@@ -501,6 +519,7 @@ class LinTable(PyoTableObject):
Defaults to 0.02.
"""
+ pyoArgsAssert(self, "SN", filename, tolerance)
_path, _name = os.path.split(filename)
# files = sorted([f for f in os.listdir(_path) if _name+"_" in f])
# if _name not in files: files.append(_name)
@@ -529,9 +548,9 @@ class LinTable(PyoTableObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
-
- Ctrl+C with focus on the grapher will copy the list of points to the
+ will be send to the object on mouse up.
+
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -540,21 +559,21 @@ class LinTable(PyoTableObject):
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
createGraphWindow(self, 0, self._size, yrange, title, wxnoserver)
@property
def list(self):
- """list. List of tuples indicating location and value of each points in the table."""
+ """list. List of tuples indicating location and value of each points in the table."""
return self.getPoints()
@list.setter
def list(self, x): self.replace(x)
@@ -568,18 +587,18 @@ class LogTable(PyoTableObject):
:Args:
list : list, optional
- List of tuples indicating location and value of each points
- in the table. The default, [(0,0.), (8191, 1.)], creates a
- logarithmic line from 0.0 at location 0 to 1.0 at the end of
+ List of tuples indicating location and value of each points
+ in the table. The default, [(0,0.), (8191, 1.)], creates a
+ logarithmic line from 0.0 at location 0 to 1.0 at the end of
the table (size - 1). Location must be an integer.
size : int, optional
Table size in samples. Defaults to 8192.
.. note::
- Locations in the list must be in increasing order. If the last value
- is less than size, the rest of the table will be filled with zeros.
-
+ Locations in the list must be in increasing order. If the last value
+ is less than size, the rest of the table will be filled with zeros.
+
Values must be greater than 0.0.
>>> s = Server().boot()
@@ -590,13 +609,14 @@ class LogTable(PyoTableObject):
"""
def __init__(self, list=[(0, 0.), (8191, 1.)], size=8192):
+ pyoArgsAssert(self, "lI", list, size)
PyoTableObject.__init__(self, size)
if size < list[-1][0]:
print "LogTable warning : size smaller than last point position."
print " Increased size to last point position + 1"
size = list[-1][0] + 1
self._size = size
- self._base_objs = [LogTable_base(list, size)]
+ self._base_objs = [LogTable_base(copy.deepcopy(list), size)]
def replace(self, list):
"""
@@ -605,10 +625,11 @@ class LogTable(PyoTableObject):
:Args:
list : list
- List of tuples indicating location and value of each points
+ List of tuples indicating location and value of each points
in the table. Location must be integer.
- """
+ """
+ pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@@ -619,8 +640,8 @@ class LogTable(PyoTableObject):
loadRecFile takes a recording file, usually from a ControlRec object,
as `filename` parameter, applies a filtering pre-processing to eliminate
- redundancies and loads the result in the table as a list of points.
- Filtering process can be controled with the `tolerance` parameter.
+ redundancies and loads the result in the table as a list of points.
+ Filtering process can be controled with the `tolerance` parameter.
:Args:
@@ -631,6 +652,7 @@ class LogTable(PyoTableObject):
Defaults to 0.02.
"""
+ pyoArgsAssert(self, "SN", filename, tolerance)
_path, _name = os.path.split(filename)
# files = sorted([f for f in os.listdir(_path) if _name+"_" in f])
# if _name not in files: files.append(_name)
@@ -659,9 +681,9 @@ class LogTable(PyoTableObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
+ will be send to the object on mouse up.
- Ctrl+C with focus on the grapher will copy the list of points to the
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -670,21 +692,21 @@ class LogTable(PyoTableObject):
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
createGraphWindow(self, 4, self._size, yrange, title, wxnoserver)
@property
def list(self):
- """list. List of tuples indicating location and value of each points in the table."""
+ """list. List of tuples indicating location and value of each points in the table."""
return self.getPoints()
@list.setter
def list(self, x): self.replace(x)
@@ -698,17 +720,17 @@ class CosLogTable(PyoTableObject):
:Args:
list : list, optional
- List of tuples indicating location and value of each points
- in the table. The default, [(0,0.), (8191, 1.)], creates a
- logarithmic line from 0.0 at location 0 to 1.0 at the end of
+ List of tuples indicating location and value of each points
+ in the table. The default, [(0,0.), (8191, 1.)], creates a
+ logarithmic line from 0.0 at location 0 to 1.0 at the end of
the table (size - 1). Location must be an integer.
size : int, optional
Table size in samples. Defaults to 8192.
.. note::
- Locations in the list must be in increasing order. If the last value
- is less than size, the rest of the table will be filled with zeros.
+ Locations in the list must be in increasing order. If the last value
+ is less than size, the rest of the table will be filled with zeros.
Values must be greater than 0.0.
@@ -720,13 +742,14 @@ class CosLogTable(PyoTableObject):
"""
def __init__(self, list=[(0, 0.), (8191, 1.)], size=8192):
+ pyoArgsAssert(self, "lI", list, size)
PyoTableObject.__init__(self, size)
if size < list[-1][0]:
print "CosLogTable warning : size smaller than last point position."
print " Increased size to last point position + 1"
size = list[-1][0] + 1
self._size = size
- self._base_objs = [CosLogTable_base(list, size)]
+ self._base_objs = [CosLogTable_base(copy.deepcopy(list), size)]
def replace(self, list):
"""
@@ -735,10 +758,11 @@ class CosLogTable(PyoTableObject):
:Args:
list : list
- List of tuples indicating location and value of each points
+ List of tuples indicating location and value of each points
in the table. Location must be integer.
- """
+ """
+ pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@@ -749,8 +773,8 @@ class CosLogTable(PyoTableObject):
loadRecFile takes a recording file, usually from a ControlRec object,
as `filename` parameter, applies a filtering pre-processing to eliminate
- redundancies and loads the result in the table as a list of points.
- Filtering process can be controled with the `tolerance` parameter.
+ redundancies and loads the result in the table as a list of points.
+ Filtering process can be controled with the `tolerance` parameter.
:Args:
@@ -761,6 +785,7 @@ class CosLogTable(PyoTableObject):
Defaults to 0.02.
"""
+ pyoArgsAssert(self, "SN", filename, tolerance)
_path, _name = os.path.split(filename)
# files = sorted([f for f in os.listdir(_path) if _name+"_" in f])
# if _name not in files: files.append(_name)
@@ -789,9 +814,9 @@ class CosLogTable(PyoTableObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
+ will be send to the object on mouse up.
- Ctrl+C with focus on the grapher will copy the list of points to the
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -800,21 +825,21 @@ class CosLogTable(PyoTableObject):
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
createGraphWindow(self, 5, self._size, yrange, title, wxnoserver)
@property
def list(self):
- """list. List of tuples indicating location and value of each points in the table."""
+ """list. List of tuples indicating location and value of each points in the table."""
return self.getPoints()
@list.setter
def list(self, x): self.replace(x)
@@ -828,17 +853,17 @@ class CosTable(PyoTableObject):
:Args:
list : list, optional
- List of tuples indicating location and value of each points
- in the table. The default, [(0,0.), (8191, 1.)], creates a
- cosine line from 0.0 at location 0 to 1.0 at the end of the
+ List of tuples indicating location and value of each points
+ in the table. The default, [(0,0.), (8191, 1.)], creates a
+ cosine line from 0.0 at location 0 to 1.0 at the end of the
table (size - 1). Location must be an integer.
size : int, optional
Table size in samples. Defaults to 8192.
.. note::
- Locations in the list must be in increasing order. If the last value
- is less than size, the rest of the table will be filled with zeros.
+ Locations in the list must be in increasing order. If the last value
+ is less than size, the rest of the table will be filled with zeros.
>>> s = Server().boot()
>>> s.start()
@@ -849,25 +874,27 @@ class CosTable(PyoTableObject):
"""
def __init__(self, list=[(0, 0.), (8191, 1.)], size=8192):
+ pyoArgsAssert(self, "lI", list, size)
PyoTableObject.__init__(self, size)
if size < list[-1][0]:
print "CosTable warning : size smaller than last point position."
print " Increased size to last point position + 1"
size = list[-1][0] + 1
self._size = size
- self._base_objs = [CosTable_base(list, size)]
-
+ self._base_objs = [CosTable_base(copy.deepcopy(list), size)]
+
def replace(self, list):
"""
Draw a new envelope according to the new `list` parameter.
-
+
:Args:
-
+
list : list
- List of tuples indicating location and value of each points
+ List of tuples indicating location and value of each points
in the table. Location must be integer.
- """
+ """
+ pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@@ -878,8 +905,8 @@ class CosTable(PyoTableObject):
loadRecFile takes a recording file, usually from a ControlRec object,
as `filename` parameter, applies a filtering pre-processing to eliminate
- redundancies and loads the result in the table as a list of points.
- Filtering process can be controled with the `tolerance` parameter.
+ redundancies and loads the result in the table as a list of points.
+ Filtering process can be controled with the `tolerance` parameter.
:Args:
@@ -890,6 +917,7 @@ class CosTable(PyoTableObject):
Defaults to 0.02.
"""
+ pyoArgsAssert(self, "SN", filename, tolerance)
_path, _name = os.path.split(filename)
# files = sorted([f for f in os.listdir(_path) if _name+"_" in f])
# if _name not in files: files.append(_name)
@@ -918,9 +946,9 @@ class CosTable(PyoTableObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
+ will be send to the object on mouse up.
- Ctrl+C with focus on the grapher will copy the list of points to the
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -929,21 +957,21 @@ class CosTable(PyoTableObject):
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
createGraphWindow(self, 1, self._size, yrange, title, wxnoserver)
@property
def list(self):
- """list. List of tuples indicating location and value of each points in the table."""
+ """list. List of tuples indicating location and value of each points in the table."""
return self.getPoints()
@list.setter
def list(self, x): self.replace(x)
@@ -954,8 +982,8 @@ class CurveTable(PyoTableObject):
CurveTable uses Hermite interpolation (sort of cubic interpolation)
to calculate each points of the curve. This algorithm allows tension
- and biasing controls. Tension can be used to tighten up the curvature
- at the known points. The bias is used to twist the curve about the
+ and biasing controls. Tension can be used to tighten up the curvature
+ at the known points. The bias is used to twist the curve about the
known points.
:Parent: :py:class:`PyoTableObject`
@@ -963,23 +991,23 @@ class CurveTable(PyoTableObject):
:Args:
list : list, optional
- List of tuples indicating location and value of each points
- in the table. The default, [(0,0.), (8191, 1.)], creates a
- curved line from 0.0 at location 0 to 1.0 at the end of the
+ List of tuples indicating location and value of each points
+ in the table. The default, [(0,0.), (8191, 1.)], creates a
+ curved line from 0.0 at location 0 to 1.0 at the end of the
table (size - 1). Location must be an integer.
tension : float, optional
Curvature at the known points. 1 is high, 0 normal, -1 is low.
Defaults to 0.
bias : float, optional
Curve attraction (for each segments) toward bundary points.
- 0 is even, positive is towards first point, negative is towards
+ 0 is even, positive is towards first point, negative is towards
the second point. Defaults to 0.
size : int, optional
Table size in samples. Defaults to 8192.
.. note::
- Locations in the list must be in increasing order. If the last value
+ Locations in the list must be in increasing order. If the last value
is less than size, the rest of the table will be filled with zeros.
High tension or bias values can create unstable or very loud table,
@@ -994,6 +1022,7 @@ class CurveTable(PyoTableObject):
"""
def __init__(self, list=[(0, 0.), (8191, 1.)], tension=0, bias=0, size=8192):
+ pyoArgsAssert(self, "lNNI", list, tension, bias, size)
PyoTableObject.__init__(self, size)
if size < list[-1][0]:
print "CurveTable warning : size smaller than last point position."
@@ -1002,20 +1031,21 @@ class CurveTable(PyoTableObject):
self._size = size
self._tension = tension
self._bias = bias
- self._base_objs = [CurveTable_base(list, tension, bias, size)]
+ self._base_objs = [CurveTable_base(copy.deepcopy(list), tension, bias, size)]
def setTension(self, x):
"""
Replace the `tension` attribute.
-
+
1 is high, 0 normal, -1 is low.
-
+
:Args:
-
+
x : float
New `tension` attribute.
-
+
"""
+ pyoArgsAssert(self, "N", x)
self._tension = x
[obj.setTension(x) for obj in self._base_objs]
self.refreshView()
@@ -1023,31 +1053,33 @@ class CurveTable(PyoTableObject):
def setBias(self, x):
"""
Replace the `bias` attribute.
-
- 0 is even, positive is towards first point, negative is towards
+
+ 0 is even, positive is towards first point, negative is towards
the second point.
-
+
:Args:
-
+
x : float
New `bias` attribute.
-
+
"""
+ pyoArgsAssert(self, "N", x)
self._bias = x
[obj.setBias(x) for obj in self._base_objs]
self.refreshView()
-
+
def replace(self, list):
"""
Draw a new envelope according to the new `list` parameter.
-
+
:Args:
-
+
list : list
- List of tuples indicating location and value of each points
+ List of tuples indicating location and value of each points
in the table. Location must be integer.
- """
+ """
+ pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@@ -1058,8 +1090,8 @@ class CurveTable(PyoTableObject):
loadRecFile takes a recording file, usually from a ControlRec object,
as `filename` parameter, applies a filtering pre-processing to eliminate
- redundancies and loads the result in the table as a list of points.
- Filtering process can be controled with the `tolerance` parameter.
+ redundancies and loads the result in the table as a list of points.
+ Filtering process can be controled with the `tolerance` parameter.
:Args:
@@ -1070,6 +1102,7 @@ class CurveTable(PyoTableObject):
Defaults to 0.02.
"""
+ pyoArgsAssert(self, "SN", filename, tolerance)
_path, _name = os.path.split(filename)
# files = sorted([f for f in os.listdir(_path) if _name+"_" in f])
# if _name not in files: files.append(_name)
@@ -1085,7 +1118,7 @@ class CurveTable(PyoTableObject):
self._list = values
obj.replace(values)
self.refreshView()
-
+
def getPoints(self):
"""
Returns list of points of the current table.
@@ -1098,9 +1131,9 @@ class CurveTable(PyoTableObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
+ will be send to the object on mouse up.
- Ctrl+C with focus on the grapher will copy the list of points to the
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -1109,35 +1142,35 @@ class CurveTable(PyoTableObject):
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
createGraphWindow(self, 3, self._size, yrange, title, wxnoserver)
@property
def tension(self):
- """float. Curvature tension."""
+ """float. Curvature tension."""
return self._tension
@tension.setter
def tension(self, x): self.setTension(x)
@property
def bias(self):
- """float. Curve Attraction."""
+ """float. Curve Attraction."""
return self._bias
@bias.setter
def bias(self, x): self.setBias(x)
@property
def list(self):
- """list. List of tuples indicating location and value of each points in the table."""
+ """list. List of tuples indicating location and value of each points in the table."""
return self.getPoints()
@list.setter
def list(self, x): self.replace(x)
@@ -1151,22 +1184,22 @@ class ExpTable(PyoTableObject):
:Args:
list : list, optional
- List of tuples indicating location and value of each points
- in the table. The default, [(0,0.), (8192, 1.)], creates a
- exponential line from 0.0 at location 0 to 1.0 at the end of
+ List of tuples indicating location and value of each points
+ in the table. The default, [(0,0.), (8192, 1.)], creates a
+ exponential line from 0.0 at location 0 to 1.0 at the end of
the table. Location must be an integer.
exp : float, optional
Exponent factor. Used to control the slope of the curve.
Defaults to 10.
inverse : boolean, optional
- If True, downward slope will be inversed. Useful to create
+ If True, downward slope will be inversed. Useful to create
biexponential curves. Defaults to True.
size : int, optional
Table size in samples. Defaults to 8192.
.. note::
- Locations in the list must be in increasing order. If the last value
+ Locations in the list must be in increasing order. If the last value
is less than size, the rest of the table will be filled with zeros.
>>> s = Server().boot()
@@ -1177,6 +1210,7 @@ class ExpTable(PyoTableObject):
"""
def __init__(self, list=[(0, 0.), (8192, 1.)], exp=10, inverse=True, size=8192):
+ pyoArgsAssert(self, "lNBI", list, exp, inverse, size)
PyoTableObject.__init__(self, size)
if size < list[-1][0]:
print "ExpTable warning : size smaller than last point position."
@@ -1185,18 +1219,19 @@ class ExpTable(PyoTableObject):
self._size = size
self._exp = exp
self._inverse = inverse
- self._base_objs = [ExpTable_base(list, exp, inverse, size)]
+ self._base_objs = [ExpTable_base(copy.deepcopy(list), exp, inverse, size)]
def setExp(self, x):
"""
Replace the `exp` attribute.
-
+
:Args:
-
+
x : float
New `exp` attribute.
-
+
"""
+ pyoArgsAssert(self, "N", x)
self._exp = x
[obj.setExp(x) for obj in self._base_objs]
self.refreshView()
@@ -1204,28 +1239,30 @@ class ExpTable(PyoTableObject):
def setInverse(self, x):
"""
Replace the `inverse` attribute.
-
+
:Args:
-
+
x : boolean
New `inverse` attribute.
-
+
"""
+ pyoArgsAssert(self, "B", x)
self._inverse = x
[obj.setInverse(x) for obj in self._base_objs]
self.refreshView()
-
+
def replace(self, list):
"""
Draw a new envelope according to the new `list` parameter.
-
+
:Args:
-
+
list : list
- List of tuples indicating location and value of each points
+ List of tuples indicating location and value of each points
in the table. Location must be integer.
"""
+ pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@@ -1236,8 +1273,8 @@ class ExpTable(PyoTableObject):
loadRecFile takes a recording file, usually from a ControlRec object,
as `filename` parameter, applies a filtering pre-processing to eliminate
- redundancies and loads the result in the table as a list of points.
- Filtering process can be controled with the `tolerance` parameter.
+ redundancies and loads the result in the table as a list of points.
+ Filtering process can be controled with the `tolerance` parameter.
:Args:
@@ -1248,6 +1285,7 @@ class ExpTable(PyoTableObject):
Defaults to 0.02.
"""
+ pyoArgsAssert(self, "SN", filename, tolerance)
_path, _name = os.path.split(filename)
# files = sorted([f for f in os.listdir(_path) if _name+"_" in f])
# if _name not in files: files.append(_name)
@@ -1263,7 +1301,7 @@ class ExpTable(PyoTableObject):
self._list = values
obj.replace(values)
self.refreshView()
-
+
def getPoints(self):
"""
Returns list of points of the current table.
@@ -1276,9 +1314,9 @@ class ExpTable(PyoTableObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
+ will be send to the object on mouse up.
- Ctrl+C with focus on the grapher will copy the list of points to the
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -1287,33 +1325,33 @@ class ExpTable(PyoTableObject):
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
createGraphWindow(self, 2, self._size, yrange, title, wxnoserver)
@property
def exp(self):
- """float. Exponent factor."""
+ """float. Exponent factor."""
return self._exp
@exp.setter
def exp(self, x): self.setExp(x)
@property
def inverse(self):
- """boolean. Inverse factor."""
+ """boolean. Inverse factor."""
return self._inverse
@inverse.setter
def inverse(self, x): self.setInverse(x)
@property
def list(self):
- """list. List of tuples indicating location and value of each points in the table."""
+ """list. List of tuples indicating location and value of each points in the table."""
return self.getPoints()
@list.setter
def list(self, x): self.replace(x)
@@ -1322,7 +1360,7 @@ class SndTable(PyoTableObject):
"""
Transfers data from a soundfile into a function table.
- If `chnl` is None, the table will contain as many table streams as
+ If `chnl` is None, the table will contain as many table streams as
necessary to read all channels of the loaded sound.
:Parent: :py:class:`PyoTableObject`
@@ -1336,11 +1374,11 @@ class SndTable(PyoTableObject):
Channel number to read in. Available at initialization time only.
The default (None) reads all channels.
start : float, optional
- Begins reading at `start` seconds into the file. Available at
+ Begins reading at `start` seconds into the file. Available at
initialization time only. Defaults to 0.
stop : float, optional
- Stops reading at `stop` seconds into the file. Available at
- initialization time only. The default (None) means the end of
+ Stops reading at `stop` seconds into the file. Available at
+ initialization time only. The default (None) means the end of
the file.
>>> s = Server().boot()
@@ -1385,20 +1423,20 @@ class SndTable(PyoTableObject):
def setSound(self, path, start=0, stop=None):
"""
Load a new sound in the table.
-
+
Keeps the number of channels of the sound loaded at initialization.
- If the new sound has less channels, it will wrap around and load
- the same channels many times. If the new sound has more channels,
+ If the new sound has less channels, it will wrap around and load
+ the same channels many times. If the new sound has more channels,
the extra channels will be skipped.
-
+
:Args:
-
+
path : string
Full path of the new sound.
start : float, optional
Begins reading at `start` seconds into the file. Defaults to 0.
stop : float, optional
- Stops reading at `stop` seconds into the file. The default (None)
+ Stops reading at `stop` seconds into the file. The default (None)
means the end of the file.
"""
@@ -1431,8 +1469,8 @@ class SndTable(PyoTableObject):
Append a sound to the one already in the table with crossfade.
Keeps the number of channels of the sound loaded at initialization.
- If the new sound has less channels, it will wrap around and load
- the same channels many times. If the new sound has more channels,
+ If the new sound has less channels, it will wrap around and load
+ the same channels many times. If the new sound has more channels,
the extra channels will be skipped.
:Args:
@@ -1440,12 +1478,12 @@ class SndTable(PyoTableObject):
path : string
Full path of the new sound.
crossfade : float, optional
- Crossfade time, in seconds, between the sound already in the table
+ Crossfade time, in seconds, between the sound already in the table
and the new one. Defaults to 0.
start : float, optional
Begins reading at `start` seconds into the file. Defaults to 0.
stop : float, optional
- Stops reading at `stop` seconds into the file. The default, None,
+ Stops reading at `stop` seconds into the file. The default, None,
means the end of the file.
"""
@@ -1476,12 +1514,12 @@ class SndTable(PyoTableObject):
"""
Insert a sound into the one already in the table with crossfade.
- Insert a sound at position `pos`, specified in seconds,
+ Insert a sound at position `pos`, specified in seconds,
with crossfading at the beginning and the end of the insertion.
-
+
Keeps the number of channels of the sound loaded at initialization.
- If the new sound has less channels, it will wrap around and load
- the same channels many times. If the new sound has more channels,
+ If the new sound has less channels, it will wrap around and load
+ the same channels many times. If the new sound has more channels,
the extra channels will be skipped.
:Args:
@@ -1492,12 +1530,12 @@ class SndTable(PyoTableObject):
Position in the table, in seconds, where to insert the new sound.
Defaults to 0.
crossfade : float, optional
- Crossfade time, in seconds, between the sound already in the table
+ Crossfade time, in seconds, between the sound already in the table
and the new one. Defaults to 0.
start : float, optional
Begins reading at `start` seconds into the file. Defaults to 0.
stop : float, optional
- Stops reading at `stop` seconds into the file. The default, None,
+ Stops reading at `stop` seconds into the file. The default, None,
means the end of the file.
"""
@@ -1526,9 +1564,9 @@ class SndTable(PyoTableObject):
def getRate(self):
"""
- Return the frequency in cps at which the sound will be read at its
+ Return the frequency in cps at which the sound will be read at its
original pitch.
-
+
"""
if type(self._path) == ListType:
return [obj.getRate() for obj in self._base_objs]
@@ -1538,18 +1576,18 @@ class SndTable(PyoTableObject):
def getDur(self, all=True):
"""
Return the duration of the sound in seconds.
-
+
:Args:
-
+
all : boolean
If the table contains more than one sound and `all` is True,
returns a list of all durations. Otherwise, returns only the
first duration as a float.
-
+
"""
if type(self._path) == ListType:
_dur = [1./obj.getRate() for obj in self._base_objs]
- else:
+ else:
_dur = 1./self._base_objs[0].getRate()
if all:
@@ -1568,7 +1606,7 @@ class SndTable(PyoTableObject):
Return the size of the table in samples.
:Args:
-
+
all : boolean
If the table contains more than one sound and `all` is True,
returns a list of all sizes. Otherwise, returns only the
@@ -1594,17 +1632,17 @@ class SndTable(PyoTableObject):
These lists can be draw on a DC (WxPython) with a DrawLines method.
:Args:
-
+
size : tuple
Size, (X, Y) pixel values, of the waveform container window.
begin : float, optional
First position in the the table, in seconds, where to get samples.
Defaults to 0.
end : float, optional
- Last position in the table, in seconds, where to get samples.
-
+ Last position in the table, in seconds, where to get samples.
+
if this value is set to 0, that means the end of the table. Defaults to 0.
-
+
"""
w, h = size
chnls = len(self._base_objs)
@@ -1618,12 +1656,12 @@ class SndTable(PyoTableObject):
def getEnvelope(self, points):
"""
Return the amplitude envelope of the table.
-
- Return a list, of length `chnl`, of lists of length `points` filled
+
+ Return a list, of length `chnl`, of lists of length `points` filled
with the amplitude envelope of the table.
-
+
:Args:
-
+
points : int
Number of points of the amplitude analysis.
@@ -1637,16 +1675,16 @@ class SndTable(PyoTableObject):
:Args:
title : string, optional
- Window title. Defaults to "Table waveform".
+ Window title. Defaults to "Table waveform".
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
mouse_callback : callable
- If provided, this function will be called with the mouse
+ If provided, this function will be called with the mouse
position, inside the frame, as argument. Defaults to None.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
createSndViewTableWindow(self, title, wxnoserver, self.__class__.__name__, mouse_callback)
@@ -1657,35 +1695,35 @@ class SndTable(PyoTableObject):
@property
def sound(self):
- """string. Full path of the sound."""
+ """string. Full path of the sound."""
return self._path
@sound.setter
def sound(self, x): self.setSound(x)
@property
def path(self):
- """string. Full path of the sound."""
+ """string. Full path of the sound."""
return self._path
@path.setter
def path(self, x): self.setSound(x)
@property
def chnl(self):
- """int. Channel to read in."""
+ """int. Channel to read in."""
return self._chnl
@chnl.setter
def chnl(self, x): print "'chnl' attribute is read-only."
@property
def start(self):
- """float. Start point, in seconds, to read into the file."""
+ """float. Start point, in seconds, to read into the file."""
return self._start
@start.setter
def start(self, x): print "'start' attribute is read-only."
@property
def stop(self):
- """float. Stop point, in seconds, to read into the file."""
+ """float. Stop point, in seconds, to read into the file."""
return self._stop
@stop.setter
def stop(self, x): print "SndTable 'stop' attribute is read-only."
@@ -1698,7 +1736,7 @@ class SndTable(PyoTableObject):
class NewTable(PyoTableObject):
"""
- Create an empty table ready for recording.
+ Create an empty table ready for recording.
See :py:class:`TableRec` to write samples in the table.
@@ -1709,17 +1747,17 @@ class NewTable(PyoTableObject):
length : float
Length of the table in seconds.
chnls : int, optional
- Number of channels that will be handled by the table.
+ Number of channels that will be handled by the table.
Defaults to 1.
init : list of floats, optional
Initial table. List of list can match the number of channels,
- otherwise, the list will be loaded in all tablestreams.
+ otherwise, the list will be loaded in all tablestreams.
Defaults to None.
feedback : float, optional
Amount of old data to mix with a new recording. Defaults to 0.0.
- .. seealso::
-
+ .. seealso::
+
:py:class:`DataTable`, :py:class:`TableRec`
>>> s = Server(duplex=1).boot()
@@ -1735,6 +1773,7 @@ class NewTable(PyoTableObject):
"""
def __init__(self, length, chnls=1, init=None, feedback=0.0):
+ pyoArgsAssert(self, "NILN", length, chnls, init, feedback)
PyoTableObject.__init__(self)
self._length = length
self._chnls = chnls
@@ -1743,7 +1782,7 @@ class NewTable(PyoTableObject):
if init == None:
self._base_objs = [NewTable_base(length, None, feedback) for i in range(chnls)]
else:
- if type(init[0]) != ListType:
+ if type(init[0]) != ListType:
init = [init]
self._base_objs = [NewTable_base(length, wrap(init,i), feedback) for i in range(chnls)]
self._size = self._base_objs[0].getSize()
@@ -1751,17 +1790,18 @@ class NewTable(PyoTableObject):
def replace(self, x):
"""
Replaces the actual table.
-
+
:Args:
-
+
x : list of floats
New table. Must be of the same size as the actual table.
- List of list can match the number of channels, otherwise,
+ List of list can match the number of channels, otherwise,
the list will be loaded in all tablestreams.
"""
- if type(x[0]) != ListType:
+ pyoArgsAssert(self, "l", x)
+ if type(x[0]) != ListType:
x = [x]
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
self.refreshView()
@@ -1776,31 +1816,32 @@ class NewTable(PyoTableObject):
New `feedback` value.
"""
+ pyoArgsAssert(self, "N", x)
self._feedback = x
[obj.setFeedback(x) for i, obj in enumerate(self._base_objs)]
def getLength(self):
"""
Returns the length of the table in seconds.
-
+
"""
return self._base_objs[0].getLength()
def getDur(self, all=True):
"""
Returns the length of the table in seconds.
-
+
The `all` argument is there for compatibility with SndTable but
is not used for now.
-
+
"""
return self._base_objs[0].getLength()
-
+
def getRate(self):
"""
- Returns the frequency (cycle per second) to give to an
+ Returns the frequency (cycle per second) to give to an
oscillator to read the sound at its original pitch.
-
+
"""
return self._base_objs[0].getRate()
@@ -1810,15 +1851,15 @@ class NewTable(PyoTableObject):
These lists can be draw on a DC (WxPython) with a DrawLines method.
:Args:
-
+
size : tuple
Size, (X, Y) pixel values, of the waveform container window.
begin : float, optional
First position in the the table, in seconds, where to get samples.
Defaults to 0.
end : float, optional
- Last position in the table, in seconds, where to get samples.
-
+ Last position in the table, in seconds, where to get samples.
+
if this value is set to 0, that means the end of the table. Defaults to 0.
"""
@@ -1838,16 +1879,16 @@ class NewTable(PyoTableObject):
:Args:
title : string, optional
- Window title. Defaults to "Table waveform".
+ Window title. Defaults to "Table waveform".
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
mouse_callback : callable
- If provided, this function will be called with the mouse
+ If provided, this function will be called with the mouse
position, inside the frame, as argument. Defaults to None.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
createSndViewTableWindow(self, title, wxnoserver, self.__class__.__name__, mouse_callback)
@@ -1858,28 +1899,28 @@ class NewTable(PyoTableObject):
@property
def length(self):
- """float. Length of the table in seconds."""
+ """float. Length of the table in seconds."""
return self._length
@length.setter
def length(self, x): print "'length' attribute is read-only."
@property
def chnls(self):
- """int. Number of channels that will be handled by the table."""
+ """int. Number of channels that will be handled by the table."""
return self._chnls
@chnls.setter
def chnls(self, x): print "'chnls' attribute is read-only."
@property
def init(self):
- """list of floats. Initial table."""
+ """list of floats. Initial table."""
return self._init
@init.setter
def init(self, x): print "'init' attribute is read-only."
@property
def feedback(self):
- """float. Amount of old data to mix with a new recording."""
+ """float. Amount of old data to mix with a new recording."""
return self._feedback
@feedback.setter
def feedback(self, x): self.setFeedback(x)
@@ -1903,14 +1944,14 @@ class DataTable(PyoTableObject):
size : int
Size of the table in samples.
chnls : int, optional
- Number of channels that will be handled by the table.
+ Number of channels that will be handled by the table.
Defaults to 1.
init : list of floats, optional
Initial table. List of list can match the number of channels,
- otherwise, the list will be loaded in all tablestreams.
+ otherwise, the list will be loaded in all tablestreams.
+
+ .. seealso::
- .. seealso::
-
:py:class:`NewTable`, :py:class:`TableRec`
>>> s = Server().boot()
@@ -1924,6 +1965,7 @@ class DataTable(PyoTableObject):
"""
def __init__(self, size, chnls=1, init=None):
+ pyoArgsAssert(self, "IIL", size, chnls, init)
PyoTableObject.__init__(self, size)
self._chnls = chnls
self._init = init
@@ -1942,19 +1984,20 @@ class DataTable(PyoTableObject):
x : list of floats
New table. Must be of the same size as the actual table.
-
- List of list can match the number of channels, otherwise,
+
+ List of list can match the number of channels, otherwise,
the list will be loaded in all tablestreams.
"""
- if type(x[0]) != ListType:
+ pyoArgsAssert(self, "l", x)
+ if type(x[0]) != ListType:
x = [x]
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
self.refreshView()
def getRate(self):
"""
- Returns the frequency (cycle per second) to give to an
+ Returns the frequency (cycle per second) to give to an
oscillator to read the sound at its original pitch.
"""
@@ -1965,7 +2008,7 @@ class DataTable(PyoTableObject):
Opens a multislider window to control the data values.
When editing the grapher with the mouse, the new values are
- sent to the object to replace the table content.
+ sent to the object to replace the table content.
:Args:
@@ -1973,35 +2016,183 @@ class DataTable(PyoTableObject):
Set the min and max values of the Y axis of the multislider.
Defaults to (0.0, 1.0).
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
createDataGraphWindow(self, yrange, title, wxnoserver)
@property
def size(self):
- """int. Length of the table in samples."""
+ """int. Length of the table in samples."""
return self._size
@size.setter
def size(self, x): print "DataTable 'size' attribute is read-only."
@property
def chnls(self):
- """int. Number of channels that will be handled by the table."""
+ """int. Number of channels that will be handled by the table."""
return self._chnls
@chnls.setter
def chnls(self, x): print "'chnls' attribute is read-only."
@property
def init(self):
- """list of floats. Initial table."""
+ """list of floats. Initial table."""
return self._init
@init.setter
def init(self, x): print "'init' attribute is read-only."
+
+class AtanTable(PyoTableObject):
+ """
+ Generates an arctangent transfert function.
+
+ This table allow the creation the classic arctangent transfert functions,
+ useful in distortion design. See Lookup object for a simple table lookup
+ process.
+
+ :Parent: :py:class:`PyoTableObject`
+
+ :Args:
+
+ slope : float, optional
+ Slope of the arctangent function, between 0 and 1. Defaults to 0.5.
+ size : int, optional
+ Table size in samples. Defaults to 8192.
+
+ >>> import math
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> t = AtanTable(slope=0.8)
+ >>> a = Sine(freq=[149,150])
+ >>> l = Lookup(table=t, index=a, mul=0.3).out()
+
+ """
+ def __init__(self, slope=0.5, size=8192):
+ pyoArgsAssert(self, "NI", slope, size)
+ PyoTableObject.__init__(self, size)
+ self._slope = slope
+ self._base_objs = [AtanTable_base(slope, size)]
+
+ def setSlope(self, x):
+ """
+ Change the slope of the arctangent function. This will redraw the table.
+
+ :Args:
+
+ x : float
+ New slope between 0 and 1.
+
+ """
+ pyoArgsAssert(self, "N", x)
+ self._slope = x
+ [obj.setSlope(x) for obj in self._base_objs]
+ self.refreshView()
+
+ @property
+ def slope(self):
+ """float. slope of the arctangent function."""
+ return self._slope
+ @slope.setter
+ def slope(self, x): self.setSlope(x)
+
+class PartialTable(PyoTableObject):
+ """
+ Inharmonic waveform generator.
+
+ Generates waveforms made of inharmonic components. Partials are
+ given as a list of 2-values tuple, where the first one is the
+ partial number (can be float) and the second one is the strength
+ of the partial.
+
+ The object uses the first two decimal values of each partial to
+ compute a higher harmonic at a multiple of 100 (so each component
+ is in reality truly harmonic). If the oscillator has a frequency
+ divided by 100, the real desired partials will be restituted.
+
+ The list:
+
+ [(1, 1), (1.1, 0.7), (1.15, 0.5)] will draw a table with:
+
+ harmonic 100 : amplitude = 1
+ harmonic 110 : amplitude = 0.7
+ harmonic 115 : amplitude = 0.5
+
+ To listen to a signal composed of 200, 220 and 230 Hz, one should
+ declared an oscillator like this (frequency of 200Hz divided by 100):
+
+ a = Osc(t, freq=2, mul=0.5).out()
+
+ :Parent: :py:class:`PyoTableObject`
+
+ :Args:
+
+ list : list of tuple, optional
+ List of 2-values tuples. First value is the partial number (float up
+ to two decimal values) and second value is its amplitude (relative to
+ the other harmonics). Defaults to [(1,1), (1.33,0.5),(1.67,0.3)].
+ size : int, optional
+ Table size in samples. Because computed harmonics are very high in
+ frequency, the table size must be bigger than a classic HarmTable.
+ Defaults to 65536.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> t = PartialTable([(1,1), (2.37, 0.5), (4.55, 0.3)]).normalize()
+ >>> # Play with fundamentals 199 and 200 Hz
+ >>> a = Osc(table=t, freq=[1.99,2], mul=.2).out()
+
+ """
+ def __init__(self, list=[(1,1), (1.33,0.5),(1.67,0.3)], size=65536):
+ pyoArgsAssert(self, "lI", list, size)
+ PyoTableObject.__init__(self, size)
+ self._list = list
+ self._par_table = HarmTable(self._create_list(), size)
+ self._base_objs = self._par_table.getBaseObjects()
+ self.normalize()
+
+ def _create_list(self):
+ # internal method used to compute the harmonics's weight
+ hrms = [(int(x*100.), y) for x, y in self._list]
+ l = []
+ ind = 0
+ for i in range(10000):
+ if i == hrms[ind][0]:
+ l.append(hrms[ind][1])
+ ind += 1
+ if ind == len(hrms):
+ break
+ else:
+ l.append(0)
+ return l
+
+ def replace(self, list):
+ """
+ Redraw the waveform according to a new set of harmonics
+ relative strengths.
+
+ :Args:
+
+ list : list of tuples
+ Each tuple contains the partial number, as a float,
+ and its strength.
+
+ """
+ pyoArgsAssert(self, "l", list)
+ self._list = list
+ [obj.replace(self._create_list()) for obj in self._base_objs]
+ self.normalize()
+ self.refreshView()
+
+ @property
+ def list(self):
+ """list. List of partial numbers and strength."""
+ return self._list
+ @list.setter
+ def list(self, x): self.replace(x)
\ No newline at end of file
diff --git a/pyolib/triggers.py b/pyolib/triggers.py
index e653171..2e74fa9 100644
--- a/pyolib/triggers.py
+++ b/pyolib/triggers.py
@@ -3,35 +3,35 @@ Set of objects to manage triggers streams.
A trigger is an audio signal with a value of 1 surrounded by 0s.
-TrigXXX objects use this kind of signal to generate different
+TrigXXX objects use this kind of signal to generate different
processes with sampling rate time accuracy.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
-import sys
from _core import *
from _maps import *
from _widgets import createGraphWindow
from types import SliceType, ListType, TupleType
+import weakref
class Trig(PyoObject):
"""
@@ -82,7 +82,7 @@ class Metro(PyoObject):
A trigger is an audio signal with a value of 1 surrounded by 0s.
- The play() method starts the metro and is not called at the object
+ The play() method starts the metro and is not called at the object
creation time.
:Parent: :py:class:`PyoObject`
@@ -92,9 +92,9 @@ class Metro(PyoObject):
time : float or PyoObject, optional
Time between each trigger in seconds. Defaults to 1.
poly : int, optional
- Metronome polyphony. Denotes how many independent streams are
+ Metronome polyphony. Denotes how many independent streams are
generated by the metronome, allowing overlapping processes.
-
+
Available only at initialization. Defaults to 1.
.. note::
@@ -113,6 +113,7 @@ class Metro(PyoObject):
"""
def __init__(self, time=1, poly=1):
+ pyoArgsAssert(self, "OI", time, poly)
PyoObject.__init__(self)
self._time = time
self._poly = poly
@@ -122,20 +123,21 @@ class Metro(PyoObject):
def setTime(self, x):
"""
Replace the `time` attribute.
-
+
:Args:
-
+
x : float or PyoObject
New `time` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._time = x
x, lmax = convertArgsToLists(x)
[obj.setTime(wrap(x,i)*self._poly) for i, obj in enumerate(self._base_objs)]
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
-
+
def setMul(self, x):
pass
@@ -151,10 +153,10 @@ class Metro(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.001, 1., 'log', 'time', self._time)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def time(self):
- """float or PyoObject. Time between each trigger in seconds."""
+ """float or PyoObject. Time between each trigger in seconds."""
return self._time
@time.setter
def time(self, x): self.setTime(x)
@@ -165,7 +167,7 @@ class Seq(PyoObject):
A trigger is an audio signal with a value of 1 surrounded by 0s.
- The play() method starts the sequence and is not called at the object
+ The play() method starts the sequence and is not called at the object
creation time.
:Parent: :py:class:`PyoObject`
@@ -179,7 +181,7 @@ class Seq(PyoObject):
poly : int, optional
Seq polyphony. Denotes how many independent streams are
generated by the metronome, allowing overlapping processes.
-
+
Available only at initialization. Defaults to 1.
.. note::
@@ -198,10 +200,8 @@ class Seq(PyoObject):
"""
def __init__(self, time=1, seq=[1], poly=1):
+ pyoArgsAssert(self, "OlI", time, seq, poly)
PyoObject.__init__(self)
- if type(seq) != ListType:
- print >> sys.stderr, 'TypeError: "seq" argument of %s must be a list.\n' % self.__class__.__name__
- exit()
self._time = time
self._seq = seq
self._poly = poly
@@ -211,7 +211,7 @@ class Seq(PyoObject):
else:
seqlen = len(seq)
lmax = max(seqlen, lmax)
- self._base_players = [Seqer_base(wrap(time,i), wrap(seq,i), poly) for i in range(lmax)]
+ self._base_players = [Seqer_base(wrap(time,i), wrap(seq,i), poly) for i in range(lmax)]
self._base_objs = [Seq_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
def setTime(self, x):
@@ -224,6 +224,7 @@ class Seq(PyoObject):
New `time` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._time = x
x, lmax = convertArgsToLists(x)
[obj.setTime(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -238,6 +239,7 @@ class Seq(PyoObject):
New `seq` attribute.
"""
+ pyoArgsAssert(self, "l", x)
self._seq = x
if type(x[0]) != ListType:
[obj.setSeq(x) for i, obj in enumerate(self._base_players)]
@@ -265,14 +267,14 @@ class Seq(PyoObject):
@property
def time(self):
- """float or PyoObject. Base time between each trigger in seconds."""
+ """float or PyoObject. Base time between each trigger in seconds."""
return self._time
@time.setter
def time(self, x): self.setTime(x)
@property
def seq(self):
- """List of ints. Sequence of beat durations in time's unit."""
+ """List of ints. Sequence of beat durations in time's unit."""
return self._seq
@seq.setter
def seq(self, x): self.setSeq(x)
@@ -285,7 +287,7 @@ class Cloud(PyoObject):
A trigger is an audio signal with a value of 1 surrounded by 0s.
- The play() method starts the Cloud and is not called at the object
+ The play() method starts the Cloud and is not called at the object
creation time.
:Parent: :py:class:`PyoObject`
@@ -295,9 +297,9 @@ class Cloud(PyoObject):
density : float or PyoObject, optional
Average number of triggers per second. Defaults to 10.
poly : int, optional
- Cloud polyphony. Denotes how many independent streams are
+ Cloud polyphony. Denotes how many independent streams are
generated by the object, allowing overlapping processes.
-
+
Available only at initialization. Defaults to 1.
.. note::
@@ -316,6 +318,7 @@ class Cloud(PyoObject):
"""
def __init__(self, density=10, poly=1):
+ pyoArgsAssert(self, "OI", density, poly)
PyoObject.__init__(self)
self._density = density
self._poly = poly
@@ -326,20 +329,21 @@ class Cloud(PyoObject):
def setDensity(self, x):
"""
Replace the `density` attribute.
-
+
:Args:
-
+
x : float or PyoObject
New `density` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._density = x
x, lmax = convertArgsToLists(x)
[obj.setDensity(wrap(x,i)) for i, obj in enumerate(self._base_players)]
-
+
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
-
+
def setMul(self, x):
pass
@@ -355,10 +359,10 @@ class Cloud(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0, 100., 'lin', 'density', self._density)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def density(self):
- """float or PyoObject. Average density of triggers generation."""
+ """float or PyoObject. Average density of triggers generation."""
return self._density
@density.setter
def density(self, x): self.setDensity(x)
@@ -366,7 +370,7 @@ class Cloud(PyoObject):
class Beat(PyoObject):
"""
Generates algorithmic trigger patterns.
-
+
A trigger is an audio signal with a value of 1 surrounded by 0s.
Beat generates measures of length `taps` and uses weight parameters
@@ -375,13 +379,13 @@ class Beat(PyoObject):
User can store the current pattern in one of the 32 preset slots with
the store() method and recall it later with recall(x).
-
+
A preset is a list where the first value is the number of beats in the
measure, followed by 1s and 0s. For a 4/4 measure with only down beats:
-
- [16, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]
-
- The play() method starts the Beat and is not called at the object
+
+ [16, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]
+
+ The play() method starts the Beat and is not called at the object
creation time.
:Parent: :py:class:`PyoObject`
@@ -399,22 +403,22 @@ class Beat(PyoObject):
w3 : int {0 -> 100}, optional
Probability for the weakest beats. Defaults to 30.
poly : int, optional
- Beat polyphony. Denotes how many independent streams are
+ Beat polyphony. Denotes how many independent streams are
generated by the object, allowing overlapping processes.
-
+
Available only at initialization. Defaults to 1.
.. note::
Beat outputs many signals identified with a string between brackets:
-
- obj['tap'] returns audio stream of the current tap of the measure.
- obj['amp'] returns audio stream of the current beat amplitude.
- obj['dur'] returns audio stream of the current beat duration in seconds.
- obj['end'] returns audio stream with a trigger just before the end of the measure.
-
+
+ | obj['tap'] returns audio stream of the current tap of the measure.
+ | obj['amp'] returns audio stream of the current beat amplitude.
+ | obj['dur'] returns audio stream of the current beat duration in seconds.
+ | obj['end'] returns audio stream with a trigger just before the end of the measure.
+
obj without brackets returns the generated trigger stream of the measure.
-
+
The out() method is bypassed. Beat's signal can not be sent to audio outs.
Beat has no `mul` and `add` attributes.
@@ -430,6 +434,7 @@ class Beat(PyoObject):
"""
def __init__(self, time=.125, taps=16, w1=80, w2=50, w3=30, poly=1):
+ pyoArgsAssert(self, "OinnnI", time, taps, w1, w2, w3, poly)
PyoObject.__init__(self)
self._tap_dummy = []
self._amp_dummy = []
@@ -467,7 +472,7 @@ class Beat(PyoObject):
if i < len(self._base_objs):
return self._base_objs[i]
else:
- print "'i' too large!"
+ print "'i' too large!"
def get(self, identifier="amp", all=False):
"""
@@ -485,9 +490,9 @@ class Beat(PyoObject):
Defaults to "amp".
all : boolean, optional
If True, the first value of each object's stream
- will be returned as a list.
-
- If False, only the value of the first object's
+ will be returned as a list.
+
+ If False, only the value of the first object's
stream will be returned as a float.
"""
@@ -496,10 +501,17 @@ class Beat(PyoObject):
else:
return [obj._getStream().getValue() for obj in self.__getitem__(identifier).getBaseObjects()]
+ def reset(self):
+ """
+ Reset internal counters to initialization values.
+
+ """
+ [obj.reset() for obj in self._base_players]
+
def new(self):
"""
Generates a new pattern with the current parameters.
-
+
"""
[obj.new() for i, obj in enumerate(self._base_players)]
@@ -513,13 +525,14 @@ class Beat(PyoObject):
def store(self, x):
"""
Store the current pattern in memory `x`.
-
+
:Args:
-
+
x : int
Memory number. 0 <= x < 32.
"""
+ pyoArgsAssert(self, "I", x)
[obj.store(x) for i, obj in enumerate(self._base_players)]
def recall(self, x):
@@ -532,8 +545,9 @@ class Beat(PyoObject):
Memory number. 0 <= x < 32.
"""
+ pyoArgsAssert(self, "I", x)
[obj.recall(x) for i, obj in enumerate(self._base_players)]
-
+
def getPresets(self):
"""
Returns the list of stored presets.
@@ -541,22 +555,23 @@ class Beat(PyoObject):
"""
if len(self._base_players) == 1:
return self._base_players[0].getPresets()
- else:
+ else:
return [obj.getPresets() for obj in self._base_players]
def setPresets(self, x):
"""
Store a list presets.
-
+
:Args:
-
+
x : list
List of presets.
"""
+ pyoArgsAssert(self, "l", x)
if len(self._base_players) == 1:
return self._base_players[0].setPresets(x)
- else:
+ else:
return [obj.setPresets(x[i]) for i, obj in enumerate(self._base_players)]
def setTime(self, x):
@@ -569,6 +584,7 @@ class Beat(PyoObject):
New `time` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._time = x
x, lmax = convertArgsToLists(x)
[obj.setTime(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -583,6 +599,7 @@ class Beat(PyoObject):
New `taps` attribute.
"""
+ pyoArgsAssert(self, "I", x)
self._taps = x
x, lmax = convertArgsToLists(x)
[obj.setTaps(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -597,6 +614,7 @@ class Beat(PyoObject):
New `w1` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self.setWeights(w1=x)
def setW2(self, x):
@@ -609,6 +627,7 @@ class Beat(PyoObject):
New `w2` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self.setWeights(w2=x)
def setW3(self, x):
@@ -621,12 +640,13 @@ class Beat(PyoObject):
New `w3` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self.setWeights(w3=x)
-
+
def setWeights(self, w1=None, w2=None, w3=None):
"""
Replace the weight attributes.
-
+
Arguments set to `None` remain unchanged.
:Args:
@@ -685,35 +705,35 @@ class Beat(PyoObject):
@property
def time(self):
- """float or PyoObject. Time, in seconds, between each beat."""
+ """float or PyoObject. Time, in seconds, between each beat."""
return self._time
@time.setter
def time(self, x): self.setTime(x)
@property
def taps(self):
- """int. Number of beats in the generated pattern."""
+ """int. Number of beats in the generated pattern."""
return self._taps
@taps.setter
def taps(self, x): self.setTaps(x)
@property
def w1(self):
- """int. Probability for down beats."""
+ """int. Probability for down beats."""
return self._w1
@w1.setter
def w1(self, x): self.setW1(x)
@property
def w2(self):
- """int. Probability for up beats."""
+ """int. Probability for up beats."""
return self._w2
@w2.setter
def w2(self, x): self.setW2(x)
@property
def w3(self):
- """int. Probability for other beats."""
+ """int. Probability for other beats."""
return self._w3
@w3.setter
def w3(self, x): self.setW3(x)
@@ -722,8 +742,8 @@ class TrigRandInt(PyoObject):
"""
Pseudo-random integer generator.
- TrigRandInt generates a pseudo-random number integer number between
- 0 and `max` values each time it receives a trigger in its `input`
+ TrigRandInt generates a pseudo-random number integer number between
+ 0 and `max` values each time it receives a trigger in its `input`
parameter. The value is kept until the next trigger.
:Parent: :py:class:`PyoObject`
@@ -737,7 +757,7 @@ class TrigRandInt(PyoObject):
.. note::
- The out() method is bypassed. TrigRandInt's signal can not be sent
+ The out() method is bypassed. TrigRandInt's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -750,6 +770,7 @@ class TrigRandInt(PyoObject):
"""
def __init__(self, input, max=100., mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, max, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._max = max
@@ -769,6 +790,7 @@ class TrigRandInt(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -782,6 +804,7 @@ class TrigRandInt(PyoObject):
new `max` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -795,26 +818,26 @@ class TrigRandInt(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def max(self):
+ def max(self):
"""float or PyoObject. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
class TrigRand(PyoObject):
"""
Pseudo-random number generator.
- TrigRand generates a pseudo-random number between `min` and `max`
- values each time it receives a trigger in its `input` parameter.
+ TrigRand generates a pseudo-random number between `min` and `max`
+ values each time it receives a trigger in its `input` parameter.
The value is kept until the next trigger.
:Parent: :py:class:`PyoObject`
@@ -830,7 +853,7 @@ class TrigRand(PyoObject):
port : float, optional
Portamento. Time to reach a new value. Defaults to 0.
init : float, optional
- Initial value. Available at initialization time only.
+ Initial value. Available at initialization time only.
Defaults to 0.
>>> s = Server().boot()
@@ -843,6 +866,7 @@ class TrigRand(PyoObject):
"""
def __init__(self, input, min=0., max=1., port=0., init=0., mul=1, add=0):
+ pyoArgsAssert(self, "oOOnnOO", input, min, max, port, init, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._min = min
@@ -855,7 +879,7 @@ class TrigRand(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -864,19 +888,21 @@ class TrigRand(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setMin(self, x):
"""
Replace the `min` attribute.
-
+
:Args:
x : float or PyoObject
new `min` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -884,13 +910,14 @@ class TrigRand(PyoObject):
def setMax(self, x):
"""
Replace the `max` attribute.
-
+
:Args:
x : float or PyoObject
new `max` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -898,13 +925,14 @@ class TrigRand(PyoObject):
def setPort(self, x):
"""
Replace the `port` attribute.
-
+
:Args:
x : float
new `port` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._port = x
x, lmax = convertArgsToLists(x)
[obj.setPort(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -916,40 +944,40 @@ class TrigRand(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def min(self):
+ def min(self):
"""float or PyoObject. Minimum value."""
return self._min
@min.setter
- def min(self, x):
+ def min(self, x):
self.setMin(x)
@property
- def max(self):
+ def max(self):
"""float or PyoObject. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
@property
- def port(self):
+ def port(self):
"""float. Ramp time."""
return self._port
@port.setter
- def port(self, x):
+ def port(self, x):
self.setPort(x)
class TrigChoice(PyoObject):
"""
Random generator from user's defined values.
- TrigChoice chooses randomly a new value in list `choice` each
- time it receives a trigger in its `input` parameter. The value
+ TrigChoice chooses randomly a new value in list `choice` each
+ time it receives a trigger in its `input` parameter. The value
is kept until the next trigger.
:Parent: :py:class:`PyoObject`
@@ -963,7 +991,7 @@ class TrigChoice(PyoObject):
port : float, optional
Portamento. Time to reach a new value. Defaults to 0.
init : float, optional
- Initial value. Available at initialization time only.
+ Initial value. Available at initialization time only.
Defaults to 0.
>>> s = Server().boot()
@@ -976,10 +1004,8 @@ class TrigChoice(PyoObject):
"""
def __init__(self, input, choice, port=0., init=0., mul=1, add=0):
+ pyoArgsAssert(self, "olnnOO", input, choice, port, init, mul, add)
PyoObject.__init__(self, mul, add)
- if type(choice) != ListType:
- print >> sys.stderr, 'TypeError: "choice" argument of %s must be a list.\n' % self.__class__.__name__
- exit()
self._input = input
self._choice = choice
self._port = port
@@ -995,7 +1021,7 @@ class TrigChoice(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1004,19 +1030,21 @@ class TrigChoice(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setChoice(self, x):
"""
Replace the `choice` attribute.
-
+
:Args:
x : list of floats
new `choice` attribute.
-
+
"""
+ pyoArgsAssert(self, "l", x)
self._choice = x
if type(x[0]) != ListType:
[obj.setChoice(self._choice) for i, obj in enumerate(self._base_objs)]
@@ -1026,44 +1054,45 @@ class TrigChoice(PyoObject):
def setPort(self, x):
"""
Replace the `port` attribute.
-
+
:Args:
x : float
new `port` attribute.
-
+
"""
+ pyoArgsAssert(self, "n", x)
self._port = x
x, lmax = convertArgsToLists(x)
[obj.setPort(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def choice(self):
+ def choice(self):
"""list of floats. Possible values."""
return self._choice
@choice.setter
- def choice(self, x):
+ def choice(self, x):
self.setChoice(x)
@property
- def port(self):
+ def port(self):
"""float. Ramp time."""
return self._port
@port.setter
- def port(self, x):
+ def port(self, x):
self.setPort(x)
class TrigFunc(PyoObject):
"""
Python function callback.
- TrigFunc calls the function given at parameter `function` each
+ TrigFunc calls the function given at parameter `function` each
time it receives a trigger in its `input` parameter.
:Parent: :py:class:`PyoObject`
@@ -1080,7 +1109,7 @@ class TrigFunc(PyoObject):
.. note::
- The out() method is bypassed. TrigFunc's signal can not be sent
+ The out() method is bypassed. TrigFunc's signal can not be sent
to audio outs.
TrigFunc has no `mul` and `add` attributes.
@@ -1102,35 +1131,28 @@ class TrigFunc(PyoObject):
"""
def __init__(self, input, function, arg=None):
+ pyoArgsAssert(self, "oc", input, function)
PyoObject.__init__(self)
- if type(function) == ListType or type(function) == TupleType:
- if not callable(function[0]):
- print >> sys.stderr, 'TypeError: "function" argument of %s must be callable.\n' % self.__class__.__name__
- exit()
- else:
- if not callable(function):
- print >> sys.stderr, 'TypeError: "function" argument of %s must be callable.\n' % self.__class__.__name__
- exit()
self._input = input
- self._function = function
+ self._function = getWeakMethodRef(function)
self._arg = arg
self._in_fader = InputFader(input)
in_fader, function, arg, lmax = convertArgsToLists(self._in_fader, function, arg)
- self._base_objs = [TrigFunc_base(wrap(in_fader,i), wrap(function,i), wrap(arg,i)) for i in range(lmax)]
+ self._base_objs = [TrigFunc_base(wrap(in_fader,i), WeakMethod(wrap(function,i)), wrap(arg,i)) for i in range(lmax)]
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
def setMul(self, x):
pass
-
+
def setAdd(self, x):
- pass
+ pass
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1139,22 +1161,24 @@ class TrigFunc(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setFunction(self, x):
"""
Replace the `function` attribute.
-
+
:Args:
x : Python function
new `function` attribute.
-
+
"""
- self._function = x
+ pyoArgsAssert(self, "c", x)
+ self._function = getWeakMethodRef(x)
x, lmax = convertArgsToLists(x)
- [obj.setFunction(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ [obj.setFunction(WeakMethod(wrap(x,i))) for i, obj in enumerate(self._base_objs)]
def setArg(self, x):
"""
@@ -1171,32 +1195,32 @@ class TrigFunc(PyoObject):
[obj.setArg(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def function(self):
+ def function(self):
"""Python callable. Function to be called."""
return self._function
@function.setter
- def function(self, x):
+ def function(self, x):
self.setFunction(x)
@property
- def arg(self):
+ def arg(self):
"""Anything. Callable's argument."""
return self._arg
@arg.setter
- def arg(self, x):
+ def arg(self, x):
self.setArg(x)
-
+
class TrigEnv(PyoObject):
"""
Envelope reader generator.
- TrigEnv starts reading an envelope in `dur` seconds each time it
+ TrigEnv starts reading an envelope in `dur` seconds each time it
receives a trigger in its `input` parameter.
:Parent: :py:class:`PyoObject`
@@ -1218,9 +1242,9 @@ class TrigEnv(PyoObject):
.. note::
- TrigEnv will sends a trigger signal at the end of the playback.
- User can retreive the trigger streams by calling obj['trig'].
- Useful to synchronize other processes.
+ TrigEnv will sends a trigger signal at the end of the playback.
+ User can retreive the trigger streams by calling obj['trig'].
+ Useful to synchronize other processes.
>>> s = Server().boot()
>>> s.start()
@@ -1232,6 +1256,7 @@ class TrigEnv(PyoObject):
"""
def __init__(self, input, table, dur=1, interp=2, mul=1, add=0):
+ pyoArgsAssert(self, "otOiOO", input, table, dur, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._table = table
@@ -1245,7 +1270,7 @@ class TrigEnv(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1254,33 +1279,36 @@ class TrigEnv(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setTable(self, x):
"""
Replace the `table` attribute.
-
+
:Args:
x : PyoTableObject
new `table` attribute.
-
+
"""
+ pyoArgsAssert(self, "t", x)
self._table = x
x, lmax = convertArgsToLists(x)
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
-
+
def setDur(self, x):
"""
Replace the `dur` attribute.
-
+
:Args:
x : float or PyoObject
new `dur` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._dur = x
x, lmax = convertArgsToLists(x)
[obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1288,13 +1316,14 @@ class TrigEnv(PyoObject):
def setInterp(self, x):
"""
Replace the `interp` attribute.
-
+
:Args:
x : int {1, 2, 3, 4}
new `interp` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1304,39 +1333,39 @@ class TrigEnv(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def table(self):
+ def table(self):
"""PyoTableObject. Envelope table."""
return self._table
@table.setter
- def table(self, x):
+ def table(self, x):
self.setTable(x)
@property
- def dur(self):
+ def dur(self):
"""float or PyoObject. Duration in seconds."""
return self._dur
@dur.setter
- def dur(self, x):
+ def dur(self, x):
self.setDur(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}, Interpolation method."""
return self._interp
@interp.setter
- def interp(self, x):
+ def interp(self, x):
self.setInterp(x)
class TrigLinseg(PyoObject):
"""
Line segments trigger.
- TrigLinseg starts reading a break-points line segments each time it
+ TrigLinseg starts reading a break-points line segments each time it
receives a trigger in its `input` parameter.
:Parent: :py:class:`PyoObject`
@@ -1347,17 +1376,17 @@ class TrigLinseg(PyoObject):
Audio signal sending triggers.
list : list of tuples
Points used to construct the line segments. Each tuple is a
- new point in the form (time, value).
-
+ new point in the form (time, value).
+
Times are given in seconds and must be in increasing order.
.. note::
- TrigLinseg will sends a trigger signal at the end of the playback.
- User can retreive the trigger streams by calling obj['trig'].
- Useful to synchronize other processes.
+ TrigLinseg will sends a trigger signal at the end of the playback.
+ User can retreive the trigger streams by calling obj['trig'].
+ Useful to synchronize other processes.
- The out() method is bypassed. TrigLinseg's signal can not be sent
+ The out() method is bypassed. TrigLinseg's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -1368,13 +1397,8 @@ class TrigLinseg(PyoObject):
"""
def __init__(self, input, list, mul=1, add=0):
+ pyoArgsAssert(self, "olOO", input, list, mul, add)
PyoObject.__init__(self, mul, add)
- if type(list) != ListType:
- print >> sys.stderr, 'TypeError: "list" argument of %s must be a list of tuples.\n' % self.__class__.__name__
- exit()
- if type(list[0]) != TupleType:
- print >> sys.stderr, 'TypeError: "list" argument of %s must be a list of tuples.\n' % self.__class__.__name__
- exit()
self._input = input
self._list = list
self._in_fader = InputFader(input)
@@ -1388,7 +1412,7 @@ class TrigLinseg(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1397,19 +1421,21 @@ class TrigLinseg(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setList(self, x):
"""
Replace the `list` attribute.
-
+
:Args:
x : list of tuples
new `list` attribute.
-
+
"""
+ pyoArgsAssert(self, "l", x)
self._list = x
[obj.setList(x) for i, obj in enumerate(self._base_objs)]
@@ -1437,9 +1463,9 @@ class TrigLinseg(PyoObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
+ will be send to the object on mouse up.
- Ctrl+C with focus on the grapher will copy the list of points to the
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -1453,14 +1479,14 @@ class TrigLinseg(PyoObject):
None, min and max are retrieve from the current list of points.
Defaults to None.
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
if xlen == None:
@@ -1477,25 +1503,25 @@ class TrigLinseg(PyoObject):
createGraphWindow(self, 0, xlen, yrange, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def list(self):
+ def list(self):
"""list of tuples. Points used to construct the line segments."""
return self._list
@list.setter
- def list(self, x):
+ def list(self, x):
self.setList(x)
class TrigExpseg(PyoObject):
"""
Exponential segments trigger.
- TrigExpseg starts reading break-points exponential segments each time
+ TrigExpseg starts reading break-points exponential segments each time
it receives a trigger in its `input` parameter.
:Parent: :py:class:`PyoObject`
@@ -1506,21 +1532,21 @@ class TrigExpseg(PyoObject):
Audio signal sending triggers.
list : list of tuples
Points used to construct the line segments. Each tuple is a
- new point in the form (time, value).
-
+ new point in the form (time, value).
+
Times are given in seconds and must be in increasing order.
exp : float, optional
Exponent factor. Used to control the slope of the curves.
Defaults to 10.
inverse : boolean, optional
- If True, downward slope will be inversed. Useful to create
+ If True, downward slope will be inversed. Useful to create
biexponential curves. Defaults to True.
.. note::
TrigExpseg will sends a trigger signal at the end of the playback.
User can retreive the trigger streams by calling obj['trig'].
- Useful to synchronize other processes.
+ Useful to synchronize other processes.
The out() method is bypassed. TrigExpseg's signal can not be sent
to audio outs.
@@ -1533,13 +1559,8 @@ class TrigExpseg(PyoObject):
"""
def __init__(self, input, list, exp=10, inverse=True, mul=1, add=0):
+ pyoArgsAssert(self, "olnbOO", input, list, exp, inverse, mul, add)
PyoObject.__init__(self, mul, add)
- if type(list) != ListType:
- print >> sys.stderr, 'TypeError: "list" argument of %s must be a list of tuples.\n' % self.__class__.__name__
- exit()
- if type(list[0]) != TupleType:
- print >> sys.stderr, 'TypeError: "list" argument of %s must be a list of tuples.\n' % self.__class__.__name__
- exit()
self._input = input
self._list = list
self._exp = exp
@@ -1555,7 +1576,7 @@ class TrigExpseg(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1564,19 +1585,21 @@ class TrigExpseg(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setList(self, x):
"""
Replace the `list` attribute.
-
+
:Args:
x : list of tuples
new `list` attribute.
-
+
"""
+ pyoArgsAssert(self, "l", x)
self._list = x
[obj.setList(x) for i, obj in enumerate(self._base_objs)]
@@ -1590,6 +1613,7 @@ class TrigExpseg(PyoObject):
new `exp` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._exp = x
x, lmax = convertArgsToLists(x)
[obj.setExp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1604,6 +1628,7 @@ class TrigExpseg(PyoObject):
new `inverse` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._inverse = x
x, lmax = convertArgsToLists(x)
[obj.setInverse(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1632,9 +1657,9 @@ class TrigExpseg(PyoObject):
Opens a grapher window to control the shape of the envelope.
When editing the grapher with the mouse, the new set of points
- will be send to the object on mouse up.
+ will be send to the object on mouse up.
- Ctrl+C with focus on the grapher will copy the list of points to the
+ Ctrl+C with focus on the grapher will copy the list of points to the
clipboard, giving an easy way to insert the new shape in a script.
:Args:
@@ -1648,14 +1673,14 @@ class TrigExpseg(PyoObject):
None, min and max are retrieve from the current list of points.
Defaults to None.
title : string, optional
- Title of the window. If none is provided, the name of the
+ Title of the window. If none is provided, the name of the
class is used.
wxnoserver : boolean, optional
- With wxPython graphical toolkit, if True, tells the
+ With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
-
- If `wxnoserver` is set to True, the interpreter will not wait for
- the server GUI before showing the controller window.
+
+ If `wxnoserver` is set to True, the interpreter will not wait for
+ the server GUI before showing the controller window.
"""
if xlen == None:
@@ -1672,40 +1697,40 @@ class TrigExpseg(PyoObject):
createGraphWindow(self, 2, xlen, yrange, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def list(self):
+ def list(self):
"""list of tuples. Points used to construct the line segments."""
return self._list
@list.setter
- def list(self, x):
+ def list(self, x):
self.setList(x)
@property
- def exp(self):
+ def exp(self):
"""float. Exponent factor."""
return self._exp
@exp.setter
- def exp(self, x):
+ def exp(self, x):
self.setExp(x)
@property
- def inverse(self):
+ def inverse(self):
"""boolean. Inversion of downward slope."""
return self._inverse
@inverse.setter
- def inverse(self, x):
+ def inverse(self, x):
self.setInverse(x)
class TrigXnoise(PyoObject):
"""
Triggered X-class pseudo-random generator.
- Xnoise implements a few of the most common noise distributions.
- A new value is generated each time the object receive a trigger
+ Xnoise implements a few of the most common noise distributions.
+ A new value is generated each time the object receive a trigger
in input. Each distribution generates values in the range 0 and 1.
:Parent: :py:class:`PyoObject`
@@ -1737,7 +1762,7 @@ class TrigXnoise(PyoObject):
10. poisson
11. walker (drunk)
12. loopseg (drunk with looped segments)
-
+
Depending on the distribution, `x1` and `x2` parameters are applied
as follow (names as string, or associated number can be used as `dist`
parameter):
@@ -1778,7 +1803,7 @@ class TrigXnoise(PyoObject):
11. walker
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
- 12. loopseg
+ 12. loopseg
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
@@ -1793,6 +1818,7 @@ class TrigXnoise(PyoObject):
"""
def __init__(self, input, dist=0, x1=0.5, x2=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, x1, x2, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._dist = dist
@@ -1816,6 +1842,7 @@ class TrigXnoise(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1845,6 +1872,7 @@ class TrigXnoise(PyoObject):
new `x1` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._x1 = x
x, lmax = convertArgsToLists(x)
[obj.setX1(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1859,47 +1887,48 @@ class TrigXnoise(PyoObject):
new `x2` attribute.
"""
- self._x2= x
+ pyoArgsAssert(self, "O", x)
+ self._x2 = x
x, lmax = convertArgsToLists(x)
[obj.setX2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def dist(self):
+ def dist(self):
"""string or int. Distribution type."""
return self._dist
@dist.setter
- def dist(self, x):
+ def dist(self, x):
self.setDist(x)
@property
- def x1(self):
+ def x1(self):
"""float or PyoObject. First parameter."""
return self._x1
@x1.setter
- def x1(self, x):
+ def x1(self, x):
self.setX1(x)
@property
- def x2(self):
+ def x2(self):
"""float or PyoObject. Second parameter."""
return self._x2
@x2.setter
- def x2(self, x):
+ def x2(self, x):
self.setX2(x)
class TrigXnoiseMidi(PyoObject):
"""
Triggered X-class midi notes pseudo-random generator.
- Xnoise implements a few of the most common noise distributions.
- A new value is generated each time the object receive a trigger
- in input. Each distribution generates integer values in the range
- defined with `mrange` parameter and output can be scaled on midi
+ Xnoise implements a few of the most common noise distributions.
+ A new value is generated each time the object receive a trigger
+ in input. Each distribution generates integer values in the range
+ defined with `mrange` parameter and output can be scaled on midi
notes, hertz or transposition factor.
:Parent: :py:class:`PyoObject`
@@ -1918,7 +1947,7 @@ class TrigXnoiseMidi(PyoObject):
Output format. 0 = MIDI, 1 = Hertz, 2 = transposition factor.
Defaults to 0.
- In the transposition mode, the central key (the key where there
+ In the transposition mode, the central key (the key where there
is no transposition) is (`minrange` + `maxrange`) / 2.
mrange : tuple of int, optional
Minimum and maximum possible values, in Midi notes. Available
@@ -1940,7 +1969,7 @@ class TrigXnoiseMidi(PyoObject):
10. poisson
11. walker (drunk)
12. loopseg (drunk with looped segments)
-
+
Depending on the distribution, `x1` and `x2` parameters are applied
as follow (names as string, or associated number can be used as `dist`
parameter):
@@ -1981,7 +2010,7 @@ class TrigXnoiseMidi(PyoObject):
11. walker
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
- 12. loopseg
+ 12. loopseg
- x1 : maximum value {0.1 -> 1}
- x2 : maximum step {0.1 -> 1}
@@ -1996,6 +2025,7 @@ class TrigXnoiseMidi(PyoObject):
"""
def __init__(self, input, dist=0, x1=0.5, x2=0.5, scale=0, mrange=(0,127), mul=1, add=0):
+ pyoArgsAssert(self, "oOOixOO", input, x1, x2, scale, mrange, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._dist = dist
@@ -2021,6 +2051,7 @@ class TrigXnoiseMidi(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2044,7 +2075,7 @@ class TrigXnoiseMidi(PyoObject):
"""
Replace the `scale` attribute.
- Possible values are:
+ Possible values are:
0. Midi notes
1. Hertz
2. transposition factor (centralkey is (`minrange` + `maxrange`) / 2
@@ -2055,6 +2086,7 @@ class TrigXnoiseMidi(PyoObject):
new `scale` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._scale = x
x, lmax = convertArgsToLists(x)
[obj.setScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2071,6 +2103,7 @@ class TrigXnoiseMidi(PyoObject):
maximum output midi range.
"""
+ pyoArgsAssert(self, "ii", mini, maxi)
self._mrange = (mini, maxi)
mini, maxi, lmax = convertArgsToLists(mini, maxi)
[obj.setRange(wrap(mini,i), wrap(maxi,i)) for i, obj in enumerate(self._base_objs)]
@@ -2085,6 +2118,7 @@ class TrigXnoiseMidi(PyoObject):
new `x1` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._x1 = x
x, lmax = convertArgsToLists(x)
[obj.setX1(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2099,52 +2133,53 @@ class TrigXnoiseMidi(PyoObject):
new `x2` attribute.
"""
- self._x2= x
+ pyoArgsAssert(self, "O", x)
+ self._x2 = x
x, lmax = convertArgsToLists(x)
[obj.setX2(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def dist(self):
+ def dist(self):
"""string or int. Distribution type."""
return self._dist
@dist.setter
- def dist(self, x):
+ def dist(self, x):
self.setDist(x)
@property
- def x1(self):
+ def x1(self):
"""float or PyoObject. First parameter."""
return self._x1
@x1.setter
- def x1(self, x):
+ def x1(self, x):
self.setX1(x)
@property
- def x2(self):
+ def x2(self):
"""float or PyoObject. Second parameter."""
return self._x2
@x2.setter
- def x2(self, x):
+ def x2(self, x):
self.setX2(x)
@property
- def scale(self):
+ def scale(self):
"""int. Output format."""
return self._scale
@scale.setter
- def scale(self, x):
+ def scale(self, x):
self.setScale(x)
class Counter(PyoObject):
"""
Integer count generator.
- Counter keeps track of all triggers received, outputs the current
- count constrained within `min` and `max` range, and can be set to
+ Counter keeps track of all triggers received, outputs the current
+ count constrained within `min` and `max` range, and can be set to
count up, down, or up-and-down.
@@ -2157,7 +2192,7 @@ class Counter(PyoObject):
min : int, optional
Minimum value of the count, included in the count. Defaults to 0.
max : int, optional
- Maximum value of the count. excluded of the count.
+ Maximum value of the count. excluded of the count.
The counter will count up to max - 1. Defaults to 100.
dir : int {0, 1, 2}, optional
Direction of the count. Defaults to 0. Three possible values:
@@ -2167,11 +2202,11 @@ class Counter(PyoObject):
.. note::
- The out() method is bypassed. Counter's signal can not be sent
+ The out() method is bypassed. Counter's signal can not be sent
to audio outs.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Select`
>>> s = Server().boot()
@@ -2182,6 +2217,7 @@ class Counter(PyoObject):
"""
def __init__(self, input, min=0, max=100, dir=0, mul=1, add=0):
+ pyoArgsAssert(self, "oiiiOO", input, min, max, dir, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._min = min
@@ -2197,7 +2233,7 @@ class Counter(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -2206,19 +2242,21 @@ class Counter(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setMin(self, x):
"""
Replace the `min` attribute.
-
+
:Args:
x : int
new `min` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2226,13 +2264,14 @@ class Counter(PyoObject):
def setMax(self, x):
"""
Replace the `max` attribute.
-
+
:Args:
x : int
new `max` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2240,13 +2279,14 @@ class Counter(PyoObject):
def setDir(self, x):
"""
Replace the `dir` attribute.
-
+
:Args:
x : int {0, 1, 2}
new `dir` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._dir = x
x, lmax = convertArgsToLists(x)
[obj.setDir(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2262,6 +2302,7 @@ class Counter(PyoObject):
Value where to reset the count. Defaults to None.
"""
+ pyoArgsAssert(self, "i", x)
value, lmax = convertArgsToLists(value)
[obj.reset(wrap(value,i)) for i, obj in enumerate(self._base_objs)]
@@ -2274,32 +2315,32 @@ class Counter(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def min(self):
+ def min(self):
"""int. Minimum value."""
return self._min
@min.setter
- def min(self, x):
+ def min(self, x):
self.setMin(x)
@property
- def max(self):
+ def max(self):
"""int. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
@property
- def dir(self):
+ def dir(self):
"""int. Direction of the count."""
return self._dir
@dir.setter
- def dir(self, x):
+ def dir(self, x):
self.setDir(x)
class Select(PyoObject):
@@ -2321,11 +2362,11 @@ class Select(PyoObject):
.. note::
- The out() method is bypassed. Select's signal can not be sent
+ The out() method is bypassed. Select's signal can not be sent
to audio outs.
- .. seealso::
-
+ .. seealso::
+
:py:class:`Counter`
>>> s = Server().boot()
@@ -2340,6 +2381,7 @@ class Select(PyoObject):
"""
def __init__(self, input, value=0, mul=1, add=0):
+ pyoArgsAssert(self, "oiOO", input, value, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._value = value
@@ -2353,7 +2395,7 @@ class Select(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -2362,19 +2404,21 @@ class Select(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setValue(self, x):
"""
Replace the `value` attribute.
-
+
:Args:
x : int
new `value` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._value = x
x, lmax = convertArgsToLists(x)
[obj.setValue(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2384,18 +2428,18 @@ class Select(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def value(self):
+ def value(self):
"""int. Matching value."""
return self._value
@value.setter
- def value(self, x):
+ def value(self, x):
self.setValue(x)
class Change(PyoObject):
@@ -2411,7 +2455,7 @@ class Change(PyoObject):
.. note::
- The out() method is bypassed. Change's signal can not be sent
+ The out() method is bypassed. Change's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -2424,6 +2468,7 @@ class Change(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -2436,7 +2481,7 @@ class Change(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -2445,23 +2490,24 @@ class Change(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
class Thresh(PyoObject):
"""
Informs when a signal crosses a threshold.
-
- Thresh sends a trigger when a signal crosses a threshold. The `dir`
- parameter can be used to set the crossing mode, down-up, up-down, or
+
+ Thresh sends a trigger when a signal crosses a threshold. The `dir`
+ parameter can be used to set the crossing mode, down-up, up-down, or
both.
:Parent: :py:class:`PyoObject`
@@ -2476,18 +2522,18 @@ class Thresh(PyoObject):
There are three modes of using Thresh:
0. down-up (default)
sends a trigger when current value is higher than the
- threshold, while old value was equal to or lower than
+ threshold, while old value was equal to or lower than
the threshold.
1. up-down
sends a trigger when current value is lower than the
- threshold, while old value was equal to or higher than
+ threshold, while old value was equal to or higher than
the threshold.
2. both direction
sends a trigger in both the two previous cases.
-
+
.. note::
- The out() method is bypassed. Thresh's signal can not be sent
+ The out() method is bypassed. Thresh's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -2497,9 +2543,10 @@ class Thresh(PyoObject):
>>> t = LinTable([(0,0), (50,1), (250,.3), (8191,0)])
>>> env = TrigEnv(b, table=t, dur=.5, mul=.3)
>>> sine = Sine(freq=[500,600,700], mul=env).out()
-
+
"""
def __init__(self, input, threshold=0., dir=0, mul=1, add=0):
+ pyoArgsAssert(self, "oOiOO", input, threshold, dir, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._threshold = threshold
@@ -2514,7 +2561,7 @@ class Thresh(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -2523,19 +2570,21 @@ class Thresh(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setThreshold(self, x):
"""
Replace the `threshold` attribute.
-
+
:Args:
x : float or PyoObject
new `threshold` attribute.
-
+
"""
+ pyoArgsAssert(self, "O", x)
self._threshold = x
x, lmax = convertArgsToLists(x)
[obj.setThreshold(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2543,37 +2592,38 @@ class Thresh(PyoObject):
def setDir(self, x):
"""
Replace the `dir` attribute.
-
+
:Args:
x : int {0, 1, 2}
new `dir` attribute.
-
+
"""
+ pyoArgsAssert(self, "i", x)
self._dir = x
x, lmax = convertArgsToLists(x)
[obj.setDir(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def threshold(self):
+ def threshold(self):
"""float or PyoObject. Threshold value."""
return self._threshold
@threshold.setter
- def threshold(self, x):
+ def threshold(self, x):
self.setThreshold(x)
@property
- def dir(self):
+ def dir(self):
"""int. User mode."""
return self._dir
@dir.setter
- def dir(self, x):
+ def dir(self, x):
self.setDir(x)
class Percent(PyoObject):
@@ -2590,12 +2640,12 @@ class Percent(PyoObject):
input : PyoObject
Audio signal sending triggers.
percent : float or PyoObject, optional
- How much percentage of triggers to let pass,
+ How much percentage of triggers to let pass,
between 0 and 100. Defaults to 50.
.. note::
- The out() method is bypassed. Percent's signal can not
+ The out() method is bypassed. Percent's signal can not
be sent to audio outs.
>>> s = Server().boot()
@@ -2610,6 +2660,7 @@ class Percent(PyoObject):
"""
def __init__(self, input, percent=50., mul=1, add=0):
+ pyoArgsAssert(self, "oOOO", input, percent, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._percent = percent
@@ -2632,6 +2683,7 @@ class Percent(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2645,6 +2697,7 @@ class Percent(PyoObject):
new `percent` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._percent = x
x, lmax = convertArgsToLists(x)
[obj.setPercent(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2654,27 +2707,27 @@ class Percent(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def percent(self):
+ def percent(self):
"""float or PyoObject. Percentage value."""
return self._percent
@percent.setter
- def percent(self, x):
+ def percent(self, x):
self.setPercent(x)
class Timer(PyoObject):
"""
Reports elapsed time between two trigs.
- A trigger in `input2` signal starts an internal timer. The next trigger
- in `input` signal stops it and reports the elapsed time between the two
- triggers. Useful for filtering triggers that are too close to each other.
+ A trigger in `input2` signal starts an internal timer. The next trigger
+ in `input` signal stops it and reports the elapsed time between the two
+ triggers. Useful for filtering triggers that are too close to each other.
:Parent: :py:class:`PyoObject`
@@ -2703,6 +2756,7 @@ class Timer(PyoObject):
"""
def __init__(self, input, input2, mul=1, add=0):
+ pyoArgsAssert(self, "ooOO", input, input2, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._input2 = input2
@@ -2723,6 +2777,7 @@ class Timer(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2738,19 +2793,20 @@ class Timer(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input2 = x
self._in_fader2.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Timer stop signal."""
+ """PyoObject. Timer stop signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def input2(self):
- """PyoObject. Timer start signal."""
+ """PyoObject. Timer start signal."""
return self._input2
@input2.setter
def input2(self, x): self.setInput2(x)
@@ -2760,7 +2816,7 @@ class Iter(PyoObject):
Triggers iterate over a list of values.
Iter loops over a list of user-defined values. When a trigger is received
- in `input`, Iter moves up to the next value in the list, with wrap-around.
+ in `input`, Iter moves up to the next value in the list, with wrap-around.
:Parent: :py:class:`PyoObject`
@@ -2771,7 +2827,7 @@ class Iter(PyoObject):
choice : list of floats
Sequence of values over which to iterate.
init : float, optional
- Initial value. Available at initialization time only.
+ Initial value. Available at initialization time only.
Defaults to 0.
>>> s = Server().boot()
@@ -2786,10 +2842,8 @@ class Iter(PyoObject):
"""
def __init__(self, input, choice, init=0., mul=1, add=0):
+ pyoArgsAssert(self, "olnOO", input, choice, init, mul, add)
PyoObject.__init__(self, mul, add)
- if type(choice) != ListType:
- print >> sys.stderr, 'TypeError: "choice" argument of %s must be a list.\n' % self.__class__.__name__
- exit()
self._input = input
self._choice = choice
self._in_fader = InputFader(input)
@@ -2813,6 +2867,7 @@ class Iter(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2826,6 +2881,7 @@ class Iter(PyoObject):
new `choice` attribute.
"""
+ pyoArgsAssert(self, "l", x)
self._choice = x
if type(x[0]) != ListType:
[obj.setChoice(self._choice) for i, obj in enumerate(self._base_objs)]
@@ -2835,36 +2891,37 @@ class Iter(PyoObject):
def reset(self, x=0):
"""
Resets the current count.
-
+
:Args:
-
+
x : int, optional
Value where to reset the count. Defaults to 0.
-
+
"""
+ pyoArgsAssert(self, "I", x)
[obj.reset(x) for obj in self._base_objs]
-
+
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def choice(self):
+ def choice(self):
"""list of floats. Possible values."""
return self._choice
@choice.setter
- def choice(self, x):
+ def choice(self, x):
self.setChoice(x)
class Count(PyoObject):
"""
Counts integers at audio rate.
- Count generates a signal increasing by 1 each sample when it receives a
- trigger. It can be used to do sample playback using TableIndex.
+ Count generates a signal increasing by 1 each sample when it receives a
+ trigger. It can be used to do sample playback using TableIndex.
:Parent: :py:class:`PyoObject`
@@ -2876,8 +2933,8 @@ class Count(PyoObject):
Minimum value of the count, included in the count. Defaults to 0.
max : int, optional
Maximum value of the count. excluded of the count. Defaults to 0.
-
- A value of 0 eliminates the maximum, and the count continues
+
+ A value of 0 eliminates the maximum, and the count continues
increasing without resetting.
>>> s = Server().boot()
@@ -2888,6 +2945,7 @@ class Count(PyoObject):
"""
def __init__(self, input, min=0, max=0, mul=1, add=0):
+ pyoArgsAssert(self, "oiiOO", input, min, max, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._min = min
@@ -2908,6 +2966,7 @@ class Count(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -2921,6 +2980,7 @@ class Count(PyoObject):
new `min` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2935,6 +2995,7 @@ class Count(PyoObject):
new `max` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -2946,32 +3007,32 @@ class Count(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Trigger signal. Start/Restart the count."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def min(self):
+ def min(self):
"""int. Minimum value."""
return self._min
@min.setter
- def min(self, x):
+ def min(self, x):
self.setMin(x)
@property
- def max(self):
+ def max(self):
"""int. Maximum value."""
return self._max
@max.setter
- def max(self, x):
+ def max(self, x):
self.setMax(x)
class NextTrig(PyoObject):
"""
A trigger in the second stream opens a gate only for the next one in the first stream.
- When the gate is opened by a trigger in `input2` signal, the next trigger
+ When the gate is opened by a trigger in `input2` signal, the next trigger
in `input` signal is allowed to pass and automatically closes the gate.
:Parent: :py:class:`PyoObject`
@@ -2999,6 +3060,7 @@ class NextTrig(PyoObject):
"""
def __init__(self, input, input2, mul=1, add=0):
+ pyoArgsAssert(self, "ooOO", input, input2, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._input2 = input2
@@ -3019,6 +3081,7 @@ class NextTrig(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -3034,22 +3097,23 @@ class NextTrig(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input2 = x
self._in_fader2.setInput(x, fadetime)
@property
- def input(self):
+ def input(self):
"""PyoObject. Incoming trigger stream signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def input2(self):
+ def input2(self):
"""PyoObject. Trigger stream opening the gate."""
return self._input2
@input2.setter
- def input2(self, x):
+ def input2(self, x):
self.setInput2(x)
class TrigVal(PyoObject):
@@ -3072,7 +3136,7 @@ class TrigVal(PyoObject):
.. note::
- The out() method is bypassed. TrigVal's signal can not be sent
+ The out() method is bypassed. TrigVal's signal can not be sent
to audio outs.
>>> s = Server().boot()
@@ -3086,6 +3150,7 @@ class TrigVal(PyoObject):
"""
def __init__(self, input, value=0., init=0., mul=1, add=0):
+ pyoArgsAssert(self, "oOnOO", input, value, init, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._value = value
@@ -3105,6 +3170,7 @@ class TrigVal(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -3118,6 +3184,7 @@ class TrigVal(PyoObject):
new `value` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._value = x
x, lmax = convertArgsToLists(x)
[obj.setValue(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -3131,16 +3198,549 @@ class TrigVal(PyoObject):
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio trigger signal."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def value(self):
+ def value(self):
"""float or PyoObject. Next value."""
return self._value
@value.setter
- def value(self, x):
+ def value(self, x):
self.setValue(x)
+
+class Euclide(PyoObject):
+ """
+ Euclidean rhythm generator.
+
+ This object generates euclidean trigger patterns, resulting in onsets
+ in the rhythm to be as equidistant as possible.
+
+ A trigger is an audio signal with a value of 1 surrounded by 0s.
+
+ The play() method starts the Euclide and is not called at the object
+ creation time.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ time : float or PyoObject, optional
+ Time, in seconds, between each beat of the pattern. Defaults to 0.125.
+ taps : int, optional
+ Number of beats in the generated pattern (measure length), max = 64.
+ Defaults to 16.
+ onsets : int, optional
+ Number of onsets (a positive tap) in the generated pattern.
+ Defaults to 10.
+ poly : int, optional
+ Beat polyphony. Denotes how many independent streams are
+ generated by the object, allowing overlapping processes.
+
+ Available only at initialization. Defaults to 1.
+
+ .. note::
+
+ Euclide outputs many signals identified with a string between brackets:
+
+ | obj['tap'] returns audio stream of the current tap of the measure.
+ | obj['amp'] returns audio stream of the current beat amplitude.
+ | obj['dur'] returns audio stream of the current beat duration in seconds.
+ | obj['end'] returns audio stream with a trigger just before the end of the measure.
+
+ obj without brackets returns the generated trigger stream of the measure.
+
+ The out() method is bypassed. Euclide's signal can not be sent to audio outs.
+
+ Euclide has no `mul` and `add` attributes.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> t = CosTable([(0,0), (100,1), (500,.3), (8191,0)])
+ >>> beat = Euclide(time=.125, taps=16, onsets=[8,7], poly=1).play()
+ >>> trmid = TrigXnoiseMidi(beat, dist=12, mrange=(60, 96))
+ >>> trhz = Snap(trmid, choice=[0,2,3,5,7,8,10], scale=1)
+ >>> tr2 = TrigEnv(beat, table=t, dur=beat['dur'], mul=beat['amp'])
+ >>> a = Sine(freq=trhz, mul=tr2*0.3).out()
+
+ """
+ def __init__(self, time=.125, taps=16, onsets=10, poly=1):
+ pyoArgsAssert(self, "OiiI", time, taps, onsets, poly)
+ PyoObject.__init__(self)
+ self._tap_dummy = []
+ self._amp_dummy = []
+ self._dur_dummy = []
+ self._end_dummy = []
+ self._time = time
+ self._taps = taps
+ self._onsets = onsets
+ self._poly = poly
+ time, taps, onsets, lmax = convertArgsToLists(time, taps, onsets)
+ self._base_players = [Beater_base(wrap(time,i), wrap(taps,i), wrap([100]*lmax,i), poly) for i in range(lmax)]
+ self._base_objs = [Beat_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+ self._tap_objs = [BeatTapStream_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+ self._amp_objs = [BeatAmpStream_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+ self._dur_objs = [BeatDurStream_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+ self._end_objs = [BeatEndStream_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+ for i in range(lmax):
+ preset = [wrap(taps,i)] + self.__generate__(wrap(onsets,i), wrap(taps,i))
+ self._base_players[i].setPresets([preset])
+ self._base_players[i].recall(0)
+
+ def __generate__(self, m, k):
+ """
+ Generates the euclidean rhythm for `m` onsets
+ in a measure of length `k` (number of taps).
+ Looping implementation, faster than recursive.
+ """
+ if m > k: m = k
+ k -= m
+ mv, kv = [1], [0]
+ while k > 1:
+ if m > k:
+ m, k = k, m-k
+ mv, kv = mv+kv, mv
+ else:
+ m, k = m, k-m
+ mv, kv = mv+kv, kv
+ return mv * m + kv * k
+
+ def __getitem__(self, i):
+ if i == 'tap':
+ self._tap_dummy.append(Dummy([obj for obj in self._tap_objs]))
+ return self._tap_dummy[-1]
+ if i == 'amp':
+ self._amp_dummy.append(Dummy([obj for obj in self._amp_objs]))
+ return self._amp_dummy[-1]
+ if i == 'dur':
+ self._dur_dummy.append(Dummy([obj for obj in self._dur_objs]))
+ return self._dur_dummy[-1]
+ if i == 'end':
+ self._end_dummy.append(Dummy([obj for obj in self._end_objs]))
+ return self._end_dummy[-1]
+ if type(i) == SliceType:
+ return self._base_objs[i]
+ if i < len(self._base_objs):
+ return self._base_objs[i]
+ else:
+ print "'i' too large!"
+
+ def get(self, identifier="amp", all=False):
+ """
+ Return the first sample of the current buffer as a float.
+
+ Can be used to convert audio stream to usable Python data.
+
+ "tap", "amp" or "dur" must be given to `identifier` to specify
+ which stream to get value from.
+
+ :Args:
+
+ identifier : string {"tap", "amp", "dur"}
+ Address string parameter identifying audio stream.
+ Defaults to "amp".
+ all : boolean, optional
+ If True, the first value of each object's stream
+ will be returned as a list.
+
+ If False, only the value of the first object's
+ stream will be returned as a float.
+
+ """
+ if not all:
+ return self.__getitem__(identifier)[0]._getStream().getValue()
+ else:
+ return [obj._getStream().getValue() for obj in self.__getitem__(identifier).getBaseObjects()]
+
+ def setTime(self, x):
+ """
+ Replace the `time` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ New `time` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._time = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setTime(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setTaps(self, x):
+ """
+ Replace the `taps` attribute.
+
+ :Args:
+
+ x : int
+ New `taps` attribute.
+
+ """
+ pyoArgsAssert(self, "i", x)
+ self._taps = x
+ x, onsets, lmax = convertArgsToLists(x, self._onsets)
+ for i in range(len(self._base_players)):
+ preset = [wrap(x,i)] + self.__generate__(wrap(onsets,i), wrap(x,i))
+ self._base_players[i].setPresets([preset])
+ self._base_players[i].recall(0)
+
+ def setOnsets(self, x):
+ """
+ Replace the `onsets` attribute.
+
+ :Args:
+
+ x : int
+ New `onsets` attribute.
+
+ """
+ pyoArgsAssert(self, "i", x)
+ self._onsets = x
+ x, taps, lmax = convertArgsToLists(x, self._taps)
+ for i in range(len(self._base_players)):
+ preset = [wrap(taps,i)] + self.__generate__(wrap(x,i), wrap(taps,i))
+ self._base_players[i].setPresets([preset])
+ self._base_players[i].recall(0)
+
+ def reset(self):
+ """
+ Reset internal counters to initialization values.
+
+ """
+ [obj.reset() for obj in self._base_players]
+
+ def play(self, dur=0, delay=0):
+ dur, delay, lmax = convertArgsToLists(dur, delay)
+ self._tap_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._tap_objs)]
+ self._amp_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._amp_objs)]
+ self._dur_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._dur_objs)]
+ self._end_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._end_objs)]
+ return PyoObject.play(self, dur, delay)
+
+ def stop(self):
+ [obj.stop() for obj in self._tap_objs]
+ [obj.stop() for obj in self._amp_objs]
+ [obj.stop() for obj in self._dur_objs]
+ [obj.stop() for obj in self._end_objs]
+ return PyoObject.stop(self)
+
+ def out(self, chnl=0, inc=1, dur=0, delay=0):
+ return self.play(dur, delay)
+
+ def setMul(self, x):
+ pass
+
+ def setAdd(self, x):
+ pass
+
+ def setSub(self, x):
+ pass
+
+ def setDiv(self, x):
+ pass
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = [SLMap(0.01, 1., 'lin', 'time', self._time),
+ SLMap(2, 64, 'lin', 'taps', self._taps, res="int", dataOnly=True),
+ SLMap(0, 64, 'lin', 'onsets', self._onsets, res="int", dataOnly=True)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def time(self):
+ """float or PyoObject. Time, in seconds, between each beat."""
+ return self._time
+ @time.setter
+ def time(self, x): self.setTime(x)
+
+ @property
+ def taps(self):
+ """int. Number of beats in the generated pattern."""
+ return self._taps
+ @taps.setter
+ def taps(self, x): self.setTaps(x)
+
+ @property
+ def onsets(self):
+ """int. Number of onsets in the generated pattern."""
+ return self._onsets
+ @onsets.setter
+ def onsets(self, x): self.setOnsets(x)
+
+class TrigBurst(PyoObject):
+ """
+ Generates a time/amplitude expandable trigger pattern.
+
+ A trigger is an audio signal with a value of 1 surrounded by 0s.
+
+ When TrigBurst receives a trigger in its `input` argument, it starts
+ to output `count` triggers with a variable delay between each trigger
+ of the pattern. If `expand` is less than 1.0, the delay becomes shorter,
+ if it is greater than 1.0, the delay becomes longer.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal sending triggers.
+ time : float or PyoObject, optional
+ Base time, in seconds, between each trig of the serie. Defaults to 0.25.
+ count : int, optional
+ Number of trigs generated (length of the serie). Defaults to 10.
+ expand : float, optional
+ Timing power serie factor. Each delay before the next trig is the
+ current delay (starting with `time`) times `expand` factor. Defaults to 1.0.
+ ampfade : float, optional
+ Amplitude power serie factor. Each amplitude in the serie is the
+ current amplitude (starting at 1) times `ampfade` factor. Defaults to 1.0.
+ poly : int, optional
+ Voice polyphony. Denotes how many independent streams are
+ generated by the object, allowing overlapping processes.
+
+ Available only at initialization. Defaults to 1.
+
+ .. note::
+
+ TrigBurst outputs many signals identified with a string between brackets:
+
+ | obj['tap'] returns audio stream of the current tap of the serie.
+ | obj['amp'] returns audio stream of the current beat amplitude.
+ | obj['dur'] returns audio stream of the current beat duration in seconds.
+ | obj['end'] returns audio stream with a trigger just before the end of the serie.
+
+ obj without brackets returns the generated trigger stream of the serie.
+
+ The out() method is bypassed. TrigBurst's signal can not be sent to audio outs.
+
+ TrigBurst has no `mul` and `add` attributes.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> env = CosTable([(0,0), (100,0.5), (500, 0.3), (4096,0.3), (8192,0)])
+ >>> m = Metro(2).play()
+ >>> tb = TrigBurst(m, time=0.15, count=[15,20], expand=[0.92,0.9], ampfade=0.85)
+ >>> amp = TrigEnv(tb, env, dur=tb["dur"], mul=tb["amp"]*0.3)
+ >>> a = Sine([800,600], mul=amp)
+ >>> rev = STRev(a, inpos=[0,1], revtime=1.5, cutoff=5000, bal=0.1).out()
+
+ """
+ def __init__(self, input, time=.25, count=10, expand=1.0, ampfade=1.0, poly=1):
+ pyoArgsAssert(self, "oOinnI", input, time, count, expand, ampfade, poly)
+ PyoObject.__init__(self)
+ self._tap_dummy = []
+ self._amp_dummy = []
+ self._dur_dummy = []
+ self._end_dummy = []
+ self._input = input
+ self._time = time
+ self._count = count
+ self._expand = expand
+ self._ampfade = ampfade
+ self._poly = poly
+ self._in_fader = InputFader(input)
+ in_fader, time, count, expand, ampfade, lmax = convertArgsToLists(self._in_fader, time, count, expand, ampfade)
+ self._base_players = [TrigBurster_base(wrap(in_fader,i), wrap(time,i), wrap(count,i), wrap(expand,i), wrap(ampfade,i), poly) for i in range(lmax)]
+ self._base_objs = [TrigBurst_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+ self._tap_objs = [TrigBurstTapStream_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+ self._amp_objs = [TrigBurstAmpStream_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+ self._dur_objs = [TrigBurstDurStream_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+ self._end_objs = [TrigBurstEndStream_base(wrap(self._base_players,j), i) for i in range(poly) for j in range(lmax)]
+
+ def __getitem__(self, i):
+ if i == 'tap':
+ self._tap_dummy.append(Dummy([obj for obj in self._tap_objs]))
+ return self._tap_dummy[-1]
+ if i == 'amp':
+ self._amp_dummy.append(Dummy([obj for obj in self._amp_objs]))
+ return self._amp_dummy[-1]
+ if i == 'dur':
+ self._dur_dummy.append(Dummy([obj for obj in self._dur_objs]))
+ return self._dur_dummy[-1]
+ if i == 'end':
+ self._end_dummy.append(Dummy([obj for obj in self._end_objs]))
+ return self._end_dummy[-1]
+ if type(i) == SliceType:
+ return self._base_objs[i]
+ if i < len(self._base_objs):
+ return self._base_objs[i]
+ else:
+ print "'i' too large!"
+
+ def get(self, identifier="amp", all=False):
+ """
+ Return the first sample of the current buffer as a float.
+
+ Can be used to convert audio stream to usable Python data.
+
+ "tap", "amp" or "dur" must be given to `identifier` to specify
+ which stream to get value from.
+
+ :Args:
+
+ identifier : string {"tap", "amp", "dur"}
+ Address string parameter identifying audio stream.
+ Defaults to "amp".
+ all : boolean, optional
+ If True, the first value of each object's stream
+ will be returned as a list.
+
+ If False, only the value of the first object's
+ stream will be returned as a float.
+
+ """
+ if not all:
+ return self.__getitem__(identifier)[0]._getStream().getValue()
+ else:
+ return [obj._getStream().getValue() for obj in self.__getitem__(identifier).getBaseObjects()]
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Defaults to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ def setTime(self, x):
+ """
+ Replace the `time` attribute.
+
+ :Args:
+
+ x : float or PyoObject
+ New `time` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._time = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setTime(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setCount(self, x):
+ """
+ Replace the `count` attribute.
+
+ :Args:
+
+ x : int
+ New `count` attribute.
+
+ """
+ pyoArgsAssert(self, "i", x)
+ self._count = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setCount(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setExpand(self, x):
+ """
+ Replace the `expand` attribute.
+
+ :Args:
+
+ x : float
+ New `expand` attribute.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._expand = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setExpand(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def setAmpfade(self, x):
+ """
+ Replace the `ampfade` attribute.
+
+ :Args:
+
+ x : float
+ New `ampfade` attribute.
+
+ """
+ pyoArgsAssert(self, "n", x)
+ self._ampfade = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setAmpfade(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+
+ def play(self, dur=0, delay=0):
+ dur, delay, lmax = convertArgsToLists(dur, delay)
+ self._tap_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._tap_objs)]
+ self._amp_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._amp_objs)]
+ self._dur_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._dur_objs)]
+ self._end_objs = [obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._end_objs)]
+ return PyoObject.play(self, dur, delay)
+
+ def stop(self):
+ [obj.stop() for obj in self._tap_objs]
+ [obj.stop() for obj in self._amp_objs]
+ [obj.stop() for obj in self._dur_objs]
+ [obj.stop() for obj in self._end_objs]
+ return PyoObject.stop(self)
+
+ def out(self, chnl=0, inc=1, dur=0, delay=0):
+ return self.play(dur, delay)
+
+ def setMul(self, x):
+ pass
+
+ def setAdd(self, x):
+ pass
+
+ def setSub(self, x):
+ pass
+
+ def setDiv(self, x):
+ pass
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = [SLMap(0.1, 1., 'lin', 'time', self._time, dataOnly=True),
+ SLMap(2, 128, 'lin', 'count', self._count, res="int", dataOnly=True),
+ SLMap(0.5, 2.0, 'lin', 'expand', self._expand, dataOnly=True),
+ SLMap(0.5, 1.0, 'lin', 'ampfade', self._ampfade, dataOnly=True)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def input(self):
+ """PyoObject. Audio trigger signal."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+ @property
+ def time(self):
+ """float or PyoObject. Base time, in seconds, between each trig."""
+ return self._time
+ @time.setter
+ def time(self, x): self.setTime(x)
+
+ @property
+ def count(self):
+ """int. Number of triggers in the generated serie."""
+ return self._count
+ @count.setter
+ def count(self, x): self.setCount(x)
+
+ @property
+ def expand(self):
+ """float. Time's power expansion factor."""
+ return self._expand
+ @expand.setter
+ def expand(self, x): self.setExpand(x)
+
+ @property
+ def ampfade(self):
+ """float. Amplitude's power expansion factor."""
+ return self._ampfade
+ @ampfade.setter
+ def ampfade(self, x): self.setAmpfade(x)
\ No newline at end of file
diff --git a/pyolib/utils.py b/pyolib/utils.py
index ab68c0a..9cfc841 100644
--- a/pyolib/utils.py
+++ b/pyolib/utils.py
@@ -4,23 +4,23 @@ Miscellaneous objects.
"""
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from _core import *
from _maps import *
@@ -32,11 +32,11 @@ class Clean_objects(threading.Thread):
Stops and deletes PyoObjects after a given time.
The start() method starts the thread timer (must be called).
-
+
:Args:
time : float
- Time, in seconds, to wait before calling stop on the given
+ Time, in seconds, to wait before calling stop on the given
objects and deleting them.
*args : PyoObject(s)
Objects to delete.
@@ -48,20 +48,20 @@ class Clean_objects(threading.Thread):
>>> c = Biquad(a, freq=500, q=2, mul=b).out()
>>> dump = Clean_objects(6, a, b, c)
>>> dump.start()
-
+
"""
def __init__(self, time, *args):
threading.Thread.__init__(self)
self.t = time
self.args = args
-
+
def run(self):
time.sleep(self.t)
for arg in self.args:
try: arg.stop()
except: pass
for arg in self.args:
- del arg
+ del arg
class Print(PyoObject):
"""
@@ -85,7 +85,7 @@ class Print(PyoObject):
.. note::
- The out() method is bypassed. Print's signal can not be sent to
+ The out() method is bypassed. Print's signal can not be sent to
audio outs.
Print has no `mul` and `add` attributes.
@@ -98,6 +98,7 @@ class Print(PyoObject):
"""
def __init__(self, input, method=0, interval=0.25, message=""):
+ pyoArgsAssert(self, "oins", input, method, interval, message)
PyoObject.__init__(self)
self._input = input
self._method = method
@@ -110,7 +111,7 @@ class Print(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -119,19 +120,21 @@ class Print(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setMethod(self, x):
"""
Replace the `method` attribute.
-
+
:Args:
x : int {0, 1}
New `method` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._method = x
x, lmax = convertArgsToLists(x)
[obj.setMethod(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -146,6 +149,7 @@ class Print(PyoObject):
New `interval` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._interval = x
x, lmax = convertArgsToLists(x)
[obj.setInterval(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -160,6 +164,7 @@ class Print(PyoObject):
New `message` attribute.
"""
+ pyoArgsAssert(self, "s", x)
self._message = x
x, lmax = convertArgsToLists(x)
[obj.setMessage(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -169,28 +174,28 @@ class Print(PyoObject):
@property
def input(self):
- """PyoObject. Input signal."""
+ """PyoObject. Input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def method(self):
- """int. Controls when a value is printed."""
+ """int. Controls when a value is printed."""
return self._method
@method.setter
def method(self, x): self.setMethod(x)
@property
def interval(self):
- """float. For method 0, interval, in seconds, between each print."""
+ """float. For method 0, interval, in seconds, between each print."""
return self._interval
@interval.setter
def interval(self, x): self.setInterval(x)
@property
def message(self):
- """str. Message to print before the current value."""
+ """str. Message to print before the current value."""
return self._message
@message.setter
def message(self, x): self.setMessage(x)
@@ -200,11 +205,11 @@ class Snap(PyoObject):
Snap input values on a user's defined midi scale.
Snap takes an audio input of floating-point values from 0
- to 127 and output the nearest value in the `choice` parameter.
- `choice` can be defined on any number of octaves and the real
- snapping values will be automatically expended. The object
- will take care of the input octave range. According to `scale`
- parameter, output can be in midi notes, hertz or transposition
+ to 127 and output the nearest value in the `choice` parameter.
+ `choice` can be defined on any number of octaves and the real
+ snapping values will be automatically expended. The object
+ will take care of the input octave range. According to `scale`
+ parameter, output can be in midi notes, hertz or transposition
factor (centralkey = 60).
:Parent: :py:class:`PyoObject`
@@ -221,7 +226,7 @@ class Snap(PyoObject):
1. Hertz
2. transposition factor
- In the transpo mode, the central key (the key where there
+ In the transpo mode, the central key (the key where there
is no transposition) is 60.
>>> s = Server().boot()
@@ -236,10 +241,8 @@ class Snap(PyoObject):
"""
def __init__(self, input, choice, scale=0, mul=1, add=0):
+ pyoArgsAssert(self, "oliOO", input, choice, scale, mul, add)
PyoObject.__init__(self, mul, add)
- if type(choice) != ListType:
- print >> sys.stderr, 'TypeError: "choice" argument of %s must be a list.\n' % self.__class__.__name__
- exit()
self._input = input
self._choice = choice
self._scale = scale
@@ -255,7 +258,7 @@ class Snap(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -264,27 +267,29 @@ class Snap(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
-
+
def setChoice(self, x):
"""
Replace the `choice` attribute.
-
+
:Args:
x : list of floats
new `choice` attribute.
-
+
"""
+ pyoArgsAssert(self, "l", x)
self._choice = x
[obj.setChoice(x) for i, obj in enumerate(self._base_objs)]
def setScale(self, x):
"""
Replace the `scale` attribute.
-
- Possible values are:
+
+ Possible values are:
0. Midi notes
1. Hertz
2. transposition factor (centralkey = 60)
@@ -295,30 +300,31 @@ class Snap(PyoObject):
new `scale` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._scale = x
x, lmax = convertArgsToLists(x)
[obj.setScale(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def input(self):
+ def input(self):
"""PyoObject. Audio signal to transform."""
return self._input
@input.setter
- def input(self, x):
+ def input(self, x):
self.setInput(x)
@property
- def choice(self):
+ def choice(self):
"""list of floats. Possible values."""
return self._choice
@choice.setter
- def choice(self, x):
+ def choice(self, x):
self.setChoice(x)
@property
- def scale(self):
+ def scale(self):
"""int. Output format."""
return self._scale
@scale.setter
- def scale(self, x):
+ def scale(self, x):
self.setScale(x)
class Interp(PyoObject):
@@ -346,6 +352,7 @@ class Interp(PyoObject):
"""
def __init__(self, input, input2, interp=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "ooOOO", input, input2, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._input2 = input2
@@ -358,7 +365,7 @@ class Interp(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -367,13 +374,14 @@ class Interp(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setInput2(self, x, fadetime=0.05):
"""
Replace the `input2` attribute.
-
+
:Args:
x : PyoObject
@@ -382,19 +390,21 @@ class Interp(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input2 = x
self._in_fader2.setInput(x, fadetime)
-
+
def setInterp(self, x):
"""
Replace the `interp` attribute.
-
+
:Args:
x : float or PyoObject
New `interp` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -402,34 +412,34 @@ class Interp(PyoObject):
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0., 1., "lin", "interp", self._interp), SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
-
+
@property
def input(self):
- """PyoObject. First input signal."""
+ """PyoObject. First input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def input2(self):
- """PyoObject. Second input signal."""
+ """PyoObject. Second input signal."""
return self._input2
@input2.setter
def input2(self, x): self.setInput2(x)
@property
def interp(self):
- """float or PyoObject. Averaging value."""
+ """float or PyoObject. Averaging value."""
return self._interp
@interp.setter
def interp(self, x): self.setInterp(x)
class SampHold(PyoObject):
"""
- Performs a sample-and-hold operation on its input.
+ Performs a sample-and-hold operation on its input.
- SampHold performs a sample-and-hold operation on its input according
- to the value of `controlsig`. If `controlsig` equals `value`, the input
+ SampHold performs a sample-and-hold operation on its input according
+ to the value of `controlsig`. If `controlsig` equals `value`, the input
is sampled and held until next sampling.
:Parent: :py:class:`PyoObject`
@@ -452,6 +462,7 @@ class SampHold(PyoObject):
"""
def __init__(self, input, controlsig, value=0.0, mul=1, add=0):
+ pyoArgsAssert(self, "ooOOO", input, controlsig, value, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._controlsig = controlsig
@@ -464,7 +475,7 @@ class SampHold(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -473,13 +484,14 @@ class SampHold(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setControlsig(self, x, fadetime=0.05):
"""
Replace the `controlsig` attribute.
-
+
:Args:
x : PyoObject
@@ -488,40 +500,42 @@ class SampHold(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._controlsig = x
self._in_fader2.setInput(x, fadetime)
-
+
def setValue(self, x):
"""
Replace the `value` attribute.
-
+
:Args:
x : float or PyoObject
New `value` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._value = x
x, lmax = convertArgsToLists(x)
[obj.setValue(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Input signal."""
+ """PyoObject. Input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def controlsig(self):
- """PyoObject. Control signal."""
+ """PyoObject. Control signal."""
return self._controlsig
@controlsig.setter
def controlsig(self, x): self.setControlsig(x)
@property
def value(self):
- """float or PyoObject. Target value."""
+ """float or PyoObject. Target value."""
return self._value
@value.setter
def value(self, x): self.setValue(x)
@@ -530,7 +544,7 @@ class Record(PyoObject):
"""
Writes input sound in an audio file on the disk.
- `input` parameter must be a valid PyoObject or an addition of
+ `input` parameter must be a valid PyoObject or an addition of
PyoObjects, parameters can't be in list format.
:Parent: :py:class:`PyoObject`
@@ -546,8 +560,8 @@ class Record(PyoObject):
fileformat : int, optional
Format type of the audio file. Defaults to 0.
- Record will first try to set the format from the filename extension.
-
+ Record will first try to set the format from the filename extension.
+
If it's not possible, it uses the fileformat parameter. Supported formats are:
0. WAV - Microsoft WAV format (little endian) {.wav, .wave}
1. AIFF - Apple/SGI AIFF format (big endian) {.aif, .aiff}
@@ -558,8 +572,8 @@ class Record(PyoObject):
6. CAF - Core Audio File format {.caf}
7. OGG - Xiph OGG container {.ogg}
sampletype : int, optional
- Bit depth encoding of the audio file.
-
+ Bit depth encoding of the audio file.
+
SD2 and FLAC only support 16 or 24 bit int. Supported types are:
0. 16 bits int (default)
1. 24 bits int
@@ -570,18 +584,18 @@ class Record(PyoObject):
6. A-Law encoded
buffering : int, optional
Number of bufferSize to wait before writing samples to disk.
-
+
High buffering uses more memory but improves performance.
Defaults to 4.
.. note::
- All parameters can only be set at intialization time.
+ All parameters can only be set at intialization time.
- The stop() method must be called on the object to close the file
+ The stop() method must be called on the object to close the file
properly.
- The out() method is bypassed. Record's signal can not be sent to
+ The out() method is bypassed. Record's signal can not be sent to
audio outs.
Record has no `mul` and `add` attributes.
@@ -601,8 +615,10 @@ class Record(PyoObject):
"""
def __init__(self, input, filename, chnls=2, fileformat=0, sampletype=0, buffering=4):
+ pyoArgsAssert(self, "oSIIII", input, filename, chnls, fileformat, sampletype, buffering)
PyoObject.__init__(self)
self._input = input
+ self._in_fader = InputFader(input)
ext = filename.rsplit('.')
if len(ext) >= 2:
ext = ext[-1].lower()
@@ -612,18 +628,41 @@ class Record(PyoObject):
print 'Warning: Unknown file extension. Using fileformat value.'
else:
print 'Warning: Filename has no extension. Using fileformat value.'
- self._base_objs = [Record_base(self._input.getBaseObjects(), filename, chnls, fileformat, sampletype, buffering)]
+ self._base_objs = [Record_base(self._in_fader.getBaseObjects(), filename, chnls, fileformat, sampletype, buffering)]
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Default to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to filter."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
class Denorm(PyoObject):
"""
Mixes low level noise to an input signal.
- Mixes low level (~1e-24 for floats, and ~1e-60 for doubles) noise to a an input signal.
- Can be used before IIR filters and reverbs to avoid denormalized numbers which may
- otherwise result in significantly increased CPU usage.
+ Mixes low level (~1e-24 for floats, and ~1e-60 for doubles) noise to a an input signal.
+ Can be used before IIR filters and reverbs to avoid denormalized numbers which may
+ otherwise result in significantly increased CPU usage.
:Parent: :py:class:`PyoObject`
@@ -641,6 +680,7 @@ class Denorm(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -659,12 +699,13 @@ class Denorm(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to filter."""
+ """PyoObject. Input signal to filter."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -680,7 +721,7 @@ class ControlRec(PyoObject):
Each line in the text files contains two values, the absolute time
in seconds and the sampled value.
- The play() method starts the recording and is not called at the
+ The play() method starts the recording and is not called at the
object creation time.
:Parent: :py:class:`PyoObject`
@@ -691,35 +732,35 @@ class ControlRec(PyoObject):
Input signal to sample.
filename : string
Full path (without extension) used to create the files.
-
+
"_000" will be added to file's names with increasing digits
- according to the number of streams in input.
-
- The same filename can be passed to a ControlRead object to
+ according to the number of streams in input.
+
+ The same filename can be passed to a ControlRead object to
read all related files.
rate : int, optional
Rate at which the input values are sampled. Defaults to 1000.
dur : float, optional
Duration of the recording, in seconds. If 0.0, the recording
- won't stop until the end of the performance.
-
- If greater than 0.0, the `stop` method is automatically called
+ won't stop until the end of the performance.
+
+ If greater than 0.0, the `stop` method is automatically called
at the end of the recording.
.. note::
- All parameters can only be set at intialization time.
+ All parameters can only be set at intialization time.
- The write() method must be called on the object to write the files
+ The write() method must be called on the object to write the files
on the disk.
- The out() method is bypassed. ControlRec's signal can not be sent to
+ The out() method is bypassed. ControlRec's signal can not be sent to
audio outs.
ControlRec has no `mul` and `add` attributes.
- .. seealso::
-
+ .. seealso::
+
:py:class:`ControlRead`
>>> s = Server().boot()
@@ -736,6 +777,7 @@ class ControlRec(PyoObject):
"""
def __init__(self, input, filename, rate=1000, dur=0.0):
+ pyoArgsAssert(self, "oSIN", input, filename, rate, dur)
PyoObject.__init__(self)
self._input = input
self._filename = filename
@@ -752,7 +794,7 @@ class ControlRec(PyoObject):
def write(self):
"""
Writes recorded values in text files on the disk.
-
+
"""
for i, obj in enumerate(self._base_objs):
f = open(os.path.join(self._path, "%s_%03d" % (self._name, i)), "w")
@@ -770,17 +812,17 @@ class ControlRead(PyoObject):
:Args:
filename : string
- Full path (without extension) used to create the files.
-
- Usually the same filename as the one given to a ControlRec
- object to record automation.
-
+ Full path (without extension) used to create the files.
+
+ Usually the same filename as the one given to a ControlRec
+ object to record automation.
+
The directory will be scaned and all files
named "filename_xxx" will add a new stream in the object.
rate : int, optional
Rate at which the values are sampled. Defaults to 1000.
loop : boolean, optional
- Looping mode, False means off, True means on.
+ Looping mode, False means off, True means on.
Defaults to False.
interp : int, optional
Choice of the interpolation method.
@@ -791,19 +833,19 @@ class ControlRead(PyoObject):
.. note::
- ControlRead will sends a trigger signal at the end of the playback if
- loop is off or any time it wraps around if loop is on. User can
+ ControlRead will sends a trigger signal at the end of the playback if
+ loop is off or any time it wraps around if loop is on. User can
retreive the trigger streams by calling obj['trig']:
>>> rnds = ControlRead(home+"/freq_auto", loop=True)
>>> t = SndTable(SNDS_PATH+"/transparent.aif")
>>> loop = TrigEnv(rnds["trig"], t, dur=[.2,.3,.4,.5], mul=.5).out()
- The out() method is bypassed. ControlRead's signal can not be sent to
+ The out() method is bypassed. ControlRead's signal can not be sent to
audio outs.
- .. seealso::
-
+ .. seealso::
+
:py:class:`ControlRec`
>>> s = Server().boot()
@@ -816,6 +858,7 @@ class ControlRead(PyoObject):
"""
def __init__(self, filename, rate=1000, loop=False, interp=2, mul=1, add=0):
+ pyoArgsAssert(self, "SIBIOO", filename, rate, loop, interp, mul, add)
PyoObject.__init__(self, mul, add)
self._filename = filename
self._path, self._name = os.path.split(filename)
@@ -846,6 +889,7 @@ class ControlRead(PyoObject):
new `rate` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._rate = x
x, lmax = convertArgsToLists(x)
[obj.setRate(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -860,6 +904,7 @@ class ControlRead(PyoObject):
new `loop` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._loop = x
x, lmax = convertArgsToLists(x)
[obj.setLoop(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -874,26 +919,27 @@ class ControlRead(PyoObject):
new `interp` attribute.
"""
+ pyoArgsAssert(self, "i", x)
self._interp = x
x, lmax = convertArgsToLists(x)
[obj.setInterp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def rate(self):
- """int. Sampling frequency in cycles per second."""
+ """int. Sampling frequency in cycles per second."""
return self._rate
@rate.setter
def rate(self, x): self.setRate(x)
@property
- def loop(self):
- """boolean. Looping mode."""
+ def loop(self):
+ """boolean. Looping mode."""
return self._loop
@loop.setter
def loop(self, x): self.setLoop(x)
@property
- def interp(self):
+ def interp(self):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
@@ -910,7 +956,7 @@ class NoteinRec(PyoObject):
Each line in the text files contains three values, the absolute time
in seconds, the Midi pitch and the normalized velocity.
- The play() method starts the recording and is not called at the
+ The play() method starts the recording and is not called at the
object creation time.
:Parent: :py:class:`PyoObject`
@@ -921,27 +967,27 @@ class NoteinRec(PyoObject):
Notein signal to sample.
filename : string
Full path (without extension) used to create the files.
-
+
"_000" will be added to file's names with increasing digits
- according to the number of streams in input.
-
- The same filename can be passed to a NoteinRead object to read
+ according to the number of streams in input.
+
+ The same filename can be passed to a NoteinRead object to read
all related files.
.. note::
- All parameters can only be set at intialization time.
+ All parameters can only be set at intialization time.
- The `write` method must be called on the object to write the files
+ The `write` method must be called on the object to write the files
on the disk.
- The out() method is bypassed. NoteinRec's signal can not be sent to
+ The out() method is bypassed. NoteinRec's signal can not be sent to
audio outs.
NoteinRec has no `mul` and `add` attributes.
- .. seealso::
-
+ .. seealso::
+
:py:class:`NoteinRead`
>>> s = Server().boot()
@@ -953,6 +999,7 @@ class NoteinRec(PyoObject):
"""
def __init__(self, input, filename):
+ pyoArgsAssert(self, "oS", input, filename)
PyoObject.__init__(self)
self._input = input
self._filename = filename
@@ -984,32 +1031,32 @@ class NoteinRead(PyoObject):
:Args:
filename : string
- Full path (without extension) used to create the files.
-
- Usually the same filename as the one given to a NoteinRec
- object to record automation.
-
+ Full path (without extension) used to create the files.
+
+ Usually the same filename as the one given to a NoteinRec
+ object to record automation.
+
The directory will be scaned and all files
named "filename_xxx" will add a new stream in the object.
loop : boolean, optional
- Looping mode, False means off, True means on.
+ Looping mode, False means off, True means on.
Defaults to False.
.. note::
- NoteinRead will sends a trigger signal at the end of the playback if
- loop is off or any time it wraps around if loop is on. User can
+ NoteinRead will sends a trigger signal at the end of the playback if
+ loop is off or any time it wraps around if loop is on. User can
retreive the trigger streams by calling obj['trig']:
>>> notes = NoteinRead(home+"/notes_rec", loop=True)
>>> t = SndTable(SNDS_PATH+"/transparent.aif")
>>> loop = TrigEnv(notes["trig"], t, dur=[.2,.3,.4,.5], mul=.25).out()
- The out() method is bypassed. NoteinRead's signal can not be sent to
+ The out() method is bypassed. NoteinRead's signal can not be sent to
audio outs.
- .. seealso::
-
+ .. seealso::
+
:py:class:`NoteinRec`
>>> s = Server().boot()
@@ -1022,6 +1069,7 @@ class NoteinRead(PyoObject):
"""
def __init__(self, filename, loop=False, mul=1, add=0):
+ pyoArgsAssert(self, "SBOO", filename, loop, mul, add)
PyoObject.__init__(self, mul, add)
self._pitch_dummy = []
self._velocity_dummy = []
@@ -1059,12 +1107,12 @@ class NoteinRead(PyoObject):
def get(self, identifier="pitch", all=False):
"""
Return the first sample of the current buffer as a float.
-
+
Can be used to convert audio stream to usable Python data.
-
+
"pitch" or "velocity" must be given to `identifier` to specify
which stream to get value from.
-
+
:Args:
identifier : string {"pitch", "velocity"}
@@ -1072,11 +1120,11 @@ class NoteinRead(PyoObject):
Defaults to "pitch".
all : boolean, optional
If True, the first value of each object's stream
- will be returned as a list.
-
- If False, only the value of the first object's stream
+ will be returned as a list.
+
+ If False, only the value of the first object's stream
will be returned as a float.
-
+
"""
if not all:
return self.__getitem__(identifier)[0]._getStream().getValue()
@@ -1096,13 +1144,14 @@ class NoteinRead(PyoObject):
new `loop` attribute.
"""
+ pyoArgsAssert(self, "b", x)
self._loop = x
x, lmax = convertArgsToLists(x)
[obj.setLoop(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
- def loop(self):
- """boolean. Looping mode."""
+ def loop(self):
+ """boolean. Looping mode."""
return self._loop
@loop.setter
def loop(self, x): self.setLoop(x)
@@ -1132,6 +1181,7 @@ class DBToA(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -1150,12 +1200,13 @@ class DBToA(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1186,6 +1237,7 @@ class AToDB(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -1204,12 +1256,13 @@ class AToDB(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1218,9 +1271,9 @@ class Scale(PyoObject):
"""
Maps an input range of audio values to an output range.
- Scale maps an input range of audio values to an output range.
- The ranges can be specified with `min` and `max` reversed for
- invert-mapping. If specified, the mapping can also be exponential.
+ Scale maps an input range of audio values to an output range.
+ The ranges can be specified with `min` and `max` reversed for
+ invert-mapping. If specified, the mapping can also be exponential.
:Parent: :py:class:`PyoObject`
@@ -1237,7 +1290,7 @@ class Scale(PyoObject):
outmax : float or PyoObject, optional
Maximum output value. Defaults to 1.
exp : float, optional
- Exponent value, specifies the nature of the scaling curve.
+ Exponent value, specifies the nature of the scaling curve.
Values between 0 and 1 give a reversed curve. Defaults to 1.0.
>>> s = Server().boot()
@@ -1251,6 +1304,7 @@ class Scale(PyoObject):
"""
def __init__(self, input, inmin=0, inmax=1, outmin=0, outmax=1, exp=1, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOOnOO", input, inmin, inmax, outmin, outmax, exp, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._inmin = inmin
@@ -1274,6 +1328,7 @@ class Scale(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1287,6 +1342,7 @@ class Scale(PyoObject):
New `inmin` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._inmin = x
x, lmax = convertArgsToLists(x)
[obj.setInMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1301,6 +1357,7 @@ class Scale(PyoObject):
New `inmax` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._inmax = x
x, lmax = convertArgsToLists(x)
[obj.setInMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1315,6 +1372,7 @@ class Scale(PyoObject):
New `outmin` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._outmin = x
x, lmax = convertArgsToLists(x)
[obj.setOutMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1329,6 +1387,7 @@ class Scale(PyoObject):
New `outmax` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._outmax = x
x, lmax = convertArgsToLists(x)
[obj.setOutMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1343,6 +1402,7 @@ class Scale(PyoObject):
New `exp` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._exp = x
x, lmax = convertArgsToLists(x)
[obj.setExp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1358,28 +1418,28 @@ class Scale(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def inmin(self):
- """float or PyoObject. Minimum input value."""
+ """float or PyoObject. Minimum input value."""
return self._inmin
@inmin.setter
def inmin(self, x): self.setInMin(x)
@property
def inmax(self):
- """float or PyoObject. Maximum input value."""
+ """float or PyoObject. Maximum input value."""
return self._inmax
@inmax.setter
def inmax(self, x): self.setInMax(x)
@property
def outmin(self):
- """float or PyoObject. Minimum output value."""
+ """float or PyoObject. Minimum output value."""
return self._outmin
@outmin.setter
def outmin(self, x): self.setOutMin(x)
@@ -1421,6 +1481,7 @@ class CentsToTranspo(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -1439,12 +1500,13 @@ class CentsToTranspo(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1473,6 +1535,7 @@ class TranspoToCents(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -1491,12 +1554,13 @@ class TranspoToCents(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1505,7 +1569,7 @@ class MToF(PyoObject):
"""
Returns the frequency (Hz) equivalent to a midi note.
- Returns the frequency (Hz) equivalent to a midi note,
+ Returns the frequency (Hz) equivalent to a midi note,
60 = 261.62556530066814 Hz.
:Parent: :py:class:`PyoObject`
@@ -1525,6 +1589,7 @@ class MToF(PyoObject):
"""
def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._in_fader = InputFader(input)
@@ -1543,12 +1608,70 @@ class MToF(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
+ self._input = x
+ self._in_fader.setInput(x, fadetime)
+
+ @property
+ def input(self):
+ """PyoObject. Input signal to process."""
+ return self._input
+ @input.setter
+ def input(self, x): self.setInput(x)
+
+class FToM(PyoObject):
+ """
+ Returns the midi note equivalent to a frequency in Hz.
+
+ Returns the midi note equivalent to a frequency in Hz,
+ 440.0 (hz) = 69.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input : PyoObject
+ Input signal as frequency in Hz.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> lfo = Sine([0.2,0.25], mul=300, add=600)
+ >>> src = SineLoop(freq=lfo, feedback=0.05)
+ >>> hz = Yin(src, minfreq=100, maxfreq=1000, cutoff=500)
+ >>> mid = FToM(hz)
+ >>> fr = Snap(mid, choice=[0,2,5,7,9], scale=1)
+ >>> freq = Port(fr, risetime=0.01, falltime=0.01)
+ >>> syn = SineLoop(freq, feedback=0.05, mul=0.3).out()
+
+ """
+
+ def __init__(self, input, mul=1, add=0):
+ pyoArgsAssert(self, "oOO", input, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._input = input
+ self._in_fader = InputFader(input)
+ in_fader, mul, add, lmax = convertArgsToLists(self._in_fader, mul, add)
+ self._base_objs = [FToM_base(wrap(in_fader,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+
+ def setInput(self, x, fadetime=0.05):
+ """
+ Replace the `input` attribute.
+
+ :Args:
+
+ x : PyoObject
+ New signal to process.
+ fadetime : float, optional
+ Crossfade time between old and new input. Default to 0.05.
+
+ """
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@@ -1567,7 +1690,7 @@ class MToT(PyoObject):
input : PyoObject
Input signal as midi note.
centralkey : float, optional
- The midi note that returns a transposition factor of 1,
+ The midi note that returns a transposition factor of 1,
that is to say no transposition. Defaults to 60.
>>> s = Server().boot()
@@ -1583,6 +1706,7 @@ class MToT(PyoObject):
"""
def __init__(self, input, centralkey=60.0, mul=1, add=0):
+ pyoArgsAssert(self, "onOO", input, centralkey, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._centralkey = centralkey
@@ -1602,6 +1726,7 @@ class MToT(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1615,19 +1740,20 @@ class MToT(PyoObject):
New `centralkey` attribute.
"""
+ pyoArgsAssert(self, "n", x)
self._centralkey = x
x, lmax = convertArgsToLists(x)
[obj.setCentralKey(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def centralkey(self):
- """float. The midi note that returns no transposition."""
+ """float. The midi note that returns no transposition."""
return self._centralkey
@centralkey.setter
def centralkey(self, x): self.setCentralKey(x)
@@ -1659,6 +1785,7 @@ class Between(PyoObject):
"""
def __init__(self, input, min=-1.0, max=1.0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, min, max, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._min = min
@@ -1679,6 +1806,7 @@ class Between(PyoObject):
Crossfade time between old and new input. Defaults to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
@@ -1692,6 +1820,7 @@ class Between(PyoObject):
New `min` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._min = x
x, lmax = convertArgsToLists(x)
[obj.setMin(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1706,6 +1835,7 @@ class Between(PyoObject):
New `max` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._max = x
x, lmax = convertArgsToLists(x)
[obj.setMax(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -1718,31 +1848,31 @@ class Between(PyoObject):
@property
def input(self):
- """PyoObject. Input signal to process."""
+ """PyoObject. Input signal to process."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def min(self):
- """float or PyoObject. Minimum range value."""
+ """float or PyoObject. Minimum range value."""
return self._min
@min.setter
def min(self, x): self.setMin(x)
@property
def max(self):
- """float or PyoObject. Maximum range value."""
+ """float or PyoObject. Maximum range value."""
return self._max
@max.setter
def max(self, x): self.setMax(x)
class TrackHold(PyoObject):
"""
- Performs a track-and-hold operation on its input.
+ Performs a track-and-hold operation on its input.
TrackHold lets pass the signal in `input` without modification but hold
- a sample according to the value of `controlsig`. If `controlsig` equals
+ a sample according to the value of `controlsig`. If `controlsig` equals
`value`, the input is sampled and held, otherwise, it passes thru.
:Parent: :py:class:`PyoObject`
@@ -1765,6 +1895,7 @@ class TrackHold(PyoObject):
"""
def __init__(self, input, controlsig, value=0.0, mul=1, add=0):
+ pyoArgsAssert(self, "ooOOO", input, controlsig, value, mul, add)
PyoObject.__init__(self, mul, add)
self._input = input
self._controlsig = controlsig
@@ -1777,7 +1908,7 @@ class TrackHold(PyoObject):
def setInput(self, x, fadetime=0.05):
"""
Replace the `input` attribute.
-
+
:Args:
x : PyoObject
@@ -1786,13 +1917,14 @@ class TrackHold(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._input = x
self._in_fader.setInput(x, fadetime)
def setControlsig(self, x, fadetime=0.05):
"""
Replace the `controlsig` attribute.
-
+
:Args:
x : PyoObject
@@ -1801,40 +1933,42 @@ class TrackHold(PyoObject):
Crossfade time between old and new input. Default to 0.05.
"""
+ pyoArgsAssert(self, "oN", x, fadetime)
self._controlsig = x
self._in_fader2.setInput(x, fadetime)
-
+
def setValue(self, x):
"""
Replace the `value` attribute.
-
+
:Args:
x : float or PyoObject
New `value` attribute.
"""
+ pyoArgsAssert(self, "O", x)
self._value = x
x, lmax = convertArgsToLists(x)
[obj.setValue(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@property
def input(self):
- """PyoObject. Input signal."""
+ """PyoObject. Input signal."""
return self._input
@input.setter
def input(self, x): self.setInput(x)
@property
def controlsig(self):
- """PyoObject. Control signal."""
+ """PyoObject. Control signal."""
return self._controlsig
@controlsig.setter
def controlsig(self, x): self.setControlsig(x)
@property
def value(self):
- """float or PyoObject. Target value."""
+ """float or PyoObject. Target value."""
return self._value
@value.setter
- def value(self, x): self.setValue(x)
+ def value(self, x): self.setValue(x)
\ No newline at end of file
diff --git a/scripts/compile_win.bat b/scripts/compile_win.bat
index 39bde38..a78f5f7 100644
--- a/scripts/compile_win.bat
+++ b/scripts/compile_win.bat
@@ -1,19 +1,19 @@
-echo off
-
-echo *** Compile for python2.6 ***
-C:\Python26\python.exe setup.py install --use-double
-
-RMDIR /S /Q build
-
-echo *** Compile for python2.7 ***
-C:\Python27\python.exe setup.py install --use-double
-
-RMDIR /S /Q build
-
-cd utils
-
-echo *** Build E-Pyo for python2.6 ***
-C:\Python26\python.exe epyo_builder_win32.py
-
-echo *** Build E-Pyo for python2.7 ***
-C:\Python27\python.exe epyo_builder_win32.py
+echo off
+
+echo *** Compile for python2.6 ***
+C:\Python26\python.exe setup.py install --use-double
+
+RMDIR /S /Q build
+
+echo *** Compile for python2.7 ***
+C:\Python27\python.exe setup.py install --use-double
+
+RMDIR /S /Q build
+
+cd utils
+
+echo *** Build E-Pyo for python2.6 ***
+C:\Python26\python.exe epyo_builder_win32.py
+
+echo *** Build E-Pyo for python2.7 ***
+C:\Python27\python.exe epyo_builder_win32.py
diff --git a/scripts/html_man.py b/scripts/html_man.py
index a127f07..ba0c575 100644
--- a/scripts/html_man.py
+++ b/scripts/html_man.py
@@ -1,22 +1,21 @@
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+GNU Lesser General Public License for more details.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
import os, inspect, shutil
from types import ListType
diff --git a/scripts/radiopyo-template.py b/scripts/radiopyo-template.py
new file mode 100644
index 0000000..bb07eec
--- /dev/null
+++ b/scripts/radiopyo-template.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+Template for a RadioPyo song (version 1.0).
+
+A RadioPyo song is a musical python script using the python-pyo
+module to create the audio processing chain. You can connect to
+the radio here : http://radiopyo.acaia.ca/
+
+There is only a few rules:
+ 1 - It must be a one-page script.
+ 2 - No soundfile, only synthesis.
+ 3 - The script must be finite in time, with fade-in and fade-out
+ to avoid clicks between pieces. Use the DURATION variable.
+
+belangeo - 2014
+
+"""
+from pyo import *
+
+################### USER-DEFINED VARIABLES ###################
+### READY is used to manage the server behaviour depending ###
+### of the context. Set this variable to True when the ###
+### music is ready for the radio. TITLE and ARTIST are the ###
+### infos shown by the radio player. DURATION set the ###
+### duration of the audio file generated for the streaming.###
+##############################################################
+READY = False # Set to True when ready for the radio
+TITLE = "Song Title" # The title of the music
+ARTIST = "Artist Name" # Your artist name
+DURATION = 300 # The duration of the music in seconds
+##################### These are optional #####################
+GENRE = "Electronic" # Kind of your music, if there is any
+DATE = 2014 # Year of creation
+
+####################### SERVER CREATION ######################
+if READY:
+ s = Server(duplex=0, audio="offline").boot()
+ s.recordOptions(dur=DURATION, filename="radiopyo.ogg", fileformat=7)
+else:
+ s = Server(duplex=0).boot()
+
+
+##################### PROCESSING SECTION #####################
+# global volume (should be used to control the overall sound)
+fade = Fader(fadein=0.001, fadeout=10, dur=DURATION).play()
+
+
+###
+### Insert your algorithms here...
+###
+
+
+#################### START THE PROCESSING ###################
+s.start()
+if not READY:
+ s.gui(locals())
diff --git a/scripts/release_doc_src.sh b/scripts/release_doc_src.sh
index 2c2f029..0c9caa2 100644
--- a/scripts/release_doc_src.sh
+++ b/scripts/release_doc_src.sh
@@ -6,7 +6,7 @@
# 3. Execute from pyo folder : ./scripts/release_doc_src.sh
#
-version=0.6.9
+version=0.7.6
replace=XXX
doc_rep=pyo_XXX-doc
diff --git a/scripts/win/windows-build-routine.txt b/scripts/win/windows-7-build-routine.txt
similarity index 90%
copy from scripts/win/windows-build-routine.txt
copy to scripts/win/windows-7-build-routine.txt
index 2cac5e2..84e74ec 100644
--- a/scripts/win/windows-build-routine.txt
+++ b/scripts/win/windows-7-build-routine.txt
@@ -1,16 +1,17 @@
=== STEP 1 ===
---- Install Python (2.5 -> 2.7)
+--- Install Python 2.6 and 2.7.10 and WxPython 3.0.2.0 for each version
-=== STEP 2 ===
---- Install Slick SVN (Slick-Subversion-1.6.12-win32.msi)
-http://www.sliksvn.com/pub/Slik-Subversion-1.6.12-win32.msi
+=== STEP 2 (should be git soon) ===
+--- Install Slick SVN 1.8.10
+http://www.sliksvn.com
=== STEP 3 ===
---- Install scons 2.2.0 in the Python site-packages:
+--- Install scons 2.3.5 in the Python site-packages:
http://www.scons.org/download.php
=== STEP 4 ===
---- Install MinGW (minimalist) from sourceforge
+--- Install MinGW (minimalist GNU for Windows) from sourceforge
+--- Add ";C:\MinGW\bin;C:\MinGW\mingw32\bin" to the PATH variable
=== STEP 5 ===
--- Install pthreads (just copy files from ftp):
@@ -25,6 +26,9 @@ Do not build from sources.
=== STEP 7 ===
--- Update liblo tag 0.26 from the tarball at http://liblo.sourceforge.net (not SVN!),
copy build/config-msvc.h --> src/config.h,
+
+If there is a conflict about struct timespec, remove the definition in pthread.h.
+
and build with this SConstruct:
# S C O N S T R U C T F O R L I B L O . D L L
@@ -81,7 +85,7 @@ Try the trunk version first, if that doesn't work use the most recent tag.
--- Copy ASIOSDK to portaudio/src/hostapi/asio
--- Check the pa_win_hostapis.c file and make sure that it is configured to build
-the DirectSound, WMME, and ASIO drivers:
+the DirectSound, WMME, and ASIO drivers. (nothing to do here)
--- Need to removed "volatile" from function definitions in MinGW/include/winbase.h
@@ -120,7 +124,7 @@ commonEnvironment.Append(CPPPATH = [".", "src/common", "src/hostapi", "src/os",
"C:/portaudio/src/hostapi/asio/ASIOSDK/host",
"C:/portaudio/src/hostapi/asio/ASIOSDK/host/pc",
"C:/portaudio/src/hostapi/asio/ASIOSDK/common",
-"C:/Program Files/Microsoft DirectX SDK (April 2007)/Include"])
+"C:/Program Files (x86)/Microsoft DirectX SDK (April 2007)/Include"])
commonEnvironment.Append(LIBS=Split('''
setupapi
@@ -175,7 +179,7 @@ portAudio = commonEnvironment.SharedLibrary('portaudio', portAudioSources)
##########################################################################
=== STEP 11 ===
-4 --- Update the PortMidi library http://portmedia.sourceforge.net from SVN and build it with this SConstruct:
+--- Update the PortMidi library http://portmedia.sourceforge.net from SVN and build it with this SConstruct:
'''
MinGW SConstruct for PortMidi
@@ -259,8 +263,6 @@ Depends(test, portmidi)
[build]
compiler = mingw32
-*** For Python 2.5, comment line 428 to 434 in Python25/include/pyconfig.py
-
=== STEP 13 ===
--- Download pyo sources from svn and build it with:
diff --git a/setup.py b/setup.py
index 1777d95..2f2c75f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,29 +1,29 @@
# -*- coding: utf-8 -*-
"""
-Copyright 2010 Olivier Belanger
+Copyright 2009-2015 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
pyo 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 3 of the License, or
-(at your option) any later version.
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
pyo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with pyo. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU Lesser General Public
+License along with pyo. If not, see <http://www.gnu.org/licenses/>.
"""
from distutils.core import setup, Extension
import os, sys, getopt
import time
-pyo_version = "0.6.9"
+pyo_version = "0.7.6"
build_osx_with_jack_support = False
compile_externals = False
@@ -62,17 +62,20 @@ if '--compile-externals' in sys.argv:
sys.argv.remove('--compile-externals')
macros.append(('COMPILE_EXTERNALS',None))
+if sys.platform == "darwin":
+ macros.append(('_OSX_', None))
+
path = 'src/engine/'
files = ['pyomodule.c', 'servermodule.c', 'pvstreammodule.c', 'streammodule.c', 'dummymodule.c',
'mixmodule.c', 'inputfadermodule.c', 'interpolation.c', 'fft.c', "wind.c"]
source_files = [path + f for f in files]
path = 'src/objects/'
-files = ['tablemodule.c', 'wgverbmodule.c', 'freeverbmodule.c', 'phasevocmodule.c', 'fftmodule.c',
+files = ['granulatormodule.c', 'tablemodule.c', 'wgverbmodule.c', 'freeverbmodule.c', 'phasevocmodule.c', 'fftmodule.c',
'oscilmodule.c', 'randommodule.c', 'oscmodule.c','analysismodule.c',
'sfplayermodule.c', 'oscbankmodule.c', 'lfomodule.c',
'matrixmodule.c', 'filtremodule.c', 'noisemodule.c', 'distomodule.c',
- 'inputmodule.c', 'fadermodule.c', 'midimodule.c', 'delaymodule.c','recordmodule.c', 'granulatormodule.c',
+ 'inputmodule.c', 'fadermodule.c', 'midimodule.c', 'delaymodule.c','recordmodule.c',
'metromodule.c', 'trigmodule.c', 'patternmodule.c', 'bandsplitmodule.c', 'hilbertmodule.c', 'panmodule.c',
'selectmodule.c', 'compressmodule.c', 'utilsmodule.c',
'convolvemodule.c', 'arithmeticmodule.c', 'sigmodule.c',
@@ -85,10 +88,10 @@ else:
# Platform-specific build settings for the pyo extension(s).
if sys.platform == "win32":
- include_dirs = ['C:\portaudio\include', 'C:\Program Files\Mega-Nerd\libsndfile\include',
+ include_dirs = ['C:\portaudio\include', 'C:\Program Files (x86)\Mega-Nerd\libsndfile\include',
'C:\portmidi\pm_common', 'C:\liblo', 'C:\pthreads\include', 'include',
'C:\portmidi\porttime']
- library_dirs = ['C:\portaudio', 'C:/Program Files/Mega-Nerd/libsndfile/bin', 'C:\portmidi', 'C:\liblo', 'C:\pthreads\lib']
+ library_dirs = ['C:\portaudio', 'C:/Program Files (x86)/Mega-Nerd/libsndfile/bin', 'C:\portmidi', 'C:\liblo', 'C:\pthreads\lib']
libraries = ['portaudio', 'portmidi', 'porttime', 'libsndfile-1', 'lo', 'pthreadVC2']
else:
tsrt = time.strftime('"%d %b %Y %H:%M:%S"', time.localtime())
@@ -104,7 +107,7 @@ else:
extensions = []
for extension_name, extra_macros in zip(extension_names, extra_macros_per_extension):
extensions.append(Extension(extension_name, source_files, include_dirs=include_dirs, library_dirs=library_dirs,
- libraries=libraries, extra_compile_args=['-Wno-strict-prototypes', '-O3'],
+ libraries=libraries, extra_compile_args=['-Wno-strict-prototypes', '-O3', '-Wno-strict-aliasing'],
define_macros=macros + extra_macros))
if compile_externals:
diff --git a/src/engine/dummymodule.c b/src/engine/dummymodule.c
index f2bcdc5..1aeaa31 100644
--- a/src/engine/dummymodule.c
+++ b/src/engine/dummymodule.c
@@ -1,22 +1,22 @@
-/*************************************************************************
-* Copyright 2010 Olivier Belanger *
-* *
-* This file is part of pyo, a python module to help digital signal *
-* processing script creation. *
-* *
-* pyo 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 3 of the License, or *
-* (at your option) any later version. *
-* *
-* pyo is distributed in the hope that it will be useful, *
-* but WITHOUT ANY WARRANTY; without even the implied warranty of *
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-* GNU General Public License for more details. *
-* *
-* You should have received a copy of the GNU General Public License *
-* along with pyo. If not, see <http://www.gnu.org/licenses/>. *
-*************************************************************************/
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
+ * This file is part of pyo, a python module to help digital signal *
+ * processing script creation. *
+ * *
+ * pyo is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * pyo is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
#include <Python.h>
#include "structmember.h"
@@ -43,31 +43,31 @@ Dummy_setProcMode(Dummy *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Dummy_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Dummy_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Dummy_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Dummy_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Dummy_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Dummy_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Dummy_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Dummy_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Dummy_postprocessing_revareva;
break;
}
@@ -80,7 +80,7 @@ Dummy_compute_next_data_frame(Dummy *self)
MYFLT *in = Stream_getData((Stream *)self->input_stream);
for (i=0; i<self->bufsize; i++) {
self->data[i] = in[i];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -93,7 +93,7 @@ Dummy_traverse(Dummy *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Dummy_clear(Dummy *self)
{
pyo_CLEAR
@@ -110,21 +110,21 @@ Dummy_dealloc(Dummy* self)
self->ob_type->tp_free((PyObject*)self);
}
-PyObject *
+PyObject *
Dummy_initialize(Dummy *self)
{
int i;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Dummy_compute_next_data_frame);
self->mode_func_ptr = Dummy_setProcMode;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Stream_setStreamActive(self->stream, 1);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -146,17 +146,17 @@ Dummy_setInput(Dummy *self, PyObject *arg)
(*self->mode_func_ptr)(self);
Dummy_compute_next_data_frame(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject * Dummy_getServer(Dummy* self) { GET_SERVER };
static PyObject * Dummy_getStream(Dummy* self) { GET_STREAM };
-static PyObject * Dummy_setMul(Dummy *self, PyObject *arg) { SET_MUL };
-static PyObject * Dummy_setAdd(Dummy *self, PyObject *arg) { SET_ADD };
-static PyObject * Dummy_setSub(Dummy *self, PyObject *arg) { SET_SUB };
-static PyObject * Dummy_setDiv(Dummy *self, PyObject *arg) { SET_DIV };
+static PyObject * Dummy_setMul(Dummy *self, PyObject *arg) { SET_MUL };
+static PyObject * Dummy_setAdd(Dummy *self, PyObject *arg) { SET_ADD };
+static PyObject * Dummy_setSub(Dummy *self, PyObject *arg) { SET_SUB };
+static PyObject * Dummy_setDiv(Dummy *self, PyObject *arg) { SET_DIV };
static PyObject * Dummy_play(Dummy *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Dummy_out(Dummy *self, PyObject *args, PyObject *kwds) { OUT };
@@ -302,36 +302,36 @@ static void
TriggerDummy_setProcMode(TriggerDummy *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TriggerDummy_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TriggerDummy_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TriggerDummy_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TriggerDummy_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TriggerDummy_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TriggerDummy_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TriggerDummy_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TriggerDummy_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TriggerDummy_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -341,7 +341,7 @@ TriggerDummy_compute_next_data_frame(TriggerDummy *self)
MYFLT *tmp = TriggerStream_getData((TriggerStream *)self->input_stream);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -354,11 +354,11 @@ TriggerDummy_traverse(TriggerDummy *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
TriggerDummy_clear(TriggerDummy *self)
{
pyo_CLEAR
- Py_CLEAR(self->input);
+ Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
return 0;
}
@@ -378,34 +378,34 @@ TriggerDummy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp;
TriggerDummy *self;
self = (TriggerDummy *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TriggerDummy_compute_next_data_frame);
self->mode_func_ptr = TriggerDummy_setProcMode;
static char *kwlist[] = {"input", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &inputtmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_TRIGGER_STREAM
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * TriggerDummy_getServer(TriggerDummy* self) { GET_SERVER };
static PyObject * TriggerDummy_getStream(TriggerDummy* self) { GET_STREAM };
-static PyObject * TriggerDummy_setMul(TriggerDummy *self, PyObject *arg) { SET_MUL };
-static PyObject * TriggerDummy_setAdd(TriggerDummy *self, PyObject *arg) { SET_ADD };
-static PyObject * TriggerDummy_setSub(TriggerDummy *self, PyObject *arg) { SET_SUB };
-static PyObject * TriggerDummy_setDiv(TriggerDummy *self, PyObject *arg) { SET_DIV };
+static PyObject * TriggerDummy_setMul(TriggerDummy *self, PyObject *arg) { SET_MUL };
+static PyObject * TriggerDummy_setAdd(TriggerDummy *self, PyObject *arg) { SET_ADD };
+static PyObject * TriggerDummy_setSub(TriggerDummy *self, PyObject *arg) { SET_SUB };
+static PyObject * TriggerDummy_setDiv(TriggerDummy *self, PyObject *arg) { SET_DIV };
static PyObject * TriggerDummy_play(TriggerDummy *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TriggerDummy_stop(TriggerDummy *self) { STOP };
@@ -435,7 +435,7 @@ static PyMethodDef TriggerDummy_methods[] = {
{"setMul", (PyCFunction)TriggerDummy_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)TriggerDummy_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)TriggerDummy_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)TriggerDummy_setDiv, METH_O, "Sets inverse mul factor."},
+ {"setDiv", (PyCFunction)TriggerDummy_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
static PyNumberMethods TriggerDummy_as_number = {
@@ -520,4 +520,4 @@ PyTypeObject TriggerDummyType = {
0, /* tp_init */
0, /* tp_alloc */
TriggerDummy_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/engine/fft.c b/src/engine/fft.c
index dcaaff3..ebd8530 100644
--- a/src/engine/fft.c
+++ b/src/engine/fft.c
@@ -1,14 +1,33 @@
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
+ * This file is part of pyo, a python module to help digital signal *
+ * processing script creation. *
+ * *
+ * pyo is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * pyo is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
/******************************************************
** FFT library
**
-** (one-dimensional complex and real FFTs for array
+** (one-dimensional complex and real FFTs for array
** lengths of 2^n)
**
** Author: Toth Laszlo (tothl at inf.u-szeged.hu)
-**
+**
** Research Group on Artificial Intelligence
** H-6720 Szeged, Aradi vertanuk tere 1, Hungary
-**
+**
** Last modified: 97.05.29
**
** Modified by belangeo 2011.05.25
@@ -55,12 +74,12 @@ void fft_compute_radix2_twiddle(MYFLT *twiddle, int size) {
** Sorensen in-place split-radix FFT for real values
** data: array of doubles:
** re(0),re(1),re(2),...,re(size-1)
-**
+**
** output:
** re(0),re(1),re(2),...,re(size/2),im(size/2-1),...,im(1)
** normalized by array length
**
-** Source:
+** Source:
** Sorensen et al: Real-Valued Fast Fourier Transform Algorithms,
** IEEE Trans. ASSP, ASSP-35, No. 6, June 1987
**************************************************************** */
@@ -83,16 +102,16 @@ void realfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
k = n2;
while (k<=j){
j -= k;
- k >>= 1;
+ k >>= 1;
}
j += k;
}
-
+
/* length two butterflies */
i0 = 0;
id = 4;
do {
- for (; i0<n4; i0+=id){
+ for (; i0<n4; i0+=id){
i1 = i0 + 1;
t1 = data[i0];
data[i0] = t1 + data[i1];
@@ -105,14 +124,14 @@ void realfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
/* L shaped butterflies */
n2 = 2;
- for(k=n; k>2; k>>=1) {
+ for(k=n; k>2; k>>=1) {
n2 <<= 1; /* power of two from 4 to n */
n4 = n2 >> 2;
n8 = n2 >> 3;
pas = n / n2;
i1 = 0;
id = n2 << 1;
- do {
+ do {
for (; i1<n; i1+=id){
i2 = i1 + n4;
i3 = i2 + n4;
@@ -138,16 +157,16 @@ void realfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
i1 = id - n2;
id <<= 1;
} while ( i1<n );
- for (j=2; j<=n8; j++){
+ for (j=2; j<=n8; j++){
pos = (j-1) * pas;
cc1 = twiddle[0][pos];
ss1 = twiddle[1][pos];
cc3 = twiddle[2][pos];
- ss3 = twiddle[3][pos];
+ ss3 = twiddle[3][pos];
i = 0;
id = n2 << 1;
do {
- for (; i<n; i+=id){
+ for (; i<n; i+=id){
i1 = i + j - 1;
i2 = i1 + n4;
i3 = i2 + n4;
@@ -185,7 +204,7 @@ void realfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
}
/* division with array length */
- for(i=0; i<n; i++)
+ for(i=0; i<n; i++)
outdata[i] = data[i] / n;
}
@@ -193,12 +212,12 @@ void realfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
** Sorensen in-place inverse split-radix FFT for real values
** data: array of doubles:
** re(0),re(1),re(2),...,re(size/2),im(size/2-1),...,im(1)
-**
+**
** output:
** re(0),re(1),re(2),...,re(size-1)
** NOT normalized by array length
**
-** Source:
+** Source:
** Sorensen et al: Real-Valued Fast Fourier Transform Algorithms,
** IEEE Trans. ASSP, ASSP-35, No. 6, June 1987
****************************************************************** */
@@ -208,19 +227,19 @@ void irealfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
int i,j,k,i5,i6,i7,i8,i0,id,i1,i2,i3,i4,n2,n4,n8,n1;
int pas, pos;
MYFLT t1,t2,t3,t4,t5,ss1,ss3,cc1,cc3,sqrt2;
-
+
sqrt2 = 1.4142135623730951; /* sqrt(2.0) */
-
+
n1 = n - 1;
n2 = n << 1;
- for(k=n; k>2; k>>=1) {
+ for(k=n; k>2; k>>=1) {
id = n2;
n2 >>= 1;
n4 = n2 >> 2;
n8 = n2 >> 3;
pas = n / n2;
i1 = 0;
- do {
+ do {
for (; i1<n; i1+=id) {
i2 = i1 + n4;
i3 = i2 + n4;
@@ -247,7 +266,7 @@ void irealfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
i1 = id - n2;
id <<= 1;
} while ( i1<n1 );
- for (j=2; j<=n8; j++) {
+ for (j=2; j<=n8; j++) {
pos = (j-1) * pas;
cc1 = twiddle[0][pos];
ss1 = twiddle[1][pos];
@@ -256,7 +275,7 @@ void irealfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
i = 0;
id = n2 << 1;
do {
- for (; i<n; i+=id) {
+ for (; i<n; i+=id) {
i1 = i + j - 1;
i2 = i1 + n4;
i3 = i2 + n4;
@@ -287,13 +306,13 @@ void irealfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
id <<= 1;
} while(i<n1);
}
- }
+ }
/*----------------------*/
i0 = 0;
id = 4;
do {
- for (; i0<n1; i0+=id) {
+ for (; i0<n1; i0+=id) {
i1 = i0 + 1;
t1 = data[i0];
data[i0] = t1 + data[i1];
@@ -314,12 +333,12 @@ void irealfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
k = n2;
while (k<=j) {
j -= k;
- k >>= 1;
+ k >>= 1;
}
j += k;
}
for (i=0; i<n; i++)
- outdata[i] = data[i];
+ outdata[i] = data[i];
}
/* *****************************************************
@@ -327,7 +346,7 @@ void irealfft_split(MYFLT *data, MYFLT *outdata, int n, MYFLT **twiddle) {
** data: array of doubles:
** re(0),im(0),re(1),im(1),...,re(size-1),im(size-1)
** it means that size=array_length/2 !!
-**
+**
** suggested use:
** intput in normal order
** output in bit-reversed order
@@ -360,7 +379,7 @@ void dif_butterfly(MYFLT *data, int size, MYFLT *twiddle){
*(l1) = xr; *(l1+1) = xi;
*(l2) = yr; *(l2+1) = yi;
angle += astep;
- }
+ }
}
}
}
@@ -415,7 +434,7 @@ void inverse_dit_butterfly(MYFLT *data, int size, MYFLT *twiddle){
** it means that size=array_length/2 !!
**
** Source: Rabiner-Gold: Theory and Application of DSP,
-** Prentice Hall,1978
+** Prentice Hall,1978
******************************************************* */
void unshuffle(MYFLT *data, int size){
@@ -433,14 +452,14 @@ void unshuffle(MYFLT *data, int size){
k = m;
while (k <= j) {
j -= k;
- k >>= 1;
+ k >>= 1;
}
j += k;
}
}
/* *****************************************************
-** used by realfft
+** used by realfft
** parameters as above
**
** Source: Brigham: The Fast Fourier Transform
@@ -456,7 +475,7 @@ void realize(MYFLT *data, int size) {
xr = *l1;
xi = *(l1+1);
*l1 = xr + xi;
- *(l1+1) = xr - xi;
+ *(l1+1) = xr - xi;
l1 += 2;
astep = PI / size;
for(ang=astep; l1<=l2; l1+=2, l2-=2, ang+=astep) {
@@ -469,14 +488,14 @@ void realize(MYFLT *data, int size) {
dr = yr * wr - yi * wi;
di = yr * wi + yi * wr;
*l1 = xr + dr;
- *(l1+1) = xi + di;
+ *(l1+1) = xi + di;
*l2 = xr - dr;
*(l2+1) = -xi + di;
}
}
/* *****************************************************
-** used by inverse realfft
+** used by inverse realfft
** parameters as above
**
** Source: Brigham: The Fast Fourier Transform
@@ -492,7 +511,7 @@ void unrealize(MYFLT *data, int size) {
xr = (*l1) / 2;
xi = (*(l1+1)) / 2;
*l1 = xr + xi;
- *(l1+1) = xr - xi;
+ *(l1+1) = xr - xi;
l1 += 2;
astep = PI / size;
for(ang=astep; l1<=l2; l1+=2, l2-=2, ang+=astep){
@@ -505,7 +524,7 @@ void unrealize(MYFLT *data, int size) {
dr = yr * wr - yi * wi;
di = yr * wi + yi * wr;
*l2 = xr + dr;
- *(l1+1) = xi + di;
+ *(l1+1) = xi + di;
*l1 = xr - dr;
*(l2+1) = -xi + di;
}
@@ -516,7 +535,7 @@ void unrealize(MYFLT *data, int size) {
** (by the so-called "packing method")
** data: array of doubles:
** re(0),re(1),re(2),...,re(size-1)
-**
+**
** output:
** re(0),re(size/2),re(1),im(1),re(2),im(2),...,re(size/2-1),im(size/2-1)
** normalized by array length
@@ -541,8 +560,8 @@ void realfft_packed(MYFLT *data, MYFLT *outdata, int size, MYFLT *twiddle) {
** in-place Radix-2 inverse FFT for real values
** (by the so-called "packing method")
** data: array of doubles:
-** re(0),re(size/2),re(1),im(1),re(2),im(2),...,re(size/2-1),im(size/2-1)
-**
+** re(0),re(size/2),re(1),im(1),re(2),im(2),...,re(size/2-1),im(size/2-1)
+**
** output:
** re(0),re(1),re(2),...,re(size-1)
** NOT normalized by array length
@@ -562,4 +581,3 @@ void irealfft_packed(MYFLT *data, MYFLT *outdata, int size, MYFLT *twiddle) {
for (i=0; i<size; i++)
outdata[i] = data[i] * 2;
}
-
diff --git a/src/engine/inputfadermodule.c b/src/engine/inputfadermodule.c
index 5f6b44e..7a59fab 100644
--- a/src/engine/inputfadermodule.c
+++ b/src/engine/inputfadermodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -40,40 +40,40 @@ typedef struct {
static void InputFader_setProcMode(InputFader *self) {};
-static void InputFader_process_only_first(InputFader *self)
+static void InputFader_process_only_first(InputFader *self)
{
int i;
MYFLT *in = Stream_getData((Stream *)self->input1_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = in[i];
}
}
-static void InputFader_process_only_second(InputFader *self)
+static void InputFader_process_only_second(InputFader *self)
{
int i;
MYFLT *in = Stream_getData((Stream *)self->input2_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = in[i];
}
}
-static void InputFader_process_one(InputFader *self)
+static void InputFader_process_one(InputFader *self)
{
int i;
MYFLT sclfade, val;
MYFLT *in1 = Stream_getData((Stream *)self->input1_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
val = 0.0;
sclfade = 1. / self->fadetime;
for (i=0; i<self->bufsize; i++) {
if (self->currentTime < self->fadetime) {
val = MYSQRT(self->currentTime * sclfade);
self->currentTime += self->sampleToSec;
- }
+ }
else
val = 1.;
@@ -84,7 +84,7 @@ static void InputFader_process_one(InputFader *self)
}
-static void InputFader_process_two(InputFader *self)
+static void InputFader_process_two(InputFader *self)
{
int i;
MYFLT sclfade, val;
@@ -97,10 +97,10 @@ static void InputFader_process_two(InputFader *self)
if (self->currentTime < self->fadetime) {
val = MYSQRT(self->currentTime * sclfade);
self->currentTime += self->sampleToSec;
- }
+ }
else
val = 1.;
-
+
self->data[i] = in2[i] * val + in1[i] * (1 - val);
}
if (val == 1.)
@@ -109,7 +109,7 @@ static void InputFader_process_two(InputFader *self)
static void
InputFader_compute_next_data_frame(InputFader *self)
-{
+{
(*self->proc_func_ptr)(self);
}
@@ -124,7 +124,7 @@ InputFader_traverse(InputFader *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
InputFader_clear(InputFader *self)
{
pyo_CLEAR
@@ -150,15 +150,15 @@ InputFader_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp=NULL, *streamtmp;
InputFader *self;
self = (InputFader *)type->tp_alloc(type, 0);
-
+
self->switcher = 0;
self->fadetime = 0.05;
self->currentTime = 0.0;
-
+
INIT_OBJECT_COMMON
self->sampleToSec = 1. / self->sr;
-
+
Stream_setFunctionPtr(self->stream, InputFader_compute_next_data_frame);
self->mode_func_ptr = InputFader_setProcMode;
self->proc_func_ptr = InputFader_process_only_first;
@@ -166,14 +166,11 @@ InputFader_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static char *kwlist[] = {"input", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &inputtmp))
- Py_RETURN_NONE;
+ Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "server") == 0 ) {
- PySys_WriteStderr("TypeError: \"input\" argument must be a PyoObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument must be a PyoObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input1);
@@ -182,9 +179,9 @@ InputFader_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_INCREF(streamtmp);
Py_XDECREF(self->input1_stream);
self->input1_stream = (Stream *)streamtmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
return (PyObject *)self;
}
@@ -196,13 +193,13 @@ InputFader_setInput(InputFader *self, PyObject *args, PyObject *kwds)
static char *kwlist[] = {"input", "fadetime", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_F, kwlist, &tmp, &self->fadetime))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
self->switcher = (self->switcher + 1) % 2;
self->currentTime = 0.0;
if (self->fadetime == 0)
self->fadetime = 0.0001;
-
+
Py_INCREF(tmp);
if (self->switcher == 0) {
@@ -222,11 +219,11 @@ InputFader_setInput(InputFader *self, PyObject *args, PyObject *kwds)
Py_XDECREF(self->input2_stream);
self->input2_stream = (Stream *)streamtmp;
self->proc_func_ptr = InputFader_process_two;
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject * InputFader_getServer(InputFader* self) { GET_SERVER };
static PyObject * InputFader_getStream(InputFader* self) { GET_STREAM };
@@ -294,4 +291,3 @@ PyTypeObject InputFaderType = {
0, /* tp_alloc */
InputFader_new, /* tp_new */
};
-
diff --git a/src/engine/interpolation.c b/src/engine/interpolation.c
index 00ee8c2..ac986a0 100644
--- a/src/engine/interpolation.c
+++ b/src/engine/interpolation.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include "interpolation.h"
@@ -36,7 +36,7 @@ MYFLT cosine(MYFLT *buf, int index, MYFLT frac, int size) {
MYFLT frac2;
MYFLT x1 = buf[index];
MYFLT x2 = buf[index+1];
-
+
frac2 = (1.0 - MYCOS(frac * M_PI)) * 0.5;
return (x1 + (x2 - x1) * frac2);
}
@@ -45,7 +45,7 @@ MYFLT cubic(MYFLT *buf, int index, MYFLT frac, int size) {
MYFLT x0, x3, a0, a1, a2, a3;
MYFLT x1 = buf[index];
MYFLT x2 = buf[index+1];
-
+
if (index == 0) {
x0 = x1 + (x1 - x2);
x3 = buf[index + 2];
@@ -53,16 +53,16 @@ MYFLT cubic(MYFLT *buf, int index, MYFLT frac, int size) {
else if (index >= (size-2)) {
x0 = buf[index - 1];
x3 = x2 + (x2 - x1);
- }
+ }
else {
x0 = buf[index - 1];
x3 = buf[index + 2];
}
-
+
a3 = frac * frac; a3 -= 1.0; a3 *= (1.0 / 6.0);
a2 = (frac + 1.0) * 0.5; a0 = a2 - 1.0;
a1 = a3 * 3.0; a2 -= a1; a0 -= a3; a1 -= frac;
a0 *= frac; a1 *= frac; a2 *= frac; a3 *= frac; a1 += 1.0;
return (a0*x0+a1*x1+a2*x2+a3*x3);
-}
+}
\ No newline at end of file
diff --git a/src/engine/mixmodule.c b/src/engine/mixmodule.c
index 5f40ea0..6353431 100644
--- a/src/engine/mixmodule.c
+++ b/src/engine/mixmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -49,39 +49,39 @@ Mix_setProcMode(Mix *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Mix_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Mix_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Mix_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Mix_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Mix_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Mix_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Mix_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Mix_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Mix_postprocessing_revareva;
break;
- }
+ }
}
static void
Mix_compute_next_data_frame(Mix *self)
-{
+{
int i, j;
MYFLT old;
PyObject *stream;
@@ -96,13 +96,13 @@ Mix_compute_next_data_frame(Mix *self)
for (j=0; j<self->bufsize; j++) {
old = buffer[j];
buffer[j] = in[j] + old;
- }
- }
-
+ }
+ }
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = buffer[i];
}
-
+
(*self->muladd_func_ptr)(self);
}
@@ -114,7 +114,7 @@ Mix_traverse(Mix *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Mix_clear(Mix *self)
{
pyo_CLEAR
@@ -148,12 +148,12 @@ Mix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static char *kwlist[] = {"input", "mul", "add", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
- Py_RETURN_NONE;
+ Py_RETURN_NONE;
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
self->input = inputtmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -161,19 +161,19 @@ Mix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Mix_getServer(Mix* self) { GET_SERVER };
static PyObject * Mix_getStream(Mix* self) { GET_STREAM };
-static PyObject * Mix_setMul(Mix *self, PyObject *arg) { SET_MUL };
-static PyObject * Mix_setAdd(Mix *self, PyObject *arg) { SET_ADD };
-static PyObject * Mix_setSub(Mix *self, PyObject *arg) { SET_SUB };
+static PyObject * Mix_setMul(Mix *self, PyObject *arg) { SET_MUL };
+static PyObject * Mix_setAdd(Mix *self, PyObject *arg) { SET_ADD };
+static PyObject * Mix_setSub(Mix *self, PyObject *arg) { SET_SUB };
static PyObject * Mix_setDiv(Mix *self, PyObject *arg) { SET_DIV };
static PyObject * Mix_play(Mix *self, PyObject *args, PyObject *kwds) { PLAY };
@@ -294,4 +294,3 @@ PyTypeObject MixType = {
0, /* tp_alloc */
Mix_new, /* tp_new */
};
-
diff --git a/src/engine/pvstreammodule.c b/src/engine/pvstreammodule.c
index 6b183dc..12cded6 100644
--- a/src/engine/pvstreammodule.c
+++ b/src/engine/pvstreammodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -53,7 +53,7 @@ MYFLT **
PVStream_getMagn(PVStream *self)
{
return (MYFLT **)self->magn;
-}
+}
MYFLT **
PVStream_getFreq(PVStream *self)
@@ -71,19 +71,19 @@ void
PVStream_setFFTsize(PVStream *self, int fftsize)
{
self->fftsize = fftsize;
-}
+}
void
PVStream_setOlaps(PVStream *self, int olaps)
{
self->olaps = olaps;
-}
+}
void
PVStream_setMagn(PVStream *self, MYFLT **data)
{
self->magn = data;
-}
+}
void
PVStream_setFreq(PVStream *self, MYFLT **data)
@@ -139,4 +139,4 @@ PyTypeObject PVStreamType = {
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/engine/pyomodule.c b/src/engine/pyomodule.c
index 6de20d9..88b37e4 100644
--- a/src/engine/pyomodule.c
+++ b/src/engine/pyomodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -30,7 +30,7 @@
#include "tablemodule.h"
#include "matrixmodule.h"
-/** Note :
+/** Note :
** Add an argument to pa_get_* and pm_get_* functions to allow printing to the console
**/
@@ -77,7 +77,7 @@ portaudio_get_version_text() {
static PyObject *
portaudio_count_host_apis(){
PaError err;
- PaHostApiIndex numApis;
+ PaHostApiIndex numApis;
err = Pa_Initialize();
if (err != paNoError) {
@@ -101,7 +101,7 @@ static PyObject*
portaudio_list_host_apis(){
PaError err;
PaHostApiIndex n, i;
-
+
err = Pa_Initialize();
if (err != paNoError) {
portaudio_assert(err, "Pa_Initialize");
@@ -117,7 +117,7 @@ portaudio_list_host_apis(){
assert(info);
fprintf(stdout, "index: %i, id: %i, name: %s, num devices: %i, default in: %i, default out: %i\n", i, (int)info->type, info->name, (int)info->deviceCount, (int)info->defaultInputDevice, (int)info->defaultOutputDevice);
}
- }
+ }
}
Py_RETURN_NONE;
}
@@ -132,7 +132,7 @@ static PyObject*
portaudio_get_default_host_api(){
PaError err;
PaHostApiIndex i;
-
+
err = Pa_Initialize();
if (err != paNoError) {
portaudio_assert(err, "Pa_Initialize");
@@ -154,7 +154,7 @@ static PyObject*
portaudio_count_devices(){
PaError err;
PaDeviceIndex numDevices;
-
+
err = Pa_Initialize();
if (err != paNoError) {
portaudio_assert(err, "Pa_Initialize");
@@ -164,7 +164,7 @@ portaudio_count_devices(){
numDevices = Pa_GetDeviceCount();
if( numDevices < 0 )
portaudio_assert(numDevices, "Pa_GetDeviceCount");
- return PyInt_FromLong(numDevices);
+ return PyInt_FromLong(numDevices);
}
}
@@ -187,7 +187,7 @@ static PyObject*
portaudio_list_devices(){
PaError err;
PaDeviceIndex n, i;
-
+
err = Pa_Initialize();
if (err != paNoError) {
portaudio_assert(err, "Pa_Initialize");
@@ -203,15 +203,15 @@ portaudio_list_devices(){
for (i=0; i < n; ++i){
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
assert(info);
-
+
if (info->maxInputChannels > 0)
fprintf(stdout, "%i: IN, name: %s, host api index: %i, default sr: %i Hz, latency: %f s\n", i, info->name, (int)info->hostApi, (int)info->defaultSampleRate, (float)info->defaultLowInputLatency);
-
+
if (info->maxOutputChannels > 0)
fprintf(stdout, "%i: OUT, name: %s, host api index: %i, default sr: %i Hz, latency: %f s\n", i, info->name, (int)info->hostApi, (int)info->defaultSampleRate, (float)info->defaultLowOutputLatency);
}
printf("\n");
- }
+ }
}
Py_RETURN_NONE;
}
@@ -272,7 +272,7 @@ portaudio_get_devices_infos(){
}
}
return Py_BuildValue("(OO)", inDict, outDict);
- }
+ }
}
}
@@ -290,7 +290,7 @@ portaudio_get_output_devices(){
PyObject *list, *list_index;
list = PyList_New(0);
list_index = PyList_New(0);
-
+
err = Pa_Initialize();
if (err != paNoError) {
portaudio_assert(err, "Pa_Initialize");
@@ -305,14 +305,14 @@ portaudio_get_output_devices(){
else {
for (i=0; i < n; ++i){
const PaDeviceInfo *info=Pa_GetDeviceInfo(i);
- assert(info);
+ assert(info);
if (info->maxOutputChannels > 0){
PyList_Append(list, PyString_FromString(info->name));
PyList_Append(list_index, PyInt_FromLong(i));
}
}
return Py_BuildValue("OO", list, list_index);
- }
+ }
}
}
@@ -330,7 +330,7 @@ x: int\n Device index as listed by Portaudio (see pa_get_output_devices).
>>> if maxouts >= 2 and maxins >= 2:\n\
... nchnls = 2\n\
>>> else:\n\
-... nchnls = 1\n\n"
+... nchnls = 1\n\n"
static PyObject*
portaudio_get_output_max_channels(PyObject *self, PyObject *arg){
@@ -350,9 +350,9 @@ portaudio_get_output_max_channels(PyObject *self, PyObject *arg){
}
else {
const PaDeviceInfo *info=Pa_GetDeviceInfo(i);
- assert(info);
+ assert(info);
return PyInt_FromLong(info->maxOutputChannels);
- }
+ }
}
}
@@ -370,7 +370,7 @@ x: int\n Device index as listed by Portaudio (see pa_get_input_devices).\
>>> if maxouts >= 2 and maxins >= 2:\n\
... nchnls = 2\n\
>>> else:\n\
-... nchnls = 1\n\n"
+... nchnls = 1\n\n"
static PyObject*
portaudio_get_input_max_channels(PyObject *self, PyObject *arg){
@@ -390,9 +390,9 @@ portaudio_get_input_max_channels(PyObject *self, PyObject *arg){
}
else {
const PaDeviceInfo *info=Pa_GetDeviceInfo(i);
- assert(info);
+ assert(info);
return PyInt_FromLong(info->maxInputChannels);
- }
+ }
}
}
@@ -406,11 +406,11 @@ static PyObject*
portaudio_get_input_devices(){
PaError err;
PaDeviceIndex n, i;
-
+
PyObject *list, *list_index;
list = PyList_New(0);
list_index = PyList_New(0);
-
+
err = Pa_Initialize();
if (err != paNoError) {
portaudio_assert(err, "Pa_Initialize");
@@ -425,14 +425,14 @@ portaudio_get_input_devices(){
else {
for (i=0; i < n; ++i){
const PaDeviceInfo *info=Pa_GetDeviceInfo(i);
- assert(info);
+ assert(info);
if (info->maxInputChannels > 0){
PyList_Append(list, PyString_FromString(info->name));
PyList_Append(list_index, PyInt_FromLong(i));
}
}
- return Py_BuildValue("OO", list, list_index);
- }
+ return Py_BuildValue("OO", list, list_index);
+ }
}
}
@@ -447,7 +447,7 @@ static PyObject*
portaudio_get_default_input(){
PaError err;
PaDeviceIndex i;
-
+
err = Pa_Initialize();
if (err != paNoError) {
portaudio_assert(err, "Pa_Initialize");
@@ -455,7 +455,7 @@ portaudio_get_default_input(){
}
else {
i = Pa_GetDefaultInputDevice();
- return PyInt_FromLong(i);
+ return PyInt_FromLong(i);
}
}
@@ -471,7 +471,7 @@ static PyObject*
portaudio_get_default_output(){
PaError err;
PaDeviceIndex i;
-
+
err = Pa_Initialize();
if (err != paNoError) {
portaudio_assert(err, "Pa_Initialize");
@@ -480,7 +480,7 @@ portaudio_get_default_output(){
else {
i = Pa_GetDefaultOutputDevice();
return PyInt_FromLong(i);
-
+
}
}
@@ -515,11 +515,11 @@ portmidi_list_devices(){
printf("MIDI devices:\n");
for (i = 0; i < Pm_CountDevices(); i++) {
const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
- if (info->input && info->output)
+ if (info->input && info->output)
printf("%d: IN/OUT, name: %s, interface: %s\n", i, info->name, info->interf);
- else if (info->input)
+ else if (info->input)
printf("%d: IN, name: %s, interface: %s\n", i, info->name, info->interf);
- else if (info->output)
+ else if (info->output)
printf("%d: OUT, name: %s, interface: %s\n", i, info->name, info->interf);
}
printf("\n");
@@ -594,7 +594,7 @@ portmidi_get_output_devices(){
static PyObject *
portmidi_get_default_input(){
PmDeviceID i;
-
+
i = Pm_GetDefaultInputDeviceID();
if (i < 0)
printf("pm_get_default_input: no midi input device found.\n");
@@ -618,7 +618,7 @@ portmidi_get_default_output(){
}
/****** Libsndfile utilities ******/
-static int
+static int
libsndfile_get_format(int fileformat, int sampletype) {
int format = 0;
switch (fileformat) {
@@ -689,7 +689,7 @@ print : boolean, optional\n If True, sndinfo will print sound infos to th
static PyObject *
sndinfo(PyObject *self, PyObject *args, PyObject *kwds) {
-
+
SNDFILE *sf;
SF_INFO info;
char *pathtmp;
@@ -814,18 +814,18 @@ sndinfo(PyObject *self, PyObject *args, PyObject *kwds) {
sampletype = malloc(strlen("Unknown...") + 1);
strcpy(sampletype, "Unknown...");
}
-
+
if (print)
- fprintf(stdout, "name: %s\nnumber of frames: %i\nduration: %.4f sec\nsr: %.2f\nchannels: %i\nformat: %s\nsample type: %s\n",
+ fprintf(stdout, "name: %s\nnumber of frames: %i\nduration: %.4f sec\nsr: %.2f\nchannels: %i\nformat: %s\nsample type: %s\n",
path, (int)info.frames, ((float)info.frames / info.samplerate), (float)info.samplerate, (int)info.channels, fileformat, sampletype);
- PyObject *sndinfo = PyTuple_Pack(6, PyInt_FromLong(info.frames), PyFloat_FromDouble((float)info.frames / info.samplerate),
+ PyObject *sndinfo = PyTuple_Pack(6, PyInt_FromLong(info.frames), PyFloat_FromDouble((float)info.frames / info.samplerate),
PyFloat_FromDouble(info.samplerate), PyInt_FromLong(info.channels), PyString_FromString(fileformat), PyString_FromString(sampletype));
sf_close(sf);
free(path);
free(sampletype);
return sndinfo;
}
-}
+}
#define savefile_info \
"\nCreates an audio file from a list of floats.\n\n:Args:\n\n \
@@ -874,7 +874,7 @@ savefile(PyObject *self, PyObject *args, PyObject *kwds) {
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|iiii", kwlist, &samples, &recpath, &sr, &channels, &fileformat, &sampletype))
return PyInt_FromLong(-1);
-
+
recinfo.samplerate = sr;
recinfo.channels = channels;
recinfo.format = libsndfile_get_format(fileformat, sampletype);
@@ -897,8 +897,8 @@ savefile(PyObject *self, PyObject *args, PyObject *kwds) {
for (j=0; j<channels; j++) {
sampsarray[i*channels+j] = PyFloat_AS_DOUBLE(PyList_GET_ITEM(PyList_GET_ITEM(samples, j), i));
}
- }
- }
+ }
+ }
if (! (recfile = sf_open(recpath, SFM_WRITE, &recinfo))) {
printf ("savefile: failed to open output file %s.\n", recpath);
return PyInt_FromLong(-1);
@@ -906,8 +906,8 @@ savefile(PyObject *self, PyObject *args, PyObject *kwds) {
SF_WRITE(recfile, sampsarray, size);
sf_close(recfile);
free(sampsarray);
-
- Py_RETURN_NONE;
+
+ Py_RETURN_NONE;
}
#define savefileFromTable_info \
@@ -956,10 +956,10 @@ savefileFromTable(PyObject *self, PyObject *args, PyObject *kwds) {
SNDFILE *recfile;
SF_INFO recinfo;
static char *kwlist[] = {"table", "path", "fileformat", "sampletype", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|ii", kwlist, &table, &recpath, &fileformat, &sampletype))
return PyInt_FromLong(-1);
-
+
base_objs = PyObject_GetAttrString(table, "_base_objs");
channels = PyList_Size(base_objs);
tablestreamlist = PyList_New(channels);
@@ -968,7 +968,7 @@ savefileFromTable(PyObject *self, PyObject *args, PyObject *kwds) {
}
sr = (int)TableStream_getSamplingRate((PyObject *)PyList_GetItem(tablestreamlist, 0));
size = TableStream_getSize((PyObject *)PyList_GetItem(tablestreamlist, 0));
-
+
recinfo.samplerate = sr;
recinfo.channels = channels;
recinfo.format = libsndfile_get_format(fileformat, sampletype);
@@ -979,7 +979,7 @@ savefileFromTable(PyObject *self, PyObject *args, PyObject *kwds) {
Py_XDECREF(tablestreamlist);
return PyInt_FromLong(-1);
}
-
+
if (channels == 1) {
MYFLT *data;
if (size < (sr * 60)) {
@@ -1036,14 +1036,14 @@ savefileFromTable(PyObject *self, PyObject *args, PyObject *kwds) {
SF_WRITE(recfile, sampsarray, num_items * channels);
} while (num_items == (sr * 30));
}
- }
+ }
sf_close(recfile);
free(sampsarray);
Py_XDECREF(base_objs);
Py_XDECREF(tablestreamlist);
-
- Py_RETURN_NONE;
+
+ Py_RETURN_NONE;
}
/****** Sampling rate conversions ******/
@@ -1093,7 +1093,7 @@ void gen_lp_impulse(MYFLT *array, int size, float freq) {
MYFLT vsum = 0.0;
MYFLT envPointerScaling = 1.0 / (size + 1) * 1024.0;
MYFLT sincScaling = (MYFLT)half;
-
+
for (i=0; i<half; i++) {
pp = i * envPointerScaling;
ppi = (int)pp;
@@ -1114,7 +1114,7 @@ void gen_lp_impulse(MYFLT *array, int size, float freq) {
}
for (i=1; i<half; i++) {
array[half+i] = array[half-i];
- }
+ }
}
/*
@@ -1129,7 +1129,7 @@ void lp_conv(MYFLT *samples, MYFLT *impulse, int num_samps, int size, int gain)
int i, j, count, tmp_count;
MYFLT val;
MYFLT intmp[size];
-
+
for (i=0; i<size; i++) {
intmp[i] = 0.0;
}
@@ -1166,10 +1166,10 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
int up = 4;
int order = 128;
static char *kwlist[] = {"path", "outfile", "up", "order", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "ss|ii", kwlist, &inpath, &outpath, &up, &order))
return PyInt_FromLong(-1);
-
+
/* opening input soundfile */
info.format = 0;
sf = sf_open(inpath, SFM_READ, &info);
@@ -1188,16 +1188,16 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
samples = (MYFLT **)malloc(snd_chnls * sizeof(MYFLT *));
for(i=0; i<snd_chnls; i++)
samples[i] = (MYFLT *)malloc(snd_size * sizeof(MYFLT));
-
+
for (i=0; i<num_items; i++)
samples[i%snd_chnls][(int)(i/snd_chnls)] = tmp[i];
free(tmp);
-
+
/* upsampling */
upsamples = (MYFLT **)malloc(snd_chnls * sizeof(MYFLT *));
for(i=0; i<snd_chnls; i++)
upsamples[i] = (MYFLT *)malloc(snd_size * up * sizeof(MYFLT));
-
+
for (i=0; i<snd_size; i++) {
for (j=0; j<snd_chnls; j++) {
upsamples[j][i*up] = samples[j][i];
@@ -1206,7 +1206,7 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
}
}
}
-
+
if (order > 2) {
/* apply lowpass filter */
sincfunc = (MYFLT *)malloc(order * sizeof(MYFLT));
@@ -1216,7 +1216,7 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
}
free(sincfunc);
}
-
+
/* save upsampled file */
info.samplerate = snd_sr * up;
tmp = (MYFLT *)malloc(num_items * up * sizeof(MYFLT));
@@ -1224,8 +1224,8 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
for (j=0; j<snd_chnls; j++) {
tmp[i*snd_chnls+j] = upsamples[j][i];
}
- }
-
+ }
+
if (! (sf = sf_open(outpath, SFM_WRITE, &info))) {
printf ("upsamp: failed to open output file %s.\n", outpath);
free(tmp);
@@ -1240,7 +1240,7 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
SF_WRITE(sf, tmp, num_items * up);
sf_close(sf);
-
+
/* clean-up */
free(tmp);
for (i=0; i<snd_chnls; i++) {
@@ -1249,8 +1249,8 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
}
free(samples);
free(upsamples);
-
- Py_RETURN_NONE;
+
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1269,10 +1269,10 @@ downsamp(PyObject *self, PyObject *args, PyObject *kwds)
int down = 4;
int order = 128;
static char *kwlist[] = {"path", "outfile", "down", "order", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "ss|ii", kwlist, &inpath, &outpath, &down, &order))
return PyInt_FromLong(-1);
-
+
/* opening input soundfile */
info.format = 0;
sf = sf_open(inpath, SFM_READ, &info);
@@ -1291,7 +1291,7 @@ downsamp(PyObject *self, PyObject *args, PyObject *kwds)
samples = (MYFLT **)malloc(snd_chnls * sizeof(MYFLT *));
for(i=0; i<snd_chnls; i++)
samples[i] = (MYFLT *)malloc(snd_size * sizeof(MYFLT));
-
+
for (i=0; i<num_items; i++)
samples[i%snd_chnls][(int)(i/snd_chnls)] = tmp[i];
free(tmp);
@@ -1305,7 +1305,7 @@ downsamp(PyObject *self, PyObject *args, PyObject *kwds)
}
free(sincfunc);
}
-
+
/* downsampling */
samples_per_channels = (snd_size / down) + (snd_size % down);
downsamples = (MYFLT **)malloc(snd_chnls * sizeof(MYFLT *));
@@ -1321,7 +1321,7 @@ downsamp(PyObject *self, PyObject *args, PyObject *kwds)
if (i*down < snd_size)
downsamples[j][i] = samples[j][i*down];
else
- downsamples[j][i] = 0.0;
+ downsamples[j][i] = 0.0;
}
}
@@ -1333,7 +1333,7 @@ downsamp(PyObject *self, PyObject *args, PyObject *kwds)
tmp[i*snd_chnls+j] = downsamples[j][i];
}
}
-
+
if (! (sf = sf_open(outpath, SFM_WRITE, &info))) {
printf("downsamp: failed to open the output file %s.\n", outpath);
free(tmp);
@@ -1345,10 +1345,10 @@ downsamp(PyObject *self, PyObject *args, PyObject *kwds)
free(downsamples);
return PyInt_FromLong(-1);
}
-
+
SF_WRITE(sf, tmp, snd_chnls * samples_per_channels);
sf_close(sf);
-
+
/* clean-up */
free(tmp);
for (i=0; i<snd_chnls; i++) {
@@ -1357,8 +1357,8 @@ downsamp(PyObject *self, PyObject *args, PyObject *kwds)
}
free(samples);
free(downsamples);
-
- Py_RETURN_NONE;
+
+ Py_RETURN_NONE;
}
/****** Algorithm utilities ******/
@@ -1418,18 +1418,18 @@ reducePoints(PyObject *self, PyObject *args, PyObject *kwds)
int *pnUseFlag;
MYFLT dTolerance = .02;
MYFLT xMax, yMin, yMax;
-
+
static char *kwlist[] = {"pointlist", "tolerance", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_F, kwlist, &pointlist, &dTolerance))
return PyInt_FromLong(-1);
-
+
nPointsCount = PyList_Size(pointlist);
-
+
pPointsX = (MYFLT *)malloc(nPointsCount * sizeof(MYFLT));
pPointsY = (MYFLT *)malloc(nPointsCount * sizeof(MYFLT));
pnUseFlag = (int *)malloc(nPointsCount * sizeof(int));
-
+
tup = PyList_GET_ITEM(pointlist, 0);
if (PyTuple_Check(tup) == 1) {
for (i=0; i<nPointsCount; i++) {
@@ -1456,7 +1456,7 @@ reducePoints(PyObject *self, PyObject *args, PyObject *kwds)
yMin = pPointsY[i];
else if (pPointsY[i] > yMax)
yMax = pPointsY[i];
- }
+ }
for (i=0; i<nPointsCount; i++) {
pPointsX[i] = pPointsX[i] / xMax;
pPointsY[i] = (pPointsY[i] - yMin) / yMax;
@@ -1516,15 +1516,15 @@ reducePoints(PyObject *self, PyObject *args, PyObject *kwds)
StackPush( nVertexIndexMaxDistance, nFloaterIndex );
}
}
-
- pPointsOut = PyList_New(0);
+
+ pPointsOut = PyList_New(0);
for (i=0; i<nPointsCount; i++) {
if (pnUseFlag[i] == 1) {
PyList_Append(pPointsOut, PyList_GET_ITEM(pointlist, i));
}
- }
+ }
- return pPointsOut;
+ return pPointsOut;
}
#define distanceToSegment_info \
@@ -1554,9 +1554,9 @@ distanceToSegment(PyObject *self, PyObject *args, PyObject *kwds)
int xlog = 0;
int ylog = 0;
MYFLT xp[2], xp1[2], xp2[2], closest[2];
-
+
static char *kwlist[] = {"p", "p1", "p2", "xmin", "xmax", "ymin", "ymax", "xlog", "ylog", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_OOO_FFFFII, kwlist, &p, &p1, &p2, &xmin, &xmax, &ymin, &ymax, &xlog, &ylog))
return PyInt_FromLong(-1);
@@ -1579,13 +1579,13 @@ distanceToSegment(PyObject *self, PyObject *args, PyObject *kwds)
yscale = ymax - ymin;
xp[1] = PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(pf, 1))) / yscale;
xp1[1] = PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(pf1, 1))) / yscale;
- xp2[1] = PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(pf2, 1))) / yscale;
+ xp2[1] = PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(pf2, 1))) / yscale;
}
else {
yscale = MYLOG10(ymax / ymin);
xp[1] = MYLOG10(PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(pf, 1))) / ymin) / yscale;
xp1[1] = MYLOG10(PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(pf1, 1))) / ymin) / yscale;
- xp2[1] = MYLOG10(PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(pf2, 1))) / ymin) / yscale;
+ xp2[1] = MYLOG10(PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(pf2, 1))) / ymin) / yscale;
}
xDelta = xp2[0] - xp1[0]; yDelta = xp2[1] - xp1[1];
@@ -1622,7 +1622,7 @@ static PyObject *
linToCosCurve(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *data, *fdata, *out, *inout, *ftup, *yrange=NULL, *fyrange=NULL;
- int i, j, datasize, steps;
+ int i, j, datasize, steps;
double tmp, x1, x2, y1, y2, mu, ydiff, log10ymin, log10ymax;
double *xdata, *ydata, *cxdata, *cydata;
double totaldur = 1.0;
@@ -1632,12 +1632,12 @@ linToCosCurve(PyObject *self, PyObject *args, PyObject *kwds)
double inc = 1.0 / num;
int log = 0;
int count = 0;
-
+
static char *kwlist[] = {"data", "yrange", "totaldur", "points", "log", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|Odii", kwlist, &data, &yrange, &totaldur, &num, &log))
Py_RETURN_NONE;
-
+
if (yrange) {
fyrange = PySequence_Fast(yrange, NULL);
ymin = PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(fyrange, 0)));
@@ -1646,12 +1646,12 @@ linToCosCurve(PyObject *self, PyObject *args, PyObject *kwds)
ydiff = ymax - ymin;
log10ymin = log10(ymin);
log10ymax = log10(ymax);
-
+
fdata = PySequence_Fast(data, NULL);
datasize = PySequence_Size(fdata);
xdata = (double *)malloc(datasize * sizeof(double));
ydata = (double *)malloc(datasize * sizeof(double));
-
+
/* acquire data + normalization */
if (log == 0) {
for (i=0; i<datasize; i++) {
@@ -1669,12 +1669,12 @@ linToCosCurve(PyObject *self, PyObject *args, PyObject *kwds)
xdata[i] = tmp / totaldur;
tmp = PyFloat_AsDouble(PyNumber_Float(PySequence_Fast_GET_ITEM(ftup, 1)));
ydata[i] = log10(tmp / ymin) / log10(ymax / ymin);
- }
+ }
}
cxdata = (double *)malloc((num+5) * sizeof(double));
cydata = (double *)malloc((num+5) * sizeof(double));
-
+
/* generates cos interpolation */
for (i=0; i<(datasize-1); i++) {
x1 = xdata[i];
@@ -1692,7 +1692,7 @@ linToCosCurve(PyObject *self, PyObject *args, PyObject *kwds)
}
cxdata[count] = xdata[datasize-1];
cydata[count++] = ydata[datasize-1];
-
+
/* denormalization */
if (log == 0) {
for (i=0; i<count; i++) {
@@ -1704,7 +1704,7 @@ linToCosCurve(PyObject *self, PyObject *args, PyObject *kwds)
for (i=0; i<count; i++) {
cxdata[i] *= totaldur;
cydata[i] = pow(10.0, cydata[i] * (log10ymax - log10ymin) + log10ymin);
- }
+ }
}
/* output Python's list of lists */
@@ -1715,7 +1715,7 @@ linToCosCurve(PyObject *self, PyObject *args, PyObject *kwds)
PyList_SET_ITEM(inout, 1, PyFloat_FromDouble(cydata[i]));
PyList_SET_ITEM(out, i, inout);
}
-
+
free(xdata);
free(ydata);
free(cxdata);
@@ -1757,9 +1757,9 @@ rescale(PyObject *self, PyObject *args, PyObject *kwds)
int ylog = 0;
int i, cnt;
int type; // 0 = float, 1 = list of floats
-
+
static char *kwlist[] = {"data", "xmin", "xmax", "ymin", "ymax", "xlog", "ylog", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FFFFII, kwlist, &data, &xmin, &xmax, &ymin, &ymax, &xlog, &ylog))
return PyInt_FromLong(-1);
@@ -1767,9 +1767,10 @@ rescale(PyObject *self, PyObject *args, PyObject *kwds)
type = 0;
else if (PyList_Check(data))
type = 1;
- else
- Py_RETURN_NONE;
-
+ else {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
if (xlog == 0 && ylog == 0) {
datascl = xmax - xmin;
curscl = ymax - ymin;
@@ -1786,7 +1787,7 @@ rescale(PyObject *self, PyObject *args, PyObject *kwds)
PyList_SET_ITEM(out, i, PyFloat_FromDouble((val - xmin) * curscl + ymin));
}
return out;
- }
+ }
}
else if (xlog == 0 && ylog == 1) {
if (xmin == 0)
@@ -1812,7 +1813,7 @@ rescale(PyObject *self, PyObject *args, PyObject *kwds)
PyList_SET_ITEM(out, i, PyFloat_FromDouble(MYPOW(10.0, val * curscl + ymin)));
}
return out;
- }
+ }
}
else if (xlog == 1 && ylog == 0) {
datascl = MYLOG10(xmax / xmin);
@@ -1831,7 +1832,7 @@ rescale(PyObject *self, PyObject *args, PyObject *kwds)
PyList_SET_ITEM(out, i, PyFloat_FromDouble(val * curscl + ymin));
}
return out;
- }
+ }
}
else if (xlog == 1 && ylog == 1) {
datascl = MYLOG10(xmax / xmin);
@@ -1851,12 +1852,50 @@ rescale(PyObject *self, PyObject *args, PyObject *kwds)
PyList_SET_ITEM(out, i, PyFloat_FromDouble(MYPOW(10.0, val * curscl + ymin)));
}
return out;
- }
+ }
}
else {
- Py_RETURN_NONE;
+ Py_INCREF(Py_None);
+ return Py_None;
}
- Py_RETURN_NONE;
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#define floatmap_info \
+"\nConverts values from a 0-1 range to an output range.\n\n\
+This function takes data in the range `0` - `1` and returns corresponding values\nin the range `min` - `max`.\n\n\
+:Argss:\n\n \
+x : float\n Value to convert, in the range 0 to 1.\n \
+min : float, optional\n Minimum value of the output range. Defaults to 0.\n \
+max : float, optional\n Maximum value of the output range. Defaults to 1.\n \
+exp : float, optional\n Power factor (1 (default) is linear, les than 1 is logarithmic, greter than 1 is exponential).\n\n\
+>>> a = 0.5\n\
+>>> b = floatmap(a, 0, 1, 4)\n\
+>>> print b\n\
+0.0625\n\n"
+
+static PyObject *
+floatmap(PyObject *self, PyObject *args, PyObject *kwds)
+{
+ MYFLT x = 0.0;
+ MYFLT min = 0.0;
+ MYFLT max = 1.0;
+ MYFLT exp = 1.0;
+
+ static char *kwlist[] = {"x", "min", "max", "exp", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_F_FFF, kwlist, &x, &min, &max, &exp))
+ return PyInt_FromLong(-1);
+
+ if (x < 0.0)
+ x = 0.0;
+ else if (x > 1.0)
+ x = 1.0;
+ if (exp != 1.0)
+ x = MYPOW(x, exp);
+
+ return Py_BuildValue("d", x * (max - min) + min);
}
/****** Conversion utilities ******/
@@ -1882,13 +1921,13 @@ midiToHz(PyObject *self, PyObject *arg) {
double x = 0.0;
PyObject *newseq = NULL;
if (PyNumber_Check(arg))
- return Py_BuildValue("d", 8.1757989156437 * pow(1.0594630943593, PyFloat_AsDouble(PyNumber_Float(arg))));
+ return Py_BuildValue("d", 440.0 * MYPOW(2.0, (PyFloat_AsDouble(PyNumber_Float(arg)) - 69) / 12.0));
else if (PyList_Check(arg)) {
count = PyList_Size(arg);
newseq = PyList_New(count);
for (i=0; i<count; i++) {
x = PyFloat_AsDouble(PyNumber_Float(PyList_GET_ITEM(arg, i)));
- PyList_SET_ITEM(newseq, i, PyFloat_FromDouble(8.1757989156437 * pow(1.0594630943593, x)));
+ PyList_SET_ITEM(newseq, i, PyFloat_FromDouble(440.0 * MYPOW(2.0, (x - 69) / 12.0)));
}
return newseq;
}
@@ -1897,13 +1936,58 @@ midiToHz(PyObject *self, PyObject *arg) {
newseq = PyTuple_New(count);
for (i=0; i<count; i++) {
x = PyFloat_AsDouble(PyNumber_Float(PyTuple_GET_ITEM(arg, i)));
- PyTuple_SET_ITEM(newseq, i, PyFloat_FromDouble(8.1757989156437 * pow(1.0594630943593, x)));
+ PyTuple_SET_ITEM(newseq, i, PyFloat_FromDouble(440.0 * MYPOW(2.0, (x - 69) / 12.0)));
}
return newseq;
}
else
Py_RETURN_NONE;
-}
+}
+
+#define hzToMidi_info \
+"\nConverts a frequency in Hertz to a midi note value.\n\n:Args:\n\n \
+x : float\n Frequency in Hertz. `x` can be a number, a list or a tuple, otherwise the function returns None.\n\n\
+>>> a = (110.0, 220.0, 440.0, 880.0)\n\
+>>> b = hzToMidi(a)\n\
+>>> print b\n\
+(45.0, 57.0, 69.0, 81.0)\n\
+>>> a = [110.0, 220.0, 440.0, 880.0]\n\
+>>> b = hzToMidi(a)\n\
+>>> print b\n\
+[45.0, 57.0, 69.0, 81.0]\n\
+>>> b = hzToMidi(440.0)\n\
+>>> print b\n\
+69.0\n\n"
+
+static PyObject *
+hzToMidi(PyObject *self, PyObject *arg) {
+ int count = 0;
+ int i = 0;
+ double x = 0.0;
+ PyObject *newseq = NULL;
+ if (PyNumber_Check(arg))
+ return Py_BuildValue("d", 12.0 * MYLOG2(PyFloat_AsDouble(PyNumber_Float(arg)) / 440.0) + 69);
+ else if (PyList_Check(arg)) {
+ count = PyList_Size(arg);
+ newseq = PyList_New(count);
+ for (i=0; i<count; i++) {
+ x = PyFloat_AsDouble(PyNumber_Float(PyList_GET_ITEM(arg, i)));
+ PyList_SET_ITEM(newseq, i, PyFloat_FromDouble(12.0 * MYLOG2(x / 440.0) + 69));
+ }
+ return newseq;
+ }
+ else if (PyTuple_Check(arg)) {
+ count = PyTuple_Size(arg);
+ newseq = PyTuple_New(count);
+ for (i=0; i<count; i++) {
+ x = PyFloat_AsDouble(PyNumber_Float(PyTuple_GET_ITEM(arg, i)));
+ PyTuple_SET_ITEM(newseq, i, PyFloat_FromDouble(12.0 * MYLOG2(x / 440.0) + 69));
+ }
+ return newseq;
+ }
+ else
+ Py_RETURN_NONE;
+}
#define midiToTranspo_info \
"\nConverts a midi note value to transposition factor (central key = 60).\n\n:Args:\n\n \
@@ -1948,7 +2032,7 @@ midiToTranspo(PyObject *self, PyObject *arg) {
}
else
Py_RETURN_NONE;
-}
+}
#define sampsToSec_info \
"\nReturns the duration in seconds equivalent to the number of samples given as an argument.\n\n:Args:\n\n \
@@ -2000,7 +2084,7 @@ sampsToSec(PyObject *self, PyObject *arg) {
}
else
Py_RETURN_NONE;
-}
+}
#define secToSamps_info \
"\nReturns the number of samples equivalent to the duration in seconds given as an argument.\n\n:Args:\n\n \
@@ -2052,7 +2136,7 @@ secToSamps(PyObject *self, PyObject *arg) {
}
else
Py_RETURN_NONE;
-}
+}
/************* Server quieries *************/
#define serverCreated_info \
@@ -2065,10 +2149,14 @@ True\n\n"
static PyObject *
serverCreated(PyObject *self) {
- if (PyServer_get_server() != NULL)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
+ if (PyServer_get_server() != NULL) {
+ Py_INCREF(Py_True);
+ return Py_True;
+ }
+ else {
+ Py_INCREF(Py_False);
+ return Py_False;
+ }
}
#define serverBooted_info \
@@ -2087,14 +2175,19 @@ serverBooted(PyObject *self) {
if (PyServer_get_server() != NULL) {
server = PyServer_get_server();
boot = PyInt_AsLong(PyObject_CallMethod(server, "getIsBooted", NULL));
- if (boot == 0)
- Py_RETURN_FALSE;
- else
- Py_RETURN_TRUE;
+ if (boot == 0) {
+ Py_INCREF(Py_False);
+ return Py_False;
+ }
+ else {
+ Py_INCREF(Py_True);
+ return Py_True;
+ }
}
else {
printf("Warning: A Server must be created before calling `serverBooted` function.\n");
- Py_RETURN_FALSE;
+ Py_INCREF(Py_False);
+ return Py_False;
}
}
@@ -2127,8 +2220,10 @@ static PyMethodDef pyo_functions[] = {
{"reducePoints", (PyCFunction)reducePoints, METH_VARARGS|METH_KEYWORDS, reducePoints_info},
{"distanceToSegment", (PyCFunction)distanceToSegment, METH_VARARGS|METH_KEYWORDS, distanceToSegment_info},
{"rescale", (PyCFunction)rescale, METH_VARARGS|METH_KEYWORDS, rescale_info},
+{"floatmap", (PyCFunction)floatmap, METH_VARARGS|METH_KEYWORDS, floatmap_info},
{"linToCosCurve", (PyCFunction)linToCosCurve, METH_VARARGS|METH_KEYWORDS, linToCosCurve_info},
{"midiToHz", (PyCFunction)midiToHz, METH_O, midiToHz_info},
+{"hzToMidi", (PyCFunction)hzToMidi, METH_O, hzToMidi_info},
{"midiToTranspo", (PyCFunction)midiToTranspo, METH_O, midiToTranspo_info},
{"sampsToSec", (PyCFunction)sampsToSec, METH_O, sampsToSec_info},
{"secToSamps", (PyCFunction)secToSamps, METH_O, secToSamps_info},
@@ -2154,7 +2249,7 @@ init_pyo64(void)
#endif
{
PyObject *m;
-
+
m = Py_InitModule3(LIB_BASE_NAME, pyo_functions, "Python digital signal processing module.");
#ifndef NO_MESSAGES
@@ -2207,6 +2302,7 @@ init_pyo64(void)
module_add_object(m, "TableMorph_base", &TableMorphType);
module_add_object(m, "TrigTableRec_base", &TrigTableRecType);
module_add_object(m, "TrigTableRecTimeStream_base", &TrigTableRecTimeStreamType);
+ module_add_object(m, "TableWrite_base", &TableWriteType);
module_add_object(m, "TablePut_base", &TablePutType);
module_add_object(m, "NewMatrix_base", &NewMatrixType);
module_add_object(m, "MatrixPointer_base", &MatrixPointerType);
@@ -2299,6 +2395,7 @@ init_pyo64(void)
module_add_object(m, "CtlScan2_base", &CtlScan2Type);
module_add_object(m, "MidiNote_base", &MidiNoteType);
module_add_object(m, "Notein_base", &NoteinType);
+ module_add_object(m, "NoteinTrig_base", &NoteinTrigType);
module_add_object(m, "Bendin_base", &BendinType);
module_add_object(m, "Touchin_base", &TouchinType);
module_add_object(m, "Programin_base", &PrograminType);
@@ -2376,6 +2473,7 @@ init_pyo64(void)
module_add_object(m, "M_Floor_base", &M_FloorType);
module_add_object(m, "M_Ceil_base", &M_CeilType);
module_add_object(m, "M_Round_base", &M_RoundType);
+ module_add_object(m, "M_Tanh_base", &M_TanhType);
module_add_object(m, "Snap_base", &SnapType);
module_add_object(m, "Interp_base", &InterpType);
module_add_object(m, "SampHold_base", &SampHoldType);
@@ -2385,6 +2483,7 @@ init_pyo64(void)
module_add_object(m, "CentsToTranspo_base", &CentsToTranspoType);
module_add_object(m, "TranspoToCents_base", &TranspoToCentsType);
module_add_object(m, "MToF_base", &MToFType);
+ module_add_object(m, "FToM_base", &FToMType);
module_add_object(m, "MToT_base", &MToTType);
module_add_object(m, "FFTMain_base", &FFTMainType);
module_add_object(m, "FFT_base", &FFTType);
@@ -2437,6 +2536,21 @@ init_pyo64(void)
module_add_object(m, "STReverb_base", &STReverbType);
module_add_object(m, "STRev_base", &STRevType);
module_add_object(m, "Pointer2_base", &Pointer2Type);
+ module_add_object(m, "Centroid_base", &CentroidType);
+ module_add_object(m, "AttackDetector_base", &AttackDetectorType);
+ module_add_object(m, "SmoothDelay_base", &SmoothDelayType);
+ module_add_object(m, "TrigBurster_base", &TrigBursterType);
+ module_add_object(m, "TrigBurst_base", &TrigBurstType);
+ module_add_object(m, "TrigBurstTapStream_base", &TrigBurstTapStreamType);
+ module_add_object(m, "TrigBurstAmpStream_base", &TrigBurstAmpStreamType);
+ module_add_object(m, "TrigBurstDurStream_base", &TrigBurstDurStreamType);
+ module_add_object(m, "TrigBurstEndStream_base", &TrigBurstEndStreamType);
+ module_add_object(m, "Scope_base", &ScopeType);
+ module_add_object(m, "PeakAmp_base", &PeakAmpType);
+ module_add_object(m, "MainParticle_base", &MainParticleType);
+ module_add_object(m, "Particle_base", &ParticleType);
+ module_add_object(m, "AtanTable_base", &AtanTableType);
+ module_add_object(m, "RawMidi_base", &RawMidiType);
PyModule_AddStringConstant(m, "PYO_VERSION", PYO_VERSION);
#ifdef COMPILE_EXTERNALS
@@ -2450,4 +2564,4 @@ init_pyo64(void)
#else
PyModule_AddIntConstant(m, "USE_DOUBLE", 1);
#endif
-}
+}
\ No newline at end of file
diff --git a/src/engine/servermodule.c b/src/engine/servermodule.c
index e7418c8..26fdb7d 100644
--- a/src/engine/servermodule.c
+++ b/src/engine/servermodule.c
@@ -1,25 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * GNU Lesser General Public License for more details. *
* *
- * Octobre 2013 : Multiple servers facility and embeded backend added by *
- * Guillaume Barrette. See embeded possibilities at: *
- * https://github.com/guibarrette/PyoPlug *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -53,11 +49,11 @@ static inline void Server_process_buffers(Server *server);
static int Server_start_rec_internal(Server *self, char *filename);
/* random objects count and multiplier to assign different seed to each instance. */
-#define num_rnd_objs 27
+#define num_rnd_objs 29
-int rnd_objs_count[num_rnd_objs] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+int rnd_objs_count[num_rnd_objs] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int rnd_objs_mult[num_rnd_objs] = {1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,
- 2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153, 2161,2179};
+ 2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207};
#ifdef USE_COREAUDIO
static int coreaudio_stop_callback(Server *self);
@@ -111,7 +107,7 @@ Server_warning(Server *self, char * format, ...)
void
Server_debug(Server *self, char * format, ...)
-{
+{
// Debug messages should print internal information which might be necessary for debugging internal conditions.
if (self->verbosity & 8) {
char buffer[256];
@@ -125,19 +121,22 @@ Server_debug(Server *self, char * format, ...)
}
/* Portmidi get input events */
-static void portmidiGetEvents(Server *self)
+static void portmidiGetEvents(Server *self)
{
+ int i;
PmError result;
PmEvent buffer;
- do {
- result = Pm_Poll(self->in);
- if (result) {
- if (Pm_Read(self->in, &buffer, 1) == pmBufferOverflow)
- continue;
- self->midiEvents[self->midi_count++] = buffer;
- }
- } while (result);
+ for (i=0; i<self->midiin_count; i++) {
+ do {
+ result = Pm_Poll(self->midiin[i]);
+ if (result) {
+ if (Pm_Read(self->midiin[i], &buffer, 1) == pmBufferOverflow)
+ continue;
+ self->midiEvents[self->midi_count++] = buffer;
+ }
+ } while (result);
+ }
}
/* Portaudio stuff */
@@ -153,7 +152,7 @@ static void portaudio_assert(PaError ecode, const char* cmdName) {
}
/* Portaudio callback function */
-static int
+static int
pa_callback_interleaved( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo* timeInfo,
@@ -165,7 +164,7 @@ pa_callback_interleaved( const void *inputBuffer, void *outputBuffer,
assert(framesPerBuffer == server->bufferSize);
int i, j, bufchnls, index1, index2;
-
+
/* avoid unused variable warnings */
(void) timeInfo;
(void) statusFlags;
@@ -173,14 +172,14 @@ pa_callback_interleaved( const void *inputBuffer, void *outputBuffer,
if (server->withPortMidi == 1) {
portmidiGetEvents(server);
}
-
+
if (server->duplex == 1) {
float *in = (float *)inputBuffer;
- bufchnls = server->nchnls + server->input_offset;
+ bufchnls = server->ichnls + server->input_offset;
for (i=0; i<server->bufferSize; i++) {
- index1 = i * server->nchnls;
+ index1 = i * server->ichnls;
index2 = i * bufchnls + server->input_offset;
- for (j=0; j<server->nchnls; j++) {
+ for (j=0; j<server->ichnls; j++) {
server->input_buffer[index1+j] = (MYFLT)in[index2+j];
}
}
@@ -196,18 +195,16 @@ pa_callback_interleaved( const void *inputBuffer, void *outputBuffer,
}
}
server->midi_count = 0;
-
- if (server->server_started == 1) {
- if (server->server_stopped == 1 && server->currentAmp < 0.0001)
- server->server_started = 0;
- return paContinue;
- }
- else {
+
+#ifdef _OSX_
+ if (server->server_stopped == 1)
return paComplete;
- }
+ else
+#endif
+ return paContinue;
}
-static int
+static int
pa_callback_nonInterleaved( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo* timeInfo,
@@ -216,14 +213,14 @@ pa_callback_nonInterleaved( const void *inputBuffer, void *outputBuffer,
{
float **out = (float **)outputBuffer;
Server *server = (Server *) arg;
-
+
assert(framesPerBuffer == server->bufferSize);
int i, j;
-
+
/* avoid unused variable warnings */
(void) timeInfo;
(void) statusFlags;
-
+
if (server->withPortMidi == 1) {
portmidiGetEvents(server);
}
@@ -231,8 +228,8 @@ pa_callback_nonInterleaved( const void *inputBuffer, void *outputBuffer,
if (server->duplex == 1) {
float **in = (float **)inputBuffer;
for (i=0; i<server->bufferSize; i++) {
- for (j=0; j<server->nchnls; j++) {
- server->input_buffer[(i*server->nchnls)+j] = (MYFLT)in[j+server->input_offset][i];
+ for (j=0; j<server->ichnls; j++) {
+ server->input_buffer[(i*server->ichnls)+j] = (MYFLT)in[j+server->input_offset][i];
}
}
}
@@ -244,15 +241,13 @@ pa_callback_nonInterleaved( const void *inputBuffer, void *outputBuffer,
}
}
server->midi_count = 0;
-
- if (server->server_started == 1) {
- if (server->server_stopped == 1 && server->currentAmp < 0.0001)
- server->server_started = 0;
- return paContinue;
- }
- else {
+
+#ifdef _OSX_
+ if (server->server_stopped == 1)
return paComplete;
- }
+ else
+#endif
+ return paContinue;
}
#ifdef USE_JACK
@@ -264,24 +259,24 @@ jack_callback (jack_nframes_t nframes, void *arg)
int i, j;
Server *server = (Server *) arg;
assert(nframes == server->bufferSize);
- jack_default_audio_sample_t *in_buffers[server->nchnls], *out_buffers[server->nchnls];
+ jack_default_audio_sample_t *in_buffers[server->ichnls], *out_buffers[server->nchnls];
if (server->withPortMidi == 1) {
portmidiGetEvents(server);
}
PyoJackBackendData *be_data = (PyoJackBackendData *) server->audio_be_data;
- for (i = 0; i < server->nchnls; i++) {
+ for (i = 0; i < server->ichnls; i++) {
in_buffers[i] = jack_port_get_buffer (be_data->jack_in_ports[i+server->input_offset], server->bufferSize);
}
for (i = 0; i < server->nchnls; i++) {
out_buffers[i] = jack_port_get_buffer (be_data->jack_out_ports[i+server->output_offset], server->bufferSize);
-
+
}
/* jack audio data is not interleaved */
if (server->duplex == 1) {
for (i=0; i<server->bufferSize; i++) {
- for (j=0; j<server->nchnls; j++) {
- server->input_buffer[(i*server->nchnls)+j] = (MYFLT) in_buffers[j][i];
+ for (j=0; j<server->ichnls; j++) {
+ server->input_buffer[(i*server->ichnls)+j] = (MYFLT) in_buffers[j][i];
}
}
}
@@ -292,7 +287,7 @@ jack_callback (jack_nframes_t nframes, void *arg)
}
}
server->midi_count = 0;
- return 0;
+ return 0;
}
static int
@@ -345,16 +340,16 @@ OSStatus coreaudio_input_callback(AudioDeviceID device, const AudioTimeStamp* in
const AudioBuffer* inputBuf = inInputData->mBuffers;
float *bufdata = (float*)inputBuf->mData;
bufchnls = inputBuf->mNumberChannels;
- servchnls = server->nchnls < bufchnls ? server->nchnls : bufchnls;
+ servchnls = server->ichnls < bufchnls ? server->ichnls : bufchnls;
for (i=0; i<server->bufferSize; i++) {
off1chnls = i*bufchnls+server->input_offset;
off2chnls = i*servchnls;
for (j=0; j<servchnls; j++) {
server->input_buffer[off2chnls+j] = (MYFLT)bufdata[off1chnls+j];
}
- }
- return kAudioHardwareNoError;
-}
+ }
+ return kAudioHardwareNoError;
+}
OSStatus coreaudio_output_callback(AudioDeviceID device, const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
@@ -371,7 +366,7 @@ OSStatus coreaudio_output_callback(AudioDeviceID device, const AudioTimeStamp* i
if (server->withPortMidi == 1) {
portmidiGetEvents(server);
}
-
+
Server_process_buffers(server);
AudioBuffer* outputBuf = outOutputData->mBuffers;
bufchnls = outputBuf->mNumberChannels;
@@ -382,31 +377,26 @@ OSStatus coreaudio_output_callback(AudioDeviceID device, const AudioTimeStamp* i
off2chnls = i*servchnls;
for(j=0; j<servchnls; j++) {
bufdata[off1chnls+j] = server->output_buffer[off2chnls+j];
- }
+ }
}
server->midi_count = 0;
- if (server->server_started == 1) {
- if (server->server_stopped == 1 && server->currentAmp < 0.0001)
- coreaudio_stop_callback(server);
- }
-
return kAudioHardwareNoError;
-}
+}
int
-coreaudio_stop_callback(Server *self)
+coreaudio_stop_callback(Server *self)
{
OSStatus err = kAudioHardwareNoError;
-
+
if (self->duplex == 1) {
err = AudioDeviceStop(self->input, coreaudio_input_callback);
if (err != kAudioHardwareNoError) {
Server_error(self, "Input AudioDeviceStop failed %d\n", (int)err);
return -1;
- }
+ }
}
-
+
err = AudioDeviceStop(self->output, coreaudio_output_callback);
if (err != kAudioHardwareNoError) {
Server_error(self, "Output AudioDeviceStop failed %d\n", (int)err);
@@ -420,7 +410,7 @@ coreaudio_stop_callback(Server *self)
static int
offline_process_block(Server *arg)
-{
+{
Server *server = (Server *) arg;
Server_process_buffers(server);
return 0;
@@ -456,7 +446,7 @@ Server_pa_init(Server *self)
if (self->output == -1)
outDevice = Pa_GetDefaultOutputDevice(); /* default output device */
else
- outDevice = (PaDeviceIndex) self->output; /* selected output device */
+ outDevice = (PaDeviceIndex) self->output; /* selected output device */
if (self->input == -1)
inDevice = Pa_GetDefaultInputDevice(); /* default input device */
else
@@ -482,12 +472,12 @@ Server_pa_init(Server *self)
sampleFormat = paFloat32;
streamCallback = pa_callback_interleaved;
}
- else {
+ else {
Server_debug(self, "Portaudio uses interleaved callback.\n");
sampleFormat = paFloat32;
streamCallback = pa_callback_interleaved;
}
-
+
/* setup output and input streams */
memset(&outputParameters, 0, sizeof(outputParameters));
@@ -500,7 +490,7 @@ Server_pa_init(Server *self)
if (self->duplex == 1) {
memset(&inputParameters, 0, sizeof(inputParameters));
inputParameters.device = inDevice;
- inputParameters.channelCount = self->nchnls + self->input_offset;
+ inputParameters.channelCount = self->ichnls + self->input_offset;
inputParameters.sampleFormat = sampleFormat;
inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultHighInputLatency ;
inputParameters.hostApiSpecificStreamInfo = NULL;
@@ -508,16 +498,44 @@ Server_pa_init(Server *self)
if (self->input == -1 && self->output == -1) {
if (self->duplex == 1)
- err = Pa_OpenDefaultStream(&be_data->stream, self->nchnls + self->input_offset, self->nchnls + self->output_offset, sampleFormat, self->samplingRate, self->bufferSize, streamCallback, (void *) self);
+ err = Pa_OpenDefaultStream(&be_data->stream,
+ self->ichnls + self->input_offset,
+ self->nchnls + self->output_offset,
+ sampleFormat,
+ self->samplingRate,
+ self->bufferSize,
+ streamCallback,
+ (void *) self);
else
- err = Pa_OpenDefaultStream(&be_data->stream, 0, self->nchnls + self->output_offset, sampleFormat, self->samplingRate, self->bufferSize, streamCallback, (void *) self);
+ err = Pa_OpenDefaultStream(&be_data->stream,
+ 0,
+ self->nchnls + self->output_offset,
+ sampleFormat,
+ self->samplingRate,
+ self->bufferSize,
+ streamCallback,
+ (void *) self);
}
else {
if (self->duplex == 1)
- err = Pa_OpenStream(&be_data->stream, &inputParameters, &outputParameters, self->samplingRate, self->bufferSize, paNoFlag, streamCallback, (void *) self);
+ err = Pa_OpenStream(&be_data->stream,
+ &inputParameters,
+ &outputParameters,
+ self->samplingRate,
+ self->bufferSize,
+ paNoFlag,
+ streamCallback,
+ (void *) self);
else
- err = Pa_OpenStream(&be_data->stream, (PaStreamParameters *) NULL, &outputParameters, self->samplingRate, self->bufferSize, paNoFlag, streamCallback, (void *) self);
- }
+ err = Pa_OpenStream(&be_data->stream,
+ (PaStreamParameters *) NULL,
+ &outputParameters,
+ self->samplingRate,
+ self->bufferSize,
+ paNoFlag,
+ streamCallback,
+ (void *) self);
+ }
portaudio_assert(err, "Pa_OpenStream");
if (err < 0) {
Server_error(self, "Portaudio error: %s", Pa_GetErrorText(err));
@@ -534,92 +552,140 @@ Server_pa_deinit(Server *self)
if (Pa_IsStreamActive(be_data->stream) || ! Pa_IsStreamStopped(be_data->stream)) {
self->server_started = 0;
- err = Pa_StopStream(be_data->stream);
- portaudio_assert(err, "Pa_StopStream");
+ err = Pa_AbortStream(be_data->stream);
+ portaudio_assert(err, "Pa_AbortStream");
}
-
+
err = Pa_CloseStream(be_data->stream);
portaudio_assert(err, "Pa_CloseStream");
-
+
err = Pa_Terminate();
portaudio_assert(err, "Pa_Terminate");
-
+
free(self->audio_be_data);
return err;
}
-int
+int
Server_pa_start(Server *self)
{
PaError err;
PyoPaBackendData *be_data = (PyoPaBackendData *) self->audio_be_data;
if (Pa_IsStreamActive(be_data->stream) || ! Pa_IsStreamStopped(be_data->stream)) {
- err = Pa_StopStream(be_data->stream);
- portaudio_assert(err, "Pa_StopStream");
+ err = Pa_AbortStream(be_data->stream);
+ portaudio_assert(err, "Pa_AbortStream");
}
err = Pa_StartStream(be_data->stream);
portaudio_assert(err, "Pa_StartStream");
return err;
}
-int
+int
Server_pa_stop(Server *self)
{
- self->timeStep = (int)(0.1 * self->samplingRate);
- self->amp = 0.;
+ PaError err;
+ PyoPaBackendData *be_data = (PyoPaBackendData *) self->audio_be_data;
+
+ if (Pa_IsStreamActive(be_data->stream) || ! Pa_IsStreamStopped(be_data->stream)) {
+#ifndef _OSX_
+ err = Pa_AbortStream(be_data->stream);
+ portaudio_assert(err, "Pa_AbortStream");
+#endif
+ }
+ self->server_started = 0;
self->server_stopped = 1;
return 0;
}
#ifdef USE_JACK
-
int
Server_jack_autoconnect (Server *self)
{
const char **ports;
- int i, ret = 0;
+ int i, j, num = 0, ret = 0;
PyoJackBackendData *be_data = (PyoJackBackendData *) self->audio_be_data;
-
+
if (self->jackautoin) {
- if ((ports = jack_get_ports (be_data->jack_client, NULL, NULL, JackPortIsOutput)) == NULL) {
- Server_error(self, "Jack: Cannot find any physical capture ports\n");
+ if ((ports = jack_get_ports (be_data->jack_client, "system", NULL, JackPortIsOutput)) == NULL) {
+ Server_error(self, "Jack: Cannot find any physical capture ports called 'system'\n");
ret = -1;
}
i=0;
while(ports[i]!=NULL && be_data->jack_in_ports[i] != NULL){
if (jack_connect (be_data->jack_client, ports[i], jack_port_name(be_data->jack_in_ports[i]))) {
- Server_error(self, "Jack: cannot connect input ports\n");
+ Server_error(self, "Jack: cannot connect input ports to 'system'\n");
ret = -1;
}
i++;
}
free (ports);
}
-
+
if (self->jackautoout) {
- if ((ports = jack_get_ports (be_data->jack_client, NULL, NULL, JackPortIsInput)) == NULL) {
- Server_error(self, "Jack: Cannot find any physical playback ports\n");
+ if ((ports = jack_get_ports (be_data->jack_client, "system", NULL, JackPortIsInput)) == NULL) {
+ Server_error(self, "Jack: Cannot find any physical playback ports called 'system'\n");
ret = -1;
}
-
+
i=0;
while(ports[i]!=NULL && be_data->jack_out_ports[i] != NULL){
if (jack_connect (be_data->jack_client, jack_port_name (be_data->jack_out_ports[i]), ports[i])) {
- Server_error(self, "Jack: cannot connect output ports\n");
+ Server_error(self, "Jack: cannot connect output ports to 'system'\n");
ret = -1;
}
i++;
}
free (ports);
}
+
+ num = PyList_Size(self->jackAutoConnectInputPorts);
+ if (num > 0) {
+ for (j=0; j<num; j++) {
+ if ((ports = jack_get_ports (be_data->jack_client, PyString_AsString(PyList_GetItem(self->jackAutoConnectInputPorts, j)), NULL, JackPortIsOutput)) == NULL) {
+ Server_error(self, "Jack: cannot connect input ports to %s\n", PyString_AsString(PyList_GetItem(self->jackAutoConnectInputPorts, j)));
+ }
+ else {
+ i = 0;
+ while(ports[i] != NULL && be_data->jack_in_ports[i] != NULL){
+ if (jack_connect (be_data->jack_client, ports[i], jack_port_name (be_data->jack_in_ports[i]))) {
+ Server_error(self, "Jack: cannot connect input ports\n");
+ ret = -1;
+ }
+ i++;
+ }
+ free (ports);
+ }
+ }
+ }
+
+ num = PyList_Size(self->jackAutoConnectOutputPorts);
+ if (num > 0) {
+ for (j=0; j<num; j++) {
+ if ((ports = jack_get_ports (be_data->jack_client, PyString_AsString(PyList_GetItem(self->jackAutoConnectOutputPorts, j)), NULL, JackPortIsInput)) == NULL) {
+ Server_error(self, "Jack: cannot connect output ports to %s\n", PyString_AsString(PyList_GetItem(self->jackAutoConnectOutputPorts, j)));
+ }
+ else {
+ i = 0;
+ while(ports[i] != NULL && be_data->jack_out_ports[i] != NULL){
+ if (jack_connect (be_data->jack_client, jack_port_name (be_data->jack_out_ports[i]), ports[i])) {
+ Server_error(self, "Jack: cannot connect output ports\n");
+ ret = -1;
+ }
+ i++;
+ }
+ free (ports);
+ }
+ }
+ }
+
return ret;
}
int
Server_jack_init (Server *self)
-{
+{
char client_name[32];
char name[16];
const char *server_name = "server";
@@ -634,7 +700,7 @@ Server_jack_init (Server *self)
assert(self->audio_be_data == NULL);
PyoJackBackendData *be_data = (PyoJackBackendData *) malloc(sizeof(PyoJackBackendData *));
self->audio_be_data = (void *) be_data;
- be_data->jack_in_ports = (jack_port_t **) calloc(self->nchnls + self->input_offset, sizeof(jack_port_t *));
+ be_data->jack_in_ports = (jack_port_t **) calloc(self->ichnls + self->input_offset, sizeof(jack_port_t *));
be_data->jack_out_ports = (jack_port_t **) calloc(self->nchnls + self->output_offset, sizeof(jack_port_t *));
strncpy(client_name,self->serverName, 32);
be_data->jack_client = jack_client_open (client_name, options, &status, server_name);
@@ -653,7 +719,7 @@ Server_jack_init (Server *self)
strcpy(self->serverName, jack_get_client_name(be_data->jack_client));
Server_warning(self, "Jack name `%s' assigned\n", self->serverName);
}
-
+
sampleRate = jack_get_sample_rate (be_data->jack_client);
if (sampleRate != self->samplingRate) {
self->samplingRate = (double)sampleRate;
@@ -676,13 +742,13 @@ Server_jack_init (Server *self)
Server_debug(self, "Jack engine buffer size: %" PRIu32 "\n", bufferSize);
}
- nchnls = total_nchnls = self->nchnls + self->input_offset;
+ nchnls = total_nchnls = self->ichnls + self->input_offset;
while (nchnls-- > 0) {
index = total_nchnls - nchnls - 1;
ret = sprintf(name, "input_%i", index + 1);
if (ret > 0) {
be_data->jack_in_ports[index]
- = jack_port_register (be_data->jack_client, name,
+ = jack_port_register (be_data->jack_client, name,
JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
}
@@ -697,8 +763,8 @@ Server_jack_init (Server *self)
index = total_nchnls - nchnls - 1;
ret = sprintf(name, "output_%i", index + 1);
if (ret > 0) {
- be_data->jack_out_ports[index]
- = jack_port_register (be_data->jack_client, name,
+ be_data->jack_out_ports[index]
+ = jack_port_register (be_data->jack_client, name,
JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
}
if ((be_data->jack_out_ports[index] == NULL)) {
@@ -713,7 +779,7 @@ Server_jack_init (Server *self)
return 0;
}
-int
+int
Server_jack_deinit (Server *self)
{
int ret = 0;
@@ -725,7 +791,7 @@ Server_jack_deinit (Server *self)
return ret;
}
-int
+int
Server_jack_start (Server *self)
{
PyoJackBackendData *be_data = (PyoJackBackendData *) self->audio_be_data;
@@ -736,12 +802,11 @@ Server_jack_start (Server *self)
Server_shut_down(self);
return -1;
}
- //if (self->jackauto)
Server_jack_autoconnect(self);
return 0;
}
-int
+int
Server_jack_stop (Server *self)
{
PyoJackBackendData *be_data = (PyoJackBackendData *) self->audio_be_data;
@@ -764,15 +829,15 @@ Server_coreaudio_init(Server *self)
AudioDeviceID mInputDevice = kAudioDeviceUnknown;
Boolean writable;
AudioTimeStamp now;
-
+
now.mFlags = kAudioTimeStampHostTimeValid;
now.mHostTime = AudioGetCurrentHostTime();
/************************************/
/* List Coreaudio available devices */
- /************************************/
+ /************************************/
err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &count, 0);
- AudioDeviceID *devices = (AudioDeviceID*) malloc(count);
+ AudioDeviceID *devices = (AudioDeviceID*) malloc(count);
err = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &count, devices);
if (err != kAudioHardwareNoError) {
Server_error(self, "Get kAudioHardwarePropertyDevices error %s\n", (char*)&err);
@@ -788,7 +853,7 @@ Server_coreaudio_init(Server *self)
Server_error(self, "Info kAudioDevicePropertyDeviceName error %s A %d %08X\n", (char*)&err, i, devices[i]);
break;
}
-
+
char *name = (char*)malloc(count);
err = AudioDeviceGetProperty(devices[i], 0, false, kAudioDevicePropertyDeviceName, &count, name);
if (err != kAudioHardwareNoError) {
@@ -798,16 +863,16 @@ Server_coreaudio_init(Server *self)
}
Server_debug(self, " %d : \"%s\"\n", i, name);
free(name);
- }
-
+ }
+
/************************************/
/* Acquire input and output devices */
- /************************************/
- /* Acquire input audio device */
+ /************************************/
+ /* Acquire input audio device */
if (self->duplex == 1) {
if (self->input != -1)
mInputDevice = devices[self->input];
-
+
if (mInputDevice==kAudioDeviceUnknown) {
count = sizeof(mInputDevice);
err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &count, (void *) &mInputDevice);
@@ -815,12 +880,12 @@ Server_coreaudio_init(Server *self)
Server_error(self, "Get kAudioHardwarePropertyDefaultInputDevice error %s\n", (char*)&err);
return -1;
}
- }
-
+ }
+
err = AudioDeviceGetPropertyInfo(mInputDevice, 0, false, kAudioDevicePropertyDeviceName, &namelen, 0);
if (err != kAudioHardwareNoError) {
Server_error(self, "Info kAudioDevicePropertyDeviceName error %s A %08X\n", (char*)&err, mInputDevice);
- }
+ }
name = (char*)malloc(namelen);
err = AudioDeviceGetProperty(mInputDevice, 0, false, kAudioDevicePropertyDeviceName, &namelen, name);
if (err != kAudioHardwareNoError) {
@@ -829,12 +894,12 @@ Server_coreaudio_init(Server *self)
Server_debug(self, "Coreaudio : Uses input device : \"%s\"\n", name);
self->input = mInputDevice;
free(name);
- }
-
- /* Acquire output audio device */
+ }
+
+ /* Acquire output audio device */
if (self->output != -1)
mOutputDevice = devices[self->output];
-
+
if (mOutputDevice==kAudioDeviceUnknown) {
count = sizeof(mOutputDevice);
err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &count, (void *) &mOutputDevice);
@@ -847,7 +912,7 @@ Server_coreaudio_init(Server *self)
err = AudioDeviceGetPropertyInfo(mOutputDevice, 0, false, kAudioDevicePropertyDeviceName, &namelen, 0);
if (err != kAudioHardwareNoError) {
Server_error(self, "Info kAudioDevicePropertyDeviceName error %s A %08X\n", (char*)&err, mOutputDevice);
- }
+ }
name = (char*)malloc(namelen);
err = AudioDeviceGetProperty(mOutputDevice, 0, false, kAudioDevicePropertyDeviceName, &namelen, name);
if (err != kAudioHardwareNoError) {
@@ -856,7 +921,7 @@ Server_coreaudio_init(Server *self)
Server_debug(self, "Coreaudio : Uses output device : \"%s\"\n", name);
self->output = mOutputDevice;
free(name);
-
+
/*************************************************/
/* Get in/out buffer frame and buffer frame size */
/*************************************************/
@@ -871,13 +936,13 @@ Server_coreaudio_init(Server *self)
if (err != kAudioHardwareNoError)
Server_error(self, "Get kAudioDevicePropertyBufferFrameSize error %s\n", (char*)&err);
Server_debug(self, "Coreaudio : Coreaudio input device buffer size = %ld\n", bufferSize);
-
+
count = sizeof(AudioValueRange);
err = AudioDeviceGetProperty(mInputDevice, 0, false, kAudioDevicePropertyBufferSizeRange, &count, &range);
if (err != kAudioHardwareNoError)
Server_error(self, "Get kAudioDevicePropertyBufferSizeRange error %s\n", (char*)&err);
Server_debug(self, "Coreaudio : Coreaudio input device buffer size range = %f -> %f\n", range.mMinimum, range.mMaximum);
-
+
/* Get input device sampling rate */
count = sizeof(Float64);
err = AudioDeviceGetProperty(mInputDevice, 0, false, kAudioDevicePropertyNominalSampleRate, &count, &sampleRate);
@@ -885,7 +950,7 @@ Server_coreaudio_init(Server *self)
Server_debug(self, "Get kAudioDevicePropertyNominalSampleRate error %s\n", (char*)&err);
Server_debug(self, "Coreaudio : Coreaudio input device sampling rate = %.2f\n", sampleRate);
}
-
+
/* Get output device buffer frame size and buffer frame size range */
count = sizeof(UInt32);
err = AudioDeviceGetProperty(mOutputDevice, 0, false, kAudioDevicePropertyBufferFrameSize, &count, &bufferSize);
@@ -898,7 +963,7 @@ Server_coreaudio_init(Server *self)
if (err != kAudioHardwareNoError)
Server_error(self, "Get kAudioDevicePropertyBufferSizeRange error %s\n", (char*)&err);
Server_debug(self, "Coreaudio : Coreaudio output device buffer size range = %.2f -> %.2f\n", range.mMinimum, range.mMaximum);
-
+
/* Get output device sampling rate */
count = sizeof(Float64);
err = AudioDeviceGetProperty(mOutputDevice, 0, false, kAudioDevicePropertyNominalSampleRate, &count, &sampleRate);
@@ -906,7 +971,7 @@ Server_coreaudio_init(Server *self)
Server_debug(self, "Get kAudioDevicePropertyNominalSampleRate error %s\n", (char*)&err);
Server_debug(self, "Coreaudio : Coreaudio output device sampling rate = %.2f\n", sampleRate);
-
+
/****************************************/
/********* Set audio properties *********/
/****************************************/
@@ -921,7 +986,7 @@ Server_coreaudio_init(Server *self)
Server_error(self, "set kAudioDevicePropertyBufferFrameSize error %4.4s\n", (char*)&err);
else
Server_debug(self, "pyo buffer size set to output device buffer size : %i\n", self->bufferSize);
- }
+ }
else
Server_debug(self, "Coreaudio : Changed output device buffer size successfully: %i\n", self->bufferSize);
@@ -929,8 +994,8 @@ Server_coreaudio_init(Server *self)
err = AudioDeviceSetProperty(mInputDevice, &now, 0, false, kAudioDevicePropertyBufferFrameSize, count, &self->bufferSize);
if (err != kAudioHardwareNoError) {
Server_error(self, "set kAudioDevicePropertyBufferFrameSize error %4.4s\n", (char*)&err);
- }
- }
+ }
+ }
/* set/get the sampling rate for the devices */
count = sizeof(double);
@@ -938,23 +1003,23 @@ Server_coreaudio_init(Server *self)
err = AudioDeviceSetProperty(mOutputDevice, &now, 0, false, kAudioDevicePropertyNominalSampleRate, count, &pyoSamplingRate);
if (err != kAudioHardwareNoError) {
Server_error(self, "set kAudioDevicePropertyNominalSampleRate error %s\n", (char*)&err);
- self->samplingRate = (double)sampleRate;
+ self->samplingRate = (double)sampleRate;
err = AudioDeviceSetProperty(mOutputDevice, &now, 0, false, kAudioDevicePropertyNominalSampleRate, count, &sampleRate);
if (err != kAudioHardwareNoError)
Server_error(self, "set kAudioDevicePropertyNominalSampleRate error %s\n", (char*)&err);
- else
+ else
Server_debug(self, "pyo sampling rate set to output device sampling rate : %i\n", self->samplingRate);
}
else
Server_debug(self, "Coreaudio : Changed output device sampling rate successfully: %.2f\n", self->samplingRate);
-
+
if (self->duplex ==1) {
pyoSamplingRate = self->samplingRate;
err = AudioDeviceSetProperty(mInputDevice, &now, 0, false, kAudioDevicePropertyNominalSampleRate, count, &pyoSamplingRate);
if (err != kAudioHardwareNoError) {
Server_error(self, "set kAudioDevicePropertyNominalSampleRate error %s\n", (char*)&err);
}
- }
+ }
/****************************************/
@@ -969,14 +1034,14 @@ Server_coreaudio_init(Server *self)
err = AudioDeviceGetProperty(mInputDevice, 0, true, kAudioDevicePropertyStreamFormat, &count, &inputStreamDescription);
if (err != kAudioHardwareNoError)
Server_debug(self, "Get kAudioDevicePropertyStreamFormat error %s\n", (char*)&err);
-
+
/*
inputStreamDescription.mSampleRate = (Float64)self->samplingRate;
-
+
err = AudioDeviceSetProperty(mInputDevice, &now, 0, false, kAudioDevicePropertyStreamFormat, count, &inputStreamDescription);
if (err != kAudioHardwareNoError)
Server_debug(self, "-- Set kAudioDevicePropertyStreamFormat error %s\n", (char*)&err);
-
+
// Print new input stream description
err = AudioDeviceGetProperty(mInputDevice, 0, true, kAudioDevicePropertyStreamFormat, &count, &inputStreamDescription);
if (err != kAudioHardwareNoError)
@@ -986,22 +1051,22 @@ Server_coreaudio_init(Server *self)
Server_debug(self, "Coreaudio : Coreaudio driver input stream bytes per frame = %i\n", inputStreamDescription.mBytesPerFrame);
Server_debug(self, "Coreaudio : Coreaudio driver input stream number of channels = %i\n", inputStreamDescription.mChannelsPerFrame);
}
-
+
/* Get output device stream configuration */
count = sizeof(AudioStreamBasicDescription);
- err = AudioDeviceGetProperty(mOutputDevice, 0, false, kAudioDevicePropertyStreamFormat, &count, &outputStreamDescription);
+ err = AudioDeviceGetProperty(mOutputDevice, 0, false, kAudioDevicePropertyStreamFormat, &count, &outputStreamDescription);
if (err != kAudioHardwareNoError)
Server_debug(self, "Get kAudioDevicePropertyStreamFormat error %s\n", (char*)&err);
/*
outputStreamDescription.mSampleRate = (Float64)self->samplingRate;
-
- err = AudioDeviceSetProperty(mOutputDevice, &now, 0, false, kAudioDevicePropertyStreamFormat, count, &outputStreamDescription);
+
+ err = AudioDeviceSetProperty(mOutputDevice, &now, 0, false, kAudioDevicePropertyStreamFormat, count, &outputStreamDescription);
if (err != kAudioHardwareNoError)
Server_debug(self, "Set kAudioDevicePropertyStreamFormat error %s\n", (char*)&err);
-
+
// Print new output stream description
- err = AudioDeviceGetProperty(mOutputDevice, 0, false, kAudioDevicePropertyStreamFormat, &count, &outputStreamDescription);
+ err = AudioDeviceGetProperty(mOutputDevice, 0, false, kAudioDevicePropertyStreamFormat, &count, &outputStreamDescription);
if (err != kAudioHardwareNoError)
Server_debug(self, "Get kAudioDevicePropertyStreamFormat error %s\n", (char*)&err);
*/
@@ -1014,11 +1079,11 @@ Server_coreaudio_init(Server *self)
/********* Set input and output callbacks *********/
/**************************************************/
if (self->duplex == 1) {
- err = AudioDeviceAddIOProc(self->input, coreaudio_input_callback, (void *) self); // setup our device with an IO proc
+ err = AudioDeviceAddIOProc(self->input, coreaudio_input_callback, (void *) self); // setup our device with an IO proc
if (err != kAudioHardwareNoError) {
Server_error(self, "Input AudioDeviceAddIOProc failed %d\n", (int)err);
return -1;
- }
+ }
err = AudioDeviceGetPropertyInfo(self->input, 0, true, kAudioDevicePropertyIOProcStreamUsage, &propertySize, &writable);
AudioHardwareIOProcStreamUsage *input_su = (AudioHardwareIOProcStreamUsage*)malloc(propertySize);
input_su->mIOProc = (void*)coreaudio_input_callback;
@@ -1028,8 +1093,8 @@ Server_coreaudio_init(Server *self)
}
err = AudioDeviceSetProperty(self->input, &now, 0, true, kAudioDevicePropertyIOProcStreamUsage, propertySize, input_su);
}
-
- err = AudioDeviceAddIOProc(self->output, coreaudio_output_callback, (void *) self); // setup our device with an IO proc
+
+ err = AudioDeviceAddIOProc(self->output, coreaudio_output_callback, (void *) self); // setup our device with an IO proc
if (err != kAudioHardwareNoError) {
Server_error(self, "Output AudioDeviceAddIOProc failed %d\n", (int)err);
return -1;
@@ -1042,11 +1107,11 @@ Server_coreaudio_init(Server *self)
output_su->mStreamIsOn[i] = 1;
}
err = AudioDeviceSetProperty(self->output, &now, 0, false, kAudioDevicePropertyIOProcStreamUsage, propertySize, output_su);
-
+
return 0;
}
-int
+int
Server_coreaudio_deinit(Server *self)
{
OSStatus err = kAudioHardwareNoError;
@@ -1056,19 +1121,19 @@ Server_coreaudio_deinit(Server *self)
if (err != kAudioHardwareNoError) {
Server_error(self, "Input AudioDeviceRemoveIOProc failed %d\n", (int)err);
return -1;
- }
+ }
}
-
+
err = AudioDeviceRemoveIOProc(self->output, coreaudio_output_callback);
if (err != kAudioHardwareNoError) {
Server_error(self, "Output AudioDeviceRemoveIOProc failed %d\n", (int)err);
return -1;
}
-
+
return 0;
}
-int
+int
Server_coreaudio_start(Server *self)
{
OSStatus err = kAudioHardwareNoError;
@@ -1078,22 +1143,21 @@ Server_coreaudio_start(Server *self)
if (err != kAudioHardwareNoError) {
Server_error(self, "Input AudioDeviceStart failed %d\n", (int)err);
return -1;
- }
+ }
}
-
+
err = AudioDeviceStart(self->output, coreaudio_output_callback);
if (err != kAudioHardwareNoError) {
Server_error(self, "Output AudioDeviceStart failed %d\n", (int)err);
return -1;
}
return 0;
-}
+}
int
Server_coreaudio_stop(Server *self)
{
- self->timeStep = (int)(0.1 * self->samplingRate);
- self->amp = 0.;
+ coreaudio_stop_callback(self);
self->server_stopped = 1;
return 0;
}
@@ -1112,13 +1176,13 @@ Server_offline_deinit(Server *self)
return 0;
}
-void
+void
*Server_offline_thread(void *arg)
{
int numBlocks;
Server *self;
self = (Server *)arg;
-
+
if (self->recdur < 0) {
Server_error(self,"Duration must be specified for Offline Server (see Server.recordOptions).");
}
@@ -1128,12 +1192,12 @@ void
Server_debug(self,"Number of blocks: %i\n", numBlocks);
Server_start_rec_internal(self, self->recpath);
while (numBlocks-- > 0 && self->server_stopped == 0) {
- offline_process_block((Server *) self);
+ offline_process_block((Server *) self);
}
self->server_started = 0;
self->record = 0;
sf_close(self->recfile);
- Server_message(self,"Offline Server rendering finished.\n");
+ Server_message(self,"Offline Server rendering finished.\n");
}
return NULL;
}
@@ -1150,7 +1214,7 @@ int
Server_offline_start(Server *self)
{
int numBlocks;
-
+
if (self->recdur < 0) {
Server_error(self,"Duration must be specified for Offline Server (see Server.recordOptions).");
return -1;
@@ -1160,12 +1224,12 @@ Server_offline_start(Server *self)
Server_debug(self,"Number of blocks: %i\n", numBlocks);
Server_start_rec_internal(self, self->recpath);
while (numBlocks-- > 0 && self->server_stopped == 0) {
- offline_process_block((Server *) self);
+ offline_process_block((Server *) self);
}
self->server_started = 0;
self->record = 0;
sf_close(self->recfile);
- Server_message(self,"Offline Server rendering finished.\n");
+ Server_message(self,"Offline Server rendering finished.\n");
return 0;
}
@@ -1219,11 +1283,11 @@ Server_embedded_ni_start(Server *self)
/* Non-Interleaved */
for (i=0; i<self->bufferSize; i++) {
for (j=0; j<=self->nchnls; j++) {
- /* This could probably be more efficient (ob) */
+ /* TODO: This could probably be more efficient (ob) */
self->output_buffer[i+(self->bufferSize*(j+1))-self->bufferSize] = out[(i*self->nchnls)+j];
}
}
-
+
return 0;
}
@@ -1234,12 +1298,12 @@ Server_embedded_ni_startIdx(int idx)
return 0;
}
-void
+void
*Server_embedded_thread(void *arg)
{
Server *self;
self = (Server *)arg;
-
+
Server_process_buffers(self);
return NULL;
@@ -1253,7 +1317,7 @@ Server_embedded_nb_start(Server *self)
return 0;
}
-/* this stop function is not very useful since the processing is stopped at the end
+/* this stop function is not very useful since the processing is stopped at the end
of every processing callback, but function put to not break pyo */
int
Server_embedded_stop(Server *self)
@@ -1269,7 +1333,7 @@ Server_embedded_stop(Server *self)
static inline void
Server_process_buffers(Server *server)
{
- float *out = server->output_buffer;
+ float *out = server->output_buffer;
MYFLT buffer[server->nchnls][server->bufferSize];
int i, j, chnl;
int nchnls = server->nchnls;
@@ -1292,7 +1356,7 @@ Server_process_buffers(Server *server)
}
if (Stream_getDuration(stream_tmp) != 0) {
Stream_IncrementDurationCount(stream_tmp);
- }
+ }
}
else if (Stream_getBufferCountWait(stream_tmp) != 0)
Stream_IncrementBufferCount(stream_tmp);
@@ -1310,7 +1374,7 @@ Server_process_buffers(Server *server)
server->stepVal = (amp - server->currentAmp) / server->timeStep;
server->lastAmp = amp;
}
-
+
for (i=0; i < server->bufferSize; i++){
if (server->timeCount < server->timeStep) {
server->currentAmp += server->stepVal;
@@ -1340,17 +1404,17 @@ Server_process_gui(Server *server)
if (outAmp > rms[j])
rms[j] = outAmp;
}
- }
+ }
if (server->gcount <= server->numPass) {
- for (j=0; j<server->nchnls; j++) {
+ for (j=0; j<server->nchnls; j++) {
server->lastRms[j] = (rms[j] + server->lastRms[j]) * 0.5;
- }
+ }
server->gcount++;
}
else {
- for (j=0; j<server->nchnls; j++) {
+ for (j=0; j<server->nchnls; j++) {
server->lastRms[j] = (rms[j] + server->lastRms[j]) * 0.5;
- }
+ }
switch (server->nchnls) {
case 1:
PyObject_CallMethod((PyObject *)server->GUI, "setRms", "f", server->lastRms[0]);
@@ -1376,7 +1440,7 @@ Server_process_gui(Server *server)
case 8:
PyObject_CallMethod((PyObject *)server->GUI, "setRms", "ffffffff", server->lastRms[0], server->lastRms[1], server->lastRms[2], server->lastRms[3], server->lastRms[4], server->lastRms[5], server->lastRms[6], server->lastRms[7]);
break;
- }
+ }
server->gcount = 0;
}
}
@@ -1387,7 +1451,7 @@ Server_process_time(Server *server)
int hours, minutes, seconds, milliseconds;
float sr = server->samplingRate;
double sampsToSecs;
-
+
if (server->tcount <= server->timePass) {
server->tcount++;
}
@@ -1399,14 +1463,14 @@ Server_process_time(Server *server)
hours = minutes / 60;
minutes = minutes % 60;
seconds = seconds % 60;
- PyObject_CallMethod((PyObject *)server->TIME, "setTime", "iiii", hours, minutes, seconds, milliseconds);
+ PyObject_CallMethod((PyObject *)server->TIME, "setTime", "iiii", hours, minutes, seconds, milliseconds);
server->tcount = 0;
}
}
/***************************************************/
-/* Global function called by any new audio object to
+/* Global function called by any new audio object to
get a pointer to the server */
PyObject *
PyServer_get_server()
@@ -1427,7 +1491,7 @@ Server_shut_down(Server *self)
if (self->server_started == 1) {
Server_stop((Server *)self);
}
-
+
for (i=0; i<num_rnd_objs; i++) {
rnd_objs_count[i] = 0;
}
@@ -1435,26 +1499,26 @@ Server_shut_down(Server *self)
switch (self->audio_be_type) {
case PyoPortaudio:
ret = Server_pa_deinit(self);
- break;
+ break;
case PyoCoreaudio:
-#ifdef USE_COREAUDIO
+#ifdef USE_COREAUDIO
ret = Server_coreaudio_deinit(self);
-#endif
- break;
- case PyoJack:
-#ifdef USE_JACK
+#endif
+ break;
+ case PyoJack:
+#ifdef USE_JACK
ret = Server_jack_deinit(self);
-#endif
- break;
+#endif
+ break;
case PyoOffline:
- ret = Server_offline_deinit(self);
- break;
+ ret = Server_offline_deinit(self);
+ break;
case PyoOfflineNB:
- ret = Server_offline_deinit(self);
- break;
+ ret = Server_offline_deinit(self);
+ break;
case PyoEmbedded:
ret = Server_embedded_deinit(self);
- break;
+ break;
}
self->server_booted = 0;
if (ret < 0) {
@@ -1465,23 +1529,29 @@ Server_shut_down(Server *self)
return Py_None;
}
+/* handling of PyObjects */
static int
Server_traverse(Server *self, visitproc visit, void *arg)
{
+ /* GUI and TIME ? */
Py_VISIT(self->streams);
+ Py_VISIT(self->jackAutoConnectInputPorts);
+ Py_VISIT(self->jackAutoConnectOutputPorts);
return 0;
}
-static int
+static int
Server_clear(Server *self)
-{
+{
Py_CLEAR(self->streams);
+ Py_CLEAR(self->jackAutoConnectInputPorts);
+ Py_CLEAR(self->jackAutoConnectOutputPorts);
return 0;
}
static void
Server_dealloc(Server* self)
-{
+{
if (self->server_booted == 1)
Server_shut_down(self);
Server_clear(self);
@@ -1498,22 +1568,24 @@ Server_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
/* Unused variables to allow the safety check of the embeded audio backend. */
double samplingRate = 44100.0;
int nchnls = 2;
+ int ichnls = 2;
int bufferSize = 256;
int duplex = 0;
char *audioType = "portaudio";
char *serverName = "pyo";
-
- static char *kwlist[] = {"sr", "nchnls", "buffersize", "duplex", "audio", "jackname", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "|diiiss", kwlist,
- &samplingRate, &nchnls, &bufferSize, &duplex, &audioType, &serverName))
- Py_RETURN_FALSE;
-
+
+ static char *kwlist[] = {"sr", "nchnls", "buffersize", "duplex", "audio", "jackname", "ichnls", NULL};
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "|diiissi", kwlist,
+ &samplingRate, &nchnls, &bufferSize, &duplex, &audioType, &serverName, &ichnls)) {
+ Py_INCREF(Py_False);
+ return Py_False;
+ }
+
if (strcmp(audioType, "embedded") != 0)
{
if (PyServer_get_server() != NULL) {
- Server_warning((Server *) PyServer_get_server(), "Warning: A Server is already created!\n"
- "If you put this Server in a new variable, please delete it!\n");
- return PyServer_get_server();
+ PyErr_SetString(PyExc_RuntimeError, "Warning: Trying to create a new Server object while one is already created!\n");
+ Py_RETURN_NONE;
}
}
@@ -1524,7 +1596,8 @@ Server_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
}
if(serverID == MAX_NBR_SERVER){
- return PyString_FromString("You are already using the maximum number of server allowed!");
+ PyErr_SetString(PyExc_RuntimeError, "You are already using the maximum number of server allowed!\n");
+ Py_RETURN_NONE;
}
Server *self;
@@ -1534,8 +1607,11 @@ Server_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->serverName = (char *) calloc(32, sizeof(char));
self->jackautoin = 1;
self->jackautoout = 1;
+ self->jackAutoConnectInputPorts = PyList_New(0);
+ self->jackAutoConnectOutputPorts = PyList_New(0);
self->samplingRate = 44100.0;
self->nchnls = 2;
+ self->ichnls = 2;
self->record = 0;
self->bufferSize = 256;
self->duplex = 0;
@@ -1543,6 +1619,8 @@ Server_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->output = -1;
self->input_offset = 0;
self->output_offset = 0;
+ self->midiin_count = 0;
+ self->midiout_count = 0;
self->midi_input = -1;
self->midi_output = -1;
self->amp = self->resetAmp = 1.;
@@ -1564,14 +1642,13 @@ Server_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int
Server_init(Server *self, PyObject *args, PyObject *kwds)
{
- static char *kwlist[] = {"sr", "nchnls", "buffersize", "duplex", "audio", "jackname", NULL};
-
+ static char *kwlist[] = {"sr", "nchnls", "buffersize", "duplex", "audio", "jackname", "ichnls", NULL};
+
char *audioType = "portaudio";
char *serverName = "pyo";
- //Server_debug(self, "Server_init. Compiled " TIMESTAMP "\n"); // Only for debugging purposes
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "|diiiss", kwlist,
- &self->samplingRate, &self->nchnls, &self->bufferSize, &self->duplex, &audioType, &serverName))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "|diiissi", kwlist,
+ &self->samplingRate, &self->nchnls, &self->bufferSize, &self->duplex, &audioType, &serverName, &self->ichnls))
return -1;
if (strcmp(audioType, "jack") == 0) {
self->audio_be_type = PyoJack;
@@ -1581,13 +1658,13 @@ Server_init(Server *self, PyObject *args, PyObject *kwds)
}
else if (strcmp(audioType, "coreaudio") == 0) {
self->audio_be_type = PyoCoreaudio;
- }
+ }
else if (strcmp(audioType, "offline") == 0) {
self->audio_be_type = PyoOffline;
- }
+ }
else if (strcmp(audioType, "offline_nb") == 0) {
self->audio_be_type = PyoOfflineNB;
- }
+ }
else if (strcmp(audioType, "embedded") == 0) {
self->audio_be_type = PyoEmbedded;
}
@@ -1607,7 +1684,7 @@ static PyObject *
Server_setDefaultRecPath(Server *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"path", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &self->recpath))
return PyInt_FromLong(-1);
@@ -1623,7 +1700,7 @@ Server_setInputOffset(Server *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
- if (arg != NULL) {
+ if (arg != NULL) {
if (PyInt_Check(arg))
self->input_offset = PyInt_AsLong(arg);
}
@@ -1639,7 +1716,7 @@ Server_setOutputOffset(Server *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
- if (arg != NULL) {
+ if (arg != NULL) {
if (PyInt_Check(arg))
self->output_offset = PyInt_AsLong(arg);
}
@@ -1650,7 +1727,7 @@ Server_setOutputOffset(Server *self, PyObject *arg)
static PyObject *
Server_setInputDevice(Server *self, PyObject *arg)
{
- if (arg != NULL) {
+ if (arg != NULL) {
if (PyInt_Check(arg))
self->input = PyInt_AsLong(arg);
}
@@ -1661,7 +1738,7 @@ Server_setInputDevice(Server *self, PyObject *arg)
static PyObject *
Server_setInOutDevice(Server *self, PyObject *arg)
{
- if (arg != NULL) {
+ if (arg != NULL) {
if (PyInt_Check(arg))
self->input = PyInt_AsLong(arg);
self->output = PyInt_AsLong(arg);
@@ -1673,7 +1750,7 @@ Server_setInOutDevice(Server *self, PyObject *arg)
static PyObject *
Server_setOutputDevice(Server *self, PyObject *arg)
{
- if (arg != NULL) {
+ if (arg != NULL) {
if (PyInt_Check(arg))
self->output = PyInt_AsLong(arg);
}
@@ -1684,7 +1761,7 @@ Server_setOutputDevice(Server *self, PyObject *arg)
static PyObject *
Server_setMidiInputDevice(Server *self, PyObject *arg)
{
- if (arg != NULL) {
+ if (arg != NULL) {
if (PyInt_Check(arg))
self->midi_input = PyInt_AsLong(arg);
}
@@ -1695,7 +1772,7 @@ Server_setMidiInputDevice(Server *self, PyObject *arg)
static PyObject *
Server_setMidiOutputDevice(Server *self, PyObject *arg)
{
- if (arg != NULL) {
+ if (arg != NULL) {
if (PyInt_Check(arg))
self->midi_output = PyInt_AsLong(arg);
}
@@ -1740,6 +1817,24 @@ Server_setNchnls(Server *self, PyObject *arg)
}
static PyObject *
+Server_setIchnls(Server *self, PyObject *arg)
+{
+ if (self->server_booted) {
+ Server_warning(self, "Can't change number of input channels for booted server.\n");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ if (arg != NULL && PyInt_Check(arg)) {
+ self->ichnls = PyInt_AsLong(arg);
+ }
+ else {
+ Server_error(self, "Number of input channels must be an integer.\n");
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
Server_setBufferSize(Server *self, PyObject *arg)
{
if (self->server_booted) {
@@ -1777,7 +1872,7 @@ static PyObject *
Server_setJackAuto(Server *self, PyObject *args)
{
int in=1, out=1;
-
+
if (! PyArg_ParseTuple(args, "ii", &in, &out)) {
Py_INCREF(Py_None);
return Py_None;
@@ -1791,10 +1886,46 @@ Server_setJackAuto(Server *self, PyObject *args)
}
static PyObject *
+Server_setJackAutoConnectInputPorts(Server *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ if (arg != NULL) {
+ if (PyList_Check(arg)) {
+ tmp = arg;
+ Py_XDECREF(self->jackAutoConnectInputPorts);
+ Py_INCREF(tmp);
+ self->jackAutoConnectInputPorts = tmp;
+ }
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+Server_setJackAutoConnectOutputPorts(Server *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ if (arg != NULL) {
+ if (PyList_Check(arg)) {
+ tmp = arg;
+ Py_XDECREF(self->jackAutoConnectOutputPorts);
+ Py_INCREF(tmp);
+ self->jackAutoConnectOutputPorts = tmp;
+ }
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
Server_setGlobalSeed(Server *self, PyObject *arg)
{
unsigned int tmp;
-
+
if (arg != NULL) {
if (PyInt_Check(arg)) {
tmp = PyInt_AsLong(arg);
@@ -1808,7 +1939,7 @@ Server_setGlobalSeed(Server *self, PyObject *arg)
}
else
self->globalSeed = 0;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1840,7 +1971,7 @@ Server_setAmp(Server *self, PyObject *arg)
{
if (arg != NULL) {
int check = PyNumber_Check(arg);
-
+
if (check) {
self->amp = PyFloat_AsDouble(PyNumber_Float(arg));
if (self->amp != 0.0)
@@ -1856,13 +1987,13 @@ Server_setAmpCallable(Server *self, PyObject *arg)
{
int i;
PyObject *tmp;
-
+
if (arg == NULL) {
Server_error(self,"The amplitude callable attribute must be a method.\n");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_XDECREF(self->GUI);
Py_INCREF(tmp);
@@ -1872,16 +2003,16 @@ Server_setAmpCallable(Server *self, PyObject *arg)
for (i=0; i<self->nchnls; i++) {
self->lastRms[i] = 0.0;
}
-
+
for (i=1; i<100; i++) {
if ((self->bufferSize * i / self->samplingRate) > 0.045) {
self->numPass = i;
break;
}
- }
+ }
self->gcount = 0;
self->withGUI = 1;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1891,13 +2022,13 @@ Server_setTimeCallable(Server *self, PyObject *arg)
{
int i;
PyObject *tmp;
-
+
if (arg == NULL) {
Server_error(self,"The time callable attribute must be a method.\n");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_XDECREF(self->TIME);
Py_INCREF(tmp);
@@ -1908,10 +2039,10 @@ Server_setTimeCallable(Server *self, PyObject *arg)
self->timePass = i;
break;
}
- }
+ }
self->tcount = 0;
self->withTIME = 1;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1921,12 +2052,12 @@ Server_setVerbosity(Server *self, PyObject *arg)
{
if (arg != NULL) {
int check = PyInt_Check(arg);
-
+
if (check) {
self->verbosity = PyInt_AsLong(arg);
}
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1936,12 +2067,12 @@ Server_setStartOffset(Server *self, PyObject *arg)
{
if (arg != NULL) {
int check = PyNumber_Check(arg);
-
+
if (check) {
self->startoffset = PyFloat_AsDouble(PyNumber_Float(arg));
}
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1949,7 +2080,8 @@ Server_setStartOffset(Server *self, PyObject *arg)
int
Server_pm_init(Server *self)
{
- /* Initializing MIDI */
+ int i = 0;
+ /* Initializing MIDI */
PmError pmerr;
pmerr = Pm_Initialize();
@@ -1958,85 +2090,149 @@ Server_pm_init(Server *self)
self->withPortMidi = 0;
self->withPortMidiOut = 0;
return -1;
- }
+ }
else {
Server_debug(self, "Portmidi initialized.\n");
self->withPortMidi = 1;
self->withPortMidiOut = 1;
- }
+ }
if (self->withPortMidi == 1) {
+ self->midiin_count = self->midiout_count = 0;
int num_devices = Pm_CountDevices();
+ Server_debug(self, "Portmidi number of devices: %d.\n", num_devices);
if (num_devices > 0) {
- if (self->midi_input == -1 || self->midi_input >= num_devices)
- self->midi_input = Pm_GetDefaultInputDeviceID();
- Server_debug(self, "Midi input device : %d.\n", self->midi_input);
- const PmDeviceInfo *info = Pm_GetDeviceInfo(self->midi_input);
- if (info != NULL) {
- if (info->input) {
- pmerr = Pm_OpenInput(&self->in, self->midi_input, NULL, 100, NULL, NULL);
- if (pmerr) {
- Server_warning(self,
+ if (self->midi_input < num_devices) {
+ if (self->midi_input == -1)
+ self->midi_input = Pm_GetDefaultInputDeviceID();
+ Server_debug(self, "Midi input device : %d.\n", self->midi_input);
+ const PmDeviceInfo *info = Pm_GetDeviceInfo(self->midi_input);
+ if (info != NULL) {
+ if (info->input) {
+ pmerr = Pm_OpenInput(&self->midiin[0], self->midi_input, NULL, 100, NULL, NULL);
+ if (pmerr) {
+ Server_warning(self,
"Portmidi warning: could not open midi input %d (%s): %s\n",
- 0, info->name, Pm_GetErrorText(pmerr));
+ self->midi_input, info->name, Pm_GetErrorText(pmerr));
+ self->withPortMidi = 0;
+ }
+ else {
+ Server_debug(self, "Midi input (%s) opened.\n", info->name);
+ self->midiin_count = 1;
+ }
+ }
+ else {
+ Server_warning(self, "Portmidi warning: Midi Device (%s), not an input device!\n", info->name);
self->withPortMidi = 0;
- }
- else
- Server_debug(self, "Midi input (%s) opened.\n", info->name);
+ }
}
- else {
- Server_warning(self, "Portmidi warning: something wrong with midi input device!\n");
- self->withPortMidi = 0;
+ }
+ else if (self->midi_input >= num_devices) {
+ Server_debug(self, "Midi input device : all!\n");
+ self->midiin_count = 0;
+ for (i=0; i<num_devices; i++) {
+ const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
+ if (info != NULL) {
+ if (info->input) {
+ pmerr = Pm_OpenInput(&self->midiin[self->midiin_count], i, NULL, 100, NULL, NULL);
+ if (pmerr) {
+ Server_warning(self,
+ "Portmidi warning: could not open midi input %d (%s): %s\n",
+ 0, info->name, Pm_GetErrorText(pmerr));
+ }
+ else {
+ Server_debug(self, "Midi input (%s) opened.\n", info->name);
+ self->midiin_count++;
+ }
+ }
+ }
}
+ if (self->midiin_count == 0)
+ self->withPortMidi = 0;
}
else {
Server_warning(self, "Portmidi warning: no input device!\n");
self->withPortMidi = 0;
}
-
- if (self->midi_output == -1 || self->midi_output >= num_devices)
- self->midi_output = Pm_GetDefaultOutputDeviceID();
- Server_debug(self, "Midi output device : %d.\n", self->midi_output);
- const PmDeviceInfo *outinfo = Pm_GetDeviceInfo(self->midi_output);
- if (outinfo != NULL) {
- if (outinfo->output) {
- Pt_Start(1, 0, 0); /* start a timer with millisecond accuracy */
- pmerr = Pm_OpenOutput(&self->out, self->midi_output, NULL, 0, NULL, NULL, 1);
- if (pmerr) {
- Server_warning(self,
- "Portmidi warning: could not open midi output %d (%s): %s\n",
- 0, outinfo->name, Pm_GetErrorText(pmerr));
+
+ if (self->midi_output < num_devices) {
+ if (self->midi_output == -1)
+ self->midi_output = Pm_GetDefaultOutputDeviceID();
+ Server_debug(self, "Midi output device : %d.\n", self->midi_output);
+ const PmDeviceInfo *outinfo = Pm_GetDeviceInfo(self->midi_output);
+ if (outinfo != NULL) {
+ if (outinfo->output) {
+ Pt_Start(1, 0, 0); /* start a timer with millisecond accuracy */
+ pmerr = Pm_OpenOutput(&self->midiout[0], self->midi_output, NULL, 0, NULL, NULL, 1);
+ if (pmerr) {
+ Server_warning(self,
+ "Portmidi warning: could not open midi output %d (%s): %s\n",
+ self->midi_output, outinfo->name, Pm_GetErrorText(pmerr));
+ self->withPortMidiOut = 0;
+ if (Pt_Started())
+ Pt_Stop();
+ }
+ else {
+ Server_debug(self, "Midi output (%s) opened.\n", outinfo->name);
+ self->midiout_count = 1;
+ }
+ }
+ else {
+ Server_warning(self, "Portmidi warning: Midi Device (%s), not an output device!\n", outinfo->name);
self->withPortMidiOut = 0;
- }
- else
- Server_debug(self, "Midi output (%s) opened.\n", outinfo->name);
+ }
}
- else {
- Server_warning(self, "Portmidi warning: something wrong with midi output device!\n");
+ }
+ else if (self->midi_output >= num_devices) {
+ Server_debug(self, "Midi output device : all!\n");
+ self->midiout_count = 0;
+ Pt_Start(1, 0, 0); /* start a timer with millisecond accuracy */
+ for (i=0; i<num_devices; i++) {
+ const PmDeviceInfo *outinfo = Pm_GetDeviceInfo(i);
+ if (outinfo != NULL) {
+ if (outinfo->output) {
+ pmerr = Pm_OpenOutput(&self->midiout[self->midiout_count], i, NULL, 100, NULL, NULL, 1);
+ if (pmerr) {
+ Server_warning(self,
+ "Portmidi warning: could not open midi output %d (%s): %s\n",
+ 0, outinfo->name, Pm_GetErrorText(pmerr));
+ }
+ else {
+ Server_debug(self, "Midi output (%s) opened.\n", outinfo->name);
+ self->midiout_count++;
+ }
+ }
+ }
+ }
+ if (self->midiout_count == 0) {
+ if (Pt_Started())
+ Pt_Stop();
self->withPortMidiOut = 0;
}
}
else {
Server_warning(self, "Portmidi warning: no output device!\n");
- self->withPortMidi = 0;
+ self->withPortMidiOut = 0;
}
-
+
if (self->withPortMidi == 0 && self->withPortMidiOut == 0) {
Pm_Terminate();
Server_warning(self, "Portmidi closed.\n");
}
- }
+ }
else {
Server_warning(self, "Portmidi warning: no midi device found!\nPortmidi closed.\n");
self->withPortMidi = 0;
self->withPortMidiOut = 0;
Pm_Terminate();
- }
+ }
}
if (self->withPortMidi == 1) {
self->midi_count = 0;
- Pm_SetFilter(self->in, PM_FILT_ACTIVE | PM_FILT_CLOCK);
- }
+ for (i=0; i<self->midiin_count; i++) {
+ Pm_SetFilter(self->midiin[i], PM_FILT_ACTIVE | PM_FILT_CLOCK);
+ }
+ }
return 0;
}
@@ -2114,14 +2310,16 @@ Server_boot(Server *self, PyObject *arg)
if (self->input_buffer) {
free(self->input_buffer);
}
- self->input_buffer = (MYFLT *)calloc(self->bufferSize * self->nchnls, sizeof(MYFLT));
+ self->input_buffer = (MYFLT *)calloc(self->bufferSize * self->ichnls, sizeof(MYFLT));
if (self->output_buffer) {
free(self->output_buffer);
}
self->output_buffer = (float *)calloc(self->bufferSize * self->nchnls, sizeof(float));
}
- for (i=0; i<self->bufferSize*self->nchnls; i++) {
+ for (i=0; i<self->bufferSize*self->ichnls; i++) {
self->input_buffer[i] = 0.0;
+ }
+ for (i=0; i<self->bufferSize*self->nchnls; i++) {
self->output_buffer[i] = 0.0;
}
if (audioerr == 0) {
@@ -2130,8 +2328,8 @@ Server_boot(Server *self, PyObject *arg)
else {
self->server_booted = 0;
Server_error(self, "\nServer not booted.\n");
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2151,7 +2349,7 @@ Server_start(Server *self)
Py_INCREF(Py_None);
return Py_None;
}
-
+
Server_debug(self, "Server_start: number of streams %d\n", self->stream_count);
/* Ensure Python is set up for threading */
@@ -2171,34 +2369,34 @@ Server_start(Server *self)
int numBlocks = ceil(self->startoffset * self->samplingRate/self->bufferSize);
self->lastAmp = 1.0; self->amp = 0.0;
while (numBlocks-- > 0) {
- offline_process_block((Server *) self);
+ offline_process_block((Server *) self);
}
Server_message(self,"Offline rendering completed. Start realtime processing.\n");
self->startoffset = 0.0;
- }
+ }
self->amp = self->resetAmp;
switch (self->audio_be_type) {
case PyoPortaudio:
err = Server_pa_start(self);
- break;
+ break;
case PyoCoreaudio:
-#ifdef USE_COREAUDIO
+#ifdef USE_COREAUDIO
err = Server_coreaudio_start(self);
-#endif
- break;
- case PyoJack:
-#ifdef USE_JACK
+#endif
+ break;
+ case PyoJack:
+#ifdef USE_JACK
err = Server_jack_start(self);
-#endif
+#endif
break;
case PyoOffline:
err = Server_offline_start(self);
- break;
+ break;
case PyoOfflineNB:
err = Server_offline_nb_start(self);
- break;
+ break;
case PyoEmbedded:
err = Server_embedded_nb_start(self);
break;
@@ -2214,6 +2412,7 @@ Server_start(Server *self)
static PyObject *
Server_stop(Server *self)
{
+ int i;
int err = -1;
if (self->server_started == 0) {
Server_warning(self, "The Server must be started!\n");
@@ -2223,23 +2422,23 @@ Server_stop(Server *self)
switch (self->audio_be_type) {
case PyoPortaudio:
err = Server_pa_stop(self);
- break;
+ break;
case PyoCoreaudio:
-#ifdef USE_COREAUDIO
+#ifdef USE_COREAUDIO
err = Server_coreaudio_stop(self);
-#endif
- break;
+#endif
+ break;
case PyoJack:
-#ifdef USE_JACK
+#ifdef USE_JACK
err = Server_jack_stop(self);
-#endif
+#endif
break;
case PyoOffline:
err = Server_offline_stop(self);
- break;
+ break;
case PyoOfflineNB:
err = Server_offline_stop(self);
- break;
+ break;
case PyoEmbedded:
err = Server_embedded_stop(self);
break;
@@ -2251,12 +2450,18 @@ Server_stop(Server *self)
else {
self->server_stopped = 1;
if (self->withPortMidi == 1) {
- Pm_Close(self->in);
+ for (i=0; i<self->midiin_count; i++) {
+ Pm_Close(self->midiin[i]);
+ }
}
if (self->withPortMidiOut == 1) {
- Pm_Close(self->out);
+ for (i=0; i<self->midiout_count; i++) {
+ Pm_Close(self->midiout[i]);
+ }
}
if (self->withPortMidi == 1 || self->withPortMidiOut == 1) {
+ if (Pt_Started())
+ Pt_Stop();
Pm_Terminate();
}
self->withPortMidi = 0;
@@ -2268,34 +2473,34 @@ Server_stop(Server *self)
static PyObject *
Server_recordOptions(Server *self, PyObject *args, PyObject *kwds)
-{
+{
static char *kwlist[] = {"dur", "filename", "fileformat", "sampletype", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "d|sii", kwlist, &self->recdur, &self->recpath, &self->recformat, &self->rectype)) {
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
Server_start_rec(Server *self, PyObject *args, PyObject *kwds)
-{
+{
char *filename=NULL;
-
+
static char *kwlist[] = {"filename", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|s", kwlist, &filename)) {
return PyInt_FromLong(-1);
}
Server_start_rec_internal(self, filename);
-
+
Py_INCREF(Py_None);
return Py_None;
}
-static int
+static int
Server_start_rec_internal(Server *self, char *filename)
{
/* Prepare sfinfo */
@@ -2361,7 +2566,7 @@ Server_start_rec_internal(Server *self, char *filename)
/* Open the output file. */
if (filename == NULL) {
Server_debug(self, "recpath : %s\n", self->recpath);
- if (! (self->recfile = sf_open(self->recpath, SFM_WRITE, &self->recinfo))) {
+ if (! (self->recfile = sf_open(self->recpath, SFM_WRITE, &self->recinfo))) {
Server_error(self, "Not able to open output file %s.\n", self->recpath);
Server_debug(self, "%s\n", sf_strerror(self->recfile));
return -1;
@@ -2369,13 +2574,13 @@ Server_start_rec_internal(Server *self, char *filename)
}
else {
Server_debug(self, "filename : %s\n", filename);
- if (! (self->recfile = sf_open(filename, SFM_WRITE, &self->recinfo))) {
+ if (! (self->recfile = sf_open(filename, SFM_WRITE, &self->recinfo))) {
Server_error(self, "Not able to open output file %s.\n", filename);
Server_debug(self, "%s\n", sf_strerror(self->recfile));
return -1;
}
}
-
+
self->record = 1;
return 0;
}
@@ -2385,7 +2590,7 @@ Server_stop_rec(Server *self, PyObject *args)
{
self->record = 0;
sf_close(self->recfile);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2394,10 +2599,10 @@ static PyObject *
Server_addStream(Server *self, PyObject *args)
{
PyObject *tmp;
-
+
if (! PyArg_ParseTuple(args, "O", &tmp))
- return PyInt_FromLong(-1);
-
+ return PyInt_FromLong(-1);
+
if (tmp == NULL) {
Server_error(self, "Server_addStream needs a pyo object as argument.\n");
return PyInt_FromLong(-1);
@@ -2406,7 +2611,7 @@ Server_addStream(Server *self, PyObject *args)
PyList_Append(self->streams, tmp);
self->stream_count++;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2416,7 +2621,7 @@ Server_removeStream(Server *self, int id)
{
int i, sid;
Stream *stream_tmp;
-
+
for (i=0; i<self->stream_count; i++) {
stream_tmp = (Stream *)PyList_GET_ITEM(self->streams, i);
sid = Stream_getStreamId(stream_tmp);
@@ -2429,7 +2634,7 @@ Server_removeStream(Server *self, int id)
}
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
}
PyObject *
@@ -2439,11 +2644,11 @@ Server_changeStreamPosition(Server *self, PyObject *args)
Stream *ref_stream_tmp, *cur_stream_tmp, *stream_tmp;
if (! PyArg_ParseTuple(args, "OO", &ref_stream_tmp, &cur_stream_tmp))
- return PyInt_FromLong(-1);
+ return PyInt_FromLong(-1);
rsid = Stream_getStreamId(ref_stream_tmp);
csid = Stream_getStreamId(cur_stream_tmp);
-
+
for (i=0; i<self->stream_count; i++) {
stream_tmp = (Stream *)PyList_GET_ITEM(self->streams, i);
sid = Stream_getStreamId(stream_tmp);
@@ -2467,29 +2672,159 @@ Server_changeStreamPosition(Server *self, PyObject *args)
self->stream_count++;
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
}
PyObject *
-Server_sendMidiNote(Server *self, PyObject *args)
+Server_noteout(Server *self, PyObject *args)
{
- int pit, vel, chan, curtime;
+ int i, pit, vel, chan, curtime;
PmEvent buffer[1];
PmTimestamp timestamp;
if (! PyArg_ParseTuple(args, "iiii", &pit, &vel, &chan, ×tamp))
- return PyInt_FromLong(-1);
+ return PyInt_FromLong(-1);
- curtime = Pt_Time();
- buffer[0].timestamp = curtime + timestamp;
- if (chan == 0)
- buffer[0].message = Pm_Message(0x90, pit, vel);
- else
- buffer[0].message = Pm_Message(0x90 | (chan - 1), pit, vel);
- Pm_Write(self->out, buffer, 1);
+ if (self->withPortMidiOut) {
+ curtime = Pt_Time();
+ buffer[0].timestamp = curtime + timestamp;
+ if (chan == 0)
+ buffer[0].message = Pm_Message(0x90, pit, vel);
+ else
+ buffer[0].message = Pm_Message(0x90 | (chan - 1), pit, vel);
+ for (i=0; i<self->midiout_count; i++) {
+ Pm_Write(self->midiout[i], buffer, 1);
+ }
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+PyObject *
+Server_afterout(Server *self, PyObject *args)
+{
+ int i, pit, vel, chan, curtime;
+ PmEvent buffer[1];
+ PmTimestamp timestamp;
+
+ if (! PyArg_ParseTuple(args, "iiii", &pit, &vel, &chan, ×tamp))
+ return PyInt_FromLong(-1);
+
+ if (self->withPortMidiOut) {
+ curtime = Pt_Time();
+ buffer[0].timestamp = curtime + timestamp;
+ if (chan == 0)
+ buffer[0].message = Pm_Message(0xA0, pit, vel);
+ else
+ buffer[0].message = Pm_Message(0xA0 | (chan - 1), pit, vel);
+ for (i=0; i<self->midiout_count; i++) {
+ Pm_Write(self->midiout[i], buffer, 1);
+ }
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+PyObject *
+Server_ctlout(Server *self, PyObject *args)
+{
+ int i, ctlnum, value, chan, curtime;
+ PmEvent buffer[1];
+ PmTimestamp timestamp;
+
+ if (! PyArg_ParseTuple(args, "iiii", &ctlnum, &value, &chan, ×tamp))
+ return PyInt_FromLong(-1);
+
+ if (self->withPortMidiOut) {
+ curtime = Pt_Time();
+ buffer[0].timestamp = curtime + timestamp;
+ if (chan == 0)
+ buffer[0].message = Pm_Message(0xB0, ctlnum, value);
+ else
+ buffer[0].message = Pm_Message(0xB0 | (chan - 1), ctlnum, value);
+ for (i=0; i<self->midiout_count; i++) {
+ Pm_Write(self->midiout[i], buffer, 1);
+ }
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+PyObject *
+Server_programout(Server *self, PyObject *args)
+{
+ int i, value, chan, curtime;
+ PmEvent buffer[1];
+ PmTimestamp timestamp;
+
+ if (! PyArg_ParseTuple(args, "iii", &value, &chan, ×tamp))
+ return PyInt_FromLong(-1);
+
+ if (self->withPortMidiOut) {
+ curtime = Pt_Time();
+ buffer[0].timestamp = curtime + timestamp;
+ if (chan == 0)
+ buffer[0].message = Pm_Message(0xC0, value, 0);
+ else
+ buffer[0].message = Pm_Message(0xC0 | (chan - 1), value, 0);
+ for (i=0; i<self->midiout_count; i++) {
+ Pm_Write(self->midiout[i], buffer, 1);
+ }
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+PyObject *
+Server_pressout(Server *self, PyObject *args)
+{
+ int i, value, chan, curtime;
+ PmEvent buffer[1];
+ PmTimestamp timestamp;
+
+ if (! PyArg_ParseTuple(args, "iii", &value, &chan, ×tamp))
+ return PyInt_FromLong(-1);
+ if (self->withPortMidiOut) {
+ curtime = Pt_Time();
+ buffer[0].timestamp = curtime + timestamp;
+ if (chan == 0)
+ buffer[0].message = Pm_Message(0xD0, value, 0);
+ else
+ buffer[0].message = Pm_Message(0xD0 | (chan - 1), value, 0);
+ for (i=0; i<self->midiout_count; i++) {
+ Pm_Write(self->midiout[i], buffer, 1);
+ }
+ }
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
+}
+
+PyObject *
+Server_bendout(Server *self, PyObject *args)
+{
+ int i, lsb, msb, value, chan, curtime;
+ PmEvent buffer[1];
+ PmTimestamp timestamp;
+
+ if (! PyArg_ParseTuple(args, "iii", &value, &chan, ×tamp))
+ return PyInt_FromLong(-1);
+
+ if (self->withPortMidiOut) {
+ curtime = Pt_Time();
+ buffer[0].timestamp = curtime + timestamp;
+ lsb = value & 0x007F;
+ msb = (value & (0x007F << 7)) >> 7;
+ if (chan == 0)
+ buffer[0].message = Pm_Message(0xE0, lsb, msb);
+ else
+ buffer[0].message = Pm_Message(0xE0 | (chan - 1), lsb, msb);
+ for (i=0; i<self->midiout_count; i++) {
+ Pm_Write(self->midiout[i], buffer, 1);
+ }
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
}
MYFLT *
@@ -2520,6 +2855,12 @@ Server_getNchnls(Server *self)
}
static PyObject *
+Server_getIchnls(Server *self)
+{
+ return PyInt_FromLong(self->ichnls);
+}
+
+static PyObject *
Server_getGlobalSeed(Server *self)
{
return PyInt_FromLong(self->globalSeed);
@@ -2630,9 +2971,12 @@ static PyMethodDef Server_methods[] = {
{"setMidiOutputDevice", (PyCFunction)Server_setMidiOutputDevice, METH_O, "Sets MIDI output device."},
{"setSamplingRate", (PyCFunction)Server_setSamplingRate, METH_O, "Sets the server's sampling rate."},
{"setBufferSize", (PyCFunction)Server_setBufferSize, METH_O, "Sets the server's buffer size."},
- {"setNchnls", (PyCFunction)Server_setNchnls, METH_O, "Sets the server's number of channels."},
+ {"setNchnls", (PyCFunction)Server_setNchnls, METH_O, "Sets the server's number of output/input channels."},
+ {"setIchnls", (PyCFunction)Server_setIchnls, METH_O, "Sets the server's number of input channels."},
{"setDuplex", (PyCFunction)Server_setDuplex, METH_O, "Sets the server's duplex mode (0 = only out, 1 = in/out)."},
{"setJackAuto", (PyCFunction)Server_setJackAuto, METH_VARARGS, "Tells the server to auto-connect Jack ports (0 = disable, 1 = enable)."},
+ {"setJackAutoConnectInputPorts", (PyCFunction)Server_setJackAutoConnectInputPorts, METH_O, "Sets a list of ports to auto-connect inputs when using Jack."},
+ {"setJackAutoConnectOutputPorts", (PyCFunction)Server_setJackAutoConnectOutputPorts, METH_O, "Sets a list of ports to auto-connect outputs when using Jack."},
{"setGlobalSeed", (PyCFunction)Server_setGlobalSeed, METH_O, "Sets the server's global seed for random objects."},
{"setAmp", (PyCFunction)Server_setAmp, METH_O, "Sets the overall amplitude."},
{"setAmpCallable", (PyCFunction)Server_setAmpCallable, METH_O, "Sets the Server's GUI callable object."},
@@ -2652,10 +2996,16 @@ static PyMethodDef Server_methods[] = {
This is for internal use and must never be called by the user."},
{"changeStreamPosition", (PyCFunction)Server_changeStreamPosition, METH_VARARGS, "Puts an audio stream before another in the stack. \
This is for internal use and must never be called by the user."},
- {"sendMidiNote", (PyCFunction)Server_sendMidiNote, METH_VARARGS, "Send a Midi note to Portmidi output stream."},
+ {"noteout", (PyCFunction)Server_noteout, METH_VARARGS, "Send a Midi note event to Portmidi output stream."},
+ {"afterout", (PyCFunction)Server_afterout, METH_VARARGS, "Send an aftertouch event to Portmidi output stream."},
+ {"ctlout", (PyCFunction)Server_ctlout, METH_VARARGS, "Send a control change event to Portmidi output stream."},
+ {"programout", (PyCFunction)Server_programout, METH_VARARGS, "Send a program change event to Portmidi output stream."},
+ {"pressout", (PyCFunction)Server_pressout, METH_VARARGS, "Send a channel pressure event to Portmidi output stream."},
+ {"bendout", (PyCFunction)Server_bendout, METH_VARARGS, "Send a pitch bend event to Portmidi output stream."},
{"getStreams", (PyCFunction)Server_getStreams, METH_NOARGS, "Returns the list of streams added to the server."},
{"getSamplingRate", (PyCFunction)Server_getSamplingRate, METH_NOARGS, "Returns the server's sampling rate."},
- {"getNchnls", (PyCFunction)Server_getNchnls, METH_NOARGS, "Returns the server's current number of channels."},
+ {"getNchnls", (PyCFunction)Server_getNchnls, METH_NOARGS, "Returns the server's current number of output channels."},
+ {"getIchnls", (PyCFunction)Server_getIchnls, METH_NOARGS, "Returns the server's current number of input channels."},
{"getGlobalSeed", (PyCFunction)Server_getGlobalSeed, METH_NOARGS, "Returns the server's global seed."},
{"getBufferSize", (PyCFunction)Server_getBufferSize, METH_NOARGS, "Returns the server's buffer size."},
{"getIsBooted", (PyCFunction)Server_getIsBooted, METH_NOARGS, "Returns 1 if the server is booted, otherwise returns 0."},
@@ -2701,10 +3051,10 @@ PyTypeObject ServerType = {
"Pyo Server object. Handles communication with Portaudio and processing callback loop.", /* tp_doc */
(traverseproc)Server_traverse, /* tp_traverse */
(inquiry)Server_clear, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
Server_methods, /* tp_methods */
Server_members, /* tp_members */
0, /* tp_getset */
@@ -2716,4 +3066,4 @@ PyTypeObject ServerType = {
(initproc)Server_init, /* tp_init */
0, /* tp_alloc */
Server_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/engine/streammodule.c b/src/engine/streammodule.c
index e67b6bc..ccbe3b8 100644
--- a/src/engine/streammodule.c
+++ b/src/engine/streammodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -28,8 +28,8 @@
int stream_id = 1;
-int
-Stream_getNewStreamId()
+int
+Stream_getNewStreamId()
{
return stream_id++;
}
@@ -37,14 +37,14 @@ Stream_getNewStreamId()
static int
Stream_traverse(Stream *self, visitproc visit, void *arg)
{
- Py_VISIT(self->streamobject);
+ Py_VISIT(self->streamobject);
return 0;
}
-static int
+static int
Stream_clear(Stream *self)
{
- Py_CLEAR(self->streamobject);
+ Py_CLEAR(self->streamobject);
return 0;
}
@@ -96,13 +96,13 @@ MYFLT *
Stream_getData(Stream *self)
{
return (MYFLT *)self->data;
-}
+}
void
Stream_setData(Stream *self, MYFLT *data)
{
self->data = data;
-}
+}
void Stream_setFunctionPtr(Stream *self, void *ptr)
{
@@ -112,9 +112,9 @@ void Stream_setFunctionPtr(Stream *self, void *ptr)
void Stream_callFunction(Stream *self)
{
(*self->funcptr)(self->streamobject);
-}
+}
-void Stream_IncrementBufferCount(Stream *self)
+void Stream_IncrementBufferCount(Stream *self)
{
self->bufferCount++;
if (self->bufferCount >= self->bufferCountWait) {
@@ -123,7 +123,7 @@ void Stream_IncrementBufferCount(Stream *self)
}
}
-void Stream_IncrementDurationCount(Stream *self)
+void Stream_IncrementDurationCount(Stream *self)
{
self->bufferCount++;
if (self->bufferCount >= self->duration) {
@@ -152,19 +152,27 @@ Stream_getStreamObject(Stream *self)
PyObject *
Stream_isPlaying(Stream *self)
{
- if (self->active || self->todac)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
+ if (self->active || self->todac) {
+ Py_INCREF(Py_True);
+ return Py_True;
+ }
+ else {
+ Py_INCREF(Py_False);
+ return Py_False;
+ }
}
PyObject *
Stream_isOutputting(Stream *self)
{
- if (self->todac)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
+ if (self->todac) {
+ Py_INCREF(Py_True);
+ return Py_True;
+ }
+ else {
+ Py_INCREF(Py_False);
+ return Py_False;
+ }
}
static PyMethodDef Stream_methods[] = {
@@ -254,13 +262,13 @@ MYFLT *
TriggerStream_getData(TriggerStream *self)
{
return (MYFLT *)self->data;
-}
+}
void
TriggerStream_setData(TriggerStream *self, MYFLT *data)
{
self->data = data;
-}
+}
PyTypeObject TriggerStreamType = {
PyObject_HEAD_INIT(NULL)
@@ -304,4 +312,4 @@ PyTypeObject TriggerStreamType = {
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/engine/wind.c b/src/engine/wind.c
index 8fc1f94..f0ba09d 100644
--- a/src/engine/wind.c
+++ b/src/engine/wind.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2011 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
* *
* Envelope window generator : *
* 0 : Rectangular (no window) *
@@ -35,8 +35,8 @@
void gen_window(MYFLT *window, int size, int wintype) {
int i;
MYFLT arg;
-
- switch (wintype) {
+
+ switch (wintype) {
case 0:
/* Rectangular */
for (i=0; i<size; i++) {
@@ -122,4 +122,3 @@ void gen_window(MYFLT *window, int size, int wintype) {
}
return;
}
-
diff --git a/src/objects/analysismodule.c b/src/objects/analysismodule.c
index b4ef933..1ad618b 100644
--- a/src/objects/analysismodule.c
+++ b/src/objects/analysismodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
#include "structmember.h"
@@ -25,6 +25,8 @@
#include "servermodule.h"
#include "dummymodule.h"
#include "interpolation.h"
+#include "fft.h"
+#include "wind.h"
/************/
/* Follower */
@@ -35,7 +37,7 @@ typedef struct {
Stream *input_stream;
PyObject *freq;
Stream *freq_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
MYFLT follow;
MYFLT last_freq;
MYFLT factor;
@@ -53,7 +55,7 @@ Follower_filters_i(Follower *self) {
self->factor = MYEXP(-1.0 / (self->sr / freq));
self->last_freq = freq;
}
-
+
for (i=0; i<self->bufsize; i++) {
absin = in[i];
if (absin < 0.0)
@@ -66,10 +68,10 @@ static void
Follower_filters_a(Follower *self) {
MYFLT freq, absin;
int i;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
if (freq != self->last_freq) {
@@ -79,7 +81,7 @@ Follower_filters_a(Follower *self) {
absin = in[i];
if (absin < 0.0)
absin = -absin;
- self->follow = self->data[i] = absin + self->factor * (self->follow - absin);
+ self->follow = self->data[i] = absin + self->factor * (self->follow - absin);
}
}
@@ -99,50 +101,50 @@ Follower_setProcMode(Follower *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Follower_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Follower_filters_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Follower_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Follower_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Follower_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Follower_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Follower_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Follower_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Follower_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Follower_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Follower_postprocessing_revareva;
break;
- }
+ }
}
static void
Follower_compute_next_data_frame(Follower *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -152,19 +154,19 @@ Follower_traverse(Follower *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
Follower_clear(Follower *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -183,7 +185,7 @@ Follower_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
Follower *self;
self = (Follower *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(20);
self->follow = 0.0;
self->last_freq = -1.0;
@@ -191,32 +193,32 @@ Follower_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Follower_compute_next_data_frame);
self->mode_func_ptr = Follower_setProcMode;
static char *kwlist[] = {"input", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &freqtmp, &multmp, &addtmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -224,10 +226,10 @@ Follower_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Follower_getServer(Follower* self) { GET_SERVER };
static PyObject * Follower_getStream(Follower* self) { GET_STREAM };
-static PyObject * Follower_setMul(Follower *self, PyObject *arg) { SET_MUL };
-static PyObject * Follower_setAdd(Follower *self, PyObject *arg) { SET_ADD };
-static PyObject * Follower_setSub(Follower *self, PyObject *arg) { SET_SUB };
-static PyObject * Follower_setDiv(Follower *self, PyObject *arg) { SET_DIV };
+static PyObject * Follower_setMul(Follower *self, PyObject *arg) { SET_MUL };
+static PyObject * Follower_setAdd(Follower *self, PyObject *arg) { SET_ADD };
+static PyObject * Follower_setSub(Follower *self, PyObject *arg) { SET_SUB };
+static PyObject * Follower_setDiv(Follower *self, PyObject *arg) { SET_DIV };
static PyObject * Follower_play(Follower *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Follower_stop(Follower *self) { STOP };
@@ -245,14 +247,14 @@ static PyObject *
Follower_setFreq(Follower *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -268,9 +270,9 @@ Follower_setFreq(Follower *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -393,7 +395,7 @@ typedef struct {
Stream *risetime_stream;
PyObject *falltime;
Stream *falltime_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
MYFLT follow;
MYFLT last_risetime;
MYFLT last_falltime;
@@ -405,7 +407,7 @@ static void
Follower2_filters_ii(Follower2 *self) {
MYFLT absin, risetime, falltime;
int i;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
risetime = PyFloat_AS_DOUBLE(self->risetime);
if (risetime <= 0.0)
@@ -413,7 +415,7 @@ Follower2_filters_ii(Follower2 *self) {
falltime = PyFloat_AS_DOUBLE(self->falltime);
if (falltime <= 0.0)
falltime = 0.001;
-
+
if (risetime != self->last_risetime) {
self->risefactor = MYEXP(-1.0 / (self->sr * risetime));
self->last_risetime = risetime;
@@ -423,7 +425,7 @@ Follower2_filters_ii(Follower2 *self) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
for (i=0; i<self->bufsize; i++) {
absin = in[i];
if (absin < 0.0)
@@ -439,7 +441,7 @@ static void
Follower2_filters_ai(Follower2 *self) {
MYFLT absin, risetime, falltime;
int i;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *rise = Stream_getData((Stream *)self->risetime_stream);
falltime = PyFloat_AS_DOUBLE(self->falltime);
@@ -450,7 +452,7 @@ Follower2_filters_ai(Follower2 *self) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
for (i=0; i<self->bufsize; i++) {
risetime = rise[i];
if (risetime <= 0.0)
@@ -473,13 +475,13 @@ static void
Follower2_filters_ia(Follower2 *self) {
MYFLT absin, risetime, falltime;
int i;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
risetime = PyFloat_AS_DOUBLE(self->risetime);
if (risetime <= 0.0)
risetime = 0.001;
MYFLT *fall = Stream_getData((Stream *)self->falltime_stream);
-
+
if (risetime != self->last_risetime) {
self->risefactor = MYEXP(-1.0 / (self->sr * risetime));
self->last_risetime = risetime;
@@ -492,7 +494,7 @@ Follower2_filters_ia(Follower2 *self) {
if (falltime != self->last_falltime) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
- }
+ }
absin = in[i];
if (absin < 0.0)
absin = -absin;
@@ -507,7 +509,7 @@ static void
Follower2_filters_aa(Follower2 *self) {
MYFLT absin, risetime, falltime;
int i;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *rise = Stream_getData((Stream *)self->risetime_stream);
MYFLT *fall = Stream_getData((Stream *)self->falltime_stream);
@@ -526,7 +528,7 @@ Follower2_filters_aa(Follower2 *self) {
if (falltime != self->last_falltime) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
- }
+ }
absin = in[i];
if (absin < 0.0)
absin = -absin;
@@ -553,56 +555,56 @@ Follower2_setProcMode(Follower2 *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Follower2_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Follower2_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Follower2_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Follower2_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Follower2_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Follower2_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Follower2_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Follower2_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Follower2_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Follower2_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Follower2_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Follower2_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Follower2_postprocessing_revareva;
break;
- }
+ }
}
static void
Follower2_compute_next_data_frame(Follower2 *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -612,23 +614,23 @@ Follower2_traverse(Follower2 *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->risetime);
- Py_VISIT(self->risetime_stream);
- Py_VISIT(self->falltime);
- Py_VISIT(self->falltime_stream);
+ Py_VISIT(self->risetime);
+ Py_VISIT(self->risetime_stream);
+ Py_VISIT(self->falltime);
+ Py_VISIT(self->falltime_stream);
return 0;
}
-static int
+static int
Follower2_clear(Follower2 *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->risetime);
- Py_CLEAR(self->risetime_stream);
- Py_CLEAR(self->falltime);
- Py_CLEAR(self->falltime_stream);
+ Py_CLEAR(self->risetime);
+ Py_CLEAR(self->risetime_stream);
+ Py_CLEAR(self->falltime);
+ Py_CLEAR(self->falltime_stream);
return 0;
}
@@ -647,7 +649,7 @@ Follower2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *risetimetmp=NULL, *falltimetmp=NULL, *multmp=NULL, *addtmp=NULL;
Follower2 *self;
self = (Follower2 *)type->tp_alloc(type, 0);
-
+
self->risetime = PyFloat_FromDouble(0.01);
self->falltime = PyFloat_FromDouble(0.1);
self->follow = 0.0;
@@ -658,36 +660,36 @@ Follower2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Follower2_compute_next_data_frame);
self->mode_func_ptr = Follower2_setProcMode;
static char *kwlist[] = {"input", "risetime", "falltime", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &inputtmp, &risetimetmp, &falltimetmp, &multmp, &addtmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_STREAM
-
+
if (risetimetmp) {
PyObject_CallMethod((PyObject *)self, "setRisetime", "O", risetimetmp);
}
-
+
if (falltimetmp) {
PyObject_CallMethod((PyObject *)self, "setFalltime", "O", falltimetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -695,10 +697,10 @@ Follower2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Follower2_getServer(Follower2* self) { GET_SERVER };
static PyObject * Follower2_getStream(Follower2* self) { GET_STREAM };
-static PyObject * Follower2_setMul(Follower2 *self, PyObject *arg) { SET_MUL };
-static PyObject * Follower2_setAdd(Follower2 *self, PyObject *arg) { SET_ADD };
-static PyObject * Follower2_setSub(Follower2 *self, PyObject *arg) { SET_SUB };
-static PyObject * Follower2_setDiv(Follower2 *self, PyObject *arg) { SET_DIV };
+static PyObject * Follower2_setMul(Follower2 *self, PyObject *arg) { SET_MUL };
+static PyObject * Follower2_setAdd(Follower2 *self, PyObject *arg) { SET_ADD };
+static PyObject * Follower2_setSub(Follower2 *self, PyObject *arg) { SET_SUB };
+static PyObject * Follower2_setDiv(Follower2 *self, PyObject *arg) { SET_DIV };
static PyObject * Follower2_play(Follower2 *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Follower2_stop(Follower2 *self) { STOP };
@@ -716,14 +718,14 @@ static PyObject *
Follower2_setRisetime(Follower2 *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->risetime);
@@ -739,9 +741,9 @@ Follower2_setRisetime(Follower2 *self, PyObject *arg)
self->risetime_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -750,14 +752,14 @@ static PyObject *
Follower2_setFalltime(Follower2 *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->falltime);
@@ -773,9 +775,9 @@ Follower2_setFalltime(Follower2 *self, PyObject *arg)
self->falltime_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -908,7 +910,7 @@ ZCross_process(ZCross *self) {
int count = 0;
MYFLT inval;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->lastValue;
inval = in[i];
@@ -940,44 +942,44 @@ ZCross_setProcMode(ZCross *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = ZCross_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = ZCross_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = ZCross_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = ZCross_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = ZCross_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = ZCross_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = ZCross_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = ZCross_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = ZCross_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = ZCross_postprocessing_revareva;
break;
- }
+ }
}
static void
ZCross_compute_next_data_frame(ZCross *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -990,7 +992,7 @@ ZCross_traverse(ZCross *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
ZCross_clear(ZCross *self)
{
pyo_CLEAR
@@ -1014,33 +1016,33 @@ ZCross_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
ZCross *self;
self = (ZCross *)type->tp_alloc(type, 0);
-
+
self->thresh = 0.0;
self->lastValue = self->lastSample = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, ZCross_compute_next_data_frame);
self->mode_func_ptr = ZCross_setProcMode;
static char *kwlist[] = {"input", "thresh", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FOO, kwlist, &inputtmp, &self->thresh, &multmp, &addtmp))
- Py_RETURN_NONE;
+ Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1048,10 +1050,10 @@ ZCross_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * ZCross_getServer(ZCross* self) { GET_SERVER };
static PyObject * ZCross_getStream(ZCross* self) { GET_STREAM };
-static PyObject * ZCross_setMul(ZCross *self, PyObject *arg) { SET_MUL };
-static PyObject * ZCross_setAdd(ZCross *self, PyObject *arg) { SET_ADD };
-static PyObject * ZCross_setSub(ZCross *self, PyObject *arg) { SET_SUB };
-static PyObject * ZCross_setDiv(ZCross *self, PyObject *arg) { SET_DIV };
+static PyObject * ZCross_setMul(ZCross *self, PyObject *arg) { SET_MUL };
+static PyObject * ZCross_setAdd(ZCross *self, PyObject *arg) { SET_ADD };
+static PyObject * ZCross_setSub(ZCross *self, PyObject *arg) { SET_SUB };
+static PyObject * ZCross_setDiv(ZCross *self, PyObject *arg) { SET_DIV };
static PyObject * ZCross_play(ZCross *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * ZCross_stop(ZCross *self) { STOP };
@@ -1072,13 +1074,13 @@ ZCross_setThresh(ZCross *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->thresh = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1247,12 +1249,12 @@ Yin_process(Yin *self) {
int i, j, period, tau = 0;
MYFLT candidate, tmp = 0.0, tmp2 = 0.0, b = 0.0;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->cutoff != self->last_cutoff) {
if (self->cutoff <= 1.0)
self->cutoff = 1.0;
else if (self->cutoff >= self->sr*0.5)
- self->cutoff = self->sr*0.5;
+ self->cutoff = self->sr*0.5;
self->last_cutoff = self->cutoff;
b = 2.0 - MYCOS(TWOPI * self->cutoff / self->sr);
self->c2 = (b - MYSQRT(b * b - 1.0));
@@ -1263,7 +1265,7 @@ Yin_process(Yin *self) {
self->input_buffer[self->input_count] = self->y1;
if (self->input_count++ == self->winsize) {
self->input_count = 0;
-
+
self->yin_buffer[0] = 1.0;
for (tau = 1; tau < self->halfsize; tau++) {
self->yin_buffer[tau] = 0.0;
@@ -1283,10 +1285,10 @@ Yin_process(Yin *self) {
candidate = quadraticInterpolation(self->yin_buffer, min_elem_pos(self->yin_buffer, self->halfsize), self->halfsize);
founded:
-
+
candidate = self->sr / candidate;
if (candidate > self->minfreq && candidate < self->maxfreq)
- self->pitch = candidate;
+ self->pitch = candidate;
}
self->data[i] = self->pitch;
@@ -1308,44 +1310,44 @@ Yin_setProcMode(Yin *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Yin_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Yin_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Yin_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Yin_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Yin_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Yin_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Yin_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Yin_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Yin_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Yin_postprocessing_revareva;
break;
- }
+ }
}
static void
Yin_compute_next_data_frame(Yin *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1358,7 +1360,7 @@ Yin_traverse(Yin *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Yin_clear(Yin *self)
{
pyo_CLEAR
@@ -1384,7 +1386,7 @@ Yin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
Yin *self;
self = (Yin *)type->tp_alloc(type, 0);
-
+
self->winsize = 1024;
self->halfsize = 512;
self->input_count = 0;
@@ -1397,40 +1399,40 @@ Yin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->y1 = self->c2 = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Yin_compute_next_data_frame);
self->mode_func_ptr = Yin_setProcMode;
static char *kwlist[] = {"input", "tolerance", "minfreq", "maxfreq", "cutoff", "winsize", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FFFFIOO, kwlist, &inputtmp, &self->tolerance, &self->minfreq, &self->maxfreq, &self->cutoff, &self->winsize, &multmp, &addtmp))
- Py_RETURN_NONE;
+ Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
if (self->winsize % 2 == 1)
self->winsize += 1;
- self->input_buffer = (MYFLT *)realloc(self->input_buffer, self->winsize * sizeof(MYFLT));
+ self->input_buffer = (MYFLT *)realloc(self->input_buffer, self->winsize * sizeof(MYFLT));
for (i=0; i<self->winsize; i++)
self->input_buffer[i] = 0.0;
self->halfsize = self->winsize / 2;
- self->yin_buffer = (MYFLT *)realloc(self->yin_buffer, self->halfsize * sizeof(MYFLT));
+ self->yin_buffer = (MYFLT *)realloc(self->yin_buffer, self->halfsize * sizeof(MYFLT));
for (i=0; i<self->halfsize; i++)
self->yin_buffer[i] = 0.0;
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1438,10 +1440,10 @@ Yin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Yin_getServer(Yin* self) { GET_SERVER };
static PyObject * Yin_getStream(Yin* self) { GET_STREAM };
-static PyObject * Yin_setMul(Yin *self, PyObject *arg) { SET_MUL };
-static PyObject * Yin_setAdd(Yin *self, PyObject *arg) { SET_ADD };
-static PyObject * Yin_setSub(Yin *self, PyObject *arg) { SET_SUB };
-static PyObject * Yin_setDiv(Yin *self, PyObject *arg) { SET_DIV };
+static PyObject * Yin_setMul(Yin *self, PyObject *arg) { SET_MUL };
+static PyObject * Yin_setAdd(Yin *self, PyObject *arg) { SET_ADD };
+static PyObject * Yin_setSub(Yin *self, PyObject *arg) { SET_SUB };
+static PyObject * Yin_setDiv(Yin *self, PyObject *arg) { SET_DIV };
static PyObject * Yin_play(Yin *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Yin_stop(Yin *self) { STOP };
@@ -1462,13 +1464,13 @@ Yin_setTolerance(Yin *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->tolerance = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
}
-
+
Py_RETURN_NONE;
}
@@ -1479,13 +1481,13 @@ Yin_setMinfreq(Yin *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->minfreq = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
}
-
+
Py_RETURN_NONE;
}
@@ -1496,13 +1498,13 @@ Yin_setMaxfreq(Yin *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->maxfreq = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
}
-
+
Py_RETURN_NONE;
}
@@ -1513,13 +1515,13 @@ Yin_setCutoff(Yin *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->cutoff = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
}
-
+
Py_RETURN_NONE;
}
@@ -1630,4 +1632,1318 @@ Yin_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
Yin_new, /* tp_new */
+};
+
+/********************/
+/* Centroid */
+/********************/
+
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ int size;
+ int hsize;
+ int incount;
+ MYFLT centroid;
+ MYFLT *inframe;
+ MYFLT *outframe;
+ MYFLT **twiddle;
+ MYFLT *input_buffer;
+ MYFLT *window;
+ int modebuffer[2];
+} Centroid;
+
+static void
+Centroid_alloc_memories(Centroid *self) {
+ int i, n8;
+ self->hsize = self->size / 2;
+ n8 = self->size >> 3;
+ self->inframe = (MYFLT *)realloc(self->inframe, self->size * sizeof(MYFLT));
+ self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
+ self->input_buffer = (MYFLT *)realloc(self->input_buffer, self->size * sizeof(MYFLT));
+ for (i=0; i<self->size; i++)
+ self->inframe[i] = self->outframe[i] = self->input_buffer[i] = 0.0;
+ self->twiddle = (MYFLT **)realloc(self->twiddle, 4 * sizeof(MYFLT *));
+ for(i=0; i<4; i++)
+ self->twiddle[i] = (MYFLT *)malloc(n8 * sizeof(MYFLT));
+ fft_compute_split_twiddle(self->twiddle, self->size);
+ self->window = (MYFLT *)realloc(self->window, self->size * sizeof(MYFLT));
+ gen_window(self->window, self->size, 2);
+}
+
+static void
+Centroid_process_i(Centroid *self) {
+ int i;
+ MYFLT re, im, tmp, sum1, sum2;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ self->input_buffer[self->incount] = in[i];
+ self->data[i] = self->centroid;
+
+ self->incount++;
+ if (self->incount == self->size) {
+ self->incount = self->hsize;
+
+ for (i=0; i<self->size; i++) {
+ self->inframe[i] = self->input_buffer[i] * self->window[i];
+ }
+ realfft_split(self->inframe, self->outframe, self->size, self->twiddle);
+ sum1 = sum2 = 0.0;
+ for (i=1; i<self->hsize; i++) {
+ re = self->outframe[i];
+ im = self->outframe[self->size - i];
+ tmp = MYSQRT(re*re + im*im);
+ sum1 += tmp * i;
+ sum2 += tmp;
+ }
+ if (sum2 < 0.000000001)
+ tmp = 0.0;
+ else
+ tmp = sum1 / sum2;
+ self->centroid += tmp * self->sr / self->size;
+ self->centroid *= 0.5;
+ for (i=0; i<self->hsize; i++) {
+ self->input_buffer[i] = self->input_buffer[i + self->hsize];
+ }
+ }
+ }
+}
+
+static void Centroid_postprocessing_ii(Centroid *self) { POST_PROCESSING_II };
+static void Centroid_postprocessing_ai(Centroid *self) { POST_PROCESSING_AI };
+static void Centroid_postprocessing_ia(Centroid *self) { POST_PROCESSING_IA };
+static void Centroid_postprocessing_aa(Centroid *self) { POST_PROCESSING_AA };
+static void Centroid_postprocessing_ireva(Centroid *self) { POST_PROCESSING_IREVA };
+static void Centroid_postprocessing_areva(Centroid *self) { POST_PROCESSING_AREVA };
+static void Centroid_postprocessing_revai(Centroid *self) { POST_PROCESSING_REVAI };
+static void Centroid_postprocessing_revaa(Centroid *self) { POST_PROCESSING_REVAA };
+static void Centroid_postprocessing_revareva(Centroid *self) { POST_PROCESSING_REVAREVA };
+
+static void
+Centroid_setProcMode(Centroid *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ self->proc_func_ptr = Centroid_process_i;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = Centroid_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = Centroid_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = Centroid_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = Centroid_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = Centroid_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = Centroid_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = Centroid_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = Centroid_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = Centroid_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+Centroid_compute_next_data_frame(Centroid *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+Centroid_traverse(Centroid *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ return 0;
+}
+
+static int
+Centroid_clear(Centroid *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ return 0;
+}
+
+static void
+Centroid_dealloc(Centroid* self)
+{
+ int i;
+ pyo_DEALLOC
+ free(self->inframe);
+ free(self->outframe);
+ free(self->input_buffer);
+ for(i=0; i<4; i++) {
+ free(self->twiddle[i]);
+ }
+ free(self->twiddle);
+ free(self->window);
+ Centroid_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+Centroid_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i, k;
+ PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
+ Centroid *self;
+ self = (Centroid *)type->tp_alloc(type, 0);
+
+ self->centroid = 0;
+ self->size = 1024;
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, Centroid_compute_next_data_frame);
+ self->mode_func_ptr = Centroid_setProcMode;
+
+ static char *kwlist[] = {"input", "size", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &inputtmp, &self->size, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ if (self->size < self->bufsize) {
+ printf("Warning : Centroid size less than buffer size!\nCentroid size set to buffersize: %d\n", self->bufsize);
+ self->size = self->bufsize;
+ }
+
+ k = 1;
+ while (k < self->size)
+ k <<= 1;
+ self->size = k;
+
+ INIT_INPUT_STREAM
+
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ }
+
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ Centroid_alloc_memories(self);
+
+ self->incount = self->hsize;
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * Centroid_getServer(Centroid* self) { GET_SERVER };
+static PyObject * Centroid_getStream(Centroid* self) { GET_STREAM };
+static PyObject * Centroid_setMul(Centroid *self, PyObject *arg) { SET_MUL };
+static PyObject * Centroid_setAdd(Centroid *self, PyObject *arg) { SET_ADD };
+static PyObject * Centroid_setSub(Centroid *self, PyObject *arg) { SET_SUB };
+static PyObject * Centroid_setDiv(Centroid *self, PyObject *arg) { SET_DIV };
+
+static PyObject * Centroid_play(Centroid *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Centroid_stop(Centroid *self) { STOP };
+
+static PyObject * Centroid_multiply(Centroid *self, PyObject *arg) { MULTIPLY };
+static PyObject * Centroid_inplace_multiply(Centroid *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Centroid_add(Centroid *self, PyObject *arg) { ADD };
+static PyObject * Centroid_inplace_add(Centroid *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Centroid_sub(Centroid *self, PyObject *arg) { SUB };
+static PyObject * Centroid_inplace_sub(Centroid *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Centroid_div(Centroid *self, PyObject *arg) { DIV };
+static PyObject * Centroid_inplace_div(Centroid *self, PyObject *arg) { INPLACE_DIV };
+
+
+static PyMemberDef Centroid_members[] = {
+{"server", T_OBJECT_EX, offsetof(Centroid, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(Centroid, stream), 0, "Stream object."},
+{"mul", T_OBJECT_EX, offsetof(Centroid, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(Centroid, add), 0, "Add factor."},
+{"input", T_OBJECT_EX, offsetof(Centroid, input), 0, "Input sound object."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef Centroid_methods[] = {
+{"getServer", (PyCFunction)Centroid_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)Centroid_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)Centroid_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"stop", (PyCFunction)Centroid_stop, METH_NOARGS, "Stops computing."},
+{"setMul", (PyCFunction)Centroid_setMul, METH_O, "Sets Centroid mul factor."},
+{"setAdd", (PyCFunction)Centroid_setAdd, METH_O, "Sets Centroid add factor."},
+{"setSub", (PyCFunction)Centroid_setSub, METH_O, "Sets Centroid add factor."},
+{"setDiv", (PyCFunction)Centroid_setDiv, METH_O, "Sets Centroid mul factor."},
+{NULL} /* Sentinel */
+};
+
+static PyNumberMethods Centroid_as_number = {
+ (binaryfunc)Centroid_add, /*nb_add*/
+ (binaryfunc)Centroid_sub, /*nb_subtract*/
+ (binaryfunc)Centroid_multiply, /*nb_multiply*/
+ (binaryfunc)Centroid_div, /*nb_divide*/
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_neg*/
+ 0, /*nb_pos*/
+ 0, /*(unaryfunc)array_abs,*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ 0, /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ 0, /*nb_oct*/
+ 0, /*nb_hex*/
+ (binaryfunc)Centroid_inplace_add, /*inplace_add*/
+ (binaryfunc)Centroid_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)Centroid_inplace_multiply, /*inplace_multiply*/
+ (binaryfunc)Centroid_inplace_div, /*inplace_divide*/
+ 0, /*inplace_remainder*/
+ 0, /*inplace_power*/
+ 0, /*inplace_lshift*/
+ 0, /*inplace_rshift*/
+ 0, /*inplace_and*/
+ 0, /*inplace_xor*/
+ 0, /*inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject CentroidType = {
+PyObject_HEAD_INIT(NULL)
+0, /*ob_size*/
+"_pyo.Centroid_base", /*tp_name*/
+sizeof(Centroid), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)Centroid_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_compare*/
+0, /*tp_repr*/
+&Centroid_as_number, /*tp_as_number*/
+0, /*tp_as_sequence*/
+0, /*tp_as_mapping*/
+0, /*tp_hash */
+0, /*tp_call*/
+0, /*tp_str*/
+0, /*tp_getattro*/
+0, /*tp_setattro*/
+0, /*tp_as_buffer*/
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+"Centroid objects. FFT transform.", /* tp_doc */
+(traverseproc)Centroid_traverse, /* tp_traverse */
+(inquiry)Centroid_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+Centroid_methods, /* tp_methods */
+Centroid_members, /* tp_members */
+0, /* tp_getset */
+0, /* tp_base */
+0, /* tp_dict */
+0, /* tp_descr_get */
+0, /* tp_descr_set */
+0, /* tp_dictoffset */
+0, /* tp_init */
+0, /* tp_alloc */
+Centroid_new, /* tp_new */
+};
+
+/************/
+/* AttackDetector */
+/************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ MYFLT deltime;
+ MYFLT cutoff;
+ MYFLT maxthresh;
+ MYFLT minthresh;
+ MYFLT reltime;
+ MYFLT folfactor;
+ MYFLT follow;
+ MYFLT followdb;
+ MYFLT *buffer;
+ MYFLT previous;
+ int memsize;
+ int sampdel;
+ int incount;
+ int overminok;
+ int belowminok;
+ long maxtime;
+ long timer;
+ int modebuffer[2]; // need at least 2 slots for mul & add
+} AttackDetector;
+
+static void
+AttackDetector_process(AttackDetector *self) {
+ int i, ind;
+ MYFLT absin;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = 0.0;
+ absin = in[i];
+ // envelope follower
+ if (absin < 0.0)
+ absin = -absin;
+ self->follow = absin + self->folfactor * (self->follow - absin);
+ // follower in dB
+ if (self->follow <= 0.000001)
+ self->followdb = -120.0;
+ else
+ self->followdb = 20.0 * MYLOG10(self->follow);
+ // previous analysis
+ ind = self->incount - self->sampdel;
+ if (ind < 0)
+ ind += self->memsize;
+ self->previous = self->buffer[ind];
+ self->buffer[self->incount] = self->followdb;
+ self->incount++;
+ if (self->incount >= self->memsize)
+ self->incount = 0;
+ // if release time has past
+ if (self->timer >= self->maxtime) {
+ // if rms is over min threshold
+ if (self->overminok) {
+ // if rms is greater than previous + maxthresh
+ if (self->followdb > (self->previous + self->maxthresh)) {
+ self->data[i] = 1.0;
+ self->overminok = self->belowminok = 0;
+ self->timer = 0;
+ }
+ }
+ }
+ if (self->belowminok == 0 && self->followdb < self->minthresh)
+ self->belowminok = 1;
+ else if (self->belowminok == 1 && self->followdb > self->minthresh)
+ self->overminok = 1;
+ self->timer++;
+ }
+}
+
+static void AttackDetector_postprocessing_ii(AttackDetector *self) { POST_PROCESSING_II };
+static void AttackDetector_postprocessing_ai(AttackDetector *self) { POST_PROCESSING_AI };
+static void AttackDetector_postprocessing_ia(AttackDetector *self) { POST_PROCESSING_IA };
+static void AttackDetector_postprocessing_aa(AttackDetector *self) { POST_PROCESSING_AA };
+static void AttackDetector_postprocessing_ireva(AttackDetector *self) { POST_PROCESSING_IREVA };
+static void AttackDetector_postprocessing_areva(AttackDetector *self) { POST_PROCESSING_AREVA };
+static void AttackDetector_postprocessing_revai(AttackDetector *self) { POST_PROCESSING_REVAI };
+static void AttackDetector_postprocessing_revaa(AttackDetector *self) { POST_PROCESSING_REVAA };
+static void AttackDetector_postprocessing_revareva(AttackDetector *self) { POST_PROCESSING_REVAREVA };
+
+static void
+AttackDetector_setProcMode(AttackDetector *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ self->proc_func_ptr = AttackDetector_process;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = AttackDetector_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = AttackDetector_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = AttackDetector_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = AttackDetector_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = AttackDetector_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = AttackDetector_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = AttackDetector_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = AttackDetector_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = AttackDetector_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+AttackDetector_compute_next_data_frame(AttackDetector *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+AttackDetector_traverse(AttackDetector *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ return 0;
+}
+
+static int
+AttackDetector_clear(AttackDetector *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ return 0;
+}
+
+static void
+AttackDetector_dealloc(AttackDetector* self)
+{
+ pyo_DEALLOC
+ free(self->buffer);
+ AttackDetector_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+AttackDetector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
+ AttackDetector *self;
+ self = (AttackDetector *)type->tp_alloc(type, 0);
+
+ self->deltime = 0.005;
+ self->cutoff = 10.0;
+ self->maxthresh = 3.0;
+ self->minthresh = -30.0;
+ self->reltime = 0.1;
+ self->follow = 0.0;
+ self->followdb = -120.0;
+ self->previous = 0.0;
+ self->incount = 0;
+ self->overminok = 0;
+ self->belowminok = 0;
+ self->timer = 0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, AttackDetector_compute_next_data_frame);
+ self->mode_func_ptr = AttackDetector_setProcMode;
+
+ static char *kwlist[] = {"input", "deltime", "cutoff", "maxthresh", "minthresh", "reltime", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FFFFFOO, kwlist, &inputtmp, &self->deltime, &self->cutoff, &self->maxthresh, &self->minthresh, &self->reltime, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ INIT_INPUT_STREAM
+
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ }
+
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ self->memsize = (int)(0.055 * self->sr + 0.5);
+ self->buffer = (MYFLT *)realloc(self->buffer, (self->memsize+1) * sizeof(MYFLT));
+ for (i=0; i<(self->memsize+1); i++) {
+ self->buffer[i] = 0.0;
+ }
+
+ if (self->deltime < 0.001) self->deltime = 0.001;
+ else if (self->deltime > 0.05) self->deltime = 0.05;
+ self->sampdel = (int)(self->deltime * self->sr);
+
+ if (self->cutoff < 1.0) self->cutoff = 1.0;
+ else if (self->cutoff > 1000.0) self->cutoff = 1000.0;
+ self->folfactor = MYEXP(-TWOPI * self->cutoff / self->sr);
+
+ if (self->cutoff < 1.0) self->cutoff = 1.0;
+ else if (self->cutoff > 1000.0) self->cutoff = 1000.0;
+
+ if (self->maxthresh < 0.0) self->maxthresh = 0.0;
+ else if (self->maxthresh > 18.0) self->maxthresh = 18.0;
+
+ if (self->minthresh < -90.0) self->minthresh = -90.0;
+ else if (self->minthresh > 0.0) self->minthresh = 0.0;
+
+ if (self->reltime < 0.001) self->reltime = 0.001;
+ self->maxtime = (long)(self->reltime * self->sr + 0.5);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * AttackDetector_getServer(AttackDetector* self) { GET_SERVER };
+static PyObject * AttackDetector_getStream(AttackDetector* self) { GET_STREAM };
+static PyObject * AttackDetector_setMul(AttackDetector *self, PyObject *arg) { SET_MUL };
+static PyObject * AttackDetector_setAdd(AttackDetector *self, PyObject *arg) { SET_ADD };
+static PyObject * AttackDetector_setSub(AttackDetector *self, PyObject *arg) { SET_SUB };
+static PyObject * AttackDetector_setDiv(AttackDetector *self, PyObject *arg) { SET_DIV };
+
+static PyObject * AttackDetector_play(AttackDetector *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * AttackDetector_stop(AttackDetector *self) { STOP };
+
+static PyObject * AttackDetector_multiply(AttackDetector *self, PyObject *arg) { MULTIPLY };
+static PyObject * AttackDetector_inplace_multiply(AttackDetector *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * AttackDetector_add(AttackDetector *self, PyObject *arg) { ADD };
+static PyObject * AttackDetector_inplace_add(AttackDetector *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * AttackDetector_sub(AttackDetector *self, PyObject *arg) { SUB };
+static PyObject * AttackDetector_inplace_sub(AttackDetector *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * AttackDetector_div(AttackDetector *self, PyObject *arg) { DIV };
+static PyObject * AttackDetector_inplace_div(AttackDetector *self, PyObject *arg) { INPLACE_DIV };
+
+static PyObject *
+AttackDetector_setDeltime(AttackDetector *self, PyObject *arg)
+{
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ if (isNumber == 1) {
+ self->deltime = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
+ if (self->deltime < 0.001) self->deltime = 0.001;
+ else if (self->deltime > 0.05) self->deltime = 0.05;
+ self->sampdel = (int)(self->deltime * self->sr);
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+AttackDetector_setCutoff(AttackDetector *self, PyObject *arg)
+{
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ if (isNumber == 1) {
+ self->cutoff = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
+ if (self->cutoff < 1.0) self->cutoff = 1.0;
+ else if (self->cutoff > 1000.0) self->cutoff = 1000.0;
+ self->folfactor = MYEXP(-TWOPI * self->cutoff / self->sr);
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+AttackDetector_setMaxthresh(AttackDetector *self, PyObject *arg)
+{
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ if (isNumber == 1) {
+ self->maxthresh = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
+ if (self->maxthresh < 0.0) self->maxthresh = 0.0;
+ else if (self->maxthresh > 18.0) self->maxthresh = 18.0;
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+AttackDetector_setMinthresh(AttackDetector *self, PyObject *arg)
+{
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ if (isNumber == 1) {
+ self->minthresh = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
+ if (self->minthresh < -90.0) self->minthresh = -90.0;
+ else if (self->minthresh > 0.0) self->minthresh = 0.0;
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+AttackDetector_setReltime(AttackDetector *self, PyObject *arg)
+{
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ if (isNumber == 1) {
+ self->reltime = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
+ if (self->reltime < 0.001) self->reltime = 0.001;
+ self->maxtime = (long)(self->reltime * self->sr + 0.5);
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyMemberDef AttackDetector_members[] = {
+{"server", T_OBJECT_EX, offsetof(AttackDetector, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(AttackDetector, stream), 0, "Stream object."},
+{"input", T_OBJECT_EX, offsetof(AttackDetector, input), 0, "Input sound object."},
+{"mul", T_OBJECT_EX, offsetof(AttackDetector, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(AttackDetector, add), 0, "Add factor."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef AttackDetector_methods[] = {
+{"getServer", (PyCFunction)AttackDetector_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)AttackDetector_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)AttackDetector_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"stop", (PyCFunction)AttackDetector_stop, METH_NOARGS, "Stops computing."},
+{"setDeltime", (PyCFunction)AttackDetector_setDeltime, METH_O, "Sets the delay time between current and previous analysis."},
+{"setCutoff", (PyCFunction)AttackDetector_setCutoff, METH_O, "Sets the frequency of the internal lowpass filter."},
+{"setMaxthresh", (PyCFunction)AttackDetector_setMaxthresh, METH_O, "Sets the higher threshold."},
+{"setMinthresh", (PyCFunction)AttackDetector_setMinthresh, METH_O, "Sets the lower threshold."},
+{"setReltime", (PyCFunction)AttackDetector_setReltime, METH_O, "Sets the release time (min time between two detected attacks)."},
+{"setMul", (PyCFunction)AttackDetector_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)AttackDetector_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)AttackDetector_setSub, METH_O, "Sets inverse add factor."},
+{"setDiv", (PyCFunction)AttackDetector_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
+};
+
+static PyNumberMethods AttackDetector_as_number = {
+(binaryfunc)AttackDetector_add, /*nb_add*/
+(binaryfunc)AttackDetector_sub, /*nb_subtract*/
+(binaryfunc)AttackDetector_multiply, /*nb_multiply*/
+(binaryfunc)AttackDetector_div, /*nb_divide*/
+0, /*nb_remainder*/
+0, /*nb_divmod*/
+0, /*nb_power*/
+0, /*nb_neg*/
+0, /*nb_pos*/
+0, /*(unaryfunc)array_abs,*/
+0, /*nb_nonzero*/
+0, /*nb_invert*/
+0, /*nb_lshift*/
+0, /*nb_rshift*/
+0, /*nb_and*/
+0, /*nb_xor*/
+0, /*nb_or*/
+0, /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+0, /*nb_oct*/
+0, /*nb_hex*/
+(binaryfunc)AttackDetector_inplace_add, /*inplace_add*/
+(binaryfunc)AttackDetector_inplace_sub, /*inplace_subtract*/
+(binaryfunc)AttackDetector_inplace_multiply, /*inplace_multiply*/
+(binaryfunc)AttackDetector_inplace_div, /*inplace_divide*/
+0, /*inplace_remainder*/
+0, /*inplace_power*/
+0, /*inplace_lshift*/
+0, /*inplace_rshift*/
+0, /*inplace_and*/
+0, /*inplace_xor*/
+0, /*inplace_or*/
+0, /*nb_floor_divide*/
+0, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+0, /*nb_inplace_true_divide*/
+0, /* nb_index */
+};
+
+PyTypeObject AttackDetectorType = {
+PyObject_HEAD_INIT(NULL)
+0, /*ob_size*/
+"_pyo.AttackDetector_base", /*tp_name*/
+sizeof(AttackDetector), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)AttackDetector_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_compare*/
+0, /*tp_repr*/
+&AttackDetector_as_number, /*tp_as_number*/
+0, /*tp_as_sequence*/
+0, /*tp_as_mapping*/
+0, /*tp_hash */
+0, /*tp_call*/
+0, /*tp_str*/
+0, /*tp_getattro*/
+0, /*tp_setattro*/
+0, /*tp_as_buffer*/
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+"AttackDetector objects. Audio signal peak detection.", /* tp_doc */
+(traverseproc)AttackDetector_traverse, /* tp_traverse */
+(inquiry)AttackDetector_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+AttackDetector_methods, /* tp_methods */
+AttackDetector_members, /* tp_members */
+0, /* tp_getset */
+0, /* tp_base */
+0, /* tp_dict */
+0, /* tp_descr_get */
+0, /* tp_descr_set */
+0, /* tp_dictoffset */
+0, /* tp_init */
+0, /* tp_alloc */
+AttackDetector_new, /* tp_new */
+};
+
+/*********************************************************************************************/
+/* Scope ********************************************************************************/
+/*********************************************************************************************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ int size;
+ int width;
+ int height;
+ int pointer;
+ MYFLT gain;
+ MYFLT *buffer;
+} Scope;
+
+static void
+Scope_generate(Scope *self) {
+ int i;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ for (i=0; i<self->bufsize; i++) {
+ if (self->pointer >= self->size)
+ self->pointer = 0;
+ self->buffer[self->pointer] = in[i];
+ self->pointer++;
+ }
+}
+
+static PyObject *
+Scope_display(Scope *self) {
+ int i, ipos;
+ MYFLT pos, step, mag, h2;
+ PyObject *points, *tuple;
+
+ step = self->size / (MYFLT)(self->width);
+ h2 = self->height * 0.5;
+
+ points = PyList_New(self->width);
+
+ for (i=0; i<self->width; i++) {
+ pos = i * step;
+ ipos = (int)pos;
+ tuple = PyTuple_New(2);
+ mag = ((self->buffer[ipos] + (self->buffer[ipos+1] - self->buffer[ipos]) * (pos - ipos)) * self->gain * h2 + h2);
+ PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(i));
+ PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->height - (int)mag));
+ PyList_SET_ITEM(points, i, tuple);
+ }
+ return points;
+}
+
+static void
+Scope_compute_next_data_frame(Scope *self)
+{
+ Scope_generate(self);
+}
+
+static int
+Scope_traverse(Scope *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ return 0;
+}
+
+static int
+Scope_clear(Scope *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ return 0;
+}
+
+static void
+Scope_dealloc(Scope* self)
+{
+ pyo_DEALLOC
+ free(self->buffer);
+ Scope_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+Scope_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i, maxsize;
+ MYFLT length = 0.05;
+ PyObject *inputtmp, *input_streamtmp;
+ Scope *self;
+ self = (Scope *)type->tp_alloc(type, 0);
+
+ self->gain = 1.0;
+ self->width = 500;
+ self->height = 400;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, Scope_compute_next_data_frame);
+
+ static char *kwlist[] = {"input", "length", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_F, kwlist, &inputtmp, &length))
+ Py_RETURN_NONE;
+
+ INIT_INPUT_STREAM
+
+ maxsize = (int)(self->sr * 0.25);
+ self->buffer = (MYFLT *)realloc(self->buffer, maxsize * sizeof(MYFLT));
+ self->size = (int)(length * self->sr);
+ if (self->size > maxsize)
+ self->size = maxsize;
+ self->pointer = 0;
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ return (PyObject *)self;
+}
+
+static PyObject * Scope_getServer(Scope* self) { GET_SERVER };
+static PyObject * Scope_getStream(Scope* self) { GET_STREAM };
+
+static PyObject * Scope_play(Scope *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Scope_stop(Scope *self) { STOP };
+
+static PyObject *
+Scope_setLength(Scope *self, PyObject *arg)
+{
+ MYFLT length;
+ int maxsize = (int)(self->sr * 0.25);
+
+ if (PyNumber_Check(arg)) {
+ length = PyFloat_AsDouble(PyNumber_Float(arg));
+ self->size = (int)(length * self->sr);
+ if (self->size > maxsize)
+ self->size = maxsize;
+ self->pointer = 0;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+Scope_setGain(Scope *self, PyObject *arg)
+{
+ if (PyNumber_Check(arg)) {
+ self->gain = PyFloat_AsDouble(PyNumber_Float(arg));
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+Scope_setWidth(Scope *self, PyObject *arg)
+{
+ if (PyInt_Check(arg)) {
+ self->width = PyInt_AsLong(arg);
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+Scope_setHeight(Scope *self, PyObject *arg)
+{
+ if (PyInt_Check(arg)) {
+ self->height = PyInt_AsLong(arg);
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef Scope_members[] = {
+{"server", T_OBJECT_EX, offsetof(Scope, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(Scope, stream), 0, "Stream object."},
+{"input", T_OBJECT_EX, offsetof(Scope, input), 0, "Input sound object."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef Scope_methods[] = {
+{"getServer", (PyCFunction)Scope_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)Scope_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)Scope_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"stop", (PyCFunction)Scope_stop, METH_NOARGS, "Stops computing."},
+{"display", (PyCFunction)Scope_display, METH_NOARGS, "Computes the samples to draw."},
+{"setLength", (PyCFunction)Scope_setLength, METH_O, "Sets function's argument."},
+{"setGain", (PyCFunction)Scope_setGain, METH_O, "Sets gain compensation."},
+{"setWidth", (PyCFunction)Scope_setWidth, METH_O, "Sets the width of the display."},
+{"setHeight", (PyCFunction)Scope_setHeight, METH_O, "Sets the height of the display."},
+{NULL} /* Sentinel */
+};
+
+PyTypeObject ScopeType = {
+PyObject_HEAD_INIT(NULL)
+0, /*ob_size*/
+"_pyo.Scope_base", /*tp_name*/
+sizeof(Scope), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)Scope_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_compare*/
+0, /*tp_repr*/
+0, /*tp_as_number*/
+0, /*tp_as_sequence*/
+0, /*tp_as_mapping*/
+0, /*tp_hash */
+0, /*tp_call*/
+0, /*tp_str*/
+0, /*tp_getattro*/
+0, /*tp_setattro*/
+0, /*tp_as_buffer*/
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+"Scope objects. Show the waveform of an input signal.", /* tp_doc */
+(traverseproc)Scope_traverse, /* tp_traverse */
+(inquiry)Scope_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+Scope_methods, /* tp_methods */
+Scope_members, /* tp_members */
+0, /* tp_getset */
+0, /* tp_base */
+0, /* tp_dict */
+0, /* tp_descr_get */
+0, /* tp_descr_set */
+0, /* tp_dictoffset */
+0, /* tp_init */
+0, /* tp_alloc */
+Scope_new, /* tp_new */
+};
+
+/************/
+/* PeakAmp */
+/************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ int modebuffer[2]; // need at least 2 slots for mul & add
+ MYFLT follow;
+} PeakAmp;
+
+static void
+PeakAmp_filters_i(PeakAmp *self) {
+ MYFLT absin, peak;
+ int i;
+
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+
+ peak = 0.0;
+ for (i=0; i<self->bufsize; i++) {
+ absin = in[i];
+ if (absin < 0.0)
+ absin = -absin;
+ if (absin > peak)
+ peak = absin;
+ self->data[i] = self->follow;
+ }
+ self->follow = peak;
+}
+
+static void PeakAmp_postprocessing_ii(PeakAmp *self) { POST_PROCESSING_II };
+static void PeakAmp_postprocessing_ai(PeakAmp *self) { POST_PROCESSING_AI };
+static void PeakAmp_postprocessing_ia(PeakAmp *self) { POST_PROCESSING_IA };
+static void PeakAmp_postprocessing_aa(PeakAmp *self) { POST_PROCESSING_AA };
+static void PeakAmp_postprocessing_ireva(PeakAmp *self) { POST_PROCESSING_IREVA };
+static void PeakAmp_postprocessing_areva(PeakAmp *self) { POST_PROCESSING_AREVA };
+static void PeakAmp_postprocessing_revai(PeakAmp *self) { POST_PROCESSING_REVAI };
+static void PeakAmp_postprocessing_revaa(PeakAmp *self) { POST_PROCESSING_REVAA };
+static void PeakAmp_postprocessing_revareva(PeakAmp *self) { POST_PROCESSING_REVAREVA };
+
+static void
+PeakAmp_setProcMode(PeakAmp *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ self->proc_func_ptr = PeakAmp_filters_i;
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = PeakAmp_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = PeakAmp_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = PeakAmp_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = PeakAmp_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = PeakAmp_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = PeakAmp_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = PeakAmp_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = PeakAmp_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = PeakAmp_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+PeakAmp_compute_next_data_frame(PeakAmp *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+PeakAmp_traverse(PeakAmp *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ return 0;
+}
+
+static int
+PeakAmp_clear(PeakAmp *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ return 0;
+}
+
+static void
+PeakAmp_dealloc(PeakAmp* self)
+{
+ pyo_DEALLOC
+ PeakAmp_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+PeakAmp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
+ PeakAmp *self;
+ self = (PeakAmp *)type->tp_alloc(type, 0);
+
+ self->follow = 0.0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, PeakAmp_compute_next_data_frame);
+ self->mode_func_ptr = PeakAmp_setProcMode;
+
+ static char *kwlist[] = {"input", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ INIT_INPUT_STREAM
+
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ }
+
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * PeakAmp_getServer(PeakAmp* self) { GET_SERVER };
+static PyObject * PeakAmp_getStream(PeakAmp* self) { GET_STREAM };
+static PyObject * PeakAmp_setMul(PeakAmp *self, PyObject *arg) { SET_MUL };
+static PyObject * PeakAmp_setAdd(PeakAmp *self, PyObject *arg) { SET_ADD };
+static PyObject * PeakAmp_setSub(PeakAmp *self, PyObject *arg) { SET_SUB };
+static PyObject * PeakAmp_setDiv(PeakAmp *self, PyObject *arg) { SET_DIV };
+
+static PyObject * PeakAmp_play(PeakAmp *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * PeakAmp_stop(PeakAmp *self) { STOP };
+
+static PyObject * PeakAmp_multiply(PeakAmp *self, PyObject *arg) { MULTIPLY };
+static PyObject * PeakAmp_inplace_multiply(PeakAmp *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * PeakAmp_add(PeakAmp *self, PyObject *arg) { ADD };
+static PyObject * PeakAmp_inplace_add(PeakAmp *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * PeakAmp_sub(PeakAmp *self, PyObject *arg) { SUB };
+static PyObject * PeakAmp_inplace_sub(PeakAmp *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * PeakAmp_div(PeakAmp *self, PyObject *arg) { DIV };
+static PyObject * PeakAmp_inplace_div(PeakAmp *self, PyObject *arg) { INPLACE_DIV };
+
+static PyObject *
+PeakAmp_getValue(PeakAmp *self)
+{
+ return PyFloat_FromDouble(self->follow);
+}
+
+static PyMemberDef PeakAmp_members[] = {
+{"server", T_OBJECT_EX, offsetof(PeakAmp, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(PeakAmp, stream), 0, "Stream object."},
+{"input", T_OBJECT_EX, offsetof(PeakAmp, input), 0, "Input sound object."},
+{"mul", T_OBJECT_EX, offsetof(PeakAmp, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(PeakAmp, add), 0, "Add factor."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef PeakAmp_methods[] = {
+{"getServer", (PyCFunction)PeakAmp_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)PeakAmp_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)PeakAmp_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"stop", (PyCFunction)PeakAmp_stop, METH_NOARGS, "Stops computing."},
+{"getValue", (PyCFunction)PeakAmp_getValue, METH_NOARGS, "Returns the current peaking value."},
+{"setMul", (PyCFunction)PeakAmp_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)PeakAmp_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)PeakAmp_setSub, METH_O, "Sets inverse add factor."},
+{"setDiv", (PyCFunction)PeakAmp_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
+};
+
+static PyNumberMethods PeakAmp_as_number = {
+(binaryfunc)PeakAmp_add, /*nb_add*/
+(binaryfunc)PeakAmp_sub, /*nb_subtract*/
+(binaryfunc)PeakAmp_multiply, /*nb_multiply*/
+(binaryfunc)PeakAmp_div, /*nb_divide*/
+0, /*nb_remainder*/
+0, /*nb_divmod*/
+0, /*nb_power*/
+0, /*nb_neg*/
+0, /*nb_pos*/
+0, /*(unaryfunc)array_abs,*/
+0, /*nb_nonzero*/
+0, /*nb_invert*/
+0, /*nb_lshift*/
+0, /*nb_rshift*/
+0, /*nb_and*/
+0, /*nb_xor*/
+0, /*nb_or*/
+0, /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+0, /*nb_oct*/
+0, /*nb_hex*/
+(binaryfunc)PeakAmp_inplace_add, /*inplace_add*/
+(binaryfunc)PeakAmp_inplace_sub, /*inplace_subtract*/
+(binaryfunc)PeakAmp_inplace_multiply, /*inplace_multiply*/
+(binaryfunc)PeakAmp_inplace_div, /*inplace_divide*/
+0, /*inplace_remainder*/
+0, /*inplace_power*/
+0, /*inplace_lshift*/
+0, /*inplace_rshift*/
+0, /*inplace_and*/
+0, /*inplace_xor*/
+0, /*inplace_or*/
+0, /*nb_floor_divide*/
+0, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+0, /*nb_inplace_true_divide*/
+0, /* nb_index */
+};
+
+PyTypeObject PeakAmpType = {
+PyObject_HEAD_INIT(NULL)
+0, /*ob_size*/
+"_pyo.PeakAmp_base", /*tp_name*/
+sizeof(PeakAmp), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)PeakAmp_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_compare*/
+0, /*tp_repr*/
+&PeakAmp_as_number, /*tp_as_number*/
+0, /*tp_as_sequence*/
+0, /*tp_as_mapping*/
+0, /*tp_hash */
+0, /*tp_call*/
+0, /*tp_str*/
+0, /*tp_getattro*/
+0, /*tp_setattro*/
+0, /*tp_as_buffer*/
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+"PeakAmp objects. Envelope follower.", /* tp_doc */
+(traverseproc)PeakAmp_traverse, /* tp_traverse */
+(inquiry)PeakAmp_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+PeakAmp_methods, /* tp_methods */
+PeakAmp_members, /* tp_members */
+0, /* tp_getset */
+0, /* tp_base */
+0, /* tp_dict */
+0, /* tp_descr_get */
+0, /* tp_descr_set */
+0, /* tp_dictoffset */
+0, /* tp_init */
+0, /* tp_alloc */
+PeakAmp_new, /* tp_new */
};
\ No newline at end of file
diff --git a/src/objects/arithmeticmodule.c b/src/objects/arithmeticmodule.c
index 1c06284..6bfc398 100644
--- a/src/objects/arithmeticmodule.c
+++ b/src/objects/arithmeticmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -40,7 +40,7 @@ static void
M_Sin_process(M_Sin *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYSIN(in[i]);
}
@@ -61,44 +61,44 @@ M_Sin_setProcMode(M_Sin *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Sin_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Sin_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Sin_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Sin_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Sin_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Sin_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Sin_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Sin_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Sin_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Sin_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Sin_compute_next_data_frame(M_Sin *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -111,7 +111,7 @@ M_Sin_traverse(M_Sin *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Sin_clear(M_Sin *self)
{
pyo_CLEAR
@@ -138,28 +138,28 @@ M_Sin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Sin_compute_next_data_frame);
self->mode_func_ptr = M_Sin_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -167,10 +167,10 @@ M_Sin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Sin_getServer(M_Sin* self) { GET_SERVER };
static PyObject * M_Sin_getStream(M_Sin* self) { GET_STREAM };
-static PyObject * M_Sin_setMul(M_Sin *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Sin_setAdd(M_Sin *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Sin_setSub(M_Sin *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Sin_setDiv(M_Sin *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Sin_setMul(M_Sin *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Sin_setAdd(M_Sin *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Sin_setSub(M_Sin *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Sin_setDiv(M_Sin *self, PyObject *arg) { SET_DIV };
static PyObject * M_Sin_play(M_Sin *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Sin_out(M_Sin *self, PyObject *args, PyObject *kwds) { OUT };
@@ -305,7 +305,7 @@ static void
M_Cos_process(M_Cos *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYCOS(in[i]);
}
@@ -326,44 +326,44 @@ M_Cos_setProcMode(M_Cos *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Cos_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Cos_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Cos_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Cos_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Cos_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Cos_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Cos_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Cos_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Cos_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Cos_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Cos_compute_next_data_frame(M_Cos *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -376,7 +376,7 @@ M_Cos_traverse(M_Cos *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Cos_clear(M_Cos *self)
{
pyo_CLEAR
@@ -400,31 +400,31 @@ M_Cos_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Cos *self;
self = (M_Cos *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Cos_compute_next_data_frame);
self->mode_func_ptr = M_Cos_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -432,10 +432,10 @@ M_Cos_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Cos_getServer(M_Cos* self) { GET_SERVER };
static PyObject * M_Cos_getStream(M_Cos* self) { GET_STREAM };
-static PyObject * M_Cos_setMul(M_Cos *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Cos_setAdd(M_Cos *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Cos_setSub(M_Cos *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Cos_setDiv(M_Cos *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Cos_setMul(M_Cos *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Cos_setAdd(M_Cos *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Cos_setSub(M_Cos *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Cos_setDiv(M_Cos *self, PyObject *arg) { SET_DIV };
static PyObject * M_Cos_play(M_Cos *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Cos_out(M_Cos *self, PyObject *args, PyObject *kwds) { OUT };
@@ -570,7 +570,7 @@ static void
M_Tan_process(M_Tan *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYTAN(in[i]);
}
@@ -591,44 +591,44 @@ M_Tan_setProcMode(M_Tan *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Tan_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Tan_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Tan_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Tan_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Tan_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Tan_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Tan_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Tan_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Tan_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Tan_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Tan_compute_next_data_frame(M_Tan *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -641,7 +641,7 @@ M_Tan_traverse(M_Tan *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Tan_clear(M_Tan *self)
{
pyo_CLEAR
@@ -665,31 +665,31 @@ M_Tan_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Tan *self;
self = (M_Tan *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Tan_compute_next_data_frame);
self->mode_func_ptr = M_Tan_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -697,10 +697,10 @@ M_Tan_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Tan_getServer(M_Tan* self) { GET_SERVER };
static PyObject * M_Tan_getStream(M_Tan* self) { GET_STREAM };
-static PyObject * M_Tan_setMul(M_Tan *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Tan_setAdd(M_Tan *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Tan_setSub(M_Tan *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Tan_setDiv(M_Tan *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Tan_setMul(M_Tan *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Tan_setAdd(M_Tan *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Tan_setSub(M_Tan *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Tan_setDiv(M_Tan *self, PyObject *arg) { SET_DIV };
static PyObject * M_Tan_play(M_Tan *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Tan_out(M_Tan *self, PyObject *args, PyObject *kwds) { OUT };
@@ -836,12 +836,12 @@ M_Abs_process(M_Abs *self) {
int i;
MYFLT inval;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
if (inval < 0.0)
self->data[i] = -inval;
- else
+ else
self->data[i] = inval;
}
}
@@ -861,44 +861,44 @@ M_Abs_setProcMode(M_Abs *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Abs_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Abs_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Abs_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Abs_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Abs_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Abs_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Abs_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Abs_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Abs_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Abs_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Abs_compute_next_data_frame(M_Abs *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -911,7 +911,7 @@ M_Abs_traverse(M_Abs *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Abs_clear(M_Abs *self)
{
pyo_CLEAR
@@ -935,31 +935,31 @@ M_Abs_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Abs *self;
self = (M_Abs *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Abs_compute_next_data_frame);
self->mode_func_ptr = M_Abs_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -967,10 +967,10 @@ M_Abs_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Abs_getServer(M_Abs* self) { GET_SERVER };
static PyObject * M_Abs_getStream(M_Abs* self) { GET_STREAM };
-static PyObject * M_Abs_setMul(M_Abs *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Abs_setAdd(M_Abs *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Abs_setSub(M_Abs *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Abs_setDiv(M_Abs *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Abs_setMul(M_Abs *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Abs_setAdd(M_Abs *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Abs_setSub(M_Abs *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Abs_setDiv(M_Abs *self, PyObject *arg) { SET_DIV };
static PyObject * M_Abs_play(M_Abs *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Abs_out(M_Abs *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1106,12 +1106,12 @@ M_Sqrt_process(M_Sqrt *self) {
int i;
MYFLT inval;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
if (inval < 0.0)
self->data[i] = 0.0;
- else
+ else
self->data[i] = MYSQRT(inval);
}
}
@@ -1131,44 +1131,44 @@ M_Sqrt_setProcMode(M_Sqrt *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Sqrt_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Sqrt_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Sqrt_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Sqrt_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Sqrt_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Sqrt_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Sqrt_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Sqrt_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Sqrt_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Sqrt_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Sqrt_compute_next_data_frame(M_Sqrt *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1181,7 +1181,7 @@ M_Sqrt_traverse(M_Sqrt *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Sqrt_clear(M_Sqrt *self)
{
pyo_CLEAR
@@ -1205,31 +1205,31 @@ M_Sqrt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Sqrt *self;
self = (M_Sqrt *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Sqrt_compute_next_data_frame);
self->mode_func_ptr = M_Sqrt_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1237,10 +1237,10 @@ M_Sqrt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Sqrt_getServer(M_Sqrt* self) { GET_SERVER };
static PyObject * M_Sqrt_getStream(M_Sqrt* self) { GET_STREAM };
-static PyObject * M_Sqrt_setMul(M_Sqrt *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Sqrt_setAdd(M_Sqrt *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Sqrt_setSub(M_Sqrt *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Sqrt_setDiv(M_Sqrt *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Sqrt_setMul(M_Sqrt *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Sqrt_setAdd(M_Sqrt *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Sqrt_setSub(M_Sqrt *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Sqrt_setDiv(M_Sqrt *self, PyObject *arg) { SET_DIV };
static PyObject * M_Sqrt_play(M_Sqrt *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Sqrt_out(M_Sqrt *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1376,12 +1376,12 @@ M_Log_process(M_Log *self) {
int i;
MYFLT inval;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
if (inval <= 0.0)
self->data[i] = 0.0;
- else
+ else
self->data[i] = MYLOG(inval);
}
}
@@ -1401,44 +1401,44 @@ M_Log_setProcMode(M_Log *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Log_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Log_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Log_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Log_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Log_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Log_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Log_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Log_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Log_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Log_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Log_compute_next_data_frame(M_Log *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1451,7 +1451,7 @@ M_Log_traverse(M_Log *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Log_clear(M_Log *self)
{
pyo_CLEAR
@@ -1475,31 +1475,31 @@ M_Log_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Log *self;
self = (M_Log *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Log_compute_next_data_frame);
self->mode_func_ptr = M_Log_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1507,10 +1507,10 @@ M_Log_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Log_getServer(M_Log* self) { GET_SERVER };
static PyObject * M_Log_getStream(M_Log* self) { GET_STREAM };
-static PyObject * M_Log_setMul(M_Log *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Log_setAdd(M_Log *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Log_setSub(M_Log *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Log_setDiv(M_Log *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Log_setMul(M_Log *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Log_setAdd(M_Log *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Log_setSub(M_Log *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Log_setDiv(M_Log *self, PyObject *arg) { SET_DIV };
static PyObject * M_Log_play(M_Log *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Log_out(M_Log *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1646,12 +1646,12 @@ M_Log10_process(M_Log10 *self) {
int i;
MYFLT inval;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
if (inval <= 0.0)
self->data[i] = 0.0;
- else
+ else
self->data[i] = MYLOG10(inval);
}
}
@@ -1671,44 +1671,44 @@ M_Log10_setProcMode(M_Log10 *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Log10_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Log10_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Log10_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Log10_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Log10_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Log10_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Log10_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Log10_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Log10_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Log10_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Log10_compute_next_data_frame(M_Log10 *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1721,7 +1721,7 @@ M_Log10_traverse(M_Log10 *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Log10_clear(M_Log10 *self)
{
pyo_CLEAR
@@ -1745,31 +1745,31 @@ M_Log10_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Log10 *self;
self = (M_Log10 *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Log10_compute_next_data_frame);
self->mode_func_ptr = M_Log10_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1777,10 +1777,10 @@ M_Log10_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Log10_getServer(M_Log10* self) { GET_SERVER };
static PyObject * M_Log10_getStream(M_Log10* self) { GET_STREAM };
-static PyObject * M_Log10_setMul(M_Log10 *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Log10_setAdd(M_Log10 *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Log10_setSub(M_Log10 *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Log10_setDiv(M_Log10 *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Log10_setMul(M_Log10 *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Log10_setAdd(M_Log10 *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Log10_setSub(M_Log10 *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Log10_setDiv(M_Log10 *self, PyObject *arg) { SET_DIV };
static PyObject * M_Log10_play(M_Log10 *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Log10_out(M_Log10 *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1916,12 +1916,12 @@ M_Log2_process(M_Log2 *self) {
int i;
MYFLT inval;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
if (inval <= 0.0)
self->data[i] = 0.0;
- else
+ else
self->data[i] = MYLOG2(inval);
}
}
@@ -1941,44 +1941,44 @@ M_Log2_setProcMode(M_Log2 *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Log2_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Log2_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Log2_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Log2_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Log2_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Log2_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Log2_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Log2_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Log2_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Log2_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Log2_compute_next_data_frame(M_Log2 *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1991,7 +1991,7 @@ M_Log2_traverse(M_Log2 *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Log2_clear(M_Log2 *self)
{
pyo_CLEAR
@@ -2015,31 +2015,31 @@ M_Log2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Log2 *self;
self = (M_Log2 *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Log2_compute_next_data_frame);
self->mode_func_ptr = M_Log2_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -2047,10 +2047,10 @@ M_Log2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Log2_getServer(M_Log2* self) { GET_SERVER };
static PyObject * M_Log2_getStream(M_Log2* self) { GET_STREAM };
-static PyObject * M_Log2_setMul(M_Log2 *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Log2_setAdd(M_Log2 *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Log2_setSub(M_Log2 *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Log2_setDiv(M_Log2 *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Log2_setMul(M_Log2 *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Log2_setAdd(M_Log2 *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Log2_setSub(M_Log2 *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Log2_setDiv(M_Log2 *self, PyObject *arg) { SET_DIV };
static PyObject * M_Log2_play(M_Log2 *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Log2_out(M_Log2 *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2186,10 +2186,10 @@ typedef struct {
static void
M_Pow_readframes_ii(M_Pow *self) {
int i;
-
+
MYFLT base = PyFloat_AS_DOUBLE(self->base);
MYFLT exp = PyFloat_AS_DOUBLE(self->exponent);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYPOW(base, exp);
}
@@ -2198,10 +2198,10 @@ M_Pow_readframes_ii(M_Pow *self) {
static void
M_Pow_readframes_ai(M_Pow *self) {
int i;
-
+
MYFLT *base = Stream_getData((Stream *)self->base_stream);
MYFLT exp = PyFloat_AS_DOUBLE(self->exponent);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYPOW(base[i], exp);
}
@@ -2210,10 +2210,10 @@ M_Pow_readframes_ai(M_Pow *self) {
static void
M_Pow_readframes_ia(M_Pow *self) {
int i;
-
+
MYFLT base = PyFloat_AS_DOUBLE(self->base);
MYFLT *exp = Stream_getData((Stream *)self->exponent_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYPOW(base, exp[i]);
}
@@ -2222,10 +2222,10 @@ M_Pow_readframes_ia(M_Pow *self) {
static void
M_Pow_readframes_aa(M_Pow *self) {
int i;
-
+
MYFLT *base = Stream_getData((Stream *)self->base_stream);
MYFLT *exp = Stream_getData((Stream *)self->exponent_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYPOW(base[i], exp[i]);
}
@@ -2247,56 +2247,56 @@ M_Pow_setProcMode(M_Pow *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = M_Pow_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = M_Pow_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = M_Pow_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = M_Pow_readframes_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Pow_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Pow_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Pow_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Pow_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Pow_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Pow_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Pow_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Pow_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Pow_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Pow_compute_next_data_frame(M_Pow *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2304,21 +2304,21 @@ static int
M_Pow_traverse(M_Pow *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->exponent);
- Py_VISIT(self->exponent_stream);
- Py_VISIT(self->base);
- Py_VISIT(self->base_stream);
+ Py_VISIT(self->exponent);
+ Py_VISIT(self->exponent_stream);
+ Py_VISIT(self->base);
+ Py_VISIT(self->base_stream);
return 0;
}
-static int
+static int
M_Pow_clear(M_Pow *self)
{
pyo_CLEAR
- Py_CLEAR(self->exponent);
- Py_CLEAR(self->exponent_stream);
- Py_CLEAR(self->base);
- Py_CLEAR(self->base_stream);
+ Py_CLEAR(self->exponent);
+ Py_CLEAR(self->exponent_stream);
+ Py_CLEAR(self->base);
+ Py_CLEAR(self->base_stream);
return 0;
}
@@ -2337,41 +2337,41 @@ M_Pow_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *basetmp=NULL, *exponenttmp=NULL, *multmp=NULL, *addtmp=NULL;
M_Pow *self;
self = (M_Pow *)type->tp_alloc(type, 0);
-
+
self->base = PyFloat_FromDouble(10);
self->exponent = PyFloat_FromDouble(1);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Pow_compute_next_data_frame);
self->mode_func_ptr = M_Pow_setProcMode;
-
+
static char *kwlist[] = {"base", "exponent", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &basetmp, &exponenttmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (basetmp) {
PyObject_CallMethod((PyObject *)self, "setBase", "O", basetmp);
}
-
+
if (exponenttmp) {
PyObject_CallMethod((PyObject *)self, "setExponent", "O", exponenttmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -2379,10 +2379,10 @@ M_Pow_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Pow_getServer(M_Pow* self) { GET_SERVER };
static PyObject * M_Pow_getStream(M_Pow* self) { GET_STREAM };
-static PyObject * M_Pow_setMul(M_Pow *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Pow_setAdd(M_Pow *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Pow_setSub(M_Pow *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Pow_setDiv(M_Pow *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Pow_setMul(M_Pow *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Pow_setAdd(M_Pow *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Pow_setSub(M_Pow *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Pow_setDiv(M_Pow *self, PyObject *arg) { SET_DIV };
static PyObject * M_Pow_play(M_Pow *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Pow_out(M_Pow *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2401,14 +2401,14 @@ static PyObject *
M_Pow_setBase(M_Pow *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->base);
@@ -2424,25 +2424,25 @@ M_Pow_setBase(M_Pow *self, PyObject *arg)
self->base_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
M_Pow_setExponent(M_Pow *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->exponent);
@@ -2458,12 +2458,12 @@ M_Pow_setExponent(M_Pow *self, PyObject *arg)
self->exponent_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef M_Pow_members[] = {
{"server", T_OBJECT_EX, offsetof(M_Pow, server), 0, "Pyo server."},
@@ -2589,10 +2589,10 @@ typedef struct {
static void
M_Atan2_readframes_ii(M_Atan2 *self) {
int i;
-
+
MYFLT b = PyFloat_AS_DOUBLE(self->b);
MYFLT a = PyFloat_AS_DOUBLE(self->a);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYATAN2(b, a);
}
@@ -2601,10 +2601,10 @@ M_Atan2_readframes_ii(M_Atan2 *self) {
static void
M_Atan2_readframes_ai(M_Atan2 *self) {
int i;
-
+
MYFLT *b = Stream_getData((Stream *)self->b_stream);
MYFLT a = PyFloat_AS_DOUBLE(self->a);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYATAN2(b[i], a);
}
@@ -2613,10 +2613,10 @@ M_Atan2_readframes_ai(M_Atan2 *self) {
static void
M_Atan2_readframes_ia(M_Atan2 *self) {
int i;
-
+
MYFLT b = PyFloat_AS_DOUBLE(self->b);
MYFLT *a = Stream_getData((Stream *)self->a_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYATAN2(b, a[i]);
}
@@ -2625,10 +2625,10 @@ M_Atan2_readframes_ia(M_Atan2 *self) {
static void
M_Atan2_readframes_aa(M_Atan2 *self) {
int i;
-
+
MYFLT *b = Stream_getData((Stream *)self->b_stream);
MYFLT *a = Stream_getData((Stream *)self->a_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYATAN2(b[i], a[i]);
}
@@ -2650,56 +2650,56 @@ M_Atan2_setProcMode(M_Atan2 *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = M_Atan2_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = M_Atan2_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = M_Atan2_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = M_Atan2_readframes_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Atan2_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Atan2_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Atan2_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Atan2_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Atan2_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Atan2_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Atan2_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Atan2_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Atan2_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Atan2_compute_next_data_frame(M_Atan2 *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2707,21 +2707,21 @@ static int
M_Atan2_traverse(M_Atan2 *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->b);
- Py_VISIT(self->b_stream);
- Py_VISIT(self->a);
- Py_VISIT(self->a_stream);
+ Py_VISIT(self->b);
+ Py_VISIT(self->b_stream);
+ Py_VISIT(self->a);
+ Py_VISIT(self->a_stream);
return 0;
}
-static int
+static int
M_Atan2_clear(M_Atan2 *self)
{
pyo_CLEAR
- Py_CLEAR(self->b);
- Py_CLEAR(self->b_stream);
- Py_CLEAR(self->a);
- Py_CLEAR(self->a_stream);
+ Py_CLEAR(self->b);
+ Py_CLEAR(self->b_stream);
+ Py_CLEAR(self->a);
+ Py_CLEAR(self->a_stream);
return 0;
}
@@ -2740,52 +2740,52 @@ M_Atan2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *btmp=NULL, *atmp=NULL, *multmp=NULL, *addtmp=NULL;
M_Atan2 *self;
self = (M_Atan2 *)type->tp_alloc(type, 0);
-
+
self->a = PyFloat_FromDouble(1);
self->b = PyFloat_FromDouble(1);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Atan2_compute_next_data_frame);
self->mode_func_ptr = M_Atan2_setProcMode;
static char *kwlist[] = {"b", "a", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &btmp, &atmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (btmp) {
PyObject_CallMethod((PyObject *)self, "setB", "O", btmp);
}
-
+
if (atmp) {
PyObject_CallMethod((PyObject *)self, "setA", "O", atmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * M_Atan2_getServer(M_Atan2* self) { GET_SERVER };
static PyObject * M_Atan2_getStream(M_Atan2* self) { GET_STREAM };
-static PyObject * M_Atan2_setMul(M_Atan2 *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Atan2_setAdd(M_Atan2 *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Atan2_setSub(M_Atan2 *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Atan2_setDiv(M_Atan2 *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Atan2_setMul(M_Atan2 *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Atan2_setAdd(M_Atan2 *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Atan2_setSub(M_Atan2 *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Atan2_setDiv(M_Atan2 *self, PyObject *arg) { SET_DIV };
static PyObject * M_Atan2_play(M_Atan2 *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Atan2_out(M_Atan2 *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2804,14 +2804,14 @@ static PyObject *
M_Atan2_setB(M_Atan2 *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->b);
@@ -2827,25 +2827,25 @@ M_Atan2_setB(M_Atan2 *self, PyObject *arg)
self->b_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
M_Atan2_setA(M_Atan2 *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->a);
@@ -2861,12 +2861,12 @@ M_Atan2_setA(M_Atan2 *self, PyObject *arg)
self->a_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef M_Atan2_members[] = {
{"server", T_OBJECT_EX, offsetof(M_Atan2, server), 0, "Pyo server."},
@@ -2991,7 +2991,7 @@ static void
M_Floor_process(M_Floor *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYFLOOR(in[i]);
}
@@ -3012,44 +3012,44 @@ M_Floor_setProcMode(M_Floor *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Floor_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Floor_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Floor_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Floor_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Floor_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Floor_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Floor_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Floor_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Floor_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Floor_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Floor_compute_next_data_frame(M_Floor *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3062,7 +3062,7 @@ M_Floor_traverse(M_Floor *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Floor_clear(M_Floor *self)
{
pyo_CLEAR
@@ -3086,31 +3086,31 @@ M_Floor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Floor *self;
self = (M_Floor *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Floor_compute_next_data_frame);
self->mode_func_ptr = M_Floor_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3118,10 +3118,10 @@ M_Floor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Floor_getServer(M_Floor* self) { GET_SERVER };
static PyObject * M_Floor_getStream(M_Floor* self) { GET_STREAM };
-static PyObject * M_Floor_setMul(M_Floor *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Floor_setAdd(M_Floor *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Floor_setSub(M_Floor *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Floor_setDiv(M_Floor *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Floor_setMul(M_Floor *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Floor_setAdd(M_Floor *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Floor_setSub(M_Floor *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Floor_setDiv(M_Floor *self, PyObject *arg) { SET_DIV };
static PyObject * M_Floor_play(M_Floor *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Floor_out(M_Floor *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3256,7 +3256,7 @@ static void
M_Ceil_process(M_Ceil *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYCEIL(in[i]);
}
@@ -3277,44 +3277,44 @@ M_Ceil_setProcMode(M_Ceil *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Ceil_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Ceil_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Ceil_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Ceil_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Ceil_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Ceil_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Ceil_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Ceil_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Ceil_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Ceil_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Ceil_compute_next_data_frame(M_Ceil *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3327,7 +3327,7 @@ M_Ceil_traverse(M_Ceil *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Ceil_clear(M_Ceil *self)
{
pyo_CLEAR
@@ -3351,31 +3351,31 @@ M_Ceil_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Ceil *self;
self = (M_Ceil *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Ceil_compute_next_data_frame);
self->mode_func_ptr = M_Ceil_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3383,10 +3383,10 @@ M_Ceil_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Ceil_getServer(M_Ceil* self) { GET_SERVER };
static PyObject * M_Ceil_getStream(M_Ceil* self) { GET_STREAM };
-static PyObject * M_Ceil_setMul(M_Ceil *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Ceil_setAdd(M_Ceil *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Ceil_setSub(M_Ceil *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Ceil_setDiv(M_Ceil *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Ceil_setMul(M_Ceil *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Ceil_setAdd(M_Ceil *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Ceil_setSub(M_Ceil *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Ceil_setDiv(M_Ceil *self, PyObject *arg) { SET_DIV };
static PyObject * M_Ceil_play(M_Ceil *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Ceil_out(M_Ceil *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3521,7 +3521,7 @@ static void
M_Round_process(M_Round *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = MYROUND(in[i]);
}
@@ -3542,44 +3542,44 @@ M_Round_setProcMode(M_Round *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = M_Round_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = M_Round_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = M_Round_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = M_Round_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = M_Round_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = M_Round_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = M_Round_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = M_Round_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = M_Round_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = M_Round_postprocessing_revareva;
break;
- }
+ }
}
static void
M_Round_compute_next_data_frame(M_Round *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3592,7 +3592,7 @@ M_Round_traverse(M_Round *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
M_Round_clear(M_Round *self)
{
pyo_CLEAR
@@ -3616,31 +3616,31 @@ M_Round_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
M_Round *self;
self = (M_Round *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, M_Round_compute_next_data_frame);
self->mode_func_ptr = M_Round_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3648,10 +3648,10 @@ M_Round_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * M_Round_getServer(M_Round* self) { GET_SERVER };
static PyObject * M_Round_getStream(M_Round* self) { GET_STREAM };
-static PyObject * M_Round_setMul(M_Round *self, PyObject *arg) { SET_MUL };
-static PyObject * M_Round_setAdd(M_Round *self, PyObject *arg) { SET_ADD };
-static PyObject * M_Round_setSub(M_Round *self, PyObject *arg) { SET_SUB };
-static PyObject * M_Round_setDiv(M_Round *self, PyObject *arg) { SET_DIV };
+static PyObject * M_Round_setMul(M_Round *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Round_setAdd(M_Round *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Round_setSub(M_Round *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Round_setDiv(M_Round *self, PyObject *arg) { SET_DIV };
static PyObject * M_Round_play(M_Round *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * M_Round_out(M_Round *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3771,3 +3771,268 @@ PyTypeObject M_RoundType = {
0, /* tp_alloc */
M_Round_new, /* tp_new */
};
+
+/************/
+/* M_Tanh */
+/************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ int modebuffer[2]; // need at least 2 slots for mul & add
+} M_Tanh;
+
+static void
+M_Tanh_process(M_Tanh *self) {
+ int i;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = MYTANH(in[i]);
+ }
+}
+
+static void M_Tanh_postprocessing_ii(M_Tanh *self) { POST_PROCESSING_II };
+static void M_Tanh_postprocessing_ai(M_Tanh *self) { POST_PROCESSING_AI };
+static void M_Tanh_postprocessing_ia(M_Tanh *self) { POST_PROCESSING_IA };
+static void M_Tanh_postprocessing_aa(M_Tanh *self) { POST_PROCESSING_AA };
+static void M_Tanh_postprocessing_ireva(M_Tanh *self) { POST_PROCESSING_IREVA };
+static void M_Tanh_postprocessing_areva(M_Tanh *self) { POST_PROCESSING_AREVA };
+static void M_Tanh_postprocessing_revai(M_Tanh *self) { POST_PROCESSING_REVAI };
+static void M_Tanh_postprocessing_revaa(M_Tanh *self) { POST_PROCESSING_REVAA };
+static void M_Tanh_postprocessing_revareva(M_Tanh *self) { POST_PROCESSING_REVAREVA };
+
+static void
+M_Tanh_setProcMode(M_Tanh *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ self->proc_func_ptr = M_Tanh_process;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = M_Tanh_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = M_Tanh_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = M_Tanh_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = M_Tanh_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = M_Tanh_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = M_Tanh_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = M_Tanh_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = M_Tanh_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = M_Tanh_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+M_Tanh_compute_next_data_frame(M_Tanh *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+M_Tanh_traverse(M_Tanh *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ return 0;
+}
+
+static int
+M_Tanh_clear(M_Tanh *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ return 0;
+}
+
+static void
+M_Tanh_dealloc(M_Tanh* self)
+{
+ pyo_DEALLOC
+ M_Tanh_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+M_Tanh_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
+ M_Tanh *self;
+ self = (M_Tanh *)type->tp_alloc(type, 0);
+
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, M_Tanh_compute_next_data_frame);
+ self->mode_func_ptr = M_Tanh_setProcMode;
+
+ static char *kwlist[] = {"input", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ INIT_INPUT_STREAM
+
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ }
+
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * M_Tanh_getServer(M_Tanh* self) { GET_SERVER };
+static PyObject * M_Tanh_getStream(M_Tanh* self) { GET_STREAM };
+static PyObject * M_Tanh_setMul(M_Tanh *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Tanh_setAdd(M_Tanh *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Tanh_setSub(M_Tanh *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Tanh_setDiv(M_Tanh *self, PyObject *arg) { SET_DIV };
+
+static PyObject * M_Tanh_play(M_Tanh *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * M_Tanh_out(M_Tanh *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * M_Tanh_stop(M_Tanh *self) { STOP };
+
+static PyObject * M_Tanh_multiply(M_Tanh *self, PyObject *arg) { MULTIPLY };
+static PyObject * M_Tanh_inplace_multiply(M_Tanh *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * M_Tanh_add(M_Tanh *self, PyObject *arg) { ADD };
+static PyObject * M_Tanh_inplace_add(M_Tanh *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * M_Tanh_sub(M_Tanh *self, PyObject *arg) { SUB };
+static PyObject * M_Tanh_inplace_sub(M_Tanh *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * M_Tanh_div(M_Tanh *self, PyObject *arg) { DIV };
+static PyObject * M_Tanh_inplace_div(M_Tanh *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef M_Tanh_members[] = {
+{"server", T_OBJECT_EX, offsetof(M_Tanh, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(M_Tanh, stream), 0, "Stream object."},
+{"input", T_OBJECT_EX, offsetof(M_Tanh, input), 0, "Input sound object."},
+{"mul", T_OBJECT_EX, offsetof(M_Tanh, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(M_Tanh, add), 0, "Add factor."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef M_Tanh_methods[] = {
+{"getServer", (PyCFunction)M_Tanh_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)M_Tanh_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)M_Tanh_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"stop", (PyCFunction)M_Tanh_stop, METH_NOARGS, "Stops computing."},
+{"out", (PyCFunction)M_Tanh_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"setMul", (PyCFunction)M_Tanh_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)M_Tanh_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)M_Tanh_setSub, METH_O, "Sets inverse add factor."},
+{"setDiv", (PyCFunction)M_Tanh_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
+};
+
+static PyNumberMethods M_Tanh_as_number = {
+(binaryfunc)M_Tanh_add, /*nb_add*/
+(binaryfunc)M_Tanh_sub, /*nb_subtract*/
+(binaryfunc)M_Tanh_multiply, /*nb_multiply*/
+(binaryfunc)M_Tanh_div, /*nb_divide*/
+0, /*nb_remainder*/
+0, /*nb_divmod*/
+0, /*nb_power*/
+0, /*nb_neg*/
+0, /*nb_pos*/
+0, /*(unaryfunc)array_abs,*/
+0, /*nb_nonzero*/
+0, /*nb_invert*/
+0, /*nb_lshift*/
+0, /*nb_rshift*/
+0, /*nb_and*/
+0, /*nb_xor*/
+0, /*nb_or*/
+0, /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+0, /*nb_oct*/
+0, /*nb_hex*/
+(binaryfunc)M_Tanh_inplace_add, /*inplace_add*/
+(binaryfunc)M_Tanh_inplace_sub, /*inplace_subtract*/
+(binaryfunc)M_Tanh_inplace_multiply, /*inplace_multiply*/
+(binaryfunc)M_Tanh_inplace_div, /*inplace_divide*/
+0, /*inplace_remainder*/
+0, /*inplace_power*/
+0, /*inplace_lshift*/
+0, /*inplace_rshift*/
+0, /*inplace_and*/
+0, /*inplace_xor*/
+0, /*inplace_or*/
+0, /*nb_floor_divide*/
+0, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+0, /*nb_inplace_true_divide*/
+0, /* nb_index */
+};
+
+PyTypeObject M_TanhType = {
+PyObject_HEAD_INIT(NULL)
+0, /*ob_size*/
+"_pyo.M_Tanh_base", /*tp_name*/
+sizeof(M_Tanh), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)M_Tanh_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_compare*/
+0, /*tp_repr*/
+&M_Tanh_as_number, /*tp_as_number*/
+0, /*tp_as_sequence*/
+0, /*tp_as_mapping*/
+0, /*tp_hash */
+0, /*tp_call*/
+0, /*tp_str*/
+0, /*tp_getattro*/
+0, /*tp_setattro*/
+0, /*tp_as_buffer*/
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+"M_Tanh objects. Performs tanh function on audio samples.", /* tp_doc */
+(traverseproc)M_Tanh_traverse, /* tp_traverse */
+(inquiry)M_Tanh_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+M_Tanh_methods, /* tp_methods */
+M_Tanh_members, /* tp_members */
+0, /* tp_getset */
+0, /* tp_base */
+0, /* tp_dict */
+0, /* tp_descr_get */
+0, /* tp_descr_set */
+0, /* tp_dictoffset */
+0, /* tp_init */
+0, /* tp_alloc */
+M_Tanh_new, /* tp_new */
+};
\ No newline at end of file
diff --git a/src/objects/bandsplitmodule.c b/src/objects/bandsplitmodule.c
index a48e717..304de37 100644
--- a/src/objects/bandsplitmodule.c
+++ b/src/objects/bandsplitmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -57,26 +57,26 @@ typedef struct {
static void
BandSplitter_compute_variables(BandSplitter *self, MYFLT q)
-{
+{
int i;
MYFLT freq;
for (i=0; i<self->bands; i++) {
freq = self->band_freqs[i];
- if (freq <= 1)
+ if (freq <= 1)
freq = 1;
else if (freq >= self->halfSr)
freq = self->halfSr;
-
+
MYFLT w0 = self->TwoPiOnSr * freq;
MYFLT c = MYCOS(w0);
MYFLT alpha = MYSIN(w0) / (2 * q);
-
+
self->b0[i] = alpha;
self->b2[i] = -alpha;
self->a0[i] = 1 + alpha;
self->a1[i] = -2 * c;
self->a2[i] = 1 - alpha;
- }
+ }
}
static void
@@ -84,7 +84,7 @@ BandSplitter_setFrequencies(BandSplitter *self)
{
int i;
MYFLT frac = 1. / self->bands;
- for (i=0; i<self->bands; i++) {
+ for (i=0; i<self->bands; i++) {
self->band_freqs[i] = MYPOW(MYPOW(self->max_freq/self->min_freq, frac), i) * self->min_freq;
}
}
@@ -94,23 +94,23 @@ BandSplitter_filters_i(BandSplitter *self) {
MYFLT val;
int j, i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
for (j=0; j<self->bands; j++) {
self->x1[j] = self->x2[j] = self->y1[j] = self->y2[j] = in[0];
- }
+ }
self->init = 0;
}
-
+
for (j=0; j<self->bands; j++) {
- for (i=0; i<self->bufsize; i++) {
+ for (i=0; i<self->bufsize; i++) {
val = ( (self->b0[j] * in[i]) + (self->b2[j] * self->x2[j]) - (self->a1[j] * self->y1[j]) - (self->a2[j] * self->y2[j]) ) / self->a0[j];
self->y2[j] = self->y1[j];
self->y1[j] = val;
self->x2[j] = self->x1[j];
self->x1[j] = in[i];
self->buffer_streams[i + j * self->bufsize] = val;
- }
+ }
}
}
@@ -119,11 +119,11 @@ BandSplitter_filters_a(BandSplitter *self) {
MYFLT val;
int j, i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
for (j=0; j<self->bands; j++) {
self->x1[j] = self->x2[j] = self->y1[j] = self->y2[j] = in[0];
- }
+ }
self->init = 0;
}
@@ -138,7 +138,7 @@ BandSplitter_filters_a(BandSplitter *self) {
self->x2[j] = self->x1[j];
self->x1[j] = in[i];
self->buffer_streams[i + j * self->bufsize] = val;
- }
+ }
}
}
@@ -146,28 +146,28 @@ MYFLT *
BandSplitter_getSamplesBuffer(BandSplitter *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
BandSplitter_setProcMode(BandSplitter *self)
{
int procmode;
procmode = self->modebuffer[0];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = BandSplitter_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = BandSplitter_filters_a;
break;
- }
+ }
}
static void
BandSplitter_compute_next_data_frame(BandSplitter *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -181,7 +181,7 @@ BandSplitter_traverse(BandSplitter *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
BandSplitter_clear(BandSplitter *self)
{
pyo_CLEAR
@@ -223,23 +223,23 @@ BandSplitter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->bands = 4;
self->q = PyFloat_FromDouble(1.);
self->init = 1;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, BandSplitter_compute_next_data_frame);
self->mode_func_ptr = BandSplitter_setProcMode;
-
+
self->halfSr = self->sr / 2.;
self->TwoPiOnSr = TWOPI / self->sr;
static char *kwlist[] = {"input", "bands", "min", "max", "q", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_IFFO, kwlist, &inputtmp, &self->bands, &self->min_freq, &self->max_freq, &qtmp))
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->band_freqs = (MYFLT *)realloc(self->band_freqs, self->bands * sizeof(MYFLT));
self->x1 = (MYFLT *)realloc(self->x1, self->bands * sizeof(MYFLT));
self->x2 = (MYFLT *)realloc(self->x2, self->bands * sizeof(MYFLT));
@@ -270,14 +270,14 @@ static PyObject *
BandSplitter_setQ(BandSplitter *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -299,7 +299,7 @@ BandSplitter_setQ(BandSplitter *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject * BandSplitter_getServer(BandSplitter* self) { GET_SERVER };
static PyObject * BandSplitter_getStream(BandSplitter* self) { GET_STREAM };
@@ -373,7 +373,7 @@ typedef struct {
pyo_audio_HEAD
BandSplitter *mainSplitter;
int modebuffer[2];
- int chnl;
+ int chnl;
} BandSplit;
static void BandSplit_postprocessing_ii(BandSplit *self) { POST_PROCESSING_II };
@@ -391,33 +391,33 @@ BandSplit_setProcMode(BandSplit *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = BandSplit_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = BandSplit_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = BandSplit_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = BandSplit_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = BandSplit_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = BandSplit_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = BandSplit_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = BandSplit_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = BandSplit_postprocessing_revareva;
break;
}
@@ -432,7 +432,7 @@ BandSplit_compute_next_data_frame(BandSplit *self)
tmp = BandSplitter_getSamplesBuffer((BandSplitter *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -444,11 +444,11 @@ BandSplit_traverse(BandSplit *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
BandSplit_clear(BandSplit *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -467,45 +467,45 @@ BandSplit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
BandSplit *self;
self = (BandSplit *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, BandSplit_compute_next_data_frame);
self->mode_func_ptr = BandSplit_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (BandSplitter *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * BandSplit_getServer(BandSplit* self) { GET_SERVER };
static PyObject * BandSplit_getStream(BandSplit* self) { GET_STREAM };
-static PyObject * BandSplit_setMul(BandSplit *self, PyObject *arg) { SET_MUL };
-static PyObject * BandSplit_setAdd(BandSplit *self, PyObject *arg) { SET_ADD };
-static PyObject * BandSplit_setSub(BandSplit *self, PyObject *arg) { SET_SUB };
-static PyObject * BandSplit_setDiv(BandSplit *self, PyObject *arg) { SET_DIV };
+static PyObject * BandSplit_setMul(BandSplit *self, PyObject *arg) { SET_MUL };
+static PyObject * BandSplit_setAdd(BandSplit *self, PyObject *arg) { SET_ADD };
+static PyObject * BandSplit_setSub(BandSplit *self, PyObject *arg) { SET_SUB };
+static PyObject * BandSplit_setDiv(BandSplit *self, PyObject *arg) { SET_DIV };
static PyObject * BandSplit_play(BandSplit *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * BandSplit_out(BandSplit *self, PyObject *args, PyObject *kwds) { OUT };
@@ -668,7 +668,7 @@ typedef struct {
static void
FourBandMain_compute_variables(FourBandMain *self, double freq, int band)
-{
+{
double wc = TWOPI * freq;
double wc2 = wc * wc;
double wc3 = wc2 * wc;
@@ -683,31 +683,31 @@ FourBandMain_compute_variables(FourBandMain *self, double freq, int band)
double a_tmp = 4.0 * wc2 * k2 + 2.0 * sq_tmp1 + k4 + 2.0 * sq_tmp2 + wc4;
double wc4_a_tmp = wc4 / a_tmp;
double k4_a_tmp = k4 / a_tmp;
-
+
/* common */
self->b1[band] = (4.0 * (wc4 + sq_tmp1 - k4 - sq_tmp2)) / a_tmp;
self->b2[band] = (6.0 * wc4 - 8.0 * wc2 * k2 + 6.0 * k4) / a_tmp;
self->b3[band] = (4.0 * (wc4 - sq_tmp1 + sq_tmp2 - k4)) / a_tmp;
self->b4[band] = (k4 - 2.0 * sq_tmp1 + wc4 - 2.0 * sq_tmp2 + 4.0 * wc2 * k2) / a_tmp;
-
+
/* lowpass */
self->la0[band] = wc4_a_tmp;
self->la1[band] = 4.0 * wc4_a_tmp;
self->la2[band] = 6.0 * wc4_a_tmp;
-
+
/* highpass */
self->ha0[band] = k4_a_tmp;
self->ha1[band] = -4.0 * k4_a_tmp;
- self->ha2[band] = 6.0 * k4_a_tmp;
+ self->ha2[band] = 6.0 * k4_a_tmp;
}
static void
FourBandMain_filters(FourBandMain *self) {
double val, inval, tmp, f1, f2, f3;
int i, j, j1, ind, ind1;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->modebuffer[0] == 0)
f1 = PyFloat_AS_DOUBLE(self->freq1);
else
@@ -720,7 +720,7 @@ FourBandMain_filters(FourBandMain *self) {
f3 = PyFloat_AS_DOUBLE(self->freq3);
else
f3 = (double)Stream_getData((Stream *)self->freq3_stream)[0];
-
+
if (f1 != self->last_freq1) {
self->last_freq1 = f1;
FourBandMain_compute_variables(self, f1, 0);
@@ -735,12 +735,12 @@ FourBandMain_filters(FourBandMain *self) {
self->last_freq3 = f3;
FourBandMain_compute_variables(self, f3, 2);
}
-
-
- for (i=0; i<self->bufsize; i++) {
+
+
+ for (i=0; i<self->bufsize; i++) {
inval = (double)in[i];
/* First band */
- val = self->la0[0] * inval + self->la1[0] * self->x1[0] + self->la2[0] * self->x2[0] + self->la1[0] * self->x3[0] + self->la0[0] * self->x4[0] -
+ val = self->la0[0] * inval + self->la1[0] * self->x1[0] + self->la2[0] * self->x2[0] + self->la1[0] * self->x3[0] + self->la0[0] * self->x4[0] -
self->b1[0] * self->y1[0] - self->b2[0] * self->y2[0] - self->b3[0] * self->y3[0] - self->b4[0] * self->y4[0];
self->y4[0] = self->y3[0];
self->y3[0] = self->y2[0];
@@ -751,13 +751,13 @@ FourBandMain_filters(FourBandMain *self) {
self->x2[0] = self->x1[0];
self->x1[0] = inval;
self->buffer_streams[i] = (MYFLT)val;
-
+
/* Second and third bands */
for (j=0; j<2; j++) {
j1 = j + 1;
ind = j * 2 + 1;
ind1 = ind + 1;
- tmp = self->ha0[j] * inval + self->ha1[j] * self->x1[ind] + self->ha2[j] * self->x2[ind] + self->ha1[j] * self->x3[ind] + self->ha0[j] * self->x4[ind] -
+ tmp = self->ha0[j] * inval + self->ha1[j] * self->x1[ind] + self->ha2[j] * self->x2[ind] + self->ha1[j] * self->x3[ind] + self->ha0[j] * self->x4[ind] -
self->b1[j] * self->y1[ind] - self->b2[j] * self->y2[ind] - self->b3[j] * self->y3[ind] - self->b4[j] * self->y4[ind];
self->y4[ind] = self->y3[ind];
self->y3[ind] = self->y2[ind];
@@ -767,8 +767,8 @@ FourBandMain_filters(FourBandMain *self) {
self->x3[ind] = self->x2[ind];
self->x2[ind] = self->x1[ind];
self->x1[ind] = inval;
-
- val = self->la0[j1] * tmp + self->la1[j1] * self->x1[ind1] + self->la2[j1] * self->x2[ind1] + self->la1[j1] * self->x3[ind1] + self->la0[j1] * self->x4[ind1] -
+
+ val = self->la0[j1] * tmp + self->la1[j1] * self->x1[ind1] + self->la2[j1] * self->x2[ind1] + self->la1[j1] * self->x3[ind1] + self->la0[j1] * self->x4[ind1] -
self->b1[j1] * self->y1[ind1] - self->b2[j1] * self->y2[ind1] - self->b3[j1] * self->y3[ind1] - self->b4[j1] * self->y4[ind1];
self->y4[ind1] = self->y3[ind1];
self->y3[ind1] = self->y2[ind1];
@@ -778,11 +778,11 @@ FourBandMain_filters(FourBandMain *self) {
self->x3[ind1] = self->x2[ind1];
self->x2[ind1] = self->x1[ind1];
self->x1[ind1] = tmp;
-
- self->buffer_streams[i + j1 * self->bufsize] = (MYFLT)val;
+
+ self->buffer_streams[i + j1 * self->bufsize] = (MYFLT)val;
}
- val = self->ha0[2] * inval + self->ha1[2] * self->x1[5] + self->ha2[2] * self->x2[5] + self->ha1[2] * self->x3[5] + self->ha0[2] * self->x4[5] -
+ val = self->ha0[2] * inval + self->ha1[2] * self->x1[5] + self->ha2[2] * self->x2[5] + self->ha1[2] * self->x3[5] + self->ha0[2] * self->x4[5] -
self->b1[2] * self->y1[5] - self->b2[2] * self->y2[5] - self->b3[2] * self->y3[5] - self->b4[2] * self->y4[5];
self->y4[5] = self->y3[5];
self->y3[5] = self->y2[5];
@@ -793,14 +793,14 @@ FourBandMain_filters(FourBandMain *self) {
self->x2[5] = self->x1[5];
self->x1[5] = inval;
self->buffer_streams[i + 3 * self->bufsize] = (MYFLT)val;
- }
+ }
}
MYFLT *
FourBandMain_getSamplesBuffer(FourBandMain *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
FourBandMain_setProcMode(FourBandMain *self)
@@ -811,7 +811,7 @@ FourBandMain_setProcMode(FourBandMain *self)
static void
FourBandMain_compute_next_data_frame(FourBandMain *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -829,7 +829,7 @@ FourBandMain_traverse(FourBandMain *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
FourBandMain_clear(FourBandMain *self)
{
pyo_CLEAR
@@ -860,12 +860,12 @@ FourBandMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freq1tmp=NULL, *freq2tmp=NULL, *freq3tmp=NULL;
FourBandMain *self;
self = (FourBandMain *)type->tp_alloc(type, 0);
-
+
self->freq1 = PyFloat_FromDouble(150);
self->freq2 = PyFloat_FromDouble(500);
self->freq3 = PyFloat_FromDouble(2000);
self->last_freq1 = self->last_freq2 = self->last_freq3 = -1.0;
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
@@ -875,14 +875,14 @@ FourBandMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = FourBandMain_setProcMode;
static char *kwlist[] = {"input", "freq1", "freq2", "freq3", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &freq1tmp, &freq2tmp, &freq3tmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
for (i=0; i<6; i++) {
self->x1[i] = self->x2[i] = self->x3[i] = self->x4[i] = self->y1[i] = self->y2[i] = self->y3[i] = self->y4[i] = 0.0;
}
@@ -892,7 +892,7 @@ FourBandMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<(4 * self->bufsize); i++) {
self->buffer_streams[i] = 0.0;
}
-
+
if (freq1tmp) {
PyObject_CallMethod((PyObject *)self, "setFreq1", "O", freq1tmp);
}
@@ -904,9 +904,9 @@ FourBandMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (freq3tmp) {
PyObject_CallMethod((PyObject *)self, "setFreq3", "O", freq3tmp);
}
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -914,14 +914,14 @@ static PyObject *
FourBandMain_setFreq1(FourBandMain *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq1);
@@ -940,20 +940,20 @@ FourBandMain_setFreq1(FourBandMain *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
FourBandMain_setFreq2(FourBandMain *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq2);
@@ -972,20 +972,20 @@ FourBandMain_setFreq2(FourBandMain *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
FourBandMain_setFreq3(FourBandMain *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq3);
@@ -1004,7 +1004,7 @@ FourBandMain_setFreq3(FourBandMain *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject * FourBandMain_getServer(FourBandMain* self) { GET_SERVER };
static PyObject * FourBandMain_getStream(FourBandMain* self) { GET_STREAM };
@@ -1082,7 +1082,7 @@ typedef struct {
pyo_audio_HEAD
FourBandMain *mainSplitter;
int modebuffer[2];
- int chnl;
+ int chnl;
} FourBand;
static void FourBand_postprocessing_ii(FourBand *self) { POST_PROCESSING_II };
@@ -1100,33 +1100,33 @@ FourBand_setProcMode(FourBand *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = FourBand_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = FourBand_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = FourBand_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = FourBand_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = FourBand_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = FourBand_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = FourBand_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = FourBand_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = FourBand_postprocessing_revareva;
break;
}
@@ -1141,7 +1141,7 @@ FourBand_compute_next_data_frame(FourBand *self)
tmp = FourBandMain_getSamplesBuffer((FourBandMain *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -1153,11 +1153,11 @@ FourBand_traverse(FourBand *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
FourBand_clear(FourBand *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -1176,45 +1176,45 @@ FourBand_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
FourBand *self;
self = (FourBand *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, FourBand_compute_next_data_frame);
self->mode_func_ptr = FourBand_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (FourBandMain *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * FourBand_getServer(FourBand* self) { GET_SERVER };
static PyObject * FourBand_getStream(FourBand* self) { GET_STREAM };
-static PyObject * FourBand_setMul(FourBand *self, PyObject *arg) { SET_MUL };
-static PyObject * FourBand_setAdd(FourBand *self, PyObject *arg) { SET_ADD };
-static PyObject * FourBand_setSub(FourBand *self, PyObject *arg) { SET_SUB };
-static PyObject * FourBand_setDiv(FourBand *self, PyObject *arg) { SET_DIV };
+static PyObject * FourBand_setMul(FourBand *self, PyObject *arg) { SET_MUL };
+static PyObject * FourBand_setAdd(FourBand *self, PyObject *arg) { SET_ADD };
+static PyObject * FourBand_setSub(FourBand *self, PyObject *arg) { SET_SUB };
+static PyObject * FourBand_setDiv(FourBand *self, PyObject *arg) { SET_DIV };
static PyObject * FourBand_play(FourBand *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * FourBand_out(FourBand *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1332,4 +1332,4 @@ PyTypeObject FourBandType = {
0, /* tp_init */
0, /* tp_alloc */
FourBand_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/chorusmodule.c b/src/objects/chorusmodule.c
index c6de4f6..e70e1d4 100644
--- a/src/objects/chorusmodule.c
+++ b/src/objects/chorusmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -66,7 +66,7 @@ static void
Chorus_process_ii(Chorus *self) {
MYFLT lfo, pos, val, fpart, inval;
int i, j, ipart;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT dpth = PyFloat_AS_DOUBLE(self->depth);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
@@ -74,16 +74,16 @@ Chorus_process_ii(Chorus *self) {
if (dpth < 0)
dpth = 0;
else if (dpth > 5)
- dpth = 5;
-
+ dpth = 5;
+
if (feed < 0)
feed = 0;
else if (feed > 1)
feed = 1;
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
-
+
self->total_signal = 0.0;
for (j=0; j<8; j++) {
if (self->pointerPos[j] < 0.0)
@@ -94,7 +94,7 @@ Chorus_process_ii(Chorus *self) {
fpart = self->pointerPos[j] - ipart;
lfo = self->delay_devs[j] * dpth * (LFO_ARRAY[ipart] * (1.0 - fpart) + LFO_ARRAY[ipart+1] * fpart) + self->delays[j];
self->pointerPos[j] += self->inc[j];
-
+
pos = self->in_count[j] - lfo;
if (pos < 0)
pos += self->size[j];
@@ -102,23 +102,23 @@ Chorus_process_ii(Chorus *self) {
fpart = pos - ipart;
val = (self->buffer[j][ipart] * (1.0 - fpart) + self->buffer[j][ipart+1] * fpart);
self->total_signal += val;
-
+
self->buffer[j][self->in_count[j]] = inval + val * feed;
if (self->in_count[j] == 0)
self->buffer[j][self->size[j]] = self->buffer[j][self->in_count[j]];
self->in_count[j]++;
if (self->in_count[j] >= self->size[j])
self->in_count[j] = 0;
- }
+ }
self->data[i] = self->total_signal * 0.25;
- }
+ }
}
static void
Chorus_process_ai(Chorus *self) {
MYFLT lfo, pos, val, fpart, inval, dpth;
int i, j, ipart;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *depth = Stream_getData((Stream *)self->depth_stream);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
@@ -129,7 +129,7 @@ Chorus_process_ai(Chorus *self) {
if (dpth < 0)
dpth = 0;
else if (dpth > 5)
- dpth = 5;
+ dpth = 5;
self->total_signal = 0.0;
for (j=0; j<8; j++) {
@@ -141,7 +141,7 @@ Chorus_process_ai(Chorus *self) {
fpart = self->pointerPos[j] - ipart;
lfo = self->delay_devs[j] * dpth * (LFO_ARRAY[ipart] * (1.0 - fpart) + LFO_ARRAY[ipart+1] * fpart) + self->delays[j];
self->pointerPos[j] += self->inc[j];
-
+
pos = self->in_count[j] - lfo;
if (pos < 0)
pos += self->size[j];
@@ -149,35 +149,35 @@ Chorus_process_ai(Chorus *self) {
fpart = pos - ipart;
val = (self->buffer[j][ipart] * (1.0 - fpart) + self->buffer[j][ipart+1] * fpart);
self->total_signal += val;
-
+
self->buffer[j][self->in_count[j]] = inval + val * feed;
if (self->in_count[j] == 0)
self->buffer[j][self->size[j]] = self->buffer[j][self->in_count[j]];
self->in_count[j]++;
if (self->in_count[j] >= self->size[j])
self->in_count[j] = 0;
- }
+ }
self->data[i] = self->total_signal * 0.25;
- }
+ }
}
static void
Chorus_process_ia(Chorus *self) {
MYFLT lfo, pos, val, fpart, inval, feed;
int i, j, ipart;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT dpth = PyFloat_AS_DOUBLE(self->depth);
MYFLT *feedback = Stream_getData((Stream *)self->feedback_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
feed = feedback[i];
if (feed < 0)
feed = 0;
else if (feed > 1)
- feed = 1;
-
+ feed = 1;
+
self->total_signal = 0.0;
for (j=0; j<8; j++) {
if (self->pointerPos[j] < 0.0)
@@ -188,7 +188,7 @@ Chorus_process_ia(Chorus *self) {
fpart = self->pointerPos[j] - ipart;
lfo = self->delay_devs[j] * dpth * (LFO_ARRAY[ipart] * (1.0 - fpart) + LFO_ARRAY[ipart+1] * fpart) + self->delays[j];
self->pointerPos[j] += self->inc[j];
-
+
pos = self->in_count[j] - lfo;
if (pos < 0)
pos += self->size[j];
@@ -196,27 +196,27 @@ Chorus_process_ia(Chorus *self) {
fpart = pos - ipart;
val = (self->buffer[j][ipart] * (1.0 - fpart) + self->buffer[j][ipart+1] * fpart);
self->total_signal += val;
-
+
self->buffer[j][self->in_count[j]] = inval + val * feed;
if (self->in_count[j] == 0)
self->buffer[j][self->size[j]] = self->buffer[j][self->in_count[j]];
self->in_count[j]++;
if (self->in_count[j] >= self->size[j])
self->in_count[j] = 0;
- }
+ }
self->data[i] = self->total_signal * 0.25;
- }
+ }
}
static void
Chorus_process_aa(Chorus *self) {
MYFLT lfo, pos, val, fpart, inval, dpth, feed;
int i, j, ipart;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *depth = Stream_getData((Stream *)self->depth_stream);
MYFLT *feedback = Stream_getData((Stream *)self->feedback_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
dpth = depth[i];
@@ -224,12 +224,12 @@ Chorus_process_aa(Chorus *self) {
if (dpth < 0)
dpth = 0;
else if (dpth > 5)
- dpth = 5;
+ dpth = 5;
if (feed < 0)
feed = 0;
else if (feed > 1)
- feed = 1;
-
+ feed = 1;
+
self->total_signal = 0.0;
for (j=0; j<8; j++) {
if (self->pointerPos[j] < 0.0)
@@ -240,7 +240,7 @@ Chorus_process_aa(Chorus *self) {
fpart = self->pointerPos[j] - ipart;
lfo = self->delay_devs[j] * dpth * (LFO_ARRAY[ipart] * (1.0 - fpart) + LFO_ARRAY[ipart+1] * fpart) + self->delays[j];
self->pointerPos[j] += self->inc[j];
-
+
pos = self->in_count[j] - lfo;
if (pos < 0)
pos += self->size[j];
@@ -248,31 +248,31 @@ Chorus_process_aa(Chorus *self) {
fpart = pos - ipart;
val = (self->buffer[j][ipart] * (1.0 - fpart) + self->buffer[j][ipart+1] * fpart);
self->total_signal += val;
-
+
self->buffer[j][self->in_count[j]] = inval + val * feed;
if (self->in_count[j] == 0)
self->buffer[j][self->size[j]] = self->buffer[j][self->in_count[j]];
self->in_count[j]++;
if (self->in_count[j] >= self->size[j])
self->in_count[j] = 0;
- }
+ }
self->data[i] = self->total_signal * 0.25;
- }
+ }
}
static void
Chorus_mix_i(Chorus *self) {
int i;
MYFLT val;
-
+
MYFLT mix = PyFloat_AS_DOUBLE(self->mix);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (mix < 0.0)
mix = 0.0;
else if (mix > 1.0)
mix = 1.0;
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i] * (1.0 - mix) + self->data[i] * mix;
self->data[i] = val;
@@ -283,17 +283,17 @@ static void
Chorus_mix_a(Chorus *self) {
int i;
MYFLT mix, val;
-
+
MYFLT *mi = Stream_getData((Stream *)self->mix_stream);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
mix = mi[i];
if (mix < 0.0)
mix = 0.0;
else if (mix > 1.0)
mix = 1.0;
-
+
val = in[i] * (1.0 - mix) + self->data[i] * mix;
self->data[i] = val;
}
@@ -316,66 +316,66 @@ Chorus_setProcMode(Chorus *self)
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
mixmode = self->modebuffer[4];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Chorus_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Chorus_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Chorus_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Chorus_process_aa;
break;
- }
+ }
switch (mixmode) {
- case 0:
+ case 0:
self->mix_func_ptr = Chorus_mix_i;
break;
- case 1:
+ case 1:
self->mix_func_ptr = Chorus_mix_a;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Chorus_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Chorus_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Chorus_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Chorus_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Chorus_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Chorus_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Chorus_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Chorus_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Chorus_postprocessing_revareva;
break;
- }
+ }
}
static void
Chorus_compute_next_data_frame(Chorus *self)
{
- (*self->proc_func_ptr)(self);
- (*self->mix_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
+ (*self->mix_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -384,28 +384,28 @@ Chorus_traverse(Chorus *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->feedback);
- Py_VISIT(self->feedback_stream);
- Py_VISIT(self->depth);
- Py_VISIT(self->depth_stream);
- Py_VISIT(self->mix);
- Py_VISIT(self->mix_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
+ Py_VISIT(self->depth);
+ Py_VISIT(self->depth_stream);
+ Py_VISIT(self->mix);
+ Py_VISIT(self->mix_stream);
return 0;
}
-static int
+static int
Chorus_clear(Chorus *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
- Py_CLEAR(self->depth);
- Py_CLEAR(self->depth_stream);
- Py_CLEAR(self->mix);
- Py_CLEAR(self->mix_stream);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
+ Py_CLEAR(self->depth);
+ Py_CLEAR(self->depth_stream);
+ Py_CLEAR(self->mix);
+ Py_CLEAR(self->mix_stream);
return 0;
}
@@ -416,7 +416,7 @@ Chorus_dealloc(Chorus* self)
pyo_DEALLOC
for (i=0; i<8; i++) {
free(self->buffer[i]);
- }
+ }
Chorus_clear(self);
self->ob_type->tp_free((PyObject*)self);
}
@@ -430,7 +430,7 @@ Chorus_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *depthtmp=NULL, *feedbacktmp=NULL, *mixtmp=NULL, *multmp=NULL, *addtmp=NULL;
Chorus *self;
self = (Chorus *)type->tp_alloc(type, 0);
-
+
self->feedback = PyFloat_FromDouble(0.5);
self->depth = PyFloat_FromDouble(1.0);
self->mix = PyFloat_FromDouble(0.5);
@@ -441,13 +441,13 @@ Chorus_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Chorus_compute_next_data_frame);
self->mode_func_ptr = Chorus_setProcMode;
-
+
srfac = self->sr / 44100.0;
-
+
for (i=0; i<8; i++) {
self->in_count[i] = 0;
self->delays[i] = chorusParams[i][0] * srfac;
@@ -456,16 +456,16 @@ Chorus_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
static char *kwlist[] = {"input", "depth", "feedback", "mix", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOO", kwlist, &inputtmp, &depthtmp, &feedbacktmp, &mixtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (depthtmp) {
PyObject_CallMethod((PyObject *)self, "setDepth", "O", depthtmp);
}
-
+
if (feedbacktmp) {
PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
}
@@ -473,15 +473,15 @@ Chorus_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (mixtmp) {
PyObject_CallMethod((PyObject *)self, "setMix", "O", mixtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
for (i=0; i<8; i++) {
@@ -489,20 +489,20 @@ Chorus_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->buffer[i] = (MYFLT *)realloc(self->buffer[i], (self->size[i]+1) * sizeof(MYFLT));
for (j=0; j<(self->size[i]+1); j++) {
self->buffer[i][j] = 0.;
- }
- }
-
+ }
+ }
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Chorus_getServer(Chorus* self) { GET_SERVER };
static PyObject * Chorus_getStream(Chorus* self) { GET_STREAM };
-static PyObject * Chorus_setMul(Chorus *self, PyObject *arg) { SET_MUL };
-static PyObject * Chorus_setAdd(Chorus *self, PyObject *arg) { SET_ADD };
-static PyObject * Chorus_setSub(Chorus *self, PyObject *arg) { SET_SUB };
-static PyObject * Chorus_setDiv(Chorus *self, PyObject *arg) { SET_DIV };
+static PyObject * Chorus_setMul(Chorus *self, PyObject *arg) { SET_MUL };
+static PyObject * Chorus_setAdd(Chorus *self, PyObject *arg) { SET_ADD };
+static PyObject * Chorus_setSub(Chorus *self, PyObject *arg) { SET_SUB };
+static PyObject * Chorus_setDiv(Chorus *self, PyObject *arg) { SET_DIV };
static PyObject * Chorus_play(Chorus *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Chorus_out(Chorus *self, PyObject *args, PyObject *kwds) { OUT };
@@ -521,14 +521,14 @@ static PyObject *
Chorus_setDepth(Chorus *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->depth);
@@ -544,9 +544,9 @@ Chorus_setDepth(Chorus *self, PyObject *arg)
self->depth_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -555,14 +555,14 @@ static PyObject *
Chorus_setFeedback(Chorus *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->feedback);
@@ -578,25 +578,25 @@ Chorus_setFeedback(Chorus *self, PyObject *arg)
self->feedback_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Chorus_setMix(Chorus *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->mix);
@@ -612,12 +612,12 @@ Chorus_setMix(Chorus *self, PyObject *arg)
self->mix_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Chorus_members[] = {
{"server", T_OBJECT_EX, offsetof(Chorus, server), 0, "Pyo server."},
@@ -729,4 +729,4 @@ Chorus_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
Chorus_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/compressmodule.c b/src/objects/compressmodule.c
index 30233ac..f899ffd 100644
--- a/src/objects/compressmodule.c
+++ b/src/objects/compressmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -39,13 +39,13 @@ typedef struct {
Stream *falltime_stream;
Stream *thresh_stream;
Stream *ratio_stream;
- int modebuffer[6]; // need at least 2 slots for mul & add
+ int modebuffer[6]; // need at least 2 slots for mul & add
int outputAmp;
MYFLT follow;
MYFLT knee;
long lh_delay;
long lh_size;
- long lh_in_count;
+ long lh_in_count;
MYFLT *lh_buffer;
} Compress;
@@ -67,9 +67,9 @@ Compress_compress_soft(Compress *self) {
MYFLT risetime, falltime, thresh, ratio;
int i;
long ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->modebuffer[2] == 0)
risetime = PyFloat_AS_DOUBLE(self->risetime);
else
@@ -91,7 +91,7 @@ Compress_compress_soft(Compress *self) {
else
ratio = Stream_getData((Stream *)self->ratio_stream)[0];
- ratio = 1.0 / ratio;
+ ratio = 1.0 / ratio;
risetime = MYEXP(-1.0 / (self->sr * risetime));
falltime = MYEXP(-1.0 / (self->sr * falltime));
knee = self->knee * 0.999 + 0.001; /* 0 = hard knee, 1 = soft knee */
@@ -104,25 +104,25 @@ Compress_compress_soft(Compress *self) {
for (i=0; i<self->bufsize; i++) {
/* Envelope follower */
- absin = in[i];
+ absin = in[i];
if (absin < 0.0)
absin = -absin;
if (self->follow < absin)
self->follow = absin + risetime * (self->follow - absin);
else
self->follow = absin + falltime * (self->follow - absin);
-
+
/* Look ahead */
ind = self->lh_in_count - self->lh_delay;
if (ind < 0)
ind += self->lh_size;
samp = self->lh_buffer[ind];
-
+
self->lh_buffer[self->lh_in_count] = in[i];
self->lh_in_count++;
if (self->lh_in_count >= self->lh_size)
self->lh_in_count = 0;
-
+
/* Compress signal */
outa = 1.0;
if (self->follow > ampthresh) { /* Above threshold */
@@ -137,7 +137,7 @@ Compress_compress_soft(Compress *self) {
indb = 20.0 * MYLOG10(C_clip(self->follow));
diff = indb - thresh;
outdb = diff - diff * kneeratio;
- outa = MYPOW(10.0, -outdb * 0.05);
+ outa = MYPOW(10.0, -outdb * 0.05);
}
if (self->outputAmp == 0)
self->data[i] = samp * C_clip(outa);
@@ -161,42 +161,42 @@ Compress_setProcMode(Compress *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Compress_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Compress_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Compress_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Compress_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Compress_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Compress_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Compress_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Compress_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Compress_postprocessing_revareva;
break;
- }
+ }
}
static void
Compress_compute_next_data_frame(Compress *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -206,31 +206,31 @@ Compress_traverse(Compress *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->risetime);
- Py_VISIT(self->risetime_stream);
- Py_VISIT(self->falltime);
- Py_VISIT(self->falltime_stream);
- Py_VISIT(self->thresh);
- Py_VISIT(self->thresh_stream);
- Py_VISIT(self->ratio);
- Py_VISIT(self->ratio_stream);
+ Py_VISIT(self->risetime);
+ Py_VISIT(self->risetime_stream);
+ Py_VISIT(self->falltime);
+ Py_VISIT(self->falltime_stream);
+ Py_VISIT(self->thresh);
+ Py_VISIT(self->thresh_stream);
+ Py_VISIT(self->ratio);
+ Py_VISIT(self->ratio_stream);
return 0;
}
-static int
+static int
Compress_clear(Compress *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->risetime);
- Py_CLEAR(self->risetime_stream);
- Py_CLEAR(self->falltime);
- Py_CLEAR(self->falltime_stream);
- Py_CLEAR(self->thresh);
- Py_CLEAR(self->thresh_stream);
- Py_CLEAR(self->ratio);
- Py_CLEAR(self->ratio_stream);
+ Py_CLEAR(self->risetime);
+ Py_CLEAR(self->risetime_stream);
+ Py_CLEAR(self->falltime);
+ Py_CLEAR(self->falltime_stream);
+ Py_CLEAR(self->thresh);
+ Py_CLEAR(self->thresh_stream);
+ Py_CLEAR(self->ratio);
+ Py_CLEAR(self->ratio_stream);
return 0;
}
@@ -251,7 +251,7 @@ Compress_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *looktmp=NULL, *kneetmp=NULL;
Compress *self;
self = (Compress *)type->tp_alloc(type, 0);
-
+
self->thresh = PyFloat_FromDouble(-20.0);
self->ratio = PyFloat_FromDouble(2.0);
self->risetime = PyFloat_FromDouble(0.01);
@@ -274,49 +274,49 @@ Compress_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Compress_setProcMode;
static char *kwlist[] = {"input", "thresh", "ratio", "risetime", "falltime", "lookahead", "knee", "outputAmp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOOOiOO", kwlist, &inputtmp, &threshtmp, &ratiotmp, &risetimetmp, &falltimetmp, &looktmp, &kneetmp, &self->outputAmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (threshtmp) {
PyObject_CallMethod((PyObject *)self, "setThresh", "O", threshtmp);
}
-
+
if (ratiotmp) {
PyObject_CallMethod((PyObject *)self, "setRatio", "O", ratiotmp);
}
-
+
if (risetimetmp) {
PyObject_CallMethod((PyObject *)self, "setRiseTime", "O", risetimetmp);
}
-
+
if (falltimetmp) {
PyObject_CallMethod((PyObject *)self, "setFallTime", "O", falltimetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
PyObject_CallMethod((PyObject *)self, "setLookAhead", "O", looktmp);
PyObject_CallMethod((PyObject *)self, "setKnee", "O", kneetmp);
-
+
self->lh_size = (long)(0.025 * self->sr + 0.5);
self->lh_buffer = (MYFLT *)realloc(self->lh_buffer, (self->lh_size+1) * sizeof(MYFLT));
for (i=0; i<(self->lh_size+1); i++) {
self->lh_buffer[i] = 0.;
- }
+ }
self->proc_func_ptr = Compress_compress_soft;
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -324,10 +324,10 @@ Compress_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Compress_getServer(Compress* self) { GET_SERVER };
static PyObject * Compress_getStream(Compress* self) { GET_STREAM };
-static PyObject * Compress_setMul(Compress *self, PyObject *arg) { SET_MUL };
-static PyObject * Compress_setAdd(Compress *self, PyObject *arg) { SET_ADD };
-static PyObject * Compress_setSub(Compress *self, PyObject *arg) { SET_SUB };
-static PyObject * Compress_setDiv(Compress *self, PyObject *arg) { SET_DIV };
+static PyObject * Compress_setMul(Compress *self, PyObject *arg) { SET_MUL };
+static PyObject * Compress_setAdd(Compress *self, PyObject *arg) { SET_ADD };
+static PyObject * Compress_setSub(Compress *self, PyObject *arg) { SET_SUB };
+static PyObject * Compress_setDiv(Compress *self, PyObject *arg) { SET_DIV };
static PyObject * Compress_play(Compress *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Compress_out(Compress *self, PyObject *args, PyObject *kwds) { OUT };
@@ -346,14 +346,14 @@ static PyObject *
Compress_setThresh(Compress *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->thresh);
@@ -369,23 +369,23 @@ Compress_setThresh(Compress *self, PyObject *arg)
self->thresh_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Compress_setRatio(Compress *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->ratio);
@@ -404,20 +404,20 @@ Compress_setRatio(Compress *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Compress_setRiseTime(Compress *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->risetime);
@@ -436,20 +436,20 @@ Compress_setRiseTime(Compress *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Compress_setFallTime(Compress *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->falltime);
@@ -468,13 +468,13 @@ Compress_setFallTime(Compress *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Compress_setLookAhead(Compress *self, PyObject *arg)
{
MYFLT tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
@@ -490,18 +490,18 @@ Compress_setLookAhead(Compress *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Compress_setKnee(Compress *self, PyObject *arg)
{
MYFLT tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
if (PyNumber_Check(arg)) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
if (tmp >= 0.0 && tmp <= 1.0)
@@ -512,7 +512,7 @@ Compress_setKnee(Compress *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Compress_members[] = {
{"server", T_OBJECT_EX, offsetof(Compress, server), 0, "Pyo server."},
@@ -644,7 +644,7 @@ typedef struct {
Stream *risetime_stream;
PyObject *falltime;
Stream *falltime_stream;
- int modebuffer[5]; // need at least 2 slots for mul & add
+ int modebuffer[5]; // need at least 2 slots for mul & add
int outputAmp;
MYFLT lpfollow;
MYFLT lpfactor;
@@ -655,7 +655,7 @@ typedef struct {
MYFLT fallfactor;
long lh_delay;
long lh_size;
- long lh_in_count;
+ long lh_in_count;
MYFLT *lh_buffer;
} Gate;
@@ -663,9 +663,9 @@ static void
Gate_filters_iii(Gate *self) {
MYFLT samp, absin, thresh, ampthresh, risetime, falltime;
int i, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
thresh = PyFloat_AS_DOUBLE(self->thresh);
risetime = PyFloat_AS_DOUBLE(self->risetime);
if (risetime <= 0.0)
@@ -673,23 +673,23 @@ Gate_filters_iii(Gate *self) {
falltime = PyFloat_AS_DOUBLE(self->falltime);
if (falltime <= 0.0)
falltime = GATE_MIN_RAMP_TIME;
-
+
if (risetime != self->last_risetime) {
self->risefactor = MYEXP(-1.0 / (self->sr * risetime));
self->last_risetime = risetime;
}
-
+
if (falltime != self->last_falltime) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
ampthresh = MYPOW(10.0, thresh * 0.05);
for (i=0; i<self->bufsize; i++) {
/* Follower */
absin = in[i] * in[i];
self->lpfollow = absin + self->lpfactor * (self->lpfollow - absin);
-
+
/* Gate slope */
if (self->lpfollow >= ampthresh)
self->gate = 1.0 + self->risefactor * (self->gate - 1.0);
@@ -701,12 +701,12 @@ Gate_filters_iii(Gate *self) {
if (ind < 0)
ind += self->lh_size;
samp = self->lh_buffer[ind];
-
+
self->lh_buffer[self->lh_in_count] = in[i];
self->lh_in_count++;
if (self->lh_in_count >= self->lh_size)
self->lh_in_count = 0;
-
+
/* Gate the signal */
if (self->outputAmp == 0)
self->data[i] = samp * self->gate;
@@ -719,8 +719,8 @@ static void
Gate_filters_aii(Gate *self) {
MYFLT samp, absin, thresh, ampthresh, risetime, falltime;
int i, ind;
-
- MYFLT *in = Stream_getData((Stream *)self->input_stream);
+
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *tr = Stream_getData((Stream *)self->thresh_stream);
risetime = PyFloat_AS_DOUBLE(self->risetime);
@@ -729,41 +729,41 @@ Gate_filters_aii(Gate *self) {
falltime = PyFloat_AS_DOUBLE(self->falltime);
if (falltime <= 0.0)
falltime = GATE_MIN_RAMP_TIME;
-
+
if (risetime != self->last_risetime) {
self->risefactor = MYEXP(-1.0 / (self->sr * risetime));
self->last_risetime = risetime;
}
-
+
if (falltime != self->last_falltime) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
for (i=0; i<self->bufsize; i++) {
thresh = tr[i];
ampthresh = MYPOW(10.0, thresh * 0.05);
/* Follower */
absin = in[i] * in[i];
self->lpfollow = absin + self->lpfactor * (self->lpfollow - absin);
-
+
/* Gate slope */
if (self->lpfollow >= ampthresh)
self->gate = 1.0 + self->risefactor * (self->gate - 1.0);
else
self->gate = self->fallfactor * self->gate;
-
+
/* Look ahead */
ind = self->lh_in_count - self->lh_delay;
if (ind < 0)
ind += self->lh_size;
samp = self->lh_buffer[ind];
-
+
self->lh_buffer[self->lh_in_count] = in[i];
self->lh_in_count++;
if (self->lh_in_count >= self->lh_size)
self->lh_in_count = 0;
-
+
/* Gate the signal */
if (self->outputAmp == 0)
self->data[i] = samp * self->gate;
@@ -776,7 +776,7 @@ static void
Gate_filters_iai(Gate *self) {
MYFLT samp, absin, thresh, ampthresh, risetime, falltime;
int i, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
thresh = PyFloat_AS_DOUBLE(self->thresh);
@@ -790,7 +790,7 @@ Gate_filters_iai(Gate *self) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
ampthresh = MYPOW(10.0, thresh * 0.05);
for (i=0; i<self->bufsize; i++) {
risetime = rise[i];
@@ -800,28 +800,28 @@ Gate_filters_iai(Gate *self) {
self->risefactor = MYEXP(-1.0 / (self->sr * risetime));
self->last_risetime = risetime;
}
-
+
/* Follower */
absin = in[i] * in[i];
self->lpfollow = absin + self->lpfactor * (self->lpfollow - absin);
-
+
/* Gate slope */
if (self->lpfollow >= ampthresh)
self->gate = 1.0 + self->risefactor * (self->gate - 1.0);
else
self->gate = self->fallfactor * self->gate;
-
+
/* Look ahead */
ind = self->lh_in_count - self->lh_delay;
if (ind < 0)
ind += self->lh_size;
samp = self->lh_buffer[ind];
-
+
self->lh_buffer[self->lh_in_count] = in[i];
self->lh_in_count++;
if (self->lh_in_count >= self->lh_size)
self->lh_in_count = 0;
-
+
/* Gate the signal */
if (self->outputAmp == 0)
self->data[i] = samp * self->gate;
@@ -834,21 +834,21 @@ static void
Gate_filters_aai(Gate *self) {
MYFLT samp, absin, thresh, ampthresh, risetime, falltime;
int i, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT *tr = Stream_getData((Stream *)self->thresh_stream);
MYFLT *rise = Stream_getData((Stream *)self->risetime_stream);
-
+
falltime = PyFloat_AS_DOUBLE(self->falltime);
if (falltime <= 0.0)
falltime = GATE_MIN_RAMP_TIME;
-
+
if (falltime != self->last_falltime) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
for (i=0; i<self->bufsize; i++) {
thresh = tr[i];
ampthresh = MYPOW(10.0, thresh * 0.05);
@@ -859,28 +859,28 @@ Gate_filters_aai(Gate *self) {
self->risefactor = MYEXP(-1.0 / (self->sr * risetime));
self->last_risetime = risetime;
}
-
+
/* Follower */
absin = in[i] * in[i];
self->lpfollow = absin + self->lpfactor * (self->lpfollow - absin);
-
+
/* Gate slope */
if (self->lpfollow >= ampthresh)
self->gate = 1.0 + self->risefactor * (self->gate - 1.0);
else
self->gate = self->fallfactor * self->gate;
-
+
/* Look ahead */
ind = self->lh_in_count - self->lh_delay;
if (ind < 0)
ind += self->lh_size;
samp = self->lh_buffer[ind];
-
+
self->lh_buffer[self->lh_in_count] = in[i];
self->lh_in_count++;
if (self->lh_in_count >= self->lh_size)
self->lh_in_count = 0;
-
+
/* Gate the signal */
if (self->outputAmp == 0)
self->data[i] = samp * self->gate;
@@ -893,15 +893,15 @@ static void
Gate_filters_iia(Gate *self) {
MYFLT samp, absin, thresh, ampthresh, risetime, falltime;
int i, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
thresh = PyFloat_AS_DOUBLE(self->thresh);
risetime = PyFloat_AS_DOUBLE(self->risetime);
if (risetime <= 0.0)
risetime = GATE_MIN_RAMP_TIME;
MYFLT *fall = Stream_getData((Stream *)self->falltime_stream);
-
+
if (risetime != self->last_risetime) {
self->risefactor = MYEXP(-1.0 / (self->sr * risetime));
self->last_risetime = risetime;
@@ -916,28 +916,28 @@ Gate_filters_iia(Gate *self) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
/* Follower */
absin = in[i] * in[i];
self->lpfollow = absin + self->lpfactor * (self->lpfollow - absin);
-
+
/* Gate slope */
if (self->lpfollow >= ampthresh)
self->gate = 1.0 + self->risefactor * (self->gate - 1.0);
else
self->gate = self->fallfactor * self->gate;
-
+
/* Look ahead */
ind = self->lh_in_count - self->lh_delay;
if (ind < 0)
ind += self->lh_size;
samp = self->lh_buffer[ind];
-
+
self->lh_buffer[self->lh_in_count] = in[i];
self->lh_in_count++;
if (self->lh_in_count >= self->lh_size)
self->lh_in_count = 0;
-
+
/* Gate the signal */
if (self->outputAmp == 0)
self->data[i] = samp * self->gate;
@@ -950,20 +950,20 @@ static void
Gate_filters_aia(Gate *self) {
MYFLT samp, absin, thresh, ampthresh, risetime, falltime;
int i, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT *tr = Stream_getData((Stream *)self->thresh_stream);
risetime = PyFloat_AS_DOUBLE(self->risetime);
if (risetime <= 0.0)
risetime = GATE_MIN_RAMP_TIME;
MYFLT *fall = Stream_getData((Stream *)self->falltime_stream);
-
+
if (risetime != self->last_risetime) {
self->risefactor = MYEXP(-1.0 / (self->sr * risetime));
self->last_risetime = risetime;
}
-
+
for (i=0; i<self->bufsize; i++) {
thresh = tr[i];
ampthresh = MYPOW(10.0, thresh * 0.05);
@@ -974,28 +974,28 @@ Gate_filters_aia(Gate *self) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
/* Follower */
absin = in[i] * in[i];
self->lpfollow = absin + self->lpfactor * (self->lpfollow - absin);
-
+
/* Gate slope */
if (self->lpfollow >= ampthresh)
self->gate = 1.0 + self->risefactor * (self->gate - 1.0);
else
self->gate = self->fallfactor * self->gate;
-
+
/* Look ahead */
ind = self->lh_in_count - self->lh_delay;
if (ind < 0)
ind += self->lh_size;
samp = self->lh_buffer[ind];
-
+
self->lh_buffer[self->lh_in_count] = in[i];
self->lh_in_count++;
if (self->lh_in_count >= self->lh_size)
self->lh_in_count = 0;
-
+
/* Gate the signal */
if (self->outputAmp == 0)
self->data[i] = samp * self->gate;
@@ -1008,9 +1008,9 @@ static void
Gate_filters_iaa(Gate *self) {
MYFLT samp, absin, thresh, ampthresh, risetime, falltime;
int i, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
thresh = PyFloat_AS_DOUBLE(self->thresh);
MYFLT *rise = Stream_getData((Stream *)self->risetime_stream);
MYFLT *fall = Stream_getData((Stream *)self->falltime_stream);
@@ -1031,28 +1031,28 @@ Gate_filters_iaa(Gate *self) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
/* Follower */
absin = in[i] * in[i];
self->lpfollow = absin + self->lpfactor * (self->lpfollow - absin);
-
+
/* Gate slope */
if (self->lpfollow >= ampthresh)
self->gate = 1.0 + self->risefactor * (self->gate - 1.0);
else
self->gate = self->fallfactor * self->gate;
-
+
/* Look ahead */
ind = self->lh_in_count - self->lh_delay;
if (ind < 0)
ind += self->lh_size;
samp = self->lh_buffer[ind];
-
+
self->lh_buffer[self->lh_in_count] = in[i];
self->lh_in_count++;
if (self->lh_in_count >= self->lh_size)
self->lh_in_count = 0;
-
+
/* Gate the signal */
if (self->outputAmp == 0)
self->data[i] = samp * self->gate;
@@ -1065,13 +1065,13 @@ static void
Gate_filters_aaa(Gate *self) {
MYFLT samp, absin, thresh, ampthresh, risetime, falltime;
int i, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT *tr = Stream_getData((Stream *)self->thresh_stream);
MYFLT *rise = Stream_getData((Stream *)self->risetime_stream);
MYFLT *fall = Stream_getData((Stream *)self->falltime_stream);
-
+
for (i=0; i<self->bufsize; i++) {
thresh = tr[i];
ampthresh = MYPOW(10.0, thresh * 0.05);
@@ -1089,28 +1089,28 @@ Gate_filters_aaa(Gate *self) {
self->fallfactor = MYEXP(-1.0 / (self->sr * falltime));
self->last_falltime = falltime;
}
-
+
/* Follower */
absin = in[i] * in[i];
self->lpfollow = absin + self->lpfactor * (self->lpfollow - absin);
-
+
/* Gate slope */
if (self->lpfollow >= ampthresh)
self->gate = 1.0 + self->risefactor * (self->gate - 1.0);
else
self->gate = self->fallfactor * self->gate;
-
+
/* Look ahead */
ind = self->lh_in_count - self->lh_delay;
if (ind < 0)
ind += self->lh_size;
samp = self->lh_buffer[ind];
-
+
self->lh_buffer[self->lh_in_count] = in[i];
self->lh_in_count++;
if (self->lh_in_count >= self->lh_size)
self->lh_in_count = 0;
-
+
/* Gate the signal */
if (self->outputAmp == 0)
self->data[i] = samp * self->gate;
@@ -1135,68 +1135,68 @@ Gate_setProcMode(Gate *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Gate_filters_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Gate_filters_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Gate_filters_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Gate_filters_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Gate_filters_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Gate_filters_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Gate_filters_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Gate_filters_aaa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Gate_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Gate_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Gate_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Gate_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Gate_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Gate_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Gate_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Gate_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Gate_postprocessing_revareva;
break;
- }
+ }
}
static void
Gate_compute_next_data_frame(Gate *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1206,27 +1206,27 @@ Gate_traverse(Gate *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->thresh);
- Py_VISIT(self->thresh_stream);
- Py_VISIT(self->risetime);
- Py_VISIT(self->risetime_stream);
- Py_VISIT(self->falltime);
- Py_VISIT(self->falltime_stream);
+ Py_VISIT(self->thresh);
+ Py_VISIT(self->thresh_stream);
+ Py_VISIT(self->risetime);
+ Py_VISIT(self->risetime_stream);
+ Py_VISIT(self->falltime);
+ Py_VISIT(self->falltime_stream);
return 0;
}
-static int
+static int
Gate_clear(Gate *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->thresh);
- Py_CLEAR(self->thresh_stream);
- Py_CLEAR(self->risetime);
- Py_CLEAR(self->risetime_stream);
- Py_CLEAR(self->falltime);
- Py_CLEAR(self->falltime_stream);
+ Py_CLEAR(self->thresh);
+ Py_CLEAR(self->thresh_stream);
+ Py_CLEAR(self->risetime);
+ Py_CLEAR(self->risetime_stream);
+ Py_CLEAR(self->falltime);
+ Py_CLEAR(self->falltime_stream);
return 0;
}
@@ -1247,7 +1247,7 @@ Gate_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *looktmp=NULL;
Gate *self;
self = (Gate *)type->tp_alloc(type, 0);
-
+
self->thresh = PyFloat_FromDouble(-70.0);
self->risetime = PyFloat_FromDouble(0.01);
self->falltime = PyFloat_FromDouble(0.05);
@@ -1263,51 +1263,51 @@ Gate_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->lh_delay = 0;
self->lh_in_count = 0;
self->outputAmp = 0;
-
+
INIT_OBJECT_COMMON
-
+
self->lpfactor = MYEXP(-1.0 / (self->sr / 20.0));
Stream_setFunctionPtr(self->stream, Gate_compute_next_data_frame);
self->mode_func_ptr = Gate_setProcMode;
static char *kwlist[] = {"input", "thresh", "risetime", "falltime", "lookahead", "outputAmp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOiOO", kwlist, &inputtmp, &threshtmp, &risetimetmp, &falltimetmp, &looktmp, &self->outputAmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (threshtmp) {
PyObject_CallMethod((PyObject *)self, "setThresh", "O", threshtmp);
}
-
+
if (risetimetmp) {
PyObject_CallMethod((PyObject *)self, "setRiseTime", "O", risetimetmp);
}
-
+
if (falltimetmp) {
PyObject_CallMethod((PyObject *)self, "setFallTime", "O", falltimetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
PyObject_CallMethod((PyObject *)self, "setLookAhead", "O", looktmp);
-
+
self->lh_size = (long)(0.025 * self->sr + 0.5);
self->lh_buffer = (MYFLT *)realloc(self->lh_buffer, (self->lh_size+1) * sizeof(MYFLT));
for (i=0; i<(self->lh_size+1); i++) {
self->lh_buffer[i] = 0.;
- }
-
+ }
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1315,10 +1315,10 @@ Gate_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Gate_getServer(Gate* self) { GET_SERVER };
static PyObject * Gate_getStream(Gate* self) { GET_STREAM };
-static PyObject * Gate_setMul(Gate *self, PyObject *arg) { SET_MUL };
-static PyObject * Gate_setAdd(Gate *self, PyObject *arg) { SET_ADD };
-static PyObject * Gate_setSub(Gate *self, PyObject *arg) { SET_SUB };
-static PyObject * Gate_setDiv(Gate *self, PyObject *arg) { SET_DIV };
+static PyObject * Gate_setMul(Gate *self, PyObject *arg) { SET_MUL };
+static PyObject * Gate_setAdd(Gate *self, PyObject *arg) { SET_ADD };
+static PyObject * Gate_setSub(Gate *self, PyObject *arg) { SET_SUB };
+static PyObject * Gate_setDiv(Gate *self, PyObject *arg) { SET_DIV };
static PyObject * Gate_play(Gate *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Gate_out(Gate *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1337,14 +1337,14 @@ static PyObject *
Gate_setThresh(Gate *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->thresh);
@@ -1360,9 +1360,9 @@ Gate_setThresh(Gate *self, PyObject *arg)
self->thresh_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1371,14 +1371,14 @@ static PyObject *
Gate_setRiseTime(Gate *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->risetime);
@@ -1394,9 +1394,9 @@ Gate_setRiseTime(Gate *self, PyObject *arg)
self->risetime_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1405,14 +1405,14 @@ static PyObject *
Gate_setFallTime(Gate *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->falltime);
@@ -1428,9 +1428,9 @@ Gate_setFallTime(Gate *self, PyObject *arg)
self->falltime_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1439,12 +1439,12 @@ static PyObject *
Gate_setLookAhead(Gate *self, PyObject *arg)
{
MYFLT tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
if (PyNumber_Check(arg)) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
if (tmp <= 25.0)
@@ -1452,10 +1452,10 @@ Gate_setLookAhead(Gate *self, PyObject *arg)
else
printf("lookahead must be less than 25.0 ms.\n");
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Gate_members[] = {
{"server", T_OBJECT_EX, offsetof(Gate, server), 0, "Pyo server."},
@@ -1581,7 +1581,7 @@ typedef struct {
Stream *input2_stream;
PyObject *freq;
Stream *freq_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
MYFLT follow1;
MYFLT follow2;
MYFLT last_freq;
@@ -1595,13 +1595,13 @@ Balance_filters_i(Balance *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
freq = PyFloat_AS_DOUBLE(self->freq);
-
+
if (freq < 0.1)
freq = 0.1;
-
+
if (freq != self->last_freq) {
self->factor = MYEXP(-1.0 / (self->sr / freq));
- self->last_freq = freq;
+ self->last_freq = freq;
}
for (i=0; i<self->bufsize; i++) {
@@ -1614,7 +1614,7 @@ Balance_filters_i(Balance *self) {
absin = in2[i];
if (absin < 0.0)
absin = -absin;
- self->follow2 = absin + self->factor * (self->follow2 - absin);
+ self->follow2 = absin + self->factor * (self->follow2 - absin);
self->data[i] = in[i] * (self->follow2 / self->follow1);
}
}
@@ -1626,15 +1626,15 @@ Balance_filters_a(Balance *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
if (freq < 0.1)
freq = 0.1;
-
+
if (freq != self->last_freq) {
self->factor = MYEXP(-1.0 / (self->sr / freq));
- self->last_freq = freq;
+ self->last_freq = freq;
}
absin = in[i];
if (absin < 0.0)
@@ -1645,7 +1645,7 @@ Balance_filters_a(Balance *self) {
absin = in2[i];
if (absin < 0.0)
absin = -absin;
- self->follow2 = absin + self->factor * (self->follow2 - absin);
+ self->follow2 = absin + self->factor * (self->follow2 - absin);
self->data[i] = in[i] * (self->follow2 / self->follow1);
}
}
@@ -1666,50 +1666,50 @@ Balance_setProcMode(Balance *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Balance_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Balance_filters_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Balance_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Balance_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Balance_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Balance_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Balance_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Balance_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Balance_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Balance_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Balance_postprocessing_revareva;
break;
- }
+ }
}
static void
Balance_compute_next_data_frame(Balance *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1721,12 +1721,12 @@ Balance_traverse(Balance *self, visitproc visit, void *arg)
Py_VISIT(self->input_stream);
Py_VISIT(self->input2);
Py_VISIT(self->input2_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
Balance_clear(Balance *self)
{
pyo_CLEAR
@@ -1734,8 +1734,8 @@ Balance_clear(Balance *self)
Py_CLEAR(self->input_stream);
Py_CLEAR(self->input2);
Py_CLEAR(self->input2_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -1754,7 +1754,7 @@ Balance_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *input2tmp, *input2_streamtmp, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
Balance *self;
self = (Balance *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(10);
self->follow1 = self->follow2 = 0.0;
self->last_freq = -1.0;
@@ -1762,50 +1762,50 @@ Balance_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Balance_compute_next_data_frame);
self->mode_func_ptr = Balance_setProcMode;
-
+
static char *kwlist[] = {"input", "input2", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOO", kwlist, &inputtmp, &input2tmp, &freqtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
Py_XDECREF(self->input2);
self->input2 = input2tmp;
input2_streamtmp = PyObject_CallMethod((PyObject *)self->input2, "_getStream", NULL);
Py_INCREF(input2_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (Stream *)input2_streamtmp;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Balance_getServer(Balance* self) { GET_SERVER };
static PyObject * Balance_getStream(Balance* self) { GET_STREAM };
-static PyObject * Balance_setMul(Balance *self, PyObject *arg) { SET_MUL };
-static PyObject * Balance_setAdd(Balance *self, PyObject *arg) { SET_ADD };
-static PyObject * Balance_setSub(Balance *self, PyObject *arg) { SET_SUB };
-static PyObject * Balance_setDiv(Balance *self, PyObject *arg) { SET_DIV };
+static PyObject * Balance_setMul(Balance *self, PyObject *arg) { SET_MUL };
+static PyObject * Balance_setAdd(Balance *self, PyObject *arg) { SET_ADD };
+static PyObject * Balance_setSub(Balance *self, PyObject *arg) { SET_SUB };
+static PyObject * Balance_setDiv(Balance *self, PyObject *arg) { SET_DIV };
static PyObject * Balance_play(Balance *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Balance_out(Balance *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1824,14 +1824,14 @@ static PyObject *
Balance_setFreq(Balance *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1847,9 +1847,9 @@ Balance_setFreq(Balance *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1962,4 +1962,3 @@ PyTypeObject BalanceType = {
0, /* tp_alloc */
Balance_new, /* tp_new */
};
-
diff --git a/src/objects/convolvemodule.c b/src/objects/convolvemodule.c
index 63b3fc3..d0f2c8e 100644
--- a/src/objects/convolvemodule.c
+++ b/src/objects/convolvemodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -36,7 +36,7 @@ typedef struct {
PyObject *table;
PyObject *input;
Stream *input_stream;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
MYFLT *input_tmp;
int size;
int count;
@@ -57,7 +57,7 @@ Convolve_filters(Convolve *self) {
tmp_count += self->size;
self->data[i] += self->input_tmp[tmp_count--] * impulse[j];
}
-
+
self->count++;
if (self->count == self->size)
self->count = 0;
@@ -80,44 +80,44 @@ Convolve_setProcMode(Convolve *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Convolve_filters;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Convolve_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Convolve_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Convolve_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Convolve_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Convolve_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Convolve_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Convolve_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Convolve_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Convolve_postprocessing_revareva;
break;
- }
+ }
}
static void
Convolve_compute_next_data_frame(Convolve *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -131,7 +131,7 @@ Convolve_traverse(Convolve *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Convolve_clear(Convolve *self)
{
pyo_CLEAR
@@ -157,42 +157,39 @@ Convolve_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *tabletmp, *multmp=NULL, *addtmp=NULL;
Convolve *self;
self = (Convolve *)type->tp_alloc(type, 0);
-
+
self->count = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Convolve_compute_next_data_frame);
self->mode_func_ptr = Convolve_setProcMode;
static char *kwlist[] = {"input", "table", "size", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOi|OO", kwlist, &inputtmp, &tabletmp, &self->size, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of Convolve must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Convolve must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
self->input_tmp = (MYFLT *)realloc(self->input_tmp, self->size * sizeof(MYFLT));
@@ -205,10 +202,10 @@ Convolve_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Convolve_getServer(Convolve* self) { GET_SERVER };
static PyObject * Convolve_getStream(Convolve* self) { GET_STREAM };
-static PyObject * Convolve_setMul(Convolve *self, PyObject *arg) { SET_MUL };
-static PyObject * Convolve_setAdd(Convolve *self, PyObject *arg) { SET_ADD };
-static PyObject * Convolve_setSub(Convolve *self, PyObject *arg) { SET_SUB };
-static PyObject * Convolve_setDiv(Convolve *self, PyObject *arg) { SET_DIV };
+static PyObject * Convolve_setMul(Convolve *self, PyObject *arg) { SET_MUL };
+static PyObject * Convolve_setAdd(Convolve *self, PyObject *arg) { SET_ADD };
+static PyObject * Convolve_setSub(Convolve *self, PyObject *arg) { SET_SUB };
+static PyObject * Convolve_setDiv(Convolve *self, PyObject *arg) { SET_DIV };
static PyObject * Convolve_play(Convolve *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Convolve_out(Convolve *self, PyObject *args, PyObject *kwds) { OUT };
@@ -234,19 +231,19 @@ static PyObject *
Convolve_setTable(Convolve *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Convolve_members[] = {
{"server", T_OBJECT_EX, offsetof(Convolve, server), 0, "Pyo server."},
@@ -367,7 +364,7 @@ typedef struct {
Stream *freq_stream;
PyObject *bandwidth;
Stream *bandwidth_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
MYFLT *impulse;
MYFLT *impulse_tmp;
MYFLT *input_tmp;
@@ -380,14 +377,14 @@ typedef struct {
MYFLT last_bandwidth;
} IRWinSinc;
-static void
+static void
IRWinSinc_alloc_memory(IRWinSinc *self) {
int i;
if ((self->order % 2) != 0)
self->order += 1;
-
+
self->size = self->order + 1;
-
+
self->input_tmp = (MYFLT *)realloc(self->input_tmp, self->size * sizeof(MYFLT));
self->impulse = (MYFLT *)realloc(self->impulse, self->size * sizeof(MYFLT));
self->impulse_tmp = (MYFLT *)realloc(self->impulse_tmp, self->size * sizeof(MYFLT));
@@ -400,12 +397,12 @@ static void
IRWinSinc_create_impulse(IRWinSinc *self, MYFLT freq, MYFLT bandwidth) {
int i, half, ipart;
MYFLT val, fpart, sum, invSum, env, envPointer, envPointerScaling, sincScaling, w;
-
+
half = self->order / 2;
sum = 0.0;
envPointerScaling = 1.0 / self->size * 512.0;
sincScaling = self->order / 2.0;
-
+
if (freq < 1)
freq = 1.0;
else if (freq > (self->sr*0.5))
@@ -415,12 +412,12 @@ IRWinSinc_create_impulse(IRWinSinc *self, MYFLT freq, MYFLT bandwidth) {
bandwidth = 1.0;
else if (bandwidth > (self->sr*0.5))
bandwidth = self->sr*0.5;
-
+
if (self->filtertype <= 1)
w = TWOPI * freq / self->sr;
else
w = TWOPI * (freq - bandwidth / 2.0) / self->sr;
-
+
/* LOWPASS */
for (i=0; i<half; i++) {
envPointer = i * envPointerScaling;
@@ -441,7 +438,7 @@ IRWinSinc_create_impulse(IRWinSinc *self, MYFLT freq, MYFLT bandwidth) {
for (i=half+1; i<self->size; i++) {
self->impulse[i] = self->impulse[self->order-i];
}
-
+
/* HIGHPASS */
if (self->filtertype == 1) {
for (i=0; i<self->size; i++) {
@@ -449,7 +446,7 @@ IRWinSinc_create_impulse(IRWinSinc *self, MYFLT freq, MYFLT bandwidth) {
}
self->impulse[half] = self->impulse[half] + 1.0;
}
-
+
/* BANDREJECT */
if (self->filtertype >= 2) {
sum = 0.0;
@@ -485,7 +482,7 @@ IRWinSinc_create_impulse(IRWinSinc *self, MYFLT freq, MYFLT bandwidth) {
for (i=0; i<self->size; i++) {
self->impulse[i] = -self->impulse[i];
}
- self->impulse[half] = self->impulse[half] + 1.0;
+ self->impulse[half] = self->impulse[half] + 1.0;
}
}
}
@@ -494,9 +491,9 @@ static void
IRWinSinc_filters(IRWinSinc *self) {
int i,j,tmp_count;
MYFLT freq, bw;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->modebuffer[2] == 0)
freq = PyFloat_AS_DOUBLE(self->freq);
else {
@@ -509,14 +506,14 @@ IRWinSinc_filters(IRWinSinc *self) {
MYFLT *band = Stream_getData((Stream *)self->bandwidth_stream);
bw = band[0];
}
-
+
if (freq != self->last_freq || bw != self->last_bandwidth || self->changed == 1) {
IRWinSinc_create_impulse(self, freq, bw);
self->last_freq = freq;
self->last_bandwidth = bw;
self->changed = 0;
}
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
tmp_count = self->count;
@@ -525,7 +522,7 @@ IRWinSinc_filters(IRWinSinc *self) {
tmp_count += self->size;
self->data[i] += self->input_tmp[tmp_count--] * self->impulse[j];
}
-
+
self->count++;
if (self->count == self->size)
self->count = 0;
@@ -548,44 +545,44 @@ IRWinSinc_setProcMode(IRWinSinc *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = IRWinSinc_filters;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = IRWinSinc_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = IRWinSinc_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = IRWinSinc_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = IRWinSinc_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = IRWinSinc_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = IRWinSinc_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = IRWinSinc_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = IRWinSinc_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = IRWinSinc_postprocessing_revareva;
break;
- }
+ }
}
static void
IRWinSinc_compute_next_data_frame(IRWinSinc *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -595,23 +592,23 @@ IRWinSinc_traverse(IRWinSinc *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->bandwidth);
- Py_VISIT(self->bandwidth_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->bandwidth);
+ Py_VISIT(self->bandwidth_stream);
return 0;
}
-static int
+static int
IRWinSinc_clear(IRWinSinc *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->bandwidth);
- Py_CLEAR(self->bandwidth_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->bandwidth);
+ Py_CLEAR(self->bandwidth_stream);
return 0;
}
@@ -633,7 +630,7 @@ IRWinSinc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *bandwidthtmp=NULL, *multmp=NULL, *addtmp=NULL;
IRWinSinc *self;
self = (IRWinSinc *)type->tp_alloc(type, 0);
-
+
self->last_freq = -1.0;
self->last_bandwidth = -1.0;
self->freq = PyFloat_FromDouble(1000.0);
@@ -646,16 +643,16 @@ IRWinSinc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, IRWinSinc_compute_next_data_frame);
self->mode_func_ptr = IRWinSinc_setProcMode;
static char *kwlist[] = {"input", "freq", "bw", "type", "order", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOiiOO", kwlist, &inputtmp, &freqtmp, &bandwidthtmp, &self->filtertype, &self->order, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (freqtmp) {
@@ -665,19 +662,19 @@ IRWinSinc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (bandwidthtmp) {
PyObject_CallMethod((PyObject *)self, "setBandwidth", "O", bandwidthtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
IRWinSinc_alloc_memory(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -685,10 +682,10 @@ IRWinSinc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * IRWinSinc_getServer(IRWinSinc* self) { GET_SERVER };
static PyObject * IRWinSinc_getStream(IRWinSinc* self) { GET_STREAM };
-static PyObject * IRWinSinc_setMul(IRWinSinc *self, PyObject *arg) { SET_MUL };
-static PyObject * IRWinSinc_setAdd(IRWinSinc *self, PyObject *arg) { SET_ADD };
-static PyObject * IRWinSinc_setSub(IRWinSinc *self, PyObject *arg) { SET_SUB };
-static PyObject * IRWinSinc_setDiv(IRWinSinc *self, PyObject *arg) { SET_DIV };
+static PyObject * IRWinSinc_setMul(IRWinSinc *self, PyObject *arg) { SET_MUL };
+static PyObject * IRWinSinc_setAdd(IRWinSinc *self, PyObject *arg) { SET_ADD };
+static PyObject * IRWinSinc_setSub(IRWinSinc *self, PyObject *arg) { SET_SUB };
+static PyObject * IRWinSinc_setDiv(IRWinSinc *self, PyObject *arg) { SET_DIV };
static PyObject * IRWinSinc_play(IRWinSinc *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * IRWinSinc_out(IRWinSinc *self, PyObject *args, PyObject *kwds) { OUT };
@@ -707,14 +704,14 @@ static PyObject *
IRWinSinc_setFreq(IRWinSinc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -733,20 +730,20 @@ IRWinSinc_setFreq(IRWinSinc *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
IRWinSinc_setBandwidth(IRWinSinc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->bandwidth);
@@ -765,19 +762,19 @@ IRWinSinc_setBandwidth(IRWinSinc *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
IRWinSinc_setType(IRWinSinc *self, PyObject *arg)
{
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->filtertype = PyInt_AsLong(arg);
self->changed = 1;
@@ -785,7 +782,7 @@ IRWinSinc_setType(IRWinSinc *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef IRWinSinc_members[] = {
{"server", T_OBJECT_EX, offsetof(IRWinSinc, server), 0, "Pyo server."},
@@ -905,7 +902,7 @@ typedef struct {
pyo_audio_HEAD
PyObject *input;
Stream *input_stream;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
MYFLT *impulse;
MYFLT *input_tmp;
int count;
@@ -913,15 +910,15 @@ typedef struct {
int size;
} IRAverage;
-static void
+static void
IRAverage_alloc_memory(IRAverage *self) {
int i;
MYFLT val, sum;
if ((self->order % 2) != 0)
self->order += 1;
-
+
self->size = self->order + 1;
-
+
self->input_tmp = (MYFLT *)realloc(self->input_tmp, self->size * sizeof(MYFLT));
self->impulse = (MYFLT *)realloc(self->impulse, self->size * sizeof(MYFLT));
@@ -940,9 +937,9 @@ IRAverage_alloc_memory(IRAverage *self) {
static void
IRAverage_filters(IRAverage *self) {
int i,j,tmp_count;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
tmp_count = self->count;
@@ -951,7 +948,7 @@ IRAverage_filters(IRAverage *self) {
tmp_count += self->size;
self->data[i] += self->input_tmp[tmp_count--] * self->impulse[j];
}
-
+
self->count++;
if (self->count == self->size)
self->count = 0;
@@ -974,44 +971,44 @@ IRAverage_setProcMode(IRAverage *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = IRAverage_filters;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = IRAverage_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = IRAverage_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = IRAverage_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = IRAverage_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = IRAverage_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = IRAverage_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = IRAverage_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = IRAverage_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = IRAverage_postprocessing_revareva;
break;
- }
+ }
}
static void
IRAverage_compute_next_data_frame(IRAverage *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1024,7 +1021,7 @@ IRAverage_traverse(IRAverage *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
IRAverage_clear(IRAverage *self)
{
pyo_CLEAR
@@ -1050,35 +1047,35 @@ IRAverage_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
IRAverage *self;
self = (IRAverage *)type->tp_alloc(type, 0);
-
+
self->order = 32;
self->count = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, IRAverage_compute_next_data_frame);
self->mode_func_ptr = IRAverage_setProcMode;
static char *kwlist[] = {"input", "order", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &inputtmp, &self->order, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
IRAverage_alloc_memory(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1086,10 +1083,10 @@ IRAverage_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * IRAverage_getServer(IRAverage* self) { GET_SERVER };
static PyObject * IRAverage_getStream(IRAverage* self) { GET_STREAM };
-static PyObject * IRAverage_setMul(IRAverage *self, PyObject *arg) { SET_MUL };
-static PyObject * IRAverage_setAdd(IRAverage *self, PyObject *arg) { SET_ADD };
-static PyObject * IRAverage_setSub(IRAverage *self, PyObject *arg) { SET_SUB };
-static PyObject * IRAverage_setDiv(IRAverage *self, PyObject *arg) { SET_DIV };
+static PyObject * IRAverage_setMul(IRAverage *self, PyObject *arg) { SET_MUL };
+static PyObject * IRAverage_setAdd(IRAverage *self, PyObject *arg) { SET_ADD };
+static PyObject * IRAverage_setSub(IRAverage *self, PyObject *arg) { SET_SUB };
+static PyObject * IRAverage_setDiv(IRAverage *self, PyObject *arg) { SET_DIV };
static PyObject * IRAverage_play(IRAverage *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * IRAverage_out(IRAverage *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1221,7 +1218,7 @@ typedef struct {
Stream *freq_stream;
PyObject *bandwidth;
Stream *bandwidth_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
MYFLT *impulse;
MYFLT *input_tmp;
int count;
@@ -1233,14 +1230,14 @@ typedef struct {
MYFLT last_bandwidth;
} IRPulse;
-static void
+static void
IRPulse_alloc_memory(IRPulse *self) {
int i;
if ((self->order % 2) != 0)
self->order += 1;
-
+
self->size = self->order + 1;
-
+
self->input_tmp = (MYFLT *)realloc(self->input_tmp, self->size * sizeof(MYFLT));
self->impulse = (MYFLT *)realloc(self->impulse, self->size * sizeof(MYFLT));
for (i=0; i<self->size; i++) {
@@ -1252,19 +1249,19 @@ static void
IRPulse_create_impulse(IRPulse *self, MYFLT freq, MYFLT bandwidth) {
int i, n, w, bw, dir, gate;
MYFLT val, sum;
-
+
sum = 0.0;
-
+
if (freq < 1)
freq = 1.0;
else if (freq > (self->sr*0.5))
freq = self->sr*0.5;
-
+
if (bandwidth < 1)
bandwidth = 1.0;
else if (bandwidth > (self->sr*0.5))
bandwidth = self->sr*0.5;
-
+
switch (self->filtertype) {
case 0:
/* PULSE */
@@ -1299,11 +1296,11 @@ IRPulse_create_impulse(IRPulse *self, MYFLT freq, MYFLT bandwidth) {
else {
self->impulse[i] = 0.0;
}
-
+
}
for (i=0; i<self->size; i++) {
self->impulse[i] /= sum;
- }
+ }
break;
case 2:
/* PULSEODD */
@@ -1368,9 +1365,9 @@ static void
IRPulse_filters(IRPulse *self) {
int i,j,tmp_count;
MYFLT freq, bw;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->modebuffer[2] == 0)
freq = PyFloat_AS_DOUBLE(self->freq);
else {
@@ -1383,14 +1380,14 @@ IRPulse_filters(IRPulse *self) {
MYFLT *band = Stream_getData((Stream *)self->bandwidth_stream);
bw = band[0];
}
-
+
if (freq != self->last_freq || bw != self->last_bandwidth || self->changed == 1) {
IRPulse_create_impulse(self, freq, bw);
self->last_freq = freq;
self->last_bandwidth = bw;
self->changed = 0;
}
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
tmp_count = self->count;
@@ -1399,7 +1396,7 @@ IRPulse_filters(IRPulse *self) {
tmp_count += self->size;
self->data[i] += self->input_tmp[tmp_count--] * self->impulse[j];
}
-
+
self->count++;
if (self->count == self->size)
self->count = 0;
@@ -1422,44 +1419,44 @@ IRPulse_setProcMode(IRPulse *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = IRPulse_filters;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = IRPulse_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = IRPulse_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = IRPulse_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = IRPulse_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = IRPulse_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = IRPulse_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = IRPulse_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = IRPulse_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = IRPulse_postprocessing_revareva;
break;
- }
+ }
}
static void
IRPulse_compute_next_data_frame(IRPulse *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1469,23 +1466,23 @@ IRPulse_traverse(IRPulse *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->bandwidth);
- Py_VISIT(self->bandwidth_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->bandwidth);
+ Py_VISIT(self->bandwidth_stream);
return 0;
}
-static int
+static int
IRPulse_clear(IRPulse *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->bandwidth);
- Py_CLEAR(self->bandwidth_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->bandwidth);
+ Py_CLEAR(self->bandwidth_stream);
return 0;
}
@@ -1506,7 +1503,7 @@ IRPulse_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *bandwidthtmp=NULL, *multmp=NULL, *addtmp=NULL;
IRPulse *self;
self = (IRPulse *)type->tp_alloc(type, 0);
-
+
self->last_freq = -1.0;
self->last_bandwidth = -1.0;
self->freq = PyFloat_FromDouble(500.0);
@@ -1519,38 +1516,38 @@ IRPulse_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, IRPulse_compute_next_data_frame);
self->mode_func_ptr = IRPulse_setProcMode;
static char *kwlist[] = {"input", "freq", "bw", "type", "order", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOiiOO", kwlist, &inputtmp, &freqtmp, &bandwidthtmp, &self->filtertype, &self->order, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (bandwidthtmp) {
PyObject_CallMethod((PyObject *)self, "setBandwidth", "O", bandwidthtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
IRPulse_alloc_memory(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1558,10 +1555,10 @@ IRPulse_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * IRPulse_getServer(IRPulse* self) { GET_SERVER };
static PyObject * IRPulse_getStream(IRPulse* self) { GET_STREAM };
-static PyObject * IRPulse_setMul(IRPulse *self, PyObject *arg) { SET_MUL };
-static PyObject * IRPulse_setAdd(IRPulse *self, PyObject *arg) { SET_ADD };
-static PyObject * IRPulse_setSub(IRPulse *self, PyObject *arg) { SET_SUB };
-static PyObject * IRPulse_setDiv(IRPulse *self, PyObject *arg) { SET_DIV };
+static PyObject * IRPulse_setMul(IRPulse *self, PyObject *arg) { SET_MUL };
+static PyObject * IRPulse_setAdd(IRPulse *self, PyObject *arg) { SET_ADD };
+static PyObject * IRPulse_setSub(IRPulse *self, PyObject *arg) { SET_SUB };
+static PyObject * IRPulse_setDiv(IRPulse *self, PyObject *arg) { SET_DIV };
static PyObject * IRPulse_play(IRPulse *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * IRPulse_out(IRPulse *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1580,14 +1577,14 @@ static PyObject *
IRPulse_setFreq(IRPulse *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1603,23 +1600,23 @@ IRPulse_setFreq(IRPulse *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
IRPulse_setBandwidth(IRPulse *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->bandwidth);
@@ -1635,30 +1632,30 @@ IRPulse_setBandwidth(IRPulse *self, PyObject *arg)
self->bandwidth_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
IRPulse_setType(IRPulse *self, PyObject *arg)
{
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->filtertype = PyInt_AsLong(arg);
self->changed = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef IRPulse_members[] = {
{"server", T_OBJECT_EX, offsetof(IRPulse, server), 0, "Pyo server."},
@@ -1784,7 +1781,7 @@ typedef struct {
Stream *ratio_stream;
PyObject *index;
Stream *index_stream;
- int modebuffer[5]; // need at least 2 slots for mul & add
+ int modebuffer[5]; // need at least 2 slots for mul & add
MYFLT *impulse;
MYFLT *input_tmp;
int count;
@@ -1795,14 +1792,14 @@ typedef struct {
MYFLT last_index;
} IRFM;
-static void
+static void
IRFM_alloc_memory(IRFM *self) {
int i;
if ((self->order % 2) != 0)
self->order += 1;
-
+
self->size = self->order + 1;
-
+
self->input_tmp = (MYFLT *)realloc(self->input_tmp, self->size * sizeof(MYFLT));
self->impulse = (MYFLT *)realloc(self->impulse, self->size * sizeof(MYFLT));
for (i=0; i<self->size; i++) {
@@ -1819,12 +1816,12 @@ IRFM_create_impulse(IRFM *self, MYFLT carrier, MYFLT ratio, MYFLT index) {
carrier = 1.0;
else if (carrier > (self->sr*0.5))
carrier = self->sr*0.5;
-
+
if (ratio < 0.0001)
ratio = 0.0001;
else if (ratio > (self->sr*0.5))
ratio = self->sr*0.5;
-
+
if (index < 0)
index = 0.0;
@@ -1850,9 +1847,9 @@ static void
IRFM_filters(IRFM *self) {
int i,j,tmp_count;
MYFLT carrier, ratio, index;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->modebuffer[2] == 0)
carrier = PyFloat_AS_DOUBLE(self->carrier);
else {
@@ -1871,14 +1868,14 @@ IRFM_filters(IRFM *self) {
MYFLT *ind = Stream_getData((Stream *)self->index_stream);
index = ind[0];
}
-
+
if (carrier != self->last_carrier || ratio != self->last_ratio || index != self->last_index) {
IRFM_create_impulse(self, carrier, ratio, index);
self->last_carrier = carrier;
self->last_ratio = ratio;
self->last_index = index;
}
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
tmp_count = self->count;
@@ -1887,7 +1884,7 @@ IRFM_filters(IRFM *self) {
tmp_count += self->size;
self->data[i] += self->input_tmp[tmp_count--] * self->impulse[j];
}
-
+
self->count++;
if (self->count == self->size)
self->count = 0;
@@ -1910,44 +1907,44 @@ IRFM_setProcMode(IRFM *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = IRFM_filters;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = IRFM_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = IRFM_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = IRFM_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = IRFM_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = IRFM_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = IRFM_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = IRFM_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = IRFM_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = IRFM_postprocessing_revareva;
break;
- }
+ }
}
static void
IRFM_compute_next_data_frame(IRFM *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1957,27 +1954,27 @@ IRFM_traverse(IRFM *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->carrier);
- Py_VISIT(self->carrier_stream);
- Py_VISIT(self->ratio);
- Py_VISIT(self->ratio_stream);
- Py_VISIT(self->index);
- Py_VISIT(self->index_stream);
+ Py_VISIT(self->carrier);
+ Py_VISIT(self->carrier_stream);
+ Py_VISIT(self->ratio);
+ Py_VISIT(self->ratio_stream);
+ Py_VISIT(self->index);
+ Py_VISIT(self->index_stream);
return 0;
}
-static int
+static int
IRFM_clear(IRFM *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->carrier);
- Py_CLEAR(self->carrier_stream);
- Py_CLEAR(self->ratio);
- Py_CLEAR(self->ratio_stream);
- Py_CLEAR(self->index);
- Py_CLEAR(self->index_stream);
+ Py_CLEAR(self->carrier);
+ Py_CLEAR(self->carrier_stream);
+ Py_CLEAR(self->ratio);
+ Py_CLEAR(self->ratio_stream);
+ Py_CLEAR(self->index);
+ Py_CLEAR(self->index_stream);
return 0;
}
@@ -1998,7 +1995,7 @@ IRFM_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *carriertmp=NULL, *ratiotmp=NULL, *indextmp=NULL, *multmp=NULL, *addtmp=NULL;
IRFM *self;
self = (IRFM *)type->tp_alloc(type, 0);
-
+
self->last_carrier = -1.0;
self->last_ratio = -1.0;
self->last_index = -1.0;
@@ -2012,22 +2009,22 @@ IRFM_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, IRFM_compute_next_data_frame);
self->mode_func_ptr = IRFM_setProcMode;
static char *kwlist[] = {"input", "carrier", "ratio", "index", "order", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOiOO", kwlist, &inputtmp, &carriertmp, &ratiotmp, &indextmp, &self->order, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (carriertmp) {
PyObject_CallMethod((PyObject *)self, "setCarrier", "O", carriertmp);
}
-
+
if (ratiotmp) {
PyObject_CallMethod((PyObject *)self, "setRatio", "O", ratiotmp);
}
@@ -2035,19 +2032,19 @@ IRFM_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (indextmp) {
PyObject_CallMethod((PyObject *)self, "setIndex", "O", indextmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
IRFM_alloc_memory(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -2055,10 +2052,10 @@ IRFM_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * IRFM_getServer(IRFM* self) { GET_SERVER };
static PyObject * IRFM_getStream(IRFM* self) { GET_STREAM };
-static PyObject * IRFM_setMul(IRFM *self, PyObject *arg) { SET_MUL };
-static PyObject * IRFM_setAdd(IRFM *self, PyObject *arg) { SET_ADD };
-static PyObject * IRFM_setSub(IRFM *self, PyObject *arg) { SET_SUB };
-static PyObject * IRFM_setDiv(IRFM *self, PyObject *arg) { SET_DIV };
+static PyObject * IRFM_setMul(IRFM *self, PyObject *arg) { SET_MUL };
+static PyObject * IRFM_setAdd(IRFM *self, PyObject *arg) { SET_ADD };
+static PyObject * IRFM_setSub(IRFM *self, PyObject *arg) { SET_SUB };
+static PyObject * IRFM_setDiv(IRFM *self, PyObject *arg) { SET_DIV };
static PyObject * IRFM_play(IRFM *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * IRFM_out(IRFM *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2077,14 +2074,14 @@ static PyObject *
IRFM_setCarrier(IRFM *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->carrier);
@@ -2100,23 +2097,23 @@ IRFM_setCarrier(IRFM *self, PyObject *arg)
self->carrier_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
IRFM_setRatio(IRFM *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->ratio);
@@ -2132,23 +2129,23 @@ IRFM_setRatio(IRFM *self, PyObject *arg)
self->ratio_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
IRFM_setIndex(IRFM *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->index);
@@ -2164,10 +2161,10 @@ IRFM_setIndex(IRFM *self, PyObject *arg)
self->index_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef IRFM_members[] = {
{"server", T_OBJECT_EX, offsetof(IRFM, server), 0, "Pyo server."},
@@ -2279,4 +2276,4 @@ PyTypeObject IRFMType = {
0, /* tp_init */
0, /* tp_alloc */
IRFM_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/delaymodule.c b/src/objects/delaymodule.c
index 4114833..aad6855 100644
--- a/src/objects/delaymodule.c
+++ b/src/objects/delaymodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -50,7 +50,7 @@ Delay_process_ii(Delay *self) {
MYFLT del = PyFloat_AS_DOUBLE(self->delay);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
-
+
if (del < self->oneOverSr)
del = self->oneOverSr;
else if (del > self->maxdelay)
@@ -61,9 +61,9 @@ Delay_process_ii(Delay *self) {
feed = 0;
else if (feed > 1)
feed = 1;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
xind = self->in_count - sampdel;
if (xind < 0)
@@ -72,7 +72,7 @@ Delay_process_ii(Delay *self) {
frac = xind - ind;
val = self->buffer[ind] * (1.0 - frac) + self->buffer[ind+1] * frac;
self->data[i] = val;
-
+
self->buffer[self->in_count] = in[i] + (val * feed);
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[self->in_count];
@@ -88,16 +88,16 @@ Delay_process_ai(Delay *self) {
int i;
long ind;
- MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
+ MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
if (feed < 0)
feed = 0;
else if (feed > 1)
feed = 1;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
del = delobj[i];
if (del < self->oneOverSr)
@@ -112,7 +112,7 @@ Delay_process_ai(Delay *self) {
frac = xind - ind;
val = self->buffer[ind] * (1.0 - frac) + self->buffer[ind+1] * frac;
self->data[i] = val;
-
+
self->buffer[self->in_count] = in[i] + (val * feed);
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[self->in_count];
@@ -127,18 +127,18 @@ Delay_process_ia(Delay *self) {
MYFLT val, xind, frac, feed;
int i;
long ind;
-
+
MYFLT del = PyFloat_AS_DOUBLE(self->delay);
- MYFLT *fdb = Stream_getData((Stream *)self->feedback_stream);
-
+ MYFLT *fdb = Stream_getData((Stream *)self->feedback_stream);
+
if (del < self->oneOverSr)
del = self->oneOverSr;
else if (del > self->maxdelay)
del = self->maxdelay;
MYFLT sampdel = del * self->sr;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
xind = self->in_count - sampdel;
if (xind < 0)
@@ -153,7 +153,7 @@ Delay_process_ia(Delay *self) {
feed = 0;
else if (feed > 1)
feed = 1;
-
+
self->buffer[self->in_count] = in[i] + (val * feed);
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[self->in_count];
@@ -168,12 +168,12 @@ Delay_process_aa(Delay *self) {
MYFLT val, xind, frac, sampdel, feed, del;
int i;
long ind;
-
- MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
- MYFLT *fdb = Stream_getData((Stream *)self->feedback_stream);
-
+
+ MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
+ MYFLT *fdb = Stream_getData((Stream *)self->feedback_stream);
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
del = delobj[i];
if (del < self->oneOverSr)
@@ -188,13 +188,13 @@ Delay_process_aa(Delay *self) {
frac = xind - ind;
val = self->buffer[ind] * (1.0 - frac) + self->buffer[ind+1] * frac;
self->data[i] = val;
-
+
feed = fdb[i];
if (feed < 0)
feed = 0;
else if (feed > 1)
feed = 1;
-
+
self->buffer[self->in_count] = in[i] + (val * feed);
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[self->in_count];
@@ -222,54 +222,54 @@ Delay_setProcMode(Delay *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Delay_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Delay_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Delay_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Delay_process_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Delay_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Delay_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Delay_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Delay_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Delay_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Delay_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Delay_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Delay_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Delay_postprocessing_revareva;
break;
- }
+ }
}
static void
Delay_compute_next_data_frame(Delay *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -278,24 +278,24 @@ Delay_traverse(Delay *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->delay);
- Py_VISIT(self->delay_stream);
- Py_VISIT(self->feedback);
- Py_VISIT(self->feedback_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->delay);
+ Py_VISIT(self->delay_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
return 0;
}
-static int
+static int
Delay_clear(Delay *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
- Py_CLEAR(self->delay);
- Py_CLEAR(self->delay_stream);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->delay);
+ Py_CLEAR(self->delay_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
return 0;
}
@@ -326,7 +326,7 @@ Delay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
-
+
self->oneOverSr = 1.0 / self->sr;
Stream_setFunctionPtr(self->stream, Delay_compute_next_data_frame);
@@ -346,7 +346,7 @@ Delay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (feedbacktmp) {
PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -354,7 +354,7 @@ Delay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->size = (long)(self->maxdelay * self->sr + 0.5);
@@ -362,19 +362,19 @@ Delay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->buffer = (MYFLT *)realloc(self->buffer, (self->size+1) * sizeof(MYFLT));
for (i=0; i<(self->size+1); i++) {
self->buffer[i] = 0.;
- }
+ }
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Delay_getServer(Delay* self) { GET_SERVER };
static PyObject * Delay_getStream(Delay* self) { GET_STREAM };
-static PyObject * Delay_setMul(Delay *self, PyObject *arg) { SET_MUL };
-static PyObject * Delay_setAdd(Delay *self, PyObject *arg) { SET_ADD };
-static PyObject * Delay_setSub(Delay *self, PyObject *arg) { SET_SUB };
-static PyObject * Delay_setDiv(Delay *self, PyObject *arg) { SET_DIV };
+static PyObject * Delay_setMul(Delay *self, PyObject *arg) { SET_MUL };
+static PyObject * Delay_setAdd(Delay *self, PyObject *arg) { SET_ADD };
+static PyObject * Delay_setSub(Delay *self, PyObject *arg) { SET_SUB };
+static PyObject * Delay_setDiv(Delay *self, PyObject *arg) { SET_DIV };
static PyObject * Delay_play(Delay *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Delay_out(Delay *self, PyObject *args, PyObject *kwds) { OUT };
@@ -393,12 +393,12 @@ static PyObject *
Delay_setDelay(Delay *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
tmp = arg;
@@ -416,25 +416,25 @@ Delay_setDelay(Delay *self, PyObject *arg)
self->delay_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Delay_setFeedback(Delay *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->feedback);
@@ -450,12 +450,12 @@ Delay_setFeedback(Delay *self, PyObject *arg)
self->feedback_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Delay_reset(Delay *self)
@@ -463,7 +463,7 @@ Delay_reset(Delay *self)
int i;
for (i=0; i<(self->size+1); i++) {
self->buffer[i] = 0.;
- }
+ }
Py_INCREF(Py_None);
return Py_None;
}
@@ -594,11 +594,11 @@ typedef struct {
static void
SDelay_process_i(SDelay *self) {
- int i;
+ int i;
long ind;
-
+
MYFLT del = PyFloat_AS_DOUBLE(self->delay);
-
+
if (del < 0.)
del = 0.;
else if (del > self->maxdelay)
@@ -615,13 +615,13 @@ SDelay_process_i(SDelay *self) {
self->in_count = 0;
}
}
- else {
+ else {
for (i=0; i<self->bufsize; i++) {
ind = self->in_count - sampdel;
if (ind < 0)
ind += self->size;
self->data[i] = self->buffer[ind];
-
+
self->buffer[self->in_count] = in[i];
self->in_count++;
if (self->in_count >= self->size)
@@ -633,12 +633,12 @@ SDelay_process_i(SDelay *self) {
static void
SDelay_process_a(SDelay *self) {
MYFLT del;
- int i;
+ int i;
long ind, sampdel;
-
+
MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
del = delobj[i];
if (del < 0.)
@@ -677,50 +677,50 @@ SDelay_setProcMode(SDelay *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = SDelay_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = SDelay_process_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SDelay_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SDelay_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SDelay_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SDelay_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SDelay_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SDelay_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SDelay_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SDelay_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SDelay_postprocessing_revareva;
break;
- }
+ }
}
static void
SDelay_compute_next_data_frame(SDelay *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -729,20 +729,20 @@ SDelay_traverse(SDelay *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->delay);
- Py_VISIT(self->delay_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->delay);
+ Py_VISIT(self->delay_stream);
return 0;
}
-static int
+static int
SDelay_clear(SDelay *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
- Py_CLEAR(self->delay);
- Py_CLEAR(self->delay_stream);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->delay);
+ Py_CLEAR(self->delay_stream);
return 0;
}
@@ -762,46 +762,46 @@ SDelay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *delaytmp=NULL, *multmp=NULL, *addtmp=NULL;
SDelay *self;
self = (SDelay *)type->tp_alloc(type, 0);
-
+
self->delay = PyFloat_FromDouble(0.25);
self->maxdelay = 1;
self->in_count = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SDelay_compute_next_data_frame);
self->mode_func_ptr = SDelay_setProcMode;
static char *kwlist[] = {"input", "delay", "maxdelay", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OFOO, kwlist, &inputtmp, &delaytmp, &self->maxdelay, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (delaytmp) {
PyObject_CallMethod((PyObject *)self, "setDelay", "O", delaytmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->size = (long)(self->maxdelay * self->sr + 0.5);
-
+
self->buffer = (MYFLT *)realloc(self->buffer, (self->size+1) * sizeof(MYFLT));
for (i=0; i<(self->size+1); i++) {
self->buffer[i] = 0.;
- }
-
+ }
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -809,10 +809,10 @@ SDelay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * SDelay_getServer(SDelay* self) { GET_SERVER };
static PyObject * SDelay_getStream(SDelay* self) { GET_STREAM };
-static PyObject * SDelay_setMul(SDelay *self, PyObject *arg) { SET_MUL };
-static PyObject * SDelay_setAdd(SDelay *self, PyObject *arg) { SET_ADD };
-static PyObject * SDelay_setSub(SDelay *self, PyObject *arg) { SET_SUB };
-static PyObject * SDelay_setDiv(SDelay *self, PyObject *arg) { SET_DIV };
+static PyObject * SDelay_setMul(SDelay *self, PyObject *arg) { SET_MUL };
+static PyObject * SDelay_setAdd(SDelay *self, PyObject *arg) { SET_ADD };
+static PyObject * SDelay_setSub(SDelay *self, PyObject *arg) { SET_SUB };
+static PyObject * SDelay_setDiv(SDelay *self, PyObject *arg) { SET_DIV };
static PyObject * SDelay_play(SDelay *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SDelay_out(SDelay *self, PyObject *args, PyObject *kwds) { OUT };
@@ -831,14 +831,14 @@ static PyObject *
SDelay_setDelay(SDelay *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->delay);
@@ -854,12 +854,12 @@ SDelay_setDelay(SDelay *self, PyObject *arg)
self->delay_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SDelay_reset(SDelay *self)
@@ -867,7 +867,7 @@ SDelay_reset(SDelay *self)
int i;
for (i=0; i<(self->size+1); i++) {
self->buffer[i] = 0.;
- }
+ }
Py_INCREF(Py_None);
return Py_None;
}
@@ -1013,9 +1013,9 @@ static void
Waveguide_process_ii(Waveguide *self) {
MYFLT val, x, y, sampdel, frac, feed, tmp;
int i, ind, isamp;
-
+
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
- MYFLT dur = PyFloat_AS_DOUBLE(self->dur);
+ MYFLT dur = PyFloat_AS_DOUBLE(self->dur);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
/* Check boundaries */
@@ -1023,11 +1023,11 @@ Waveguide_process_ii(Waveguide *self) {
fr = self->minfreq;
else if (fr >= self->nyquist)
fr = self->nyquist;
-
+
if (dur <= 0)
dur = 0.1;
-
-
+
+
sampdel = self->lastSampDel;
feed = self->lastFeed;
/* lagrange coeffs and feedback coeff */
@@ -1042,25 +1042,25 @@ Waveguide_process_ii(Waveguide *self) {
self->coeffs[2] = frac*(frac-1)*(frac-3)*(frac-4)/4.0;
self->coeffs[3] = -frac*(frac-1)*(frac-2)*(frac-4)/6.0;
self->coeffs[4] = frac*(frac-1)*(frac-2)*(frac-3)/24.0;
-
+
self->lastDur = dur;
feed = MYPOW(100, -1.0/(fr*dur));
self->lastFeed = feed;
- }
+ }
else if (dur != self->lastDur) {
self->lastDur = dur;
feed = MYPOW(100, -1.0/(fr*dur));
self->lastFeed = feed;
}
-
+
/* pick a new value in th delay line */
- isamp = (int)sampdel;
+ isamp = (int)sampdel;
for (i=0; i<self->bufsize; i++) {
ind = self->in_count - isamp;
if (ind < 0)
ind += self->size;
val = self->buffer[ind];
-
+
/* simple lowpass filtering */
tmp = val;
val = (val + self->lpsamp) * 0.5;
@@ -1080,7 +1080,7 @@ Waveguide_process_ii(Waveguide *self) {
self->yn1 = y;
self->data[i] = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + (x * feed);
if (self->in_count == 0)
@@ -1095,11 +1095,11 @@ static void
Waveguide_process_ai(Waveguide *self) {
MYFLT val, x, y, sampdel, frac, feed, freq, tmp;
int i, ind, isamp;
-
+
MYFLT *fr =Stream_getData((Stream *)self->freq_stream);
- MYFLT dur = PyFloat_AS_DOUBLE(self->dur);
+ MYFLT dur = PyFloat_AS_DOUBLE(self->dur);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
/* Check dur boundary */
if (dur <= 0)
dur = 0.1;
@@ -1126,7 +1126,7 @@ Waveguide_process_ai(Waveguide *self) {
self->coeffs[2] = frac*(frac-1)*(frac-3)*(frac-4)/4.0;
self->coeffs[3] = -frac*(frac-1)*(frac-2)*(frac-4)/6.0;
self->coeffs[4] = frac*(frac-1)*(frac-2)*(frac-3)/24.0;
-
+
self->lastDur = dur;
feed = MYPOW(100, -1.0/(freq*dur));
self->lastFeed = feed;
@@ -1138,18 +1138,18 @@ Waveguide_process_ai(Waveguide *self) {
}
/* pick a new value in th delay line */
- isamp = (int)sampdel;
-
+ isamp = (int)sampdel;
+
ind = self->in_count - isamp;
if (ind < 0)
ind += self->size;
val = self->buffer[ind];
-
+
/* simple lowpass filtering */
tmp = val;
val = (val + self->lpsamp) * 0.5;
self->lpsamp = tmp;
-
+
/* lagrange filtering */
x = (val*self->coeffs[0])+(self->lagrange[0]*self->coeffs[1])+(self->lagrange[1]*self->coeffs[2])+
(self->lagrange[2]*self->coeffs[3])+(self->lagrange[3]*self->coeffs[4]);
@@ -1162,9 +1162,9 @@ Waveguide_process_ai(Waveguide *self) {
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x;
self->yn1 = y;
-
+
self->data[i] = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + (x * feed);
if (self->in_count == 0)
@@ -1180,11 +1180,11 @@ static void
Waveguide_process_ia(Waveguide *self) {
MYFLT val, x, y, sampdel, frac, feed, dur, tmp;
int i, ind, isamp;
-
+
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *du = Stream_getData((Stream *)self->dur_stream);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
/* Check boundaries */
if (fr < self->minfreq)
fr = self->minfreq;
@@ -1205,9 +1205,9 @@ Waveguide_process_ia(Waveguide *self) {
self->coeffs[3] = -frac*(frac-1)*(frac-2)*(frac-4)/6.0;
self->coeffs[4] = frac*(frac-1)*(frac-2)*(frac-3)/24.0;
}
-
+
/* pick a new value in th delay line */
- isamp = (int)sampdel;
+ isamp = (int)sampdel;
for (i=0; i<self->bufsize; i++) {
feed = self->lastFeed;
dur = du[i];
@@ -1222,12 +1222,12 @@ Waveguide_process_ia(Waveguide *self) {
if (ind < 0)
ind += self->size;
val = self->buffer[ind];
-
+
/* simple lowpass filtering */
tmp = val;
val = (val + self->lpsamp) * 0.5;
self->lpsamp = tmp;
-
+
/* lagrange filtering */
x = (val*self->coeffs[0])+(self->lagrange[0]*self->coeffs[1])+(self->lagrange[1]*self->coeffs[2])+
(self->lagrange[2]*self->coeffs[3])+(self->lagrange[3]*self->coeffs[4]);
@@ -1240,9 +1240,9 @@ Waveguide_process_ia(Waveguide *self) {
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x;
self->yn1 = y;
-
+
self->data[i] = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + (x * feed);
if (self->in_count == 0)
@@ -1258,11 +1258,11 @@ static void
Waveguide_process_aa(Waveguide *self) {
MYFLT val, x, y, sampdel, frac, feed, freq, dur, tmp;
int i, ind, isamp;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
- MYFLT *du = Stream_getData((Stream *)self->dur_stream);
+ MYFLT *du = Stream_getData((Stream *)self->dur_stream);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
dur = du[i];
@@ -1274,7 +1274,7 @@ Waveguide_process_aa(Waveguide *self) {
if (dur <= 0)
dur = 0.1;
-
+
sampdel = self->lastSampDel;
feed = self->lastFeed;
/* lagrange coeffs and feedback coeff */
@@ -1289,7 +1289,7 @@ Waveguide_process_aa(Waveguide *self) {
self->coeffs[2] = frac*(frac-1)*(frac-3)*(frac-4)/4.0;
self->coeffs[3] = -frac*(frac-1)*(frac-2)*(frac-4)/6.0;
self->coeffs[4] = frac*(frac-1)*(frac-2)*(frac-3)/24.0;
-
+
self->lastDur = dur;
feed = MYPOW(100, -1.0/(freq*dur));
self->lastFeed = feed;
@@ -1299,20 +1299,20 @@ Waveguide_process_aa(Waveguide *self) {
feed = MYPOW(100, -1.0/(freq*dur));
self->lastFeed = feed;
}
-
+
/* pick a new value in th delay line */
- isamp = (int)sampdel;
-
+ isamp = (int)sampdel;
+
ind = self->in_count - isamp;
if (ind < 0)
ind += self->size;
val = self->buffer[ind];
-
+
/* simple lowpass filtering */
tmp = val;
val = (val + self->lpsamp) * 0.5;
self->lpsamp = tmp;
-
+
/* lagrange filtering */
x = (val*self->coeffs[0])+(self->lagrange[0]*self->coeffs[1])+(self->lagrange[1]*self->coeffs[2])+
(self->lagrange[2]*self->coeffs[3])+(self->lagrange[3]*self->coeffs[4]);
@@ -1320,14 +1320,14 @@ Waveguide_process_aa(Waveguide *self) {
self->lagrange[2] = self->lagrange[1];
self->lagrange[1] = self->lagrange[0];
self->lagrange[0] = val;
-
+
/* DC filtering */
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x;
self->yn1 = y;
-
+
self->data[i] = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + (x * feed);
if (self->in_count == 0)
@@ -1354,56 +1354,56 @@ Waveguide_setProcMode(Waveguide *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Waveguide_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Waveguide_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Waveguide_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Waveguide_process_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Waveguide_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Waveguide_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Waveguide_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Waveguide_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Waveguide_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Waveguide_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Waveguide_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Waveguide_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Waveguide_postprocessing_revareva;
break;
- }
+ }
}
static void
Waveguide_compute_next_data_frame(Waveguide *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1412,24 +1412,24 @@ Waveguide_traverse(Waveguide *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->dur);
- Py_VISIT(self->dur_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->dur);
+ Py_VISIT(self->dur_stream);
return 0;
}
-static int
+static int
Waveguide_clear(Waveguide *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->dur);
- Py_CLEAR(self->dur_stream);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->dur);
+ Py_CLEAR(self->dur_stream);
return 0;
}
@@ -1449,7 +1449,7 @@ Waveguide_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *durtmp=NULL, *multmp=NULL, *addtmp=NULL;
Waveguide *self;
self = (Waveguide *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100);
self->dur = PyFloat_FromDouble(0.99);
self->minfreq = 20;
@@ -1461,64 +1461,64 @@ Waveguide_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->lpsamp = 0.0;
for(i=0; i<4; i++) {
self->lagrange[i] = 0.0;
- }
+ }
self->xn1 = 0.0;
self->yn1 = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
-
+
self->nyquist = (MYFLT)self->sr * 0.45;
Stream_setFunctionPtr(self->stream, Waveguide_compute_next_data_frame);
self->mode_func_ptr = Waveguide_setProcMode;
static char *kwlist[] = {"input", "freq", "dur", "minfreq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OOFOO, kwlist, &inputtmp, &freqtmp, &durtmp, &self->minfreq, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (durtmp) {
PyObject_CallMethod((PyObject *)self, "setDur", "O", durtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->size = (long)(1.0 / self->minfreq * self->sr + 0.5);
-
+
self->buffer = (MYFLT *)realloc(self->buffer, (self->size+1) * sizeof(MYFLT));
for (i=0; i<(self->size+1); i++) {
self->buffer[i] = 0.;
- }
-
+ }
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Waveguide_getServer(Waveguide* self) { GET_SERVER };
static PyObject * Waveguide_getStream(Waveguide* self) { GET_STREAM };
-static PyObject * Waveguide_setMul(Waveguide *self, PyObject *arg) { SET_MUL };
-static PyObject * Waveguide_setAdd(Waveguide *self, PyObject *arg) { SET_ADD };
-static PyObject * Waveguide_setSub(Waveguide *self, PyObject *arg) { SET_SUB };
-static PyObject * Waveguide_setDiv(Waveguide *self, PyObject *arg) { SET_DIV };
+static PyObject * Waveguide_setMul(Waveguide *self, PyObject *arg) { SET_MUL };
+static PyObject * Waveguide_setAdd(Waveguide *self, PyObject *arg) { SET_ADD };
+static PyObject * Waveguide_setSub(Waveguide *self, PyObject *arg) { SET_SUB };
+static PyObject * Waveguide_setDiv(Waveguide *self, PyObject *arg) { SET_DIV };
static PyObject * Waveguide_play(Waveguide *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Waveguide_out(Waveguide *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1537,14 +1537,14 @@ static PyObject *
Waveguide_setFreq(Waveguide *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1560,25 +1560,25 @@ Waveguide_setFreq(Waveguide *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Waveguide_setDur(Waveguide *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->dur);
@@ -1594,12 +1594,12 @@ Waveguide_setDur(Waveguide *self, PyObject *arg)
self->dur_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Waveguide_members[] = {
{"server", T_OBJECT_EX, offsetof(Waveguide, server), 0, "Pyo server."},
@@ -1745,12 +1745,12 @@ AllpassWG_process_iii(AllpassWG *self) {
int i, j;
long ind;
MYFLT val, y, xind, sampdel, frac, freqshift, alpsampdel, alpsampdelin, alpdetune;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
- MYFLT feed = PyFloat_AS_DOUBLE(self->feed);
+ MYFLT feed = PyFloat_AS_DOUBLE(self->feed);
MYFLT detune = PyFloat_AS_DOUBLE(self->detune);
-
+
/* Check boundaries */
if (fr < self->minfreq)
fr = self->minfreq;
@@ -1767,7 +1767,7 @@ AllpassWG_process_iii(AllpassWG *self) {
detune = 0.05;
else if (detune > 1.0)
detune = 1.0;
-
+
sampdel = self->sr / (fr * freqshift);
alpdetune = detune * self->alpsize;
@@ -1779,7 +1779,7 @@ AllpassWG_process_iii(AllpassWG *self) {
ind = (long)xind;
frac = xind - ind;
val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
-
+
/* all-pass filter */
for (j=0; j<3; j++) {
xind = self->alp_in_count[j] - (alpdetune * alp_chorus_factor[j]);
@@ -1798,19 +1798,19 @@ AllpassWG_process_iii(AllpassWG *self) {
if (self->alp_in_count[j] == self->alpsize)
self->alp_in_count[j] = 0;
}
-
+
/* DC filtering and output */
y = val - self->xn1 + 0.995 * self->yn1;
self->xn1 = val;
self->data[i] = self->yn1 = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + val * feed;
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
self->in_count++;
if (self->in_count == self->size)
- self->in_count = 0;
+ self->in_count = 0;
}
}
@@ -1819,12 +1819,12 @@ AllpassWG_process_aii(AllpassWG *self) {
int i, j;
long ind;
MYFLT val, y, xind, sampdel, frac, fr, freqshift, alpsampdel, alpsampdelin, alpdetune;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
- MYFLT feed = PyFloat_AS_DOUBLE(self->feed);
+ MYFLT feed = PyFloat_AS_DOUBLE(self->feed);
MYFLT detune = PyFloat_AS_DOUBLE(self->detune);
-
+
feed *= 0.4525;
if (feed > 0.4525)
feed = 0.4525;
@@ -1836,7 +1836,7 @@ AllpassWG_process_aii(AllpassWG *self) {
detune = 0.05;
else if (detune > 1.0)
detune = 1.0;
-
+
alpdetune = detune * self->alpsize;
for (i=0; i<self->bufsize; i++) {
fr = freq[i];
@@ -1844,7 +1844,7 @@ AllpassWG_process_aii(AllpassWG *self) {
fr = self->minfreq;
else if (fr >= self->nyquist)
fr = self->nyquist;
-
+
/* pick a new value in the delay line */
sampdel = self->sr / (fr * freqshift);
xind = self->in_count - sampdel;
@@ -1853,7 +1853,7 @@ AllpassWG_process_aii(AllpassWG *self) {
ind = (long)xind;
frac = xind - ind;
val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
-
+
/* all-pass filter */
for (j=0; j<3; j++) {
xind = self->alp_in_count[j] - (alpdetune * alp_chorus_factor[j]);
@@ -1872,19 +1872,19 @@ AllpassWG_process_aii(AllpassWG *self) {
if (self->alp_in_count[j] == self->alpsize)
self->alp_in_count[j] = 0;
}
-
+
/* DC filtering and output */
y = val - self->xn1 + 0.995 * self->yn1;
self->xn1 = val;
self->data[i] = self->yn1 = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + val * feed;
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
self->in_count++;
if (self->in_count == self->size)
- self->in_count = 0;
+ self->in_count = 0;
}
}
@@ -1893,12 +1893,12 @@ AllpassWG_process_iai(AllpassWG *self) {
int i, j;
long ind;
MYFLT val, y, xind, sampdel, frac, feed, freqshift, alpsampdel, alpsampdelin, alpdetune;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
- MYFLT *fdb = Stream_getData((Stream *)self->feed_stream);
+ MYFLT *fdb = Stream_getData((Stream *)self->feed_stream);
MYFLT detune = PyFloat_AS_DOUBLE(self->detune);
-
+
/* Check boundaries */
if (fr < self->minfreq)
fr = self->minfreq;
@@ -1910,10 +1910,10 @@ AllpassWG_process_iai(AllpassWG *self) {
detune = 0.05;
else if (detune > 1.0)
detune = 1.0;
-
+
sampdel = self->sr / (fr * freqshift);
alpdetune = detune * self->alpsize;
-
+
for (i=0; i<self->bufsize; i++) {
feed = fdb[i] * 0.4525;
if (feed > 0.4525)
@@ -1927,7 +1927,7 @@ AllpassWG_process_iai(AllpassWG *self) {
ind = (long)xind;
frac = xind - ind;
val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
-
+
/* all-pass filter */
for (j=0; j<3; j++) {
xind = self->alp_in_count[j] - (alpdetune * alp_chorus_factor[j]);
@@ -1946,19 +1946,19 @@ AllpassWG_process_iai(AllpassWG *self) {
if (self->alp_in_count[j] == self->alpsize)
self->alp_in_count[j] = 0;
}
-
+
/* DC filtering and output */
y = val - self->xn1 + 0.995 * self->yn1;
self->xn1 = val;
self->data[i] = self->yn1 = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + val * feed;
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
self->in_count++;
if (self->in_count == self->size)
- self->in_count = 0;
+ self->in_count = 0;
}
}
@@ -1967,19 +1967,19 @@ AllpassWG_process_aai(AllpassWG *self) {
int i, j;
long ind;
MYFLT val, y, xind, sampdel, frac, fr, feed, freqshift, alpsampdel, alpsampdelin, alpdetune;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
- MYFLT *fdb = Stream_getData((Stream *)self->feed_stream);
+ MYFLT *fdb = Stream_getData((Stream *)self->feed_stream);
MYFLT detune = PyFloat_AS_DOUBLE(self->detune);
-
+
freqshift = detune * 0.5 + 1.;
detune = detune * 0.95 + 0.05;
if (detune < 0.05)
detune = 0.05;
else if (detune > 1.0)
detune = 1.0;
-
+
alpdetune = detune * self->alpsize;
for (i=0; i<self->bufsize; i++) {
fr = freq[i];
@@ -1992,7 +1992,7 @@ AllpassWG_process_aai(AllpassWG *self) {
feed = 0.4525;
else if (feed < 0)
feed = 0;
-
+
/* pick a new value in the delay line */
sampdel = self->sr / (fr * freqshift);
xind = self->in_count - sampdel;
@@ -2001,7 +2001,7 @@ AllpassWG_process_aai(AllpassWG *self) {
ind = (long)xind;
frac = xind - ind;
val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
-
+
/* all-pass filter */
for (j=0; j<3; j++) {
xind = self->alp_in_count[j] - (alpdetune * alp_chorus_factor[j]);
@@ -2020,19 +2020,19 @@ AllpassWG_process_aai(AllpassWG *self) {
if (self->alp_in_count[j] == self->alpsize)
self->alp_in_count[j] = 0;
}
-
+
/* DC filtering and output */
y = val - self->xn1 + 0.995 * self->yn1;
self->xn1 = val;
self->data[i] = self->yn1 = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + val * feed;
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
self->in_count++;
if (self->in_count == self->size)
- self->in_count = 0;
+ self->in_count = 0;
}
}
@@ -2041,12 +2041,12 @@ AllpassWG_process_iia(AllpassWG *self) {
int i, j;
long ind;
MYFLT val, y, xind, sampdel, frac, detune, freqshift, alpsampdel, alpsampdelin, alpdetune;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
- MYFLT feed = PyFloat_AS_DOUBLE(self->feed);
+ MYFLT feed = PyFloat_AS_DOUBLE(self->feed);
MYFLT *det = Stream_getData((Stream *)self->detune_stream);
-
+
/* Check boundaries */
if (fr < self->minfreq)
fr = self->minfreq;
@@ -2057,7 +2057,7 @@ AllpassWG_process_iia(AllpassWG *self) {
feed = 0.4525;
else if (feed < 0)
feed = 0;
-
+
for (i=0; i<self->bufsize; i++) {
detune = det[i];
freqshift = detune * 0.5 + 1.;
@@ -2066,7 +2066,7 @@ AllpassWG_process_iia(AllpassWG *self) {
detune = 0.05;
else if (detune > 1.0)
detune = 1.0;
-
+
/* pick a new value in the delay line */
sampdel = self->sr / (fr * freqshift);
xind = self->in_count - sampdel;
@@ -2075,7 +2075,7 @@ AllpassWG_process_iia(AllpassWG *self) {
ind = (long)xind;
frac = xind - ind;
val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
-
+
/* all-pass filter */
alpdetune = detune * self->alpsize;
for (j=0; j<3; j++) {
@@ -2107,7 +2107,7 @@ AllpassWG_process_iia(AllpassWG *self) {
self->buffer[self->size] = self->buffer[0];
self->in_count++;
if (self->in_count == self->size)
- self->in_count = 0;
+ self->in_count = 0;
}
}
@@ -2116,18 +2116,18 @@ AllpassWG_process_aia(AllpassWG *self) {
int i, j;
long ind;
MYFLT val, y, xind, sampdel, frac, fr, detune, freqshift, alpsampdel, alpsampdelin, alpdetune;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
- MYFLT feed = PyFloat_AS_DOUBLE(self->feed);
+ MYFLT feed = PyFloat_AS_DOUBLE(self->feed);
MYFLT *det = Stream_getData((Stream *)self->detune_stream);
-
+
feed *= 0.4525;
if (feed > 0.4525)
feed = 0.4525;
else if (feed < 0)
feed = 0;
-
+
for (i=0; i<self->bufsize; i++) {
fr = freq[i];
if (fr < self->minfreq)
@@ -2141,7 +2141,7 @@ AllpassWG_process_aia(AllpassWG *self) {
detune = 0.05;
else if (detune > 1.0)
detune = 1.0;
-
+
/* pick a new value in the delay line */
sampdel = self->sr / (fr * freqshift);
xind = self->in_count - sampdel;
@@ -2150,7 +2150,7 @@ AllpassWG_process_aia(AllpassWG *self) {
ind = (long)xind;
frac = xind - ind;
val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
-
+
/* all-pass filter */
alpdetune = detune * self->alpsize;
for (j=0; j<3; j++) {
@@ -2170,19 +2170,19 @@ AllpassWG_process_aia(AllpassWG *self) {
if (self->alp_in_count[j] == self->alpsize)
self->alp_in_count[j] = 0;
}
-
+
/* DC filtering and output */
y = val - self->xn1 + 0.995 * self->yn1;
self->xn1 = val;
self->data[i] = self->yn1 = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + val * feed;
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
self->in_count++;
if (self->in_count == self->size)
- self->in_count = 0;
+ self->in_count = 0;
}
}
@@ -2191,18 +2191,18 @@ AllpassWG_process_iaa(AllpassWG *self) {
int i, j;
long ind;
MYFLT val, y, xind, sampdel, frac, feed, detune, freqshift, alpsampdel, alpsampdelin, alpdetune;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
- MYFLT *fdb = Stream_getData((Stream *)self->feed_stream);
+ MYFLT *fdb = Stream_getData((Stream *)self->feed_stream);
MYFLT *det = Stream_getData((Stream *)self->detune_stream);
-
+
/* Check boundaries */
if (fr < self->minfreq)
fr = self->minfreq;
else if (fr >= self->nyquist)
fr = self->nyquist;
-
+
for (i=0; i<self->bufsize; i++) {
feed = fdb[i] * 0.4525;
if (feed > 0.4525)
@@ -2216,7 +2216,7 @@ AllpassWG_process_iaa(AllpassWG *self) {
detune = 0.05;
else if (detune > 1.0)
detune = 1.0;
-
+
/* pick a new value in the delay line */
sampdel = self->sr / (fr * freqshift);
xind = self->in_count - sampdel;
@@ -2225,7 +2225,7 @@ AllpassWG_process_iaa(AllpassWG *self) {
ind = (long)xind;
frac = xind - ind;
val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
-
+
/* all-pass filter */
alpdetune = detune * self->alpsize;
for (j=0; j<3; j++) {
@@ -2245,19 +2245,19 @@ AllpassWG_process_iaa(AllpassWG *self) {
if (self->alp_in_count[j] == self->alpsize)
self->alp_in_count[j] = 0;
}
-
+
/* DC filtering and output */
y = val - self->xn1 + 0.995 * self->yn1;
self->xn1 = val;
self->data[i] = self->yn1 = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + val * feed;
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
self->in_count++;
if (self->in_count == self->size)
- self->in_count = 0;
+ self->in_count = 0;
}
}
@@ -2266,10 +2266,10 @@ AllpassWG_process_aaa(AllpassWG *self) {
int i, j;
long ind;
MYFLT val, y, xind, sampdel, frac, fr, feed, detune, freqshift, alpsampdel, alpsampdelin, alpdetune;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
- MYFLT *fdb = Stream_getData((Stream *)self->feed_stream);
+ MYFLT *fdb = Stream_getData((Stream *)self->feed_stream);
MYFLT *det = Stream_getData((Stream *)self->detune_stream);
for (i=0; i<self->bufsize; i++) {
@@ -2290,7 +2290,7 @@ AllpassWG_process_aaa(AllpassWG *self) {
detune = 0.05;
else if (detune > 1.0)
detune = 1.0;
-
+
/* pick a new value in the delay line */
sampdel = self->sr / (fr * freqshift);
xind = self->in_count - sampdel;
@@ -2299,7 +2299,7 @@ AllpassWG_process_aaa(AllpassWG *self) {
ind = (long)xind;
frac = xind - ind;
val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
-
+
/* all-pass filter */
alpdetune = detune * self->alpsize;
for (j=0; j<3; j++) {
@@ -2319,19 +2319,19 @@ AllpassWG_process_aaa(AllpassWG *self) {
if (self->alp_in_count[j] == self->alpsize)
self->alp_in_count[j] = 0;
}
-
+
/* DC filtering and output */
y = val - self->xn1 + 0.995 * self->yn1;
self->xn1 = val;
self->data[i] = self->yn1 = y;
-
+
/* write current value in the delay line */
self->buffer[self->in_count] = in[i] + val * feed;
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
self->in_count++;
if (self->in_count == self->size)
- self->in_count = 0;
+ self->in_count = 0;
}
}
@@ -2351,68 +2351,68 @@ AllpassWG_setProcMode(AllpassWG *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = AllpassWG_process_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = AllpassWG_process_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = AllpassWG_process_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = AllpassWG_process_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = AllpassWG_process_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = AllpassWG_process_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = AllpassWG_process_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = AllpassWG_process_aaa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = AllpassWG_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = AllpassWG_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = AllpassWG_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = AllpassWG_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = AllpassWG_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = AllpassWG_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = AllpassWG_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = AllpassWG_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = AllpassWG_postprocessing_revareva;
break;
- }
+ }
}
static void
AllpassWG_compute_next_data_frame(AllpassWG *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2421,28 +2421,28 @@ AllpassWG_traverse(AllpassWG *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->feed);
- Py_VISIT(self->feed_stream);
- Py_VISIT(self->detune);
- Py_VISIT(self->detune_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->feed);
+ Py_VISIT(self->feed_stream);
+ Py_VISIT(self->detune);
+ Py_VISIT(self->detune_stream);
return 0;
}
-static int
+static int
AllpassWG_clear(AllpassWG *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->feed);
- Py_CLEAR(self->feed_stream);
- Py_CLEAR(self->detune);
- Py_CLEAR(self->detune_stream);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->feed);
+ Py_CLEAR(self->feed_stream);
+ Py_CLEAR(self->detune);
+ Py_CLEAR(self->detune_stream);
return 0;
}
@@ -2466,7 +2466,7 @@ AllpassWG_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *feedtmp=NULL, *detunetmp=NULL, *multmp=NULL, *addtmp=NULL;
AllpassWG *self;
self = (AllpassWG *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100);
self->feed = PyFloat_FromDouble(0.);
self->detune = PyFloat_FromDouble(0.5);
@@ -2479,47 +2479,47 @@ AllpassWG_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
-
+
self->nyquist = (MYFLT)self->sr * 0.45;
Stream_setFunctionPtr(self->stream, AllpassWG_compute_next_data_frame);
self->mode_func_ptr = AllpassWG_setProcMode;
static char *kwlist[] = {"input", "freq", "feed", "detune", "minfreq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OOOFOO, kwlist, &inputtmp, &freqtmp, &feedtmp, &detunetmp, &self->minfreq, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (feedtmp) {
PyObject_CallMethod((PyObject *)self, "setFeed", "O", feedtmp);
}
if (detunetmp) {
PyObject_CallMethod((PyObject *)self, "setDetune", "O", detunetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
- self->size = (long)(1.0 / self->minfreq * self->sr + 0.5);
+
+ self->size = (long)(1.0 / self->minfreq * self->sr + 0.5);
self->buffer = (MYFLT *)realloc(self->buffer, (self->size+1) * sizeof(MYFLT));
for (i=0; i<(self->size+1); i++) {
self->buffer[i] = 0.;
- }
+ }
self->alpsize = (int)(self->sr * 0.0025);
for (i=0; i<3; i++) {
@@ -2527,19 +2527,19 @@ AllpassWG_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (j=0; j<(self->alpsize+1); j++) {
self->alpbuffer[i][j] = 0.;
}
- }
-
+ }
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * AllpassWG_getServer(AllpassWG* self) { GET_SERVER };
static PyObject * AllpassWG_getStream(AllpassWG* self) { GET_STREAM };
-static PyObject * AllpassWG_setMul(AllpassWG *self, PyObject *arg) { SET_MUL };
-static PyObject * AllpassWG_setAdd(AllpassWG *self, PyObject *arg) { SET_ADD };
-static PyObject * AllpassWG_setSub(AllpassWG *self, PyObject *arg) { SET_SUB };
-static PyObject * AllpassWG_setDiv(AllpassWG *self, PyObject *arg) { SET_DIV };
+static PyObject * AllpassWG_setMul(AllpassWG *self, PyObject *arg) { SET_MUL };
+static PyObject * AllpassWG_setAdd(AllpassWG *self, PyObject *arg) { SET_ADD };
+static PyObject * AllpassWG_setSub(AllpassWG *self, PyObject *arg) { SET_SUB };
+static PyObject * AllpassWG_setDiv(AllpassWG *self, PyObject *arg) { SET_DIV };
static PyObject * AllpassWG_play(AllpassWG *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * AllpassWG_out(AllpassWG *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2558,14 +2558,14 @@ static PyObject *
AllpassWG_setFreq(AllpassWG *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -2581,25 +2581,25 @@ AllpassWG_setFreq(AllpassWG *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
AllpassWG_setFeed(AllpassWG *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->feed);
@@ -2615,25 +2615,25 @@ AllpassWG_setFeed(AllpassWG *self, PyObject *arg)
self->feed_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
AllpassWG_setDetune(AllpassWG *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->detune);
@@ -2649,12 +2649,12 @@ AllpassWG_setDetune(AllpassWG *self, PyObject *arg)
self->detune_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef AllpassWG_members[] = {
{"server", T_OBJECT_EX, offsetof(AllpassWG, server), 0, "Pyo server."},
@@ -2775,7 +2775,7 @@ typedef struct {
pyo_audio_HEAD
PyObject *input;
Stream *input_stream;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
MYFLT x1;
} Delay1;
@@ -2805,44 +2805,44 @@ Delay1_setProcMode(Delay1 *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Delay1_filters;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Delay1_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Delay1_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Delay1_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Delay1_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Delay1_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Delay1_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Delay1_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Delay1_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Delay1_postprocessing_revareva;
break;
- }
+ }
}
static void
Delay1_compute_next_data_frame(Delay1 *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2855,7 +2855,7 @@ Delay1_traverse(Delay1 *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Delay1_clear(Delay1 *self)
{
pyo_CLEAR
@@ -2879,32 +2879,32 @@ Delay1_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
Delay1 *self;
self = (Delay1 *)type->tp_alloc(type, 0);
-
+
self->x1 = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Delay1_compute_next_data_frame);
self->mode_func_ptr = Delay1_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -2912,10 +2912,10 @@ Delay1_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Delay1_getServer(Delay1* self) { GET_SERVER };
static PyObject * Delay1_getStream(Delay1* self) { GET_STREAM };
-static PyObject * Delay1_setMul(Delay1 *self, PyObject *arg) { SET_MUL };
-static PyObject * Delay1_setAdd(Delay1 *self, PyObject *arg) { SET_ADD };
-static PyObject * Delay1_setSub(Delay1 *self, PyObject *arg) { SET_SUB };
-static PyObject * Delay1_setDiv(Delay1 *self, PyObject *arg) { SET_DIV };
+static PyObject * Delay1_setMul(Delay1 *self, PyObject *arg) { SET_MUL };
+static PyObject * Delay1_setAdd(Delay1 *self, PyObject *arg) { SET_ADD };
+static PyObject * Delay1_setSub(Delay1 *self, PyObject *arg) { SET_SUB };
+static PyObject * Delay1_setDiv(Delay1 *self, PyObject *arg) { SET_DIV };
static PyObject * Delay1_play(Delay1 *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Delay1_out(Delay1 *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3035,3 +3035,716 @@ Delay1_members, /* tp_members */
0, /* tp_alloc */
Delay1_new, /* tp_new */
};
+
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ PyObject *delay;
+ Stream *delay_stream;
+ PyObject *feedback;
+ Stream *feedback_stream;
+ MYFLT crossfade;
+ MYFLT maxdelay;
+ MYFLT oneOverSr;
+ MYFLT amp1;
+ MYFLT amp2;
+ MYFLT inc1;
+ MYFLT inc2;
+ int current;
+ long timer;
+ long size;
+ long in_count;
+ long sampdel;
+ MYFLT sampdel1;
+ MYFLT sampdel2;
+ int modebuffer[4];
+ MYFLT *buffer; // samples memory
+} SmoothDelay;
+
+static void
+SmoothDelay_process_ii(SmoothDelay *self) {
+ MYFLT val, xind, frac, sum;
+ int i;
+ long ind, xsamps = 0;
+
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ MYFLT del = PyFloat_AS_DOUBLE(self->delay);
+ MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
+
+ if (del < self->oneOverSr) del = self->oneOverSr;
+ else if (del > self->maxdelay) del = self->maxdelay;
+
+ if (feed < 0) feed = 0.0;
+ else if (feed > 1) feed = 1.0;
+
+ for (i=0; i<self->bufsize; i++) {
+ if (self->timer == 0) {
+ self->current = (self->current + 1) % 2;
+ self->sampdel = (long)(del * self->sr + 0.5);
+ xsamps = (long)(self->crossfade * self->sr + 0.5);
+ if (xsamps > self->sampdel) xsamps = self->sampdel;
+ if (xsamps <= 0) xsamps = 1;
+ if (self->current == 0) {
+ self->sampdel1 = del * self->sr;
+ self->inc1 = 1.0 / xsamps;
+ self->inc2 = -self->inc1;
+ }
+ else {
+ self->sampdel2 = del * self->sr;
+ self->inc2 = 1.0 / xsamps;
+ self->inc1 = -self->inc2;
+ }
+ }
+
+ xind = self->in_count - self->sampdel1;
+ while (xind < 0)
+ xind += self->size;
+ ind = (long)xind;
+ frac = xind - ind;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ sum = val * self->amp1;
+ self->amp1 += self->inc1;
+ if (self->amp1 < 0) self->amp1 = 0.0;
+ else if (self->amp1 > 1) self->amp1 = 1.0;
+
+ xind = self->in_count - self->sampdel2;
+ while (xind < 0)
+ xind += self->size;
+ ind = (long)xind;
+ frac = xind - ind;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ sum += val * self->amp2;
+ self->amp2 += self->inc2;
+ if (self->amp2 < 0) self->amp2 = 0.0;
+ else if (self->amp2 > 1) self->amp2 = 1.0;
+
+ self->data[i] = sum;
+
+ self->buffer[self->in_count] = in[i] + (sum * feed);
+ if (self->in_count == 0)
+ self->buffer[self->size] = self->buffer[0];
+ self->in_count++;
+ if (self->in_count >= self->size)
+ self->in_count = 0;
+
+ self->timer++;
+ if (self->timer == self->sampdel)
+ self->timer = 0;
+ }
+}
+
+static void
+SmoothDelay_process_ai(SmoothDelay *self) {
+ MYFLT val, xind, frac, sum, del;
+ int i;
+ long ind, xsamps = 0;
+
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ MYFLT *dl = Stream_getData((Stream *)self->delay_stream);
+ MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
+
+ if (feed < 0) feed = 0.0;
+ else if (feed > 1) feed = 1.0;
+
+ for (i=0; i<self->bufsize; i++) {
+ if (self->timer == 0) {
+ del = dl[i];
+ if (del < self->oneOverSr) del = self->oneOverSr;
+ else if (del > self->maxdelay) del = self->maxdelay;
+ self->current = (self->current + 1) % 2;
+ self->sampdel = (long)(del * self->sr + 0.5);
+ xsamps = (long)(self->crossfade * self->sr + 0.5);
+ if (xsamps > self->sampdel) xsamps = self->sampdel;
+ if (xsamps <= 0) xsamps = 1;
+ if (self->current == 0) {
+ self->sampdel1 = del * self->sr;
+ self->inc1 = 1.0 / xsamps;
+ self->inc2 = -self->inc1;
+ }
+ else {
+ self->sampdel2 = del * self->sr;
+ self->inc2 = 1.0 / xsamps;
+ self->inc1 = -self->inc2;
+ }
+ }
+
+ xind = self->in_count - self->sampdel1;
+ while (xind < 0)
+ xind += self->size;
+ ind = (long)xind;
+ frac = xind - ind;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ sum = val * self->amp1;
+ self->amp1 += self->inc1;
+ if (self->amp1 < 0) self->amp1 = 0.0;
+ else if (self->amp1 > 1) self->amp1 = 1.0;
+
+ xind = self->in_count - self->sampdel2;
+ while (xind < 0)
+ xind += self->size;
+ ind = (long)xind;
+ frac = xind - ind;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ sum += val * self->amp2;
+ self->amp2 += self->inc2;
+ if (self->amp2 < 0) self->amp2 = 0.0;
+ else if (self->amp2 > 1) self->amp2 = 1.0;
+
+ self->data[i] = sum;
+
+ self->buffer[self->in_count] = in[i] + (sum * feed);
+ if (self->in_count == 0)
+ self->buffer[self->size] = self->buffer[0];
+ self->in_count++;
+ if (self->in_count >= self->size)
+ self->in_count = 0;
+
+ self->timer++;
+ if (self->timer == self->sampdel)
+ self->timer = 0;
+ }
+}
+
+static void
+SmoothDelay_process_ia(SmoothDelay *self) {
+ MYFLT val, xind, frac, sum, feed;
+ int i;
+ long ind, xsamps = 0;
+
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ MYFLT del = PyFloat_AS_DOUBLE(self->delay);
+ MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
+
+ if (del < self->oneOverSr) del = self->oneOverSr;
+ else if (del > self->maxdelay) del = self->maxdelay;
+
+ for (i=0; i<self->bufsize; i++) {
+ feed = fd[i];
+ if (feed < 0) feed = 0.0;
+ else if (feed > 1) feed = 1.0;
+ if (self->timer == 0) {
+ self->current = (self->current + 1) % 2;
+ self->sampdel = (long)(del * self->sr + 0.5);
+ xsamps = (long)(self->crossfade * self->sr + 0.5);
+ if (xsamps > self->sampdel) xsamps = self->sampdel;
+ if (xsamps <= 0) xsamps = 1;
+ if (self->current == 0) {
+ self->sampdel1 = del * self->sr;
+ self->inc1 = 1.0 / xsamps;
+ self->inc2 = -self->inc1;
+ }
+ else {
+ self->sampdel2 = del * self->sr;
+ self->inc2 = 1.0 / xsamps;
+ self->inc1 = -self->inc2;
+ }
+ }
+
+ xind = self->in_count - self->sampdel1;
+ while (xind < 0)
+ xind += self->size;
+ ind = (long)xind;
+ frac = xind - ind;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ sum = val * self->amp1;
+ self->amp1 += self->inc1;
+ if (self->amp1 < 0) self->amp1 = 0.0;
+ else if (self->amp1 > 1) self->amp1 = 1.0;
+
+ xind = self->in_count - self->sampdel2;
+ while (xind < 0)
+ xind += self->size;
+ ind = (long)xind;
+ frac = xind - ind;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ sum += val * self->amp2;
+ self->amp2 += self->inc2;
+ if (self->amp2 < 0) self->amp2 = 0.0;
+ else if (self->amp2 > 1) self->amp2 = 1.0;
+
+ self->data[i] = sum;
+
+ self->buffer[self->in_count] = in[i] + (sum * feed);
+ if (self->in_count == 0)
+ self->buffer[self->size] = self->buffer[0];
+ self->in_count++;
+ if (self->in_count >= self->size)
+ self->in_count = 0;
+
+ self->timer++;
+ if (self->timer == self->sampdel)
+ self->timer = 0;
+ }
+}
+
+static void
+SmoothDelay_process_aa(SmoothDelay *self) {
+ MYFLT val, xind, frac, sum, del, feed;
+ int i;
+ long ind, xsamps = 0;
+
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ MYFLT *dl = Stream_getData((Stream *)self->delay_stream);
+ MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ feed = fd[i];
+ if (feed < 0) feed = 0.0;
+ else if (feed > 1) feed = 1.0;
+ if (self->timer == 0) {
+ del = dl[i];
+ if (del < self->oneOverSr) del = self->oneOverSr;
+ else if (del > self->maxdelay) del = self->maxdelay;
+ self->current = (self->current + 1) % 2;
+ self->sampdel = (long)(del * self->sr + 0.5);
+ xsamps = (long)(self->crossfade * self->sr + 0.5);
+ if (xsamps > self->sampdel) xsamps = self->sampdel;
+ if (xsamps <= 0) xsamps = 1;
+ if (self->current == 0) {
+ self->sampdel1 = del * self->sr;
+ self->inc1 = 1.0 / xsamps;
+ self->inc2 = -self->inc1;
+ }
+ else {
+ self->sampdel2 = del * self->sr;
+ self->inc2 = 1.0 / xsamps;
+ self->inc1 = -self->inc2;
+ }
+ }
+
+ xind = self->in_count - self->sampdel1;
+ while (xind < 0)
+ xind += self->size;
+ ind = (long)xind;
+ frac = xind - ind;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ sum = val * self->amp1;
+ self->amp1 += self->inc1;
+ if (self->amp1 < 0) self->amp1 = 0.0;
+ else if (self->amp1 > 1) self->amp1 = 1.0;
+
+ xind = self->in_count - self->sampdel2;
+ while (xind < 0)
+ xind += self->size;
+ ind = (long)xind;
+ frac = xind - ind;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ sum += val * self->amp2;
+ self->amp2 += self->inc2;
+ if (self->amp2 < 0) self->amp2 = 0.0;
+ else if (self->amp2 > 1) self->amp2 = 1.0;
+
+ self->data[i] = sum;
+
+ self->buffer[self->in_count] = in[i] + (sum * feed);
+ if (self->in_count == 0)
+ self->buffer[self->size] = self->buffer[0];
+ self->in_count++;
+ if (self->in_count >= self->size)
+ self->in_count = 0;
+
+ self->timer++;
+ if (self->timer == self->sampdel)
+ self->timer = 0;
+ }
+}
+
+static void SmoothDelay_postprocessing_ii(SmoothDelay *self) { POST_PROCESSING_II };
+static void SmoothDelay_postprocessing_ai(SmoothDelay *self) { POST_PROCESSING_AI };
+static void SmoothDelay_postprocessing_ia(SmoothDelay *self) { POST_PROCESSING_IA };
+static void SmoothDelay_postprocessing_aa(SmoothDelay *self) { POST_PROCESSING_AA };
+static void SmoothDelay_postprocessing_ireva(SmoothDelay *self) { POST_PROCESSING_IREVA };
+static void SmoothDelay_postprocessing_areva(SmoothDelay *self) { POST_PROCESSING_AREVA };
+static void SmoothDelay_postprocessing_revai(SmoothDelay *self) { POST_PROCESSING_REVAI };
+static void SmoothDelay_postprocessing_revaa(SmoothDelay *self) { POST_PROCESSING_REVAA };
+static void SmoothDelay_postprocessing_revareva(SmoothDelay *self) { POST_PROCESSING_REVAREVA };
+
+static void
+SmoothDelay_setProcMode(SmoothDelay *self)
+{
+ int procmode, muladdmode;
+ procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ switch (procmode) {
+ case 0:
+ self->proc_func_ptr = SmoothDelay_process_ii;
+ break;
+ case 1:
+ self->proc_func_ptr = SmoothDelay_process_ai;
+ break;
+ case 10:
+ self->proc_func_ptr = SmoothDelay_process_ia;
+ break;
+ case 11:
+ self->proc_func_ptr = SmoothDelay_process_aa;
+ break;
+ }
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = SmoothDelay_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = SmoothDelay_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = SmoothDelay_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = SmoothDelay_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = SmoothDelay_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = SmoothDelay_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = SmoothDelay_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = SmoothDelay_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = SmoothDelay_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+SmoothDelay_compute_next_data_frame(SmoothDelay *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+SmoothDelay_traverse(SmoothDelay *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->delay);
+ Py_VISIT(self->delay_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
+ return 0;
+}
+
+static int
+SmoothDelay_clear(SmoothDelay *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->delay);
+ Py_CLEAR(self->delay_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
+ return 0;
+}
+
+static void
+SmoothDelay_dealloc(SmoothDelay* self)
+{
+ pyo_DEALLOC
+ free(self->buffer);
+ SmoothDelay_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+SmoothDelay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *inputtmp, *input_streamtmp, *delaytmp=NULL, *feedbacktmp=NULL, *multmp=NULL, *addtmp=NULL;
+ SmoothDelay *self;
+ self = (SmoothDelay *)type->tp_alloc(type, 0);
+
+ self->delay = PyFloat_FromDouble(0.25);
+ self->feedback = PyFloat_FromDouble(0);
+ self->crossfade = 0.05;
+ self->maxdelay = 1;
+ self->in_count = 0;
+ self->current = 1;
+ self->timer = 0;
+ self->amp1 = 0.0;
+ self->amp2 = 1.0;
+ self->inc1 = self->inc2 = 0.0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+ self->modebuffer[2] = 0;
+ self->modebuffer[3] = 0;
+
+ INIT_OBJECT_COMMON
+
+ self->oneOverSr = self->sampdel1 = self->sampdel2 = 1.0 / self->sr;
+
+ Stream_setFunctionPtr(self->stream, SmoothDelay_compute_next_data_frame);
+ self->mode_func_ptr = SmoothDelay_setProcMode;
+
+ static char *kwlist[] = {"input", "delay", "feedback", "crossfade", "maxdelay", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OOFFOO, kwlist, &inputtmp, &delaytmp, &feedbacktmp, &self->crossfade, &self->maxdelay, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ INIT_INPUT_STREAM
+
+ if (delaytmp) {
+ PyObject_CallMethod((PyObject *)self, "setDelay", "O", delaytmp);
+ }
+
+ if (feedbacktmp) {
+ PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
+ }
+
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ }
+
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ self->size = (long)(self->maxdelay * self->sr + 0.5);
+
+ self->buffer = (MYFLT *)realloc(self->buffer, (self->size+1) * sizeof(MYFLT));
+ for (i=0; i<(self->size+1); i++) {
+ self->buffer[i] = 0.;
+ }
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * SmoothDelay_getServer(SmoothDelay* self) { GET_SERVER };
+static PyObject * SmoothDelay_getStream(SmoothDelay* self) { GET_STREAM };
+static PyObject * SmoothDelay_setMul(SmoothDelay *self, PyObject *arg) { SET_MUL };
+static PyObject * SmoothDelay_setAdd(SmoothDelay *self, PyObject *arg) { SET_ADD };
+static PyObject * SmoothDelay_setSub(SmoothDelay *self, PyObject *arg) { SET_SUB };
+static PyObject * SmoothDelay_setDiv(SmoothDelay *self, PyObject *arg) { SET_DIV };
+
+static PyObject * SmoothDelay_play(SmoothDelay *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * SmoothDelay_out(SmoothDelay *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * SmoothDelay_stop(SmoothDelay *self) { STOP };
+
+static PyObject * SmoothDelay_multiply(SmoothDelay *self, PyObject *arg) { MULTIPLY };
+static PyObject * SmoothDelay_inplace_multiply(SmoothDelay *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * SmoothDelay_add(SmoothDelay *self, PyObject *arg) { ADD };
+static PyObject * SmoothDelay_inplace_add(SmoothDelay *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * SmoothDelay_sub(SmoothDelay *self, PyObject *arg) { SUB };
+static PyObject * SmoothDelay_inplace_sub(SmoothDelay *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * SmoothDelay_div(SmoothDelay *self, PyObject *arg) { DIV };
+static PyObject * SmoothDelay_inplace_div(SmoothDelay *self, PyObject *arg) { INPLACE_DIV };
+
+static PyObject *
+SmoothDelay_setDelay(SmoothDelay *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->delay);
+ if (isNumber == 1) {
+ self->delay = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->delay = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->delay, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->delay_stream);
+ self->delay_stream = (Stream *)streamtmp;
+ self->modebuffer[2] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+SmoothDelay_setFeedback(SmoothDelay *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->feedback);
+ if (isNumber == 1) {
+ self->feedback = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->feedback = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->feedback, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->feedback_stream);
+ self->feedback_stream = (Stream *)streamtmp;
+ self->modebuffer[3] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+SmoothDelay_setCrossfade(SmoothDelay *self, PyObject *arg)
+{
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ if (isNumber == 1) {
+ self->crossfade = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+SmoothDelay_reset(SmoothDelay *self)
+{
+ int i;
+ for (i=0; i<(self->size+1); i++) {
+ self->buffer[i] = 0.;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef SmoothDelay_members[] = {
+ {"server", T_OBJECT_EX, offsetof(SmoothDelay, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(SmoothDelay, stream), 0, "Stream object."},
+ {"input", T_OBJECT_EX, offsetof(SmoothDelay, input), 0, "Input sound object."},
+ {"delay", T_OBJECT_EX, offsetof(SmoothDelay, delay), 0, "SmoothDelay time in seconds."},
+ {"feedback", T_OBJECT_EX, offsetof(SmoothDelay, feedback), 0, "Feedback value."},
+ {"mul", T_OBJECT_EX, offsetof(SmoothDelay, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(SmoothDelay, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef SmoothDelay_methods[] = {
+ {"getServer", (PyCFunction)SmoothDelay_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)SmoothDelay_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)SmoothDelay_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)SmoothDelay_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)SmoothDelay_stop, METH_NOARGS, "Stops computing."},
+ {"setDelay", (PyCFunction)SmoothDelay_setDelay, METH_O, "Sets delay time in seconds."},
+ {"setFeedback", (PyCFunction)SmoothDelay_setFeedback, METH_O, "Sets feedback value between 0 -> 1."},
+ {"setCrossfade", (PyCFunction)SmoothDelay_setCrossfade, METH_O, "Sets crossfade time."},
+ {"reset", (PyCFunction)SmoothDelay_reset, METH_NOARGS, "Resets the memory buffer to zeros."},
+ {"setMul", (PyCFunction)SmoothDelay_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)SmoothDelay_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)SmoothDelay_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)SmoothDelay_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods SmoothDelay_as_number = {
+ (binaryfunc)SmoothDelay_add, /*nb_add*/
+ (binaryfunc)SmoothDelay_sub, /*nb_subtract*/
+ (binaryfunc)SmoothDelay_multiply, /*nb_multiply*/
+ (binaryfunc)SmoothDelay_div, /*nb_divide*/
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_neg*/
+ 0, /*nb_pos*/
+ 0, /*(unaryfunc)array_abs,*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ 0, /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ 0, /*nb_oct*/
+ 0, /*nb_hex*/
+ (binaryfunc)SmoothDelay_inplace_add, /*inplace_add*/
+ (binaryfunc)SmoothDelay_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)SmoothDelay_inplace_multiply, /*inplace_multiply*/
+ (binaryfunc)SmoothDelay_inplace_div, /*inplace_divide*/
+ 0, /*inplace_remainder*/
+ 0, /*inplace_power*/
+ 0, /*inplace_lshift*/
+ 0, /*inplace_rshift*/
+ 0, /*inplace_and*/
+ 0, /*inplace_xor*/
+ 0, /*inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject SmoothDelayType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.SmoothDelay_base", /*tp_name*/
+ sizeof(SmoothDelay), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)SmoothDelay_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &SmoothDelay_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "SmoothDelay objects. Delay signal by x samples.", /* tp_doc */
+ (traverseproc)SmoothDelay_traverse, /* tp_traverse */
+ (inquiry)SmoothDelay_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ SmoothDelay_methods, /* tp_methods */
+ SmoothDelay_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ SmoothDelay_new, /* tp_new */
+};
\ No newline at end of file
diff --git a/src/objects/distomodule.c b/src/objects/distomodule.c
index 89cbb1c..67bca8c 100644
--- a/src/objects/distomodule.c
+++ b/src/objects/distomodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -58,7 +58,7 @@ Disto_transform_ii(Disto *self) {
MYFLT drv = .4 - _clip(PyFloat_AS_DOUBLE(self->drive)) * .3999;
MYFLT slp = _clip(PyFloat_AS_DOUBLE(self->slope));
-
+
for (i=0; i<self->bufsize; i++) {
val = MYATAN2(in[i], drv);
self->data[i] = val;
@@ -79,13 +79,13 @@ Disto_transform_ai(Disto *self) {
MYFLT *drive = Stream_getData((Stream *)self->drive_stream);
MYFLT slp = _clip(PyFloat_AS_DOUBLE(self->slope));
-
+
for (i=0; i<self->bufsize; i++) {
drv = .4 - _clip(drive[i]) * .3999;
val = MYATAN2(in[i], drv);
self->data[i] = val;
}
-
+
coeff = 1.0 - slp;
for (i=0; i<self->bufsize; i++) {
val = self->data[i] * coeff + self->y1 * slp;
@@ -99,10 +99,10 @@ Disto_transform_ia(Disto *self) {
MYFLT val, coeff, slp;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT drv = .4 - _clip(PyFloat_AS_DOUBLE(self->drive)) * .3999;
MYFLT *slope = Stream_getData((Stream *)self->slope_stream);
-
+
for (i=0; i<self->bufsize; i++) {
val = MYATAN2(in[i], drv);
self->data[i] = val;
@@ -121,10 +121,10 @@ Disto_transform_aa(Disto *self) {
MYFLT val, drv, coeff, slp;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT *drive = Stream_getData((Stream *)self->drive_stream);
MYFLT *slope = Stream_getData((Stream *)self->slope_stream);
-
+
for (i=0; i<self->bufsize; i++) {
drv = .4 - _clip(drive[i]) * .3999;
val = MYATAN2(in[i], drv);
@@ -157,54 +157,54 @@ Disto_setProcMode(Disto *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Disto_transform_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Disto_transform_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Disto_transform_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Disto_transform_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Disto_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Disto_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Disto_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Disto_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Disto_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Disto_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Disto_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Disto_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Disto_postprocessing_revareva;
break;
- }
+ }
}
static void
Disto_compute_next_data_frame(Disto *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -213,24 +213,24 @@ Disto_traverse(Disto *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->drive);
- Py_VISIT(self->drive_stream);
- Py_VISIT(self->slope);
- Py_VISIT(self->slope_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->drive);
+ Py_VISIT(self->drive_stream);
+ Py_VISIT(self->slope);
+ Py_VISIT(self->slope_stream);
return 0;
}
-static int
+static int
Disto_clear(Disto *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->drive);
- Py_CLEAR(self->drive_stream);
- Py_CLEAR(self->slope);
- Py_CLEAR(self->slope_stream);
+ Py_CLEAR(self->drive);
+ Py_CLEAR(self->drive_stream);
+ Py_CLEAR(self->slope);
+ Py_CLEAR(self->slope_stream);
return 0;
}
@@ -268,7 +268,7 @@ Disto_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (drivetmp) {
PyObject_CallMethod((PyObject *)self, "setDrive", "O", drivetmp);
}
@@ -276,7 +276,7 @@ Disto_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (slopetmp) {
PyObject_CallMethod((PyObject *)self, "setSlope", "O", slopetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -284,20 +284,20 @@ Disto_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Disto_getServer(Disto* self) { GET_SERVER };
static PyObject * Disto_getStream(Disto* self) { GET_STREAM };
-static PyObject * Disto_setMul(Disto *self, PyObject *arg) { SET_MUL };
-static PyObject * Disto_setAdd(Disto *self, PyObject *arg) { SET_ADD };
-static PyObject * Disto_setSub(Disto *self, PyObject *arg) { SET_SUB };
-static PyObject * Disto_setDiv(Disto *self, PyObject *arg) { SET_DIV };
+static PyObject * Disto_setMul(Disto *self, PyObject *arg) { SET_MUL };
+static PyObject * Disto_setAdd(Disto *self, PyObject *arg) { SET_ADD };
+static PyObject * Disto_setSub(Disto *self, PyObject *arg) { SET_SUB };
+static PyObject * Disto_setDiv(Disto *self, PyObject *arg) { SET_DIV };
static PyObject * Disto_play(Disto *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Disto_out(Disto *self, PyObject *args, PyObject *kwds) { OUT };
@@ -316,14 +316,14 @@ static PyObject *
Disto_setDrive(Disto *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->drive);
@@ -339,25 +339,25 @@ Disto_setDrive(Disto *self, PyObject *arg)
self->drive_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Disto_setSlope(Disto *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->slope);
@@ -373,12 +373,12 @@ Disto_setSlope(Disto *self, PyObject *arg)
self->slope_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Disto_members[] = {
{"server", T_OBJECT_EX, offsetof(Disto, server), 0, "Pyo server."},
@@ -512,7 +512,7 @@ Clip_transform_ii(Clip *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
if(val < mi)
@@ -531,7 +531,7 @@ Clip_transform_ai(Clip *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
mini = mi[i];
@@ -551,7 +551,7 @@ Clip_transform_ia(Clip *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
maxi = ma[i];
@@ -563,7 +563,7 @@ Clip_transform_ia(Clip *self) {
self->data[i] = val;
}
}
-
+
static void
Clip_transform_aa(Clip *self) {
MYFLT val, mini, maxi;
@@ -571,7 +571,7 @@ Clip_transform_aa(Clip *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
mini = mi[i];
@@ -601,56 +601,56 @@ Clip_setProcMode(Clip *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Clip_transform_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Clip_transform_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Clip_transform_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Clip_transform_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Clip_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Clip_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Clip_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Clip_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Clip_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Clip_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Clip_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Clip_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Clip_postprocessing_revareva;
break;
- }
+ }
}
static void
Clip_compute_next_data_frame(Clip *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -659,24 +659,24 @@ Clip_traverse(Clip *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->min);
- Py_VISIT(self->min_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->min);
+ Py_VISIT(self->min_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
Clip_clear(Clip *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->min);
- Py_CLEAR(self->min_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->min);
+ Py_CLEAR(self->min_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -695,54 +695,54 @@ Clip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *mintmp=NULL, *maxtmp=NULL, *multmp=NULL, *addtmp=NULL;
Clip *self;
self = (Clip *)type->tp_alloc(type, 0);
-
+
self->min = PyFloat_FromDouble(-1.0);
self->max = PyFloat_FromDouble(1.0);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Clip_compute_next_data_frame);
self->mode_func_ptr = Clip_setProcMode;
static char *kwlist[] = {"input", "min", "max", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &inputtmp, &mintmp, &maxtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (mintmp) {
PyObject_CallMethod((PyObject *)self, "setMin", "O", mintmp);
}
-
+
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Clip_getServer(Clip* self) { GET_SERVER };
static PyObject * Clip_getStream(Clip* self) { GET_STREAM };
-static PyObject * Clip_setMul(Clip *self, PyObject *arg) { SET_MUL };
-static PyObject * Clip_setAdd(Clip *self, PyObject *arg) { SET_ADD };
-static PyObject * Clip_setSub(Clip *self, PyObject *arg) { SET_SUB };
-static PyObject * Clip_setDiv(Clip *self, PyObject *arg) { SET_DIV };
+static PyObject * Clip_setMul(Clip *self, PyObject *arg) { SET_MUL };
+static PyObject * Clip_setAdd(Clip *self, PyObject *arg) { SET_ADD };
+static PyObject * Clip_setSub(Clip *self, PyObject *arg) { SET_SUB };
+static PyObject * Clip_setDiv(Clip *self, PyObject *arg) { SET_DIV };
static PyObject * Clip_play(Clip *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Clip_out(Clip *self, PyObject *args, PyObject *kwds) { OUT };
@@ -761,14 +761,14 @@ static PyObject *
Clip_setMin(Clip *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->min);
@@ -784,25 +784,25 @@ Clip_setMin(Clip *self, PyObject *arg)
self->min_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Clip_setMax(Clip *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -818,12 +818,12 @@ Clip_setMax(Clip *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Clip_members[] = {
{"server", T_OBJECT_EX, offsetof(Clip, server), 0, "Pyo server."},
@@ -957,7 +957,7 @@ Mirror_transform_ii(Mirror *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
if (mi >= ma) {
avg = (mi + ma) * 0.5;
for (i=0; i<self->bufsize; i++) {
@@ -985,7 +985,7 @@ Mirror_transform_ai(Mirror *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mini = Stream_getData((Stream *)self->min_stream);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
mi = mini[i];
@@ -1000,7 +1000,7 @@ Mirror_transform_ai(Mirror *self) {
else
val = mi + mi - val;
}
- self->data[i] = val;
+ self->data[i] = val;
}
}
}
@@ -1012,7 +1012,7 @@ Mirror_transform_ia(Mirror *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT *maxi = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
ma = maxi[i];
@@ -1027,7 +1027,7 @@ Mirror_transform_ia(Mirror *self) {
else
val = mi + mi - val;
}
- self->data[i] = val;
+ self->data[i] = val;
}
}
}
@@ -1039,7 +1039,7 @@ Mirror_transform_aa(Mirror *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mini = Stream_getData((Stream *)self->min_stream);
MYFLT *maxi = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
mi = mini[i];
@@ -1055,7 +1055,7 @@ Mirror_transform_aa(Mirror *self) {
else
val = mi + mi - val;
}
- self->data[i] = val;
+ self->data[i] = val;
}
}
}
@@ -1076,56 +1076,56 @@ Mirror_setProcMode(Mirror *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Mirror_transform_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Mirror_transform_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Mirror_transform_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Mirror_transform_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Mirror_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Mirror_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Mirror_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Mirror_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Mirror_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Mirror_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Mirror_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Mirror_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Mirror_postprocessing_revareva;
break;
- }
+ }
}
static void
Mirror_compute_next_data_frame(Mirror *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1134,24 +1134,24 @@ Mirror_traverse(Mirror *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->min);
- Py_VISIT(self->min_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->min);
+ Py_VISIT(self->min_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
Mirror_clear(Mirror *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->min);
- Py_CLEAR(self->min_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->min);
+ Py_CLEAR(self->min_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -1170,54 +1170,54 @@ Mirror_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *mintmp=NULL, *maxtmp=NULL, *multmp=NULL, *addtmp=NULL;
Mirror *self;
self = (Mirror *)type->tp_alloc(type, 0);
-
+
self->min = PyFloat_FromDouble(0.0);
self->max = PyFloat_FromDouble(1.0);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Mirror_compute_next_data_frame);
self->mode_func_ptr = Mirror_setProcMode;
static char *kwlist[] = {"input", "min", "max", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &inputtmp, &mintmp, &maxtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (mintmp) {
PyObject_CallMethod((PyObject *)self, "setMin", "O", mintmp);
}
-
+
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Mirror_getServer(Mirror* self) { GET_SERVER };
static PyObject * Mirror_getStream(Mirror* self) { GET_STREAM };
-static PyObject * Mirror_setMul(Mirror *self, PyObject *arg) { SET_MUL };
-static PyObject * Mirror_setAdd(Mirror *self, PyObject *arg) { SET_ADD };
-static PyObject * Mirror_setSub(Mirror *self, PyObject *arg) { SET_SUB };
-static PyObject * Mirror_setDiv(Mirror *self, PyObject *arg) { SET_DIV };
+static PyObject * Mirror_setMul(Mirror *self, PyObject *arg) { SET_MUL };
+static PyObject * Mirror_setAdd(Mirror *self, PyObject *arg) { SET_ADD };
+static PyObject * Mirror_setSub(Mirror *self, PyObject *arg) { SET_SUB };
+static PyObject * Mirror_setDiv(Mirror *self, PyObject *arg) { SET_DIV };
static PyObject * Mirror_play(Mirror *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Mirror_out(Mirror *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1236,14 +1236,14 @@ static PyObject *
Mirror_setMin(Mirror *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->min);
@@ -1259,25 +1259,25 @@ Mirror_setMin(Mirror *self, PyObject *arg)
self->min_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Mirror_setMax(Mirror *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -1293,12 +1293,12 @@ Mirror_setMax(Mirror *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Mirror_members[] = {
{"server", T_OBJECT_EX, offsetof(Mirror, server), 0, "Pyo server."},
@@ -1432,7 +1432,7 @@ Wrap_transform_ii(Wrap *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
if (mi >= ma) {
avg = (mi + ma) * 0.5;
for (i=0; i<self->bufsize; i++) {
@@ -1453,7 +1453,7 @@ Wrap_transform_ii(Wrap *self) {
val = tmp * rng + mi;
if (val == ma)
val = mi;
- }
+ }
self->data[i] = val;
}
}
@@ -1466,7 +1466,7 @@ Wrap_transform_ai(Wrap *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mini = Stream_getData((Stream *)self->min_stream);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
mi = mini[i];
@@ -1486,8 +1486,8 @@ Wrap_transform_ai(Wrap *self) {
val = tmp * rng + mi;
if (val == ma)
val = mi;
- }
- self->data[i] = val;
+ }
+ self->data[i] = val;
}
}
}
@@ -1499,7 +1499,7 @@ Wrap_transform_ia(Wrap *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT *maxi = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
ma = maxi[i];
@@ -1519,8 +1519,8 @@ Wrap_transform_ia(Wrap *self) {
val = tmp * rng + mi;
if (val == ma)
val = mi;
- }
- self->data[i] = val;
+ }
+ self->data[i] = val;
}
}
}
@@ -1532,7 +1532,7 @@ Wrap_transform_aa(Wrap *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mini = Stream_getData((Stream *)self->min_stream);
MYFLT *maxi = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
mi = mini[i];
@@ -1553,8 +1553,8 @@ Wrap_transform_aa(Wrap *self) {
val = tmp * rng + mi;
if (val == ma)
val = mi;
- }
- self->data[i] = val;
+ }
+ self->data[i] = val;
}
}
}
@@ -1575,56 +1575,56 @@ Wrap_setProcMode(Wrap *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Wrap_transform_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Wrap_transform_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Wrap_transform_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Wrap_transform_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Wrap_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Wrap_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Wrap_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Wrap_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Wrap_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Wrap_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Wrap_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Wrap_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Wrap_postprocessing_revareva;
break;
- }
+ }
}
static void
Wrap_compute_next_data_frame(Wrap *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1633,24 +1633,24 @@ Wrap_traverse(Wrap *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->min);
- Py_VISIT(self->min_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->min);
+ Py_VISIT(self->min_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
Wrap_clear(Wrap *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->min);
- Py_CLEAR(self->min_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->min);
+ Py_CLEAR(self->min_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -1669,54 +1669,54 @@ Wrap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *mintmp=NULL, *maxtmp=NULL, *multmp=NULL, *addtmp=NULL;
Wrap *self;
self = (Wrap *)type->tp_alloc(type, 0);
-
+
self->min = PyFloat_FromDouble(0.0);
self->max = PyFloat_FromDouble(1.0);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Wrap_compute_next_data_frame);
self->mode_func_ptr = Wrap_setProcMode;
static char *kwlist[] = {"input", "min", "max", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &inputtmp, &mintmp, &maxtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (mintmp) {
PyObject_CallMethod((PyObject *)self, "setMin", "O", mintmp);
}
-
+
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Wrap_getServer(Wrap* self) { GET_SERVER };
static PyObject * Wrap_getStream(Wrap* self) { GET_STREAM };
-static PyObject * Wrap_setMul(Wrap *self, PyObject *arg) { SET_MUL };
-static PyObject * Wrap_setAdd(Wrap *self, PyObject *arg) { SET_ADD };
-static PyObject * Wrap_setSub(Wrap *self, PyObject *arg) { SET_SUB };
-static PyObject * Wrap_setDiv(Wrap *self, PyObject *arg) { SET_DIV };
+static PyObject * Wrap_setMul(Wrap *self, PyObject *arg) { SET_MUL };
+static PyObject * Wrap_setAdd(Wrap *self, PyObject *arg) { SET_ADD };
+static PyObject * Wrap_setSub(Wrap *self, PyObject *arg) { SET_SUB };
+static PyObject * Wrap_setDiv(Wrap *self, PyObject *arg) { SET_DIV };
static PyObject * Wrap_play(Wrap *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Wrap_out(Wrap *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1735,14 +1735,14 @@ static PyObject *
Wrap_setMin(Wrap *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->min);
@@ -1758,25 +1758,25 @@ Wrap_setMin(Wrap *self, PyObject *arg)
self->min_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Wrap_setMax(Wrap *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -1792,12 +1792,12 @@ Wrap_setMax(Wrap *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Wrap_members[] = {
{"server", T_OBJECT_EX, offsetof(Wrap, server), 0, "Pyo server."},
@@ -1926,7 +1926,7 @@ typedef struct {
int modebuffer[4];
} Degrade;
-static MYFLT
+static MYFLT
_bit_clip(MYFLT x) {
if (x < 1.0)
return 1.0;
@@ -1936,7 +1936,7 @@ _bit_clip(MYFLT x) {
return x;
}
-static MYFLT
+static MYFLT
_sr_clip(MYFLT x) {
// half sr ten times
if (x <= 0.0009765625)
@@ -1951,23 +1951,23 @@ static void
Degrade_transform_ii(Degrade *self) {
MYFLT bitscl, ibitscl, newsr;
int i, nsamps, tmp;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT bitdepth = _bit_clip(PyFloat_AS_DOUBLE(self->bitdepth));
MYFLT srscale = _sr_clip(PyFloat_AS_DOUBLE(self->srscale));
-
+
bitscl = MYPOW(2.0, bitdepth-1);
ibitscl = 1.0 / bitscl;
-
+
newsr = self->sr * srscale;
nsamps = (int)(self->sr / newsr);
-
+
for (i=0; i<self->bufsize; i++) {
self->sampsCount++;
if (self->sampsCount >= nsamps) {
self->sampsCount = 0;
tmp = (int)(in[i] * bitscl + 0.5);
- self->value = tmp * ibitscl;
+ self->value = tmp * ibitscl;
}
self->data[i] = self->value;
}
@@ -1977,14 +1977,14 @@ static void
Degrade_transform_ai(Degrade *self) {
MYFLT bitscl, ibitscl, newsr;
int i, nsamps, tmp;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *bitdepth = Stream_getData((Stream *)self->bitdepth_stream);
MYFLT srscale = _sr_clip(PyFloat_AS_DOUBLE(self->srscale));
newsr = self->sr * srscale;
nsamps = (int)(self->sr / newsr);
-
+
for (i=0; i<self->bufsize; i++) {
self->sampsCount++;
if (self->sampsCount >= nsamps) {
@@ -1992,7 +1992,7 @@ Degrade_transform_ai(Degrade *self) {
bitscl = MYPOW(2.0, _bit_clip(bitdepth[i])-1);
ibitscl = 1.0 / bitscl;
tmp = (int)(in[i] * bitscl + 0.5);
- self->value = tmp * ibitscl;
+ self->value = tmp * ibitscl;
}
self->data[i] = self->value;
}
@@ -2002,11 +2002,11 @@ static void
Degrade_transform_ia(Degrade *self) {
MYFLT bitscl, ibitscl, newsr;
int i, nsamps, tmp;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT bitdepth = _bit_clip(PyFloat_AS_DOUBLE(self->bitdepth));
MYFLT *srscale = Stream_getData((Stream *)self->srscale_stream);
-
+
bitscl = MYPOW(2.0, bitdepth-1);
ibitscl = 1.0 / bitscl;
@@ -2017,7 +2017,7 @@ Degrade_transform_ia(Degrade *self) {
if (self->sampsCount >= nsamps) {
self->sampsCount = 0;
tmp = (int)(in[i] * bitscl + 0.5);
- self->value = tmp * ibitscl;
+ self->value = tmp * ibitscl;
}
self->data[i] = self->value;
}
@@ -2027,7 +2027,7 @@ static void
Degrade_transform_aa(Degrade *self) {
MYFLT bitscl, ibitscl, newsr;
int i, nsamps, tmp;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *bitdepth = Stream_getData((Stream *)self->bitdepth_stream);
MYFLT *srscale = Stream_getData((Stream *)self->srscale_stream);
@@ -2041,7 +2041,7 @@ Degrade_transform_aa(Degrade *self) {
bitscl = MYPOW(2.0, _bit_clip(bitdepth[i])-1);
ibitscl = 1.0 / bitscl;
tmp = (int)(in[i] * bitscl + 0.5);
- self->value = tmp * ibitscl;
+ self->value = tmp * ibitscl;
}
self->data[i] = self->value;
}
@@ -2063,56 +2063,56 @@ Degrade_setProcMode(Degrade *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Degrade_transform_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Degrade_transform_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Degrade_transform_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Degrade_transform_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Degrade_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Degrade_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Degrade_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Degrade_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Degrade_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Degrade_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Degrade_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Degrade_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Degrade_postprocessing_revareva;
break;
- }
+ }
}
static void
Degrade_compute_next_data_frame(Degrade *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2121,24 +2121,24 @@ Degrade_traverse(Degrade *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->bitdepth);
- Py_VISIT(self->bitdepth_stream);
- Py_VISIT(self->srscale);
- Py_VISIT(self->srscale_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->bitdepth);
+ Py_VISIT(self->bitdepth_stream);
+ Py_VISIT(self->srscale);
+ Py_VISIT(self->srscale_stream);
return 0;
}
-static int
+static int
Degrade_clear(Degrade *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->bitdepth);
- Py_CLEAR(self->bitdepth_stream);
- Py_CLEAR(self->srscale);
- Py_CLEAR(self->srscale_stream);
+ Py_CLEAR(self->bitdepth);
+ Py_CLEAR(self->bitdepth_stream);
+ Py_CLEAR(self->srscale);
+ Py_CLEAR(self->srscale_stream);
return 0;
}
@@ -2157,7 +2157,7 @@ Degrade_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *bitdepthtmp=NULL, *srscaletmp=NULL, *multmp=NULL, *addtmp=NULL;
Degrade *self;
self = (Degrade *)type->tp_alloc(type, 0);
-
+
self->bitdepth = PyFloat_FromDouble(16);
self->srscale = PyFloat_FromDouble(1.0);
self->value = 0.0;
@@ -2166,47 +2166,47 @@ Degrade_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Degrade_compute_next_data_frame);
self->mode_func_ptr = Degrade_setProcMode;
static char *kwlist[] = {"input", "bitdepth", "srscale", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &inputtmp, &bitdepthtmp, &srscaletmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (bitdepthtmp) {
PyObject_CallMethod((PyObject *)self, "setBitdepth", "O", bitdepthtmp);
}
-
+
if (srscaletmp) {
PyObject_CallMethod((PyObject *)self, "setSrscale", "O", srscaletmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Degrade_getServer(Degrade* self) { GET_SERVER };
static PyObject * Degrade_getStream(Degrade* self) { GET_STREAM };
-static PyObject * Degrade_setMul(Degrade *self, PyObject *arg) { SET_MUL };
-static PyObject * Degrade_setAdd(Degrade *self, PyObject *arg) { SET_ADD };
-static PyObject * Degrade_setSub(Degrade *self, PyObject *arg) { SET_SUB };
-static PyObject * Degrade_setDiv(Degrade *self, PyObject *arg) { SET_DIV };
+static PyObject * Degrade_setMul(Degrade *self, PyObject *arg) { SET_MUL };
+static PyObject * Degrade_setAdd(Degrade *self, PyObject *arg) { SET_ADD };
+static PyObject * Degrade_setSub(Degrade *self, PyObject *arg) { SET_SUB };
+static PyObject * Degrade_setDiv(Degrade *self, PyObject *arg) { SET_DIV };
static PyObject * Degrade_play(Degrade *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Degrade_out(Degrade *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2225,14 +2225,14 @@ static PyObject *
Degrade_setBitdepth(Degrade *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->bitdepth);
@@ -2248,25 +2248,25 @@ Degrade_setBitdepth(Degrade *self, PyObject *arg)
self->bitdepth_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Degrade_setSrscale(Degrade *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->srscale);
@@ -2282,12 +2282,12 @@ Degrade_setSrscale(Degrade *self, PyObject *arg)
self->srscale_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Degrade_members[] = {
{"server", T_OBJECT_EX, offsetof(Degrade, server), 0, "Pyo server."},
@@ -2408,7 +2408,7 @@ typedef struct {
Stream *input_stream;
PyObject *comp;
Stream *comp_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} Min;
static void
@@ -2427,7 +2427,7 @@ Min_process_a(Min *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *cp = Stream_getData((Stream *)self->comp_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = in[i] < cp[i] ? in[i] : cp[i];
}
@@ -2449,50 +2449,50 @@ Min_setProcMode(Min *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Min_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Min_process_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Min_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Min_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Min_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Min_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Min_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Min_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Min_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Min_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Min_postprocessing_revareva;
break;
- }
+ }
}
static void
Min_compute_next_data_frame(Min *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2502,19 +2502,19 @@ Min_traverse(Min *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->comp);
- Py_VISIT(self->comp_stream);
+ Py_VISIT(self->comp);
+ Py_VISIT(self->comp_stream);
return 0;
}
-static int
+static int
Min_clear(Min *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->comp);
- Py_CLEAR(self->comp_stream);
+ Py_CLEAR(self->comp);
+ Py_CLEAR(self->comp_stream);
return 0;
}
@@ -2533,38 +2533,38 @@ Min_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *comptmp=NULL, *multmp=NULL, *addtmp=NULL;
Min *self;
self = (Min *)type->tp_alloc(type, 0);
-
+
self->comp = PyFloat_FromDouble(0.5);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Min_compute_next_data_frame);
self->mode_func_ptr = Min_setProcMode;
static char *kwlist[] = {"input", "comp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &comptmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (comptmp) {
PyObject_CallMethod((PyObject *)self, "setComp", "O", comptmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -2572,10 +2572,10 @@ Min_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Min_getServer(Min* self) { GET_SERVER };
static PyObject * Min_getStream(Min* self) { GET_STREAM };
-static PyObject * Min_setMul(Min *self, PyObject *arg) { SET_MUL };
-static PyObject * Min_setAdd(Min *self, PyObject *arg) { SET_ADD };
-static PyObject * Min_setSub(Min *self, PyObject *arg) { SET_SUB };
-static PyObject * Min_setDiv(Min *self, PyObject *arg) { SET_DIV };
+static PyObject * Min_setMul(Min *self, PyObject *arg) { SET_MUL };
+static PyObject * Min_setAdd(Min *self, PyObject *arg) { SET_ADD };
+static PyObject * Min_setSub(Min *self, PyObject *arg) { SET_SUB };
+static PyObject * Min_setDiv(Min *self, PyObject *arg) { SET_DIV };
static PyObject * Min_play(Min *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Min_out(Min *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2594,14 +2594,14 @@ static PyObject *
Min_setComp(Min *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->comp);
@@ -2617,9 +2617,9 @@ Min_setComp(Min *self, PyObject *arg)
self->comp_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2741,7 +2741,7 @@ typedef struct {
Stream *input_stream;
PyObject *comp;
Stream *comp_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} Max;
static void
@@ -2760,7 +2760,7 @@ Max_process_a(Max *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *cp = Stream_getData((Stream *)self->comp_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = in[i] > cp[i] ? in[i] : cp[i];
}
@@ -2782,50 +2782,50 @@ Max_setProcMode(Max *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Max_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Max_process_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Max_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Max_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Max_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Max_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Max_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Max_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Max_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Max_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Max_postprocessing_revareva;
break;
- }
+ }
}
static void
Max_compute_next_data_frame(Max *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2835,19 +2835,19 @@ Max_traverse(Max *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->comp);
- Py_VISIT(self->comp_stream);
+ Py_VISIT(self->comp);
+ Py_VISIT(self->comp_stream);
return 0;
}
-static int
+static int
Max_clear(Max *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->comp);
- Py_CLEAR(self->comp_stream);
+ Py_CLEAR(self->comp);
+ Py_CLEAR(self->comp_stream);
return 0;
}
@@ -2866,38 +2866,38 @@ Max_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *comptmp=NULL, *multmp=NULL, *addtmp=NULL;
Max *self;
self = (Max *)type->tp_alloc(type, 0);
-
+
self->comp = PyFloat_FromDouble(0.5);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Max_compute_next_data_frame);
self->mode_func_ptr = Max_setProcMode;
static char *kwlist[] = {"input", "comp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &comptmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (comptmp) {
PyObject_CallMethod((PyObject *)self, "setComp", "O", comptmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -2905,10 +2905,10 @@ Max_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Max_getServer(Max* self) { GET_SERVER };
static PyObject * Max_getStream(Max* self) { GET_STREAM };
-static PyObject * Max_setMul(Max *self, PyObject *arg) { SET_MUL };
-static PyObject * Max_setAdd(Max *self, PyObject *arg) { SET_ADD };
-static PyObject * Max_setSub(Max *self, PyObject *arg) { SET_SUB };
-static PyObject * Max_setDiv(Max *self, PyObject *arg) { SET_DIV };
+static PyObject * Max_setMul(Max *self, PyObject *arg) { SET_MUL };
+static PyObject * Max_setAdd(Max *self, PyObject *arg) { SET_ADD };
+static PyObject * Max_setSub(Max *self, PyObject *arg) { SET_SUB };
+static PyObject * Max_setDiv(Max *self, PyObject *arg) { SET_DIV };
static PyObject * Max_play(Max *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Max_out(Max *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2927,14 +2927,14 @@ static PyObject *
Max_setComp(Max *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->comp);
@@ -2950,9 +2950,9 @@ Max_setComp(Max *self, PyObject *arg)
self->comp_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3063,4 +3063,4 @@ Max_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
Max_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/fadermodule.c b/src/objects/fadermodule.c
index 98cf25b..2ea07e5 100644
--- a/src/objects/fadermodule.c
+++ b/src/objects/fadermodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -29,6 +29,7 @@ typedef struct {
pyo_audio_HEAD
int modebuffer[2];
int fademode;
+ int ended;
MYFLT topValue;
MYFLT attack;
MYFLT release;
@@ -37,7 +38,7 @@ typedef struct {
MYFLT sampleToSec;
} Fader;
-static void Fader_internal_stop(Fader *self) {
+static void Fader_internal_stop(Fader *self) {
int i;
Stream_setStreamActive(self->stream, 0);
Stream_setStreamChnl(self->stream, 0);
@@ -52,18 +53,23 @@ Fader_generate_auto(Fader *self) {
MYFLT val;
int i;
+ if (self->ended == 1) {
+ Fader_internal_stop((Fader *)self);
+ return;
+ }
+
for (i=0; i<self->bufsize; i++) {
if (self->currentTime <= self->attack)
val = self->currentTime / self->attack;
else if (self->currentTime > self->duration) {
val = 0.;
- Fader_internal_stop((Fader *)self);
+ self->ended = 1;
}
else if (self->currentTime >= (self->duration - self->release))
val = (self->duration - self->currentTime) / self->release;
else
val = 1.;
-
+
self->data[i] = val;
self->currentTime += self->sampleToSec;
}
@@ -73,27 +79,30 @@ static void
Fader_generate_wait(Fader *self) {
MYFLT val;
int i;
-
+
+ if (self->fademode == 1 && self->currentTime > self->release) {
+ Fader_internal_stop((Fader *)self);
+ return;
+ }
+
for (i=0; i<self->bufsize; i++) {
if (self->fademode == 0) {
-
+
if (self->currentTime <= self->attack)
val = self->currentTime / self->attack;
else
val = 1.;
- self->topValue = val;
- }
- else {
+ self->topValue = val;
+ }
+ else {
if (self->currentTime <= self->release)
val = (1. - self->currentTime / self->release) * self->topValue;
- else
+ else
val = 0.;
- }
+ }
self->data[i] = val;
- self->currentTime += self->sampleToSec;
+ self->currentTime += self->sampleToSec;
}
- if (self->fademode == 1 && self->currentTime > self->release)
- Fader_internal_stop((Fader *)self);
}
static void Fader_postprocessing_ii(Fader *self) { POST_PROCESSING_II };
@@ -111,47 +120,47 @@ Fader_setProcMode(Fader *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
if (self->duration == 0.0)
self->proc_func_ptr = Fader_generate_wait;
else
- self->proc_func_ptr = Fader_generate_auto;
-
+ self->proc_func_ptr = Fader_generate_auto;
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Fader_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Fader_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Fader_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Fader_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Fader_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Fader_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Fader_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Fader_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Fader_postprocessing_revareva;
break;
- }
+ }
}
static void
Fader_compute_next_data_frame(Fader *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -162,7 +171,7 @@ Fader_traverse(Fader *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Fader_clear(Fader *self)
{
pyo_CLEAR
@@ -184,11 +193,12 @@ Fader_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *multmp=NULL, *addtmp=NULL;
Fader *self;
self = (Fader *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->topValue = 0.0;
self->fademode = 0;
+ self->ended = 0;
self->attack = 0.01;
self->release = 0.1;
self->duration = 0.0;
@@ -197,41 +207,42 @@ Fader_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Fader_compute_next_data_frame);
self->mode_func_ptr = Fader_setProcMode;
-
+
Stream_setStreamActive(self->stream, 0);
-
+
self->sampleToSec = 1. / self->sr;
static char *kwlist[] = {"fadein", "fadeout", "dur", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__FFFOO, kwlist, &self->attack, &self->release, &self->duration, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Fader_getServer(Fader* self) { GET_SERVER };
static PyObject * Fader_getStream(Fader* self) { GET_STREAM };
-static PyObject * Fader_setMul(Fader *self, PyObject *arg) { SET_MUL };
-static PyObject * Fader_setAdd(Fader *self, PyObject *arg) { SET_ADD };
-static PyObject * Fader_setSub(Fader *self, PyObject *arg) { SET_SUB };
-static PyObject * Fader_setDiv(Fader *self, PyObject *arg) { SET_DIV };
+static PyObject * Fader_setMul(Fader *self, PyObject *arg) { SET_MUL };
+static PyObject * Fader_setAdd(Fader *self, PyObject *arg) { SET_ADD };
+static PyObject * Fader_setSub(Fader *self, PyObject *arg) { SET_SUB };
+static PyObject * Fader_setDiv(Fader *self, PyObject *arg) { SET_DIV };
-static PyObject * Fader_play(Fader *self, PyObject *args, PyObject *kwds)
+static PyObject * Fader_play(Fader *self, PyObject *args, PyObject *kwds)
{
self->fademode = 0;
+ self->ended = 0;
self->currentTime = 0.0;
(*self->mode_func_ptr)(self);
PLAY
@@ -405,7 +416,7 @@ typedef struct {
MYFLT sampleToSec;
} Adsr;
-static void Adsr_internal_stop(Adsr *self) {
+static void Adsr_internal_stop(Adsr *self) {
int i;
Stream_setStreamActive(self->stream, 0);
Stream_setStreamChnl(self->stream, 0);
@@ -419,7 +430,7 @@ static void
Adsr_generate_auto(Adsr *self) {
MYFLT val, invatt, invdec, invrel;
int i;
-
+
invatt = 1.0 / self->attack;
invdec = 1.0 / self->decay;
invrel = 1.0 / self->release;
@@ -437,7 +448,7 @@ Adsr_generate_auto(Adsr *self) {
val = (self->duration - self->currentTime) * invrel * self->sustain;
else
val = self->sustain;
-
+
self->data[i] = val;
self->currentTime += self->sampleToSec;
}
@@ -450,14 +461,14 @@ Adsr_generate_wait(Adsr *self) {
if (self->fademode == 1 && self->currentTime > self->release)
Adsr_internal_stop((Adsr *)self);
-
+
invatt = 1.0 / self->attack;
invdec = 1.0 / self->decay;
invrel = 1.0 / self->release;
for (i=0; i<self->bufsize; i++) {
if (self->fademode == 0) {
-
+
if (self->currentTime <= self->attack)
val = self->currentTime * invatt;
else if (self->currentTime <= (self->attack + self->decay))
@@ -465,16 +476,16 @@ Adsr_generate_wait(Adsr *self) {
else
val = self->sustain;
self->topValue = val;
- }
- else {
+ }
+ else {
if (self->currentTime <= self->release) {
val = self->topValue * (1. - self->currentTime * invrel);
}
- else
+ else
val = 0.;
- }
+ }
self->data[i] = val;
- self->currentTime += self->sampleToSec;
+ self->currentTime += self->sampleToSec;
}
}
@@ -493,47 +504,47 @@ Adsr_setProcMode(Adsr *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
if (self->duration == 0.0)
self->proc_func_ptr = Adsr_generate_wait;
else
- self->proc_func_ptr = Adsr_generate_auto;
-
+ self->proc_func_ptr = Adsr_generate_auto;
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Adsr_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Adsr_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Adsr_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Adsr_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Adsr_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Adsr_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Adsr_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Adsr_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Adsr_postprocessing_revareva;
break;
- }
+ }
}
static void
Adsr_compute_next_data_frame(Adsr *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -544,7 +555,7 @@ Adsr_traverse(Adsr *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Adsr_clear(Adsr *self)
{
pyo_CLEAR
@@ -566,7 +577,7 @@ Adsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *multmp=NULL, *addtmp=NULL;
Adsr *self;
self = (Adsr *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->topValue = 0.0;
@@ -577,30 +588,30 @@ Adsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->release = 0.1;
self->duration = 0.0;
self->currentTime = 0.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Adsr_compute_next_data_frame);
self->mode_func_ptr = Adsr_setProcMode;
-
+
Stream_setStreamActive(self->stream, 0);
-
+
self->sampleToSec = 1. / self->sr;
static char *kwlist[] = {"attack", "decay", "sustain", "release", "dur", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__FFFFFOO, kwlist, &self->attack, &self->decay, &self->sustain, &self->release, &self->duration, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
if (self->attack < 0.000001)
self->attack = 0.000001;
if (self->decay < 0.000001)
@@ -613,18 +624,18 @@ Adsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sustain = 1.0;
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Adsr_getServer(Adsr* self) { GET_SERVER };
static PyObject * Adsr_getStream(Adsr* self) { GET_STREAM };
-static PyObject * Adsr_setMul(Adsr *self, PyObject *arg) { SET_MUL };
-static PyObject * Adsr_setAdd(Adsr *self, PyObject *arg) { SET_ADD };
-static PyObject * Adsr_setSub(Adsr *self, PyObject *arg) { SET_SUB };
-static PyObject * Adsr_setDiv(Adsr *self, PyObject *arg) { SET_DIV };
+static PyObject * Adsr_setMul(Adsr *self, PyObject *arg) { SET_MUL };
+static PyObject * Adsr_setAdd(Adsr *self, PyObject *arg) { SET_ADD };
+static PyObject * Adsr_setSub(Adsr *self, PyObject *arg) { SET_SUB };
+static PyObject * Adsr_setDiv(Adsr *self, PyObject *arg) { SET_DIV };
-static PyObject * Adsr_play(Adsr *self, PyObject *args, PyObject *kwds)
+static PyObject * Adsr_play(Adsr *self, PyObject *args, PyObject *kwds)
{
self->fademode = 0;
self->currentTime = 0.0;
@@ -641,7 +652,7 @@ Adsr_stop(Adsr *self)
}
else
Adsr_internal_stop((Adsr *)self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -846,12 +857,12 @@ Linseg_convert_pointslist(Linseg *self) {
}
}
-static void
+static void
Linseg_reinit(Linseg *self) {
if (self->newlist == 1) {
Linseg_convert_pointslist((Linseg *)self);
self->newlist = 0;
- }
+ }
self->currentTime = 0.0;
self->currentValue = self->targets[0];
self->which = 0;
@@ -861,7 +872,7 @@ Linseg_reinit(Linseg *self) {
static void
Linseg_generate(Linseg *self) {
int i;
-
+
for (i=0; i<self->bufsize; i++) {
if (self->flag == 1) {
if (self->currentTime >= self->times[self->which]) {
@@ -872,8 +883,8 @@ Linseg_generate(Linseg *self) {
else {
self->flag = 0;
self->currentValue = self->targets[self->which-1];
- }
- }
+ }
+ }
else {
if ((self->times[self->which] - self->times[self->which-1]) <= 0)
self->increment = self->targets[self->which] - self->currentValue;
@@ -882,9 +893,9 @@ Linseg_generate(Linseg *self) {
}
}
if (self->currentTime <= self->times[self->listsize-1])
- self->currentValue += self->increment;
+ self->currentValue += self->increment;
self->data[i] = (MYFLT)self->currentValue;
- self->currentTime += self->sampleToSec;
+ self->currentTime += self->sampleToSec;
}
else
self->data[i] = (MYFLT)self->currentValue;
@@ -906,44 +917,44 @@ Linseg_setProcMode(Linseg *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Linseg_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Linseg_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Linseg_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Linseg_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Linseg_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Linseg_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Linseg_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Linseg_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Linseg_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Linseg_postprocessing_revareva;
break;
- }
+ }
}
static void
Linseg_compute_next_data_frame(Linseg *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -955,7 +966,7 @@ Linseg_traverse(Linseg *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Linseg_clear(Linseg *self)
{
pyo_CLEAR
@@ -980,22 +991,22 @@ Linseg_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pointslist=NULL, *multmp=NULL, *addtmp=NULL;
Linseg *self;
self = (Linseg *)type->tp_alloc(type, 0);
-
+
self->loop = 0;
self->newlist = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Linseg_compute_next_data_frame);
self->mode_func_ptr = Linseg_setProcMode;
-
+
Stream_setStreamActive(self->stream, 0);
-
+
self->sampleToSec = 1. / self->sr;
static char *kwlist[] = {"list", "loop", "initToFirstVal", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iiOO", kwlist, &pointslist, &self->loop, &initToFirstVal, &multmp, &addtmp))
Py_RETURN_NONE;
@@ -1003,36 +1014,36 @@ Linseg_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_XDECREF(self->pointslist);
self->pointslist = pointslist;
Linseg_convert_pointslist((Linseg *)self);
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
if (initToFirstVal) {
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->targets[0];
}
}
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Linseg_getServer(Linseg* self) { GET_SERVER };
static PyObject * Linseg_getStream(Linseg* self) { GET_STREAM };
-static PyObject * Linseg_setMul(Linseg *self, PyObject *arg) { SET_MUL };
-static PyObject * Linseg_setAdd(Linseg *self, PyObject *arg) { SET_ADD };
-static PyObject * Linseg_setSub(Linseg *self, PyObject *arg) { SET_SUB };
-static PyObject * Linseg_setDiv(Linseg *self, PyObject *arg) { SET_DIV };
+static PyObject * Linseg_setMul(Linseg *self, PyObject *arg) { SET_MUL };
+static PyObject * Linseg_setAdd(Linseg *self, PyObject *arg) { SET_ADD };
+static PyObject * Linseg_setSub(Linseg *self, PyObject *arg) { SET_SUB };
+static PyObject * Linseg_setDiv(Linseg *self, PyObject *arg) { SET_DIV };
-static PyObject * Linseg_play(Linseg *self, PyObject *args, PyObject *kwds)
+static PyObject * Linseg_play(Linseg *self, PyObject *args, PyObject *kwds)
{
Linseg_reinit((Linseg *)self);
PLAY
@@ -1056,18 +1067,18 @@ Linseg_setList(Linseg *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The points list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
self->newlist = 1;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1079,9 +1090,9 @@ Linseg_setLoop(Linseg *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->loop = PyInt_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1221,7 +1232,7 @@ static void
Expseg_convert_pointslist(Expseg *self) {
int i;
PyObject *tup;
-
+
self->listsize = PyList_Size(self->pointslist);
self->targets = (MYFLT *)realloc(self->targets, self->listsize * sizeof(MYFLT));
self->times = (MYFLT *)realloc(self->times, self->listsize * sizeof(MYFLT));
@@ -1232,12 +1243,12 @@ Expseg_convert_pointslist(Expseg *self) {
}
}
-static void
+static void
Expseg_reinit(Expseg *self) {
if (self->newlist == 1) {
Expseg_convert_pointslist((Expseg *)self);
self->newlist = 0;
- }
+ }
self->currentTime = 0.0;
self->currentValue = self->targets[0];
self->which = 0;
@@ -1250,7 +1261,7 @@ static void
Expseg_generate(Expseg *self) {
int i;
double scl;
-
+
for (i=0; i<self->bufsize; i++) {
if (self->flag == 1) {
if (self->currentTime >= self->times[self->which]) {
@@ -1261,8 +1272,8 @@ Expseg_generate(Expseg *self) {
else {
self->flag = 0;
self->currentValue = self->targets[self->which-1];
- }
- }
+ }
+ }
else {
self->range = self->targets[self->which] - self->targets[self->which-1];
self->steps = (self->times[self->which] - self->times[self->which-1]) * self->sr;
@@ -1270,8 +1281,8 @@ Expseg_generate(Expseg *self) {
self->inc = 1.0;
else
self->inc = 1.0 / self->steps;
- }
- self->pointer = 0.0;
+ }
+ self->pointer = 0.0;
}
if (self->currentTime <= self->times[self->listsize-1]) {
if (self->pointer >= 1.0)
@@ -1283,9 +1294,9 @@ Expseg_generate(Expseg *self) {
self->currentValue = scl * self->range + self->targets[self->which-1];
self->pointer += self->inc;
- }
+ }
self->data[i] = (MYFLT)self->currentValue;
- self->currentTime += self->sampleToSec;
+ self->currentTime += self->sampleToSec;
}
else
self->data[i] = (MYFLT)self->currentValue;
@@ -1307,44 +1318,44 @@ Expseg_setProcMode(Expseg *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Expseg_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Expseg_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Expseg_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Expseg_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Expseg_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Expseg_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Expseg_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Expseg_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Expseg_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Expseg_postprocessing_revareva;
break;
- }
+ }
}
static void
Expseg_compute_next_data_frame(Expseg *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1356,7 +1367,7 @@ Expseg_traverse(Expseg *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Expseg_clear(Expseg *self)
{
pyo_CLEAR
@@ -1381,40 +1392,40 @@ Expseg_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pointslist=NULL, *multmp=NULL, *addtmp=NULL;
Expseg *self;
self = (Expseg *)type->tp_alloc(type, 0);
-
+
self->loop = 0;
self->newlist = 1;
self->exp = self->exp_tmp = 10;
self->inverse = self->inverse_tmp = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Expseg_compute_next_data_frame);
self->mode_func_ptr = Expseg_setProcMode;
-
+
Stream_setStreamActive(self->stream, 0);
-
+
self->sampleToSec = 1. / self->sr;
static char *kwlist[] = {"list", "loop", "exp", "inverse", "initToFirstVal", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|idiiOO", kwlist, &pointslist, &self->loop, &self->exp_tmp, &self->inverse_tmp, &initToFirstVal, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_INCREF(pointslist);
Py_XDECREF(self->pointslist);
self->pointslist = pointslist;
Expseg_convert_pointslist((Expseg *)self);
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
if (initToFirstVal) {
@@ -1424,18 +1435,18 @@ Expseg_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Expseg_getServer(Expseg* self) { GET_SERVER };
static PyObject * Expseg_getStream(Expseg* self) { GET_STREAM };
-static PyObject * Expseg_setMul(Expseg *self, PyObject *arg) { SET_MUL };
-static PyObject * Expseg_setAdd(Expseg *self, PyObject *arg) { SET_ADD };
-static PyObject * Expseg_setSub(Expseg *self, PyObject *arg) { SET_SUB };
-static PyObject * Expseg_setDiv(Expseg *self, PyObject *arg) { SET_DIV };
+static PyObject * Expseg_setMul(Expseg *self, PyObject *arg) { SET_MUL };
+static PyObject * Expseg_setAdd(Expseg *self, PyObject *arg) { SET_ADD };
+static PyObject * Expseg_setSub(Expseg *self, PyObject *arg) { SET_SUB };
+static PyObject * Expseg_setDiv(Expseg *self, PyObject *arg) { SET_DIV };
-static PyObject * Expseg_play(Expseg *self, PyObject *args, PyObject *kwds)
+static PyObject * Expseg_play(Expseg *self, PyObject *args, PyObject *kwds)
{
Expseg_reinit((Expseg *)self);
PLAY
@@ -1459,18 +1470,18 @@ Expseg_setList(Expseg *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The points list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
self->newlist = 1;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1482,9 +1493,9 @@ Expseg_setLoop(Expseg *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->loop = PyInt_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1496,9 +1507,9 @@ Expseg_setExp(Expseg *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->exp_tmp = PyFloat_AsDouble(PyNumber_Float(arg));
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1510,9 +1521,9 @@ Expseg_setInverse(Expseg *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->inverse_tmp = PyInt_AsLong(PyNumber_Int(arg));
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1624,4 +1635,4 @@ PyTypeObject ExpsegType = {
0, /* tp_init */
0, /* tp_alloc */
Expseg_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/fftmodule.c b/src/objects/fftmodule.c
index 39ca586..f8d6f6d 100644
--- a/src/objects/fftmodule.c
+++ b/src/objects/fftmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -29,7 +29,7 @@
#include "wind.h"
#include "sndfile.h"
-static int
+static int
isPowerOfTwo(int x) {
return (x != 0) && ((x & (x - 1)) == 0);
}
@@ -57,7 +57,7 @@ FFTMain_realloc_memories(FFTMain *self) {
self->hsize = self->size / 2;
n8 = self->size >> 3;
self->inframe = (MYFLT *)realloc(self->inframe, self->size * sizeof(MYFLT));
- self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
+ self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
for (i=0; i<self->size; i++)
self->inframe[i] = self->outframe[i] = 0.0;
self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, 3 * self->bufsize * sizeof(MYFLT));
@@ -78,7 +78,7 @@ static void
FFTMain_filters(FFTMain *self) {
int i, incount;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
incount = self->incount;
for (i=0; i<self->bufsize; i++) {
@@ -99,10 +99,10 @@ FFTMain_filters(FFTMain *self) {
}
incount++;
if (incount >= self->size) {
- incount -= self->size;
+ incount -= self->size;
realfft_split(self->inframe, self->outframe, self->size, self->twiddle);
}
- }
+ }
/*
for (i=0; i<self->bufsize; i++) {
@@ -113,12 +113,12 @@ FFTMain_filters(FFTMain *self) {
self->buffer_streams[i+self->bufsize] = self->outframe[incount*2+1];
}
else
- self->buffer_streams[i] = self->buffer_streams[i+self->bufsize] = 0.0;
+ self->buffer_streams[i] = self->buffer_streams[i+self->bufsize] = 0.0;
self->buffer_streams[i+self->bufsize*2] = (MYFLT)incount;
}
incount++;
if (incount >= self->size) {
- incount -= self->size;
+ incount -= self->size;
realfft_packed(self->inframe, self->outframe, self->size, self->twiddle2);
}
}
@@ -130,18 +130,18 @@ MYFLT *
FFTMain_getSamplesBuffer(FFTMain *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
FFTMain_setProcMode(FFTMain *self)
-{
- self->proc_func_ptr = FFTMain_filters;
+{
+ self->proc_func_ptr = FFTMain_filters;
}
static void
FFTMain_compute_next_data_frame(FFTMain *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -153,7 +153,7 @@ FFTMain_traverse(FFTMain *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
FFTMain_clear(FFTMain *self)
{
pyo_CLEAR
@@ -187,7 +187,7 @@ FFTMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp;
FFTMain *self;
self = (FFTMain *)type->tp_alloc(type, 0);
-
+
self->size = 1024;
self->wintype = 2;
INIT_OBJECT_COMMON
@@ -195,12 +195,12 @@ FFTMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = FFTMain_setProcMode;
static char *kwlist[] = {"input", "size", "hopsize", "wintype", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iii", kwlist, &inputtmp, &self->size, &self->hopsize, &self->wintype))
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
FFTMain_realloc_memories(self);
@@ -219,7 +219,7 @@ static PyObject * FFTMain_stop(FFTMain *self) { STOP };
static PyObject *
FFTMain_setSize(FFTMain *self, PyObject *args, PyObject *kwds)
{
- int size, hopsize;
+ int size, hopsize;
static char *kwlist[] = {"size", "hopsize", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwlist, &size, &hopsize)) {
@@ -234,19 +234,19 @@ FFTMain_setSize(FFTMain *self, PyObject *args, PyObject *kwds)
}
else
printf("FFT size must be a power of two!\n");
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
FFTMain_setWinType(FFTMain *self, PyObject *arg)
-{
+{
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->wintype = PyLong_AsLong(arg);
gen_window(self->window, self->size, self->wintype);
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -335,33 +335,33 @@ FFT_setProcMode(FFT *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = FFT_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = FFT_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = FFT_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = FFT_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = FFT_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = FFT_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = FFT_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = FFT_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = FFT_postprocessing_revareva;
break;
}
@@ -376,7 +376,7 @@ FFT_compute_next_data_frame(FFT *self)
tmp = FFTMain_getSamplesBuffer((FFTMain *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -388,11 +388,11 @@ FFT_traverse(FFT *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
FFT_clear(FFT *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -411,33 +411,33 @@ FFT_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
FFT *self;
self = (FFT *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, FFT_compute_next_data_frame);
self->mode_func_ptr = FFT_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (FFTMain *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -445,10 +445,10 @@ FFT_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * FFT_getServer(FFT* self) { GET_SERVER };
static PyObject * FFT_getStream(FFT* self) { GET_STREAM };
-static PyObject * FFT_setMul(FFT *self, PyObject *arg) { SET_MUL };
-static PyObject * FFT_setAdd(FFT *self, PyObject *arg) { SET_ADD };
-static PyObject * FFT_setSub(FFT *self, PyObject *arg) { SET_SUB };
-static PyObject * FFT_setDiv(FFT *self, PyObject *arg) { SET_DIV };
+static PyObject * FFT_setMul(FFT *self, PyObject *arg) { SET_MUL };
+static PyObject * FFT_setAdd(FFT *self, PyObject *arg) { SET_ADD };
+static PyObject * FFT_setSub(FFT *self, PyObject *arg) { SET_SUB };
+static PyObject * FFT_setDiv(FFT *self, PyObject *arg) { SET_DIV };
static PyObject * FFT_play(FFT *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * FFT_stop(FFT *self) { STOP };
@@ -578,7 +578,7 @@ typedef struct {
int wintype;
int incount;
MYFLT *inframe;
- MYFLT *outframe;
+ MYFLT *outframe;
MYFLT *window;
MYFLT **twiddle;
MYFLT *twiddle2;
@@ -591,7 +591,7 @@ IFFT_realloc_memories(IFFT *self) {
self->hsize = self->size / 2;
n8 = self->size >> 3;
self->inframe = (MYFLT *)realloc(self->inframe, self->size * sizeof(MYFLT));
- self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
+ self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
for (i=0; i<self->size; i++)
self->inframe[i] = self->outframe[i] = 0.0;
self->twiddle = (MYFLT **)realloc(self->twiddle, 4 * sizeof(MYFLT *));
@@ -627,7 +627,7 @@ IFFT_filters(IFFT *self) {
}
incount++;
if (incount >= self->size) {
- incount -= self->size;
+ incount -= self->size;
irealfft_split(self->inframe, self->outframe, self->size, self->twiddle);
}
}
@@ -642,11 +642,11 @@ IFFT_filters(IFFT *self) {
}
incount++;
if (incount >= self->size) {
- incount -= self->size;
+ incount -= self->size;
irealfft_packed(self->inframe, self->outframe, self->size, self->twiddle2);
}
}
- */
+ */
self->incount = incount;
}
@@ -667,42 +667,42 @@ IFFT_setProcMode(IFFT *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
self->proc_func_ptr = IFFT_filters;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = IFFT_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = IFFT_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = IFFT_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = IFFT_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = IFFT_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = IFFT_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = IFFT_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = IFFT_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = IFFT_postprocessing_revareva;
break;
- }
+ }
}
static void
IFFT_compute_next_data_frame(IFFT *self)
-{
- (*self->proc_func_ptr)(self);
+{
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -717,7 +717,7 @@ IFFT_traverse(IFFT *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
IFFT_clear(IFFT *self)
{
pyo_CLEAR
@@ -780,7 +780,7 @@ IFFT_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_INCREF(inreal_streamtmp);
Py_XDECREF(self->inreal_stream);
self->inreal_stream = (Stream *)inreal_streamtmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -788,22 +788,22 @@ IFFT_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
- IFFT_realloc_memories(self);
+ IFFT_realloc_memories(self);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * IFFT_getServer(IFFT* self) { GET_SERVER };
static PyObject * IFFT_getStream(IFFT* self) { GET_STREAM };
-static PyObject * IFFT_setMul(IFFT *self, PyObject *arg) { SET_MUL };
-static PyObject * IFFT_setAdd(IFFT *self, PyObject *arg) { SET_ADD };
-static PyObject * IFFT_setSub(IFFT *self, PyObject *arg) { SET_SUB };
-static PyObject * IFFT_setDiv(IFFT *self, PyObject *arg) { SET_DIV };
+static PyObject * IFFT_setMul(IFFT *self, PyObject *arg) { SET_MUL };
+static PyObject * IFFT_setAdd(IFFT *self, PyObject *arg) { SET_ADD };
+static PyObject * IFFT_setSub(IFFT *self, PyObject *arg) { SET_SUB };
+static PyObject * IFFT_setDiv(IFFT *self, PyObject *arg) { SET_DIV };
static PyObject * IFFT_play(IFFT *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * IFFT_out(IFFT *self, PyObject *args, PyObject *kwds) { OUT };
@@ -821,7 +821,7 @@ static PyObject * IFFT_inplace_div(IFFT *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
IFFT_setSize(IFFT *self, PyObject *args, PyObject *kwds)
{
- int size, hopsize;
+ int size, hopsize;
static char *kwlist[] = {"size", "hopsize", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwlist, &size, &hopsize)) {
@@ -836,19 +836,19 @@ IFFT_setSize(IFFT *self, PyObject *args, PyObject *kwds)
}
else
printf("IFFT size must be a power of two!\n");
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
IFFT_setWinType(IFFT *self, PyObject *arg)
-{
+{
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->wintype = PyLong_AsLong(arg);
gen_window(self->window, self->size, self->wintype);
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1005,35 +1005,35 @@ CarToPol_setProcMode(CarToPol *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = CarToPol_generate;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = CarToPol_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = CarToPol_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = CarToPol_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = CarToPol_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = CarToPol_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = CarToPol_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = CarToPol_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = CarToPol_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = CarToPol_postprocessing_revareva;
break;
}
@@ -1042,7 +1042,7 @@ CarToPol_setProcMode(CarToPol *self)
static void
CarToPol_compute_next_data_frame(CarToPol *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1057,7 +1057,7 @@ CarToPol_traverse(CarToPol *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
CarToPol_clear(CarToPol *self)
{
pyo_CLEAR
@@ -1083,49 +1083,49 @@ CarToPol_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *input2tmp, *input2_streamtmp, *multmp=NULL, *addtmp=NULL;
CarToPol *self;
self = (CarToPol *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, CarToPol_compute_next_data_frame);
self->mode_func_ptr = CarToPol_setProcMode;
static char *kwlist[] = {"input", "input2", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOi|OO", kwlist, &inputtmp, &input2tmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
Py_XDECREF(self->input2);
self->input2 = input2tmp;
input2_streamtmp = PyObject_CallMethod((PyObject *)self->input2, "_getStream", NULL);
Py_INCREF(input2_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (Stream *)input2_streamtmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * CarToPol_getServer(CarToPol* self) { GET_SERVER };
static PyObject * CarToPol_getStream(CarToPol* self) { GET_STREAM };
-static PyObject * CarToPol_setMul(CarToPol *self, PyObject *arg) { SET_MUL };
-static PyObject * CarToPol_setAdd(CarToPol *self, PyObject *arg) { SET_ADD };
-static PyObject * CarToPol_setSub(CarToPol *self, PyObject *arg) { SET_SUB };
-static PyObject * CarToPol_setDiv(CarToPol *self, PyObject *arg) { SET_DIV };
+static PyObject * CarToPol_setMul(CarToPol *self, PyObject *arg) { SET_MUL };
+static PyObject * CarToPol_setAdd(CarToPol *self, PyObject *arg) { SET_ADD };
+static PyObject * CarToPol_setSub(CarToPol *self, PyObject *arg) { SET_SUB };
+static PyObject * CarToPol_setDiv(CarToPol *self, PyObject *arg) { SET_DIV };
static PyObject * CarToPol_play(CarToPol *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * CarToPol_stop(CarToPol *self) { STOP };
@@ -1260,7 +1260,7 @@ PolToCar_generate(PolToCar *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
if (self->chnl == 0) {
for (i=0; i<self->bufsize; i++) {
self->data[i] = in[i] * MYCOS(in2[i]);
@@ -1288,35 +1288,35 @@ PolToCar_setProcMode(PolToCar *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = PolToCar_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = PolToCar_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = PolToCar_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = PolToCar_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = PolToCar_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = PolToCar_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = PolToCar_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = PolToCar_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = PolToCar_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = PolToCar_postprocessing_revareva;
break;
}
@@ -1325,7 +1325,7 @@ PolToCar_setProcMode(PolToCar *self)
static void
PolToCar_compute_next_data_frame(PolToCar *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1340,7 +1340,7 @@ PolToCar_traverse(PolToCar *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PolToCar_clear(PolToCar *self)
{
pyo_CLEAR
@@ -1366,49 +1366,49 @@ PolToCar_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *input2tmp, *input2_streamtmp, *multmp=NULL, *addtmp=NULL;
PolToCar *self;
self = (PolToCar *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, PolToCar_compute_next_data_frame);
self->mode_func_ptr = PolToCar_setProcMode;
static char *kwlist[] = {"input", "input2", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOi|OO", kwlist, &inputtmp, &input2tmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
Py_XDECREF(self->input2);
self->input2 = input2tmp;
input2_streamtmp = PyObject_CallMethod((PyObject *)self->input2, "_getStream", NULL);
Py_INCREF(input2_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (Stream *)input2_streamtmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * PolToCar_getServer(PolToCar* self) { GET_SERVER };
static PyObject * PolToCar_getStream(PolToCar* self) { GET_STREAM };
-static PyObject * PolToCar_setMul(PolToCar *self, PyObject *arg) { SET_MUL };
-static PyObject * PolToCar_setAdd(PolToCar *self, PyObject *arg) { SET_ADD };
-static PyObject * PolToCar_setSub(PolToCar *self, PyObject *arg) { SET_SUB };
-static PyObject * PolToCar_setDiv(PolToCar *self, PyObject *arg) { SET_DIV };
+static PyObject * PolToCar_setMul(PolToCar *self, PyObject *arg) { SET_MUL };
+static PyObject * PolToCar_setAdd(PolToCar *self, PyObject *arg) { SET_ADD };
+static PyObject * PolToCar_setSub(PolToCar *self, PyObject *arg) { SET_SUB };
+static PyObject * PolToCar_setDiv(PolToCar *self, PyObject *arg) { SET_DIV };
static PyObject * PolToCar_play(PolToCar *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * PolToCar_stop(PolToCar *self) { STOP };
@@ -1530,10 +1530,10 @@ PyTypeObject PolToCarType = {
typedef struct {
pyo_audio_HEAD
- PyObject *input;
+ PyObject *input;
int inputSize;
int modebuffer[2];
- int frameSize;
+ int frameSize;
int overlaps;
int hopsize;
int count;
@@ -1552,7 +1552,7 @@ FrameDeltaMain_generate(FrameDeltaMain *self) {
for (i=0; i<self->bufsize; i++) {
ins[j][i] = in[i];
}
- }
+ }
for (i=0; i<self->bufsize; i++) {
for (j=0; j<self->overlaps; j++) {
curPhase = ins[j][i];
@@ -1570,7 +1570,7 @@ FrameDeltaMain_generate(FrameDeltaMain *self) {
while (diff > PI) {
diff -= TWOPI;
}
- self->frameBuffer[j][self->count] = curPhase;
+ self->frameBuffer[j][self->count] = curPhase;
self->buffer_streams[i+j*self->bufsize] = diff;
}
self->count++;
@@ -1583,18 +1583,18 @@ MYFLT *
FrameDeltaMain_getSamplesBuffer(FrameDeltaMain *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
FrameDeltaMain_setProcMode(FrameDeltaMain *self)
-{
+{
self->proc_func_ptr = FrameDeltaMain_generate;
}
static void
FrameDeltaMain_compute_next_data_frame(FrameDeltaMain *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -1605,7 +1605,7 @@ FrameDeltaMain_traverse(FrameDeltaMain *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
FrameDeltaMain_clear(FrameDeltaMain *self)
{
pyo_CLEAR
@@ -1634,24 +1634,24 @@ FrameDeltaMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp;
FrameDeltaMain *self;
self = (FrameDeltaMain *)type->tp_alloc(type, 0);
-
+
self->count = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, FrameDeltaMain_compute_next_data_frame);
self->mode_func_ptr = FrameDeltaMain_setProcMode;
static char *kwlist[] = {"input", "frameSize", "overlaps", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oii", kwlist, &inputtmp, &self->frameSize, &self->overlaps))
Py_RETURN_NONE;
-
+
if (inputtmp) {
PyObject_CallMethod((PyObject *)self, "setInput", "O", inputtmp);
}
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->hopsize = self->frameSize / self->overlaps;
self->frameBuffer = (MYFLT **)realloc(self->frameBuffer, self->overlaps * sizeof(MYFLT *));
for(i=0; i<self->overlaps; i++) {
@@ -1666,7 +1666,7 @@ FrameDeltaMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -1680,29 +1680,29 @@ static PyObject *
FrameDeltaMain_setInput(FrameDeltaMain *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The inputs attribute must be a list.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
self->inputSize = PyList_Size(tmp);
Py_INCREF(tmp);
Py_XDECREF(self->input);
self->input = tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
FrameDeltaMain_setFrameSize(FrameDeltaMain *self, PyObject *arg)
-{
+{
int i, j, tmp;
- if (PyInt_Check(arg)) {
+ if (PyInt_Check(arg)) {
tmp = PyLong_AsLong(arg);
if (isPowerOfTwo(tmp)) {
self->frameSize = tmp;
@@ -1721,7 +1721,7 @@ FrameDeltaMain_setFrameSize(FrameDeltaMain *self, PyObject *arg)
}
else
printf("frameSize must be a power of two!\n");
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1810,33 +1810,33 @@ FrameDelta_setProcMode(FrameDelta *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = FrameDelta_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = FrameDelta_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = FrameDelta_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = FrameDelta_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = FrameDelta_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = FrameDelta_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = FrameDelta_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = FrameDelta_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = FrameDelta_postprocessing_revareva;
break;
}
@@ -1851,7 +1851,7 @@ FrameDelta_compute_next_data_frame(FrameDelta *self)
tmp = FrameDeltaMain_getSamplesBuffer((FrameDeltaMain *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -1863,11 +1863,11 @@ FrameDelta_traverse(FrameDelta *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
FrameDelta_clear(FrameDelta *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -1886,44 +1886,44 @@ FrameDelta_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
FrameDelta *self;
self = (FrameDelta *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, FrameDelta_compute_next_data_frame);
self->mode_func_ptr = FrameDelta_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (FrameDeltaMain *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * FrameDelta_getServer(FrameDelta* self) { GET_SERVER };
static PyObject * FrameDelta_getStream(FrameDelta* self) { GET_STREAM };
-static PyObject * FrameDelta_setMul(FrameDelta *self, PyObject *arg) { SET_MUL };
-static PyObject * FrameDelta_setAdd(FrameDelta *self, PyObject *arg) { SET_ADD };
-static PyObject * FrameDelta_setSub(FrameDelta *self, PyObject *arg) { SET_SUB };
-static PyObject * FrameDelta_setDiv(FrameDelta *self, PyObject *arg) { SET_DIV };
+static PyObject * FrameDelta_setMul(FrameDelta *self, PyObject *arg) { SET_MUL };
+static PyObject * FrameDelta_setAdd(FrameDelta *self, PyObject *arg) { SET_ADD };
+static PyObject * FrameDelta_setSub(FrameDelta *self, PyObject *arg) { SET_SUB };
+static PyObject * FrameDelta_setDiv(FrameDelta *self, PyObject *arg) { SET_DIV };
static PyObject * FrameDelta_play(FrameDelta *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * FrameDelta_out(FrameDelta *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2045,10 +2045,10 @@ PyTypeObject FrameDeltaType = {
typedef struct {
pyo_audio_HEAD
- PyObject *input;
+ PyObject *input;
int inputSize;
int modebuffer[2];
- int frameSize;
+ int frameSize;
int overlaps;
int hopsize;
int count;
@@ -2060,14 +2060,14 @@ static void
FrameAccumMain_generate(FrameAccumMain *self) {
int i, j, which, where;
MYFLT curPhase, lastPhase, diff;
-
+
MYFLT ins[self->overlaps][self->bufsize];
for (j=0; j<self->overlaps; j++) {
MYFLT *in = Stream_getData((Stream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->input, j), "_getStream", NULL));
for (i=0; i<self->bufsize; i++) {
ins[j][i] = in[i];
}
- }
+ }
for (i=0; i<self->bufsize; i++) {
for (j=0; j<self->overlaps; j++) {
curPhase = ins[j][i];
@@ -2079,7 +2079,7 @@ FrameAccumMain_generate(FrameAccumMain *self) {
where += self->frameSize;
lastPhase = self->frameBuffer[which][where];
diff = curPhase + lastPhase;
- self->frameBuffer[j][self->count] = diff;
+ self->frameBuffer[j][self->count] = diff;
self->buffer_streams[i+j*self->bufsize] = diff;
}
self->count++;
@@ -2092,18 +2092,18 @@ MYFLT *
FrameAccumMain_getSamplesBuffer(FrameAccumMain *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
FrameAccumMain_setProcMode(FrameAccumMain *self)
-{
+{
self->proc_func_ptr = FrameAccumMain_generate;
}
static void
FrameAccumMain_compute_next_data_frame(FrameAccumMain *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -2114,7 +2114,7 @@ FrameAccumMain_traverse(FrameAccumMain *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
FrameAccumMain_clear(FrameAccumMain *self)
{
pyo_CLEAR
@@ -2143,24 +2143,24 @@ FrameAccumMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp;
FrameAccumMain *self;
self = (FrameAccumMain *)type->tp_alloc(type, 0);
-
+
self->count = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, FrameAccumMain_compute_next_data_frame);
self->mode_func_ptr = FrameAccumMain_setProcMode;
static char *kwlist[] = {"input", "framesize", "overlaps", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oii", kwlist, &inputtmp, &self->frameSize, &self->overlaps))
Py_RETURN_NONE;
-
+
if (inputtmp) {
PyObject_CallMethod((PyObject *)self, "setInput", "O", inputtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->hopsize = self->frameSize / self->overlaps;
self->frameBuffer = (MYFLT **)realloc(self->frameBuffer, self->overlaps * sizeof(MYFLT *));
for(i=0; i<self->overlaps; i++) {
@@ -2173,9 +2173,9 @@ FrameAccumMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<(self->overlaps*self->bufsize); i++) {
self->buffer_streams[i] = 0.0;
}
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -2189,34 +2189,34 @@ static PyObject *
FrameAccumMain_setInput(FrameAccumMain *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The inputs attribute must be a list.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
self->inputSize = PyList_Size(tmp);
Py_INCREF(tmp);
Py_XDECREF(self->input);
self->input = tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
FrameAccumMain_setFrameSize(FrameAccumMain *self, PyObject *arg)
-{
+{
int i, j, tmp;
-
- if (PyInt_Check(arg)) {
+
+ if (PyInt_Check(arg)) {
tmp = PyLong_AsLong(arg);
if (isPowerOfTwo(tmp)) {
self->frameSize = tmp;
self->hopsize = self->frameSize / self->overlaps;
-
+
self->frameBuffer = (MYFLT **)realloc(self->frameBuffer, self->overlaps * sizeof(MYFLT *));
for(i=0; i<self->overlaps; i++) {
self->frameBuffer[i] = (MYFLT *)malloc(self->frameSize * sizeof(MYFLT));
@@ -2224,13 +2224,13 @@ FrameAccumMain_setFrameSize(FrameAccumMain *self, PyObject *arg)
self->frameBuffer[i][j] = 0.0;
}
}
-
+
self->count = 0;
}
}
else
printf("frameSize must be a power of two!\n");
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2319,33 +2319,33 @@ FrameAccum_setProcMode(FrameAccum *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = FrameAccum_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = FrameAccum_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = FrameAccum_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = FrameAccum_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = FrameAccum_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = FrameAccum_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = FrameAccum_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = FrameAccum_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = FrameAccum_postprocessing_revareva;
break;
}
@@ -2360,7 +2360,7 @@ FrameAccum_compute_next_data_frame(FrameAccum *self)
tmp = FrameAccumMain_getSamplesBuffer((FrameAccumMain *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -2372,11 +2372,11 @@ FrameAccum_traverse(FrameAccum *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
FrameAccum_clear(FrameAccum *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -2395,44 +2395,44 @@ FrameAccum_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
FrameAccum *self;
self = (FrameAccum *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, FrameAccum_compute_next_data_frame);
self->mode_func_ptr = FrameAccum_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (FrameAccumMain *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * FrameAccum_getServer(FrameAccum* self) { GET_SERVER };
static PyObject * FrameAccum_getStream(FrameAccum* self) { GET_STREAM };
-static PyObject * FrameAccum_setMul(FrameAccum *self, PyObject *arg) { SET_MUL };
-static PyObject * FrameAccum_setAdd(FrameAccum *self, PyObject *arg) { SET_ADD };
-static PyObject * FrameAccum_setSub(FrameAccum *self, PyObject *arg) { SET_SUB };
-static PyObject * FrameAccum_setDiv(FrameAccum *self, PyObject *arg) { SET_DIV };
+static PyObject * FrameAccum_setMul(FrameAccum *self, PyObject *arg) { SET_MUL };
+static PyObject * FrameAccum_setAdd(FrameAccum *self, PyObject *arg) { SET_ADD };
+static PyObject * FrameAccum_setSub(FrameAccum *self, PyObject *arg) { SET_SUB };
+static PyObject * FrameAccum_setDiv(FrameAccum *self, PyObject *arg) { SET_DIV };
static PyObject * FrameAccum_play(FrameAccum *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * FrameAccum_out(FrameAccum *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2554,7 +2554,7 @@ PyTypeObject FrameAccumType = {
typedef struct {
pyo_audio_HEAD
- PyObject *input;
+ PyObject *input;
PyObject *up;
Stream *up_stream;
PyObject *down;
@@ -2563,7 +2563,7 @@ typedef struct {
Stream *damp_stream;
int inputSize;
int modebuffer[5];
- int frameSize;
+ int frameSize;
int overlaps;
int hopsize;
int count;
@@ -2575,9 +2575,9 @@ static void
VectralMain_generate(VectralMain *self) {
int i, j, which, where, bin, halfSize;
MYFLT curMag, lastMag, diff, slope, up, down, damp;
-
+
halfSize = self->frameSize / 2;
-
+
if (self->modebuffer[2] == 0)
up = PyFloat_AS_DOUBLE(self->up);
else
@@ -2607,14 +2607,14 @@ VectralMain_generate(VectralMain *self) {
else if (damp > 1.0)
damp = 1.0;
damp = damp * 0.1 + 0.9;
-
+
MYFLT ins[self->overlaps][self->bufsize];
for (j=0; j<self->overlaps; j++) {
MYFLT *in = Stream_getData((Stream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->input, j), "_getStream", NULL));
for (i=0; i<self->bufsize; i++) {
ins[j][i] = in[i];
}
- }
+ }
for (i=0; i<self->bufsize; i++) {
for (j=0; j<self->overlaps; j++) {
which = j - 1;
@@ -2634,7 +2634,7 @@ VectralMain_generate(VectralMain *self) {
curMag = curMag * down + lastMag * (1.0 - down);
else if (diff >= 0.0)
curMag = curMag * up + lastMag * (1.0 - up);
- self->frameBuffer[j][self->count] = curMag;
+ self->frameBuffer[j][self->count] = curMag;
self->buffer_streams[i+j*self->bufsize] = curMag;
}
self->count++;
@@ -2647,18 +2647,18 @@ MYFLT *
VectralMain_getSamplesBuffer(VectralMain *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
VectralMain_setProcMode(VectralMain *self)
-{
+{
self->proc_func_ptr = VectralMain_generate;
}
static void
VectralMain_compute_next_data_frame(VectralMain *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -2666,26 +2666,26 @@ VectralMain_traverse(VectralMain *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->up);
- Py_VISIT(self->up_stream);
- Py_VISIT(self->down);
- Py_VISIT(self->down_stream);
- Py_VISIT(self->damp);
- Py_VISIT(self->damp_stream);
+ Py_VISIT(self->up);
+ Py_VISIT(self->up_stream);
+ Py_VISIT(self->down);
+ Py_VISIT(self->down_stream);
+ Py_VISIT(self->damp);
+ Py_VISIT(self->damp_stream);
return 0;
}
-static int
+static int
VectralMain_clear(VectralMain *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->up);
- Py_CLEAR(self->up_stream);
- Py_CLEAR(self->down);
- Py_CLEAR(self->down_stream);
- Py_CLEAR(self->damp);
- Py_CLEAR(self->damp_stream);
+ Py_CLEAR(self->up);
+ Py_CLEAR(self->up_stream);
+ Py_CLEAR(self->down);
+ Py_CLEAR(self->down_stream);
+ Py_CLEAR(self->damp);
+ Py_CLEAR(self->damp_stream);
return 0;
}
@@ -2710,7 +2710,7 @@ VectralMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *uptmp=NULL, *downtmp=NULL, *damptmp=NULL;
VectralMain *self;
self = (VectralMain *)type->tp_alloc(type, 0);
-
+
self->up = PyFloat_FromDouble(1.0);
self->down = PyFloat_FromDouble(0.7);
self->damp = PyFloat_FromDouble(0.9);
@@ -2720,16 +2720,16 @@ VectralMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, VectralMain_compute_next_data_frame);
self->mode_func_ptr = VectralMain_setProcMode;
static char *kwlist[] = {"input", "frameSize", "overlaps", "up", "down", "damp", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oii|OOO", kwlist, &inputtmp, &self->frameSize, &self->overlaps, &uptmp, &downtmp, &damptmp))
Py_RETURN_NONE;
-
+
if (inputtmp) {
PyObject_CallMethod((PyObject *)self, "setInput", "O", inputtmp);
}
@@ -2745,9 +2745,9 @@ VectralMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (damptmp) {
PyObject_CallMethod((PyObject *)self, "setDamp", "O", damptmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->hopsize = self->frameSize / self->overlaps;
self->frameBuffer = (MYFLT **)realloc(self->frameBuffer, self->overlaps * sizeof(MYFLT *));
for(i=0; i<self->overlaps; i++) {
@@ -2760,9 +2760,9 @@ VectralMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<(self->overlaps*self->bufsize); i++) {
self->buffer_streams[i] = 0.0;
}
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -2776,29 +2776,29 @@ static PyObject *
VectralMain_setInput(VectralMain *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The inputs attribute must be a list.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
self->inputSize = PyList_Size(tmp);
Py_INCREF(tmp);
Py_XDECREF(self->input);
self->input = tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
VectralMain_setFrameSize(VectralMain *self, PyObject *arg)
-{
+{
int i, j, tmp;
-
- if (PyInt_Check(arg)) {
+
+ if (PyInt_Check(arg)) {
tmp = PyLong_AsLong(arg);
if (isPowerOfTwo(tmp)) {
self->frameSize = tmp;
@@ -2811,13 +2811,13 @@ VectralMain_setFrameSize(VectralMain *self, PyObject *arg)
self->frameBuffer[i][j] = 0.0;
}
}
-
+
self->count = 0;
}
}
else
printf("frameSize must be a power of two!\n");
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2826,14 +2826,14 @@ static PyObject *
VectralMain_setUp(VectralMain *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->up);
@@ -2849,23 +2849,23 @@ VectralMain_setUp(VectralMain *self, PyObject *arg)
self->up_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
VectralMain_setDown(VectralMain *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->down);
@@ -2881,23 +2881,23 @@ VectralMain_setDown(VectralMain *self, PyObject *arg)
self->down_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
VectralMain_setDamp(VectralMain *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->damp);
@@ -2913,10 +2913,10 @@ VectralMain_setDamp(VectralMain *self, PyObject *arg)
self->damp_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef VectralMain_members[] = {
{"server", T_OBJECT_EX, offsetof(VectralMain, server), 0, "Pyo server."},
@@ -3005,33 +3005,33 @@ Vectral_setProcMode(Vectral *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Vectral_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Vectral_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Vectral_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Vectral_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Vectral_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Vectral_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Vectral_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Vectral_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Vectral_postprocessing_revareva;
break;
}
@@ -3046,7 +3046,7 @@ Vectral_compute_next_data_frame(Vectral *self)
tmp = VectralMain_getSamplesBuffer((VectralMain *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -3058,11 +3058,11 @@ Vectral_traverse(Vectral *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Vectral_clear(Vectral *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -3081,44 +3081,44 @@ Vectral_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
Vectral *self;
self = (Vectral *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Vectral_compute_next_data_frame);
self->mode_func_ptr = Vectral_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (VectralMain *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Vectral_getServer(Vectral* self) { GET_SERVER };
static PyObject * Vectral_getStream(Vectral* self) { GET_STREAM };
-static PyObject * Vectral_setMul(Vectral *self, PyObject *arg) { SET_MUL };
-static PyObject * Vectral_setAdd(Vectral *self, PyObject *arg) { SET_ADD };
-static PyObject * Vectral_setSub(Vectral *self, PyObject *arg) { SET_SUB };
-static PyObject * Vectral_setDiv(Vectral *self, PyObject *arg) { SET_DIV };
+static PyObject * Vectral_setMul(Vectral *self, PyObject *arg) { SET_MUL };
+static PyObject * Vectral_setAdd(Vectral *self, PyObject *arg) { SET_ADD };
+static PyObject * Vectral_setSub(Vectral *self, PyObject *arg) { SET_SUB };
+static PyObject * Vectral_setDiv(Vectral *self, PyObject *arg) { SET_DIV };
static PyObject * Vectral_play(Vectral *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Vectral_out(Vectral *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3274,13 +3274,13 @@ CvlVerb_alloc_memories(CvlVerb *self) {
self->hsize = self->size / 2;
self->size2 = self->size * 2;
n8 = self->size2 >> 3;
- self->real = (MYFLT *)realloc(self->real, self->size * sizeof(MYFLT));
- self->imag = (MYFLT *)realloc(self->imag, self->size * sizeof(MYFLT));
+ self->real = (MYFLT *)realloc(self->real, self->size * sizeof(MYFLT));
+ self->imag = (MYFLT *)realloc(self->imag, self->size * sizeof(MYFLT));
self->inframe = (MYFLT *)realloc(self->inframe, self->size2 * sizeof(MYFLT));
- self->outframe = (MYFLT *)realloc(self->outframe, self->size2 * sizeof(MYFLT));
- self->last_half_frame = (MYFLT *)realloc(self->last_half_frame, self->size * sizeof(MYFLT));
- self->input_buffer = (MYFLT *)realloc(self->output_buffer, self->size * sizeof(MYFLT));
- self->output_buffer = (MYFLT *)realloc(self->output_buffer, self->size2 * sizeof(MYFLT));
+ self->outframe = (MYFLT *)realloc(self->outframe, self->size2 * sizeof(MYFLT));
+ self->last_half_frame = (MYFLT *)realloc(self->last_half_frame, self->size * sizeof(MYFLT));
+ self->input_buffer = (MYFLT *)realloc(self->input_buffer, self->size * sizeof(MYFLT));
+ self->output_buffer = (MYFLT *)realloc(self->output_buffer, self->size2 * sizeof(MYFLT));
for (i=0; i<self->size2; i++)
self->inframe[i] = self->outframe[i] = self->output_buffer[i] = 0.0;
for (i=0; i<self->size; i++)
@@ -3308,7 +3308,7 @@ CvlVerb_analyse_impulse(CvlVerb *self) {
snd_sr = info.samplerate;
snd_chnls = info.channels;
num_items = snd_size * snd_chnls;
-
+
if (snd_sr != self->sr) {
printf("CvlVerb warning : Impulse sampling rate does't match the sampling rate of the server.\n");
}
@@ -3331,8 +3331,8 @@ CvlVerb_analyse_impulse(CvlVerb *self) {
self->impulse_real = (MYFLT **)realloc(self->impulse_real, self->num_iter * sizeof(MYFLT *));
self->impulse_imag = (MYFLT **)realloc(self->impulse_imag, self->num_iter * sizeof(MYFLT *));
- self->accum_real = (MYFLT **)realloc(self->accum_real, self->num_iter * sizeof(MYFLT *));
- self->accum_imag = (MYFLT **)realloc(self->accum_imag, self->num_iter * sizeof(MYFLT *));
+ self->accum_real = (MYFLT **)realloc(self->accum_real, self->num_iter * sizeof(MYFLT *));
+ self->accum_imag = (MYFLT **)realloc(self->accum_imag, self->num_iter * sizeof(MYFLT *));
for(i=0; i<self->num_iter; i++) {
self->impulse_real[i] = (MYFLT *)malloc(self->size * sizeof(MYFLT));
self->impulse_imag[i] = (MYFLT *)malloc(self->size * sizeof(MYFLT));
@@ -3346,7 +3346,7 @@ CvlVerb_analyse_impulse(CvlVerb *self) {
inframe = (MYFLT *)malloc(self->size2 * sizeof(MYFLT));
outframe = (MYFLT *)malloc(self->size2 * sizeof(MYFLT));
-
+
for (j=0; j<self->num_iter; j++) {
num = j * self->size;
for (i=0; i<self->size; i++) {
@@ -3354,7 +3354,7 @@ CvlVerb_analyse_impulse(CvlVerb *self) {
}
for (i=self->size; i<self->size2; i++) {
inframe[i] = 0.0;
- }
+ }
realfft_split(inframe, outframe, self->size2, self->twiddle);
self->impulse_real[j][0] = outframe[0];
self->impulse_imag[j][0] = 0.0;
@@ -3363,7 +3363,7 @@ CvlVerb_analyse_impulse(CvlVerb *self) {
self->impulse_imag[j][i] = outframe[self->size2 - i];
}
}
-
+
free(tmp);
free(tmp2);
free(inframe);
@@ -3385,11 +3385,11 @@ CvlVerb_process_i(CvlVerb *self) {
for (i=0; i<self->bufsize; i++) {
self->input_buffer[self->incount] = in[i];
self->data[i] = (self->output_buffer[self->incount] * 100 * bal) + (in[i] * gdry);
-
+
self->incount++;
if (self->incount == self->size) {
self->incount = 0;
-
+
k = self->current_iter - 1;
if (k < 0)
k += self->num_iter;
@@ -3430,7 +3430,7 @@ CvlVerb_process_i(CvlVerb *self) {
if (self->current_iter == self->num_iter)
self->current_iter = 0;
}
- }
+ }
}
static void
@@ -3449,11 +3449,11 @@ CvlVerb_process_a(CvlVerb *self) {
gdry = 1.0 - gwet;
self->input_buffer[self->incount] = in[i];
self->data[i] = (self->output_buffer[self->incount] * 100 * gwet) + in[i] * gdry;
-
+
self->incount++;
if (self->incount == self->size) {
self->incount = 0;
-
+
k = self->current_iter - 1;
if (k < 0)
k += self->num_iter;
@@ -3494,7 +3494,7 @@ CvlVerb_process_a(CvlVerb *self) {
if (self->current_iter == self->num_iter)
self->current_iter = 0;
}
- }
+ }
}
static void CvlVerb_postprocessing_ii(CvlVerb *self) { POST_PROCESSING_II };
@@ -3509,46 +3509,46 @@ static void CvlVerb_postprocessing_revareva(CvlVerb *self) { POST_PROCESSING_REV
static void
CvlVerb_setProcMode(CvlVerb *self)
-{
+{
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = CvlVerb_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = CvlVerb_process_a;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = CvlVerb_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = CvlVerb_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = CvlVerb_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = CvlVerb_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = CvlVerb_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = CvlVerb_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = CvlVerb_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = CvlVerb_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = CvlVerb_postprocessing_revareva;
break;
}
@@ -3557,7 +3557,7 @@ CvlVerb_setProcMode(CvlVerb *self)
static void
CvlVerb_compute_next_data_frame(CvlVerb *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3572,7 +3572,7 @@ CvlVerb_traverse(CvlVerb *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
CvlVerb_clear(CvlVerb *self)
{
pyo_CLEAR
@@ -3602,7 +3602,7 @@ CvlVerb_dealloc(CvlVerb* self)
free(self->impulse_imag[i]);
free(self->accum_real[i]);
free(self->accum_imag[i]);
- }
+ }
free(self->impulse_real);
free(self->impulse_imag);
free(self->accum_real);
@@ -3620,7 +3620,7 @@ CvlVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *baltmp=NULL, *multmp=NULL, *addtmp=NULL;
CvlVerb *self;
self = (CvlVerb *)type->tp_alloc(type, 0);
-
+
self->bal = PyFloat_FromDouble(0.25);
self->size = 1024;
self->chnl = 0;
@@ -3631,7 +3631,7 @@ CvlVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = CvlVerb_setProcMode;
static char *kwlist[] = {"input", "impulse", "bal", "size", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|OiiOO", kwlist, &inputtmp, &self->impulse_path, &baltmp, &self->size, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
@@ -3639,7 +3639,7 @@ CvlVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
printf("Warning : CvlVerb size less than buffer size!\nCvlVerb size set to buffersize: %d\n", self->bufsize);
self->size = self->bufsize;
}
-
+
k = 1;
while (k < self->size)
k <<= 1;
@@ -3654,13 +3654,13 @@ CvlVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
CvlVerb_alloc_memories(self);
CvlVerb_analyse_impulse(self);
@@ -3673,14 +3673,14 @@ static PyObject *
CvlVerb_setBal(CvlVerb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->bal);
@@ -3698,17 +3698,17 @@ CvlVerb_setBal(CvlVerb *self, PyObject *arg)
}
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject * CvlVerb_getServer(CvlVerb* self) { GET_SERVER };
static PyObject * CvlVerb_getStream(CvlVerb* self) { GET_STREAM };
-static PyObject * CvlVerb_setMul(CvlVerb *self, PyObject *arg) { SET_MUL };
-static PyObject * CvlVerb_setAdd(CvlVerb *self, PyObject *arg) { SET_ADD };
-static PyObject * CvlVerb_setSub(CvlVerb *self, PyObject *arg) { SET_SUB };
-static PyObject * CvlVerb_setDiv(CvlVerb *self, PyObject *arg) { SET_DIV };
+static PyObject * CvlVerb_setMul(CvlVerb *self, PyObject *arg) { SET_MUL };
+static PyObject * CvlVerb_setAdd(CvlVerb *self, PyObject *arg) { SET_ADD };
+static PyObject * CvlVerb_setSub(CvlVerb *self, PyObject *arg) { SET_SUB };
+static PyObject * CvlVerb_setDiv(CvlVerb *self, PyObject *arg) { SET_DIV };
static PyObject * CvlVerb_play(CvlVerb *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * CvlVerb_out(CvlVerb *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3852,9 +3852,9 @@ typedef struct {
MYFLT *input_buffer;
MYFLT *inframe;
MYFLT *outframe;
- MYFLT *magnitude;
- MYFLT *last_magnitude;
- MYFLT *tmpmag;
+ MYFLT *magnitude;
+ MYFLT *last_magnitude;
+ MYFLT *tmpmag;
MYFLT *window;
MYFLT **twiddle;
} Spectrum;
@@ -3866,12 +3866,12 @@ Spectrum_realloc_memories(Spectrum *self) {
n8 = self->size >> 3;
self->input_buffer = (MYFLT *)realloc(self->input_buffer, self->size * sizeof(MYFLT));
self->inframe = (MYFLT *)realloc(self->inframe, self->size * sizeof(MYFLT));
- self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
+ self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
for (i=0; i<self->size; i++)
self->input_buffer[i] = self->inframe[i] = self->outframe[i] = 0.0;
- self->magnitude = (MYFLT *)realloc(self->magnitude, self->hsize * sizeof(MYFLT));
- self->last_magnitude = (MYFLT *)realloc(self->last_magnitude, self->hsize * sizeof(MYFLT));
- self->tmpmag = (MYFLT *)realloc(self->tmpmag, (self->hsize+6) * sizeof(MYFLT));
+ self->magnitude = (MYFLT *)realloc(self->magnitude, self->hsize * sizeof(MYFLT));
+ self->last_magnitude = (MYFLT *)realloc(self->last_magnitude, self->hsize * sizeof(MYFLT));
+ self->tmpmag = (MYFLT *)realloc(self->tmpmag, (self->hsize+6) * sizeof(MYFLT));
for (i=0; i<self->hsize; i++)
self->magnitude[i] = self->last_magnitude[i] = self->tmpmag[i+3] = 0.0;
self->twiddle = (MYFLT **)realloc(self->twiddle, 4 * sizeof(MYFLT *));
@@ -3890,7 +3890,7 @@ Spectrum_display(Spectrum *self) {
MYFLT pos, step, frac, iw, mag, h4;
MYFLT logmin, logrange;
PyObject *points, *tuple;
-
+
b1 = (int)(self->freqone / self->freqPerBin);
b2 = (int)(self->freqtwo / self->freqPerBin);
bins = b2 - b1;
@@ -3928,7 +3928,7 @@ Spectrum_display(Spectrum *self) {
tuple = PyTuple_New(2);
mag = ((self->magnitude[p1] + (self->magnitude[p1+1] - self->magnitude[p1]) * frac) * 0.7 * self->gain);
mag = mag > 0.001 ? mag : 0.001;
- mag = (60.0 + (20.0 * MYLOG10(mag))) * 0.01666 * h4;
+ mag = (60.0 + (20.0 * MYLOG10(mag))) * 0.01666 * h4;
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(i));
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->height - (int)mag));
PyList_SET_ITEM(points, i+1, tuple);
@@ -3962,13 +3962,13 @@ Spectrum_display(Spectrum *self) {
tuple = PyTuple_New(2);
mag = ((self->magnitude[p1] + (self->magnitude[p1+1] - self->magnitude[p1]) * frac) * 0.7 * self->gain);
mag = mag > 0.001 ? mag : 0.001;
- mag = (60.0 + (20.0 * MYLOG10(mag))) * 0.01666 * self->height;
+ mag = (60.0 + (20.0 * MYLOG10(mag))) * 0.01666 * self->height;
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(i));
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->height - (int)mag));
PyList_SET_ITEM(points, i+1, tuple);
}
}
-
+
return points;
}
@@ -3977,7 +3977,7 @@ Spectrum_filters(Spectrum *self) {
int i, j = 0, impos = 0;
MYFLT tmp = 0.0;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->input_buffer[self->incount] = in[i];
self->incount++;
@@ -3996,9 +3996,9 @@ Spectrum_filters(Spectrum *self) {
self->tmpmag[j+3] = self->last_magnitude[j] = tmp + self->last_magnitude[j] * 0.5;
}
for (j=0; j<self->hsize; j++) {
- tmp = (self->tmpmag[j] + self->tmpmag[j+6]) * 0.05 +
- (self->tmpmag[j+1] + self->tmpmag[j+5]) * 0.15 +
- (self->tmpmag[j+2] + self->tmpmag[j+4])* 0.3 +
+ tmp = (self->tmpmag[j] + self->tmpmag[j+6]) * 0.05 +
+ (self->tmpmag[j+1] + self->tmpmag[j+5]) * 0.15 +
+ (self->tmpmag[j+2] + self->tmpmag[j+4])* 0.3 +
self->tmpmag[j+3] * 0.5;
self->magnitude[j] = tmp;
self->input_buffer[j] = self->input_buffer[j+self->hsize];
@@ -4009,14 +4009,14 @@ Spectrum_filters(Spectrum *self) {
static void
Spectrum_setProcMode(Spectrum *self)
-{
- self->proc_func_ptr = Spectrum_filters;
+{
+ self->proc_func_ptr = Spectrum_filters;
}
static void
Spectrum_compute_next_data_frame(Spectrum *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -4028,7 +4028,7 @@ Spectrum_traverse(Spectrum *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Spectrum_clear(Spectrum *self)
{
pyo_CLEAR
@@ -4064,7 +4064,7 @@ Spectrum_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp;
Spectrum *self;
self = (Spectrum *)type->tp_alloc(type, 0);
-
+
self->size = 1024;
self->wintype = 2;
@@ -4078,17 +4078,17 @@ Spectrum_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->height = 400;
self->fscaling = 0;
self->mscaling = 1;
-
+
Stream_setFunctionPtr(self->stream, Spectrum_compute_next_data_frame);
self->mode_func_ptr = Spectrum_setProcMode;
static char *kwlist[] = {"input", "size", "wintype", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|ii", kwlist, &inputtmp, &self->size, &self->wintype))
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
if (!isPowerOfTwo(self->size)) {
@@ -4113,7 +4113,7 @@ static PyObject * Spectrum_stop(Spectrum *self) { STOP };
static PyObject *
Spectrum_setSize(Spectrum *self, PyObject *arg)
-{
+{
int tmp;
if (PyLong_Check(arg) || PyInt_Check(arg)) {
tmp = PyInt_AsLong(arg);
@@ -4123,27 +4123,27 @@ Spectrum_setSize(Spectrum *self, PyObject *arg)
}
else
printf("FFT size must be a power of two!\n");
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
Spectrum_setWinType(Spectrum *self, PyObject *arg)
-{
+{
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->wintype = PyLong_AsLong(arg);
gen_window(self->window, self->size, self->wintype);
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
Spectrum_setLowbound(Spectrum *self, PyObject *arg)
-{
+{
MYFLT tmp;
if (PyNumber_Check(arg)) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
@@ -4151,7 +4151,7 @@ Spectrum_setLowbound(Spectrum *self, PyObject *arg)
self->freqone = tmp * self->sr;
else
self->freqone = 0.0;
- }
+ }
else
self->freqone = 0.0;
@@ -4166,7 +4166,7 @@ Spectrum_getLowfreq(Spectrum *self)
static PyObject *
Spectrum_setHighbound(Spectrum *self, PyObject *arg)
-{
+{
MYFLT tmp;
if (PyNumber_Check(arg)) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
@@ -4177,7 +4177,7 @@ Spectrum_setHighbound(Spectrum *self, PyObject *arg)
}
else
self->freqtwo = self->sr * 0.5;
-
+
return PyFloat_FromDouble(MYFLOOR(self->freqtwo / self->freqPerBin) * self->freqPerBin);
}
@@ -4189,50 +4189,50 @@ Spectrum_getHighfreq(Spectrum *self)
static PyObject *
Spectrum_setWidth(Spectrum *self, PyObject *arg)
-{
+{
if (PyInt_Check(arg) || PyLong_Check(arg))
self->width = PyLong_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
Spectrum_setHeight(Spectrum *self, PyObject *arg)
-{
+{
if (PyInt_Check(arg) || PyLong_Check(arg))
self->height = PyLong_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
Spectrum_setFscaling(Spectrum *self, PyObject *arg)
-{
+{
if (PyInt_Check(arg) || PyLong_Check(arg))
self->fscaling = PyLong_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
Spectrum_setMscaling(Spectrum *self, PyObject *arg)
-{
+{
if (PyInt_Check(arg) || PyLong_Check(arg))
self->mscaling = PyLong_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
Spectrum_setGain(Spectrum *self, PyObject *arg)
-{
+{
if (PyNumber_Check(arg))
self->gain = PyFloat_AsDouble(PyNumber_Float(arg));
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -4304,4 +4304,4 @@ Spectrum_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
Spectrum_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/filtremodule.c b/src/objects/filtremodule.c
index de7c575..5d77198 100644
--- a/src/objects/filtremodule.c
+++ b/src/objects/filtremodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -26,7 +26,7 @@
#include "servermodule.h"
#include "dummymodule.h"
-static MYFLT HALF_COS_ARRAY[513] = {1.0, 0.99998110153278696, 0.99992440684545181, 0.99982991808087995, 0.99969763881045715, 0.99952757403393411, 0.99931973017923825, 0.99907411510222999, 0.99879073808640628, 0.99846960984254973, 0.99811074250832332, 0.99771414964781235, 0.99727984625101107, 0.99680784873325645, 0.99629817493460782, 0.99575084411917214, 0.99516587697437664, 0.99454329561018584, 0.99388312355826691, 0.9931853857710996, 0.99245010862103322, 0.99167731989928998, 0.99086704881491472, 0.99001932599367026, 0.98913418347688054, 0.98821165472021921, 0.9872517745924454, 0.98625457937408512, 0.98522010675606064, 0.98414839583826585, 0.98303948712808786, 0.98189342253887657, 0.98071024538836005, 0.97949000039700762, 0.97823273368633901, 0.9769384927771817, 0.97560732658787452, 0.97423928543241856, 0.97283442101857576, 0.97139278644591409, 0.96991443620380113, 0.96839942616934394, 0.96684781360527761, 0.96525965715780015, 0.96363501685435693, 0.96197395410137099, 0.96027653168192206, 0.95854281375337425, 0.95677286584495025, 0.95496675485525528, 0.95312454904974775, 0.95124631805815985, 0.94933213287186513, 0.94738206584119555, 0.94539619067270686, 0.9433745824263926, 0.94131731751284708, 0.9392244736903772, 0.93709613006206383, 0.9349323670727715, 0.93273326650610799, 0.93049891148133324, 0.92822938645021758, 0.92592477719384991, 0.92358517081939495, 0.92121065575680161, 0.91880132175545981, 0.91635725988080907, 0.91387856251089561, 0.91136532333288145, 0.90881763733950294, 0.9062356008254806, 0.90361931138387919, 0.90096886790241915, 0.89828437055973898, 0.89556592082160869, 0.89281362143709486, 0.89002757643467667, 0.88720789111831455, 0.8843546720634694, 0.88146802711307481, 0.87854806537346075, 0.87559489721022943, 0.8726086342440843, 0.86958938934661101, 0.86653727663601088, 0.86345241147278784, 0.86033491045538835, 0.85718489141579368, 0.85400247341506719, 0.8507877767388532, 0.84754092289283123, 0.8442620345981231, 0.84095123578665476, 0.8376086515964718, 0.83423440836700968, 0.83082863363431847, 0.82739145612624232, 0.82392300575755428, 0.82042341362504534, 0.81689281200256991, 0.81333133433604599, 0.80973911523841147, 0.80611629048453592, 0.80246299700608914, 0.79877937288636502, 0.7950655573550629, 0.79132169078302494, 0.78754791467693042, 0.78374437167394739, 0.77991120553634141, 0.77604856114604148, 0.77215658449916424, 0.76823542270049605, 0.76428522395793219, 0.7603061375768756, 0.75629831395459302, 0.75226190457453135, 0.74819706200059122, 0.7441039398713607, 0.73998269289430851, 0.73583347683993672, 0.73165644853589207, 0.72745176586103977, 0.72321958773949491, 0.71896007413461649, 0.71467338604296105, 0.71035968548819706, 0.70601913551498185, 0.70165190018279788, 0.69725814455975277, 0.69283803471633953, 0.68839173771916018, 0.68391942162461061, 0.6794212554725293, 0.67489740927980701, 0.67034805403396192, 0.66577336168667567, 0.66117350514729512, 0.65654865827629605, 0.65189899587871258, 0.64722469369752944, 0.6425259284070397, 0.63780287760616672, 0.63305571981175202, 0.62828463445180749, 0.62348980185873359, 0.61867140326250347, 0.61382962078381298, 0.60896463742719675, 0.60407663707411186, 0.59916580447598711, 0.59423232524724023, 0.58927638585826192, 0.58429817362836856, 0.57929787671872113, 0.57427568412521424, 0.56923178567133192, 0.56416637200097319, 0.55907963457124654, 0.55397176564523298, 0.5488429582847193, 0.5436934063429012, 0.53852330445705543, 0.53333284804118442, 0.52812223327862839, 0.52289165711465235, 0.51764131724900009, 0.51237141212842374, 0.50708214093918114, 0.50177370359950879, 0.49644630075206486, 0.49110013375634509, 0.48573540468107329, 0.48035231629656205, 0.47495107206705045, 0.46953187614301212, 0.46409493335344021, 0.45864044919810504, 0.45316862983978612, 0.44767968209648135, 0.44217381343358825, 0.43665123195606403, 0.43111214640055828, 0.42555676612752463, 0.41998530111330729, 0.41439796194220363, 0.40879495979850627, 0.40317650645851943, 0.39754281428255606, 0.3918940962069094, 0.38623056573580644, 0.38055243693333718, 0.3748599244153632, 0.36915324334140731, 0.36343260940651945, 0.35769823883312568, 0.35195034836285416, 0.34618915524834432, 0.34041487724503472, 0.33462773260293199, 0.32882794005836308, 0.32301571882570607, 0.31719128858910622, 0.31135486949417079, 0.30550668213964982, 0.29964694756909749, 0.29377588726251663, 0.28789372312798917, 0.28200067749328667, 0.27609697309746906, 0.27018283308246382, 0.26425848098463345, 0.25832414072632598, 0.25238003660741054, 0.24642639329680122, 0.24046343582396335, 0.23449138957040974, 0.22851048026118126, 0.22252093395631445, 0.21652297704229864, 0.21051683622351761, 0.20450273851368242, 0.19848091122724945, 0.19245158197082995, 0.18641497863458675, 0.1803713293836198, 0.17432086264934399, 0.16826380712085329, 0.16220039173627876, 0.15613084567413366, 0.1500553983446527, 0.14397427938112045, 0.13788771863119115, 0.13179594614820278, 0.12569919218247999, 0.11959768717263308, 0.11349166173684638, 0.10738134666416307, 0.10126697290576155, 0.095148771566225324, 0.089026973894809708, 0.082901811276699419, 0.076773515224264705, 0.070642317368309157, 0.064508449449316344, 0.058372143308689985, 0.052233630879990445, 0.046093144180169916, 0.039950915300801082, 0.033807176399306589, 0.027662159690182372, 0.021516097436222258, 0.01536922193973846, 0.0092217655337806046, 0.0030739605733557966, -0.0030739605733554522, -0.0092217655337804832, -0.015369221939738116, -0.021516097436222133, -0.027662159690182025, -0.033807176399306464, -0.039950915300800735, -0.046093144180169791, -0.052233630879990098, -0.05837214330868986, -0.064508449449316232, -0.07064231736830906, -0.076773515224264371, -0.082901811276699308, -0.089026973894809375, -0.095148771566225213, -0.10126697290576121, -0.10738134666416296, -0.11349166173684605, -0.11959768717263299, -0.12569919218247966, -0.13179594614820267, -0.13788771863119104, -0.14397427938112034, -0.15005539834465259, -0.15613084567413354, -0.16220039173627843, -0.16826380712085318, -0.17432086264934366, -0.18037132938361969, -0.18641497863458642, -0.19245158197082984, -0.19848091122724912, -0.20450273851368231, -0.21051683622351727, -0.21652297704229853, -0.22252093395631434, -0.22851048026118118, -0.23449138957040966, -0.24046343582396323, -0.24642639329680088, -0.25238003660741043, -0.25832414072632565, -0.26425848098463334, -0.27018283308246349, -0.27609697309746895, -0.28200067749328633, -0.28789372312798905, -0.2937758872625163, -0.29964694756909738, -0.30550668213964971, -0.31135486949417068, -0.31719128858910589, -0.32301571882570601, -0.32882794005836274, -0.33462773260293188, -0.34041487724503444, -0.3461891552483442, -0.35195034836285388, -0.35769823883312557, -0.36343260940651911, -0.3691532433414072, -0.37485992441536287, -0.38055243693333707, -0.38623056573580633, -0.39189409620690935, -0.39754281428255578, -0.40317650645851938, -0.408794959798506, -0.41439796194220352, -0.41998530111330723, -0.42555676612752458, -0.43111214640055795, -0.43665123195606392, -0.44217381343358819, -0.44767968209648107, -0.45316862983978584, -0.45864044919810493, -0.46409493335344015, -0.46953187614301223, -0.47495107206704995, -0.48035231629656183, -0.4857354046810729, -0.49110013375634509, -0.4964463007520647, -0.50177370359950857, -0.5070821409391808, -0.51237141212842352, -0.51764131724899998, -0.52289165711465191, -0.52812223327862795, -0.53333284804118419, -0.53852330445705532, -0.5436934063429012, -0.54884295828471885, -0.55397176564523276, -0.55907963457124621, -0.56416637200097308, -0.5692317856713317, -0.57427568412521401, -0.57929787671872079, -0.58429817362836844, -0.5892763858582617, -0.5942323252472399, -0.59916580447598666, -0.60407663707411174, -0.60896463742719653, -0.61382962078381298, -0.61867140326250303, -0.62348980185873337, -0.62828463445180716, -0.6330557198117519, -0.6378028776061665, -0.64252592840703937, -0.64722469369752911, -0.65189899587871247, -0.65654865827629583, -0.66117350514729478, -0.66577336168667522, -0.67034805403396169, -0.67489740927980679, -0.6794212554725293, -0.68391942162461028, -0.68839173771915996, -0.6928380347163392, -0.69725814455975266, -0.70165190018279777, -0.70601913551498163, -0.71035968548819683, -0.71467338604296105, -0.71896007413461638, -0.72321958773949468, -0.72745176586103955, -0.73165644853589207, -0.73583347683993661, -0.73998269289430874, -0.74410393987136036, -0.74819706200059111, -0.75226190457453113, -0.75629831395459302, -0.76030613757687548, -0.76428522395793208, -0.76823542270049594, -0.77215658449916424, -0.77604856114604126, -0.77991120553634119, -0.78374437167394717, -0.78754791467693031, -0.79132169078302472, -0.7950655573550629, -0.79877937288636469, -0.80246299700608903, -0.80611629048453581, -0.80973911523841147, -0.81333133433604599, -0.8168928120025698, -0.82042341362504512, -0.82392300575755417, -0.82739145612624221, -0.83082863363431825, -0.83423440836700946, -0.8376086515964718, -0.84095123578665465, -0.8442620345981231, -0.84754092289283089, -0.85078777673885309, -0.85400247341506696, -0.85718489141579368, -0.86033491045538824, -0.86345241147278773, -0.86653727663601066, -0.86958938934661101, -0.87260863424408419, -0.87559489721022921, -0.87854806537346053, -0.88146802711307481, -0.88435467206346929, -0.88720789111831455, -0.89002757643467667, -0.89281362143709475, -0.89556592082160857, -0.89828437055973898, -0.90096886790241903, -0.90361931138387908, -0.90623560082548038, -0.90881763733950294, -0.91136532333288134, -0.9138785625108955, -0.91635725988080885, -0.91880132175545981, -0.92121065575680139, -0.92358517081939495, -0.9259247771938498, -0.92822938645021758, -0.93049891148133312, -0.93273326650610799, -0.9349323670727715, -0.93709613006206383, -0.93922447369037709, -0.94131731751284708, -0.9433745824263926, -0.94539619067270697, -0.94738206584119544, -0.94933213287186502, -0.95124631805815973, -0.95312454904974775, -0.95496675485525517, -0.95677286584495025, -0.95854281375337413, -0.96027653168192206, -0.96197395410137099, -0.96363501685435693, -0.96525965715780004, -0.9668478136052775, -0.96839942616934394, -0.96991443620380113, -0.97139278644591398, -0.97283442101857565, -0.97423928543241844, -0.97560732658787452, -0.9769384927771817, -0.9782327336863389, -0.97949000039700751, -0.98071024538836005, -0.98189342253887657, -0.98303948712808775, -0.98414839583826574, -0.98522010675606064, -0.98625457937408501, -0.9872517745924454, -0.98821165472021921, -0.98913418347688054, -0.99001932599367015, -0.99086704881491472, -0.99167731989928998, -0.99245010862103311, -0.99318538577109949, -0.99388312355826691, -0.99454329561018584, -0.99516587697437653, -0.99575084411917214, -0.99629817493460782, -0.99680784873325645, -0.99727984625101107, -0.99771414964781235, -0.99811074250832332, -0.99846960984254973, -0.99879073808640628, -0.99907411510222999, -0.99931973017923825, -0.99952757403393411, -0.99969763881045715, -0.99982991808087995, -0.99992440684545181, -0.99998110153278685, -1.0, -1.0};
+static MYFLT HALF_COS_ARRAY[513] = {1.0, 0.99998110153278696, 0.99992440684545181, 0.99982991808087995, 0.99969763881045715, 0.99952757403393411, 0.99931973017923825, 0.99907411510222999, 0.99879073808640628, 0.99846960984254973, 0.99811074250832332, 0.99771414964781235, 0.99727984625101107, 0.99680784873325645, 0.99629817493460782, 0.99575084411917214, 0.99516587697437664, 0.99454329561018584, 0.99388312355826691, 0.9931853857710996, 0.99245010862103322, 0.99167731989928998, 0.99086704881491472, 0.99001932599367026, 0.98913418347688054, 0.98821165472021921, 0.9872517745924454, 0.98625457937408512, 0.98522010675606064, 0.98414839583826585, 0.98303948712808786, 0.98189342253887657, 0.98071024538836005, 0.97949000039700762, 0.97823273368633901, 0.9769384927771817, 0.97560732658787452, 0.97423928543241856, 0.97283442101857576, 0.97139278644591409, 0.96991443620380113, 0.96839942616934394, 0.96684781360527761, 0.96525965715780015, 0.96363501685435693, 0.96197395410137099, 0.96027653168192206, 0.95854281375337425, 0.95677286584495025, 0.95496675485525528, 0.95312454904974775, 0.95124631805815985, 0.94933213287186513, 0.94738206584119555, 0.94539619067270686, 0.9433745824263926, 0.94131731751284708, 0.9392244736903772, 0.93709613006206383, 0.9349323670727715, 0.93273326650610799, 0.93049891148133324, 0.92822938645021758, 0.92592477719384991, 0.92358517081939495, 0.92121065575680161, 0.91880132175545981, 0.91635725988080907, 0.91387856251089561, 0.91136532333288145, 0.90881763733950294, 0.9062356008254806, 0.90361931138387919, 0.90096886790241915, 0.89828437055973898, 0.89556592082160869, 0.89281362143709486, 0.89002757643467667, 0.88720789111831455, 0.8843546720634694, 0.88146802711307481, 0.87854806537346075, 0.87559489721022943, 0.8726086342440843, 0.86958938934661101, 0.86653727663601088, 0.86345241147278784, 0.86033491045538835, 0.85718489141579368, 0.85400247341506719, 0.8507877767388532, 0.84754092289283123, 0.8442620345981231, 0.84095123578665476, 0.8376086515964718, 0.83423440836700968, 0.83082863363431847, 0.82739145612624232, 0.82392300575755428, 0.82042341362504534, 0.81689281200256991, 0.81333133433604599, 0.80973911523841147, 0.80611629048453592, 0.80246299700608914, 0.79877937288636502, 0.7950655573550629, 0.79132169078302494, 0.78754791467693042, 0.78374437167394739, 0.77991120553634141, 0.77604856114604148, 0.77215658449916424, 0.76823542270049605, 0.76428522395793219, 0.7603061375768756, 0.75629831395459302, 0.75226190457453135, 0.74819706200059122, 0.7441039398713607, 0.73998269289430851, 0.73583347683993672, 0.73165644853589207, 0.72745176586103977, 0.72321958773949491, 0.71896007413461649, 0.71467338604296105, 0.71035968548819706, 0.70601913551498185, 0.70165190018279788, 0.69725814455975277, 0.69283803471633953, 0.68839173771916018, 0.68391942162461061, 0.6794212554725293, 0.67489740927980701, 0.67034805403396192, 0.66577336168667567, 0.66117350514729512, 0.65654865827629605, 0.65189899587871258, 0.64722469369752944, 0.6425259284070397, 0.63780287760616672, 0.63305571981175202, 0.62828463445180749, 0.62348980185873359, 0.61867140326250347, 0.61382962078381298, 0.60896463742719675, 0.60407663707411186, 0.59916580447598711, 0.59423232524724023, 0.58927638585826192, 0.58429817362836856, 0.57929787671872113, 0.57427568412521424, 0.56923178567133192, 0.56416637200097319, 0.55907963457124654, 0.55397176564523298, 0.5488429582847193, 0.5436934063429012, 0.53852330445705543, 0.53333284804118442, 0.52812223327862839, 0.52289165711465235, 0.51764131724900009, 0.51237141212842374, 0.50708214093918114, 0.50177370359950879, 0.49644630075206486, 0.49110013375634509, 0.48573540468107329, 0.48035231629656205, 0.47495107206705045, 0.46953187614301212, 0.46409493335344021, 0.45864044919810504, 0.45316862983978612, 0.44767968209648135, 0.44217381343358825, 0.43665123195606403, 0.43111214640055828, 0.42555676612752463, 0.41998530111330729, 0.41439796194220363, 0.40879495979850627, 0.40317650645851943, 0.39754281428255606, 0.3918940962069094, 0.38623056573580644, 0.38055243693333718, 0.3748599244153632, 0.36915324334140731, 0.36343260940651945, 0.35769823883312568, 0.35195034836285416, 0.34618915524834432, 0.34041487724503472, 0.33462773260293199, 0.32882794005836308, 0.32301571882570607, 0.31719128858910622, 0.31135486949417079, 0.30550668213964982, 0.29964694756909749, 0.29377588726251663, 0.28789372312798917, 0.28200067749328667, 0.27609697309746906, 0.27018283308246382, 0.26425848098463345, 0.25832414072632598, 0.25238003660741054, 0.24642639329680122, 0.24046343582396335, 0.23449138957040974, 0.22851048026118126, 0.22252093395631445, 0.21652297704229864, 0.21051683622351761, 0.20450273851368242, 0.19848091122724945, 0.19245158197082995, 0.18641497863458675, 0.1803713293836198, 0.17432086264934399, 0.16826380712085329, 0.16220039173627876, 0.15613084567413366, 0.1500553983446527, 0.14397427938112045, 0.13788771863119115, 0.13179594614820278, 0.12569919218247999, 0.11959768717263308, 0.11349166173684638, 0.10738134666416307, 0.10126697290576155, 0.095148771566225324, 0.089026973894809708, 0.082901811276699419, 0.076773515224264705, 0.070642317368309157, 0.064508449449316344, 0.058372143308689985, 0.052233630879990445, 0.046093144180169916, 0.039950915300801082, 0.033807176399306589, 0.027662159690182372, 0.021516097436222258, 0.01536922193973846, 0.0092217655337806046, 0.0030739605733557966, -0.0030739605733554522, -0.0092217655337804832, -0.015369221939738116, -0.021516097436222133, -0.027662159690182025, -0.033807176399306464, -0.039950915300800735, -0.046093144180169791, -0.052233630879990098, -0.05837214330868986, -0.064508449449316232, -0.07064231736830906, -0.076773515224264371, -0.082901811276699308, -0.089026973894809375, -0.095148771566225213, -0.10126697290576121, -0.10738134666416296, -0.11349166173684605, -0.11959768717263299, -0.12569919218247966, -0.13179594614820267, -0.13788771863119104, -0.14397427938112034, -0.15005539834465259, -0.15613084567413354, -0.16220039173627843, -0.16826380712085318, -0.17432086264934366, -0.18037132938361969, -0.18641497863458642, -0.19245158197082984, -0.19848091122724912, -0.20450273851368231, -0.21051683622351727, -0.21652297704229853, -0.22252093395631434, -0.22851048026118118, -0.23449138957040966, -0.24046343582396323, -0.24642639329680088, -0.25238003660741043, -0.25832414072632565, -0.26425848098463334, -0.27018283308246349, -0.27609697309746895, -0.28200067749328633, -0.28789372312798905, -0.2937758872625163, -0.29964694756909738, -0.30550668213964971, -0.31135486949417068, -0.31719128858910589, -0.32301571882570601, -0.32882794005836274, -0.33462773260293188, -0.34041487724503444, -0.3461891552483442, -0.35195034836285388, -0.35769823883312557, -0.36343260940651911, -0.3691532433414072, -0.37485992441536287, -0.38055243693333707, -0.38623056573580633, -0.39189409620690935, -0.39754281428255578, -0.40317650645851938, -0.408794959798506, -0.41439796194220352, -0.41998530111330723, -0.42555676612752458, -0.43111214640055795, -0.43665123195606392, -0.44217381343358819, -0.44767968209648107, -0.45316862983978584, -0.45864044919810493, -0.46409493335344015, -0.46953187614301223, -0.47495107206704995, -0.48035231629656183, -0.4857354046810729, -0.49110013375634509, -0.4964463007520647, -0.50177370359950857, -0.5070821409391808, -0.51237141212842352, -0.51764131724899998, -0.52289165711465191, -0.52812223327862795, -0.53333284804118419, -0.53852330445705532, -0.5436934063429012, -0.54884295828471885, -0.55397176564523276, -0.55907963457124621, -0.56416637200097308, -0.5692317856713317, -0.57427568412521401, -0.57929787671872079, -0.58429817362836844, -0.5892763858582617, -0.5942323252472399, -0.59916580447598666, -0.60407663707411174, -0.60896463742719653, -0.61382962078381298, -0.61867140326250303, -0.62348980185873337, -0.62828463445180716, -0.6330557198117519, -0.6378028776061665, -0.64252592840703937, -0.64722469369752911, -0.65189899587871247, -0.65654865827629583, -0.66117350514729478, -0.66577336168667522, -0.67034805403396169, -0.67489740927980679, -0.6794212554725293, -0.68391942162461028, -0.68839173771915996, -0.6928380347163392, -0.69725814455975266, -0.70165190018279777, -0.70601913551498163, -0.71035968548819683, -0.71467338604296105, -0.71896007413461638, -0.72321958773949468, -0.72745176586103955, -0.73165644853589207, -0.73583347683993661, -0.73998269289430874, -0.74410393987136036, -0.74819706200059111, -0.75226190457453113, -0.75629831395459302, -0.76030613757687548, -0.76428522395793208, -0.76823542270049594, -0.77215658449916424, -0.77604856114604126, -0.77991120553634119, -0.78374437167394717, -0.78754791467693031, -0.79132169078302472, -0.7950655573550629, -0.79877937288636469, -0.80246299700608903, -0.80611629048453581, -0.80973911523841147, -0.81333133433604599, -0.8168928120025698, -0.82042341362504512, -0.82392300575755417, -0.82739145612624221, -0.83082863363431825, -0.83423440836700946, -0.8376086515964718, -0.84095123578665465, -0.8442620345981231, -0.84754092289283089, -0.85078777673885309, -0.85400247341506696, -0.85718489141579368, -0.86033491045538824, -0.86345241147278773, -0.86653727663601066, -0.86958938934661101, -0.87260863424408419, -0.87559489721022921, -0.87854806537346053, -0.88146802711307481, -0.88435467206346929, -0.88720789111831455, -0.89002757643467667, -0.89281362143709475, -0.89556592082160857, -0.89828437055973898, -0.90096886790241903, -0.90361931138387908, -0.90623560082548038, -0.90881763733950294, -0.91136532333288134, -0.9138785625108955, -0.91635725988080885, -0.91880132175545981, -0.92121065575680139, -0.92358517081939495, -0.9259247771938498, -0.92822938645021758, -0.93049891148133312, -0.93273326650610799, -0.9349323670727715, -0.93709613006206383, -0.93922447369037709, -0.94131731751284708, -0.9433745824263926, -0.94539619067270697, -0.94738206584119544, -0.94933213287186502, -0.95124631805815973, -0.95312454904974775, -0.95496675485525517, -0.95677286584495025, -0.95854281375337413, -0.96027653168192206, -0.96197395410137099, -0.96363501685435693, -0.96525965715780004, -0.9668478136052775, -0.96839942616934394, -0.96991443620380113, -0.97139278644591398, -0.97283442101857565, -0.97423928543241844, -0.97560732658787452, -0.9769384927771817, -0.9782327336863389, -0.97949000039700751, -0.98071024538836005, -0.98189342253887657, -0.98303948712808775, -0.98414839583826574, -0.98522010675606064, -0.98625457937408501, -0.9872517745924454, -0.98821165472021921, -0.98913418347688054, -0.99001932599367015, -0.99086704881491472, -0.99167731989928998, -0.99245010862103311, -0.99318538577109949, -0.99388312355826691, -0.99454329561018584, -0.99516587697437653, -0.99575084411917214, -0.99629817493460782, -0.99680784873325645, -0.99727984625101107, -0.99771414964781235, -0.99811074250832332, -0.99846960984254973, -0.99879073808640628, -0.99907411510222999, -0.99931973017923825, -0.99952757403393411, -0.99969763881045715, -0.99982991808087995, -0.99992440684545181, -0.99998110153278685, -1.0, -1.0};
typedef struct {
pyo_audio_HEAD
@@ -38,7 +38,7 @@ typedef struct {
Stream *q_stream;
void (*coeffs_func_ptr)();
int init;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
int filtertype;
MYFLT nyquist;
// sample memories
@@ -59,7 +59,7 @@ typedef struct {
MYFLT a2;
} Biquad;
-static void
+static void
Biquad_compute_coeffs_lp(Biquad *self)
{
self->b0 = self->b2 = (1 - self->c) / 2;
@@ -69,7 +69,7 @@ Biquad_compute_coeffs_lp(Biquad *self)
self->a2 = 1 - self->alpha;
}
-static void
+static void
Biquad_compute_coeffs_hp(Biquad *self)
{
self->b0 = (1 + self->c) / 2;
@@ -80,7 +80,7 @@ Biquad_compute_coeffs_hp(Biquad *self)
self->a2 = 1 - self->alpha;
}
-static void
+static void
Biquad_compute_coeffs_bp(Biquad *self)
{
self->b0 = self->alpha;
@@ -91,7 +91,7 @@ Biquad_compute_coeffs_bp(Biquad *self)
self->a2 = 1 - self->alpha;
}
-static void
+static void
Biquad_compute_coeffs_bs(Biquad *self)
{
self->b0 = 1;
@@ -101,7 +101,7 @@ Biquad_compute_coeffs_bs(Biquad *self)
self->a2 = 1 - self->alpha;
}
-static void
+static void
Biquad_compute_coeffs_ap(Biquad *self)
{
self->b0 = self->a2 = 1 - self->alpha;
@@ -111,14 +111,14 @@ Biquad_compute_coeffs_ap(Biquad *self)
static void
Biquad_compute_variables(Biquad *self, MYFLT freq, MYFLT q)
-{
- if (freq <= 1)
+{
+ if (freq <= 1)
freq = 1;
else if (freq >= self->nyquist)
freq = self->nyquist;
if (q < 0.1)
q = 0.1;
-
+
self->w0 = TWOPI * freq / self->sr;
self->c = MYCOS(self->w0);
self->alpha = MYSIN(self->w0) / (2 * q);
@@ -135,7 +135,7 @@ Biquad_filters_ii(Biquad *self) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
for (i=0; i<self->bufsize; i++) {
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
self->y2 = self->y1;
@@ -151,7 +151,7 @@ Biquad_filters_ai(Biquad *self) {
MYFLT val, q;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
@@ -159,7 +159,7 @@ Biquad_filters_ai(Biquad *self) {
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
q = PyFloat_AS_DOUBLE(self->q);
-
+
for (i=0; i<self->bufsize; i++) {
Biquad_compute_variables(self, fr[i], q);
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
@@ -176,15 +176,15 @@ Biquad_filters_ia(Biquad *self) {
MYFLT val, fr;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
-
+
for (i=0; i<self->bufsize; i++) {
Biquad_compute_variables(self, fr, q[i]);
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
@@ -201,7 +201,7 @@ Biquad_filters_aa(Biquad *self) {
MYFLT val;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
@@ -255,57 +255,57 @@ Biquad_setProcMode(Biquad *self)
self->coeffs_func_ptr = Biquad_compute_coeffs_ap;
break;
}
-
+
switch (procmode) {
- case 0:
+ case 0:
Biquad_compute_variables(self, PyFloat_AS_DOUBLE(self->freq), PyFloat_AS_DOUBLE(self->q));
self->proc_func_ptr = Biquad_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Biquad_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Biquad_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Biquad_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Biquad_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Biquad_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Biquad_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Biquad_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Biquad_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Biquad_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Biquad_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Biquad_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Biquad_postprocessing_revareva;
break;
- }
+ }
}
static void
Biquad_compute_next_data_frame(Biquad *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -315,23 +315,23 @@ Biquad_traverse(Biquad *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
return 0;
}
-static int
+static int
Biquad_clear(Biquad *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->q);
- Py_CLEAR(self->q_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->q);
+ Py_CLEAR(self->q_stream);
return 0;
}
@@ -350,7 +350,7 @@ Biquad_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *qtmp=NULL, *multmp=NULL, *addtmp=NULL;
Biquad *self;
self = (Biquad *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->q = PyFloat_FromDouble(1);
self->filtertype = 0;
@@ -361,9 +361,9 @@ Biquad_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->init = 1;
INIT_OBJECT_COMMON
-
+
self->nyquist = (MYFLT)self->sr * 0.49;
-
+
Stream_setFunctionPtr(self->stream, Biquad_compute_next_data_frame);
self->mode_func_ptr = Biquad_setProcMode;
@@ -373,7 +373,7 @@ Biquad_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -381,7 +381,7 @@ Biquad_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (qtmp) {
PyObject_CallMethod((PyObject *)self, "setQ", "O", qtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -389,7 +389,7 @@ Biquad_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -399,10 +399,10 @@ Biquad_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Biquad_getServer(Biquad* self) { GET_SERVER };
static PyObject * Biquad_getStream(Biquad* self) { GET_STREAM };
-static PyObject * Biquad_setMul(Biquad *self, PyObject *arg) { SET_MUL };
-static PyObject * Biquad_setAdd(Biquad *self, PyObject *arg) { SET_ADD };
-static PyObject * Biquad_setSub(Biquad *self, PyObject *arg) { SET_SUB };
-static PyObject * Biquad_setDiv(Biquad *self, PyObject *arg) { SET_DIV };
+static PyObject * Biquad_setMul(Biquad *self, PyObject *arg) { SET_MUL };
+static PyObject * Biquad_setAdd(Biquad *self, PyObject *arg) { SET_ADD };
+static PyObject * Biquad_setSub(Biquad *self, PyObject *arg) { SET_SUB };
+static PyObject * Biquad_setDiv(Biquad *self, PyObject *arg) { SET_DIV };
static PyObject * Biquad_play(Biquad *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Biquad_out(Biquad *self, PyObject *args, PyObject *kwds) { OUT };
@@ -421,14 +421,14 @@ static PyObject *
Biquad_setFreq(Biquad *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -444,25 +444,25 @@ Biquad_setFreq(Biquad *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Biquad_setQ(Biquad *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -478,33 +478,33 @@ Biquad_setQ(Biquad *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Biquad_setType(Biquad *self, PyObject *arg)
{
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->filtertype = PyInt_AsLong(arg);
}
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Biquad_members[] = {
{"server", T_OBJECT_EX, offsetof(Biquad, server), 0, "Pyo server."},
@@ -627,7 +627,7 @@ typedef struct {
Stream *q_stream;
void (*coeffs_func_ptr)();
int init;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
int filtertype;
int stages;
MYFLT nyquist;
@@ -659,7 +659,7 @@ Biquadx_allocate_memories(Biquadx *self)
self->init = 1;
}
-static void
+static void
Biquadx_compute_coeffs_lp(Biquadx *self)
{
self->b0 = self->b2 = (1 - self->c) / 2;
@@ -669,7 +669,7 @@ Biquadx_compute_coeffs_lp(Biquadx *self)
self->a2 = 1 - self->alpha;
}
-static void
+static void
Biquadx_compute_coeffs_hp(Biquadx *self)
{
self->b0 = (1 + self->c) / 2;
@@ -680,7 +680,7 @@ Biquadx_compute_coeffs_hp(Biquadx *self)
self->a2 = 1 - self->alpha;
}
-static void
+static void
Biquadx_compute_coeffs_bp(Biquadx *self)
{
self->b0 = self->alpha;
@@ -691,7 +691,7 @@ Biquadx_compute_coeffs_bp(Biquadx *self)
self->a2 = 1 - self->alpha;
}
-static void
+static void
Biquadx_compute_coeffs_bs(Biquadx *self)
{
self->b0 = 1;
@@ -701,7 +701,7 @@ Biquadx_compute_coeffs_bs(Biquadx *self)
self->a2 = 1 - self->alpha;
}
-static void
+static void
Biquadx_compute_coeffs_ap(Biquadx *self)
{
self->b0 = self->a2 = 1 - self->alpha;
@@ -711,14 +711,14 @@ Biquadx_compute_coeffs_ap(Biquadx *self)
static void
Biquadx_compute_variables(Biquadx *self, MYFLT freq, MYFLT q)
-{
- if (freq <= 1)
+{
+ if (freq <= 1)
freq = 1;
else if (freq >= self->nyquist)
freq = self->nyquist;
if (q < 0.1)
q = 0.1;
-
+
self->w0 = TWOPI * freq / self->sr;
self->c = MYCOS(self->w0);
self->alpha = MYSIN(self->w0) / (2 * q);
@@ -730,18 +730,18 @@ Biquadx_filters_ii(Biquadx *self) {
MYFLT vin, vout;
int i, j;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
for (i=0; i<self->stages; i++) {
self->x1[i] = self->x2[i] = self->y1[i] = self->y2[i] = in[0];
- }
+ }
self->init = 0;
}
-
+
vout = 0.0;
for (i=0; i<self->bufsize; i++) {
vin = in[i];
- for (j=0; j<self->stages; j++) {
+ for (j=0; j<self->stages; j++) {
vout = ( (self->b0 * vin) + (self->b1 * self->x1[j]) + (self->b2 * self->x2[j]) - (self->a1 * self->y1[j]) - (self->a2 * self->y2[j]) ) / self->a0;
self->x2[j] = self->x1[j];
self->x1[j] = vin;
@@ -757,22 +757,22 @@ Biquadx_filters_ai(Biquadx *self) {
MYFLT vin, vout, q;
int i, j;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
for (i=0; i<self->stages; i++) {
self->x1[i] = self->x2[i] = self->y1[i] = self->y2[i] = in[0];
- }
+ }
self->init = 0;
}
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
q = PyFloat_AS_DOUBLE(self->q);
-
+
vout = 0.0;
for (i=0; i<self->bufsize; i++) {
Biquadx_compute_variables(self, fr[i], q);
vin = in[i];
- for (j=0; j<self->stages; j++) {
+ for (j=0; j<self->stages; j++) {
vout = ( (self->b0 * vin) + (self->b1 * self->x1[j]) + (self->b2 * self->x2[j]) - (self->a1 * self->y1[j]) - (self->a2 * self->y2[j]) ) / self->a0;
self->x2[j] = self->x1[j];
self->x1[j] = vin;
@@ -788,22 +788,22 @@ Biquadx_filters_ia(Biquadx *self) {
MYFLT vin, vout, fr;
int i, j;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
for (i=0; i<self->stages; i++) {
self->x1[i] = self->x2[i] = self->y1[i] = self->y2[i] = in[0];
- }
+ }
self->init = 0;
}
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
-
+
vout = 0.0;
for (i=0; i<self->bufsize; i++) {
Biquadx_compute_variables(self, fr, q[i]);
vin = in[i];
- for (j=0; j<self->stages; j++) {
+ for (j=0; j<self->stages; j++) {
vout = ( (self->b0 * vin) + (self->b1 * self->x1[j]) + (self->b2 * self->x2[j]) - (self->a1 * self->y1[j]) - (self->a2 * self->y2[j]) ) / self->a0;
self->x2[j] = self->x1[j];
self->x1[j] = vin;
@@ -819,22 +819,22 @@ Biquadx_filters_aa(Biquadx *self) {
MYFLT vin, vout;
int i, j;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
for (i=0; i<self->stages; i++) {
self->x1[i] = self->x2[i] = self->y1[i] = self->y2[i] = in[0];
- }
+ }
self->init = 0;
}
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
-
+
vout = 0.0;
for (i=0; i<self->bufsize; i++) {
Biquadx_compute_variables(self, fr[i], q[i]);
vin = in[i];
- for (j=0; j<self->stages; j++) {
+ for (j=0; j<self->stages; j++) {
vout = ( (self->b0 * vin) + (self->b1 * self->x1[j]) + (self->b2 * self->x2[j]) - (self->a1 * self->y1[j]) - (self->a2 * self->y2[j]) ) / self->a0;
self->x2[j] = self->x1[j];
self->x1[j] = vin;
@@ -861,7 +861,7 @@ Biquadx_setProcMode(Biquadx *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (self->filtertype) {
case 0:
self->coeffs_func_ptr = Biquadx_compute_coeffs_lp;
@@ -879,57 +879,57 @@ Biquadx_setProcMode(Biquadx *self)
self->coeffs_func_ptr = Biquadx_compute_coeffs_ap;
break;
}
-
+
switch (procmode) {
- case 0:
+ case 0:
Biquadx_compute_variables(self, PyFloat_AS_DOUBLE(self->freq), PyFloat_AS_DOUBLE(self->q));
self->proc_func_ptr = Biquadx_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Biquadx_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Biquadx_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Biquadx_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Biquadx_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Biquadx_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Biquadx_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Biquadx_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Biquadx_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Biquadx_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Biquadx_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Biquadx_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Biquadx_postprocessing_revareva;
break;
- }
+ }
}
static void
Biquadx_compute_next_data_frame(Biquadx *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -939,23 +939,23 @@ Biquadx_traverse(Biquadx *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
return 0;
}
-static int
+static int
Biquadx_clear(Biquadx *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->q);
- Py_CLEAR(self->q_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->q);
+ Py_CLEAR(self->q_stream);
return 0;
}
@@ -978,7 +978,7 @@ Biquadx_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *qtmp=NULL, *multmp=NULL, *addtmp=NULL;
Biquadx *self;
self = (Biquadx *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->q = PyFloat_FromDouble(1);
self->filtertype = 0;
@@ -988,37 +988,37 @@ Biquadx_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->init = 1;
-
+
INIT_OBJECT_COMMON
-
+
self->nyquist = (MYFLT)self->sr * 0.49;
Stream_setFunctionPtr(self->stream, Biquadx_compute_next_data_frame);
self->mode_func_ptr = Biquadx_setProcMode;
static char *kwlist[] = {"input", "freq", "q", "type", "stages", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOiiOO", kwlist, &inputtmp, &freqtmp, &qtmp, &self->filtertype, &self->stages, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (qtmp) {
PyObject_CallMethod((PyObject *)self, "setQ", "O", qtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Biquadx_allocate_memories(self);
@@ -1030,10 +1030,10 @@ Biquadx_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Biquadx_getServer(Biquadx* self) { GET_SERVER };
static PyObject * Biquadx_getStream(Biquadx* self) { GET_STREAM };
-static PyObject * Biquadx_setMul(Biquadx *self, PyObject *arg) { SET_MUL };
-static PyObject * Biquadx_setAdd(Biquadx *self, PyObject *arg) { SET_ADD };
-static PyObject * Biquadx_setSub(Biquadx *self, PyObject *arg) { SET_SUB };
-static PyObject * Biquadx_setDiv(Biquadx *self, PyObject *arg) { SET_DIV };
+static PyObject * Biquadx_setMul(Biquadx *self, PyObject *arg) { SET_MUL };
+static PyObject * Biquadx_setAdd(Biquadx *self, PyObject *arg) { SET_ADD };
+static PyObject * Biquadx_setSub(Biquadx *self, PyObject *arg) { SET_SUB };
+static PyObject * Biquadx_setDiv(Biquadx *self, PyObject *arg) { SET_DIV };
static PyObject * Biquadx_play(Biquadx *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Biquadx_out(Biquadx *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1052,14 +1052,14 @@ static PyObject *
Biquadx_setFreq(Biquadx *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1075,25 +1075,25 @@ Biquadx_setFreq(Biquadx *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Biquadx_setQ(Biquadx *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -1109,45 +1109,45 @@ Biquadx_setQ(Biquadx *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Biquadx_setType(Biquadx *self, PyObject *arg)
{
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->filtertype = PyInt_AsLong(arg);
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Biquadx_setStages(Biquadx *self, PyObject *arg)
{
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->stages = PyInt_AsLong(arg);
Biquadx_allocate_memories(self);
@@ -1155,7 +1155,7 @@ Biquadx_setStages(Biquadx *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Biquadx_members[] = {
{"server", T_OBJECT_EX, offsetof(Biquadx, server), 0, "Pyo server."},
@@ -1282,7 +1282,7 @@ typedef struct {
Stream *a1_stream;
Stream *a2_stream;
int init;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
// sample memories
MYFLT x1;
MYFLT x2;
@@ -1306,7 +1306,7 @@ Biquada_filters(Biquada *self) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
for (i=0; i<self->bufsize; i++) {
val = ( (b0[i] * in[i]) + (b1[i] * self->x1) + (b2[i] * self->x2) - (a1[i] * self->y1) - (a2[i] * self->y2) ) / a0[i];
self->y2 = self->y1;
@@ -1331,44 +1331,44 @@ Biquada_setProcMode(Biquada *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Biquada_filters;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Biquada_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Biquada_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Biquada_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Biquada_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Biquada_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Biquada_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Biquada_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Biquada_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Biquada_postprocessing_revareva;
break;
- }
+ }
}
static void
Biquada_compute_next_data_frame(Biquada *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1387,7 +1387,7 @@ Biquada_traverse(Biquada *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Biquada_clear(Biquada *self)
{
pyo_CLEAR
@@ -1417,21 +1417,21 @@ Biquada_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *b0tmp, *b1tmp, *b2tmp, *a0tmp, *a1tmp, *a2tmp, *multmp=NULL, *addtmp=NULL;
Biquada *self;
self = (Biquada *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->init = 1;
-
+
INIT_OBJECT_COMMON
-
+
Stream_setFunctionPtr(self->stream, Biquada_compute_next_data_frame);
self->mode_func_ptr = Biquada_setProcMode;
static char *kwlist[] = {"input", "b0", "b1", "b2", "a0", "a1", "a2", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOOOOO", kwlist, &inputtmp, &b0tmp, &b1tmp, &b2tmp, &a0tmp, &a1tmp, &a2tmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (b0tmp)
@@ -1450,9 +1450,9 @@ Biquada_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
if (addtmp)
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1460,10 +1460,10 @@ Biquada_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Biquada_getServer(Biquada* self) { GET_SERVER };
static PyObject * Biquada_getStream(Biquada* self) { GET_STREAM };
-static PyObject * Biquada_setMul(Biquada *self, PyObject *arg) { SET_MUL };
-static PyObject * Biquada_setAdd(Biquada *self, PyObject *arg) { SET_ADD };
-static PyObject * Biquada_setSub(Biquada *self, PyObject *arg) { SET_SUB };
-static PyObject * Biquada_setDiv(Biquada *self, PyObject *arg) { SET_DIV };
+static PyObject * Biquada_setMul(Biquada *self, PyObject *arg) { SET_MUL };
+static PyObject * Biquada_setAdd(Biquada *self, PyObject *arg) { SET_ADD };
+static PyObject * Biquada_setSub(Biquada *self, PyObject *arg) { SET_SUB };
+static PyObject * Biquada_setDiv(Biquada *self, PyObject *arg) { SET_DIV };
static PyObject * Biquada_play(Biquada *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Biquada_out(Biquada *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1480,99 +1480,99 @@ static PyObject * Biquada_inplace_div(Biquada *self, PyObject *arg) { INPLACE_DI
static PyObject *
Biquada_setB0(Biquada *self, PyObject *arg)
-{
+{
PyObject *streamtmp;
if (arg == NULL)
Py_RETURN_NONE;
-
+
streamtmp = PyObject_CallMethod((PyObject *)arg, "_getStream", NULL);
Py_INCREF(streamtmp);
Py_XDECREF(self->b0_stream);
self->b0_stream = (Stream *)streamtmp;
-
+
Py_RETURN_NONE;
-}
+}
static PyObject *
Biquada_setB1(Biquada *self, PyObject *arg)
-{
+{
PyObject *streamtmp;
if (arg == NULL)
Py_RETURN_NONE;
-
+
streamtmp = PyObject_CallMethod((PyObject *)arg, "_getStream", NULL);
Py_INCREF(streamtmp);
Py_XDECREF(self->b1_stream);
self->b1_stream = (Stream *)streamtmp;
-
+
Py_RETURN_NONE;
-}
+}
static PyObject *
Biquada_setB2(Biquada *self, PyObject *arg)
-{
+{
PyObject *streamtmp;
-
+
if (arg == NULL)
Py_RETURN_NONE;
-
+
streamtmp = PyObject_CallMethod((PyObject *)arg, "_getStream", NULL);
Py_INCREF(streamtmp);
Py_XDECREF(self->b2_stream);
self->b2_stream = (Stream *)streamtmp;
-
+
Py_RETURN_NONE;
-}
+}
static PyObject *
Biquada_setA0(Biquada *self, PyObject *arg)
-{
+{
PyObject *streamtmp;
-
+
if (arg == NULL)
Py_RETURN_NONE;
-
+
streamtmp = PyObject_CallMethod((PyObject *)arg, "_getStream", NULL);
Py_INCREF(streamtmp);
Py_XDECREF(self->a0_stream);
self->a0_stream = (Stream *)streamtmp;
-
+
Py_RETURN_NONE;
-}
+}
static PyObject *
Biquada_setA1(Biquada *self, PyObject *arg)
-{
+{
PyObject *streamtmp;
-
+
if (arg == NULL)
Py_RETURN_NONE;
-
+
streamtmp = PyObject_CallMethod((PyObject *)arg, "_getStream", NULL);
Py_INCREF(streamtmp);
Py_XDECREF(self->a1_stream);
self->a1_stream = (Stream *)streamtmp;
-
+
Py_RETURN_NONE;
-}
+}
static PyObject *
Biquada_setA2(Biquada *self, PyObject *arg)
-{
+{
PyObject *streamtmp;
-
+
if (arg == NULL)
Py_RETURN_NONE;
-
+
streamtmp = PyObject_CallMethod((PyObject *)arg, "_getStream", NULL);
Py_INCREF(streamtmp);
Py_XDECREF(self->a2_stream);
self->a2_stream = (Stream *)streamtmp;
-
+
Py_RETURN_NONE;
-}
+}
static PyMemberDef Biquada_members[] = {
{"server", T_OBJECT_EX, offsetof(Biquada, server), 0, "Pyo server."},
@@ -1699,7 +1699,7 @@ typedef struct {
Stream *boost_stream;
void (*coeffs_func_ptr)();
int init;
- int modebuffer[5]; // need at least 2 slots for mul & add
+ int modebuffer[5]; // need at least 2 slots for mul & add
int filtertype;
MYFLT nyquist;
// sample memories
@@ -1721,12 +1721,12 @@ typedef struct {
MYFLT a2;
} EQ;
-static void
+static void
EQ_compute_coeffs_peak(EQ *self)
{
MYFLT alphaMul = self->alpha * self->A;
MYFLT alphaDiv = self->alpha / self->A;
-
+
self->b0 = 1.0 + alphaMul;
self->b1 = self->a1 = -2.0 * self->c;
self->b2 = 1.0 - alphaMul;
@@ -1735,43 +1735,43 @@ EQ_compute_coeffs_peak(EQ *self)
}
static void
-EQ_compute_coeffs_lowshelf(EQ *self)
+EQ_compute_coeffs_lowshelf(EQ *self)
{
MYFLT twoSqrtAAlpha = MYSQRT(self->A * 2.0)*self->alpha;
MYFLT AminOneC = (self->A - 1.0) * self->c;
MYFLT AAddOneC = (self->A + 1.0) * self->c;
-
+
self->b0 = self->A * ((self->A + 1.0) - AminOneC + twoSqrtAAlpha);
self->b1 = 2.0 * self->A * ((self->A - 1.0) - AAddOneC);
self->b2 = self->A * ((self->A + 1.0) - AminOneC - twoSqrtAAlpha);
self->a0 = (self->A + 1.0) + AminOneC + twoSqrtAAlpha;
self->a1 = -2.0 * ((self->A - 1.0) + AAddOneC);
self->a2 = (self->A + 1.0) + AminOneC - twoSqrtAAlpha;
-}
+}
static void
-EQ_compute_coeffs_highshelf(EQ *self)
+EQ_compute_coeffs_highshelf(EQ *self)
{
MYFLT twoSqrtAAlpha = MYSQRT(self->A * 2.0)*self->alpha;
MYFLT AminOneC = (self->A - 1.0) * self->c;
MYFLT AAddOneC = (self->A + 1.0) * self->c;
-
+
self->b0 = self->A * ((self->A + 1.0) + AminOneC + twoSqrtAAlpha);
self->b1 = -2.0 * self->A * ((self->A - 1.0) + AAddOneC);
self->b2 = self->A * ((self->A + 1.0) + AminOneC - twoSqrtAAlpha);
self->a0 = (self->A + 1.0) - AminOneC + twoSqrtAAlpha;
self->a1 = 2.0 * ((self->A - 1.0) - AAddOneC);
self->a2 = (self->A + 1.0) - AminOneC - twoSqrtAAlpha;
-}
+}
static void
EQ_compute_variables(EQ *self, MYFLT freq, MYFLT q, MYFLT boost)
-{
- if (freq <= 1)
+{
+ if (freq <= 1)
freq = 1;
else if (freq >= self->nyquist)
freq = self->nyquist;
-
+
self->A = MYPOW(10.0, boost/40.0);
self->w0 = TWOPI * freq / self->sr;
self->c = MYCOS(self->w0);
@@ -1784,12 +1784,12 @@ EQ_filters_iii(EQ *self) {
MYFLT val;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
for (i=0; i<self->bufsize; i++) {
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
self->y2 = self->y1;
@@ -1805,16 +1805,16 @@ EQ_filters_aii(EQ *self) {
MYFLT val, q, boost;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
q = PyFloat_AS_DOUBLE(self->q);
boost = PyFloat_AS_DOUBLE(self->boost);
-
+
for (i=0; i<self->bufsize; i++) {
EQ_compute_variables(self, fr[i], q, boost);
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
@@ -1831,16 +1831,16 @@ EQ_filters_iai(EQ *self) {
MYFLT val, fr, boost;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
boost = PyFloat_AS_DOUBLE(self->boost);
-
+
for (i=0; i<self->bufsize; i++) {
EQ_compute_variables(self, fr, q[i], boost);
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
@@ -1857,16 +1857,16 @@ EQ_filters_aai(EQ *self) {
MYFLT val, boost;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
boost = PyFloat_AS_DOUBLE(self->boost);
-
+
for (i=0; i<self->bufsize; i++) {
EQ_compute_variables(self, fr[i], q[i], boost);
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
@@ -1883,7 +1883,7 @@ EQ_filters_iia(EQ *self) {
MYFLT val, fr, q;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
@@ -1909,16 +1909,16 @@ EQ_filters_aia(EQ *self) {
MYFLT val, q;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
q = PyFloat_AS_DOUBLE(self->q);
MYFLT *boost = Stream_getData((Stream *)self->boost_stream);
-
+
for (i=0; i<self->bufsize; i++) {
EQ_compute_variables(self, fr[i], q, boost[i]);
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
@@ -1935,16 +1935,16 @@ EQ_filters_iaa(EQ *self) {
MYFLT val, fr;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
MYFLT *boost = Stream_getData((Stream *)self->boost_stream);
-
+
for (i=0; i<self->bufsize; i++) {
EQ_compute_variables(self, fr, q[i], boost[i]);
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
@@ -1961,16 +1961,16 @@ EQ_filters_aaa(EQ *self) {
MYFLT val;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->x1 = self->x2 = self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
MYFLT *boost = Stream_getData((Stream *)self->boost_stream);
-
+
for (i=0; i<self->bufsize; i++) {
EQ_compute_variables(self, fr[i], q[i], boost[i]);
val = ( (self->b0 * in[i]) + (self->b1 * self->x1) + (self->b2 * self->x2) - (self->a1 * self->y1) - (self->a2 * self->y2) ) / self->a0;
@@ -1998,7 +1998,7 @@ EQ_setProcMode(EQ *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (self->filtertype) {
case 0:
self->coeffs_func_ptr = EQ_compute_coeffs_peak;
@@ -2010,69 +2010,69 @@ EQ_setProcMode(EQ *self)
self->coeffs_func_ptr = EQ_compute_coeffs_highshelf;
break;
}
-
+
switch (procmode) {
- case 0:
+ case 0:
EQ_compute_variables(self, PyFloat_AS_DOUBLE(self->freq), PyFloat_AS_DOUBLE(self->q), PyFloat_AS_DOUBLE(self->boost));
self->proc_func_ptr = EQ_filters_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = EQ_filters_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = EQ_filters_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = EQ_filters_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = EQ_filters_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = EQ_filters_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = EQ_filters_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = EQ_filters_aaa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = EQ_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = EQ_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = EQ_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = EQ_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = EQ_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = EQ_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = EQ_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = EQ_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = EQ_postprocessing_revareva;
break;
- }
+ }
}
static void
EQ_compute_next_data_frame(EQ *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2082,24 +2082,24 @@ EQ_traverse(EQ *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
- Py_VISIT(self->boost);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
+ Py_VISIT(self->boost);
Py_VISIT(self->boost_stream);
return 0;
}
-static int
+static int
EQ_clear(EQ *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->q);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->q);
Py_CLEAR(self->q_stream);
Py_CLEAR(self->boost);
Py_CLEAR(self->boost_stream);
@@ -2121,7 +2121,7 @@ EQ_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *qtmp=NULL, *boosttmp=NULL, *multmp=NULL, *addtmp=NULL;
EQ *self;
self = (EQ *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->q = PyFloat_FromDouble(1);
self->boost = PyFloat_FromDouble(-3.0);
@@ -2132,7 +2132,7 @@ EQ_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
self->init = 1;
-
+
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
@@ -2141,16 +2141,16 @@ EQ_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = EQ_setProcMode;
static char *kwlist[] = {"input", "freq", "q", "boost", "type", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOiOO", kwlist, &inputtmp, &freqtmp, &qtmp, &boosttmp, &self->filtertype, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (qtmp) {
PyObject_CallMethod((PyObject *)self, "setQ", "O", qtmp);
}
@@ -2158,17 +2158,17 @@ EQ_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (boosttmp) {
PyObject_CallMethod((PyObject *)self, "setBoost", "O", boosttmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -2176,10 +2176,10 @@ EQ_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * EQ_getServer(EQ* self) { GET_SERVER };
static PyObject * EQ_getStream(EQ* self) { GET_STREAM };
-static PyObject * EQ_setMul(EQ *self, PyObject *arg) { SET_MUL };
-static PyObject * EQ_setAdd(EQ *self, PyObject *arg) { SET_ADD };
-static PyObject * EQ_setSub(EQ *self, PyObject *arg) { SET_SUB };
-static PyObject * EQ_setDiv(EQ *self, PyObject *arg) { SET_DIV };
+static PyObject * EQ_setMul(EQ *self, PyObject *arg) { SET_MUL };
+static PyObject * EQ_setAdd(EQ *self, PyObject *arg) { SET_ADD };
+static PyObject * EQ_setSub(EQ *self, PyObject *arg) { SET_SUB };
+static PyObject * EQ_setDiv(EQ *self, PyObject *arg) { SET_DIV };
static PyObject * EQ_play(EQ *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * EQ_out(EQ *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2198,14 +2198,14 @@ static PyObject *
EQ_setFreq(EQ *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -2221,25 +2221,25 @@ EQ_setFreq(EQ *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
EQ_setQ(EQ *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -2255,25 +2255,25 @@ EQ_setQ(EQ *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
EQ_setBoost(EQ *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->boost);
@@ -2289,33 +2289,33 @@ EQ_setBoost(EQ *self, PyObject *arg)
self->boost_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
EQ_setType(EQ *self, PyObject *arg)
{
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->filtertype = PyInt_AsLong(arg);
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef EQ_members[] = {
{"server", T_OBJECT_EX, offsetof(EQ, server), 0, "Pyo server."},
@@ -2439,13 +2439,13 @@ typedef struct {
PyObject *falltime;
Stream *risetime_stream;
Stream *falltime_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
MYFLT y1; // sample memory
MYFLT x1;
int dir;
} Port;
-static void
+static void
direction(Port *self, MYFLT val)
{
if (val == self->x1)
@@ -2455,8 +2455,8 @@ direction(Port *self, MYFLT val)
else
self->dir = 0;
self->x1 = val;
-}
-
+}
+
static void
Port_filters_ii(Port *self) {
MYFLT val;
@@ -2484,10 +2484,10 @@ Port_filters_ai(Port *self) {
MYFLT *risetime = Stream_getData((Stream *)self->risetime_stream);
MYFLT falltime = PyFloat_AS_DOUBLE(self->falltime);
MYFLT fallfactor = 1. / ((falltime + 0.001) * self->sr);
-
+
for (i=0; i<self->bufsize; i++) {
direction(self, in[i]);
- risefactor = (*risetime++ + 0.001) * self->sr;
+ risefactor = (*risetime++ + 0.001) * self->sr;
if (self->dir == 1)
val = self->y1 + (*in++ - self->y1) / risefactor;
else
@@ -2505,10 +2505,10 @@ Port_filters_ia(Port *self) {
MYFLT *falltime = Stream_getData((Stream *)self->falltime_stream);
MYFLT risetime = PyFloat_AS_DOUBLE(self->risetime);
MYFLT risefactor = 1. / ((risetime + 0.001) * self->sr);
-
+
for (i=0; i<self->bufsize; i++) {
direction(self, in[i]);
- fallfactor = (*falltime++ + 0.001) * self->sr;
+ fallfactor = (*falltime++ + 0.001) * self->sr;
if (self->dir == 1)
val = self->y1 + (*in++ - self->y1) * risefactor;
else
@@ -2525,11 +2525,11 @@ Port_filters_aa(Port *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *risetime = Stream_getData((Stream *)self->risetime_stream);
MYFLT *falltime = Stream_getData((Stream *)self->falltime_stream);
-
+
for (i=0; i<self->bufsize; i++) {
direction(self, in[i]);
- risefactor = (*risetime++ + 0.001) * self->sr;
- fallfactor = (*falltime++ + 0.001) * self->sr;
+ risefactor = (*risetime++ + 0.001) * self->sr;
+ fallfactor = (*falltime++ + 0.001) * self->sr;
if (self->dir == 1)
val = self->y1 + (*in++ - self->y1) / risefactor;
else
@@ -2557,54 +2557,54 @@ Port_setProcMode(Port *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Port_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Port_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Port_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Port_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Port_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Port_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Port_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Port_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Port_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Port_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Port_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Port_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Port_postprocessing_revareva;
break;
- }
+ }
}
static void
Port_compute_next_data_frame(Port *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2614,23 +2614,23 @@ Port_traverse(Port *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->risetime);
- Py_VISIT(self->risetime_stream);
- Py_VISIT(self->falltime);
- Py_VISIT(self->falltime_stream);
+ Py_VISIT(self->risetime);
+ Py_VISIT(self->risetime_stream);
+ Py_VISIT(self->falltime);
+ Py_VISIT(self->falltime_stream);
return 0;
}
-static int
+static int
Port_clear(Port *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->risetime);
- Py_CLEAR(self->risetime_stream);
- Py_CLEAR(self->falltime);
- Py_CLEAR(self->falltime_stream);
+ Py_CLEAR(self->risetime);
+ Py_CLEAR(self->risetime_stream);
+ Py_CLEAR(self->falltime);
+ Py_CLEAR(self->falltime_stream);
return 0;
}
@@ -2650,7 +2650,7 @@ Port_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *risetimetmp=NULL, *falltimetmp=NULL, *multmp=NULL, *addtmp=NULL;
Port *self;
self = (Port *)type->tp_alloc(type, 0);
-
+
self->risetime = PyFloat_FromDouble(0.05);
self->falltime = PyFloat_FromDouble(0.05);
self->modebuffer[0] = 0;
@@ -2660,18 +2660,18 @@ Port_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->y1 = 0.0;
self->x1 = 0.0;
self->dir = 1;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Port_compute_next_data_frame);
self->mode_func_ptr = Port_setProcMode;
static char *kwlist[] = {"input", "risetime", "falltime", "init", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OOFOO, kwlist, &inputtmp, &risetimetmp, &falltimetmp, &inittmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (risetimetmp) {
PyObject_CallMethod((PyObject *)self, "setRiseTime", "O", risetimetmp);
}
@@ -2679,20 +2679,20 @@ Port_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (falltimetmp) {
PyObject_CallMethod((PyObject *)self, "setFallTime", "O", falltimetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
if (inittmp != 0.0)
self->x1 = self->y1 = inittmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -2700,10 +2700,10 @@ Port_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Port_getServer(Port* self) { GET_SERVER };
static PyObject * Port_getStream(Port* self) { GET_STREAM };
-static PyObject * Port_setMul(Port *self, PyObject *arg) { SET_MUL };
-static PyObject * Port_setAdd(Port *self, PyObject *arg) { SET_ADD };
-static PyObject * Port_setSub(Port *self, PyObject *arg) { SET_SUB };
-static PyObject * Port_setDiv(Port *self, PyObject *arg) { SET_DIV };
+static PyObject * Port_setMul(Port *self, PyObject *arg) { SET_MUL };
+static PyObject * Port_setAdd(Port *self, PyObject *arg) { SET_ADD };
+static PyObject * Port_setSub(Port *self, PyObject *arg) { SET_SUB };
+static PyObject * Port_setDiv(Port *self, PyObject *arg) { SET_DIV };
static PyObject * Port_play(Port *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Port_out(Port *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2722,14 +2722,14 @@ static PyObject *
Port_setRiseTime(Port *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->risetime);
@@ -2745,25 +2745,25 @@ Port_setRiseTime(Port *self, PyObject *arg)
self->risetime_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Port_setFallTime(Port *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->falltime);
@@ -2779,12 +2779,12 @@ Port_setFallTime(Port *self, PyObject *arg)
self->falltime_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Port_members[] = {
{"server", T_OBJECT_EX, offsetof(Port, server), 0, "Pyo server."},
@@ -2905,7 +2905,7 @@ typedef struct {
Stream *input_stream;
PyObject *freq;
Stream *freq_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
MYFLT lastFreq;
MYFLT nyquist;
// sample memories
@@ -2921,18 +2921,18 @@ Tone_filters_i(Tone *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
-
+
if (fr != self->lastFreq) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
+ fr = self->nyquist;
self->lastFreq = fr;
b = 2.0 - MYCOS(TWOPI * fr / self->sr);
self->c2 = (b - MYSQRT(b * b - 1.0));
self->c1 = 1.0 - self->c2;
}
-
+
for (i=0; i<self->bufsize; i++) {
val = self->c1 * in[i] + self->c2 * self->y1;
self->data[i] = val;
@@ -2946,14 +2946,14 @@ Tone_filters_a(Tone *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
- freq = fr[i];
+ freq = fr[i];
if (freq != self->lastFreq) {
if (freq <= 1.0)
freq = 1.0;
else if (freq >= self->nyquist)
- freq = self->nyquist;
+ freq = self->nyquist;
self->lastFreq = freq;
b = 2.0 - MYCOS(TWOPI * freq / self->sr);
self->c2 = (b - MYSQRT(b * b - 1.0));
@@ -2981,50 +2981,50 @@ Tone_setProcMode(Tone *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Tone_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Tone_filters_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Tone_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Tone_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Tone_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Tone_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Tone_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Tone_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Tone_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Tone_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Tone_postprocessing_revareva;
break;
- }
+ }
}
static void
Tone_compute_next_data_frame(Tone *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3034,19 +3034,19 @@ Tone_traverse(Tone *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
Tone_clear(Tone *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -3065,14 +3065,14 @@ Tone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
Tone *self;
self = (Tone *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->lastFreq = -1.0;
self->y1 = self->c1 = self->c2 = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
@@ -3081,26 +3081,26 @@ Tone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Tone_setProcMode;
static char *kwlist[] = {"input", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &freqtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3108,10 +3108,10 @@ Tone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Tone_getServer(Tone* self) { GET_SERVER };
static PyObject * Tone_getStream(Tone* self) { GET_STREAM };
-static PyObject * Tone_setMul(Tone *self, PyObject *arg) { SET_MUL };
-static PyObject * Tone_setAdd(Tone *self, PyObject *arg) { SET_ADD };
-static PyObject * Tone_setSub(Tone *self, PyObject *arg) { SET_SUB };
-static PyObject * Tone_setDiv(Tone *self, PyObject *arg) { SET_DIV };
+static PyObject * Tone_setMul(Tone *self, PyObject *arg) { SET_MUL };
+static PyObject * Tone_setAdd(Tone *self, PyObject *arg) { SET_ADD };
+static PyObject * Tone_setSub(Tone *self, PyObject *arg) { SET_SUB };
+static PyObject * Tone_setDiv(Tone *self, PyObject *arg) { SET_DIV };
static PyObject * Tone_play(Tone *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Tone_out(Tone *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3130,14 +3130,14 @@ static PyObject *
Tone_setFreq(Tone *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -3153,9 +3153,9 @@ Tone_setFreq(Tone *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3277,7 +3277,7 @@ typedef struct {
Stream *input_stream;
PyObject *freq;
Stream *freq_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
MYFLT lastFreq;
MYFLT nyquist;
// sample memories
@@ -3293,18 +3293,18 @@ Atone_filters_i(Atone *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
-
+
if (fr != self->lastFreq) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
+ fr = self->nyquist;
self->lastFreq = fr;
b = 2.0 - MYCOS(TWOPI * fr / self->sr);
self->c2 = (b - MYSQRT(b * b - 1.0));
self->c1 = 1.0 - self->c2;
}
-
+
for (i=0; i<self->bufsize; i++) {
self->y1 = val = self->c1 * in[i] + self->c2 * self->y1;
self->data[i] = in[i] - val;
@@ -3317,14 +3317,14 @@ Atone_filters_a(Atone *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
- freq = fr[i];
+ freq = fr[i];
if (freq != self->lastFreq) {
if (freq <= 1.0)
freq = 1.0;
else if (freq >= self->nyquist)
- freq = self->nyquist;
+ freq = self->nyquist;
self->lastFreq = freq;
b = 2.0 - MYCOS(TWOPI * freq / self->sr);
self->c2 = (b - MYSQRT(b * b - 1.0));
@@ -3351,50 +3351,50 @@ Atone_setProcMode(Atone *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Atone_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Atone_filters_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Atone_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Atone_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Atone_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Atone_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Atone_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Atone_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Atone_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Atone_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Atone_postprocessing_revareva;
break;
- }
+ }
}
static void
Atone_compute_next_data_frame(Atone *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3404,19 +3404,19 @@ Atone_traverse(Atone *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
Atone_clear(Atone *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -3435,14 +3435,14 @@ Atone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
Atone *self;
self = (Atone *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->lastFreq = -1.0;
self->y1 = self->c1 = self->c2 = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
@@ -3451,26 +3451,26 @@ Atone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Atone_setProcMode;
static char *kwlist[] = {"input", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &freqtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3478,10 +3478,10 @@ Atone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Atone_getServer(Atone* self) { GET_SERVER };
static PyObject * Atone_getStream(Atone* self) { GET_STREAM };
-static PyObject * Atone_setMul(Atone *self, PyObject *arg) { SET_MUL };
-static PyObject * Atone_setAdd(Atone *self, PyObject *arg) { SET_ADD };
-static PyObject * Atone_setSub(Atone *self, PyObject *arg) { SET_SUB };
-static PyObject * Atone_setDiv(Atone *self, PyObject *arg) { SET_DIV };
+static PyObject * Atone_setMul(Atone *self, PyObject *arg) { SET_MUL };
+static PyObject * Atone_setAdd(Atone *self, PyObject *arg) { SET_ADD };
+static PyObject * Atone_setSub(Atone *self, PyObject *arg) { SET_SUB };
+static PyObject * Atone_setDiv(Atone *self, PyObject *arg) { SET_DIV };
static PyObject * Atone_play(Atone *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Atone_out(Atone *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3500,14 +3500,14 @@ static PyObject *
Atone_setFreq(Atone *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -3523,9 +3523,9 @@ Atone_setFreq(Atone *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3645,7 +3645,7 @@ typedef struct {
pyo_audio_HEAD
PyObject *input;
Stream *input_stream;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
// sample memories
MYFLT x1;
MYFLT y1;
@@ -3680,44 +3680,44 @@ DCBlock_setProcMode(DCBlock *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = DCBlock_filters;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = DCBlock_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = DCBlock_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = DCBlock_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = DCBlock_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = DCBlock_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = DCBlock_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = DCBlock_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = DCBlock_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = DCBlock_postprocessing_revareva;
break;
- }
+ }
}
static void
DCBlock_compute_next_data_frame(DCBlock *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3730,7 +3730,7 @@ DCBlock_traverse(DCBlock *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
DCBlock_clear(DCBlock *self)
{
pyo_CLEAR
@@ -3754,32 +3754,32 @@ DCBlock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
DCBlock *self;
self = (DCBlock *)type->tp_alloc(type, 0);
-
+
self->x1 = self->y1 = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, DCBlock_compute_next_data_frame);
self->mode_func_ptr = DCBlock_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3787,10 +3787,10 @@ DCBlock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * DCBlock_getServer(DCBlock* self) { GET_SERVER };
static PyObject * DCBlock_getStream(DCBlock* self) { GET_STREAM };
-static PyObject * DCBlock_setMul(DCBlock *self, PyObject *arg) { SET_MUL };
-static PyObject * DCBlock_setAdd(DCBlock *self, PyObject *arg) { SET_ADD };
-static PyObject * DCBlock_setSub(DCBlock *self, PyObject *arg) { SET_SUB };
-static PyObject * DCBlock_setDiv(DCBlock *self, PyObject *arg) { SET_DIV };
+static PyObject * DCBlock_setMul(DCBlock *self, PyObject *arg) { SET_MUL };
+static PyObject * DCBlock_setAdd(DCBlock *self, PyObject *arg) { SET_ADD };
+static PyObject * DCBlock_setSub(DCBlock *self, PyObject *arg) { SET_SUB };
+static PyObject * DCBlock_setDiv(DCBlock *self, PyObject *arg) { SET_DIV };
static PyObject * DCBlock_play(DCBlock *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * DCBlock_out(DCBlock *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3930,23 +3930,23 @@ static void
Allpass_process_ii(Allpass *self) {
MYFLT val, xind, frac;
int i, ind;
-
+
MYFLT del = PyFloat_AS_DOUBLE(self->delay);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
-
+
if (del < 0.)
del = 0.;
else if (del > self->maxDelay)
del = self->maxDelay;
MYFLT sampdel = del * self->sr;
-
+
if (feed < 0)
feed = 0;
else if (feed > 1)
feed = 1;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
xind = self->in_count - sampdel;
if (xind < 0)
@@ -3955,7 +3955,7 @@ Allpass_process_ii(Allpass *self) {
frac = xind - ind;
val = self->buffer[ind] * (1.0 - frac) + self->buffer[ind+1] * frac;
self->data[i] = val * (1.0 - (feed * feed)) + in[i] * -feed;
-
+
self->buffer[self->in_count] = in[i] + (val * feed);
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
@@ -3969,17 +3969,17 @@ static void
Allpass_process_ai(Allpass *self) {
MYFLT val, xind, frac, sampdel, del;
int i, ind;
-
- MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
+
+ MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
-
+
if (feed < 0)
feed = 0;
else if (feed > 1)
feed = 1;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
del = delobj[i];
if (del < 0.)
@@ -3994,7 +3994,7 @@ Allpass_process_ai(Allpass *self) {
frac = xind - ind;
val = self->buffer[ind] * (1.0 - frac) + self->buffer[ind+1] * frac;
self->data[i] = val * (1.0 - (feed * feed)) + in[i] * -feed;
-
+
self->buffer[self->in_count] = in[i] + (val * feed);
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
@@ -4008,18 +4008,18 @@ static void
Allpass_process_ia(Allpass *self) {
MYFLT val, xind, frac, feed;
int i, ind;
-
+
MYFLT del = PyFloat_AS_DOUBLE(self->delay);
- MYFLT *fdb = Stream_getData((Stream *)self->feedback_stream);
-
+ MYFLT *fdb = Stream_getData((Stream *)self->feedback_stream);
+
if (del < 0.)
del = 0.;
else if (del > self->maxDelay)
del = self->maxDelay;
MYFLT sampdel = del * self->sr;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
feed = fdb[i];
if (feed < 0)
@@ -4047,12 +4047,12 @@ static void
Allpass_process_aa(Allpass *self) {
MYFLT val, xind, frac, sampdel, feed, del;
int i, ind;
-
- MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
- MYFLT *fdb = Stream_getData((Stream *)self->feedback_stream);
-
+
+ MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
+ MYFLT *fdb = Stream_getData((Stream *)self->feedback_stream);
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
del = delobj[i];
feed = fdb[i];
@@ -4072,7 +4072,7 @@ Allpass_process_aa(Allpass *self) {
frac = xind - ind;
val = self->buffer[ind] * (1.0 - frac) + self->buffer[ind+1] * frac;
self->data[i] = val * (1.0 - (feed * feed)) + in[i] * -feed;
-
+
self->buffer[self->in_count] = in[i] + (val * feed);
if (self->in_count == 0)
self->buffer[self->size] = self->buffer[0];
@@ -4098,56 +4098,56 @@ Allpass_setProcMode(Allpass *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Allpass_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Allpass_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Allpass_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Allpass_process_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Allpass_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Allpass_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Allpass_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Allpass_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Allpass_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Allpass_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Allpass_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Allpass_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Allpass_postprocessing_revareva;
break;
- }
+ }
}
static void
Allpass_compute_next_data_frame(Allpass *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4156,24 +4156,24 @@ Allpass_traverse(Allpass *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->delay);
- Py_VISIT(self->delay_stream);
- Py_VISIT(self->feedback);
- Py_VISIT(self->feedback_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->delay);
+ Py_VISIT(self->delay_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
return 0;
}
-static int
+static int
Allpass_clear(Allpass *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
- Py_CLEAR(self->delay);
- Py_CLEAR(self->delay_stream);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->delay);
+ Py_CLEAR(self->delay_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
return 0;
}
@@ -4193,7 +4193,7 @@ Allpass_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *delaytmp=NULL, *feedbacktmp=NULL, *multmp=NULL, *addtmp=NULL;
Allpass *self;
self = (Allpass *)type->tp_alloc(type, 0);
-
+
self->delay = PyFloat_FromDouble(0);
self->feedback = PyFloat_FromDouble(0);
self->maxDelay = 1;
@@ -4202,43 +4202,43 @@ Allpass_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Allpass_compute_next_data_frame);
self->mode_func_ptr = Allpass_setProcMode;
-
+
static char *kwlist[] = {"input", "delay", "feedback", "maxDelay", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OOFOO, kwlist, &inputtmp, &delaytmp, &feedbacktmp, &self->maxDelay, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (delaytmp) {
PyObject_CallMethod((PyObject *)self, "setDelay", "O", delaytmp);
}
-
+
if (feedbacktmp) {
PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->size = self->maxDelay * self->sr + 0.5;
-
+
self->buffer = (MYFLT *)realloc(self->buffer, (self->size+1) * sizeof(MYFLT));
for (i=0; i<(self->size+1); i++) {
self->buffer[i] = 0.;
- }
-
+ }
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -4246,10 +4246,10 @@ Allpass_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Allpass_getServer(Allpass* self) { GET_SERVER };
static PyObject * Allpass_getStream(Allpass* self) { GET_STREAM };
-static PyObject * Allpass_setMul(Allpass *self, PyObject *arg) { SET_MUL };
-static PyObject * Allpass_setAdd(Allpass *self, PyObject *arg) { SET_ADD };
-static PyObject * Allpass_setSub(Allpass *self, PyObject *arg) { SET_SUB };
-static PyObject * Allpass_setDiv(Allpass *self, PyObject *arg) { SET_DIV };
+static PyObject * Allpass_setMul(Allpass *self, PyObject *arg) { SET_MUL };
+static PyObject * Allpass_setAdd(Allpass *self, PyObject *arg) { SET_ADD };
+static PyObject * Allpass_setSub(Allpass *self, PyObject *arg) { SET_SUB };
+static PyObject * Allpass_setDiv(Allpass *self, PyObject *arg) { SET_DIV };
static PyObject * Allpass_play(Allpass *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Allpass_out(Allpass *self, PyObject *args, PyObject *kwds) { OUT };
@@ -4268,14 +4268,14 @@ static PyObject *
Allpass_setDelay(Allpass *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->delay);
@@ -4291,25 +4291,25 @@ Allpass_setDelay(Allpass *self, PyObject *arg)
self->delay_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Allpass_setFeedback(Allpass *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->feedback);
@@ -4325,12 +4325,12 @@ Allpass_setFeedback(Allpass *self, PyObject *arg)
self->feedback_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Allpass_members[] = {
{"server", T_OBJECT_EX, offsetof(Allpass, server), 0, "Pyo server."},
@@ -4451,7 +4451,7 @@ typedef struct {
PyObject *bw;
Stream *bw_stream;
int init;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
MYFLT oneOnSr;
MYFLT nyquist;
// sample memories
@@ -4464,16 +4464,16 @@ typedef struct {
static void
Allpass2_compute_variables(Allpass2 *self, MYFLT freq, MYFLT bw)
-{
+{
MYFLT radius, angle;
- if (freq <= 1)
+ if (freq <= 1)
freq = 1;
else if (freq >= self->nyquist)
freq = self->nyquist;
-
+
radius = MYPOW(E, -PI * bw * self->oneOnSr);
angle = TWOPI * freq * self->oneOnSr;
-
+
self->alpha = radius * radius;
self->beta = -2.0 * radius * MYCOS(angle);
}
@@ -4483,12 +4483,12 @@ Allpass2_filters_ii(Allpass2 *self) {
MYFLT val;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i] + (self->y1 * -self->beta) + (self->y2 * -self->alpha);
self->data[i] = (val * self->alpha) + (self->y1 * self->beta) + self->y2;
@@ -4502,15 +4502,15 @@ Allpass2_filters_ai(Allpass2 *self) {
MYFLT val, bw;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
bw = PyFloat_AS_DOUBLE(self->bw);
-
+
for (i=0; i<self->bufsize; i++) {
Allpass2_compute_variables(self, fr[i], bw);
val = in[i] + (self->y1 * -self->beta) + (self->y2 * -self->alpha);
@@ -4525,15 +4525,15 @@ Allpass2_filters_ia(Allpass2 *self) {
MYFLT val, fr;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *bw = Stream_getData((Stream *)self->bw_stream);
-
+
for (i=0; i<self->bufsize; i++) {
Allpass2_compute_variables(self, fr, bw[i]);
val = in[i] + (self->y1 * -self->beta) + (self->y2 * -self->alpha);
@@ -4548,15 +4548,15 @@ Allpass2_filters_aa(Allpass2 *self) {
MYFLT val;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->init == 1) {
self->y1 = self->y2 = in[0];
self->init = 0;
}
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *bw = Stream_getData((Stream *)self->bw_stream);
-
+
for (i=0; i<self->bufsize; i++) {
Allpass2_compute_variables(self, fr[i], bw[i]);
val = in[i] + (self->y1 * -self->beta) + (self->y2 * -self->alpha);
@@ -4584,55 +4584,55 @@ Allpass2_setProcMode(Allpass2 *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
Allpass2_compute_variables(self, PyFloat_AS_DOUBLE(self->freq), PyFloat_AS_DOUBLE(self->bw));
self->proc_func_ptr = Allpass2_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Allpass2_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Allpass2_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Allpass2_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Allpass2_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Allpass2_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Allpass2_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Allpass2_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Allpass2_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Allpass2_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Allpass2_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Allpass2_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Allpass2_postprocessing_revareva;
break;
- }
+ }
}
static void
Allpass2_compute_next_data_frame(Allpass2 *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4642,23 +4642,23 @@ Allpass2_traverse(Allpass2 *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->bw);
- Py_VISIT(self->bw_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->bw);
+ Py_VISIT(self->bw_stream);
return 0;
}
-static int
+static int
Allpass2_clear(Allpass2 *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->bw);
- Py_CLEAR(self->bw_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->bw);
+ Py_CLEAR(self->bw_stream);
return 0;
}
@@ -4677,7 +4677,7 @@ Allpass2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *bwtmp=NULL, *multmp=NULL, *addtmp=NULL;
Allpass2 *self;
self = (Allpass2 *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->bw = PyFloat_FromDouble(100);
self->modebuffer[0] = 0;
@@ -4685,9 +4685,9 @@ Allpass2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->init = 1;
-
+
INIT_OBJECT_COMMON
-
+
self->oneOnSr = 1.0 / self->sr;
self->nyquist = (MYFLT)self->sr * 0.49;
@@ -4695,30 +4695,30 @@ Allpass2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Allpass2_setProcMode;
static char *kwlist[] = {"input", "freq", "bw", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &inputtmp, &freqtmp, &bwtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (bwtmp) {
PyObject_CallMethod((PyObject *)self, "setBw", "O", bwtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -4726,10 +4726,10 @@ Allpass2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Allpass2_getServer(Allpass2* self) { GET_SERVER };
static PyObject * Allpass2_getStream(Allpass2* self) { GET_STREAM };
-static PyObject * Allpass2_setMul(Allpass2 *self, PyObject *arg) { SET_MUL };
-static PyObject * Allpass2_setAdd(Allpass2 *self, PyObject *arg) { SET_ADD };
-static PyObject * Allpass2_setSub(Allpass2 *self, PyObject *arg) { SET_SUB };
-static PyObject * Allpass2_setDiv(Allpass2 *self, PyObject *arg) { SET_DIV };
+static PyObject * Allpass2_setMul(Allpass2 *self, PyObject *arg) { SET_MUL };
+static PyObject * Allpass2_setAdd(Allpass2 *self, PyObject *arg) { SET_ADD };
+static PyObject * Allpass2_setSub(Allpass2 *self, PyObject *arg) { SET_SUB };
+static PyObject * Allpass2_setDiv(Allpass2 *self, PyObject *arg) { SET_DIV };
static PyObject * Allpass2_play(Allpass2 *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Allpass2_out(Allpass2 *self, PyObject *args, PyObject *kwds) { OUT };
@@ -4748,14 +4748,14 @@ static PyObject *
Allpass2_setFreq(Allpass2 *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -4771,25 +4771,25 @@ Allpass2_setFreq(Allpass2 *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Allpass2_setBw(Allpass2 *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->bw);
@@ -4805,12 +4805,12 @@ Allpass2_setBw(Allpass2 *self, PyObject *arg)
self->bw_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Allpass2_members[] = {
{"server", T_OBJECT_EX, offsetof(Allpass2, server), 0, "Pyo server."},
@@ -4938,7 +4938,7 @@ typedef struct {
PyObject *feedback;
Stream *feedback_stream;
int stages;
- int modebuffer[6]; // need at least 2 slots for mul & add
+ int modebuffer[6]; // need at least 2 slots for mul & add
MYFLT halfSr;
MYFLT minusPiOnSr;
MYFLT twoPiOnSr;
@@ -4958,35 +4958,35 @@ Phaser_clip(MYFLT x) {
return -1.0;
else if (x > 1.0)
return 1.0;
- else
+ else
return x;
-}
+}
static void
Phaser_compute_variables(Phaser *self, MYFLT freq, MYFLT spread, MYFLT q)
-{
+{
int i, ipart;
MYFLT radius, angle, fr, qfactor, pos, fpart;
qfactor = 1.0 / q * self->minusPiOnSr;
fr = freq;
for (i=0; i<self->stages; i++) {
- if (fr <= 20)
+ if (fr <= 20)
fr = 20;
else if (fr >= self->halfSr)
fr = self->halfSr;
-
+
radius = MYPOW(E, fr * qfactor);
angle = fr * self->twoPiOnSr;
-
+
self->alpha[i] = radius * radius;
-
+
pos = angle * self->norm_arr_pos;
ipart = (int)pos;
fpart = pos - ipart;
self->beta[i] = -2.0 * radius * (HALF_COS_ARRAY[i] * (1.0 - fpart) + HALF_COS_ARRAY[i+1] * fpart);
fr *= spread;
- }
+ }
}
static void
@@ -5007,7 +5007,7 @@ Phaser_filters_iii(Phaser *self) {
}
self->data[i] = self->tmp;
}
- }
+ }
else {
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
for (i=0; i<self->bufsize; i++) {
@@ -5031,7 +5031,7 @@ Phaser_filters_aii(Phaser *self) {
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
MYFLT spread = PyFloat_AS_DOUBLE(self->spread);
MYFLT q = PyFloat_AS_DOUBLE(self->q);
-
+
if (self->modebuffer[5] == 0) {
MYFLT feed = Phaser_clip(PyFloat_AS_DOUBLE(self->feedback));
for (i=0; i<self->bufsize; i++) {
@@ -5045,7 +5045,7 @@ Phaser_filters_aii(Phaser *self) {
}
self->data[i] = self->tmp;
}
- }
+ }
else {
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
for (i=0; i<self->bufsize; i++) {
@@ -5070,7 +5070,7 @@ Phaser_filters_iai(Phaser *self) {
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *spread = Stream_getData((Stream *)self->spread_stream);
MYFLT q = PyFloat_AS_DOUBLE(self->q);
-
+
if (self->modebuffer[5] == 0) {
MYFLT feed = Phaser_clip(PyFloat_AS_DOUBLE(self->feedback));
for (i=0; i<self->bufsize; i++) {
@@ -5084,7 +5084,7 @@ Phaser_filters_iai(Phaser *self) {
}
self->data[i] = self->tmp;
}
- }
+ }
else {
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
for (i=0; i<self->bufsize; i++) {
@@ -5109,7 +5109,7 @@ Phaser_filters_aai(Phaser *self) {
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
MYFLT *spread = Stream_getData((Stream *)self->spread_stream);
MYFLT q = PyFloat_AS_DOUBLE(self->q);
-
+
if (self->modebuffer[5] == 0) {
MYFLT feed = Phaser_clip(PyFloat_AS_DOUBLE(self->feedback));
for (i=0; i<self->bufsize; i++) {
@@ -5123,7 +5123,7 @@ Phaser_filters_aai(Phaser *self) {
}
self->data[i] = self->tmp;
}
- }
+ }
else {
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
for (i=0; i<self->bufsize; i++) {
@@ -5148,7 +5148,7 @@ Phaser_filters_iia(Phaser *self) {
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT spread = PyFloat_AS_DOUBLE(self->spread);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
-
+
if (self->modebuffer[5] == 0) {
MYFLT feed = Phaser_clip(PyFloat_AS_DOUBLE(self->feedback));
for (i=0; i<self->bufsize; i++) {
@@ -5162,7 +5162,7 @@ Phaser_filters_iia(Phaser *self) {
}
self->data[i] = self->tmp;
}
- }
+ }
else {
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
for (i=0; i<self->bufsize; i++) {
@@ -5187,7 +5187,7 @@ Phaser_filters_aia(Phaser *self) {
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
MYFLT spread = PyFloat_AS_DOUBLE(self->spread);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
-
+
if (self->modebuffer[5] == 0) {
MYFLT feed = Phaser_clip(PyFloat_AS_DOUBLE(self->feedback));
for (i=0; i<self->bufsize; i++) {
@@ -5201,7 +5201,7 @@ Phaser_filters_aia(Phaser *self) {
}
self->data[i] = self->tmp;
}
- }
+ }
else {
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
for (i=0; i<self->bufsize; i++) {
@@ -5226,7 +5226,7 @@ Phaser_filters_iaa(Phaser *self) {
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *spread = Stream_getData((Stream *)self->spread_stream);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
-
+
if (self->modebuffer[5] == 0) {
MYFLT feed = Phaser_clip(PyFloat_AS_DOUBLE(self->feedback));
for (i=0; i<self->bufsize; i++) {
@@ -5240,7 +5240,7 @@ Phaser_filters_iaa(Phaser *self) {
}
self->data[i] = self->tmp;
}
- }
+ }
else {
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
for (i=0; i<self->bufsize; i++) {
@@ -5265,7 +5265,7 @@ Phaser_filters_aaa(Phaser *self) {
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
MYFLT *spread = Stream_getData((Stream *)self->spread_stream);
MYFLT *q = Stream_getData((Stream *)self->q_stream);
-
+
if (self->modebuffer[5] == 0) {
MYFLT feed = Phaser_clip(PyFloat_AS_DOUBLE(self->feedback));
for (i=0; i<self->bufsize; i++) {
@@ -5279,7 +5279,7 @@ Phaser_filters_aaa(Phaser *self) {
}
self->data[i] = self->tmp;
}
- }
+ }
else {
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
for (i=0; i<self->bufsize; i++) {
@@ -5312,69 +5312,69 @@ Phaser_setProcMode(Phaser *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
Phaser_compute_variables(self, PyFloat_AS_DOUBLE(self->freq), PyFloat_AS_DOUBLE(self->spread), PyFloat_AS_DOUBLE(self->q));
self->proc_func_ptr = Phaser_filters_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Phaser_filters_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Phaser_filters_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Phaser_filters_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Phaser_filters_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Phaser_filters_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Phaser_filters_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Phaser_filters_aaa;
- break;
- }
+ break;
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Phaser_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Phaser_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Phaser_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Phaser_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Phaser_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Phaser_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Phaser_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Phaser_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Phaser_postprocessing_revareva;
break;
- }
+ }
}
static void
Phaser_compute_next_data_frame(Phaser *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -5384,31 +5384,31 @@ Phaser_traverse(Phaser *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->spread);
- Py_VISIT(self->spread_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
- Py_VISIT(self->feedback);
- Py_VISIT(self->feedback_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->spread);
+ Py_VISIT(self->spread_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
return 0;
}
-static int
+static int
Phaser_clear(Phaser *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->spread);
- Py_CLEAR(self->spread_stream);
- Py_CLEAR(self->q);
- Py_CLEAR(self->q_stream);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->spread);
+ Py_CLEAR(self->spread_stream);
+ Py_CLEAR(self->q);
+ Py_CLEAR(self->q_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
return 0;
}
@@ -5431,7 +5431,7 @@ Phaser_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *spreadtmp=NULL, *qtmp=NULL, *feedbacktmp=NULL, *multmp=NULL, *addtmp=NULL;
Phaser *self;
self = (Phaser *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000.0);
self->spread = PyFloat_FromDouble(1.0);
self->q = PyFloat_FromDouble(10.0);
@@ -5444,30 +5444,30 @@ Phaser_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
self->modebuffer[5] = 0;
-
+
INIT_OBJECT_COMMON
-
+
self->halfSr = (MYFLT)self->sr * 0.49;
self->minusPiOnSr = -PI / self->sr;
self->twoPiOnSr = TWOPI / self->sr;
self->norm_arr_pos = 1.0 / PI * 512.0;
-
+
Stream_setFunctionPtr(self->stream, Phaser_compute_next_data_frame);
self->mode_func_ptr = Phaser_setProcMode;
static char *kwlist[] = {"input", "freq", "spread", "q", "feedback", "num", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOiOO", kwlist, &inputtmp, &freqtmp, &spreadtmp, &qtmp, &feedbacktmp, &self->stages, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
self->y1 = (MYFLT *)realloc(self->y1, self->stages * sizeof(MYFLT));
self->y2 = (MYFLT *)realloc(self->y2, self->stages * sizeof(MYFLT));
self->alpha = (MYFLT *)realloc(self->alpha, self->stages * sizeof(MYFLT));
self->beta = (MYFLT *)realloc(self->beta, self->stages * sizeof(MYFLT));
-
-
+
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -5475,7 +5475,7 @@ Phaser_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (spreadtmp) {
PyObject_CallMethod((PyObject *)self, "setSpread", "O", spreadtmp);
}
-
+
if (qtmp) {
PyObject_CallMethod((PyObject *)self, "setQ", "O", qtmp);
}
@@ -5483,19 +5483,19 @@ Phaser_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (feedbacktmp) {
PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
for (i=0; i<self->stages; i++) {
self->y1[i] = self->y2[i] = 0.0;
}
@@ -5505,10 +5505,10 @@ Phaser_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Phaser_getServer(Phaser* self) { GET_SERVER };
static PyObject * Phaser_getStream(Phaser* self) { GET_STREAM };
-static PyObject * Phaser_setMul(Phaser *self, PyObject *arg) { SET_MUL };
-static PyObject * Phaser_setAdd(Phaser *self, PyObject *arg) { SET_ADD };
-static PyObject * Phaser_setSub(Phaser *self, PyObject *arg) { SET_SUB };
-static PyObject * Phaser_setDiv(Phaser *self, PyObject *arg) { SET_DIV };
+static PyObject * Phaser_setMul(Phaser *self, PyObject *arg) { SET_MUL };
+static PyObject * Phaser_setAdd(Phaser *self, PyObject *arg) { SET_ADD };
+static PyObject * Phaser_setSub(Phaser *self, PyObject *arg) { SET_SUB };
+static PyObject * Phaser_setDiv(Phaser *self, PyObject *arg) { SET_DIV };
static PyObject * Phaser_play(Phaser *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Phaser_out(Phaser *self, PyObject *args, PyObject *kwds) { OUT };
@@ -5527,14 +5527,14 @@ static PyObject *
Phaser_setFreq(Phaser *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -5550,25 +5550,25 @@ Phaser_setFreq(Phaser *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Phaser_setSpread(Phaser *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->spread);
@@ -5584,25 +5584,25 @@ Phaser_setSpread(Phaser *self, PyObject *arg)
self->spread_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Phaser_setQ(Phaser *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -5618,25 +5618,25 @@ Phaser_setQ(Phaser *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Phaser_setFeedback(Phaser *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->feedback);
@@ -5655,7 +5655,7 @@ Phaser_setFeedback(Phaser *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Phaser_members[] = {
{"server", T_OBJECT_EX, offsetof(Phaser, server), 0, "Pyo server."},
@@ -5795,7 +5795,7 @@ typedef struct {
int flag;
MYFLT nyquist;
MYFLT twoPiOnSr;
- int modebuffer[6]; // need at least 2 slots for mul & add
+ int modebuffer[6]; // need at least 2 slots for mul & add
// sample memories
MYFLT *y1;
MYFLT *y2;
@@ -5832,24 +5832,24 @@ Vocoder_allocate_memories(Vocoder *self)
self->yy1[i2j] = self->yy2[i2j] = self->y1[i2j] = self->y2[i2j] = 0.0;
}
}
- self->flag = 1;
+ self->flag = 1;
}
static void
Vocoder_compute_variables(Vocoder *self, MYFLT base, MYFLT spread, MYFLT q)
-{
+{
int i;
MYFLT w0, c, alpha, freq, invqfac;
-
+
invqfac = 1.0 / (2.0 * q);
for (i=0; i<self->stages; i++) {
freq = base * MYPOW(i+1, spread);
- if (freq <= 10)
+ if (freq <= 10)
freq = 10.0;
else if (freq >= self->nyquist)
freq = self->nyquist;
-
+
w0 = self->twoPiOnSr * freq;
c = MYCOS(w0);
alpha = MYSIN(w0) * invqfac;
@@ -5860,21 +5860,21 @@ Vocoder_compute_variables(Vocoder *self, MYFLT base, MYFLT spread, MYFLT q)
self->a2[i] = 1.0 - alpha;
}
}
-
+
static void
Vocoder_filters_iii(Vocoder *self) {
int i, j, j2;
MYFLT vin, vout, vin2, vout2, w, w2, freq, spread, q, slope, output, amp;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
freq = PyFloat_AS_DOUBLE(self->freq);
spread = PyFloat_AS_DOUBLE(self->spread);
q = PyFloat_AS_DOUBLE(self->q);
if (q < 0.1)
q = 0.1;
amp = q * 10.0;
-
+
if (self->modebuffer[5] == 0)
slope = PyFloat_AS_DOUBLE(self->slope);
else
@@ -5896,7 +5896,7 @@ Vocoder_filters_iii(Vocoder *self) {
self->flag = 0;
Vocoder_compute_variables(self, freq, spread, q);
}
-
+
for (i=0; i<self->bufsize; i++) {
output = 0.0;
vin = in[i];
@@ -5908,26 +5908,26 @@ Vocoder_filters_iii(Vocoder *self) {
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 1 */
w2 = ( vin2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
j2++;
/* Analysis part filter 2 */
w = ( vout - (self->a1[j] * self->y1[j2]) - (self->a2[j] * self->y2[j2]) ) * self->a0[j];
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 2 */
w2 = ( vout2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
/* Follower */
if (vout < 0.0)
vout = -vout;
@@ -5953,7 +5953,7 @@ Vocoder_filters_aii(Vocoder *self) {
if (q < 0.1)
q = 0.1;
amp = q * 10.0;
-
+
if (self->modebuffer[5] == 0)
slope = PyFloat_AS_DOUBLE(self->slope);
else
@@ -5966,7 +5966,7 @@ Vocoder_filters_aii(Vocoder *self) {
self->last_slope = slope;
self->factor = MYEXP(-1.0 / (self->sr / ((slope * 48.0) + 2.0)));
}
-
+
for (i=0; i<self->bufsize; i++) {
if (count == 0)
freq = fr[i];
@@ -5991,26 +5991,26 @@ Vocoder_filters_aii(Vocoder *self) {
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 1 */
w2 = ( vin2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
j2++;
/* Analysis part filter 2 */
w = ( vout - (self->a1[j] * self->y1[j2]) - (self->a2[j] * self->y2[j2]) ) * self->a0[j];
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 2 */
w2 = ( vout2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
/* Follower */
if (vout < 0.0)
vout = -vout;
@@ -6028,7 +6028,7 @@ Vocoder_filters_iai(Vocoder *self) {
MYFLT vin, vout, vin2, vout2, w, w2, freq, q, slope, output, amp;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *sprd = Stream_getData((Stream *)self->spread_stream);
MYFLT spread = sprd[0];
@@ -6036,7 +6036,7 @@ Vocoder_filters_iai(Vocoder *self) {
if (q < 0.1)
q = 0.1;
amp = q * 10.0;
-
+
if (self->modebuffer[5] == 0)
slope = PyFloat_AS_DOUBLE(self->slope);
else
@@ -6049,7 +6049,7 @@ Vocoder_filters_iai(Vocoder *self) {
self->last_slope = slope;
self->factor = MYEXP(-1.0 / (self->sr / ((slope * 48.0) + 2.0)));
}
-
+
for (i=0; i<self->bufsize; i++) {
if (count == 0)
spread = sprd[i];
@@ -6074,26 +6074,26 @@ Vocoder_filters_iai(Vocoder *self) {
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 1 */
w2 = ( vin2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
j2++;
/* Analysis part filter 2 */
w = ( vout - (self->a1[j] * self->y1[j2]) - (self->a2[j] * self->y2[j2]) ) * self->a0[j];
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 2 */
w2 = ( vout2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
/* Follower */
if (vout < 0.0)
vout = -vout;
@@ -6101,7 +6101,7 @@ Vocoder_filters_iai(Vocoder *self) {
output += vout2 * self->follow[j];
}
self->data[i] = output * amp;
- }
+ }
}
static void
@@ -6111,7 +6111,7 @@ Vocoder_filters_aai(Vocoder *self) {
MYFLT vin, vout, vin2, vout2, w, w2, q, slope, output, amp;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT freq = fr[0];
MYFLT *sprd = Stream_getData((Stream *)self->spread_stream);
@@ -6120,7 +6120,7 @@ Vocoder_filters_aai(Vocoder *self) {
if (q < 0.1)
q = 0.1;
amp = q * 10.0;
-
+
if (self->modebuffer[5] == 0)
slope = PyFloat_AS_DOUBLE(self->slope);
else
@@ -6133,7 +6133,7 @@ Vocoder_filters_aai(Vocoder *self) {
self->last_slope = slope;
self->factor = MYEXP(-1.0 / (self->sr / ((slope * 48.0) + 2.0)));
}
-
+
for (i=0; i<self->bufsize; i++) {
if (count == 0) {
freq = fr[i];
@@ -6160,26 +6160,26 @@ Vocoder_filters_aai(Vocoder *self) {
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 1 */
w2 = ( vin2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
j2++;
/* Analysis part filter 2 */
w = ( vout - (self->a1[j] * self->y1[j2]) - (self->a2[j] * self->y2[j2]) ) * self->a0[j];
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 2 */
w2 = ( vout2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
/* Follower */
if (vout < 0.0)
vout = -vout;
@@ -6187,7 +6187,7 @@ Vocoder_filters_aai(Vocoder *self) {
output += vout2 * self->follow[j];
}
self->data[i] = output * amp;
- }
+ }
}
static void
@@ -6197,7 +6197,7 @@ Vocoder_filters_iia(Vocoder *self) {
MYFLT vin, vout, vin2, vout2, w, w2, freq, spread, slope, output, amp = 1.0;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
freq = PyFloat_AS_DOUBLE(self->freq);
spread = PyFloat_AS_DOUBLE(self->spread);
MYFLT *qstr = Stream_getData((Stream *)self->q_stream);
@@ -6214,13 +6214,13 @@ Vocoder_filters_iia(Vocoder *self) {
self->last_slope = slope;
self->factor = MYEXP(-1.0 / (self->sr / ((slope * 48.0) + 2.0)));
}
-
+
for (i=0; i<self->bufsize; i++) {
if (count == 0) {
q = qstr[i];
if (q < 0.1)
q = 0.1;
- amp = q * 10.0;
+ amp = q * 10.0;
}
else if (count >= maxcount)
count = 0;
@@ -6243,26 +6243,26 @@ Vocoder_filters_iia(Vocoder *self) {
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 1 */
w2 = ( vin2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
j2++;
/* Analysis part filter 2 */
w = ( vout - (self->a1[j] * self->y1[j2]) - (self->a2[j] * self->y2[j2]) ) * self->a0[j];
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 2 */
w2 = ( vout2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
/* Follower */
if (vout < 0.0)
vout = -vout;
@@ -6270,7 +6270,7 @@ Vocoder_filters_iia(Vocoder *self) {
output += vout2 * self->follow[j];
}
self->data[i] = output * amp;
- }
+ }
}
static void
@@ -6280,7 +6280,7 @@ Vocoder_filters_aia(Vocoder *self) {
MYFLT vin, vout, vin2, vout2, w, w2, spread, slope, output, amp = 1.0;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT freq = fr[0];
spread = PyFloat_AS_DOUBLE(self->spread);
@@ -6298,14 +6298,14 @@ Vocoder_filters_aia(Vocoder *self) {
self->last_slope = slope;
self->factor = MYEXP(-1.0 / (self->sr / ((slope * 48.0) + 2.0)));
}
-
+
for (i=0; i<self->bufsize; i++) {
if (count == 0) {
freq = fr[i];
q = qstr[i];
if (q < 0.1)
q = 0.1;
- amp = q * 10.0;
+ amp = q * 10.0;
}
else if (count >= maxcount)
count = 0;
@@ -6328,26 +6328,26 @@ Vocoder_filters_aia(Vocoder *self) {
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 1 */
w2 = ( vin2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
j2++;
/* Analysis part filter 2 */
w = ( vout - (self->a1[j] * self->y1[j2]) - (self->a2[j] * self->y2[j2]) ) * self->a0[j];
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 2 */
w2 = ( vout2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
/* Follower */
if (vout < 0.0)
vout = -vout;
@@ -6355,7 +6355,7 @@ Vocoder_filters_aia(Vocoder *self) {
output += vout2 * self->follow[j];
}
self->data[i] = output * amp;
- }
+ }
}
static void
@@ -6365,7 +6365,7 @@ Vocoder_filters_iaa(Vocoder *self) {
MYFLT vin, vout, vin2, vout2, w, w2, freq, slope, output, amp = 1.0;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *sprd = Stream_getData((Stream *)self->spread_stream);
MYFLT spread = sprd[0];
@@ -6383,14 +6383,14 @@ Vocoder_filters_iaa(Vocoder *self) {
self->last_slope = slope;
self->factor = MYEXP(-1.0 / (self->sr / ((slope * 48.0) + 2.0)));
}
-
+
for (i=0; i<self->bufsize; i++) {
if (count == 0) {
spread = sprd[i];
q = qstr[i];
if (q < 0.1)
q = 0.1;
- amp = q * 10.0;
+ amp = q * 10.0;
}
else if (count >= maxcount)
count = 0;
@@ -6413,26 +6413,26 @@ Vocoder_filters_iaa(Vocoder *self) {
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 1 */
w2 = ( vin2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
j2++;
/* Analysis part filter 2 */
w = ( vout - (self->a1[j] * self->y1[j2]) - (self->a2[j] * self->y2[j2]) ) * self->a0[j];
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 2 */
w2 = ( vout2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
/* Follower */
if (vout < 0.0)
vout = -vout;
@@ -6440,7 +6440,7 @@ Vocoder_filters_iaa(Vocoder *self) {
output += vout2 * self->follow[j];
}
self->data[i] = output * amp;
- }
+ }
}
static void
@@ -6450,7 +6450,7 @@ Vocoder_filters_aaa(Vocoder *self) {
MYFLT vin, vout, vin2, vout2, w, w2, slope, output, amp = 1.0;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT freq = fr[0];
MYFLT *sprd = Stream_getData((Stream *)self->spread_stream);
@@ -6469,7 +6469,7 @@ Vocoder_filters_aaa(Vocoder *self) {
self->last_slope = slope;
self->factor = MYEXP(-1.0 / (self->sr / ((slope * 99.0) + 1.0)));
}
-
+
for (i=0; i<self->bufsize; i++) {
if (count == 0) {
freq = fr[i];
@@ -6477,7 +6477,7 @@ Vocoder_filters_aaa(Vocoder *self) {
q = qstr[i];
if (q < 0.1)
q = 0.1;
- amp = q * 10.0;
+ amp = q * 10.0;
}
else if (count >= maxcount)
count = 0;
@@ -6500,26 +6500,26 @@ Vocoder_filters_aaa(Vocoder *self) {
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 1 */
w2 = ( vin2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
j2++;
/* Analysis part filter 2 */
w = ( vout - (self->a1[j] * self->y1[j2]) - (self->a2[j] * self->y2[j2]) ) * self->a0[j];
vout = (self->b0[j] * w) + (self->b2[j] * self->y2[j2]);
self->y2[j2] = self->y1[j2];
self->y1[j2] = w;
-
+
/* Exciter part filter 2 */
w2 = ( vout2 - (self->a1[j] * self->yy1[j2]) - (self->a2[j] * self->yy2[j2]) ) * self->a0[j];
vout2 = (self->b0[j] * w2) + (self->b2[j] * self->yy2[j2]);
self->yy2[j2] = self->yy1[j2];
self->yy1[j2] = w2;
-
+
/* Follower */
if (vout < 0.0)
vout = -vout;
@@ -6527,7 +6527,7 @@ Vocoder_filters_aaa(Vocoder *self) {
output += vout2 * self->follow[j];
}
self->data[i] = output * amp;
- }
+ }
}
static void Vocoder_postprocessing_ii(Vocoder *self) { POST_PROCESSING_II };
@@ -6548,66 +6548,66 @@ Vocoder_setProcMode(Vocoder *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Vocoder_filters_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Vocoder_filters_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Vocoder_filters_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Vocoder_filters_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Vocoder_filters_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Vocoder_filters_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Vocoder_filters_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Vocoder_filters_aaa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Vocoder_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Vocoder_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Vocoder_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Vocoder_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Vocoder_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Vocoder_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Vocoder_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Vocoder_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Vocoder_postprocessing_revareva;
break;
- }
+ }
}
static void
Vocoder_compute_next_data_frame(Vocoder *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -6619,18 +6619,18 @@ Vocoder_traverse(Vocoder *self, visitproc visit, void *arg)
Py_VISIT(self->input_stream);
Py_VISIT(self->input2);
Py_VISIT(self->input2_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->spread);
- Py_VISIT(self->spread_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
- Py_VISIT(self->slope);
- Py_VISIT(self->slope_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->spread);
+ Py_VISIT(self->spread_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
+ Py_VISIT(self->slope);
+ Py_VISIT(self->slope_stream);
return 0;
}
-static int
+static int
Vocoder_clear(Vocoder *self)
{
pyo_CLEAR
@@ -6638,12 +6638,12 @@ Vocoder_clear(Vocoder *self)
Py_CLEAR(self->input_stream);
Py_CLEAR(self->input2);
Py_CLEAR(self->input2_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
Py_CLEAR(self->spread);
Py_CLEAR(self->spread_stream);
- Py_CLEAR(self->q);
- Py_CLEAR(self->q_stream);
+ Py_CLEAR(self->q);
+ Py_CLEAR(self->q_stream);
Py_CLEAR(self->slope);
Py_CLEAR(self->slope_stream);
return 0;
@@ -6674,7 +6674,7 @@ Vocoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *input2tmp, *input2_streamtmp, *freqtmp=NULL, *spreadtmp=NULL, *qtmp=NULL, *slopetmp=NULL, *multmp=NULL, *addtmp=NULL;
Vocoder *self;
self = (Vocoder *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(60);
self->spread = PyFloat_FromDouble(1.25);
self->q = PyFloat_FromDouble(20);
@@ -6690,36 +6690,33 @@ Vocoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
self->modebuffer[5] = 0;
-
+
INIT_OBJECT_COMMON
-
+
self->nyquist = (MYFLT)self->sr * 0.49;
self->twoPiOnSr = (MYFLT)(TWOPI / self->sr);
-
+
Stream_setFunctionPtr(self->stream, Vocoder_compute_next_data_frame);
self->mode_func_ptr = Vocoder_setProcMode;
static char *kwlist[] = {"input", "input2", "freq", "spread", "q", "slope", "stages", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOOOiOO", kwlist, &inputtmp, &input2tmp, &freqtmp, &spreadtmp, &qtmp, &slopetmp, &self->stages, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if ( PyObject_HasAttrString((PyObject *)input2tmp, "server") == 0 ) {
- PySys_WriteStderr("TypeError: \"input2\" argument of Vocoder must be a PyoObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
- }
+ PyErr_SetString(PyExc_TypeError, "\"input2\" argument of Vocoder must be a PyoObject.\n");
+ Py_RETURN_NONE;
+ }
Py_XDECREF(self->input2);
self->input2 = input2tmp;
input2_streamtmp = PyObject_CallMethod((PyObject *)self->input2, "_getStream", NULL);
Py_INCREF(input2_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (Stream *)input2_streamtmp;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -6727,7 +6724,7 @@ Vocoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (spreadtmp) {
PyObject_CallMethod((PyObject *)self, "setSpread", "O", spreadtmp);
}
-
+
if (qtmp) {
PyObject_CallMethod((PyObject *)self, "setQ", "O", qtmp);
}
@@ -6735,19 +6732,19 @@ Vocoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (slopetmp) {
PyObject_CallMethod((PyObject *)self, "setSlope", "O", slopetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
Vocoder_allocate_memories(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -6755,10 +6752,10 @@ Vocoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Vocoder_getServer(Vocoder* self) { GET_SERVER };
static PyObject * Vocoder_getStream(Vocoder* self) { GET_STREAM };
-static PyObject * Vocoder_setMul(Vocoder *self, PyObject *arg) { SET_MUL };
-static PyObject * Vocoder_setAdd(Vocoder *self, PyObject *arg) { SET_ADD };
-static PyObject * Vocoder_setSub(Vocoder *self, PyObject *arg) { SET_SUB };
-static PyObject * Vocoder_setDiv(Vocoder *self, PyObject *arg) { SET_DIV };
+static PyObject * Vocoder_setMul(Vocoder *self, PyObject *arg) { SET_MUL };
+static PyObject * Vocoder_setAdd(Vocoder *self, PyObject *arg) { SET_ADD };
+static PyObject * Vocoder_setSub(Vocoder *self, PyObject *arg) { SET_SUB };
+static PyObject * Vocoder_setDiv(Vocoder *self, PyObject *arg) { SET_DIV };
static PyObject * Vocoder_play(Vocoder *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Vocoder_out(Vocoder *self, PyObject *args, PyObject *kwds) { OUT };
@@ -6777,14 +6774,14 @@ static PyObject *
Vocoder_setFreq(Vocoder *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -6800,25 +6797,25 @@ Vocoder_setFreq(Vocoder *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Vocoder_setSpread(Vocoder *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->spread);
@@ -6834,25 +6831,25 @@ Vocoder_setSpread(Vocoder *self, PyObject *arg)
self->spread_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Vocoder_setQ(Vocoder *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -6868,25 +6865,25 @@ Vocoder_setQ(Vocoder *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Vocoder_setSlope(Vocoder *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->slope);
@@ -6902,32 +6899,32 @@ Vocoder_setSlope(Vocoder *self, PyObject *arg)
self->slope_stream = (Stream *)streamtmp;
self->modebuffer[5] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Vocoder_setStages(Vocoder *self, PyObject *arg)
{
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->stages = PyInt_AsLong(arg);
Vocoder_allocate_memories(self);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Vocoder_members[] = {
{"server", T_OBJECT_EX, offsetof(Vocoder, server), 0, "Pyo server."},
@@ -7055,7 +7052,7 @@ typedef struct {
Stream *q_stream;
PyObject *type;
Stream *type_stream;
- int modebuffer[5]; // need at least 2 slots for mul & add
+ int modebuffer[5]; // need at least 2 slots for mul & add
MYFLT srOverSix;
MYFLT last_freq;
MYFLT piOverSr;
@@ -7076,21 +7073,21 @@ SVF_filters_iii(SVF *self) {
freq = PyFloat_AS_DOUBLE(self->freq);
q = PyFloat_AS_DOUBLE(self->q);
type = PyFloat_AS_DOUBLE(self->type);
-
+
if (freq < 0.1)
freq = 0.1;
else if (freq > self->srOverSix)
freq = self->srOverSix;
-
+
if (freq != self->last_freq) {
self->last_freq = freq;
self->w = 2.0 * MYSIN(freq * self->piOverSr);
}
-
+
if (q < 0.5)
q = 0.5;
q1 = 1.0 / q;
-
+
if (type < 0.0)
type = 0.0;
else if (type > 1.0)
@@ -7127,7 +7124,7 @@ SVF_filters_aii(SVF *self) {
if (q < 0.5)
q = 0.5;
q1 = 1.0 / q;
-
+
if (type < 0.0)
type = 0.0;
else if (type > 1.0)
@@ -7142,7 +7139,7 @@ SVF_filters_aii(SVF *self) {
freq = 0.1;
else if (freq > self->srOverSix)
freq = self->srOverSix;
-
+
if (freq != self->last_freq) {
self->last_freq = freq;
self->w = 2.0 * MYSIN(freq * self->piOverSr);
@@ -7170,12 +7167,12 @@ SVF_filters_iai(SVF *self) {
freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *qst = Stream_getData((Stream *)self->q_stream);
type = PyFloat_AS_DOUBLE(self->type);
-
+
if (freq < 0.1)
freq = 0.1;
else if (freq > self->srOverSix)
freq = self->srOverSix;
-
+
if (freq != self->last_freq) {
self->last_freq = freq;
self->w = 2.0 * MYSIN(freq * self->piOverSr);
@@ -7217,7 +7214,7 @@ SVF_filters_aai(SVF *self) {
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *qst = Stream_getData((Stream *)self->q_stream);
type = PyFloat_AS_DOUBLE(self->type);
-
+
if (type < 0.0)
type = 0.0;
else if (type > 1.0)
@@ -7233,7 +7230,7 @@ SVF_filters_aai(SVF *self) {
freq = 0.1;
else if (freq > self->srOverSix)
freq = self->srOverSix;
-
+
if (freq != self->last_freq) {
self->last_freq = freq;
self->w = 2.0 * MYSIN(freq * self->piOverSr);
@@ -7264,17 +7261,17 @@ SVF_filters_iia(SVF *self) {
freq = PyFloat_AS_DOUBLE(self->freq);
q = PyFloat_AS_DOUBLE(self->q);
MYFLT *tp = Stream_getData((Stream *)self->type_stream);
-
+
if (freq < 0.1)
freq = 0.1;
else if (freq > self->srOverSix)
freq = self->srOverSix;
-
+
if (freq != self->last_freq) {
self->last_freq = freq;
self->w = 2.0 * MYSIN(freq * self->piOverSr);
}
-
+
if (q < 0.5)
q = 0.5;
q1 = 1.0 / q;
@@ -7323,7 +7320,7 @@ SVF_filters_aia(SVF *self) {
freq = 0.1;
else if (freq > self->srOverSix)
freq = self->srOverSix;
-
+
if (freq != self->last_freq) {
self->last_freq = freq;
self->w = 2.0 * MYSIN(freq * self->piOverSr);
@@ -7334,7 +7331,7 @@ SVF_filters_aia(SVF *self) {
type = 1.0;
lowgain = (type <= 0.5) ? (0.5 - type) : 0.0;
highgain = (type >= 0.5) ? (type - 0.5) : 0.0;
- bandgain = (type <= 0.5) ? type : (1.0 - type);
+ bandgain = (type <= 0.5) ? type : (1.0 - type);
low = self->y2 + self->w * self->y1;
high = in[i] - low - q1 * self->y1;
band = self->w * high + self->y1;
@@ -7358,12 +7355,12 @@ SVF_filters_iaa(SVF *self) {
freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *qst = Stream_getData((Stream *)self->q_stream);
MYFLT *tp = Stream_getData((Stream *)self->type_stream);
-
+
if (freq < 0.1)
freq = 0.1;
else if (freq > self->srOverSix)
freq = self->srOverSix;
-
+
if (freq != self->last_freq) {
self->last_freq = freq;
self->w = 2.0 * MYSIN(freq * self->piOverSr);
@@ -7414,7 +7411,7 @@ SVF_filters_aaa(SVF *self) {
freq = 0.1;
else if (freq > self->srOverSix)
freq = self->srOverSix;
-
+
if (freq != self->last_freq) {
self->last_freq = freq;
self->w = 2.0 * MYSIN(freq * self->piOverSr);
@@ -7428,7 +7425,7 @@ SVF_filters_aaa(SVF *self) {
type = 1.0;
lowgain = (type <= 0.5) ? (0.5 - type) : 0.0;
highgain = (type >= 0.5) ? (type - 0.5) : 0.0;
- bandgain = (type <= 0.5) ? type : (1.0 - type);
+ bandgain = (type <= 0.5) ? type : (1.0 - type);
low = self->y2 + self->w * self->y1;
high = in[i] - low - q1 * self->y1;
band = self->w * high + self->y1;
@@ -7460,68 +7457,68 @@ SVF_setProcMode(SVF *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = SVF_filters_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = SVF_filters_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = SVF_filters_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = SVF_filters_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = SVF_filters_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = SVF_filters_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = SVF_filters_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = SVF_filters_aaa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SVF_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SVF_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SVF_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SVF_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SVF_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SVF_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SVF_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SVF_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SVF_postprocessing_revareva;
break;
- }
+ }
}
static void
SVF_compute_next_data_frame(SVF *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -7531,27 +7528,27 @@ SVF_traverse(SVF *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
- Py_VISIT(self->type);
- Py_VISIT(self->type_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
+ Py_VISIT(self->type);
+ Py_VISIT(self->type_stream);
return 0;
}
-static int
+static int
SVF_clear(SVF *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->q);
- Py_CLEAR(self->q_stream);
- Py_CLEAR(self->type);
- Py_CLEAR(self->type_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->q);
+ Py_CLEAR(self->q_stream);
+ Py_CLEAR(self->type);
+ Py_CLEAR(self->type_stream);
return 0;
}
@@ -7570,7 +7567,7 @@ SVF_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *qtmp=NULL, *typetmp=NULL, *multmp=NULL, *addtmp=NULL;
SVF *self;
self = (SVF *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->q = PyFloat_FromDouble(1);
self->type = PyFloat_FromDouble(0);
@@ -7583,10 +7580,10 @@ SVF_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->last_freq = -1.0;
INIT_OBJECT_COMMON
-
+
self->srOverSix = (MYFLT)self->sr / 6.0;
self->piOverSr = PI / self->sr;
-
+
Stream_setFunctionPtr(self->stream, SVF_compute_next_data_frame);
self->mode_func_ptr = SVF_setProcMode;
@@ -7596,7 +7593,7 @@ SVF_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -7608,7 +7605,7 @@ SVF_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (typetmp) {
PyObject_CallMethod((PyObject *)self, "setType", "O", typetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -7616,7 +7613,7 @@ SVF_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -7626,10 +7623,10 @@ SVF_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * SVF_getServer(SVF* self) { GET_SERVER };
static PyObject * SVF_getStream(SVF* self) { GET_STREAM };
-static PyObject * SVF_setMul(SVF *self, PyObject *arg) { SET_MUL };
-static PyObject * SVF_setAdd(SVF *self, PyObject *arg) { SET_ADD };
-static PyObject * SVF_setSub(SVF *self, PyObject *arg) { SET_SUB };
-static PyObject * SVF_setDiv(SVF *self, PyObject *arg) { SET_DIV };
+static PyObject * SVF_setMul(SVF *self, PyObject *arg) { SET_MUL };
+static PyObject * SVF_setAdd(SVF *self, PyObject *arg) { SET_ADD };
+static PyObject * SVF_setSub(SVF *self, PyObject *arg) { SET_SUB };
+static PyObject * SVF_setDiv(SVF *self, PyObject *arg) { SET_DIV };
static PyObject * SVF_play(SVF *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SVF_out(SVF *self, PyObject *args, PyObject *kwds) { OUT };
@@ -7648,14 +7645,14 @@ static PyObject *
SVF_setFreq(SVF *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -7671,25 +7668,25 @@ SVF_setFreq(SVF *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SVF_setQ(SVF *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -7705,25 +7702,25 @@ SVF_setQ(SVF *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SVF_setType(SVF *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->type);
@@ -7739,12 +7736,12 @@ SVF_setType(SVF *self, PyObject *arg)
self->type_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef SVF_members[] = {
{"server", T_OBJECT_EX, offsetof(SVF, server), 0, "Pyo server."},
@@ -7874,7 +7871,7 @@ typedef struct {
static void
Average_process_i(Average *self) {
- int i;
+ int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
@@ -7932,44 +7929,44 @@ Average_setProcMode(Average *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Average_process_i;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Average_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Average_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Average_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Average_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Average_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Average_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Average_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Average_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Average_postprocessing_revareva;
break;
- }
+ }
}
static void
Average_compute_next_data_frame(Average *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -7978,16 +7975,16 @@ Average_traverse(Average *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
+ Py_VISIT(self->input_stream);
return 0;
}
-static int
+static int
Average_clear(Average *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->input_stream);
return 0;
}
@@ -8007,7 +8004,7 @@ Average_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
Average *self;
self = (Average *)type->tp_alloc(type, 0);
-
+
self->size = 10;
self->init = 1;
self->in_count = 0;
@@ -8020,30 +8017,30 @@ Average_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Average_setProcMode;
static char *kwlist[] = {"input", "size", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &inputtmp, &self->size, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->halfSize = (int)(self->size / 2);
self->oneOnSize = 1.0 / (double)self->size;
-
+
self->buffer = (MYFLT *)realloc(self->buffer, (self->size) * sizeof(MYFLT));
for (i=0; i<(self->size); i++) {
self->buffer[i] = 0.;
- }
-
+ }
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -8051,10 +8048,10 @@ Average_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Average_getServer(Average* self) { GET_SERVER };
static PyObject * Average_getStream(Average* self) { GET_STREAM };
-static PyObject * Average_setMul(Average *self, PyObject *arg) { SET_MUL };
-static PyObject * Average_setAdd(Average *self, PyObject *arg) { SET_ADD };
-static PyObject * Average_setSub(Average *self, PyObject *arg) { SET_SUB };
-static PyObject * Average_setDiv(Average *self, PyObject *arg) { SET_DIV };
+static PyObject * Average_setMul(Average *self, PyObject *arg) { SET_MUL };
+static PyObject * Average_setAdd(Average *self, PyObject *arg) { SET_ADD };
+static PyObject * Average_setSub(Average *self, PyObject *arg) { SET_SUB };
+static PyObject * Average_setDiv(Average *self, PyObject *arg) { SET_DIV };
static PyObject * Average_play(Average *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Average_out(Average *self, PyObject *args, PyObject *kwds) { OUT };
@@ -8077,25 +8074,25 @@ Average_setSize(Average *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->size = PyInt_AsLong(arg);
self->halfSize = (int)(self->size / 2);
self->oneOnSize = 1.0 / (double)self->size;
self->init = 1;
self->in_count = 0;
- self->currentValue = 0.0;
+ self->currentValue = 0.0;
self->buffer = (MYFLT *)realloc(self->buffer, (self->size) * sizeof(MYFLT));
for (i=0; i<(self->size); i++) {
self->buffer[i] = 0.;
- }
+ }
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Average_members[] = {
{"server", T_OBJECT_EX, offsetof(Average, server), 0, "Pyo server."},
@@ -8212,7 +8209,7 @@ typedef struct {
Stream *freq_stream;
PyObject *q;
Stream *q_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
MYFLT nyquist;
MYFLT last_freq;
MYFLT last_q;
@@ -8228,20 +8225,20 @@ typedef struct {
MYFLT a;
} Reson;
-static void
+static void
Reson_compute_coeffs(Reson *self, MYFLT freq, MYFLT q)
{
MYFLT bw;
-
+
if (freq < 0.1)
freq = 0.1;
else if (freq > self->nyquist)
freq = self->nyquist;
if (q < 0.1)
q = 0.1;
-
+
bw = freq / q;
-
+
self->b2 = MYEXP(-self->twopiOverSr * bw);
self->b1 = (-4.0 * self->b2) / (1.0 + self->b2) * MYCOS(freq * self->twopiOverSr);
self->a = 1.0 - MYSQRT(self->b2);
@@ -8254,7 +8251,7 @@ Reson_filters_ii(Reson *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
fr = PyFloat_AS_DOUBLE(self->freq);
q = PyFloat_AS_DOUBLE(self->q);
-
+
if (fr != self->last_freq || q != self->last_q) {
self->last_freq = fr;
self->last_q = q;
@@ -8300,7 +8297,7 @@ Reson_filters_ia(Reson *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *qst = Stream_getData((Stream *)self->q_stream);
-
+
for (i=0; i<self->bufsize; i++) {
q = qst[i];
if (fr != self->last_freq || q != self->last_q) {
@@ -8356,56 +8353,56 @@ Reson_setProcMode(Reson *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Reson_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Reson_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Reson_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Reson_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Reson_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Reson_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Reson_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Reson_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Reson_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Reson_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Reson_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Reson_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Reson_postprocessing_revareva;
break;
- }
+ }
}
static void
Reson_compute_next_data_frame(Reson *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -8415,23 +8412,23 @@ Reson_traverse(Reson *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
return 0;
}
-static int
+static int
Reson_clear(Reson *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->q);
- Py_CLEAR(self->q_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->q);
+ Py_CLEAR(self->q_stream);
return 0;
}
@@ -8450,7 +8447,7 @@ Reson_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *qtmp=NULL, *multmp=NULL, *addtmp=NULL;
Reson *self;
self = (Reson *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->q = PyFloat_FromDouble(1);
self->last_freq = self->last_q = -1.0;
@@ -8462,10 +8459,10 @@ Reson_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
-
+
self->nyquist = (MYFLT)self->sr * 0.49;
self->twopiOverSr = TWOPI / (MYFLT)self->sr;
-
+
Stream_setFunctionPtr(self->stream, Reson_compute_next_data_frame);
self->mode_func_ptr = Reson_setProcMode;
@@ -8475,7 +8472,7 @@ Reson_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -8483,7 +8480,7 @@ Reson_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (qtmp) {
PyObject_CallMethod((PyObject *)self, "setQ", "O", qtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -8491,7 +8488,7 @@ Reson_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -8501,10 +8498,10 @@ Reson_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Reson_getServer(Reson* self) { GET_SERVER };
static PyObject * Reson_getStream(Reson* self) { GET_STREAM };
-static PyObject * Reson_setMul(Reson *self, PyObject *arg) { SET_MUL };
-static PyObject * Reson_setAdd(Reson *self, PyObject *arg) { SET_ADD };
-static PyObject * Reson_setSub(Reson *self, PyObject *arg) { SET_SUB };
-static PyObject * Reson_setDiv(Reson *self, PyObject *arg) { SET_DIV };
+static PyObject * Reson_setMul(Reson *self, PyObject *arg) { SET_MUL };
+static PyObject * Reson_setAdd(Reson *self, PyObject *arg) { SET_ADD };
+static PyObject * Reson_setSub(Reson *self, PyObject *arg) { SET_SUB };
+static PyObject * Reson_setDiv(Reson *self, PyObject *arg) { SET_DIV };
static PyObject * Reson_play(Reson *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Reson_out(Reson *self, PyObject *args, PyObject *kwds) { OUT };
@@ -8523,14 +8520,14 @@ static PyObject *
Reson_setFreq(Reson *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -8546,25 +8543,25 @@ Reson_setFreq(Reson *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Reson_setQ(Reson *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -8580,12 +8577,12 @@ Reson_setQ(Reson *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Reson_members[] = {
{"server", T_OBJECT_EX, offsetof(Reson, server), 0, "Pyo server."},
@@ -8705,7 +8702,7 @@ typedef struct {
Stream *freq_stream;
PyObject *q;
Stream *q_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
int stages;
MYFLT nyquist;
MYFLT last_freq;
@@ -8735,20 +8732,20 @@ Resonx_allocate_memories(Resonx *self)
}
}
-static void
+static void
Resonx_compute_coeffs(Resonx *self, MYFLT freq, MYFLT q)
{
MYFLT bw;
-
+
if (freq < 0.1)
freq = 0.1;
else if (freq > self->nyquist)
freq = self->nyquist;
if (q < 0.1)
q = 0.1;
-
+
bw = freq / q;
-
+
self->b2 = MYEXP(-self->twopiOverSr * bw);
self->b1 = (-4.0 * self->b2) / (1.0 + self->b2) * MYCOS(freq * self->twopiOverSr);
self->a = 1.0 - MYSQRT(self->b2);
@@ -8761,7 +8758,7 @@ Resonx_filters_ii(Resonx *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
fr = PyFloat_AS_DOUBLE(self->freq);
q = PyFloat_AS_DOUBLE(self->q);
-
+
if (fr != self->last_freq || q != self->last_q) {
self->last_freq = fr;
self->last_q = q;
@@ -8771,7 +8768,7 @@ Resonx_filters_ii(Resonx *self) {
vout = 0.0;
for (i=0; i<self->bufsize; i++) {
vin = in[i];
- for (j=0; j<self->stages; j++) {
+ for (j=0; j<self->stages; j++) {
vout = (self->a * vin) - (self->a * self->x2[j]) - (self->b1 * self->y1[j]) - (self->b2 * self->y2[j]);
self->x2[j] = self->x1[j];
self->x1[j] = vin;
@@ -8799,7 +8796,7 @@ Resonx_filters_ai(Resonx *self) {
self->last_q = q;
Resonx_compute_coeffs(self, fr, q);
}
- for (j=0; j<self->stages; j++) {
+ for (j=0; j<self->stages; j++) {
vout = (self->a * vin) - (self->a * self->x2[j]) - (self->b1 * self->y1[j]) - (self->b2 * self->y2[j]);
self->x2[j] = self->x1[j];
self->x1[j] = vin;
@@ -8827,7 +8824,7 @@ Resonx_filters_ia(Resonx *self) {
self->last_q = q;
Resonx_compute_coeffs(self, fr, q);
}
- for (j=0; j<self->stages; j++) {
+ for (j=0; j<self->stages; j++) {
vout = (self->a * vin) - (self->a * self->x2[j]) - (self->b1 * self->y1[j]) - (self->b2 * self->y2[j]);
self->x2[j] = self->x1[j];
self->x1[j] = vin;
@@ -8856,7 +8853,7 @@ Resonx_filters_aa(Resonx *self) {
self->last_q = q;
Resonx_compute_coeffs(self, fr, q);
}
- for (j=0; j<self->stages; j++) {
+ for (j=0; j<self->stages; j++) {
vout = (self->a * vin) - (self->a * self->x2[j]) - (self->b1 * self->y1[j]) - (self->b2 * self->y2[j]);
self->x2[j] = self->x1[j];
self->x1[j] = vin;
@@ -8883,56 +8880,56 @@ Resonx_setProcMode(Resonx *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Resonx_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Resonx_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Resonx_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Resonx_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Resonx_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Resonx_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Resonx_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Resonx_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Resonx_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Resonx_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Resonx_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Resonx_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Resonx_postprocessing_revareva;
break;
- }
+ }
}
static void
Resonx_compute_next_data_frame(Resonx *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -8942,23 +8939,23 @@ Resonx_traverse(Resonx *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
return 0;
}
-static int
+static int
Resonx_clear(Resonx *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->q);
- Py_CLEAR(self->q_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->q);
+ Py_CLEAR(self->q_stream);
return 0;
}
@@ -8981,7 +8978,7 @@ Resonx_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *qtmp=NULL, *multmp=NULL, *addtmp=NULL;
Resonx *self;
self = (Resonx *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->q = PyFloat_FromDouble(1);
self->last_freq = self->last_q = -1.0;
@@ -8993,10 +8990,10 @@ Resonx_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
-
+
self->nyquist = (MYFLT)self->sr * 0.49;
self->twopiOverSr = TWOPI / (MYFLT)self->sr;
-
+
Stream_setFunctionPtr(self->stream, Resonx_compute_next_data_frame);
self->mode_func_ptr = Resonx_setProcMode;
@@ -9006,7 +9003,7 @@ Resonx_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -9014,7 +9011,7 @@ Resonx_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (qtmp) {
PyObject_CallMethod((PyObject *)self, "setQ", "O", qtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -9022,7 +9019,7 @@ Resonx_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Resonx_allocate_memories(self);
@@ -9034,10 +9031,10 @@ Resonx_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Resonx_getServer(Resonx* self) { GET_SERVER };
static PyObject * Resonx_getStream(Resonx* self) { GET_STREAM };
-static PyObject * Resonx_setMul(Resonx *self, PyObject *arg) { SET_MUL };
-static PyObject * Resonx_setAdd(Resonx *self, PyObject *arg) { SET_ADD };
-static PyObject * Resonx_setSub(Resonx *self, PyObject *arg) { SET_SUB };
-static PyObject * Resonx_setDiv(Resonx *self, PyObject *arg) { SET_DIV };
+static PyObject * Resonx_setMul(Resonx *self, PyObject *arg) { SET_MUL };
+static PyObject * Resonx_setAdd(Resonx *self, PyObject *arg) { SET_ADD };
+static PyObject * Resonx_setSub(Resonx *self, PyObject *arg) { SET_SUB };
+static PyObject * Resonx_setDiv(Resonx *self, PyObject *arg) { SET_DIV };
static PyObject * Resonx_play(Resonx *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Resonx_out(Resonx *self, PyObject *args, PyObject *kwds) { OUT };
@@ -9056,14 +9053,14 @@ static PyObject *
Resonx_setFreq(Resonx *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -9079,25 +9076,25 @@ Resonx_setFreq(Resonx *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Resonx_setQ(Resonx *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -9113,24 +9110,24 @@ Resonx_setQ(Resonx *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Resonx_setStages(Resonx *self, PyObject *arg)
{
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->stages = PyInt_AsLong(arg);
Resonx_allocate_memories(self);
@@ -9138,7 +9135,7 @@ Resonx_setStages(Resonx *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Resonx_members[] = {
{"server", T_OBJECT_EX, offsetof(Resonx, server), 0, "Pyo server."},
@@ -9260,7 +9257,7 @@ typedef struct {
Stream *input_stream;
PyObject *freq;
Stream *freq_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
MYFLT lastFreq;
MYFLT nyquist;
MYFLT piOnSr;
@@ -9284,12 +9281,12 @@ ButLP_filters_i(ButLP *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
-
+
if (fr != self->lastFreq) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
+ fr = self->nyquist;
self->lastFreq = fr;
c = 1.0 / MYTAN(self->piOnSr * fr);
c2 = c * c;
@@ -9314,14 +9311,14 @@ ButLP_filters_a(ButLP *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
- fr = freq[i];
+ fr = freq[i];
if (fr != self->lastFreq) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
+ fr = self->nyquist;
self->lastFreq = fr;
c = 1.0 / MYTAN(self->piOnSr * fr);
c2 = c * c;
@@ -9354,50 +9351,50 @@ ButLP_setProcMode(ButLP *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = ButLP_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = ButLP_filters_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = ButLP_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = ButLP_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = ButLP_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = ButLP_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = ButLP_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = ButLP_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = ButLP_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = ButLP_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = ButLP_postprocessing_revareva;
break;
- }
+ }
}
static void
ButLP_compute_next_data_frame(ButLP *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -9407,19 +9404,19 @@ ButLP_traverse(ButLP *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
ButLP_clear(ButLP *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -9438,14 +9435,14 @@ ButLP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
ButLP *self;
self = (ButLP *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->lastFreq = -1.0;
self->x1 = self->x2 = self->y1 = self->y2 = self->a0 = self->a1 = self->a2 = self->b1 = self->b2 = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
@@ -9456,26 +9453,26 @@ ButLP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = ButLP_setProcMode;
static char *kwlist[] = {"input", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &freqtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -9483,10 +9480,10 @@ ButLP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * ButLP_getServer(ButLP* self) { GET_SERVER };
static PyObject * ButLP_getStream(ButLP* self) { GET_STREAM };
-static PyObject * ButLP_setMul(ButLP *self, PyObject *arg) { SET_MUL };
-static PyObject * ButLP_setAdd(ButLP *self, PyObject *arg) { SET_ADD };
-static PyObject * ButLP_setSub(ButLP *self, PyObject *arg) { SET_SUB };
-static PyObject * ButLP_setDiv(ButLP *self, PyObject *arg) { SET_DIV };
+static PyObject * ButLP_setMul(ButLP *self, PyObject *arg) { SET_MUL };
+static PyObject * ButLP_setAdd(ButLP *self, PyObject *arg) { SET_ADD };
+static PyObject * ButLP_setSub(ButLP *self, PyObject *arg) { SET_SUB };
+static PyObject * ButLP_setDiv(ButLP *self, PyObject *arg) { SET_DIV };
static PyObject * ButLP_play(ButLP *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * ButLP_out(ButLP *self, PyObject *args, PyObject *kwds) { OUT };
@@ -9505,14 +9502,14 @@ static PyObject *
ButLP_setFreq(ButLP *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -9528,9 +9525,9 @@ ButLP_setFreq(ButLP *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -9652,7 +9649,7 @@ typedef struct {
Stream *input_stream;
PyObject *freq;
Stream *freq_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
MYFLT lastFreq;
MYFLT nyquist;
MYFLT piOnSr;
@@ -9676,12 +9673,12 @@ ButHP_filters_i(ButHP *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
-
+
if (fr != self->lastFreq) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
+ fr = self->nyquist;
self->lastFreq = fr;
c = MYTAN(self->piOnSr * fr);
c2 = c * c;
@@ -9706,14 +9703,14 @@ ButHP_filters_a(ButHP *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
- fr = freq[i];
+ fr = freq[i];
if (fr != self->lastFreq) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
+ fr = self->nyquist;
self->lastFreq = fr;
c = MYTAN(self->piOnSr * fr);
c2 = c * c;
@@ -9746,50 +9743,50 @@ ButHP_setProcMode(ButHP *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = ButHP_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = ButHP_filters_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = ButHP_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = ButHP_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = ButHP_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = ButHP_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = ButHP_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = ButHP_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = ButHP_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = ButHP_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = ButHP_postprocessing_revareva;
break;
- }
+ }
}
static void
ButHP_compute_next_data_frame(ButHP *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -9799,19 +9796,19 @@ ButHP_traverse(ButHP *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
ButHP_clear(ButHP *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -9830,14 +9827,14 @@ ButHP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
ButHP *self;
self = (ButHP *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->lastFreq = -1.0;
self->x1 = self->x2 = self->y1 = self->y2 = self->a0 = self->a1 = self->a2 = self->b1 = self->b2 = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
@@ -9848,26 +9845,26 @@ ButHP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = ButHP_setProcMode;
static char *kwlist[] = {"input", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &freqtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -9875,10 +9872,10 @@ ButHP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * ButHP_getServer(ButHP* self) { GET_SERVER };
static PyObject * ButHP_getStream(ButHP* self) { GET_STREAM };
-static PyObject * ButHP_setMul(ButHP *self, PyObject *arg) { SET_MUL };
-static PyObject * ButHP_setAdd(ButHP *self, PyObject *arg) { SET_ADD };
-static PyObject * ButHP_setSub(ButHP *self, PyObject *arg) { SET_SUB };
-static PyObject * ButHP_setDiv(ButHP *self, PyObject *arg) { SET_DIV };
+static PyObject * ButHP_setMul(ButHP *self, PyObject *arg) { SET_MUL };
+static PyObject * ButHP_setAdd(ButHP *self, PyObject *arg) { SET_ADD };
+static PyObject * ButHP_setSub(ButHP *self, PyObject *arg) { SET_SUB };
+static PyObject * ButHP_setDiv(ButHP *self, PyObject *arg) { SET_DIV };
static PyObject * ButHP_play(ButHP *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * ButHP_out(ButHP *self, PyObject *args, PyObject *kwds) { OUT };
@@ -9897,14 +9894,14 @@ static PyObject *
ButHP_setFreq(ButHP *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -9920,9 +9917,9 @@ ButHP_setFreq(ButHP *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -10046,7 +10043,7 @@ typedef struct {
Stream *freq_stream;
PyObject *q;
Stream *q_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
MYFLT nyquist;
MYFLT last_freq;
MYFLT last_q;
@@ -10063,22 +10060,22 @@ typedef struct {
MYFLT b2;
} ButBP;
-static void
+static void
ButBP_compute_coeffs(ButBP *self, MYFLT freq, MYFLT q)
{
MYFLT bw, c, d;
-
+
if (freq < 1.0)
freq = 1.0;
else if (freq > self->nyquist)
freq = self->nyquist;
if (q < 1.0)
q = 1.0;
-
+
bw = freq / q;
c = 1.0 / MYTAN(self->piOnSr * bw);
d = 2.0 * MYCOS(2.0 * self->piOnSr * freq);
-
+
self->a0 = 1.0 / (1.0 + c);
self->a2 = -self->a0;
self->b1 = self->a2 * c * d;
@@ -10092,7 +10089,7 @@ ButBP_filters_ii(ButBP *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
fr = PyFloat_AS_DOUBLE(self->freq);
q = PyFloat_AS_DOUBLE(self->q);
-
+
if (fr != self->last_freq || q != self->last_q) {
self->last_freq = fr;
self->last_q = q;
@@ -10138,7 +10135,7 @@ ButBP_filters_ia(ButBP *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *qst = Stream_getData((Stream *)self->q_stream);
-
+
for (i=0; i<self->bufsize; i++) {
q = qst[i];
if (fr != self->last_freq || q != self->last_q) {
@@ -10194,56 +10191,56 @@ ButBP_setProcMode(ButBP *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = ButBP_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = ButBP_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = ButBP_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = ButBP_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = ButBP_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = ButBP_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = ButBP_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = ButBP_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = ButBP_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = ButBP_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = ButBP_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = ButBP_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = ButBP_postprocessing_revareva;
break;
- }
+ }
}
static void
ButBP_compute_next_data_frame(ButBP *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -10253,23 +10250,23 @@ ButBP_traverse(ButBP *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
return 0;
}
-static int
+static int
ButBP_clear(ButBP *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->q);
- Py_CLEAR(self->q_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->q);
+ Py_CLEAR(self->q_stream);
return 0;
}
@@ -10288,7 +10285,7 @@ ButBP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *qtmp=NULL, *multmp=NULL, *addtmp=NULL;
ButBP *self;
self = (ButBP *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->q = PyFloat_FromDouble(1);
self->last_freq = self->last_q = -1.0;
@@ -10300,10 +10297,10 @@ ButBP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
-
+
self->nyquist = (MYFLT)self->sr * 0.49;
self->piOnSr = PI / (MYFLT)self->sr;
-
+
Stream_setFunctionPtr(self->stream, ButBP_compute_next_data_frame);
self->mode_func_ptr = ButBP_setProcMode;
@@ -10313,7 +10310,7 @@ ButBP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -10321,7 +10318,7 @@ ButBP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (qtmp) {
PyObject_CallMethod((PyObject *)self, "setQ", "O", qtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -10329,7 +10326,7 @@ ButBP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -10339,10 +10336,10 @@ ButBP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * ButBP_getServer(ButBP* self) { GET_SERVER };
static PyObject * ButBP_getStream(ButBP* self) { GET_STREAM };
-static PyObject * ButBP_setMul(ButBP *self, PyObject *arg) { SET_MUL };
-static PyObject * ButBP_setAdd(ButBP *self, PyObject *arg) { SET_ADD };
-static PyObject * ButBP_setSub(ButBP *self, PyObject *arg) { SET_SUB };
-static PyObject * ButBP_setDiv(ButBP *self, PyObject *arg) { SET_DIV };
+static PyObject * ButBP_setMul(ButBP *self, PyObject *arg) { SET_MUL };
+static PyObject * ButBP_setAdd(ButBP *self, PyObject *arg) { SET_ADD };
+static PyObject * ButBP_setSub(ButBP *self, PyObject *arg) { SET_SUB };
+static PyObject * ButBP_setDiv(ButBP *self, PyObject *arg) { SET_DIV };
static PyObject * ButBP_play(ButBP *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * ButBP_out(ButBP *self, PyObject *args, PyObject *kwds) { OUT };
@@ -10361,14 +10358,14 @@ static PyObject *
ButBP_setFreq(ButBP *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -10384,25 +10381,25 @@ ButBP_setFreq(ButBP *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
ButBP_setQ(ButBP *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -10418,12 +10415,12 @@ ButBP_setQ(ButBP *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef ButBP_members[] = {
{"server", T_OBJECT_EX, offsetof(ButBP, server), 0, "Pyo server."},
@@ -10546,7 +10543,7 @@ typedef struct {
Stream *freq_stream;
PyObject *q;
Stream *q_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
MYFLT nyquist;
MYFLT last_freq;
MYFLT last_q;
@@ -10564,22 +10561,22 @@ typedef struct {
MYFLT b2;
} ButBR;
-static void
+static void
ButBR_compute_coeffs(ButBR *self, MYFLT freq, MYFLT q)
{
MYFLT bw, c, d;
-
+
if (freq < 1.0)
freq = 1.0;
else if (freq > self->nyquist)
freq = self->nyquist;
if (q < 1.0)
q = 1.0;
-
+
bw = freq / q;
c = MYTAN(self->piOnSr * bw);
d = 2.0 * MYCOS(2.0 * self->piOnSr * freq);
-
+
self->a0 = self->a2 = 1.0 / (1.0 + c);
self->a1 = self->b1 = -self->a0 * d;
self->b2 = self->a0 * (1.0 - c);
@@ -10592,7 +10589,7 @@ ButBR_filters_ii(ButBR *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
fr = PyFloat_AS_DOUBLE(self->freq);
q = PyFloat_AS_DOUBLE(self->q);
-
+
if (fr != self->last_freq || q != self->last_q) {
self->last_freq = fr;
self->last_q = q;
@@ -10638,7 +10635,7 @@ ButBR_filters_ia(ButBR *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *qst = Stream_getData((Stream *)self->q_stream);
-
+
for (i=0; i<self->bufsize; i++) {
q = qst[i];
if (fr != self->last_freq || q != self->last_q) {
@@ -10694,56 +10691,56 @@ ButBR_setProcMode(ButBR *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = ButBR_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = ButBR_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = ButBR_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = ButBR_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = ButBR_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = ButBR_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = ButBR_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = ButBR_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = ButBR_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = ButBR_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = ButBR_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = ButBR_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = ButBR_postprocessing_revareva;
break;
- }
+ }
}
static void
ButBR_compute_next_data_frame(ButBR *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -10753,23 +10750,23 @@ ButBR_traverse(ButBR *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->q);
- Py_VISIT(self->q_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->q);
+ Py_VISIT(self->q_stream);
return 0;
}
-static int
+static int
ButBR_clear(ButBR *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->q);
- Py_CLEAR(self->q_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->q);
+ Py_CLEAR(self->q_stream);
return 0;
}
@@ -10788,7 +10785,7 @@ ButBR_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *qtmp=NULL, *multmp=NULL, *addtmp=NULL;
ButBR *self;
self = (ButBR *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->q = PyFloat_FromDouble(1);
self->last_freq = self->last_q = -1.0;
@@ -10800,10 +10797,10 @@ ButBR_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
-
+
self->nyquist = (MYFLT)self->sr * 0.49;
self->piOnSr = PI / (MYFLT)self->sr;
-
+
Stream_setFunctionPtr(self->stream, ButBR_compute_next_data_frame);
self->mode_func_ptr = ButBR_setProcMode;
@@ -10813,7 +10810,7 @@ ButBR_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -10821,7 +10818,7 @@ ButBR_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (qtmp) {
PyObject_CallMethod((PyObject *)self, "setQ", "O", qtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -10829,7 +10826,7 @@ ButBR_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -10839,10 +10836,10 @@ ButBR_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * ButBR_getServer(ButBR* self) { GET_SERVER };
static PyObject * ButBR_getStream(ButBR* self) { GET_STREAM };
-static PyObject * ButBR_setMul(ButBR *self, PyObject *arg) { SET_MUL };
-static PyObject * ButBR_setAdd(ButBR *self, PyObject *arg) { SET_ADD };
-static PyObject * ButBR_setSub(ButBR *self, PyObject *arg) { SET_SUB };
-static PyObject * ButBR_setDiv(ButBR *self, PyObject *arg) { SET_DIV };
+static PyObject * ButBR_setMul(ButBR *self, PyObject *arg) { SET_MUL };
+static PyObject * ButBR_setAdd(ButBR *self, PyObject *arg) { SET_ADD };
+static PyObject * ButBR_setSub(ButBR *self, PyObject *arg) { SET_SUB };
+static PyObject * ButBR_setDiv(ButBR *self, PyObject *arg) { SET_DIV };
static PyObject * ButBR_play(ButBR *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * ButBR_out(ButBR *self, PyObject *args, PyObject *kwds) { OUT };
@@ -10861,14 +10858,14 @@ static PyObject *
ButBR_setFreq(ButBR *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -10884,25 +10881,25 @@ ButBR_setFreq(ButBR *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
ButBR_setQ(ButBR *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->q);
@@ -10918,12 +10915,12 @@ ButBR_setQ(ButBR *self, PyObject *arg)
self->q_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef ButBR_members[] = {
{"server", T_OBJECT_EX, offsetof(ButBR, server), 0, "Pyo server."},
@@ -11046,7 +11043,7 @@ typedef struct {
Stream *freq_stream;
PyObject *decay;
Stream *decay_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
MYFLT last_freq;
MYFLT last_decay;
MYFLT oneOnSr;
@@ -11065,9 +11062,9 @@ ComplexRes_filters_ii(ComplexRes *self) {
int i;
MYFLT ang, x, y;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
- MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
+ MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT decay = PyFloat_AS_DOUBLE(self->decay);
-
+
if (decay <= 0.0001)
decay = 0.0001;
@@ -11084,7 +11081,7 @@ ComplexRes_filters_ii(ComplexRes *self) {
for (i=0; i<self->bufsize; i++) {
x = self->coeffx * self->x - self->coeffy * self->y + in[i];
y = self->coeffy * self->x + self->coeffx * self->y;
- self->data[i] = y * self->norm;
+ self->data[i] = y * self->norm;
self->x = x;
self->y = y;
}
@@ -11107,7 +11104,7 @@ ComplexRes_filters_ai(ComplexRes *self) {
self->last_decay = decay;
check = 1;
}
-
+
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
if (freq != self->last_freq || check) {
@@ -11119,7 +11116,7 @@ ComplexRes_filters_ai(ComplexRes *self) {
}
x = self->coeffx * self->x - self->coeffy * self->y + in[i];
y = self->coeffy * self->x + self->coeffx * self->y;
- self->data[i] = y * self->norm;
+ self->data[i] = y * self->norm;
self->x = x;
self->y = y;
}
@@ -11132,7 +11129,7 @@ ComplexRes_filters_ia(ComplexRes *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *dec = Stream_getData((Stream *)self->decay_stream);
-
+
for (i=0; i<self->bufsize; i++) {
decay = dec[i];
if (decay <= 0.0001)
@@ -11148,7 +11145,7 @@ ComplexRes_filters_ia(ComplexRes *self) {
}
x = self->coeffx * self->x - self->coeffy * self->y + in[i];
y = self->coeffy * self->x + self->coeffx * self->y;
- self->data[i] = y * self->norm;
+ self->data[i] = y * self->norm;
self->x = x;
self->y = y;
}
@@ -11161,7 +11158,7 @@ ComplexRes_filters_aa(ComplexRes *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *dec = Stream_getData((Stream *)self->decay_stream);
-
+
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
decay = dec[i];
@@ -11178,7 +11175,7 @@ ComplexRes_filters_aa(ComplexRes *self) {
}
x = self->coeffx * self->x - self->coeffy * self->y + in[i];
y = self->coeffy * self->x + self->coeffx * self->y;
- self->data[i] = y * self->norm;
+ self->data[i] = y * self->norm;
self->x = x;
self->y = y;
}
@@ -11202,54 +11199,54 @@ ComplexRes_setProcMode(ComplexRes *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = ComplexRes_filters_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = ComplexRes_filters_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = ComplexRes_filters_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = ComplexRes_filters_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = ComplexRes_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = ComplexRes_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = ComplexRes_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = ComplexRes_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = ComplexRes_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = ComplexRes_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = ComplexRes_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = ComplexRes_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = ComplexRes_postprocessing_revareva;
break;
- }
+ }
}
static void
ComplexRes_compute_next_data_frame(ComplexRes *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -11259,23 +11256,23 @@ ComplexRes_traverse(ComplexRes *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->decay);
- Py_VISIT(self->decay_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->decay);
+ Py_VISIT(self->decay_stream);
return 0;
}
-static int
+static int
ComplexRes_clear(ComplexRes *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->decay);
- Py_CLEAR(self->decay_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->decay);
+ Py_CLEAR(self->decay_stream);
return 0;
}
@@ -11294,7 +11291,7 @@ ComplexRes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *decaytmp=NULL, *multmp=NULL, *addtmp=NULL;
ComplexRes *self;
self = (ComplexRes *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->decay = PyFloat_FromDouble(.25);
self->last_freq = self->last_decay = -1.0;
@@ -11306,39 +11303,39 @@ ComplexRes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
-
+
self->oneOnSr = 1.0 / self->sr;
Stream_setFunctionPtr(self->stream, ComplexRes_compute_next_data_frame);
self->mode_func_ptr = ComplexRes_setProcMode;
static char *kwlist[] = {"input", "freq", "decay", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &inputtmp, &freqtmp, &decaytmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (decaytmp) {
PyObject_CallMethod((PyObject *)self, "setDecay", "O", decaytmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -11346,10 +11343,10 @@ ComplexRes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * ComplexRes_getServer(ComplexRes* self) { GET_SERVER };
static PyObject * ComplexRes_getStream(ComplexRes* self) { GET_STREAM };
-static PyObject * ComplexRes_setMul(ComplexRes *self, PyObject *arg) { SET_MUL };
-static PyObject * ComplexRes_setAdd(ComplexRes *self, PyObject *arg) { SET_ADD };
-static PyObject * ComplexRes_setSub(ComplexRes *self, PyObject *arg) { SET_SUB };
-static PyObject * ComplexRes_setDiv(ComplexRes *self, PyObject *arg) { SET_DIV };
+static PyObject * ComplexRes_setMul(ComplexRes *self, PyObject *arg) { SET_MUL };
+static PyObject * ComplexRes_setAdd(ComplexRes *self, PyObject *arg) { SET_ADD };
+static PyObject * ComplexRes_setSub(ComplexRes *self, PyObject *arg) { SET_SUB };
+static PyObject * ComplexRes_setDiv(ComplexRes *self, PyObject *arg) { SET_DIV };
static PyObject * ComplexRes_play(ComplexRes *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * ComplexRes_out(ComplexRes *self, PyObject *args, PyObject *kwds) { OUT };
@@ -11368,14 +11365,14 @@ static PyObject *
ComplexRes_setFreq(ComplexRes *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -11391,25 +11388,25 @@ ComplexRes_setFreq(ComplexRes *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
ComplexRes_setDecay(ComplexRes *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->decay);
@@ -11425,12 +11422,12 @@ ComplexRes_setDecay(ComplexRes *self, PyObject *arg)
self->decay_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef ComplexRes_members[] = {
{"server", T_OBJECT_EX, offsetof(ComplexRes, server), 0, "Pyo server."},
@@ -11540,4 +11537,4 @@ ComplexRes_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
ComplexRes_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/freeverbmodule.c b/src/objects/freeverbmodule.c
index 9f98523..2558d79 100644
--- a/src/objects/freeverbmodule.c
+++ b/src/objects/freeverbmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -31,20 +31,20 @@
#define NUM_ALLPASS 4
static const MYFLT comb_delays[NUM_COMB] = {
-1116.0 / DEFAULT_SRATE,
-1188.0 / DEFAULT_SRATE,
-1277.0 / DEFAULT_SRATE,
+1116.0 / DEFAULT_SRATE,
+1188.0 / DEFAULT_SRATE,
+1277.0 / DEFAULT_SRATE,
1356.0 / DEFAULT_SRATE,
-1422.0 / DEFAULT_SRATE,
-1491.0 / DEFAULT_SRATE,
-1557.0 / DEFAULT_SRATE,
+1422.0 / DEFAULT_SRATE,
+1491.0 / DEFAULT_SRATE,
+1557.0 / DEFAULT_SRATE,
1617.0 / DEFAULT_SRATE
};
static const MYFLT allpass_delays[NUM_ALLPASS] = {
-556.0 / DEFAULT_SRATE,
-441.0 / DEFAULT_SRATE,
-341.0 / DEFAULT_SRATE,
+556.0 / DEFAULT_SRATE,
+441.0 / DEFAULT_SRATE,
+341.0 / DEFAULT_SRATE,
225.0 / DEFAULT_SRATE
};
@@ -86,7 +86,7 @@ _clip(MYFLT x)
return x;
}
-static int
+static int
Freeverb_calc_nsamples(Freeverb *self, MYFLT delTime)
{
return (int)(delTime * self->sr + 0.5);
@@ -108,10 +108,10 @@ Freeverb_transform_iii(Freeverb *self) {
mix1 = MYSQRT(mix);
mix2 = MYSQRT(1.0 - mix);
-
+
MYFLT tmp[self->bufsize];
memset(&tmp, 0, sizeof(tmp));
-
+
for (j=0; j<self->bufsize; j++) {
for (i=0; i<NUM_COMB; i++) {
x = self->comb_buf[i][self->comb_bufPos[i]];
@@ -124,7 +124,7 @@ Freeverb_transform_iii(Freeverb *self) {
self->comb_bufPos[i] = 0;
}
}
-
+
for (i=0; i<NUM_ALLPASS; i++) {
for (j=0; j<self->bufsize; j++) {
x = self->allpass_buf[i][self->allpass_bufPos[i]] - tmp[j];
@@ -134,33 +134,33 @@ Freeverb_transform_iii(Freeverb *self) {
if (self->allpass_bufPos[i] >= self->allpass_nSamples[i])
self->allpass_bufPos[i] = 0;
tmp[j] = x;
- }
+ }
}
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = (tmp[i] * fixedGain * mix1) + (in[i] * mix2);
- }
+ }
}
static void
Freeverb_transform_aii(Freeverb *self) {
MYFLT x, feedback, damp1, damp2, mix1, mix2;
int i, j;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *siz = Stream_getData((Stream *)self->size_stream);
MYFLT dam = _clip(PyFloat_AS_DOUBLE(self->damp));
MYFLT mix = _clip(PyFloat_AS_DOUBLE(self->mix));
-
+
damp1 = dam * scaleDamp;
damp2 = 1.0 - damp1;
-
+
mix1 = MYSQRT(mix);
mix2 = MYSQRT(1.0 - mix);
-
+
MYFLT tmp[self->bufsize];
memset(&tmp, 0, sizeof(tmp));
-
+
for (j=0; j<self->bufsize; j++) {
feedback = _clip(siz[j]) * scaleRoom + offsetRoom;
for (i=0; i<NUM_COMB; i++) {
@@ -174,7 +174,7 @@ Freeverb_transform_aii(Freeverb *self) {
self->comb_bufPos[i] = 0;
}
}
-
+
for (i=0; i<NUM_ALLPASS; i++) {
for (j=0; j<self->bufsize; j++) {
x = self->allpass_buf[i][self->allpass_bufPos[i]] - tmp[j];
@@ -184,32 +184,32 @@ Freeverb_transform_aii(Freeverb *self) {
if (self->allpass_bufPos[i] >= self->allpass_nSamples[i])
self->allpass_bufPos[i] = 0;
tmp[j] = x;
- }
+ }
}
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = (tmp[i] * fixedGain * mix1) + (in[i] * mix2);
- }
+ }
}
static void
Freeverb_transform_iai(Freeverb *self) {
MYFLT x, feedback, damp1, damp2, mix1, mix2;
int i, j;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT siz = _clip(PyFloat_AS_DOUBLE(self->size));
MYFLT *dam = Stream_getData((Stream *)self->damp_stream);
MYFLT mix = _clip(PyFloat_AS_DOUBLE(self->mix));
-
+
feedback = siz * scaleRoom + offsetRoom;
-
+
mix1 = MYSQRT(mix);
mix2 = MYSQRT(1.0 - mix);
-
+
MYFLT tmp[self->bufsize];
memset(&tmp, 0, sizeof(tmp));
-
+
for (j=0; j<self->bufsize; j++) {
damp1 = _clip(dam[j]) * scaleDamp;
damp2 = 1.0 - damp1;
@@ -224,7 +224,7 @@ Freeverb_transform_iai(Freeverb *self) {
self->comb_bufPos[i] = 0;
}
}
-
+
for (i=0; i<NUM_ALLPASS; i++) {
for (j=0; j<self->bufsize; j++) {
x = self->allpass_buf[i][self->allpass_bufPos[i]] - tmp[j];
@@ -234,19 +234,19 @@ Freeverb_transform_iai(Freeverb *self) {
if (self->allpass_bufPos[i] >= self->allpass_nSamples[i])
self->allpass_bufPos[i] = 0;
tmp[j] = x;
- }
+ }
}
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = (tmp[i] * fixedGain * mix1) + (in[i] * mix2);
- }
+ }
}
static void
Freeverb_transform_aai(Freeverb *self) {
MYFLT x, feedback, damp1, damp2, mix1, mix2;
int i, j;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *siz = Stream_getData((Stream *)self->size_stream);
MYFLT *dam = Stream_getData((Stream *)self->damp_stream);
@@ -257,7 +257,7 @@ Freeverb_transform_aai(Freeverb *self) {
MYFLT tmp[self->bufsize];
memset(&tmp, 0, sizeof(tmp));
-
+
for (j=0; j<self->bufsize; j++) {
feedback = _clip(siz[j]) * scaleRoom + offsetRoom;
damp1 = _clip(dam[j]) * scaleDamp;
@@ -273,7 +273,7 @@ Freeverb_transform_aai(Freeverb *self) {
self->comb_bufPos[i] = 0;
}
}
-
+
for (i=0; i<NUM_ALLPASS; i++) {
for (j=0; j<self->bufsize; j++) {
x = self->allpass_buf[i][self->allpass_bufPos[i]] - tmp[j];
@@ -283,31 +283,31 @@ Freeverb_transform_aai(Freeverb *self) {
if (self->allpass_bufPos[i] >= self->allpass_nSamples[i])
self->allpass_bufPos[i] = 0;
tmp[j] = x;
- }
+ }
}
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = (tmp[i] * fixedGain * mix1) + (in[i] * mix2);
- }
+ }
}
static void
Freeverb_transform_iia(Freeverb *self) {
MYFLT x, feedback, damp1, damp2, mix1, mix2, mixtmp;
int i, j;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT siz = _clip(PyFloat_AS_DOUBLE(self->size));
MYFLT dam = _clip(PyFloat_AS_DOUBLE(self->damp));
MYFLT *mix = Stream_getData((Stream *)self->mix_stream);
-
+
feedback = siz * scaleRoom + offsetRoom;
damp1 = dam * scaleDamp;
damp2 = 1.0 - damp1;
MYFLT tmp[self->bufsize];
memset(&tmp, 0, sizeof(tmp));
-
+
for (j=0; j<self->bufsize; j++) {
for (i=0; i<NUM_COMB; i++) {
x = self->comb_buf[i][self->comb_bufPos[i]];
@@ -320,7 +320,7 @@ Freeverb_transform_iia(Freeverb *self) {
self->comb_bufPos[i] = 0;
}
}
-
+
for (i=0; i<NUM_ALLPASS; i++) {
for (j=0; j<self->bufsize; j++) {
x = self->allpass_buf[i][self->allpass_bufPos[i]] - tmp[j];
@@ -330,33 +330,33 @@ Freeverb_transform_iia(Freeverb *self) {
if (self->allpass_bufPos[i] >= self->allpass_nSamples[i])
self->allpass_bufPos[i] = 0;
tmp[j] = x;
- }
+ }
}
-
+
for (i=0; i<self->bufsize; i++) {
mixtmp = _clip(mix[i]);
mix1 = MYSQRT(mixtmp);
mix2 = MYSQRT(1.0 - mixtmp);
self->data[i] = (tmp[i] * fixedGain * mix1) + (in[i] * mix2);
- }
+ }
}
static void
Freeverb_transform_aia(Freeverb *self) {
MYFLT x, feedback, damp1, damp2, mix1, mix2, mixtmp;
int i, j;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *siz = Stream_getData((Stream *)self->size_stream);
MYFLT dam = _clip(PyFloat_AS_DOUBLE(self->damp));
MYFLT *mix = Stream_getData((Stream *)self->mix_stream);
-
+
damp1 = dam * scaleDamp;
damp2 = 1.0 - damp1;
-
+
MYFLT tmp[self->bufsize];
memset(&tmp, 0, sizeof(tmp));
-
+
for (j=0; j<self->bufsize; j++) {
feedback = _clip(siz[j]) * scaleRoom + offsetRoom;
for (i=0; i<NUM_COMB; i++) {
@@ -370,7 +370,7 @@ Freeverb_transform_aia(Freeverb *self) {
self->comb_bufPos[i] = 0;
}
}
-
+
for (i=0; i<NUM_ALLPASS; i++) {
for (j=0; j<self->bufsize; j++) {
x = self->allpass_buf[i][self->allpass_bufPos[i]] - tmp[j];
@@ -380,32 +380,32 @@ Freeverb_transform_aia(Freeverb *self) {
if (self->allpass_bufPos[i] >= self->allpass_nSamples[i])
self->allpass_bufPos[i] = 0;
tmp[j] = x;
- }
+ }
}
-
+
for (i=0; i<self->bufsize; i++) {
mixtmp = _clip(mix[i]);
mix1 = MYSQRT(mixtmp);
mix2 = MYSQRT(1.0 - mixtmp);
self->data[i] = (tmp[i] * fixedGain * mix1) + (in[i] * mix2);
- }
+ }
}
static void
Freeverb_transform_iaa(Freeverb *self) {
MYFLT x, feedback, damp1, damp2, mix1, mix2, mixtmp;
int i, j;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT siz = _clip(PyFloat_AS_DOUBLE(self->size));
MYFLT *dam = Stream_getData((Stream *)self->damp_stream);
MYFLT *mix = Stream_getData((Stream *)self->mix_stream);
-
+
feedback = siz * scaleRoom + offsetRoom;
-
+
MYFLT tmp[self->bufsize];
memset(&tmp, 0, sizeof(tmp));
-
+
for (j=0; j<self->bufsize; j++) {
damp1 = _clip(dam[j]) * scaleDamp;
damp2 = 1.0 - damp1;
@@ -420,7 +420,7 @@ Freeverb_transform_iaa(Freeverb *self) {
self->comb_bufPos[i] = 0;
}
}
-
+
for (i=0; i<NUM_ALLPASS; i++) {
for (j=0; j<self->bufsize; j++) {
x = self->allpass_buf[i][self->allpass_bufPos[i]] - tmp[j];
@@ -430,30 +430,30 @@ Freeverb_transform_iaa(Freeverb *self) {
if (self->allpass_bufPos[i] >= self->allpass_nSamples[i])
self->allpass_bufPos[i] = 0;
tmp[j] = x;
- }
+ }
}
-
+
for (i=0; i<self->bufsize; i++) {
mixtmp = _clip(mix[i]);
mix1 = MYSQRT(mixtmp);
mix2 = MYSQRT(1.0 - mixtmp);
self->data[i] = (tmp[i] * fixedGain * mix1) + (in[i] * mix2);
- }
+ }
}
static void
Freeverb_transform_aaa(Freeverb *self) {
MYFLT x, feedback, damp1, damp2, mix1, mix2, mixtmp;
int i, j;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *siz = Stream_getData((Stream *)self->size_stream);
MYFLT *dam = Stream_getData((Stream *)self->damp_stream);
MYFLT *mix = Stream_getData((Stream *)self->mix_stream);
-
+
MYFLT tmp[self->bufsize];
memset(&tmp, 0, sizeof(tmp));
-
+
for (j=0; j<self->bufsize; j++) {
feedback = _clip(siz[j]) * scaleRoom + offsetRoom;
damp1 = _clip(dam[j]) * scaleDamp;
@@ -469,7 +469,7 @@ Freeverb_transform_aaa(Freeverb *self) {
self->comb_bufPos[i] = 0;
}
}
-
+
for (i=0; i<NUM_ALLPASS; i++) {
for (j=0; j<self->bufsize; j++) {
x = self->allpass_buf[i][self->allpass_bufPos[i]] - tmp[j];
@@ -479,15 +479,15 @@ Freeverb_transform_aaa(Freeverb *self) {
if (self->allpass_bufPos[i] >= self->allpass_nSamples[i])
self->allpass_bufPos[i] = 0;
tmp[j] = x;
- }
+ }
}
-
+
for (i=0; i<self->bufsize; i++) {
mixtmp = _clip(mix[i]);
mix1 = MYSQRT(mixtmp);
mix2 = MYSQRT(1.0 - mixtmp);
self->data[i] = (tmp[i] * fixedGain * mix1) + (in[i] * mix2);
- }
+ }
}
static void Freeverb_postprocessing_ii(Freeverb *self) { POST_PROCESSING_II };
@@ -508,66 +508,66 @@ Freeverb_setProcMode(Freeverb *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Freeverb_transform_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Freeverb_transform_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Freeverb_transform_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Freeverb_transform_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Freeverb_transform_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Freeverb_transform_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Freeverb_transform_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Freeverb_transform_aaa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Freeverb_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Freeverb_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Freeverb_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Freeverb_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Freeverb_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Freeverb_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Freeverb_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Freeverb_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Freeverb_postprocessing_revareva;
break;
- }
+ }
}
static void
Freeverb_compute_next_data_frame(Freeverb *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -576,28 +576,28 @@ Freeverb_traverse(Freeverb *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->size);
- Py_VISIT(self->size_stream);
- Py_VISIT(self->damp);
- Py_VISIT(self->damp_stream);
- Py_VISIT(self->mix);
- Py_VISIT(self->mix_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->size);
+ Py_VISIT(self->size_stream);
+ Py_VISIT(self->damp);
+ Py_VISIT(self->damp_stream);
+ Py_VISIT(self->mix);
+ Py_VISIT(self->mix_stream);
return 0;
}
-static int
+static int
Freeverb_clear(Freeverb *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->size);
- Py_CLEAR(self->size_stream);
- Py_CLEAR(self->damp);
- Py_CLEAR(self->damp_stream);
- Py_CLEAR(self->mix);
- Py_CLEAR(self->mix_stream);
+ Py_CLEAR(self->size);
+ Py_CLEAR(self->size_stream);
+ Py_CLEAR(self->damp);
+ Py_CLEAR(self->damp_stream);
+ Py_CLEAR(self->mix);
+ Py_CLEAR(self->mix_stream);
return 0;
}
@@ -611,7 +611,7 @@ Freeverb_dealloc(Freeverb* self)
}
for(i=0; i<NUM_ALLPASS; i++) {
free(self->allpass_buf[i]);
- }
+ }
Freeverb_clear(self);
self->ob_type->tp_free((PyObject*)self);
}
@@ -633,7 +633,7 @@ Freeverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
self->srFactor = pow((DEFAULT_SRATE/self->sr), 0.8);
INIT_OBJECT_COMMON
@@ -658,7 +658,7 @@ Freeverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (mixtmp) {
PyObject_CallMethod((PyObject *)self, "setMix", "O", mixtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -666,13 +666,13 @@ Freeverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
Server_generateSeed((Server *)self->server, FREEVERB_ID);
-
+
rndSamps = (rand()/(MYFLT)(RAND_MAX) * 20 + 10) / DEFAULT_SRATE;
for(i=0; i<NUM_COMB; i++) {
nsamps = Freeverb_calc_nsamples((Freeverb *)self, comb_delays[i] + rndSamps);
@@ -683,7 +683,7 @@ Freeverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for(j=0; j<nsamps; j++) {
self->comb_buf[i][j] = 0.0;
}
- }
+ }
for(i=0; i<NUM_ALLPASS; i++) {
nsamps = Freeverb_calc_nsamples((Freeverb *)self, allpass_delays[i] + rndSamps);
self->allpass_buf[i] = (MYFLT *)realloc(self->allpass_buf[i], (nsamps+1) * sizeof(MYFLT));
@@ -693,16 +693,16 @@ Freeverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->allpass_buf[i][j] = 0.0;
}
}
-
+
return (PyObject *)self;
}
static PyObject * Freeverb_getServer(Freeverb* self) { GET_SERVER };
static PyObject * Freeverb_getStream(Freeverb* self) { GET_STREAM };
-static PyObject * Freeverb_setMul(Freeverb *self, PyObject *arg) { SET_MUL };
-static PyObject * Freeverb_setAdd(Freeverb *self, PyObject *arg) { SET_ADD };
-static PyObject * Freeverb_setSub(Freeverb *self, PyObject *arg) { SET_SUB };
-static PyObject * Freeverb_setDiv(Freeverb *self, PyObject *arg) { SET_DIV };
+static PyObject * Freeverb_setMul(Freeverb *self, PyObject *arg) { SET_MUL };
+static PyObject * Freeverb_setAdd(Freeverb *self, PyObject *arg) { SET_ADD };
+static PyObject * Freeverb_setSub(Freeverb *self, PyObject *arg) { SET_SUB };
+static PyObject * Freeverb_setDiv(Freeverb *self, PyObject *arg) { SET_DIV };
static PyObject * Freeverb_play(Freeverb *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Freeverb_out(Freeverb *self, PyObject *args, PyObject *kwds) { OUT };
@@ -721,14 +721,14 @@ static PyObject *
Freeverb_setSize(Freeverb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->size);
@@ -744,25 +744,25 @@ Freeverb_setSize(Freeverb *self, PyObject *arg)
self->size_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Freeverb_setDamp(Freeverb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->damp);
@@ -778,25 +778,25 @@ Freeverb_setDamp(Freeverb *self, PyObject *arg)
self->damp_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Freeverb_setMix(Freeverb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->mix);
@@ -812,9 +812,9 @@ Freeverb_setMix(Freeverb *self, PyObject *arg)
self->mix_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -928,4 +928,4 @@ PyTypeObject FreeverbType = {
0, /* tp_init */
0, /* tp_alloc */
Freeverb_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/granulatormodule.c b/src/objects/granulatormodule.c
index 44eaf46..6610ba3 100644
--- a/src/objects/granulatormodule.c
+++ b/src/objects/granulatormodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -56,23 +56,23 @@ static void
Granulator_transform_iii(Granulator *self) {
MYFLT val, x, x1, inc, index, fpart, amp, ppos;
int i, j, ipart;
-
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *envlist = TableStream_getData(self->env);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT pit = PyFloat_AS_DOUBLE(self->pitch);
MYFLT pos = PyFloat_AS_DOUBLE(self->pos);
MYFLT dur = PyFloat_AS_DOUBLE(self->dur);
-
+
inc = pit * (1.0 / self->basedur) / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
self->pointerPos += inc;
-
+
for (j=0; j<self->ngrains; j++) {
ppos = self->pointerPos + self->gphase[j];
if (ppos >= 1.0) {
@@ -85,13 +85,13 @@ Granulator_transform_iii(Granulator *self) {
x = envlist[ipart];
x1 = envlist[ipart+1];
amp = x + (x1 - x) * fpart;
-
+
if (ppos < self->lastppos[j]) {
self->startPos[j] = pos;
self->gsize[j] = dur * self->sr;
}
self->lastppos[j] = ppos;
-
+
// compute sampling
index = ppos * self->gsize[j] + self->startPos[j];
if (index >= 0 && index < size) {
@@ -103,39 +103,39 @@ Granulator_transform_iii(Granulator *self) {
}
else
val = 0.0;
-
+
self->data[i] += (val * amp);
}
-
+
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
}
static void
Granulator_transform_aii(Granulator *self) {
MYFLT val, x, x1, inc, index, fpart, amp, ppos, frtosamps;
int i, j, ipart;
-
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *envlist = TableStream_getData(self->env);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT *pit = Stream_getData((Stream *)self->pitch_stream);
MYFLT pos = PyFloat_AS_DOUBLE(self->pos);
MYFLT dur = PyFloat_AS_DOUBLE(self->dur);
-
+
frtosamps = (1.0 / self->basedur) / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
inc = pit[i] * frtosamps;
self->pointerPos += inc;
-
+
for (j=0; j<self->ngrains; j++) {
ppos = self->pointerPos + self->gphase[j];
if (ppos >= 1.0) {
@@ -148,13 +148,13 @@ Granulator_transform_aii(Granulator *self) {
x = envlist[ipart];
x1 = envlist[ipart+1];
amp = x + (x1 - x) * fpart;
-
+
if (ppos < self->lastppos[j]) {
self->startPos[j] = pos;
self->gsize[j] = dur * self->sr;
}
self->lastppos[j] = ppos;
-
+
// compute sampling
index = ppos * self->gsize[j] + self->startPos[j];
if (index >= 0 && index < size) {
@@ -166,15 +166,15 @@ Granulator_transform_aii(Granulator *self) {
}
else
val = 0.0;
-
+
self->data[i] += (val * amp);
}
-
+
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
}
static void
@@ -193,9 +193,9 @@ Granulator_transform_iai(Granulator *self) {
MYFLT dur = PyFloat_AS_DOUBLE(self->dur);
inc = pit * (1.0 / self->basedur) / self->sr;
-
+
MYFLT gsize = dur * self->sr;
-
+
for (j=0; j<self->ngrains; j++) {
self->gsize[j] = gsize;
}
@@ -203,7 +203,7 @@ Granulator_transform_iai(Granulator *self) {
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
self->pointerPos += inc;
-
+
for (j=0; j<self->ngrains; j++) {
ppos = self->pointerPos + self->gphase[j];
if (ppos >= 1.0) {
@@ -221,7 +221,7 @@ Granulator_transform_iai(Granulator *self) {
self->startPos[j] = pos[i];
}
self->lastppos[j] = ppos;
-
+
// compute sampling
index = ppos * self->gsize[j] + self->startPos[j];
if (index >= 0 && index < size) {
@@ -236,36 +236,36 @@ Granulator_transform_iai(Granulator *self) {
self->data[i] += (val * amp);
}
-
+
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
}
static void
Granulator_transform_aai(Granulator *self) {
MYFLT val, x, x1, inc, index, fpart, amp, ppos, frtosamps;
int i, j, ipart;
-
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *envlist = TableStream_getData(self->env);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT *pit = Stream_getData((Stream *)self->pitch_stream);
MYFLT *pos = Stream_getData((Stream *)self->pos_stream);
MYFLT dur = PyFloat_AS_DOUBLE(self->dur);
-
+
frtosamps = (1.0 / self->basedur) / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
inc = pit[i] * frtosamps;
self->pointerPos += inc;
-
+
for (j=0; j<self->ngrains; j++) {
ppos = self->pointerPos + self->gphase[j];
if (ppos >= 1.0) {
@@ -278,13 +278,13 @@ Granulator_transform_aai(Granulator *self) {
x = envlist[ipart];
x1 = envlist[ipart+1];
amp = x + (x1 - x) * fpart;
-
+
if (ppos < self->lastppos[j]) {
self->startPos[j] = pos[i];
self->gsize[j] = dur * self->sr;
}
self->lastppos[j] = ppos;
-
+
// compute sampling
index = ppos * self->gsize[j] + self->startPos[j];
if (index >= 0 && index < size) {
@@ -296,38 +296,38 @@ Granulator_transform_aai(Granulator *self) {
}
else
val = 0.0;
-
+
self->data[i] += (val * amp);
}
-
+
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
}
-}
+}
static void
Granulator_transform_iia(Granulator *self) {
MYFLT val, x, x1, inc, index, fpart, amp, ppos;
int i, j, ipart;
-
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *envlist = TableStream_getData(self->env);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT pit = PyFloat_AS_DOUBLE(self->pitch);
MYFLT pos = PyFloat_AS_DOUBLE(self->pos);
MYFLT *dur = Stream_getData((Stream *)self->dur_stream);
-
+
inc = pit * (1.0 / self->basedur) / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
self->pointerPos += inc;
-
+
for (j=0; j<self->ngrains; j++) {
ppos = self->pointerPos + self->gphase[j];
if (ppos >= 1.0) {
@@ -340,13 +340,13 @@ Granulator_transform_iia(Granulator *self) {
x = envlist[ipart];
x1 = envlist[ipart+1];
amp = x + (x1 - x) * fpart;
-
+
if (ppos < self->lastppos[j]) {
self->startPos[j] = pos;
self->gsize[j] = dur[i] * self->sr;
}
self->lastppos[j] = ppos;
-
+
// compute sampling
index = ppos * self->gsize[j] + self->startPos[j];
if (index >= 0 && index < size) {
@@ -358,39 +358,39 @@ Granulator_transform_iia(Granulator *self) {
}
else
val = 0.0;
-
+
self->data[i] += (val * amp);
}
-
+
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
}
static void
Granulator_transform_aia(Granulator *self) {
MYFLT val, x, x1, inc, index, fpart, amp, ppos, frtosamps;
int i, j, ipart;
-
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *envlist = TableStream_getData(self->env);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT *pit = Stream_getData((Stream *)self->pitch_stream);
MYFLT pos = PyFloat_AS_DOUBLE(self->pos);
MYFLT *dur = Stream_getData((Stream *)self->dur_stream);
-
+
frtosamps = (1.0 / self->basedur) / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
inc = pit[i] * frtosamps;
self->pointerPos += inc;
-
+
for (j=0; j<self->ngrains; j++) {
ppos = self->pointerPos + self->gphase[j];
if (ppos >= 1.0) {
@@ -403,13 +403,13 @@ Granulator_transform_aia(Granulator *self) {
x = envlist[ipart];
x1 = envlist[ipart+1];
amp = x + (x1 - x) * fpart;
-
+
if (ppos < self->lastppos[j]) {
self->startPos[j] = pos;
self->gsize[j] = dur[i] * self->sr;
}
self->lastppos[j] = ppos;
-
+
// compute sampling
index = ppos * self->gsize[j] + self->startPos[j];
if (index >= 0 && index < size) {
@@ -421,38 +421,38 @@ Granulator_transform_aia(Granulator *self) {
}
else
val = 0.0;
-
+
self->data[i] += (val * amp);
}
-
+
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
}
static void
Granulator_transform_iaa(Granulator *self) {
MYFLT val, x, x1, inc, index, fpart, amp, ppos;
int i, j, ipart;
-
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *envlist = TableStream_getData(self->env);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT pit = PyFloat_AS_DOUBLE(self->pitch);
MYFLT *pos = Stream_getData((Stream *)self->pos_stream);
MYFLT *dur = Stream_getData((Stream *)self->dur_stream);
-
+
inc = pit * (1.0 / self->basedur) / self->sr;
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
self->pointerPos += inc;
-
+
for (j=0; j<self->ngrains; j++) {
ppos = self->pointerPos + self->gphase[j];
if (ppos >= 1.0) {
@@ -465,13 +465,13 @@ Granulator_transform_iaa(Granulator *self) {
x = envlist[ipart];
x1 = envlist[ipart+1];
amp = x + (x1 - x) * fpart;
-
+
if (ppos < self->lastppos[j]) {
self->startPos[j] = pos[i];
self->gsize[j] = dur[i] * self->sr;
}
self->lastppos[j] = ppos;
-
+
// compute sampling
index = ppos * self->gsize[j] + self->startPos[j];
if (index >= 0 && index < size) {
@@ -483,39 +483,39 @@ Granulator_transform_iaa(Granulator *self) {
}
else
val = 0.0;
-
+
self->data[i] += (val * amp);
}
-
+
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
}
static void
-Granulator_transform_aaa(Granulator *self) {
+Granulator_transform_aaa(Granulator *self) {
MYFLT val, x, x1, inc, index, fpart, amp, ppos, frtosamps;
int i, j, ipart;
-
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *envlist = TableStream_getData(self->env);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT *pit = Stream_getData((Stream *)self->pitch_stream);
MYFLT *pos = Stream_getData((Stream *)self->pos_stream);
MYFLT *dur = Stream_getData((Stream *)self->dur_stream);
-
+
frtosamps = (1.0 / self->basedur) / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
inc = pit[i] * frtosamps;
self->pointerPos += inc;
-
+
for (j=0; j<self->ngrains; j++) {
ppos = self->pointerPos + self->gphase[j];
if (ppos >= 1.0) {
@@ -528,13 +528,13 @@ Granulator_transform_aaa(Granulator *self) {
x = envlist[ipart];
x1 = envlist[ipart+1];
amp = x + (x1 - x) * fpart;
-
+
if (ppos < self->lastppos[j]) {
self->startPos[j] = pos[i];
self->gsize[j] = dur[i] * self->sr;
}
self->lastppos[j] = ppos;
-
+
// compute sampling
index = ppos * self->gsize[j] + self->startPos[j];
if (index >= 0 && index < size) {
@@ -546,15 +546,15 @@ Granulator_transform_aaa(Granulator *self) {
}
else
val = 0.0;
-
+
self->data[i] += (val * amp);
}
-
+
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
}
static void Granulator_postprocessing_ii(Granulator *self) { POST_PROCESSING_II };
@@ -575,66 +575,66 @@ Granulator_setProcMode(Granulator *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Granulator_transform_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Granulator_transform_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Granulator_transform_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Granulator_transform_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Granulator_transform_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Granulator_transform_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Granulator_transform_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Granulator_transform_aaa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Granulator_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Granulator_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Granulator_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Granulator_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Granulator_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Granulator_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Granulator_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Granulator_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Granulator_postprocessing_revareva;
break;
- }
+ }
}
static void
Granulator_compute_next_data_frame(Granulator *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -644,27 +644,27 @@ Granulator_traverse(Granulator *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->table);
Py_VISIT(self->env);
- Py_VISIT(self->pitch);
- Py_VISIT(self->pitch_stream);
- Py_VISIT(self->pos);
- Py_VISIT(self->pos_stream);
- Py_VISIT(self->dur);
- Py_VISIT(self->dur_stream);
+ Py_VISIT(self->pitch);
+ Py_VISIT(self->pitch_stream);
+ Py_VISIT(self->pos);
+ Py_VISIT(self->pos_stream);
+ Py_VISIT(self->dur);
+ Py_VISIT(self->dur_stream);
return 0;
}
-static int
+static int
Granulator_clear(Granulator *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
Py_CLEAR(self->env);
- Py_CLEAR(self->pitch);
- Py_CLEAR(self->pitch_stream);
- Py_CLEAR(self->pos);
- Py_CLEAR(self->pos_stream);
- Py_CLEAR(self->dur);
- Py_CLEAR(self->dur_stream);
+ Py_CLEAR(self->pitch);
+ Py_CLEAR(self->pitch_stream);
+ Py_CLEAR(self->pos);
+ Py_CLEAR(self->pos_stream);
+ Py_CLEAR(self->dur);
+ Py_CLEAR(self->dur_stream);
return 0;
}
@@ -672,7 +672,7 @@ static void
Granulator_dealloc(Granulator* self)
{
pyo_DEALLOC
- free(self->startPos);
+ free(self->startPos);
free(self->gphase);
free(self->gsize);
free(self->lastppos);
@@ -711,25 +711,19 @@ Granulator_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of Granulator must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Granulator must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
if ( PyObject_HasAttrString((PyObject *)envtmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"env\" argument of Granulator must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"env\" argument of Granulator must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->env);
self->env = PyObject_CallMethod((PyObject *)envtmp, "getTableStream", "");
-
+
if (pitchtmp) {
PyObject_CallMethod((PyObject *)self, "setPitch", "O", pitchtmp);
}
@@ -741,7 +735,7 @@ Granulator_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (durtmp) {
PyObject_CallMethod((PyObject *)self, "setDur", "O", durtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -749,7 +743,7 @@ Granulator_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->startPos = (MYFLT *)realloc(self->startPos, self->ngrains * sizeof(MYFLT));
@@ -758,7 +752,7 @@ Granulator_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->lastppos = (MYFLT *)realloc(self->lastppos, self->ngrains * sizeof(MYFLT));
Server_generateSeed((Server *)self->server, GRANULATOR_ID);
-
+
for (i=0; i<self->ngrains; i++) {
phase = ((MYFLT)i/self->ngrains) * (1.0 + ((rand()/((MYFLT)(RAND_MAX)+1)*2.0-1.0) * 0.01));
if (phase < 0.0)
@@ -769,18 +763,18 @@ Granulator_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->startPos[i] = self->gsize[i] = 0.0;
self->lastppos[i] = 1.0;
}
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Granulator_getServer(Granulator* self) { GET_SERVER };
static PyObject * Granulator_getStream(Granulator* self) { GET_STREAM };
-static PyObject * Granulator_setMul(Granulator *self, PyObject *arg) { SET_MUL };
-static PyObject * Granulator_setAdd(Granulator *self, PyObject *arg) { SET_ADD };
-static PyObject * Granulator_setSub(Granulator *self, PyObject *arg) { SET_SUB };
-static PyObject * Granulator_setDiv(Granulator *self, PyObject *arg) { SET_DIV };
+static PyObject * Granulator_setMul(Granulator *self, PyObject *arg) { SET_MUL };
+static PyObject * Granulator_setAdd(Granulator *self, PyObject *arg) { SET_ADD };
+static PyObject * Granulator_setSub(Granulator *self, PyObject *arg) { SET_SUB };
+static PyObject * Granulator_setDiv(Granulator *self, PyObject *arg) { SET_DIV };
static PyObject * Granulator_play(Granulator *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Granulator_out(Granulator *self, PyObject *args, PyObject *kwds) { OUT };
@@ -799,14 +793,14 @@ static PyObject *
Granulator_setPitch(Granulator *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pitch);
@@ -822,25 +816,25 @@ Granulator_setPitch(Granulator *self, PyObject *arg)
self->pitch_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Granulator_setPos(Granulator *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pos);
@@ -856,25 +850,25 @@ Granulator_setPos(Granulator *self, PyObject *arg)
self->pos_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Granulator_setDur(Granulator *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->dur);
@@ -890,9 +884,9 @@ Granulator_setDur(Granulator *self, PyObject *arg)
self->dur_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -908,19 +902,19 @@ static PyObject *
Granulator_setTable(Granulator *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Granulator_getEnv(Granulator* self)
@@ -933,33 +927,33 @@ static PyObject *
Granulator_setEnv(Granulator *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->env);
self->env = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Granulator_setBaseDur(Granulator *self, PyObject *arg)
-{
+{
if (arg != NULL)
self->basedur = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Granulator_setGrains(Granulator *self, PyObject *arg)
-{
+{
int i;
MYFLT phase;
if (PyLong_Check(arg) || PyInt_Check(arg)) {
@@ -968,7 +962,7 @@ Granulator_setGrains(Granulator *self, PyObject *arg)
self->gsize = (MYFLT *)realloc(self->gsize, self->ngrains * sizeof(MYFLT));
self->gphase = (MYFLT *)realloc(self->gphase, self->ngrains * sizeof(MYFLT));
self->lastppos = (MYFLT *)realloc(self->lastppos, self->ngrains * sizeof(MYFLT));
-
+
for (i=0; i<self->ngrains; i++) {
phase = ((MYFLT)i/self->ngrains) * (1.0 + ((rand()/((MYFLT)(RAND_MAX)+1)*2.0-1.0) * 0.01));
if (phase < 0.0)
@@ -978,12 +972,12 @@ Granulator_setGrains(Granulator *self, PyObject *arg)
self->gphase[i] = phase;
self->startPos[i] = self->gsize[i] = 0.0;
self->lastppos[i] = 1.0;
- }
- }
-
+ }
+ }
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Granulator_members[] = {
{"server", T_OBJECT_EX, offsetof(Granulator, server), 0, "Pyo server."},
@@ -1118,8 +1112,9 @@ typedef struct {
int xfadeshape;
int startfromloop;
int init;
- int mode; /* 0 = no loop, 1 = forward, 2 = backward, 3 = back-and-forth */
+ int mode[2]; /* 0 = no loop, 1 = forward, 2 = backward, 3 = back-and-forth */
int tmpmode;
+ int direction[2];
double pointerPos[2];
int active[2];
long loopstart[2];
@@ -1139,8 +1134,7 @@ typedef struct {
MYFLT y2;
// variables
MYFLT c1;
- MYFLT c2;
-
+
} Looper;
static void
@@ -1162,7 +1156,7 @@ Looper_reset(Looper *self, int x, int which, int init) {
xfade = PyFloat_AS_DOUBLE(self->xfade);
else
xfade = Stream_getData((Stream *)self->xfade_stream)[x];
-
+
if (start < 0.0)
start = 0.0;
else if (start > (size/tableSr))
@@ -1182,18 +1176,16 @@ Looper_reset(Looper *self, int x, int which, int init) {
self->fader = LOOPER_SIGMOID_FADE;
else
self->fader = LOOPER_LINEAR_FADE;
-
- if (self->tmpmode != self->mode) {
- self->mode = self->tmpmode;
- self->active[0] = self->active[1] = 0;
- which = 0;
- }
-
- switch (self->mode) {
+
+ if (self->tmpmode != self->mode[which])
+ self->mode[which] = self->tmpmode;
+
+ switch (self->mode[which]) {
case 0:
self->loopstart[which] = 0;
self->loopend[which] = (long)size;
- self->crossfadedur[which] = 5;
+ if (self->crossfadedur[which] < 1)
+ self->crossfadedur[which] = 1;
self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
if (init == 1 && self->startfromloop == 0) {
self->minfadepoint[which] = self->crossfadedur[which];
@@ -1203,15 +1195,15 @@ Looper_reset(Looper *self, int x, int which, int init) {
else {
self->minfadepoint[which] = self->loopstart[which] + self->crossfadedur[which];
self->maxfadepoint[which] = self->loopend[which] - self->crossfadedur[which];
- self->pointerPos[which] = self->loopstart[which];
- }
+ self->pointerPos[which] = self->loopstart[which];
+ }
break;
case 1:
self->loopstart[which] = (long)(start * tableSr);
self->loopend[which] = (long)((start + dur) * tableSr);
self->crossfadedur[which] = (long)((self->loopend[which] - self->loopstart[which]) * xfade * 0.01);
- if (self->crossfadedur[which] < 5)
- self->crossfadedur[which] = 5;
+ if (self->crossfadedur[which] < 1)
+ self->crossfadedur[which] = 1;
self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
if (init == 1 && self->startfromloop == 0) {
self->minfadepoint[which] = self->crossfadedur[which];
@@ -1221,15 +1213,15 @@ Looper_reset(Looper *self, int x, int which, int init) {
else {
self->minfadepoint[which] = self->loopstart[which] + self->crossfadedur[which];
self->maxfadepoint[which] = self->loopend[which] - self->crossfadedur[which];
- self->pointerPos[which] = self->loopstart[which];
- }
+ self->pointerPos[which] = self->loopstart[which];
+ }
break;
case 2:
self->loopstart[which] = (long)((start + dur) * tableSr);
- self->loopend[which] = (long)((start) * tableSr);
+ self->loopend[which] = (long)(start * tableSr);
self->crossfadedur[which] = (long)((self->loopstart[which] - self->loopend[which]) * xfade * 0.01);
- if (self->crossfadedur[which] < 5)
- self->crossfadedur[which] = 5;
+ if (self->crossfadedur[which] < 1)
+ self->crossfadedur[which] = 1;
self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
if (init == 1 && self->startfromloop == 0) {
self->minfadepoint[which] = size - self->crossfadedur[which];
@@ -1239,16 +1231,29 @@ Looper_reset(Looper *self, int x, int which, int init) {
else {
self->minfadepoint[which] = self->loopstart[which] - self->crossfadedur[which];
self->maxfadepoint[which] = self->loopend[which] + self->crossfadedur[which];
- self->pointerPos[which] = self->loopstart[which];
- }
+ self->pointerPos[which] = self->loopstart[which];
+ }
break;
case 3:
- if (which == 0) {
+ if (self->direction[1-which] == 0) {
+ self->direction[which] = 1;
+ self->loopstart[which] = (long)((start + dur) * tableSr);
+ self->loopend[which] = (long)(start * tableSr);
+ self->crossfadedur[which] = (long)((self->loopstart[which] - self->loopend[which]) * xfade * 0.01);
+ if (self->crossfadedur[which] < 1)
+ self->crossfadedur[which] = 1;
+ self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
+ self->minfadepoint[which] = self->loopstart[which] - self->crossfadedur[which];
+ self->maxfadepoint[which] = self->loopend[which] + self->crossfadedur[which];
+ self->pointerPos[which] = self->loopstart[which];
+ }
+ else {
+ self->direction[which] = 0;
self->loopstart[which] = (long)(start * tableSr);
self->loopend[which] = (long)((start + dur) * tableSr);
self->crossfadedur[which] = (long)((self->loopend[which] - self->loopstart[which]) * xfade * 0.01);
- if (self->crossfadedur[which] < 5)
- self->crossfadedur[which] = 5;
+ if (self->crossfadedur[which] < 1)
+ self->crossfadedur[which] = 1;
self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
if (init == 1 && self->startfromloop == 0) {
self->minfadepoint[which] = self->crossfadedur[which];
@@ -1258,32 +1263,26 @@ Looper_reset(Looper *self, int x, int which, int init) {
else {
self->minfadepoint[which] = self->loopstart[which] + self->crossfadedur[which];
self->maxfadepoint[which] = self->loopend[which] - self->crossfadedur[which];
- self->pointerPos[which] = self->loopstart[which];
+ self->pointerPos[which] = self->loopstart[which];
}
}
- else {
- self->loopstart[which] = (long)((start + dur) * tableSr);
- self->loopend[which] = (long)(start * tableSr);
- self->crossfadedur[which] = (long)((self->loopstart[which] - self->loopend[which]) * xfade * 0.01);
- if (self->crossfadedur[which] < 5)
- self->crossfadedur[which] = 5;
- self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
- self->minfadepoint[which] = self->loopstart[which] - self->crossfadedur[which];
- self->maxfadepoint[which] = self->loopend[which] + self->crossfadedur[which];
- self->pointerPos[which] = self->loopstart[which];
- }
break;
}
-
self->active[which] = 1;
}
+static MYFLT
+Looper_get_amp(Looper *self, MYFLT pos) {
+ int ipart = (int)pos;
+ return self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * (pos - ipart);
+}
+
static void
Looper_transform_i(Looper *self) {
- MYFLT fpart, amp, fr, b;
+ MYFLT fpart, amp, fr;
double pit;
int i, j, ipart;
-
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
double tableSr = TableStream_getSamplingRate(self->table);
@@ -1291,68 +1290,51 @@ Looper_transform_i(Looper *self) {
MYFLT pitval = PyFloat_AS_DOUBLE(self->pitch);
if (pitval < 0.0)
pitval = 0.0;
-
+
pit = pitval * tableSr / self->sr;
-
+
if (self->active[0] == 0 && self->active[1] == 0) {
Looper_reset(self, 0, 0, 1);
}
-
- switch (self->mode) {
- case 0:
- for (i=0; i<self->bufsize; i++) {
- self->data[i] = 0.0;
- if (self->active[0] == 1) {
- if (self->pointerPos[0] > size)
- self->data[i] += 0.0;
- else {
- if (self->pointerPos[0] < self->minfadepoint[0]) {
- fpart = (self->pointerPos[0] - self->loopstart[0]) * self->crossfadescaling[0];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = 0.0;
+ for (j=0; j<2; j++) {
+ if (self->active[j] == 1) {
+ switch (self->mode[j]) {
+ case 0:
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
+ if (self->pointerPos[j] < self->minfadepoint[j]) {
+ fpart = (self->pointerPos[j] - self->loopstart[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else if (self->pointerPos[j] > self->maxfadepoint[j]) {
+ fpart = (self->loopend[j] - self->pointerPos[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else
+ amp = 1.0;
+ ipart = (int)self->pointerPos[j];
+ fpart = self->pointerPos[j] - ipart;
+ self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
}
- else if (self->pointerPos[0] > self->maxfadepoint[0]) {
- fpart = (self->loopend[0] - self->pointerPos[0]) * self->crossfadescaling[0];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ self->pointerPos[j] += pit;
+ if (self->pointerPos[j] < 0.0)
+ self->pointerPos[j] = 0.0;
+ else if (self->pointerPos[j] >= self->loopend[j]) {
+ self->active[j] = 0;
+ PyObject_CallMethod((PyObject *)self, "stop", NULL);
}
- else
- amp = 1.0;
- ipart = (int)self->pointerPos[0];
- fpart = self->pointerPos[0] - ipart;
- self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
- }
- self->pointerPos[0] += pit;
- if (self->pointerPos[0] < 0)
- self->pointerPos[0] = 0.0;
- else if (self->pointerPos[0] >= self->loopend[0]) {
- self->active[0] = 0;
- PyObject_CallMethod((PyObject *)self, "stop", NULL);
- }
- }
- }
- break;
- case 1:
- for (i=0; i<self->bufsize; i++) {
- self->data[i] = 0.0;
- for (j=0; j<2; j++) {
- if (self->active[j] == 1) {
- if (self->pointerPos[j] > size)
- self->data[i] += 0.0;
- else {
+ break;
+ case 1:
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
if (self->pointerPos[j] < self->minfadepoint[j]) {
fpart = (self->pointerPos[j] - self->loopstart[j]) * self->crossfadescaling[j];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ amp = Looper_get_amp(self, fpart);
}
else if (self->pointerPos[j] > self->maxfadepoint[j]) {
fpart = (self->loopend[j] - self->pointerPos[j]) * self->crossfadescaling[j];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ amp = Looper_get_amp(self, fpart);
}
else
amp = 1.0;
@@ -1361,35 +1343,22 @@ Looper_transform_i(Looper *self) {
self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
}
self->pointerPos[j] += pit;
- if (self->pointerPos[j] < 0)
+ if (self->pointerPos[j] < 0.0)
self->pointerPos[j] = 0.0;
else if (self->pointerPos[j] > self->maxfadepoint[j] && self->active[1-j] == 0)
- Looper_reset(self, i, 1-j, 0);
- else if (self->pointerPos[j] >= self->loopend[j])
+ Looper_reset(self, i, 1-j, 0);
+ if (self->pointerPos[j] >= self->loopend[j])
self->active[j] = 0;
- }
- }
- }
- break;
- case 2:
- for (i=0; i<self->bufsize; i++) {
- self->data[i] = 0.0;
- for (j=0; j<2; j++) {
- if (self->active[j] == 1) {
- if (self->pointerPos[j] < 0.0)
- self->data[i] += 0.0;
- else {
+ break;
+ case 2:
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
if (self->pointerPos[j] > self->minfadepoint[j]) {
fpart = (self->loopstart[j] - self->pointerPos[j]) * self->crossfadescaling[j];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ amp = Looper_get_amp(self, fpart);
}
else if (self->pointerPos[j] < self->maxfadepoint[j]) {
fpart = (self->pointerPos[j] - self->loopend[j]) * self->crossfadescaling[j];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ amp = Looper_get_amp(self, fpart);
}
else
amp = 1.0;
@@ -1401,92 +1370,77 @@ Looper_transform_i(Looper *self) {
if (self->pointerPos[j] >= size)
self->pointerPos[j] = size-1;
else if (self->pointerPos[j] < self->maxfadepoint[j] && self->active[1-j] == 0)
- Looper_reset(self, i, 1-j, 0);
- else if (self->pointerPos[j] <= self->loopend[j])
+ Looper_reset(self, i, 1-j, 0);
+ if (self->pointerPos[j] <= self->loopend[j])
self->active[j] = 0;
- }
- }
- }
- break;
- case 3:
- for (i=0; i<self->bufsize; i++) {
- self->data[i] = 0.0;
- if (self->active[0] == 1) {
- if (self->pointerPos[0] > size)
- self->data[i] += 0.0;
- else {
- if (self->pointerPos[0] < self->minfadepoint[0]) {
- fpart = (self->pointerPos[0] - self->loopstart[0]) * self->crossfadescaling[0];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
- }
- else if (self->pointerPos[0] > self->maxfadepoint[0]) {
- fpart = (self->loopend[0] - self->pointerPos[0]) * self->crossfadescaling[0];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
- }
- else
- amp = 1.0;
- ipart = (int)self->pointerPos[0];
- fpart = self->pointerPos[0] - ipart;
- self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
- }
- self->pointerPos[0] += pit;
- if (self->pointerPos[0] < 0)
- self->pointerPos[0] = 0.0;
- else if (self->pointerPos[0] > self->maxfadepoint[0] && self->active[1] == 0)
- Looper_reset(self, i, 1, 0);
- else if (self->pointerPos[0] >= self->loopend[0])
- self->active[0] = 0;
- }
- if (self->active[1] == 1) {
- if (self->pointerPos[1] < 0.0)
- self->data[i] += 0.0;
- else {
- if (self->pointerPos[1] > self->minfadepoint[1]) {
- fpart = (self->loopstart[1] - self->pointerPos[1]) * self->crossfadescaling[1];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ break;
+ case 3:
+ if (self->direction[j] == 0) {
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
+ if (self->pointerPos[j] < self->minfadepoint[j]) {
+ fpart = (self->pointerPos[j] - self->loopstart[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else if (self->pointerPos[j] > self->maxfadepoint[j]) {
+ fpart = (self->loopend[j] - self->pointerPos[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else
+ amp = 1.0;
+ ipart = (int)self->pointerPos[j];
+ fpart = self->pointerPos[j] - ipart;
+ self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
+ }
+ self->pointerPos[j] += pit;
+ if (self->pointerPos[j] < 0.0)
+ self->pointerPos[j] = 0.0;
+ else if (self->pointerPos[j] > self->maxfadepoint[j] && self->active[1-j] == 0)
+ Looper_reset(self, i, 1-j, 0);
+ if (self->pointerPos[j] >= self->loopend[j])
+ self->active[j] = 0;
}
- else if (self->pointerPos[1] < self->maxfadepoint[1]) {
- fpart = (self->pointerPos[1] - self->loopend[1]) * self->crossfadescaling[1];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ else {
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
+ if (self->pointerPos[j] > self->minfadepoint[j]) {
+ fpart = (self->loopstart[j] - self->pointerPos[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else if (self->pointerPos[j] < self->maxfadepoint[j]) {
+ fpart = (self->pointerPos[j] - self->loopend[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else
+ amp = 1.0;
+ ipart = (int)self->pointerPos[j];
+ fpart = self->pointerPos[j] - ipart;
+ self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
+ }
+ self->pointerPos[j] -= pit;
+ if (self->pointerPos[j] >= size)
+ self->pointerPos[j] = size-1;
+ else if (self->pointerPos[j] < self->maxfadepoint[j] && self->active[1-j] == 0)
+ Looper_reset(self, i, 1-j, 0);
+ if (self->pointerPos[j] <= self->loopend[j])
+ self->active[j] = 0;
}
- else
- amp = 1.0;
- ipart = (int)self->pointerPos[1];
- fpart = self->pointerPos[1] - ipart;
- self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
- }
- self->pointerPos[1] -= pit;
- if (self->pointerPos[1] >= size)
- self->pointerPos[1] = size-1;
- else if (self->pointerPos[1] < self->maxfadepoint[1] && self->active[0] == 0)
- Looper_reset(self, i, 0, 0);
- else if (self->pointerPos[1] <= self->loopend[1])
- self->active[1] = 0;
- }
+ break;
+ } // end of switch
}
- break;
+ }
}
/* Automatic smoothering of low transposition */
- if (self->autosmooth == 1 && pitval < 1.0 && pit > 0.0) {
+ if (self->autosmooth == 1 && pitval < 1.0) {
if (self->lastpitch != pitval) {
self->lastpitch = pitval;
- fr = pitval * tableSr * 0.45;
- b = 2.0 - MYCOS(TWOPI * fr / self->sr);
- self->c2 = (b - MYSQRT(b * b - 1.0));
- self->c1 = 1.0 - self->c2;
+ if (pitval < 0.001)
+ pitval = 0.001;
+ fr = pitval * self->sr * 0.45;
+ self->c1 = MYEXP(-TWOPI * fr / self->sr);
}
for (i=0; i<self->bufsize; i++) {
- self->y1 = self->c1 * self->data[i] + self->c2 * self->y1;
- self->y2 = self->c1 * self->y1 + self->c2 * self->y2;
+ self->y1 = self->data[i] + (self->y1 - self->data[i]) * self->c1;
+ self->y2 = self->y1 + (self->y2 - self->y1) * self->c1;
self->data[i] = self->y2;
}
}
@@ -1494,84 +1448,64 @@ Looper_transform_i(Looper *self) {
static void
Looper_transform_a(Looper *self) {
- MYFLT fpart, amp, fr, b;
- double pit;
+ MYFLT fpart, amp, fr, pitval;
+ double pit, srFactor;
int i, j, ipart;
-
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
double tableSr = TableStream_getSamplingRate(self->table);
- double ratio = tableSr / self->sr;
-
+
MYFLT *pitch = Stream_getData((Stream *)self->pitch_stream);
-
+
+ srFactor = tableSr / self->sr;
+
if (self->active[0] == 0 && self->active[1] == 0) {
Looper_reset(self, 0, 0, 1);
}
-
- switch (self->mode) {
- case 0:
- for (i=0; i<self->bufsize; i++) {
- self->data[i] = 0.0;
- pit = pitch[i];
- if (pit < 0.0)
- pit = 0.0;
- pit = pit * ratio;
- if (self->active[0] == 1) {
- if (self->pointerPos[0] > size)
- self->data[i] += 0.0;
- else {
- if (self->pointerPos[0] < self->minfadepoint[0]) {
- fpart = (self->pointerPos[0] - self->loopstart[0]) * self->crossfadescaling[0];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = 0.0;
+ pitval = pitch[i];
+ if (pitval < 0.0)
+ pitval = 0.0;
+ pit = pitval * srFactor;
+ for (j=0; j<2; j++) {
+ if (self->active[j] == 1) {
+ switch (self->mode[j]) {
+ case 0:
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
+ if (self->pointerPos[j] < self->minfadepoint[j]) {
+ fpart = (self->pointerPos[j] - self->loopstart[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else if (self->pointerPos[j] > self->maxfadepoint[j]) {
+ fpart = (self->loopend[j] - self->pointerPos[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else
+ amp = 1.0;
+ ipart = (int)self->pointerPos[j];
+ fpart = self->pointerPos[j] - ipart;
+ self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
}
- else if (self->pointerPos[0] > self->maxfadepoint[0]) {
- fpart = (self->loopend[0] - self->pointerPos[0]) * self->crossfadescaling[0];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ self->pointerPos[j] += pit;
+ if (self->pointerPos[j] < 0.0)
+ self->pointerPos[j] = 0.0;
+ else if (self->pointerPos[j] >= self->loopend[j]) {
+ self->active[j] = 0;
+ PyObject_CallMethod((PyObject *)self, "stop", NULL);
}
- else
- amp = 1.0;
- ipart = (int)self->pointerPos[0];
- fpart = self->pointerPos[0] - ipart;
- self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
- }
- self->pointerPos[0] += pit;
- if (self->pointerPos[0] < 0)
- self->pointerPos[0] = 0.0;
- else if (self->pointerPos[0] >= self->loopend[0]) {
- self->active[0] = 0;
- PyObject_CallMethod((PyObject *)self, "stop", NULL);
- }
- }
- }
- break;
- case 1:
- for (i=0; i<self->bufsize; i++) {
- self->data[i] = 0.0;
- pit = pitch[i];
- if (pit < 0.0)
- pit = 0.0;
- pit = pit * ratio;
- for (j=0; j<2; j++) {
- if (self->active[j] == 1) {
- if (self->pointerPos[j] > size)
- self->data[i] += 0.0;
- else {
+ break;
+ case 1:
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
if (self->pointerPos[j] < self->minfadepoint[j]) {
fpart = (self->pointerPos[j] - self->loopstart[j]) * self->crossfadescaling[j];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ amp = Looper_get_amp(self, fpart);
}
else if (self->pointerPos[j] > self->maxfadepoint[j]) {
fpart = (self->loopend[j] - self->pointerPos[j]) * self->crossfadescaling[j];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ amp = Looper_get_amp(self, fpart);
}
else
amp = 1.0;
@@ -1580,39 +1514,22 @@ Looper_transform_a(Looper *self) {
self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
}
self->pointerPos[j] += pit;
- if (self->pointerPos[j] < 0)
+ if (self->pointerPos[j] < 0.0)
self->pointerPos[j] = 0.0;
else if (self->pointerPos[j] > self->maxfadepoint[j] && self->active[1-j] == 0)
- Looper_reset(self, i, 1-j, 0);
- else if (self->pointerPos[j] >= self->loopend[j])
+ Looper_reset(self, i, 1-j, 0);
+ if (self->pointerPos[j] >= self->loopend[j])
self->active[j] = 0;
- }
- }
- }
- break;
- case 2:
- for (i=0; i<self->bufsize; i++) {
- self->data[i] = 0.0;
- pit = pitch[i];
- if (pit < 0.0)
- pit = 0.0;
- pit = pit * ratio;
- for (j=0; j<2; j++) {
- if (self->active[j] == 1) {
- if (self->pointerPos[j] < 0.0)
- self->data[i] += 0.0;
- else {
+ break;
+ case 2:
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
if (self->pointerPos[j] > self->minfadepoint[j]) {
fpart = (self->loopstart[j] - self->pointerPos[j]) * self->crossfadescaling[j];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ amp = Looper_get_amp(self, fpart);
}
else if (self->pointerPos[j] < self->maxfadepoint[j]) {
fpart = (self->pointerPos[j] - self->loopend[j]) * self->crossfadescaling[j];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ amp = Looper_get_amp(self, fpart);
}
else
amp = 1.0;
@@ -1624,102 +1541,80 @@ Looper_transform_a(Looper *self) {
if (self->pointerPos[j] >= size)
self->pointerPos[j] = size-1;
else if (self->pointerPos[j] < self->maxfadepoint[j] && self->active[1-j] == 0)
- Looper_reset(self, i, 1-j, 0);
- else if (self->pointerPos[j] <= self->loopend[j])
+ Looper_reset(self, i, 1-j, 0);
+ if (self->pointerPos[j] <= self->loopend[j])
self->active[j] = 0;
- }
- }
- }
- break;
- case 3:
- for (i=0; i<self->bufsize; i++) {
- self->data[i] = 0.0;
- pit = pitch[i];
- if (pit < 0.0)
- pit = 0.0;
- pit = pit * ratio;
- if (self->active[0] == 1) {
- if (self->pointerPos[0] > size)
- self->data[i] += 0.0;
- else {
- if (self->pointerPos[0] < self->minfadepoint[0]) {
- fpart = (self->pointerPos[0] - self->loopstart[0]) * self->crossfadescaling[0];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
- }
- else if (self->pointerPos[0] > self->maxfadepoint[0]) {
- fpart = (self->loopend[0] - self->pointerPos[0]) * self->crossfadescaling[0];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
- }
- else
- amp = 1.0;
- ipart = (int)self->pointerPos[0];
- fpart = self->pointerPos[0] - ipart;
- self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
- }
- self->pointerPos[0] += pit;
- if (self->pointerPos[0] < 0)
- self->pointerPos[0] = 0.0;
- else if (self->pointerPos[0] > self->maxfadepoint[0] && self->active[1] == 0)
- Looper_reset(self, i, 1, 0);
- else if (self->pointerPos[0] >= self->loopend[0])
- self->active[0] = 0;
- }
- if (self->active[1] == 1) {
- if (self->pointerPos[1] < 0.0)
- self->data[i] += 0.0;
- else {
- if (self->pointerPos[1] > self->minfadepoint[1]) {
- fpart = (self->loopstart[1] - self->pointerPos[1]) * self->crossfadescaling[1];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ break;
+ case 3:
+ if (self->direction[j] == 0) {
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
+ if (self->pointerPos[j] < self->minfadepoint[j]) {
+ fpart = (self->pointerPos[j] - self->loopstart[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else if (self->pointerPos[j] > self->maxfadepoint[j]) {
+ fpart = (self->loopend[j] - self->pointerPos[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else
+ amp = 1.0;
+ ipart = (int)self->pointerPos[j];
+ fpart = self->pointerPos[j] - ipart;
+ self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
+ }
+ self->pointerPos[j] += pit;
+ if (self->pointerPos[j] < 0.0)
+ self->pointerPos[j] = 0.0;
+ else if (self->pointerPos[j] > self->maxfadepoint[j] && self->active[1-j] == 0)
+ Looper_reset(self, i, 1-j, 0);
+ if (self->pointerPos[j] >= self->loopend[j])
+ self->active[j] = 0;
}
- else if (self->pointerPos[1] < self->maxfadepoint[1]) {
- fpart = (self->pointerPos[1] - self->loopend[1]) * self->crossfadescaling[1];
- ipart = (int)fpart;
- fpart = fpart - ipart;
- amp = self->fader[ipart] + (self->fader[ipart+1] - self->fader[ipart]) * fpart;
+ else {
+ if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
+ if (self->pointerPos[j] > self->minfadepoint[j]) {
+ fpart = (self->loopstart[j] - self->pointerPos[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else if (self->pointerPos[j] < self->maxfadepoint[j]) {
+ fpart = (self->pointerPos[j] - self->loopend[j]) * self->crossfadescaling[j];
+ amp = Looper_get_amp(self, fpart);
+ }
+ else
+ amp = 1.0;
+ ipart = (int)self->pointerPos[j];
+ fpart = self->pointerPos[j] - ipart;
+ self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
+ }
+ self->pointerPos[j] -= pit;
+ if (self->pointerPos[j] >= size)
+ self->pointerPos[j] = size-1;
+ else if (self->pointerPos[j] < self->maxfadepoint[j] && self->active[1-j] == 0)
+ Looper_reset(self, i, 1-j, 0);
+ if (self->pointerPos[j] <= self->loopend[j])
+ self->active[j] = 0;
}
- else
- amp = 1.0;
- ipart = (int)self->pointerPos[1];
- fpart = self->pointerPos[1] - ipart;
- self->data[i] += (*self->interp_func_ptr)(tablelist, ipart, fpart, size) * amp;
- }
- self->pointerPos[1] -= pit;
- if (self->pointerPos[1] >= size)
- self->pointerPos[1] = size-1;
- else if (self->pointerPos[1] < self->maxfadepoint[1] && self->active[0] == 0)
- Looper_reset(self, i, 0, 0);
- else if (self->pointerPos[1] <= self->loopend[1])
- self->active[1] = 0;
- }
+ break;
+ } // end of switch
}
- break;
+ }
}
+
/* Automatic smoothering of low transposition */
if (self->autosmooth == 1) {
for (i=0; i<self->bufsize; i++) {
- pit = pitch[i];
- if (pit < 0.0)
- pit = 0.0;
- if (pit < 1.0 && pit > 0.0) {
- if (self->lastpitch != pit) {
- self->lastpitch = pit;
- fr = pit * tableSr * 0.45;
- b = 2.0 - MYCOS(TWOPI * fr / self->sr);
- self->c2 = (b - MYSQRT(b * b - 1.0));
- self->c1 = 1.0 - self->c2;
- }
- for (i=0; i<self->bufsize; i++) {
- self->y1 = self->c1 * self->data[i] + self->c2 * self->y1;
- self->y2 = self->c1 * self->y1 + self->c2 * self->y2;
- self->data[i] = self->y2;
+ pitval = pitch[i];
+ if (pitval < 0.001)
+ pitval = 0.001;
+ if (pitval < 1.0) {
+ if (self->lastpitch != pitval) {
+ self->lastpitch = pitval;
+ fr = pitval * self->sr * 0.45;
+ self->c1 = MYEXP(-TWOPI * fr / self->sr);
}
+ self->y1 = self->data[i] + (self->y1 - self->data[i]) * self->c1;
+ self->y2 = self->y1 + (self->y2 - self->y1) * self->c1;
+ self->data[i] = self->y2;
}
}
}
@@ -1741,50 +1636,50 @@ Looper_setProcMode(Looper *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Looper_transform_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Looper_transform_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Looper_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Looper_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Looper_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Looper_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Looper_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Looper_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Looper_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Looper_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Looper_postprocessing_revareva;
break;
- }
+ }
}
static void
Looper_compute_next_data_frame(Looper *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1793,30 +1688,30 @@ Looper_traverse(Looper *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->pitch);
- Py_VISIT(self->pitch_stream);
- Py_VISIT(self->start);
- Py_VISIT(self->start_stream);
- Py_VISIT(self->dur);
- Py_VISIT(self->dur_stream);
- Py_VISIT(self->xfade);
- Py_VISIT(self->xfade_stream);
+ Py_VISIT(self->pitch);
+ Py_VISIT(self->pitch_stream);
+ Py_VISIT(self->start);
+ Py_VISIT(self->start_stream);
+ Py_VISIT(self->dur);
+ Py_VISIT(self->dur_stream);
+ Py_VISIT(self->xfade);
+ Py_VISIT(self->xfade_stream);
return 0;
}
-static int
+static int
Looper_clear(Looper *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->pitch);
- Py_CLEAR(self->pitch_stream);
- Py_CLEAR(self->start);
- Py_CLEAR(self->start_stream);
- Py_CLEAR(self->dur);
- Py_CLEAR(self->dur_stream);
- Py_CLEAR(self->xfade);
- Py_CLEAR(self->xfade_stream);
+ Py_CLEAR(self->pitch);
+ Py_CLEAR(self->pitch_stream);
+ Py_CLEAR(self->start);
+ Py_CLEAR(self->start_stream);
+ Py_CLEAR(self->dur);
+ Py_CLEAR(self->dur_stream);
+ Py_CLEAR(self->xfade);
+ Py_CLEAR(self->xfade_stream);
return 0;
}
@@ -1835,19 +1730,20 @@ Looper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *pitchtmp=NULL, *starttmp=NULL, *durtmp=NULL, *xfadetmp=NULL, *multmp=NULL, *addtmp=NULL;
Looper *self;
self = (Looper *)type->tp_alloc(type, 0);
-
+
self->pitch = PyFloat_FromDouble(1.0);
self->start = PyFloat_FromDouble(0.0);
self->dur = PyFloat_FromDouble(1.0);
self->xfade = PyFloat_FromDouble(20.0);
self->lastpitch = -1.0;
self->autosmooth = 0;
- self->y1 = self->y2 = 0.0;
+ self->y1 = self->y2 = self->c1 = 0.0;
self->xfadeshape = 0;
self->startfromloop = 0;
self->interp = 2;
self->init = 1;
- self->mode = self->tmpmode = 1;
+ self->mode[0] = self->mode[1] = self->tmpmode = 1;
+ self->direction[0] = self->direction[1] = 0;
self->pointerPos[0] = self->pointerPos[1] = 0.0;
self->active[0] = self->active[1] = 0;
self->modebuffer[0] = 0;
@@ -1855,22 +1751,19 @@ Looper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Looper_compute_next_data_frame);
self->mode_func_ptr = Looper_setProcMode;
static char *kwlist[] = {"table", "pitch", "start", "dur", "xfade", "mode", "xfadeshape", "startfromloop", "interp", "autosmooth", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOiiiiiOO", kwlist, &tabletmp, &pitchtmp, &starttmp, &durtmp, &xfadetmp, &self->tmpmode, &self->xfadeshape, &self->startfromloop, &self->interp, &self->autosmooth, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of Looper must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Looper must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
@@ -1878,11 +1771,11 @@ Looper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (pitchtmp) {
PyObject_CallMethod((PyObject *)self, "setPitch", "O", pitchtmp);
}
-
+
if (starttmp) {
PyObject_CallMethod((PyObject *)self, "setStart", "O", starttmp);
}
-
+
if (durtmp) {
PyObject_CallMethod((PyObject *)self, "setDur", "O", durtmp);
}
@@ -1890,35 +1783,35 @@ Looper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (xfadetmp) {
PyObject_CallMethod((PyObject *)self, "setXfade", "O", xfadetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
if (self->tmpmode >= 0 && self->tmpmode < 4)
- self->mode = self->tmpmode;
+ self->mode[0] = self->mode[1] = self->tmpmode;
else
- self->mode = self->tmpmode = 1;
+ self->mode[0] = self->mode[1] = self->tmpmode = 1;
SET_INTERP_POINTER
-
+
return (PyObject *)self;
}
static PyObject * Looper_getServer(Looper* self) { GET_SERVER };
static PyObject * Looper_getStream(Looper* self) { GET_STREAM };
-static PyObject * Looper_setMul(Looper *self, PyObject *arg) { SET_MUL };
-static PyObject * Looper_setAdd(Looper *self, PyObject *arg) { SET_ADD };
-static PyObject * Looper_setSub(Looper *self, PyObject *arg) { SET_SUB };
-static PyObject * Looper_setDiv(Looper *self, PyObject *arg) { SET_DIV };
+static PyObject * Looper_setMul(Looper *self, PyObject *arg) { SET_MUL };
+static PyObject * Looper_setAdd(Looper *self, PyObject *arg) { SET_ADD };
+static PyObject * Looper_setSub(Looper *self, PyObject *arg) { SET_SUB };
+static PyObject * Looper_setDiv(Looper *self, PyObject *arg) { SET_DIV };
static PyObject * Looper_play(Looper *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Looper_out(Looper *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1937,14 +1830,14 @@ static PyObject *
Looper_setPitch(Looper *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pitch);
@@ -1960,25 +1853,25 @@ Looper_setPitch(Looper *self, PyObject *arg)
self->pitch_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Looper_setStart(Looper *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->start);
@@ -1997,20 +1890,20 @@ Looper_setStart(Looper *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Looper_setDur(Looper *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->dur);
@@ -2035,14 +1928,14 @@ static PyObject *
Looper_setXfade(Looper *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->xfade);
@@ -2074,19 +1967,19 @@ static PyObject *
Looper_setTable(Looper *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Looper_setStartFromLoop(Looper *self, PyObject *arg)
@@ -2095,13 +1988,13 @@ Looper_setStartFromLoop(Looper *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->startfromloop = PyInt_AsLong(arg);
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2113,12 +2006,12 @@ Looper_setXfadeShape(Looper *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->xfadeshape = PyInt_AsLong(arg);
- }
+ }
Py_INCREF(Py_None);
return Py_None;
@@ -2132,15 +2025,15 @@ Looper_setMode(Looper *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 4)
self->tmpmode = tmp;
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2152,15 +2045,15 @@ Looper_setInterp(Looper *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
SET_INTERP_POINTER
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2172,17 +2065,25 @@ Looper_setAutoSmooth(Looper *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
self->autosmooth = PyInt_AsLong(arg);
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
+static PyObject *
+Looper_on_reset(Looper *self) {
+ self->pointerPos[0] = self->pointerPos[1] = 0.0;
+ self->active[0] = self->active[1] = 0;
+ Py_INCREF(Py_None);
+ return Py_None;
+};
+
static PyMemberDef Looper_members[] = {
{"server", T_OBJECT_EX, offsetof(Looper, server), 0, "Pyo server."},
{"stream", T_OBJECT_EX, offsetof(Looper, stream), 0, "Stream object."},
@@ -2213,6 +2114,7 @@ static PyMethodDef Looper_methods[] = {
{"setStartFromLoop", (PyCFunction)Looper_setStartFromLoop, METH_O, "Sets init pointer position."},
{"setInterp", (PyCFunction)Looper_setInterp, METH_O, "Sets oscillator interpolation mode."},
{"setAutoSmooth", (PyCFunction)Looper_setAutoSmooth, METH_O, "Activate lowpass filter for transposition below 1."},
+ {"reset", (PyCFunction)Looper_on_reset, METH_NOARGS, "Resets internal counters."},
{"setMul", (PyCFunction)Looper_setMul, METH_O, "Sets granulator mul factor."},
{"setAdd", (PyCFunction)Looper_setAdd, METH_O, "Sets granulator add factor."},
{"setSub", (PyCFunction)Looper_setSub, METH_O, "Sets inverse add factor."},
@@ -2304,7 +2206,7 @@ PyTypeObject LooperType = {
Looper_new, /* tp_new */
};
-static const MYFLT Granule_MAX_GRAINS = 1024;
+static const MYFLT Granule_MAX_GRAINS = 4096;
typedef struct {
pyo_audio_HEAD
PyObject *table;
@@ -2323,38 +2225,45 @@ typedef struct {
MYFLT *phase;
int *flags;
int num;
+ int sync;
double timer;
MYFLT oneOnSr;
+ MYFLT srOnRandMax;
int modebuffer[6];
} Granule;
static void
Granule_transform_i(Granule *self) {
MYFLT dens, inc, index, amp, phase;
- int i, j, ipart;
- int flag = 0;
- MYFLT pit = 0, pos = 0, dur = 0;
-
+ int i, j, ipart, flag = 0;
+ MYFLT pit = 0, pos = 0, dur = 0;
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *envlist = TableStream_getData(self->env);
int envsize = TableStream_getSize(self->env);
-
+
dens = PyFloat_AS_DOUBLE(self->dens);
if (dens < 0.0)
- dens = -dens;
-
+ dens = 0.0;
+
inc = dens * self->oneOnSr;
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
- /* clocker */
- self->timer += inc;
- if (self->timer >= 1.0) {
- self->timer -= 1.0;
- flag = 1;
+ if (self->sync == 1) {
+ /* synchronous */
+ self->timer += inc;
+ if (self->timer >= 1.0) {
+ self->timer -= 1.0;
+ flag = 1;
+ }
+ } else {
+ /* asynchronous */
+ if ((rand() * self->srOnRandMax) < dens)
+ flag = 1;
}
/* need to start a new grain */
@@ -2376,10 +2285,14 @@ Granule_transform_i(Granule *self) {
dur = PyFloat_AS_DOUBLE(self->dur);
else
dur = Stream_getData((Stream *)self->dur_stream)[i];
+ if (pit < 0.0)
+ pit = -pit;
if (pos < 0.0)
pos = 0.0;
else if (pos >= size)
pos = (MYFLT)size;
+ if (dur < 0.0001)
+ dur = 0.0001;
self->gpos[j] = pos;
self->glen[j] = dur * self->sr * pit;
if ((pos + self->glen[j]) >= size || (pos + self->glen[j]) < 0)
@@ -2395,39 +2308,34 @@ Granule_transform_i(Granule *self) {
for (j=0; j<self->num; j++) {
if (self->flags[j]) {
phase = self->phase[j];
- if (phase >= 0.0 && phase < 1.0) {
- // compute envelope
- index = phase * envsize;
- ipart = (int)index;
- amp = envlist[ipart] + (envlist[ipart+1] - envlist[ipart]) * (index - ipart);
-
- // compute sampling
- index = phase * self->glen[j] + self->gpos[j];
- ipart = (int)index;
- self->data[i] += (tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * (index - ipart)) * amp;
-
- phase += self->inc[j];
- if (phase >= 1.0)
- self->flags[j] = 0;
- else
- self->phase[j] = phase;
- }
+ /* compute envelope */
+ index = phase * envsize;
+ ipart = (int)index;
+ amp = envlist[ipart] + (envlist[ipart+1] - envlist[ipart]) * (index - ipart);
+ /* compute sampling */
+ index = phase * self->glen[j] + self->gpos[j];
+ ipart = (int)index;
+ self->data[i] += (tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * (index - ipart)) * amp;
+ phase += self->inc[j];
+ if (phase >= 1.0)
+ self->flags[j] = 0;
+ else
+ self->phase[j] = phase;
}
}
flag = 0;
- }
+ }
}
static void
Granule_transform_a(Granule *self) {
MYFLT index, amp, phase;
- int i, j, ipart;
- int flag = 0;
- MYFLT pit = 0, pos = 0, dur = 0;
-
+ int i, j, ipart, flag = 0;
+ MYFLT pit = 0, pos = 0, dur = 0;
+
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *envlist = TableStream_getData(self->env);
int envsize = TableStream_getSize(self->env);
@@ -2436,11 +2344,17 @@ Granule_transform_a(Granule *self) {
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
- /* clocker */
- self->timer += density[i] * self->oneOnSr;
- if (self->timer >= 1.0) {
- self->timer -= 1.0;
- flag = 1;
+ if (self->sync == 1) {
+ /* synchronous */
+ self->timer += density[i] * self->oneOnSr;
+ if (self->timer >= 1.0) {
+ self->timer -= 1.0;
+ flag = 1;
+ }
+ } else {
+ /* asynchronous */
+ if ((rand() * self->srOnRandMax) < density[i])
+ flag = 1;
}
/* need to start a new grain */
@@ -2462,10 +2376,14 @@ Granule_transform_a(Granule *self) {
dur = PyFloat_AS_DOUBLE(self->dur);
else
dur = Stream_getData((Stream *)self->dur_stream)[i];
+ if (pit < 0.0)
+ pit = -pit;
if (pos < 0.0)
pos = 0.0;
else if (pos >= size)
pos = (MYFLT)size;
+ if (dur < 0.0001)
+ dur = 0.0001;
self->gpos[j] = pos;
self->glen[j] = dur * self->sr * pit;
if ((pos + self->glen[j]) >= size || (pos + self->glen[j]) < 0)
@@ -2481,27 +2399,23 @@ Granule_transform_a(Granule *self) {
for (j=0; j<self->num; j++) {
if (self->flags[j]) {
phase = self->phase[j];
- if (phase >= 0.0 && phase < 1.0) {
- // compute envelope
- index = phase * envsize;
- ipart = (int)index;
- amp = envlist[ipart] + (envlist[ipart+1] - envlist[ipart]) * (index - ipart);
-
- // compute sampling
- index = phase * self->glen[j] + self->gpos[j];
- ipart = (int)index;
- self->data[i] += (tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * (index - ipart)) * amp;
-
- phase += self->inc[j];
- if (phase >= 1.0)
- self->flags[j] = 0;
- else
- self->phase[j] = phase;
- }
+ // compute envelope
+ index = phase * envsize;
+ ipart = (int)index;
+ amp = envlist[ipart] + (envlist[ipart+1] - envlist[ipart]) * (index - ipart);
+ // compute sampling
+ index = phase * self->glen[j] + self->gpos[j];
+ ipart = (int)index;
+ self->data[i] += (tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * (index - ipart)) * amp;
+ phase += self->inc[j];
+ if (phase >= 1.0)
+ self->flags[j] = 0;
+ else
+ self->phase[j] = phase;
}
}
flag = 0;
- }
+ }
}
static void Granule_postprocessing_ii(Granule *self) { POST_PROCESSING_II };
@@ -2522,48 +2436,48 @@ Granule_setProcMode(Granule *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Granule_transform_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Granule_transform_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Granule_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Granule_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Granule_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Granule_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Granule_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Granule_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Granule_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Granule_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Granule_postprocessing_revareva;
break;
- }
+ }
}
static void
Granule_compute_next_data_frame(Granule *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2573,31 +2487,31 @@ Granule_traverse(Granule *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->table);
Py_VISIT(self->env);
- Py_VISIT(self->dens);
- Py_VISIT(self->dens_stream);
- Py_VISIT(self->pitch);
- Py_VISIT(self->pitch_stream);
- Py_VISIT(self->pos);
- Py_VISIT(self->pos_stream);
- Py_VISIT(self->dur);
- Py_VISIT(self->dur_stream);
+ Py_VISIT(self->dens);
+ Py_VISIT(self->dens_stream);
+ Py_VISIT(self->pitch);
+ Py_VISIT(self->pitch_stream);
+ Py_VISIT(self->pos);
+ Py_VISIT(self->pos_stream);
+ Py_VISIT(self->dur);
+ Py_VISIT(self->dur_stream);
return 0;
}
-static int
+static int
Granule_clear(Granule *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
Py_CLEAR(self->env);
- Py_CLEAR(self->dens);
- Py_CLEAR(self->dens_stream);
- Py_CLEAR(self->pitch);
- Py_CLEAR(self->pitch_stream);
- Py_CLEAR(self->pos);
- Py_CLEAR(self->pos_stream);
- Py_CLEAR(self->dur);
- Py_CLEAR(self->dur_stream);
+ Py_CLEAR(self->dens);
+ Py_CLEAR(self->dens_stream);
+ Py_CLEAR(self->pitch);
+ Py_CLEAR(self->pitch_stream);
+ Py_CLEAR(self->pos);
+ Py_CLEAR(self->pos_stream);
+ Py_CLEAR(self->dur);
+ Py_CLEAR(self->dur_stream);
return 0;
}
@@ -2605,7 +2519,7 @@ static void
Granule_dealloc(Granule* self)
{
pyo_DEALLOC
- free(self->gpos);
+ free(self->gpos);
free(self->glen);
free(self->inc);
free(self->flags);
@@ -2628,6 +2542,7 @@ Granule_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->dur = PyFloat_FromDouble(0.1);
self->timer = 1.0;
self->num = 0;
+ self->sync = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
@@ -2636,8 +2551,9 @@ Granule_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[5] = 0;
INIT_OBJECT_COMMON
-
+
self->oneOnSr = 1.0 / self->sr;
+ self->srOnRandMax = self->sr / (MYFLT)RAND_MAX;
Stream_setFunctionPtr(self->stream, Granule_compute_next_data_frame);
self->mode_func_ptr = Granule_setProcMode;
@@ -2648,21 +2564,15 @@ Granule_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of Granule must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Granule must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
if ( PyObject_HasAttrString((PyObject *)envtmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"env\" argument of Granule must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"env\" argument of Granule must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->env);
self->env = PyObject_CallMethod((PyObject *)envtmp, "getTableStream", "");
@@ -2670,7 +2580,7 @@ Granule_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (denstmp) {
PyObject_CallMethod((PyObject *)self, "setDens", "O", denstmp);
}
-
+
if (pitchtmp) {
PyObject_CallMethod((PyObject *)self, "setPitch", "O", pitchtmp);
}
@@ -2682,7 +2592,7 @@ Granule_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (durtmp) {
PyObject_CallMethod((PyObject *)self, "setDur", "O", durtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -2690,7 +2600,7 @@ Granule_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->gpos = (MYFLT *)realloc(self->gpos, Granule_MAX_GRAINS * sizeof(MYFLT));
@@ -2698,23 +2608,25 @@ Granule_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->inc = (MYFLT *)realloc(self->inc, Granule_MAX_GRAINS * sizeof(MYFLT));
self->phase = (MYFLT *)realloc(self->phase, Granule_MAX_GRAINS * sizeof(MYFLT));
self->flags = (int *)realloc(self->flags, Granule_MAX_GRAINS * sizeof(int));
-
+
for (i=0; i<Granule_MAX_GRAINS; i++) {
self->gpos[i] = self->glen[i] = self->inc[i] = self->phase[i] = 0.0;
self->flags[i] = 0;
}
-
+
+ Server_generateSeed((Server *)self->server, GRANULE_ID);
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Granule_getServer(Granule* self) { GET_SERVER };
static PyObject * Granule_getStream(Granule* self) { GET_STREAM };
-static PyObject * Granule_setMul(Granule *self, PyObject *arg) { SET_MUL };
-static PyObject * Granule_setAdd(Granule *self, PyObject *arg) { SET_ADD };
-static PyObject * Granule_setSub(Granule *self, PyObject *arg) { SET_SUB };
-static PyObject * Granule_setDiv(Granule *self, PyObject *arg) { SET_DIV };
+static PyObject * Granule_setMul(Granule *self, PyObject *arg) { SET_MUL };
+static PyObject * Granule_setAdd(Granule *self, PyObject *arg) { SET_ADD };
+static PyObject * Granule_setSub(Granule *self, PyObject *arg) { SET_SUB };
+static PyObject * Granule_setDiv(Granule *self, PyObject *arg) { SET_DIV };
static PyObject * Granule_play(Granule *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Granule_out(Granule *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2733,14 +2645,14 @@ static PyObject *
Granule_setDens(Granule *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->dens);
@@ -2756,25 +2668,25 @@ Granule_setDens(Granule *self, PyObject *arg)
self->dens_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Granule_setPitch(Granule *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pitch);
@@ -2793,20 +2705,20 @@ Granule_setPitch(Granule *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Granule_setPos(Granule *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pos);
@@ -2825,20 +2737,20 @@ Granule_setPos(Granule *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Granule_setDur(Granule *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->dur);
@@ -2870,19 +2782,19 @@ static PyObject *
Granule_setTable(Granule *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Granule_getEnv(Granule* self)
@@ -2895,19 +2807,34 @@ static PyObject *
Granule_setEnv(Granule *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->env);
self->env = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+Granule_setSync(Granule *self, PyObject *arg)
+{
+ if (PyLong_Check(arg) || PyInt_Check(arg)) {
+ self->sync = PyLong_AsLong(arg);
+ if (self->sync <= 0)
+ self->sync = 0;
+ else
+ self->sync = 1;
+ }
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Granule_members[] = {
{"server", T_OBJECT_EX, offsetof(Granule, server), 0, "Pyo server."},
@@ -2937,6 +2864,7 @@ static PyMethodDef Granule_methods[] = {
{"setPitch", (PyCFunction)Granule_setPitch, METH_O, "Sets global pitch factor."},
{"setPos", (PyCFunction)Granule_setPos, METH_O, "Sets position in the sound table."},
{"setDur", (PyCFunction)Granule_setDur, METH_O, "Sets the grain duration."},
+ {"setSync", (PyCFunction)Granule_setSync, METH_O, "Sets the granulator mode: synchronous or asynchronous."},
{"setMul", (PyCFunction)Granule_setMul, METH_O, "Sets Granule mul factor."},
{"setAdd", (PyCFunction)Granule_setAdd, METH_O, "Sets Granule add factor."},
{"setSub", (PyCFunction)Granule_setSub, METH_O, "Sets inverse add factor."},
@@ -3028,3 +2956,1289 @@ PyTypeObject GranuleType = {
Granule_new, /* tp_new */
};
+static const MYFLT MAINPARTICLE_MAX_GRAINS = 4096;
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *table;
+ PyObject *env;
+ PyObject *dens;
+ Stream *dens_stream;
+ PyObject *pitch;
+ Stream *pitch_stream;
+ PyObject *pos;
+ Stream *pos_stream;
+ PyObject *dur;
+ Stream *dur_stream;
+ PyObject *dev;
+ Stream *dev_stream;
+ PyObject *pan;
+ Stream *pan_stream;
+ MYFLT *gpos;
+ MYFLT *glen;
+ MYFLT *inc;
+ MYFLT *phase;
+ MYFLT *amp1;
+ MYFLT *amp2;
+ int *flags;
+ int *k1;
+ int *k2;
+ int num;
+ int chnls;
+ double timer;
+ double devFactor;
+ double srScale;
+ MYFLT oneOnSr;
+ MYFLT srOnRandMax;
+ MYFLT *buffer_streams;
+ int modebuffer[6];
+} MainParticle;
+
+static void
+MainParticle_transform_mono_i(MainParticle *self) {
+ MYFLT dens, inc, index, amp, phase, val;
+ int i, j, ipart, flag = 0;
+ MYFLT pit = 0, pos = 0, dur = 0, dev = 0;
+
+ MYFLT *tablelist = TableStream_getData(self->table);
+ int size = TableStream_getSize(self->table);
+
+ MYFLT *envlist = TableStream_getData(self->env);
+ int envsize = TableStream_getSize(self->env);
+
+ dens = PyFloat_AS_DOUBLE(self->dens);
+ if (dens < 0.0)
+ dens = 0.0;
+
+ inc = dens * self->oneOnSr * self->devFactor;
+
+ for (i=0; i<self->bufsize*self->chnls; i++) {
+ self->buffer_streams[i] = 0.0;
+ }
+
+ for (i=0; i<self->bufsize; i++) {
+ self->timer += inc;
+ if (self->timer >= 1.0) {
+ self->timer -= 1.0;
+ flag = 1;
+ }
+
+ /* need to start a new grain */
+ if (flag) {
+ for (j=0; j<MAINPARTICLE_MAX_GRAINS; j++) {
+ if (self->flags[j] == 0) {
+ self->flags[j] = 1;
+ if (j >= self->num)
+ self->num = j + 1;
+ if (self->modebuffer[1] == 0)
+ pit = PyFloat_AS_DOUBLE(self->pitch);
+ else
+ pit = Stream_getData((Stream *)self->pitch_stream)[i];
+ if (self->modebuffer[2] == 0)
+ pos = PyFloat_AS_DOUBLE(self->pos);
+ else
+ pos = Stream_getData((Stream *)self->pos_stream)[i];
+ if (self->modebuffer[3] == 0)
+ dur = PyFloat_AS_DOUBLE(self->dur);
+ else
+ dur = Stream_getData((Stream *)self->dur_stream)[i];
+ if (self->modebuffer[4] == 0)
+ dev = PyFloat_AS_DOUBLE(self->dev);
+ else
+ dev = Stream_getData((Stream *)self->dev_stream)[i];
+ if (pit < 0.0)
+ pit = -pit;
+ if (pos < 0.0)
+ pos = 0.0;
+ else if (pos >= size)
+ pos = (MYFLT)size;
+ if (dur < 0.0001)
+ dur = 0.0001;
+ if (dev < 0.0)
+ dev = 0.0;
+ else if (dev > 1.0)
+ dev = 1.0;
+ self->gpos[j] = pos;
+ self->glen[j] = dur * self->sr * pit * self->srScale;
+ if ((pos + self->glen[j]) >= size || (pos + self->glen[j]) < 0)
+ self->flags[j] = 0;
+ self->phase[j] = 0.0;
+ self->inc[j] = 1.0 / (dur * self->sr);
+ self->devFactor = (rand() / (MYFLT)RAND_MAX * 2.0 - 1.0) * dev + 1.0;
+ break;
+ }
+ }
+ }
+
+ /* compute active grains */
+ for (j=0; j<self->num; j++) {
+ if (self->flags[j]) {
+ phase = self->phase[j];
+ /* compute envelope */
+ index = phase * envsize;
+ ipart = (int)index;
+ amp = envlist[ipart] + (envlist[ipart+1] - envlist[ipart]) * (index - ipart);
+ /* compute sampling */
+ index = phase * self->glen[j] + self->gpos[j];
+ ipart = (int)index;
+ val = (tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * (index - ipart)) * amp;
+ self->buffer_streams[i] += val;
+ phase += self->inc[j];
+ if (phase >= 1.0)
+ self->flags[j] = 0;
+ else
+ self->phase[j] = phase;
+ }
+ }
+ flag = 0;
+ }
+}
+
+static void
+MainParticle_transform_mono_a(MainParticle *self) {
+ MYFLT dens, index, amp, phase, val;
+ int i, j, ipart, flag = 0;
+ MYFLT pit = 0, pos = 0, dur = 0, dev = 0;
+
+ MYFLT *tablelist = TableStream_getData(self->table);
+ int size = TableStream_getSize(self->table);
+
+ MYFLT *envlist = TableStream_getData(self->env);
+ int envsize = TableStream_getSize(self->env);
+
+ MYFLT *density = Stream_getData((Stream *)self->dens_stream);
+
+ for (i=0; i<self->bufsize*self->chnls; i++) {
+ self->buffer_streams[i] = 0.0;
+ }
+
+ for (i=0; i<self->bufsize; i++) {
+ if (density[i] < 0.0)
+ dens = 0.0;
+ else
+ dens = density[i];
+ self->timer += dens * self->oneOnSr * self->devFactor;
+ if (self->timer >= 1.0) {
+ self->timer -= 1.0;
+ flag = 1;
+ }
+
+ /* need to start a new grain */
+ if (flag) {
+ for (j=0; j<MAINPARTICLE_MAX_GRAINS; j++) {
+ if (self->flags[j] == 0) {
+ self->flags[j] = 1;
+ if (j >= self->num)
+ self->num = j + 1;
+ if (self->modebuffer[1] == 0)
+ pit = PyFloat_AS_DOUBLE(self->pitch);
+ else
+ pit = Stream_getData((Stream *)self->pitch_stream)[i];
+ if (self->modebuffer[2] == 0)
+ pos = PyFloat_AS_DOUBLE(self->pos);
+ else
+ pos = Stream_getData((Stream *)self->pos_stream)[i];
+ if (self->modebuffer[3] == 0)
+ dur = PyFloat_AS_DOUBLE(self->dur);
+ else
+ dur = Stream_getData((Stream *)self->dur_stream)[i];
+ if (self->modebuffer[4] == 0)
+ dev = PyFloat_AS_DOUBLE(self->dev);
+ else
+ dev = Stream_getData((Stream *)self->dev_stream)[i];
+ if (pit < 0.0)
+ pit = -pit;
+ if (pos < 0.0)
+ pos = 0.0;
+ else if (pos >= size)
+ pos = (MYFLT)size;
+ if (dur < 0.0001)
+ dur = 0.0001;
+ if (dev < 0.0)
+ dev = 0.0;
+ else if (dev > 1.0)
+ dev = 1.0;
+ self->gpos[j] = pos;
+ self->glen[j] = dur * self->sr * pit * self->srScale;
+ if ((pos + self->glen[j]) >= size || (pos + self->glen[j]) < 0)
+ self->flags[j] = 0;
+ self->phase[j] = 0.0;
+ self->inc[j] = 1.0 / (dur * self->sr);
+ self->devFactor = (rand() / (MYFLT)RAND_MAX * 2.0 - 1.0) * dev + 1.0;
+ break;
+ }
+ }
+ }
+
+ /* compute active grains */
+ for (j=0; j<self->num; j++) {
+ if (self->flags[j]) {
+ phase = self->phase[j];
+ /* compute envelope */
+ index = phase * envsize;
+ ipart = (int)index;
+ amp = envlist[ipart] + (envlist[ipart+1] - envlist[ipart]) * (index - ipart);
+ /* compute sampling */
+ index = phase * self->glen[j] + self->gpos[j];
+ ipart = (int)index;
+ val = (tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * (index - ipart)) * amp;
+ self->buffer_streams[i] += val;
+ phase += self->inc[j];
+ if (phase >= 1.0)
+ self->flags[j] = 0;
+ else
+ self->phase[j] = phase;
+ }
+ }
+ flag = 0;
+ }
+}
+
+static void
+MainParticle_transform_i(MainParticle *self) {
+ MYFLT dens, inc, index, amp, phase, val, min = 0;
+ int i, j, l, l1, ipart, flag = 0;
+ MYFLT pit = 0, pos = 0, dur = 0, dev = 0, pan = 0;
+
+ MYFLT *tablelist = TableStream_getData(self->table);
+ int size = TableStream_getSize(self->table);
+
+ MYFLT *envlist = TableStream_getData(self->env);
+ int envsize = TableStream_getSize(self->env);
+
+ dens = PyFloat_AS_DOUBLE(self->dens);
+ if (dens < 0.0)
+ dens = 0.0;
+
+ inc = dens * self->oneOnSr * self->devFactor;
+
+ for (i=0; i<self->bufsize*self->chnls; i++) {
+ self->buffer_streams[i] = 0.0;
+ }
+
+ for (i=0; i<self->bufsize; i++) {
+ self->timer += inc;
+ if (self->timer >= 1.0) {
+ self->timer -= 1.0;
+ flag = 1;
+ }
+
+ /* need to start a new grain */
+ if (flag) {
+ for (j=0; j<MAINPARTICLE_MAX_GRAINS; j++) {
+ if (self->flags[j] == 0) {
+ self->flags[j] = 1;
+ if (j >= self->num)
+ self->num = j + 1;
+ if (self->modebuffer[1] == 0)
+ pit = PyFloat_AS_DOUBLE(self->pitch);
+ else
+ pit = Stream_getData((Stream *)self->pitch_stream)[i];
+ if (self->modebuffer[2] == 0)
+ pos = PyFloat_AS_DOUBLE(self->pos);
+ else
+ pos = Stream_getData((Stream *)self->pos_stream)[i];
+ if (self->modebuffer[3] == 0)
+ dur = PyFloat_AS_DOUBLE(self->dur);
+ else
+ dur = Stream_getData((Stream *)self->dur_stream)[i];
+ if (self->modebuffer[4] == 0)
+ dev = PyFloat_AS_DOUBLE(self->dev);
+ else
+ dev = Stream_getData((Stream *)self->dev_stream)[i];
+ if (self->modebuffer[5] == 0)
+ pan = PyFloat_AS_DOUBLE(self->pan);
+ else
+ pan = Stream_getData((Stream *)self->pan_stream)[i];
+ if (pit < 0.0)
+ pit = -pit;
+ if (pos < 0.0)
+ pos = 0.0;
+ else if (pos >= size)
+ pos = (MYFLT)size;
+ if (dur < 0.0001)
+ dur = 0.0001;
+ if (dev < 0.0)
+ dev = 0.0;
+ else if (dev > 1.0)
+ dev = 1.0;
+ if (pan < 0.0)
+ pan = 0.0;
+ else if (pan > 1.0)
+ pan = 1.0;
+ self->gpos[j] = pos;
+ self->glen[j] = dur * self->sr * pit * self->srScale;
+ if ((pos + self->glen[j]) >= size || (pos + self->glen[j]) < 0)
+ self->flags[j] = 0;
+ self->phase[j] = 0.0;
+ self->inc[j] = 1.0 / (dur * self->sr);
+ self->devFactor = (rand() / (MYFLT)RAND_MAX * 2.0 - 1.0) * dev + 1.0;
+ if (self->chnls == 2) {
+ self->k1[j] = 0;
+ self->k2[j] = self->bufsize;
+ self->amp1[j] = MYSQRT(1.0 - pan);
+ self->amp2[j] = MYSQRT(pan);
+ }
+ else {
+ self->amp1[j] = MYSQRT(1.0 - pan);
+ self->amp2[j] = MYSQRT(pan);
+ min = 0;
+ self->k1[j] = 0;
+ self->k2[j] = self->bufsize;
+ for (l=self->chnls; l>0; l--) {
+ l1 = l - 1;
+ min = l1 / (MYFLT)self->chnls;
+ if (pan > min) {
+ self->k1[j] = l1 * self->bufsize;
+ if (l == self->chnls)
+ self->k2[j] = 0;
+ else
+ self->k2[j] = l * self->bufsize;
+ break;
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /* compute active grains */
+ for (j=0; j<self->num; j++) {
+ if (self->flags[j]) {
+ phase = self->phase[j];
+ /* compute envelope */
+ index = phase * envsize;
+ ipart = (int)index;
+ amp = envlist[ipart] + (envlist[ipart+1] - envlist[ipart]) * (index - ipart);
+ /* compute sampling */
+ index = phase * self->glen[j] + self->gpos[j];
+ ipart = (int)index;
+ val = (tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * (index - ipart)) * amp;
+ self->buffer_streams[i+self->k1[j]] += val * self->amp1[j];
+ self->buffer_streams[i+self->k2[j]] += val * self->amp2[j];
+ phase += self->inc[j];
+ if (phase >= 1.0)
+ self->flags[j] = 0;
+ else
+ self->phase[j] = phase;
+ }
+ }
+ flag = 0;
+ }
+}
+
+static void
+MainParticle_transform_a(MainParticle *self) {
+ MYFLT dens, index, amp, phase, val, min = 0;
+ int i, j, l, l1, ipart, flag = 0;
+ MYFLT pit = 0, pos = 0, dur = 0, dev = 0, pan = 0;
+
+ MYFLT *tablelist = TableStream_getData(self->table);
+ int size = TableStream_getSize(self->table);
+
+ MYFLT *envlist = TableStream_getData(self->env);
+ int envsize = TableStream_getSize(self->env);
+
+ MYFLT *density = Stream_getData((Stream *)self->dens_stream);
+
+ for (i=0; i<self->bufsize*self->chnls; i++) {
+ self->buffer_streams[i] = 0.0;
+ }
+
+ for (i=0; i<self->bufsize; i++) {
+ if (density[i] < 0.0)
+ dens = 0.0;
+ else
+ dens = density[i];
+ self->timer += dens * self->oneOnSr * self->devFactor;
+ if (self->timer >= 1.0) {
+ self->timer -= 1.0;
+ flag = 1;
+ }
+
+ /* need to start a new grain */
+ if (flag) {
+ for (j=0; j<MAINPARTICLE_MAX_GRAINS; j++) {
+ if (self->flags[j] == 0) {
+ self->flags[j] = 1;
+ if (j >= self->num)
+ self->num = j + 1;
+ if (self->modebuffer[1] == 0)
+ pit = PyFloat_AS_DOUBLE(self->pitch);
+ else
+ pit = Stream_getData((Stream *)self->pitch_stream)[i];
+ if (self->modebuffer[2] == 0)
+ pos = PyFloat_AS_DOUBLE(self->pos);
+ else
+ pos = Stream_getData((Stream *)self->pos_stream)[i];
+ if (self->modebuffer[3] == 0)
+ dur = PyFloat_AS_DOUBLE(self->dur);
+ else
+ dur = Stream_getData((Stream *)self->dur_stream)[i];
+ if (self->modebuffer[4] == 0)
+ dev = PyFloat_AS_DOUBLE(self->dev);
+ else
+ dev = Stream_getData((Stream *)self->dev_stream)[i];
+ if (self->modebuffer[5] == 0)
+ pan = PyFloat_AS_DOUBLE(self->pan);
+ else
+ pan = Stream_getData((Stream *)self->pan_stream)[i];
+ if (pit < 0.0)
+ pit = -pit;
+ if (pos < 0.0)
+ pos = 0.0;
+ else if (pos >= size)
+ pos = (MYFLT)size;
+ if (dur < 0.0001)
+ dur = 0.0001;
+ if (dev < 0.0)
+ dev = 0.0;
+ else if (dev > 1.0)
+ dev = 1.0;
+ if (pan < 0.0)
+ pan = 0.0;
+ else if (pan > 1.0)
+ pan = 1.0;
+ self->gpos[j] = pos;
+ self->glen[j] = dur * self->sr * pit * self->srScale;
+ if ((pos + self->glen[j]) >= size || (pos + self->glen[j]) < 0)
+ self->flags[j] = 0;
+ self->phase[j] = 0.0;
+ self->inc[j] = 1.0 / (dur * self->sr);
+ self->devFactor = (rand() / (MYFLT)RAND_MAX * 2.0 - 1.0) * dev + 1.0;
+ if (self->chnls == 2) {
+ self->k1[j] = 0;
+ self->k2[j] = self->bufsize;
+ self->amp1[j] = MYSQRT(1.0 - pan);
+ self->amp2[j] = MYSQRT(pan);
+ }
+ else {
+ self->amp1[j] = MYSQRT(1.0 - pan);
+ self->amp2[j] = MYSQRT(pan);
+ min = 0;
+ self->k1[j] = 0;
+ self->k2[j] = self->bufsize;
+ for (l=self->chnls; l>0; l--) {
+ l1 = l - 1;
+ min = l1 / (MYFLT)self->chnls;
+ if (pan > min) {
+ self->k1[j] = l1 * self->bufsize;
+ if (l == self->chnls)
+ self->k2[j] = 0;
+ else
+ self->k2[j] = l * self->bufsize;
+ break;
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /* compute active grains */
+ for (j=0; j<self->num; j++) {
+ if (self->flags[j]) {
+ phase = self->phase[j];
+ /* compute envelope */
+ index = phase * envsize;
+ ipart = (int)index;
+ amp = envlist[ipart] + (envlist[ipart+1] - envlist[ipart]) * (index - ipart);
+ /* compute sampling */
+ index = phase * self->glen[j] + self->gpos[j];
+ ipart = (int)index;
+ val = (tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * (index - ipart)) * amp;
+ self->buffer_streams[i+self->k1[j]] += val * self->amp1[j];
+ self->buffer_streams[i+self->k2[j]] += val * self->amp2[j];
+ phase += self->inc[j];
+ if (phase >= 1.0)
+ self->flags[j] = 0;
+ else
+ self->phase[j] = phase;
+ }
+ }
+ flag = 0;
+ }
+}
+
+static void
+MainParticle_setProcMode(MainParticle *self)
+{
+ int procmode = self->modebuffer[0];
+
+ switch (procmode) {
+ case 0:
+ if (self->chnls == 1)
+ self->proc_func_ptr = MainParticle_transform_mono_i;
+ else
+ self->proc_func_ptr = MainParticle_transform_i;
+ break;
+ case 1:
+ if (self->chnls == 1)
+ self->proc_func_ptr = MainParticle_transform_mono_a;
+ else
+ self->proc_func_ptr = MainParticle_transform_a;
+ break;
+ }
+}
+
+static void
+MainParticle_compute_next_data_frame(MainParticle *self)
+{
+ (*self->proc_func_ptr)(self);
+}
+
+static int
+MainParticle_traverse(MainParticle *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->table);
+ Py_VISIT(self->env);
+ Py_VISIT(self->dens);
+ Py_VISIT(self->dens_stream);
+ Py_VISIT(self->pitch);
+ Py_VISIT(self->pitch_stream);
+ Py_VISIT(self->pos);
+ Py_VISIT(self->pos_stream);
+ Py_VISIT(self->dur);
+ Py_VISIT(self->dur_stream);
+ Py_VISIT(self->dev);
+ Py_VISIT(self->dev_stream);
+ Py_VISIT(self->pan);
+ Py_VISIT(self->pan_stream);
+ return 0;
+}
+
+static int
+MainParticle_clear(MainParticle *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->table);
+ Py_CLEAR(self->env);
+ Py_CLEAR(self->dens);
+ Py_CLEAR(self->dens_stream);
+ Py_CLEAR(self->pitch);
+ Py_CLEAR(self->pitch_stream);
+ Py_CLEAR(self->pos);
+ Py_CLEAR(self->pos_stream);
+ Py_CLEAR(self->dur);
+ Py_CLEAR(self->dur_stream);
+ Py_CLEAR(self->dev);
+ Py_CLEAR(self->dev_stream);
+ Py_CLEAR(self->pan);
+ Py_CLEAR(self->pan_stream);
+ return 0;
+}
+
+static void
+MainParticle_dealloc(MainParticle* self)
+{
+ pyo_DEALLOC
+ free(self->gpos);
+ free(self->glen);
+ free(self->inc);
+ free(self->flags);
+ free(self->k1);
+ free(self->k2);
+ free(self->phase);
+ free(self->amp1);
+ free(self->amp2);
+ free(self->buffer_streams);
+ MainParticle_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+MYFLT *
+MainParticle_getSamplesBuffer(MainParticle *self)
+{
+ return (MYFLT *)self->buffer_streams;
+}
+
+static PyObject *
+MainParticle_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *tabletmp, *envtmp, *denstmp=NULL, *pitchtmp=NULL, *postmp=NULL, *durtmp=NULL, *devtmp=NULL, *pantmp=NULL;
+ MainParticle *self;
+ self = (MainParticle *)type->tp_alloc(type, 0);
+
+ self->dens = PyFloat_FromDouble(50);
+ self->pitch = PyFloat_FromDouble(1);
+ self->pos = PyFloat_FromDouble(0.0);
+ self->dur = PyFloat_FromDouble(0.1);
+ self->dev = PyFloat_FromDouble(0);
+ self->pan = PyFloat_FromDouble(0.5);
+ self->timer = self->devFactor = 1.0;
+ self->srScale = 1.0;
+ self->num = 0;
+ self->chnls = 1;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+ self->modebuffer[2] = 0;
+ self->modebuffer[3] = 0;
+ self->modebuffer[4] = 0;
+ self->modebuffer[5] = 0;
+
+ INIT_OBJECT_COMMON
+
+ self->oneOnSr = 1.0 / self->sr;
+ self->srOnRandMax = self->sr / (MYFLT)RAND_MAX;
+
+ Stream_setFunctionPtr(self->stream, MainParticle_compute_next_data_frame);
+ self->mode_func_ptr = MainParticle_setProcMode;
+
+ static char *kwlist[] = {"table", "env", "dens", "pitch", "pos", "dur", "dev", "pan", "chnls", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOOOOOi", kwlist, &tabletmp, &envtmp, &denstmp, &pitchtmp, &postmp, &durtmp, &devtmp, &pantmp, &self->chnls))
+ Py_RETURN_NONE;
+
+ if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of MainParticle must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
+ }
+ Py_XDECREF(self->table);
+ self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
+ self->srScale = TableStream_getSamplingRate(self->table) / self->sr;
+
+ if ( PyObject_HasAttrString((PyObject *)envtmp, "getTableStream") == 0 ) {
+ PyErr_SetString(PyExc_TypeError, "\"env\" argument of MainParticle must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
+ }
+ Py_XDECREF(self->env);
+ self->env = PyObject_CallMethod((PyObject *)envtmp, "getTableStream", "");
+
+ if (denstmp) {
+ PyObject_CallMethod((PyObject *)self, "setDens", "O", denstmp);
+ }
+
+ if (pitchtmp) {
+ PyObject_CallMethod((PyObject *)self, "setPitch", "O", pitchtmp);
+ }
+
+ if (postmp) {
+ PyObject_CallMethod((PyObject *)self, "setPos", "O", postmp);
+ }
+
+ if (durtmp) {
+ PyObject_CallMethod((PyObject *)self, "setDur", "O", durtmp);
+ }
+
+ if (devtmp) {
+ PyObject_CallMethod((PyObject *)self, "setDev", "O", devtmp);
+ }
+
+ if (pantmp) {
+ PyObject_CallMethod((PyObject *)self, "setPan", "O", pantmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ if (self->chnls < 1)
+ self->chnls = 1;
+
+ self->gpos = (MYFLT *)realloc(self->gpos, MAINPARTICLE_MAX_GRAINS * sizeof(MYFLT));
+ self->glen = (MYFLT *)realloc(self->glen, MAINPARTICLE_MAX_GRAINS * sizeof(MYFLT));
+ self->inc = (MYFLT *)realloc(self->inc, MAINPARTICLE_MAX_GRAINS * sizeof(MYFLT));
+ self->phase = (MYFLT *)realloc(self->phase, MAINPARTICLE_MAX_GRAINS * sizeof(MYFLT));
+ self->amp1 = (MYFLT *)realloc(self->amp1, MAINPARTICLE_MAX_GRAINS * sizeof(MYFLT));
+ self->amp2 = (MYFLT *)realloc(self->amp2, MAINPARTICLE_MAX_GRAINS * sizeof(MYFLT));
+ self->flags = (int *)realloc(self->flags, MAINPARTICLE_MAX_GRAINS * sizeof(int));
+ self->k1 = (int *)realloc(self->k1, MAINPARTICLE_MAX_GRAINS * sizeof(int));
+ self->k2 = (int *)realloc(self->k2, MAINPARTICLE_MAX_GRAINS * sizeof(int));
+
+ for (i=0; i<MAINPARTICLE_MAX_GRAINS; i++) {
+ self->gpos[i] = self->glen[i] = self->inc[i] = self->phase[i] = self->amp1[i] = self->amp2[i] = 0.0;
+ self->flags[i] = self->k1[i] = self->k2[i] = 0;
+ }
+
+ self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->bufsize * self->chnls * sizeof(MYFLT));
+ for (i=0; i<self->bufsize*self->chnls; i++) {
+ self->buffer_streams[i] = 0.0;
+ }
+
+ Server_generateSeed((Server *)self->server, MAINPARTICLE_ID);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * MainParticle_getServer(MainParticle* self) { GET_SERVER };
+static PyObject * MainParticle_getStream(MainParticle* self) { GET_STREAM };
+
+static PyObject * MainParticle_play(MainParticle *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * MainParticle_stop(MainParticle *self) { STOP };
+
+static PyObject *
+MainParticle_setDens(MainParticle *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->dens);
+ if (isNumber == 1) {
+ self->dens = PyNumber_Float(tmp);
+ self->modebuffer[0] = 0;
+ }
+ else {
+ self->dens = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->dens, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->dens_stream);
+ self->dens_stream = (Stream *)streamtmp;
+ self->modebuffer[0] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+MainParticle_setPitch(MainParticle *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->pitch);
+ if (isNumber == 1) {
+ self->pitch = PyNumber_Float(tmp);
+ self->modebuffer[1] = 0;
+ }
+ else {
+ self->pitch = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->pitch, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->pitch_stream);
+ self->pitch_stream = (Stream *)streamtmp;
+ self->modebuffer[1] = 1;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+MainParticle_setPos(MainParticle *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->pos);
+ if (isNumber == 1) {
+ self->pos = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->pos = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->pos, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->pos_stream);
+ self->pos_stream = (Stream *)streamtmp;
+ self->modebuffer[2] = 1;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+MainParticle_setDur(MainParticle *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->dur);
+ if (isNumber == 1) {
+ self->dur = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->dur = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->dur, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->dur_stream);
+ self->dur_stream = (Stream *)streamtmp;
+ self->modebuffer[3] = 1;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+MainParticle_setDev(MainParticle *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->dev);
+ if (isNumber == 1) {
+ self->dev = PyNumber_Float(tmp);
+ self->modebuffer[4] = 0;
+ }
+ else {
+ self->dev = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->dev, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->dev_stream);
+ self->dev_stream = (Stream *)streamtmp;
+ self->modebuffer[4] = 1;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+MainParticle_setPan(MainParticle *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->pan);
+ if (isNumber == 1) {
+ self->pan = PyNumber_Float(tmp);
+ self->modebuffer[5] = 0;
+ }
+ else {
+ self->pan = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->pan, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->pan_stream);
+ self->pan_stream = (Stream *)streamtmp;
+ self->modebuffer[5] = 1;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+MainParticle_getTable(MainParticle* self)
+{
+ Py_INCREF(self->table);
+ return self->table;
+};
+
+static PyObject *
+MainParticle_setTable(MainParticle *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ tmp = arg;
+ Py_DECREF(self->table);
+ self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
+ self->srScale = TableStream_getSamplingRate(self->table) / self->sr;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+MainParticle_getEnv(MainParticle* self)
+{
+ Py_INCREF(self->env);
+ return self->env;
+};
+
+static PyObject *
+MainParticle_setEnv(MainParticle *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ tmp = arg;
+ Py_DECREF(self->env);
+ self->env = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef MainParticle_members[] = {
+ {"server", T_OBJECT_EX, offsetof(MainParticle, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(MainParticle, stream), 0, "Stream object."},
+ {"table", T_OBJECT_EX, offsetof(MainParticle, table), 0, "Sound table."},
+ {"env", T_OBJECT_EX, offsetof(MainParticle, env), 0, "Envelope table."},
+ {"dens", T_OBJECT_EX, offsetof(MainParticle, dens), 0, "Density of grains per second."},
+ {"pitch", T_OBJECT_EX, offsetof(MainParticle, pitch), 0, "Speed of the reading pointer."},
+ {"pos", T_OBJECT_EX, offsetof(MainParticle, pos), 0, "Position in the sound table."},
+ {"dur", T_OBJECT_EX, offsetof(MainParticle, dur), 0, "Duration of each grains."},
+ {"dev", T_OBJECT_EX, offsetof(MainParticle, dev), 0, "Grain start point deviation factor."},
+ {"pan", T_OBJECT_EX, offsetof(MainParticle, pan), 0, "Grain panning factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef MainParticle_methods[] = {
+ {"getTable", (PyCFunction)MainParticle_getTable, METH_NOARGS, "Returns sound table object."},
+ {"setTable", (PyCFunction)MainParticle_setTable, METH_O, "Sets sound table."},
+ {"getEnv", (PyCFunction)MainParticle_getEnv, METH_NOARGS, "Returns envelope table object."},
+ {"setEnv", (PyCFunction)MainParticle_setEnv, METH_O, "Sets envelope table."},
+ {"getServer", (PyCFunction)MainParticle_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)MainParticle_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)MainParticle_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"stop", (PyCFunction)MainParticle_stop, METH_NOARGS, "Stops computing."},
+ {"setDens", (PyCFunction)MainParticle_setDens, METH_O, "Sets the density of grains per second."},
+ {"setPitch", (PyCFunction)MainParticle_setPitch, METH_O, "Sets global pitch factor."},
+ {"setPos", (PyCFunction)MainParticle_setPos, METH_O, "Sets position in the sound table."},
+ {"setDur", (PyCFunction)MainParticle_setDur, METH_O, "Sets the grain duration."},
+ {"setDev", (PyCFunction)MainParticle_setDev, METH_O, "Sets grain start point deviation factor."},
+ {"setPan", (PyCFunction)MainParticle_setPan, METH_O, "Sets grain panning factor."},
+ {NULL} /* Sentinel */
+};
+
+PyTypeObject MainParticleType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_pitch*/
+ "_pyo.MainParticle_base", /*tp_name*/
+ sizeof(MainParticle), /*tp_basicpitch*/
+ 0, /*tp_itempitch*/
+ (destructor)MainParticle_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "MainParticle objects. Accumulation of multiples grains of sound.", /* tp_doc */
+ (traverseproc)MainParticle_traverse, /* tp_traverse */
+ (inquiry)MainParticle_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ MainParticle_methods, /* tp_methods */
+ MainParticle_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ MainParticle_new, /* tp_new */
+};
+
+typedef struct {
+ pyo_audio_HEAD
+ MainParticle *mainSplitter;
+ int modebuffer[2];
+ int chnl; // panning order
+} Particle;
+
+static void Particle_postprocessing_ii(Particle *self) { POST_PROCESSING_II };
+static void Particle_postprocessing_ai(Particle *self) { POST_PROCESSING_AI };
+static void Particle_postprocessing_ia(Particle *self) { POST_PROCESSING_IA };
+static void Particle_postprocessing_aa(Particle *self) { POST_PROCESSING_AA };
+static void Particle_postprocessing_ireva(Particle *self) { POST_PROCESSING_IREVA };
+static void Particle_postprocessing_areva(Particle *self) { POST_PROCESSING_AREVA };
+static void Particle_postprocessing_revai(Particle *self) { POST_PROCESSING_REVAI };
+static void Particle_postprocessing_revaa(Particle *self) { POST_PROCESSING_REVAA };
+static void Particle_postprocessing_revareva(Particle *self) { POST_PROCESSING_REVAREVA };
+
+static void
+Particle_setProcMode(Particle *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = Particle_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = Particle_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = Particle_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = Particle_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = Particle_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = Particle_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = Particle_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = Particle_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = Particle_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+Particle_compute_next_data_frame(Particle *self)
+{
+ int i;
+ MYFLT *tmp;
+ int offset = self->chnl * self->bufsize;
+ tmp = MainParticle_getSamplesBuffer((MainParticle *)self->mainSplitter);
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = tmp[i + offset];
+ }
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+Particle_traverse(Particle *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->mainSplitter);
+ return 0;
+}
+
+static int
+Particle_clear(Particle *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->mainSplitter);
+ return 0;
+}
+
+static void
+Particle_dealloc(Particle* self)
+{
+ pyo_DEALLOC
+ Particle_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+Particle_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
+ Particle *self;
+ self = (Particle *)type->tp_alloc(type, 0);
+
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, Particle_compute_next_data_frame);
+ self->mode_func_ptr = Particle_setProcMode;
+
+ static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ Py_XDECREF(self->mainSplitter);
+ Py_INCREF(maintmp);
+ self->mainSplitter = (MainParticle *)maintmp;
+
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ }
+
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * Particle_getServer(Particle* self) { GET_SERVER };
+static PyObject * Particle_getStream(Particle* self) { GET_STREAM };
+static PyObject * Particle_setMul(Particle *self, PyObject *arg) { SET_MUL };
+static PyObject * Particle_setAdd(Particle *self, PyObject *arg) { SET_ADD };
+static PyObject * Particle_setSub(Particle *self, PyObject *arg) { SET_SUB };
+static PyObject * Particle_setDiv(Particle *self, PyObject *arg) { SET_DIV };
+
+static PyObject * Particle_play(Particle *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Particle_out(Particle *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Particle_stop(Particle *self) { STOP };
+
+static PyObject * Particle_multiply(Particle *self, PyObject *arg) { MULTIPLY };
+static PyObject * Particle_inplace_multiply(Particle *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Particle_add(Particle *self, PyObject *arg) { ADD };
+static PyObject * Particle_inplace_add(Particle *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Particle_sub(Particle *self, PyObject *arg) { SUB };
+static PyObject * Particle_inplace_sub(Particle *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Particle_div(Particle *self, PyObject *arg) { DIV };
+static PyObject * Particle_inplace_div(Particle *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef Particle_members[] = {
+{"server", T_OBJECT_EX, offsetof(Particle, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(Particle, stream), 0, "Stream object."},
+{"mul", T_OBJECT_EX, offsetof(Particle, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(Particle, add), 0, "Add factor."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef Particle_methods[] = {
+{"getServer", (PyCFunction)Particle_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)Particle_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)Particle_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)Particle_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)Particle_stop, METH_NOARGS, "Stops computing."},
+{"setMul", (PyCFunction)Particle_setMul, METH_O, "Sets Particle mul factor."},
+{"setAdd", (PyCFunction)Particle_setAdd, METH_O, "Sets Particle add factor."},
+{"setSub", (PyCFunction)Particle_setSub, METH_O, "Sets inverse add factor."},
+{"setDiv", (PyCFunction)Particle_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
+};
+
+static PyNumberMethods Particle_as_number = {
+(binaryfunc)Particle_add, /*nb_add*/
+(binaryfunc)Particle_sub, /*nb_subtract*/
+(binaryfunc)Particle_multiply, /*nb_multiply*/
+(binaryfunc)Particle_div, /*nb_divide*/
+0, /*nb_remainder*/
+0, /*nb_divmod*/
+0, /*nb_power*/
+0, /*nb_neg*/
+0, /*nb_pos*/
+0, /*(unaryfunc)array_abs,*/
+0, /*nb_nonzero*/
+0, /*nb_invert*/
+0, /*nb_lshift*/
+0, /*nb_rshift*/
+0, /*nb_and*/
+0, /*nb_xor*/
+0, /*nb_or*/
+0, /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+0, /*nb_oct*/
+0, /*nb_hex*/
+(binaryfunc)Particle_inplace_add, /*inplace_add*/
+(binaryfunc)Particle_inplace_sub, /*inplace_subtract*/
+(binaryfunc)Particle_inplace_multiply, /*inplace_multiply*/
+(binaryfunc)Particle_inplace_div, /*inplace_divide*/
+0, /*inplace_remainder*/
+0, /*inplace_power*/
+0, /*inplace_lshift*/
+0, /*inplace_rshift*/
+0, /*inplace_and*/
+0, /*inplace_xor*/
+0, /*inplace_or*/
+0, /*nb_floor_divide*/
+0, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+0, /*nb_inplace_true_divide*/
+0, /* nb_index */
+};
+
+PyTypeObject ParticleType = {
+PyObject_HEAD_INIT(NULL)
+0, /*ob_size*/
+"_pyo.Particle_base", /*tp_name*/
+sizeof(Particle), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)Particle_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_compare*/
+0, /*tp_repr*/
+&Particle_as_number, /*tp_as_number*/
+0, /*tp_as_sequence*/
+0, /*tp_as_mapping*/
+0, /*tp_hash */
+0, /*tp_call*/
+0, /*tp_str*/
+0, /*tp_getattro*/
+0, /*tp_setattro*/
+0, /*tp_as_buffer*/
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+"Particle objects. Reads one band from a MainParticle object.", /* tp_doc */
+(traverseproc)Particle_traverse, /* tp_traverse */
+(inquiry)Particle_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+Particle_methods, /* tp_methods */
+Particle_members, /* tp_members */
+0, /* tp_getset */
+0, /* tp_base */
+0, /* tp_dict */
+0, /* tp_descr_get */
+0, /* tp_descr_set */
+0, /* tp_dictoffset */
+0, /* tp_init */
+0, /* tp_alloc */
+Particle_new, /* tp_new */
+};
\ No newline at end of file
diff --git a/src/objects/harmonizermodule.c b/src/objects/harmonizermodule.c
index 2bc85e4..94f3c6f 100644
--- a/src/objects/harmonizermodule.c
+++ b/src/objects/harmonizermodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -47,7 +47,7 @@ static void
Harmonizer_transform_ii(Harmonizer *self) {
MYFLT val, amp, inc, ratio, rate, del, xind, pos, envpos, fpart;
int i, ipart;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT trans = PyFloat_AS_DOUBLE(self->transpo);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
@@ -55,11 +55,11 @@ Harmonizer_transform_ii(Harmonizer *self) {
feed = 0.0;
else if (feed > 1.0)
feed = 1.0;
-
+
ratio = MYPOW(2.0, trans/12.0);
- rate = (ratio-1.0) / self->winsize;
+ rate = (ratio-1.0) / self->winsize;
inc = -rate / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
/* first overlap */
pos = self->pointerPos;
@@ -67,7 +67,7 @@ Harmonizer_transform_ii(Harmonizer *self) {
ipart = (int)envpos;
fpart = envpos - ipart;
amp = ENVELOPE[ipart] + (ENVELOPE[ipart+1] - ENVELOPE[ipart]) * fpart;
-
+
del = pos * self->winsize;
xind = self->in_count - (del * self->sr);
if (xind < 0)
@@ -85,7 +85,7 @@ Harmonizer_transform_ii(Harmonizer *self) {
ipart = (int)envpos;
fpart = envpos - ipart;
amp = ENVELOPE[ipart] + (ENVELOPE[ipart+1] - ENVELOPE[ipart]) * fpart;
-
+
del = pos * self->winsize;
xind = self->in_count - (del * self->sr);
if (xind < 0)
@@ -94,27 +94,27 @@ Harmonizer_transform_ii(Harmonizer *self) {
fpart = xind - ipart;
val = self->buffer[ipart] + (self->buffer[ipart+1] - self->buffer[ipart]) * fpart;
self->data[i] += (val * amp);
-
+
self->pointerPos += inc;
if (self->pointerPos < 0.0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1.0)
self->pointerPos -= 1.0;
-
+
self->buffer[self->in_count] = in[i] + (self->data[i] * feed);
if (self->in_count == 0)
self->buffer[(int)self->sr] = self->buffer[0];
self->in_count++;
if (self->in_count >= self->sr)
self->in_count = 0;
- }
+ }
}
static void
Harmonizer_transform_ai(Harmonizer *self) {
MYFLT val, amp, inc, ratio, rate, del, xind, pos, envpos, fpart;
int i, ipart;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *trans = Stream_getData((Stream *)self->transpo_stream);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
@@ -122,21 +122,21 @@ Harmonizer_transform_ai(Harmonizer *self) {
feed = 0.0;
else if (feed > 1.0)
feed = 1.0;
-
+
MYFLT oneOnWinsize = 1.0 / self->winsize;
MYFLT oneOnSr = 1.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
ratio = MYPOW(2.0, trans[i]/12.0);
- rate = (ratio-1.0) * oneOnWinsize;
+ rate = (ratio-1.0) * oneOnWinsize;
inc = -rate * oneOnSr;;
-
+
/* first overlap */
pos = self->pointerPos;
envpos = pos * 8192.0;
ipart = (int)envpos;
fpart = envpos - ipart;
amp = ENVELOPE[ipart] + (ENVELOPE[ipart+1] - ENVELOPE[ipart]) * fpart;
-
+
del = pos * self->winsize;
xind = self->in_count - (del * self->sr);
if (xind < 0)
@@ -145,7 +145,7 @@ Harmonizer_transform_ai(Harmonizer *self) {
fpart = xind - ipart;
val = self->buffer[ipart] + (self->buffer[ipart+1] - self->buffer[ipart]) * fpart;
self->data[i] = val * amp;
-
+
/* second overlap */
pos = self->pointerPos + 0.5;
if (pos >= 1)
@@ -154,7 +154,7 @@ Harmonizer_transform_ai(Harmonizer *self) {
ipart = (int)envpos;
fpart = envpos - ipart;
amp = ENVELOPE[ipart] + (ENVELOPE[ipart+1] - ENVELOPE[ipart]) * fpart;
-
+
del = pos * self->winsize;
xind = self->in_count - (del * self->sr);
if (xind < 0)
@@ -163,35 +163,35 @@ Harmonizer_transform_ai(Harmonizer *self) {
fpart = xind - ipart;
val = self->buffer[ipart] + (self->buffer[ipart+1] - self->buffer[ipart]) * fpart;
self->data[i] += (val * amp);
-
+
self->pointerPos += inc;
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
-
+
self->buffer[self->in_count] = in[i] + (self->data[i] * feed);
if (self->in_count == 0)
self->buffer[(int)self->sr] = self->buffer[0];
self->in_count++;
if (self->in_count >= self->sr)
self->in_count = 0;
- }
+ }
}
static void
Harmonizer_transform_ia(Harmonizer *self) {
MYFLT val, amp, inc, ratio, rate, del, xind, pos, envpos, fpart, feedback;
int i, ipart;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT trans = PyFloat_AS_DOUBLE(self->transpo);
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
-
+
ratio = MYPOW(2.0, trans/12.0);
- rate = (ratio-1.0) / self->winsize;
+ rate = (ratio-1.0) / self->winsize;
inc = -rate / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
if (feed[i] < 0.0)
feedback = 0.0;
@@ -206,7 +206,7 @@ Harmonizer_transform_ia(Harmonizer *self) {
ipart = (int)envpos;
fpart = envpos - ipart;
amp = ENVELOPE[ipart] + (ENVELOPE[ipart+1] - ENVELOPE[ipart]) * fpart;
-
+
del = pos * self->winsize;
xind = self->in_count - (del * self->sr);
if (xind < 0)
@@ -215,7 +215,7 @@ Harmonizer_transform_ia(Harmonizer *self) {
fpart = xind - ipart;
val = self->buffer[ipart] + (self->buffer[ipart+1] - self->buffer[ipart]) * fpart;
self->data[i] = val * amp;
-
+
/* second overlap */
pos = self->pointerPos + 0.5;
if (pos > 1)
@@ -224,7 +224,7 @@ Harmonizer_transform_ia(Harmonizer *self) {
ipart = (int)envpos;
fpart = envpos - ipart;
amp = ENVELOPE[ipart] + (ENVELOPE[ipart+1] - ENVELOPE[ipart]) * fpart;
-
+
del = pos * self->winsize;
xind = self->in_count - (del * self->sr);
if (xind < 0)
@@ -233,38 +233,38 @@ Harmonizer_transform_ia(Harmonizer *self) {
fpart = xind - ipart;
val = self->buffer[ipart] + (self->buffer[ipart+1] - self->buffer[ipart]) * fpart;
self->data[i] += (val * amp);
-
+
self->pointerPos += inc;
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
-
+
self->buffer[self->in_count] = in[i] + (self->data[i] * feedback);
if (self->in_count == 0)
self->buffer[(int)self->sr] = self->buffer[0];
self->in_count++;
if (self->in_count >= self->sr)
self->in_count = 0;
- }
+ }
}
static void
Harmonizer_transform_aa(Harmonizer *self) {
MYFLT val, amp, inc, ratio, rate, del, xind, pos, envpos, fpart, feedback;
int i, ipart;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *trans = Stream_getData((Stream *)self->transpo_stream);
MYFLT *feed = Stream_getData((Stream *)self->feedback_stream);
-
+
MYFLT oneOnWinsize = 1.0 / self->winsize;
MYFLT oneOnSr = 1.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
ratio = MYPOW(2.0, trans[i]/12.0);
- rate = (ratio-1.0) * oneOnWinsize;
+ rate = (ratio-1.0) * oneOnWinsize;
inc = -rate * oneOnSr;;
-
+
if (feed[i] < 0.0)
feedback = 0.0;
else if (feed[i] > 1.0)
@@ -278,7 +278,7 @@ Harmonizer_transform_aa(Harmonizer *self) {
ipart = (int)envpos;
fpart = envpos - ipart;
amp = ENVELOPE[ipart] + (ENVELOPE[ipart+1] - ENVELOPE[ipart]) * fpart;
-
+
del = pos * self->winsize;
xind = self->in_count - (del * self->sr);
if (xind < 0)
@@ -287,7 +287,7 @@ Harmonizer_transform_aa(Harmonizer *self) {
fpart = xind - ipart;
val = self->buffer[ipart] + (self->buffer[ipart+1] - self->buffer[ipart]) * fpart;
self->data[i] = val * amp;
-
+
/* second overlap */
pos = self->pointerPos + 0.5;
if (pos > 1)
@@ -296,7 +296,7 @@ Harmonizer_transform_aa(Harmonizer *self) {
ipart = (int)envpos;
fpart = envpos - ipart;
amp = ENVELOPE[ipart] + (ENVELOPE[ipart+1] - ENVELOPE[ipart]) * fpart;
-
+
del = pos * self->winsize;
xind = self->in_count - (del * self->sr);
if (xind < 0)
@@ -305,13 +305,13 @@ Harmonizer_transform_aa(Harmonizer *self) {
fpart = xind - ipart;
val = self->buffer[ipart] + (self->buffer[ipart+1] - self->buffer[ipart]) * fpart;
self->data[i] += (val * amp);
-
+
self->pointerPos += inc;
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
-
+
self->buffer[self->in_count] = in[i] + (self->data[i] * feedback);
if (self->in_count == 0)
self->buffer[(int)self->sr] = self->buffer[0];
@@ -319,7 +319,7 @@ Harmonizer_transform_aa(Harmonizer *self) {
if (self->in_count >= self->sr)
self->in_count = 0;
}
-}
+}
static void Harmonizer_feedbacktprocessing_ii(Harmonizer *self) { POST_PROCESSING_II };
static void Harmonizer_feedbacktprocessing_ai(Harmonizer *self) { POST_PROCESSING_AI };
@@ -339,54 +339,54 @@ Harmonizer_setProcMode(Harmonizer *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Harmonizer_transform_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Harmonizer_transform_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Harmonizer_transform_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Harmonizer_transform_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Harmonizer_feedbacktprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Harmonizer_feedbacktprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Harmonizer_feedbacktprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Harmonizer_feedbacktprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Harmonizer_feedbacktprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Harmonizer_feedbacktprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Harmonizer_feedbacktprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Harmonizer_feedbacktprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Harmonizer_feedbacktprocessing_revareva;
break;
- }
+ }
}
static void
Harmonizer_compute_next_data_frame(Harmonizer *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -396,23 +396,23 @@ Harmonizer_traverse(Harmonizer *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->transpo);
- Py_VISIT(self->transpo_stream);
- Py_VISIT(self->feedback);
- Py_VISIT(self->feedback_stream);
+ Py_VISIT(self->transpo);
+ Py_VISIT(self->transpo_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
return 0;
}
-static int
+static int
Harmonizer_clear(Harmonizer *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->transpo);
- Py_CLEAR(self->transpo_stream);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
+ Py_CLEAR(self->transpo);
+ Py_CLEAR(self->transpo_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
return 0;
}
@@ -470,14 +470,14 @@ Harmonizer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->buffer = (MYFLT *)realloc(self->buffer, (self->sr+1) * sizeof(MYFLT));
for (i=0; i<(self->sr+1); i++) {
self->buffer[i] = 0.;
- }
-
+ }
+
if (wintmp > 0.0 && wintmp <= 1.0)
self->winsize = wintmp;
else
@@ -490,10 +490,10 @@ Harmonizer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Harmonizer_getServer(Harmonizer* self) { GET_SERVER };
static PyObject * Harmonizer_getStream(Harmonizer* self) { GET_STREAM };
-static PyObject * Harmonizer_setMul(Harmonizer *self, PyObject *arg) { SET_MUL };
-static PyObject * Harmonizer_setAdd(Harmonizer *self, PyObject *arg) { SET_ADD };
-static PyObject * Harmonizer_setSub(Harmonizer *self, PyObject *arg) { SET_SUB };
-static PyObject * Harmonizer_setDiv(Harmonizer *self, PyObject *arg) { SET_DIV };
+static PyObject * Harmonizer_setMul(Harmonizer *self, PyObject *arg) { SET_MUL };
+static PyObject * Harmonizer_setAdd(Harmonizer *self, PyObject *arg) { SET_ADD };
+static PyObject * Harmonizer_setSub(Harmonizer *self, PyObject *arg) { SET_SUB };
+static PyObject * Harmonizer_setDiv(Harmonizer *self, PyObject *arg) { SET_DIV };
static PyObject * Harmonizer_play(Harmonizer *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Harmonizer_out(Harmonizer *self, PyObject *args, PyObject *kwds) { OUT };
@@ -512,14 +512,14 @@ static PyObject *
Harmonizer_setTranspo(Harmonizer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->transpo);
@@ -535,25 +535,25 @@ Harmonizer_setTranspo(Harmonizer *self, PyObject *arg)
self->transpo_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Harmonizer_setFeedback(Harmonizer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->feedback);
@@ -569,12 +569,12 @@ Harmonizer_setFeedback(Harmonizer *self, PyObject *arg)
self->feedback_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Harmonizer_setWinsize(Harmonizer *self, PyObject *arg)
@@ -587,7 +587,7 @@ Harmonizer_setWinsize(Harmonizer *self, PyObject *arg)
else
printf("winsize lower than 0.0 or larger than 1.0 second!\n");
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -702,4 +702,3 @@ PyTypeObject HarmonizerType = {
0, /* tp_alloc */
Harmonizer_new, /* tp_new */
};
-
diff --git a/src/objects/hilbertmodule.c b/src/objects/hilbertmodule.c
index 5c860e7..639bff1 100644
--- a/src/objects/hilbertmodule.c
+++ b/src/objects/hilbertmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -38,23 +38,23 @@ typedef struct {
} HilbertMain;
/* 6th order allpass poles */
-static const MYFLT poles[12] = {.3609, 2.7412, 11.1573, 44.7581, 179.6242, 798.4578,
+static const MYFLT poles[12] = {.3609, 2.7412, 11.1573, 44.7581, 179.6242, 798.4578,
1.2524, 5.5671, 22.3423, 89.6271, 364.7914, 2770.1114};
static void
HilbertMain_compute_variables(HilbertMain *self)
-{
+{
int i;
MYFLT polefreq[12];
MYFLT rc[12];
MYFLT alpha[12];
-
+
for (i=0; i<12; i++) {
polefreq[i] = poles[i] * 15.0;
rc[i] = 1.0 / (TWOPI * polefreq[i]);
alpha[i] = 1.0 / rc[i];
self->coefs[i] = - (1.0 - (alpha[i] / (2.0 * self->sr))) / (1.0 + (alpha[i] / (2.0 * self->sr)));
- }
+ }
}
static void
@@ -62,7 +62,7 @@ HilbertMain_filters(HilbertMain *self) {
MYFLT xn1, xn2, yn1, yn2;
int j, i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
xn1 = in[i];
for (j=0; j<6; j++) {
@@ -75,32 +75,32 @@ HilbertMain_filters(HilbertMain *self) {
xn2 = in[i];
for (j=6; j<12; j++) {
yn2 = self->coefs[j] * (xn2 - self->y1[j]) + self->x1[j];
- self->x1[j] = xn1;
- self->y1[j] = yn1;
+ self->x1[j] = xn2;
+ self->y1[j] = yn2;
xn2 = yn2;
}
self->buffer_streams[i] = yn1;
self->buffer_streams[i+self->bufsize] = yn2;
-
- }
+
+ }
}
MYFLT *
HilbertMain_getSamplesBuffer(HilbertMain *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
HilbertMain_setProcMode(HilbertMain *self)
-{
- self->proc_func_ptr = HilbertMain_filters;
+{
+ self->proc_func_ptr = HilbertMain_filters;
}
static void
HilbertMain_compute_next_data_frame(HilbertMain *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -112,7 +112,7 @@ HilbertMain_traverse(HilbertMain *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
HilbertMain_clear(HilbertMain *self)
{
pyo_CLEAR
@@ -137,7 +137,7 @@ HilbertMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp;
HilbertMain *self;
self = (HilbertMain *)type->tp_alloc(type, 0);
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, HilbertMain_compute_next_data_frame);
self->mode_func_ptr = HilbertMain_setProcMode;
@@ -148,12 +148,12 @@ HilbertMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
static char *kwlist[] = {"input", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &inputtmp))
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, 2 * self->bufsize * sizeof(MYFLT));
@@ -253,33 +253,33 @@ Hilbert_setProcMode(Hilbert *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Hilbert_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Hilbert_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Hilbert_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Hilbert_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Hilbert_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Hilbert_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Hilbert_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Hilbert_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Hilbert_postprocessing_revareva;
break;
}
@@ -294,7 +294,7 @@ Hilbert_compute_next_data_frame(Hilbert *self)
tmp = HilbertMain_getSamplesBuffer((HilbertMain *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -306,11 +306,11 @@ Hilbert_traverse(Hilbert *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Hilbert_clear(Hilbert *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -329,44 +329,44 @@ Hilbert_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
Hilbert *self;
self = (Hilbert *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Hilbert_compute_next_data_frame);
self->mode_func_ptr = Hilbert_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (HilbertMain *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Hilbert_getServer(Hilbert* self) { GET_SERVER };
static PyObject * Hilbert_getStream(Hilbert* self) { GET_STREAM };
-static PyObject * Hilbert_setMul(Hilbert *self, PyObject *arg) { SET_MUL };
-static PyObject * Hilbert_setAdd(Hilbert *self, PyObject *arg) { SET_ADD };
-static PyObject * Hilbert_setSub(Hilbert *self, PyObject *arg) { SET_SUB };
-static PyObject * Hilbert_setDiv(Hilbert *self, PyObject *arg) { SET_DIV };
+static PyObject * Hilbert_setMul(Hilbert *self, PyObject *arg) { SET_MUL };
+static PyObject * Hilbert_setAdd(Hilbert *self, PyObject *arg) { SET_ADD };
+static PyObject * Hilbert_setSub(Hilbert *self, PyObject *arg) { SET_SUB };
+static PyObject * Hilbert_setDiv(Hilbert *self, PyObject *arg) { SET_DIV };
static PyObject * Hilbert_play(Hilbert *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Hilbert_out(Hilbert *self, PyObject *args, PyObject *kwds) { OUT };
@@ -484,4 +484,4 @@ Hilbert_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
Hilbert_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/inputmodule.c b/src/objects/inputmodule.c
index 5661103..cd3df62 100644
--- a/src/objects/inputmodule.c
+++ b/src/objects/inputmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -48,46 +48,46 @@ Input_setProcMode(Input *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Input_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Input_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Input_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Input_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Input_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Input_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Input_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Input_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Input_postprocessing_revareva;
break;
- }
+ }
}
static void
Input_compute_next_data_frame(Input *self)
-{
+{
int i;
MYFLT *tmp;
tmp = Server_getInputBuffer((Server *)self->server);
- for (i=0; i<self->bufsize*self->nchnls; i++) {
- if ((i % self->nchnls) == self->chnl)
- self->data[(int)(i/self->nchnls)] = tmp[i];
- }
+ for (i=0; i<self->bufsize*self->ichnls; i++) {
+ if ((i % self->ichnls) == self->chnl)
+ self->data[(int)(i/self->ichnls)] = tmp[i];
+ }
(*self->muladd_func_ptr)(self);
}
@@ -98,7 +98,7 @@ Input_traverse(Input *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Input_clear(Input *self)
{
pyo_CLEAR
@@ -133,7 +133,7 @@ Input_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iOO", kwlist, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -141,20 +141,20 @@ Input_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Input_getServer(Input* self) { GET_SERVER };
static PyObject * Input_getStream(Input* self) { GET_STREAM };
-static PyObject * Input_setMul(Input *self, PyObject *arg) { SET_MUL };
-static PyObject * Input_setAdd(Input *self, PyObject *arg) { SET_ADD };
-static PyObject * Input_setSub(Input *self, PyObject *arg) { SET_SUB };
-static PyObject * Input_setDiv(Input *self, PyObject *arg) { SET_DIV };
+static PyObject * Input_setMul(Input *self, PyObject *arg) { SET_MUL };
+static PyObject * Input_setAdd(Input *self, PyObject *arg) { SET_ADD };
+static PyObject * Input_setSub(Input *self, PyObject *arg) { SET_SUB };
+static PyObject * Input_setDiv(Input *self, PyObject *arg) { SET_DIV };
static PyObject * Input_play(Input *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Input_out(Input *self, PyObject *args, PyObject *kwds) { OUT };
@@ -273,4 +273,3 @@ PyTypeObject InputType = {
0, /* tp_alloc */
Input_new, /* tp_new */
};
-
diff --git a/src/objects/lfomodule.c b/src/objects/lfomodule.c
index b1a2bdb..f8ccbcd 100644
--- a/src/objects/lfomodule.c
+++ b/src/objects/lfomodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -32,7 +32,7 @@ typedef struct {
Stream *freq_stream;
PyObject *sharp;
Stream *sharp_stream;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
int wavetype;
MYFLT oneOverPiOverTwo;
MYFLT srOverFour;
@@ -66,7 +66,7 @@ LFO_generates_ii(LFO *self) {
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
for (i=0; i<self->bufsize; i++) {
pointer = self->pointerPos * 2.0 - 1.0;
val = pointer - MYTANH(numh * pointer) / MYTANH(numh);
@@ -75,14 +75,14 @@ LFO_generates_ii(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 1: /* Saw down */
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
for (i=0; i<self->bufsize; i++) {
pointer = self->pointerPos * 2.0 - 1.0;
val = -(pointer - MYTANH(numh * pointer) / MYTANH(numh));
@@ -91,14 +91,14 @@ LFO_generates_ii(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 2: /* Square */
maxHarms = (int)(self->srOverEight/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
for (i=0; i<self->bufsize; i++) {
val = MYATAN(numh * MYSIN(TWOPI*self->pointerPos));
self->data[i] = val * self->oneOverPiOverTwo;
@@ -106,15 +106,15 @@ LFO_generates_ii(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 3: /* Triangle */
maxHarms = (int)(self->srOverFour/freq);
if ((sharp * 36.0) > maxHarms)
numh = (MYFLT)(maxHarms / 36.0);
else
- numh = sharp;
+ numh = sharp;
for (i=0; i<self->bufsize; i++) {
v1 = MYTAN(MYSIN(TWOPI*self->pointerPos));
pointer = self->pointerPos + 0.25;
@@ -127,8 +127,8 @@ LFO_generates_ii(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 4: /* Pulse */
maxHarms = (int)(self->srOverEight/freq);
@@ -144,14 +144,14 @@ LFO_generates_ii(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 5: /* Bi-Pulse */
maxHarms = (int)(self->srOverEight/freq);
numh = MYFLOOR(sharp * 46.0 + 4.0);
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
if (MYFMOD(numh, 2.0) == 0.0)
numh += 1.0;
for (i=0; i<self->bufsize; i++) {
@@ -161,8 +161,8 @@ LFO_generates_ii(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 6: /* SAH */
numh = 1.0 - sharp;
@@ -186,7 +186,7 @@ LFO_generates_ii(LFO *self) {
val = self->sahCurrentValue;
}
self->data[i] = val;
- }
+ }
break;
case 7: /* Sine-mod */
inc2 = inc * sharp;
@@ -203,7 +203,7 @@ LFO_generates_ii(LFO *self) {
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
break;
default:
break;
@@ -215,7 +215,7 @@ LFO_generates_ai(LFO *self) {
MYFLT val, inc, freq, sharp, pointer, numh;
MYFLT v1, v2, inc2, fade;
int i, maxHarms;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
if (fr[0] <= 0) {
return;
@@ -225,7 +225,7 @@ LFO_generates_ai(LFO *self) {
sharp = 0.0;
else if (sharp > 1.0)
sharp = 1.0;
-
+
switch (self->wavetype) {
case 0: /* Saw up */
for (i=0; i<self->bufsize; i++) {
@@ -234,7 +234,7 @@ LFO_generates_ai(LFO *self) {
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
pointer = self->pointerPos * 2.0 - 1.0;
val = pointer - MYTANH(numh * pointer) / MYTANH(numh);
self->data[i] = val;
@@ -242,8 +242,8 @@ LFO_generates_ai(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 1: /* Saw down */
for (i=0; i<self->bufsize; i++) {
@@ -252,7 +252,7 @@ LFO_generates_ai(LFO *self) {
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
pointer = self->pointerPos * 2.0 - 1.0;
val = -(pointer - MYTANH(numh * pointer) / MYTANH(numh));
self->data[i] = val;
@@ -260,8 +260,8 @@ LFO_generates_ai(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 2: /* Square */
for (i=0; i<self->bufsize; i++) {
@@ -270,15 +270,15 @@ LFO_generates_ai(LFO *self) {
maxHarms = (int)(self->srOverEight/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
val = MYATAN(numh * MYSIN(TWOPI*self->pointerPos));
self->data[i] = val * self->oneOverPiOverTwo;
self->pointerPos += inc;
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 3: /* Triangle */
for (i=0; i<self->bufsize; i++) {
@@ -288,7 +288,7 @@ LFO_generates_ai(LFO *self) {
if ((sharp * 36.0) > maxHarms)
numh = (MYFLT)(maxHarms / 36.0);
else
- numh = sharp;
+ numh = sharp;
v1 = MYTAN(MYSIN(TWOPI*self->pointerPos));
pointer = self->pointerPos + 0.25;
if (pointer > 1.0)
@@ -300,8 +300,8 @@ LFO_generates_ai(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 4: /* Pulse */
for (i=0; i<self->bufsize; i++) {
@@ -319,8 +319,8 @@ LFO_generates_ai(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 5: /* Bi-Pulse */
for (i=0; i<self->bufsize; i++) {
@@ -329,7 +329,7 @@ LFO_generates_ai(LFO *self) {
maxHarms = (int)(self->srOverEight/freq);
numh = MYFLOOR(sharp * 46.0 + 4.0);
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
if (MYFMOD(numh, 2.0) == 0.0)
numh += 1.0;
val = MYTAN(MYPOW(MYSIN(TWOPI*self->pointerPos), numh));
@@ -338,8 +338,8 @@ LFO_generates_ai(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 6: /* SAH */
numh = 1.0 - sharp;
@@ -365,7 +365,7 @@ LFO_generates_ai(LFO *self) {
val = self->sahCurrentValue;
}
self->data[i] = val;
- }
+ }
break;
case 7: /* Sine-mod */
for (i=0; i<self->bufsize; i++) {
@@ -384,11 +384,11 @@ LFO_generates_ai(LFO *self) {
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
break;
default:
break;
- }
+ }
}
static void
@@ -396,14 +396,14 @@ LFO_generates_ia(LFO *self) {
MYFLT val, inc, freq, sharp, pointer, numh;
MYFLT v1, v2, inc2, fade;
int i, maxHarms;
-
+
freq = PyFloat_AS_DOUBLE(self->freq);
if (freq <= 0) {
return;
}
MYFLT *sh = Stream_getData((Stream *)self->sharp_stream);
inc = freq / self->sr;
-
+
switch (self->wavetype) {
case 0: /* Saw up */
maxHarms = (int)(self->srOverFour/freq);
@@ -415,7 +415,7 @@ LFO_generates_ia(LFO *self) {
sharp = 1.0;
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
pointer = self->pointerPos * 2.0 - 1.0;
val = pointer - MYTANH(numh * pointer) / MYTANH(numh);
self->data[i] = val;
@@ -423,8 +423,8 @@ LFO_generates_ia(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 1: /* Saw down */
maxHarms = (int)(self->srOverFour/freq);
@@ -436,7 +436,7 @@ LFO_generates_ia(LFO *self) {
sharp = 1.0;
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
pointer = self->pointerPos * 2.0 - 1.0;
val = -(pointer - MYTANH(numh * pointer) / MYTANH(numh));
self->data[i] = val;
@@ -444,8 +444,8 @@ LFO_generates_ia(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 2: /* Square */
maxHarms = (int)(self->srOverEight/freq);
@@ -457,15 +457,15 @@ LFO_generates_ia(LFO *self) {
sharp = 1.0;
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
val = MYATAN(numh * MYSIN(TWOPI*self->pointerPos));
self->data[i] = val * self->oneOverPiOverTwo;
self->pointerPos += inc;
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 3: /* Triangle */
maxHarms = (int)(self->srOverFour/freq);
@@ -478,7 +478,7 @@ LFO_generates_ia(LFO *self) {
if ((sharp * 36.0) > maxHarms)
numh = (MYFLT)(maxHarms / 36.0);
else
- numh = sharp;
+ numh = sharp;
v1 = MYTAN(MYSIN(TWOPI*self->pointerPos));
pointer = self->pointerPos + 0.25;
if (pointer > 1.0)
@@ -490,8 +490,8 @@ LFO_generates_ia(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 4: /* Pulse */
maxHarms = (int)(self->srOverEight/freq);
@@ -512,8 +512,8 @@ LFO_generates_ia(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 5: /* Bi-Pulse */
maxHarms = (int)(self->srOverEight/freq);
@@ -534,8 +534,8 @@ LFO_generates_ia(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 6: /* SAH */
for (i=0; i<self->bufsize; i++) {
@@ -564,7 +564,7 @@ LFO_generates_ia(LFO *self) {
val = self->sahCurrentValue;
}
self->data[i] = val;
- }
+ }
break;
case 7: /* Sine-mod */
for (i=0; i<self->bufsize; i++) {
@@ -586,7 +586,7 @@ LFO_generates_ia(LFO *self) {
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
break;
default:
break;
@@ -598,13 +598,13 @@ LFO_generates_aa(LFO *self) {
MYFLT val, inc, freq, sharp, pointer, numh;
MYFLT v1, v2, inc2, fade;
int i, maxHarms;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
if (fr[0] <= 0) {
return;
}
MYFLT *sh = Stream_getData((Stream *)self->sharp_stream);
-
+
switch (self->wavetype) {
case 0: /* Saw up */
for (i=0; i<self->bufsize; i++) {
@@ -618,7 +618,7 @@ LFO_generates_aa(LFO *self) {
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
pointer = self->pointerPos * 2.0 - 1.0;
val = pointer - MYTANH(numh * pointer) / MYTANH(numh);
self->data[i] = val;
@@ -626,8 +626,8 @@ LFO_generates_aa(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 1: /* Saw down */
for (i=0; i<self->bufsize; i++) {
@@ -641,7 +641,7 @@ LFO_generates_aa(LFO *self) {
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
pointer = self->pointerPos * 2.0 - 1.0;
val = -(pointer - MYTANH(numh * pointer) / MYTANH(numh));
self->data[i] = val;
@@ -649,8 +649,8 @@ LFO_generates_aa(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 2: /* Square */
for (i=0; i<self->bufsize; i++) {
@@ -664,15 +664,15 @@ LFO_generates_aa(LFO *self) {
maxHarms = (int)(self->srOverEight/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
val = MYATAN(numh * MYSIN(TWOPI*self->pointerPos));
self->data[i] = val * self->oneOverPiOverTwo;
self->pointerPos += inc;
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 3: /* Triangle */
for (i=0; i<self->bufsize; i++) {
@@ -687,7 +687,7 @@ LFO_generates_aa(LFO *self) {
if ((sharp * 36.0) > maxHarms)
numh = (MYFLT)(maxHarms / 36.0);
else
- numh = sharp;
+ numh = sharp;
v1 = MYTAN(MYSIN(TWOPI*self->pointerPos));
pointer = self->pointerPos + 0.25;
if (pointer > 1.0)
@@ -699,8 +699,8 @@ LFO_generates_aa(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 4: /* Pulse */
for (i=0; i<self->bufsize; i++) {
@@ -723,8 +723,8 @@ LFO_generates_aa(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 5: /* Bi-Pulse */
for (i=0; i<self->bufsize; i++) {
@@ -738,7 +738,7 @@ LFO_generates_aa(LFO *self) {
maxHarms = (int)(self->srOverEight/freq);
numh = MYFLOOR(sharp * 46.0 + 4.0);
if (numh > maxHarms)
- numh = maxHarms;
+ numh = maxHarms;
if (MYFMOD(numh, 2.0) == 0.0)
numh += 1.0;
val = MYTAN(MYPOW(MYSIN(TWOPI*self->pointerPos), numh));
@@ -747,8 +747,8 @@ LFO_generates_aa(LFO *self) {
if (self->pointerPos < 0)
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
- }
+ self->pointerPos -= 1.0;
+ }
break;
case 6: /* SAH */
for (i=0; i<self->bufsize; i++) {
@@ -779,7 +779,7 @@ LFO_generates_aa(LFO *self) {
val = self->sahCurrentValue;
}
self->data[i] = val;
- }
+ }
break;
case 7: /* Sine-mod */
for (i=0; i<self->bufsize; i++) {
@@ -803,7 +803,7 @@ LFO_generates_aa(LFO *self) {
self->pointerPos += 1.0;
else if (self->pointerPos >= 1)
self->pointerPos -= 1.0;
- }
+ }
break;
default:
break;
@@ -826,56 +826,56 @@ LFO_setProcMode(LFO *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = LFO_generates_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = LFO_generates_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = LFO_generates_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = LFO_generates_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = LFO_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = LFO_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = LFO_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = LFO_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = LFO_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = LFO_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = LFO_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = LFO_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = LFO_postprocessing_revareva;
break;
- }
+ }
}
static void
LFO_compute_next_data_frame(LFO *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -883,21 +883,21 @@ static int
LFO_traverse(LFO *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->sharp);
- Py_VISIT(self->sharp_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->sharp);
+ Py_VISIT(self->sharp_stream);
return 0;
}
-static int
+static int
LFO_clear(LFO *self)
{
pyo_CLEAR
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->sharp);
- Py_CLEAR(self->sharp_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->sharp);
+ Py_CLEAR(self->sharp_stream);
return 0;
}
@@ -916,7 +916,7 @@ LFO_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *sharptmp=NULL, *multmp=NULL, *addtmp=NULL;
LFO *self;
self = (LFO *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100);
self->sharp = PyFloat_FromDouble(0.5);
self->oneOverPiOverTwo = 1.0 / (PI / 2.0);
@@ -930,7 +930,7 @@ LFO_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
-
+
self->srOverFour = (MYFLT)self->sr * 0.25;
self->srOverEight = (MYFLT)self->sr * 0.125;
Stream_setFunctionPtr(self->stream, LFO_compute_next_data_frame);
@@ -948,7 +948,7 @@ LFO_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (sharptmp) {
PyObject_CallMethod((PyObject *)self, "setSharp", "O", sharptmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -956,13 +956,13 @@ LFO_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Server_generateSeed((Server *)self->server, LFO_ID);
self->sahCurrentValue = self->sahLastValue = rand()/((MYFLT)(RAND_MAX)*0.5) - 1.0;
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -970,10 +970,10 @@ LFO_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * LFO_getServer(LFO* self) { GET_SERVER };
static PyObject * LFO_getStream(LFO* self) { GET_STREAM };
-static PyObject * LFO_setMul(LFO *self, PyObject *arg) { SET_MUL };
-static PyObject * LFO_setAdd(LFO *self, PyObject *arg) { SET_ADD };
-static PyObject * LFO_setSub(LFO *self, PyObject *arg) { SET_SUB };
-static PyObject * LFO_setDiv(LFO *self, PyObject *arg) { SET_DIV };
+static PyObject * LFO_setMul(LFO *self, PyObject *arg) { SET_MUL };
+static PyObject * LFO_setAdd(LFO *self, PyObject *arg) { SET_ADD };
+static PyObject * LFO_setSub(LFO *self, PyObject *arg) { SET_SUB };
+static PyObject * LFO_setDiv(LFO *self, PyObject *arg) { SET_DIV };
static PyObject * LFO_play(LFO *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * LFO_out(LFO *self, PyObject *args, PyObject *kwds) { OUT };
@@ -992,14 +992,14 @@ static PyObject *
LFO_setFreq(LFO *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1015,25 +1015,25 @@ LFO_setFreq(LFO *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
LFO_setSharp(LFO *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->sharp);
@@ -1049,25 +1049,25 @@ LFO_setSharp(LFO *self, PyObject *arg)
self->sharp_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
LFO_setType(LFO *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 8)
@@ -1075,13 +1075,13 @@ LFO_setType(LFO *self, PyObject *arg)
}
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
-static PyObject *
-LFO_reset(LFO *self)
+static PyObject *
+LFO_reset(LFO *self)
{
self->pointerPos = 0.0;
self->sahPointerPos = 0.0;
@@ -1199,4 +1199,4 @@ PyTypeObject LFOType = {
0, /* tp_init */
0, /* tp_alloc */
LFO_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/matrixmodule.c b/src/objects/matrixmodule.c
index 9178518..1b7b068 100644
--- a/src/objects/matrixmodule.c
+++ b/src/objects/matrixmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -72,7 +72,7 @@ MatrixStream_getInterpPointFromPos(MatrixStream *self, MYFLT x, MYFLT y)
while (xpos >= self->width) {
xpos -= self->width;
}
- }
+ }
ypos = y * self->height;
if (ypos < 0)
@@ -81,11 +81,11 @@ MatrixStream_getInterpPointFromPos(MatrixStream *self, MYFLT x, MYFLT y)
while (ypos >= self->height) {
ypos -= self->height;
}
- }
+ }
xipart = (int)xpos;
xfpart = xpos - xipart;
-
+
yipart = (int)ypos;
yfpart = ypos - yipart;
@@ -93,33 +93,33 @@ MatrixStream_getInterpPointFromPos(MatrixStream *self, MYFLT x, MYFLT y)
x2 = self->data[yipart+1][xipart]; // (0, 1)
x3 = self->data[yipart][xipart+1]; // (1, 0)
x4 = self->data[yipart+1][xipart+1]; // (1, 1)
-
+
return (x1*(1-yfpart)*(1-xfpart) + x2*yfpart*(1-xfpart) + x3*(1-yfpart)*xfpart + x4*yfpart*xfpart);
}
-MYFLT
+MYFLT
MatrixStream_getPointFromPos(MatrixStream *self, long x, long y)
{
return self->data[y][x];
-}
+}
void
MatrixStream_setData(MatrixStream *self, MYFLT **data)
{
self->data = data;
-}
+}
void
MatrixStream_setWidth(MatrixStream *self, int size)
{
self->width = size;
-}
+}
void
MatrixStream_setHeight(MatrixStream *self, int size)
{
self->height = size;
-}
+}
PyTypeObject MatrixStreamType = {
PyObject_HEAD_INIT(NULL)
@@ -172,7 +172,7 @@ typedef struct {
int y_pointer;
} NewMatrix;
-MYFLT
+MYFLT
NewMatrix_clip(MYFLT val, MYFLT min, MYFLT max) {
if (val < min) return min;
else if (val > max) return max;
@@ -191,7 +191,7 @@ NewMatrix_recordChunkAllRow(NewMatrix *self, MYFLT *data, long datasize)
self->y_pointer++;
if (self->y_pointer >= self->height)
self->y_pointer = 0;
- }
+ }
}
Py_INCREF(Py_None);
return Py_None;
@@ -204,7 +204,7 @@ NewMatrix_traverse(NewMatrix *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
NewMatrix_clear(NewMatrix *self)
{
pyo_matrix_CLEAR
@@ -217,7 +217,7 @@ NewMatrix_dealloc(NewMatrix* self)
int i;
for (i=0; i<(self->height+1); i++) {
free(self->data[i]);
- }
+ }
free(self->data);
NewMatrix_clear(self);
self->ob_type->tp_free((PyObject*)self);
@@ -229,41 +229,41 @@ NewMatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
int i, j;
PyObject *inittmp=NULL;
NewMatrix *self;
-
+
self = (NewMatrix *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->x_pointer = self->y_pointer = 0;
-
+
MAKE_NEW_MATRIXSTREAM(self->matrixstream, &MatrixStreamType, NULL);
static char *kwlist[] = {"width", "height", "init", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "ii|O", kwlist, &self->width, &self->height, &inittmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
self->data = (MYFLT **)realloc(self->data, (self->height + 1) * sizeof(MYFLT *));
-
+
for (i=0; i<(self->height+1); i++) {
self->data[i] = (MYFLT *)malloc((self->width + 1) * sizeof(MYFLT));
}
-
+
for(i=0; i<(self->height+1); i++) {
for (j=0; j<(self->width+1); j++) {
self->data[i][j] = 0.0;
- }
+ }
}
-
+
MatrixStream_setWidth(self->matrixstream, self->width);
MatrixStream_setHeight(self->matrixstream, self->height);
-
+
if (inittmp) {
PyObject_CallMethod((PyObject *)self, "setMatrix", "O", inittmp);
}
-
+
MatrixStream_setData(self->matrixstream, self->data);
-
+
return (PyObject *)self;
}
@@ -306,16 +306,16 @@ NewMatrix_getData(NewMatrix *self)
{
int i, j;
PyObject *matrix, *samples;
-
+
matrix = PyList_New(self->height);
for(i=0; i<self->height; i++) {
samples = PyList_New(self->width);
for (j=0; j<self->width; j++) {
PyList_SetItem(samples, j, PyFloat_FromDouble(self->data[i][j]));
- }
+ }
PyList_SetItem(matrix, i, samples);
}
-
+
return matrix;
};
@@ -324,14 +324,14 @@ NewMatrix_getViewData(NewMatrix *self)
{
int i, j;
PyObject *matrix;
-
+
matrix = PyList_New(self->width*self->height);
for(i=0; i<self->height; i++) {
for (j=0; j<self->width; j++) {
PyList_SET_ITEM(matrix, i*self->width+j, PyFloat_FromDouble(self->data[i][j]*128+128));
- }
+ }
}
-
+
return matrix;
};
@@ -345,7 +345,7 @@ NewMatrix_setMatrix(NewMatrix *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The matrix value value must be a list.");
return PyInt_FromLong(-1);
@@ -357,16 +357,16 @@ NewMatrix_setMatrix(NewMatrix *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "New matrix must be of the same size as actual matrix.");
return PyInt_FromLong(-1);
}
-
+
for(i=0; i<self->height; i++) {
innerlist = PyList_GetItem(value, i);
for (j=0; j<self->width; j++) {
self->data[i][j] = PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(innerlist, j)));
- }
+ }
}
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
}
static PyObject *
@@ -377,10 +377,10 @@ NewMatrix_genSineTerrain(NewMatrix *self, PyObject *args, PyObject *kwds)
MYFLT freq = 1;
MYFLT phase = 0.0625;
static char *kwlist[] = {"freq", "phase", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__FF, kwlist, &freq, &phase))
return PyInt_FromLong(-1);
-
+
xfreq = TWOPI * freq;
xsize = 1.0 / self->width;
for (i=0; i<self->height; i++) {
@@ -390,7 +390,7 @@ NewMatrix_genSineTerrain(NewMatrix *self, PyObject *args, PyObject *kwds)
}
}
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
}
static PyMemberDef NewMatrix_members[] = {
@@ -485,9 +485,9 @@ MatrixRec_compute_next_data_frame(MatrixRec *self)
int width = NewMatrix_getWidth((NewMatrix *)self->matrix);
int height = NewMatrix_getHeight((NewMatrix *)self->matrix);
int size = width * height;
-
+
int off = self->delay - self->delayCount;
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
}
@@ -502,12 +502,12 @@ MatrixRec_compute_next_data_frame(MatrixRec *self)
else
self->trigsBuffer[num-1] = 1.0;
self->active = 0;
- }
+ }
}
-
- if (self->pointer < size) {
+
+ if (self->pointer < size) {
upBound = size - self->fadeInSample;
-
+
if (off == 0)
num2 = num;
else if ((num-off) <= 0)
@@ -518,7 +518,7 @@ MatrixRec_compute_next_data_frame(MatrixRec *self)
MYFLT buffer[num2];
memset(&buffer, 0, sizeof(buffer));
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<num; i++) {
if (self->delayCount < self->delay) {
self->delayCount++;
@@ -535,7 +535,7 @@ MatrixRec_compute_next_data_frame(MatrixRec *self)
}
}
NewMatrix_recordChunkAllRow((NewMatrix *)self->matrix, buffer, num2);
- }
+ }
}
static int
@@ -545,18 +545,18 @@ MatrixRec_traverse(MatrixRec *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->matrix);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
MatrixRec_clear(MatrixRec *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->matrix);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -576,36 +576,36 @@ MatrixRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *matrixtmp;
MatrixRec *self;
self = (MatrixRec *)type->tp_alloc(type, 0);
-
+
self->pointer = 0;
self->active = 1;
self->fadetime = 0.;
self->delay = self->delayCount = 0;
-
+
INIT_OBJECT_COMMON
-
+
Stream_setFunctionPtr(self->stream, MatrixRec_compute_next_data_frame);
Stream_setStreamActive(self->stream, 0);
static char *kwlist[] = {"input", "matrix", "fadetime", "delay", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_OO_FI, kwlist, &inputtmp, &matrixtmp, &self->fadetime, &self->delay))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_STREAM
Py_XDECREF(self->matrix);
Py_INCREF(matrixtmp);
self->matrix = (NewMatrix *)matrixtmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
-
+ }
+
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
@@ -615,7 +615,7 @@ MatrixRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if ((self->fadetime * self->sr) > (size * 0.5))
self->fadetime = size * 0.5 / self->sr;
self->fadeInSample = roundf(self->fadetime * self->sr + 0.5);
-
+
return (PyObject *)self;
}
@@ -623,12 +623,12 @@ static PyObject * MatrixRec_getServer(MatrixRec* self) { GET_SERVER };
static PyObject * MatrixRec_getStream(MatrixRec* self) { GET_STREAM };
static PyObject * MatrixRec_getTriggerStream(MatrixRec* self) { GET_TRIGGER_STREAM };
-static PyObject * MatrixRec_play(MatrixRec *self, PyObject *args, PyObject *kwds)
-{
+static PyObject * MatrixRec_play(MatrixRec *self, PyObject *args, PyObject *kwds)
+{
self->pointer = 0;
self->active = 1;
self->delayCount = 0;
- PLAY
+ PLAY
};
static PyObject * MatrixRec_stop(MatrixRec *self) { STOP };
@@ -637,20 +637,20 @@ static PyObject *
MatrixRec_setMatrix(MatrixRec *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->matrix);
self->matrix = (NewMatrix *)tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef MatrixRec_members[] = {
{"server", T_OBJECT_EX, offsetof(MatrixRec, server), 0, "Pyo server."},
@@ -737,7 +737,7 @@ MatrixRecLoop_compute_next_data_frame(MatrixRecLoop *self)
MYFLT buffer[self->bufsize];
memset(&buffer, 0, sizeof(buffer));
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
buffer[i] = in[i];
@@ -756,18 +756,18 @@ MatrixRecLoop_traverse(MatrixRecLoop *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->matrix);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
MatrixRecLoop_clear(MatrixRecLoop *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->matrix);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -787,32 +787,32 @@ MatrixRecLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *matrixtmp;
MatrixRecLoop *self;
self = (MatrixRecLoop *)type->tp_alloc(type, 0);
-
+
self->pointer = 0;
-
+
INIT_OBJECT_COMMON
-
+
Stream_setFunctionPtr(self->stream, MatrixRecLoop_compute_next_data_frame);
-
+
static char *kwlist[] = {"input", "matrix", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &inputtmp, &matrixtmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_STREAM
Py_XDECREF(self->matrix);
Py_INCREF(matrixtmp);
self->matrix = (NewMatrix *)matrixtmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
-
+ }
+
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
@@ -830,20 +830,20 @@ static PyObject *
MatrixRecLoop_setMatrix(MatrixRecLoop *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->matrix);
self->matrix = (NewMatrix *)tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef MatrixRecLoop_members[] = {
{"server", T_OBJECT_EX, offsetof(MatrixRecLoop, server), 0, "Pyo server."},
@@ -934,32 +934,32 @@ MatrixMorph_compute_next_data_frame(MatrixMorph *self)
int x, y;
long i, j, width, height, numsamps, index;
MYFLT input, interp, interp1;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
width = NewMatrix_getWidth((NewMatrix *)self->matrix);
height = NewMatrix_getHeight((NewMatrix *)self->matrix);
numsamps = width * height;
int len = PyList_Size(self->sources);
-
+
input = MatrixMorph_clip(in[0]);
-
+
interp = input * (len - 1);
- x = (int)(interp);
+ x = (int)(interp);
y = x + 1;
-
+
MatrixStream *tab1 = (MatrixStream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->sources, x), "getMatrixStream", "");
MatrixStream *tab2 = (MatrixStream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->sources, y), "getMatrixStream", "");
-
+
interp = MYFMOD(interp, 1.0);
interp1 = 1. - interp;
-
+
for (i=0; i<height; i++) {
for (j=0; j<width; j++) {
index = i*width+j;
self->buffer[index] = MatrixStream_getPointFromPos(tab1, j, i) * interp1 + MatrixStream_getPointFromPos(tab2, j, i) * interp;
- }
- }
-
+ }
+ }
+
NewMatrix_recordChunkAllRow((NewMatrix *)self->matrix, self->buffer, numsamps);
}
@@ -974,7 +974,7 @@ MatrixMorph_traverse(MatrixMorph *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
MatrixMorph_clear(MatrixMorph *self)
{
pyo_CLEAR
@@ -1002,16 +1002,16 @@ MatrixMorph_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *matrixtmp, *sourcestmp;
MatrixMorph *self;
self = (MatrixMorph *)type->tp_alloc(type, 0);
-
+
INIT_OBJECT_COMMON
-
+
Stream_setFunctionPtr(self->stream, MatrixMorph_compute_next_data_frame);
static char *kwlist[] = {"input", "matrix", "sources", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOO", kwlist, &inputtmp, &matrixtmp, &sourcestmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_STREAM
Py_XDECREF(self->matrix);
@@ -1026,9 +1026,9 @@ MatrixMorph_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_XDECREF(self->sources);
Py_INCREF(sourcestmp);
self->sources = (PyObject *)sourcestmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
return (PyObject *)self;
}
@@ -1042,38 +1042,38 @@ static PyObject *
MatrixMorph_setMatrix(MatrixMorph *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->matrix);
self->matrix = (PyObject *)tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
MatrixMorph_setSources(MatrixMorph *self, PyObject *arg)
-{
+{
if (arg == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(arg);
Py_DECREF(self->sources);
self->sources = arg;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1138,4 +1138,3 @@ PyTypeObject MatrixMorphType = {
0, /* tp_alloc */
MatrixMorph_new, /* tp_new */
};
-
diff --git a/src/objects/matrixprocessmodule.c b/src/objects/matrixprocessmodule.c
index 19a5018..78a51f7 100644
--- a/src/objects/matrixprocessmodule.c
+++ b/src/objects/matrixprocessmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -70,40 +70,40 @@ MatrixPointer_setProcMode(MatrixPointer *self)
self->proc_func_ptr = MatrixPointer_readframes;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = MatrixPointer_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = MatrixPointer_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = MatrixPointer_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = MatrixPointer_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = MatrixPointer_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = MatrixPointer_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = MatrixPointer_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = MatrixPointer_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = MatrixPointer_postprocessing_revareva;
break;
- }
+ }
}
static void
MatrixPointer_compute_next_data_frame(MatrixPointer *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -112,22 +112,22 @@ MatrixPointer_traverse(MatrixPointer *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->matrix);
- Py_VISIT(self->x);
- Py_VISIT(self->x_stream);
- Py_VISIT(self->y);
- Py_VISIT(self->y_stream);
+ Py_VISIT(self->x);
+ Py_VISIT(self->x_stream);
+ Py_VISIT(self->y);
+ Py_VISIT(self->y_stream);
return 0;
}
-static int
+static int
MatrixPointer_clear(MatrixPointer *self)
{
pyo_CLEAR
Py_CLEAR(self->matrix);
- Py_CLEAR(self->x);
- Py_CLEAR(self->x_stream);
- Py_CLEAR(self->y);
- Py_CLEAR(self->y_stream);
+ Py_CLEAR(self->x);
+ Py_CLEAR(self->x_stream);
+ Py_CLEAR(self->y);
+ Py_CLEAR(self->y_stream);
return 0;
}
@@ -146,22 +146,26 @@ MatrixPointer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *matrixtmp, *xtmp, *ytmp, *multmp=NULL, *addtmp=NULL;
MatrixPointer *self;
self = (MatrixPointer *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, MatrixPointer_compute_next_data_frame);
self->mode_func_ptr = MatrixPointer_setProcMode;
static char *kwlist[] = {"matrix", "x", "y", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOO|OO", kwlist, &matrixtmp, &xtmp, &ytmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
+ if ( PyObject_HasAttrString((PyObject *)matrixtmp, "getMatrixStream") == 0 ) {
+ PyErr_SetString(PyExc_TypeError, "\"matrix\" argument of MatrixPointer must be a PyoMatrixObject.\n");
+ Py_RETURN_NONE;
+ }
Py_XDECREF(self->matrix);
self->matrix = PyObject_CallMethod((PyObject *)matrixtmp, "getMatrixStream", "");
-
+
if (xtmp) {
PyObject_CallMethod((PyObject *)self, "setX", "O", xtmp);
}
@@ -169,26 +173,26 @@ MatrixPointer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (ytmp) {
PyObject_CallMethod((PyObject *)self, "setY", "O", ytmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
return (PyObject *)self;
}
static PyObject * MatrixPointer_getServer(MatrixPointer* self) { GET_SERVER };
static PyObject * MatrixPointer_getStream(MatrixPointer* self) { GET_STREAM };
-static PyObject * MatrixPointer_setMul(MatrixPointer *self, PyObject *arg) { SET_MUL };
-static PyObject * MatrixPointer_setAdd(MatrixPointer *self, PyObject *arg) { SET_ADD };
-static PyObject * MatrixPointer_setSub(MatrixPointer *self, PyObject *arg) { SET_SUB };
-static PyObject * MatrixPointer_setDiv(MatrixPointer *self, PyObject *arg) { SET_DIV };
+static PyObject * MatrixPointer_setMul(MatrixPointer *self, PyObject *arg) { SET_MUL };
+static PyObject * MatrixPointer_setAdd(MatrixPointer *self, PyObject *arg) { SET_ADD };
+static PyObject * MatrixPointer_setSub(MatrixPointer *self, PyObject *arg) { SET_SUB };
+static PyObject * MatrixPointer_setDiv(MatrixPointer *self, PyObject *arg) { SET_DIV };
static PyObject * MatrixPointer_play(MatrixPointer *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * MatrixPointer_out(MatrixPointer *self, PyObject *args, PyObject *kwds) { OUT };
@@ -214,40 +218,42 @@ static PyObject *
MatrixPointer_setMatrix(MatrixPointer *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
+ if ( PyObject_HasAttrString((PyObject *)tmp, "getMatrixStream") == 0 ) {
+ PyErr_SetString(PyExc_TypeError, "\"matrix\" argument of MatrixPointer must be a PyoMatrixObject.\n");
+ Py_RETURN_NONE;
+ }
+
Py_DECREF(self->matrix);
self->matrix = PyObject_CallMethod((PyObject *)tmp, "getMatrixStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
MatrixPointer_setX(MatrixPointer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- int isNumber = PyNumber_Check(arg);
- if (isNumber == 1) {
- PySys_WriteStderr("MatrixPointer x attributes must be a PyoObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
- }
-
+
tmp = arg;
+
+ if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
+ PyErr_SetString(PyExc_TypeError, "\"x\" attribute of MatrixPointer must be a PyoObject.\n");
+ Py_RETURN_NONE;
+ }
+
Py_INCREF(tmp);
Py_XDECREF(self->x);
@@ -256,43 +262,40 @@ MatrixPointer_setX(MatrixPointer *self, PyObject *arg)
Py_INCREF(streamtmp);
Py_XDECREF(self->x_stream);
self->x_stream = (Stream *)streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
MatrixPointer_setY(MatrixPointer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- int isNumber = PyNumber_Check(arg);
- if (isNumber == 1) {
- PySys_WriteStderr("MatrixPointer y attributes must be a PyoObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
- }
-
+
tmp = arg;
+
+ if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
+ PyErr_SetString(PyExc_TypeError, "\"y\" attribute of MatrixPointer must be a PyoObject.\n");
+ Py_RETURN_NONE;
+ }
+
Py_INCREF(tmp);
Py_XDECREF(self->y);
-
+
self->y = tmp;
streamtmp = PyObject_CallMethod((PyObject *)self->y, "_getStream", NULL);
Py_INCREF(streamtmp);
Py_XDECREF(self->y_stream);
self->y_stream = (Stream *)streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef MatrixPointer_members[] = {
{"server", T_OBJECT_EX, offsetof(MatrixPointer, server), 0, "Pyo server."},
@@ -404,4 +407,4 @@ MatrixPointer_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
MatrixPointer_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/metromodule.c b/src/objects/metromodule.c
index 2279b70..8efc518 100644
--- a/src/objects/metromodule.c
+++ b/src/objects/metromodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -44,23 +44,23 @@ Metro_generate_i(Metro *self) {
MYFLT val;
double tm, off;
int i;
-
+
tm = PyFloat_AS_DOUBLE(self->time);
off = tm * self->offset;
-
+
for (i=0; i<self->bufsize; i++) {
if (self->currentTime >= tm) {
val = 0;
self->currentTime -= tm;
self->flag = 1;
- }
+ }
else if (self->currentTime >= off && self->flag == 1) {
val = 1;
self->flag = 0;
- }
+ }
else
val = 0;
-
+
self->data[i] = val;
self->currentTime += self->sampleToSec;
}
@@ -71,9 +71,9 @@ Metro_generate_a(Metro *self) {
MYFLT val;
double off, tmd;
int i;
-
+
MYFLT *tm = Stream_getData((Stream *)self->time_stream);
-
+
for (i=0; i<self->bufsize; i++) {
tmd = (double)tm[i];
off = tmd * self->offset;
@@ -85,10 +85,10 @@ Metro_generate_a(Metro *self) {
else if (self->currentTime >= off && self->flag == 1) {
val = 1;
self->flag = 0;
- }
+ }
else
val = 0;
-
+
self->data[i] = val;
self->currentTime += self->sampleToSec;
}
@@ -112,48 +112,48 @@ Metro_setProcMode(Metro *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Metro_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Metro_generate_a;
break;
}
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Metro_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Metro_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Metro_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Metro_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Metro_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Metro_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Metro_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Metro_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Metro_postprocessing_revareva;
break;
- }
+ }
}
static void
Metro_compute_next_data_frame(Metro *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -161,16 +161,16 @@ static int
Metro_traverse(Metro *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->time);
- Py_VISIT(self->time_stream);
+ Py_VISIT(self->time);
+ Py_VISIT(self->time_stream);
return 0;
}
-static int
+static int
Metro_clear(Metro *self)
{
pyo_CLEAR
- Py_CLEAR(self->time);
+ Py_CLEAR(self->time);
Py_CLEAR(self->time_stream);
return 0;
}
@@ -190,7 +190,7 @@ Metro_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *timetmp=NULL;
Metro *self;
self = (Metro *)type->tp_alloc(type, 0);
-
+
self->time = PyFloat_FromDouble(1.);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
@@ -207,27 +207,27 @@ Metro_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->currentTime = 0.;
static char *kwlist[] = {"time", "offset", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Od", kwlist, &timetmp, &self->offset))
Py_RETURN_NONE;
if (timetmp) {
PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Metro_getServer(Metro* self) { GET_SERVER };
static PyObject * Metro_getStream(Metro* self) { GET_STREAM };
-static PyObject * Metro_setMul(Metro *self, PyObject *arg) { SET_MUL };
-static PyObject * Metro_setAdd(Metro *self, PyObject *arg) { SET_ADD };
-static PyObject * Metro_setSub(Metro *self, PyObject *arg) { SET_SUB };
-static PyObject * Metro_setDiv(Metro *self, PyObject *arg) { SET_DIV };
+static PyObject * Metro_setMul(Metro *self, PyObject *arg) { SET_MUL };
+static PyObject * Metro_setAdd(Metro *self, PyObject *arg) { SET_ADD };
+static PyObject * Metro_setSub(Metro *self, PyObject *arg) { SET_SUB };
+static PyObject * Metro_setDiv(Metro *self, PyObject *arg) { SET_DIV };
static PyObject * Metro_play(Metro *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Metro_stop(Metro *self) { STOP };
@@ -245,14 +245,14 @@ static PyObject *
Metro_setTime(Metro *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->time);
@@ -268,12 +268,12 @@ Metro_setTime(Metro *self, PyObject *arg)
self->time_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Metro_members[] = {
{"server", T_OBJECT_EX, offsetof(Metro, server), 0, "Pyo server."},
@@ -290,7 +290,7 @@ static PyMethodDef Metro_methods[] = {
{"play", (PyCFunction)Metro_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"stop", (PyCFunction)Metro_stop, METH_NOARGS, "Stops computing."},
{"setTime", (PyCFunction)Metro_setTime, METH_O, "Sets time factor."},
-{"setMul", (PyCFunction)Metro_setMul, METH_O, "Sets oscillator mul factor."},
+{"setMul", (PyCFunction)Metro_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)Metro_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)Metro_setSub, METH_O, "Sets inverse add factor."},
{"setDiv", (PyCFunction)Metro_setDiv, METH_O, "Sets inverse mul factor."},
@@ -408,7 +408,7 @@ static void
Seqer_reset(Seqer *self)
{
int i;
-
+
self->seqsize = PyList_Size(self->tmp);
self->seq = (int *)realloc(self->seq, self->seqsize * sizeof(int));
for (i=0; i<self->seqsize; i++) {
@@ -421,18 +421,18 @@ static void
Seqer_generate_i(Seqer *self) {
double tm;
int i;
-
+
tm = PyFloat_AS_DOUBLE(self->time);
if (self->currentTime == -1.0) {
self->currentTime = tm;
- }
-
+ }
+
for (i=0; i<(self->poly*self->bufsize); i++) {
self->buffer_streams[i] = 0.0;
}
-
- for (i=0; i<self->bufsize; i++) {
+
+ for (i=0; i<self->bufsize; i++) {
self->currentTime += self->sampleToSec;
if (self->currentTime >= tm) {
self->currentTime -= tm;
@@ -448,9 +448,9 @@ Seqer_generate_i(Seqer *self) {
self->tap = 0;
if (self->newseq == 1)
Seqer_reset(self);
- }
- }
- }
+ }
+ }
+ }
}
}
@@ -458,18 +458,18 @@ static void
Seqer_generate_a(Seqer *self) {
double tm;
int i;
-
+
MYFLT *time = Stream_getData((Stream *)self->time_stream);
-
+
if (self->currentTime == -1.0) {
self->currentTime = time[0];
- }
-
+ }
+
for (i=0; i<(self->poly*self->bufsize); i++) {
self->buffer_streams[i] = 0.0;
}
-
- for (i=0; i<self->bufsize; i++) {
+
+ for (i=0; i<self->bufsize; i++) {
tm = (double)time[i];
self->currentTime += self->sampleToSec;
if (self->currentTime >= tm) {
@@ -486,9 +486,9 @@ Seqer_generate_a(Seqer *self) {
self->tap = 0;
if (self->newseq == 1)
Seqer_reset(self);
- }
- }
- }
+ }
+ }
+ }
}
}
@@ -496,17 +496,17 @@ MYFLT *
Seqer_getSamplesBuffer(Seqer *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
Seqer_setProcMode(Seqer *self)
{
int procmode = self->modebuffer[0];
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Seqer_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Seqer_generate_a;
break;
}
@@ -515,24 +515,24 @@ Seqer_setProcMode(Seqer *self)
static void
Seqer_compute_next_data_frame(Seqer *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
Seqer_traverse(Seqer *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->time);
- Py_VISIT(self->time_stream);
+ Py_VISIT(self->time);
+ Py_VISIT(self->time_stream);
Py_VISIT(self->tmp);
return 0;
}
-static int
+static int
Seqer_clear(Seqer *self)
{
pyo_CLEAR
- Py_CLEAR(self->time);
+ Py_CLEAR(self->time);
Py_CLEAR(self->time_stream);
Py_CLEAR(self->tmp);
return 0;
@@ -554,7 +554,7 @@ Seqer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *timetmp=NULL, *seqtmp=NULL;
Seqer *self;
self = (Seqer *)type->tp_alloc(type, 0);
-
+
self->time = PyFloat_FromDouble(1.);
self->flag = 1;
self->poly = 1;
@@ -567,21 +567,21 @@ Seqer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->count = 0;
self->voiceCount = 0;
self->modebuffer[0] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Seqer_compute_next_data_frame);
self->mode_func_ptr = Seqer_setProcMode;
-
+
Stream_setStreamActive(self->stream, 0);
-
+
self->sampleToSec = 1.0 / self->sr;
self->currentTime = -1.0;
static char *kwlist[] = {"time", "seq", "poly", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist, &timetmp, &seqtmp, &self->poly))
Py_RETURN_NONE;
-
+
if (timetmp) {
PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
}
@@ -589,13 +589,13 @@ Seqer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (seqtmp) {
PyObject_CallMethod((PyObject *)self, "setSeq", "O", seqtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -609,14 +609,14 @@ static PyObject *
Seqer_setTime(Seqer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->time);
@@ -632,25 +632,25 @@ Seqer_setTime(Seqer *self, PyObject *arg)
self->time_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Seqer_setSeq(Seqer *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isList = PyList_Check(arg);
-
+
if (isList == 1) {
tmp = arg;
Py_INCREF(tmp);
@@ -658,10 +658,10 @@ Seqer_setSeq(Seqer *self, PyObject *arg)
self->tmp = tmp;
self->newseq = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Seqer_members[] = {
{"server", T_OBJECT_EX, offsetof(Seqer, server), 0, "Pyo server."},
@@ -728,7 +728,7 @@ PyTypeObject SeqerType = {
typedef struct {
pyo_audio_HEAD
Seqer *mainPlayer;
- int chnl;
+ int chnl;
int modebuffer[2];
} Seq;
@@ -746,36 +746,36 @@ static void
Seq_setProcMode(Seq *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Seq_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Seq_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Seq_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Seq_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Seq_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Seq_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Seq_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Seq_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Seq_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -787,7 +787,7 @@ Seq_compute_next_data_frame(Seq *self)
tmp = Seqer_getSamplesBuffer((Seqer *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -799,11 +799,11 @@ Seq_traverse(Seq *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Seq_clear(Seq *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -822,37 +822,37 @@ Seq_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL;
Seq *self;
self = (Seq *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Seq_compute_next_data_frame);
self->mode_func_ptr = Seq_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (Seqer *)maintmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Seq_getServer(Seq* self) { GET_SERVER };
static PyObject * Seq_getStream(Seq* self) { GET_STREAM };
-static PyObject * Seq_setMul(Seq *self, PyObject *arg) { SET_MUL };
-static PyObject * Seq_setAdd(Seq *self, PyObject *arg) { SET_ADD };
-static PyObject * Seq_setSub(Seq *self, PyObject *arg) { SET_SUB };
-static PyObject * Seq_setDiv(Seq *self, PyObject *arg) { SET_DIV };
+static PyObject * Seq_setMul(Seq *self, PyObject *arg) { SET_MUL };
+static PyObject * Seq_setAdd(Seq *self, PyObject *arg) { SET_ADD };
+static PyObject * Seq_setSub(Seq *self, PyObject *arg) { SET_SUB };
+static PyObject * Seq_setDiv(Seq *self, PyObject *arg) { SET_DIV };
static PyObject * Seq_play(Seq *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Seq_out(Seq *self, PyObject *args, PyObject *kwds) { OUT };
@@ -884,7 +884,7 @@ static PyMethodDef Seq_methods[] = {
{"setMul", (PyCFunction)Seq_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)Seq_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)Seq_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)Seq_setDiv, METH_O, "Sets inverse mul factor."},
+ {"setDiv", (PyCFunction)Seq_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -998,7 +998,7 @@ Clouder_generate_i(Clouder *self) {
for (i=0; i<(self->poly*self->bufsize); i++) {
self->buffer_streams[i] = 0.0;
}
-
+
dens *= 0.5;
for (i=0; i<self->bufsize; i++) {
rnd = (int)(rand() / (MYFLT)RAND_MAX * self->sr);
@@ -1006,7 +1006,7 @@ Clouder_generate_i(Clouder *self) {
self->buffer_streams[i + self->voiceCount++ * self->bufsize] = 1.0;
if (self->voiceCount == self->poly)
self->voiceCount = 0;
- }
+ }
}
}
@@ -1014,27 +1014,27 @@ static void
Clouder_generate_a(Clouder *self) {
MYFLT dens;
int i, rnd;
-
+
MYFLT *density = Stream_getData((Stream *)self->density_stream);
for (i=0; i<(self->poly*self->bufsize); i++) {
self->buffer_streams[i] = 0.0;
}
-
+
for (i=0; i<self->bufsize; i++) {
dens = density[i];
if (dens <= 0.0)
dens = 0.0;
else if (dens > self->sr)
dens = self->sr;
-
+
dens *= 0.5;
rnd = (int)(rand() / (MYFLT)RAND_MAX * self->sr);
if (rnd < dens) {
self->buffer_streams[i + self->voiceCount++ * self->bufsize] = 1.0;
if (self->voiceCount == self->poly)
self->voiceCount = 0;
- }
+ }
}
}
@@ -1042,17 +1042,17 @@ MYFLT *
Clouder_getSamplesBuffer(Clouder *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
Clouder_setProcMode(Clouder *self)
{
int procmode = self->modebuffer[0];
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Clouder_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Clouder_generate_a;
break;
}
@@ -1061,23 +1061,23 @@ Clouder_setProcMode(Clouder *self)
static void
Clouder_compute_next_data_frame(Clouder *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
Clouder_traverse(Clouder *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->density);
- Py_VISIT(self->density_stream);
+ Py_VISIT(self->density);
+ Py_VISIT(self->density_stream);
return 0;
}
-static int
+static int
Clouder_clear(Clouder *self)
{
pyo_CLEAR
- Py_CLEAR(self->density);
+ Py_CLEAR(self->density);
Py_CLEAR(self->density_stream);
return 0;
}
@@ -1098,35 +1098,35 @@ Clouder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *densitytmp=NULL;
Clouder *self;
self = (Clouder *)type->tp_alloc(type, 0);
-
+
self->density = PyFloat_FromDouble(10.0);
self->poly = 1;
self->voiceCount = 0;
self->modebuffer[0] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Clouder_compute_next_data_frame);
self->mode_func_ptr = Clouder_setProcMode;
-
+
Stream_setStreamActive(self->stream, 0);
static char *kwlist[] = {"density", "poly", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", kwlist, &densitytmp, &self->poly))
Py_RETURN_NONE;
-
+
if (densitytmp) {
PyObject_CallMethod((PyObject *)self, "setDensity", "O", densitytmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
Server_generateSeed((Server *)self->server, CLOUD_ID);
self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
-
+
return (PyObject *)self;
}
@@ -1140,14 +1140,14 @@ static PyObject *
Clouder_setDensity(Clouder *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->density);
@@ -1163,12 +1163,12 @@ Clouder_setDensity(Clouder *self, PyObject *arg)
self->density_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Clouder_members[] = {
{"server", T_OBJECT_EX, offsetof(Clouder, server), 0, "Pyo server."},
@@ -1234,7 +1234,7 @@ Clouder_new, /* tp_new */
typedef struct {
pyo_audio_HEAD
Clouder *mainPlayer;
- int chnl;
+ int chnl;
int modebuffer[2];
} Cloud;
@@ -1252,36 +1252,36 @@ static void
Cloud_setProcMode(Cloud *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Cloud_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Cloud_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Cloud_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Cloud_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Cloud_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Cloud_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Cloud_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Cloud_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Cloud_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -1293,7 +1293,7 @@ Cloud_compute_next_data_frame(Cloud *self)
tmp = Clouder_getSamplesBuffer((Clouder *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -1305,11 +1305,11 @@ Cloud_traverse(Cloud *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Cloud_clear(Cloud *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -1328,37 +1328,37 @@ Cloud_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL;
Cloud *self;
self = (Cloud *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Cloud_compute_next_data_frame);
self->mode_func_ptr = Cloud_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (Clouder *)maintmp;
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Cloud_getServer(Cloud* self) { GET_SERVER };
static PyObject * Cloud_getStream(Cloud* self) { GET_STREAM };
-static PyObject * Cloud_setMul(Cloud *self, PyObject *arg) { SET_MUL };
-static PyObject * Cloud_setAdd(Cloud *self, PyObject *arg) { SET_ADD };
-static PyObject * Cloud_setSub(Cloud *self, PyObject *arg) { SET_SUB };
-static PyObject * Cloud_setDiv(Cloud *self, PyObject *arg) { SET_DIV };
+static PyObject * Cloud_setMul(Cloud *self, PyObject *arg) { SET_MUL };
+static PyObject * Cloud_setAdd(Cloud *self, PyObject *arg) { SET_ADD };
+static PyObject * Cloud_setSub(Cloud *self, PyObject *arg) { SET_SUB };
+static PyObject * Cloud_setDiv(Cloud *self, PyObject *arg) { SET_DIV };
static PyObject * Cloud_play(Cloud *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Cloud_out(Cloud *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1390,7 +1390,7 @@ static PyMethodDef Cloud_methods[] = {
{"setMul", (PyCFunction)Cloud_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)Cloud_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)Cloud_setSub, METH_O, "Sets inverse add factor."},
-{"setDiv", (PyCFunction)Cloud_setDiv, METH_O, "Sets inverse mul factor."},
+{"setDiv", (PyCFunction)Cloud_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -1502,36 +1502,36 @@ Trig_setProcMode(Trig *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Trig_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Trig_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Trig_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Trig_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Trig_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Trig_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Trig_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Trig_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Trig_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -1540,7 +1540,7 @@ Trig_compute_next_data_frame(Trig *self)
if (self->flag == 1) {
self->data[0] = 1.0;
self->flag = 0;
- }
+ }
else
self->data[0] = 0.0;
(*self->muladd_func_ptr)(self);
@@ -1553,7 +1553,7 @@ Trig_traverse(Trig *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Trig_clear(Trig *self)
{
pyo_CLEAR
@@ -1574,38 +1574,38 @@ Trig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
int i;
Trig *self;
self = (Trig *)type->tp_alloc(type, 0);
-
+
self->flag = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Trig_compute_next_data_frame);
self->mode_func_ptr = Trig_setProcMode;
static char *kwlist[] = {NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist))
Py_RETURN_NONE;
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Trig_getServer(Trig* self) { GET_SERVER };
static PyObject * Trig_getStream(Trig* self) { GET_STREAM };
-static PyObject * Trig_setMul(Trig *self, PyObject *arg) { SET_MUL };
-static PyObject * Trig_setAdd(Trig *self, PyObject *arg) { SET_ADD };
-static PyObject * Trig_setSub(Trig *self, PyObject *arg) { SET_SUB };
-static PyObject * Trig_setDiv(Trig *self, PyObject *arg) { SET_DIV };
+static PyObject * Trig_setMul(Trig *self, PyObject *arg) { SET_MUL };
+static PyObject * Trig_setAdd(Trig *self, PyObject *arg) { SET_ADD };
+static PyObject * Trig_setSub(Trig *self, PyObject *arg) { SET_SUB };
+static PyObject * Trig_setDiv(Trig *self, PyObject *arg) { SET_DIV };
-static PyObject * Trig_play(Trig *self, PyObject *args, PyObject *kwds)
-{
+static PyObject * Trig_play(Trig *self, PyObject *args, PyObject *kwds)
+{
self->flag = 1;
- PLAY
+ PLAY
};
static PyObject * Trig_stop(Trig *self) { STOP };
@@ -1780,7 +1780,7 @@ Beater_defineAccent(int n) {
return 0.5;
}
-static void
+static void
Beater_restore(Beater *self) {
int i;
self->fillEnd = 0;
@@ -1789,9 +1789,9 @@ Beater_restore(Beater *self) {
self->sequence[i] = self->tmp_sequence[i];
self->durations[i] = self->tmp_durations[i];
}
-}
-
-static void
+}
+
+static void
Beater_makeTable(Beater *self, int fill) {
short i;
short len;
@@ -1813,25 +1813,25 @@ Beater_makeTable(Beater *self, int fill) {
self->tmp_accentTable[i] = self->accentTable[i];
self->tmp_sequence[i] = self->sequence[i];
self->tmp_durations[i] = self->durations[i];
- }
+ }
}
-
+
if ((self->taps % 7) == 0) {
len = 7;
for (i=0; i < self->taps; i++) {
if ((i % len) == 4 || (i % len) == 2) {
self->tapProb[i] = w2;
self->accentTable[i] = Beater_defineAccent(2);
- }
+ }
else if ((i % len) == 0) {
self->tapProb[i] = w1;
self->accentTable[i] = Beater_defineAccent(1);
- }
+ }
else {
self->tapProb[i] = w3;
self->accentTable[i] = Beater_defineAccent(3);
- }
- }
+ }
+ }
}
else if ((self->taps % 6) == 0) {
len = 6;
@@ -1839,7 +1839,7 @@ Beater_makeTable(Beater *self, int fill) {
if ((i % len) == 3) {
self->tapProb[i] = w2;
self->accentTable[i] = Beater_defineAccent(2);
- }
+ }
else if ((i % len) == 0) {
self->tapProb[i] = w1;
self->accentTable[i] = Beater_defineAccent(1);
@@ -1847,8 +1847,8 @@ Beater_makeTable(Beater *self, int fill) {
else {
self->tapProb[i] = w3;
self->accentTable[i] = Beater_defineAccent(3);
- }
- }
+ }
+ }
}
else if ((self->taps % 5) == 0) {
len = 5;
@@ -1856,7 +1856,7 @@ Beater_makeTable(Beater *self, int fill) {
if ((i % len) == 3) {
self->tapProb[i] = w2;
self->accentTable[i] = Beater_defineAccent(2);
- }
+ }
else if ((i % len) == 0) {
self->tapProb[i] = w1;
self->accentTable[i] = Beater_defineAccent(1);
@@ -1864,25 +1864,25 @@ Beater_makeTable(Beater *self, int fill) {
else {
self->tapProb[i] = w3;
self->accentTable[i] = Beater_defineAccent(3);
- }
- }
+ }
+ }
}
else if ((self->taps % 4) == 0) {
len = 4;
- for (i=0; i < self->taps; i++) {
+ for (i=0; i < self->taps; i++) {
if ((i % len) == 2) {
self->tapProb[i] = w2;
self->accentTable[i] = Beater_defineAccent(2);
- }
+ }
else if ((i % len) == 0) {
self->tapProb[i] = w1;
self->accentTable[i] = Beater_defineAccent(1);
- }
+ }
else {
self->tapProb[i] = w3;
self->accentTable[i] = Beater_defineAccent(3);
- }
- }
+ }
+ }
}
else if ((self->taps % 3) == 0) {
len = 3;
@@ -1894,8 +1894,8 @@ Beater_makeTable(Beater *self, int fill) {
else {
self->tapProb[i] = w3;
self->accentTable[i] = Beater_defineAccent(3);
- }
- }
+ }
+ }
}
else if ((self->taps % 2) == 0) {
len = 2;
@@ -1907,22 +1907,22 @@ Beater_makeTable(Beater *self, int fill) {
else {
self->tapProb[i] = w3;
self->accentTable[i] = Beater_defineAccent(3);
- }
- }
- }
+ }
+ }
+ }
}
-static void
+static void
Beater_makeSequence(Beater *self) {
short i, j;
-
+
j = 0;
for (i=0; i < self->taps; i++) {
if ((rand() % 100) < self->tapProb[i]) {
self->sequence[i] = 1;
self->tapList[j++] = i;
- }
- else
+ }
+ else
self->sequence[i] = 0;
}
@@ -1932,7 +1932,7 @@ Beater_makeSequence(Beater *self) {
static void
Beater_calculateDurations(Beater *self) {
int i;
-
+
for (i=0; i < (self->tapLength-1); i++) {
self->durations[self->tapList[i]] = (self->tapList[i+1] - self->tapList[i]) * self->tapDur - 0.005;
}
@@ -1940,24 +1940,24 @@ Beater_calculateDurations(Beater *self) {
}
static void
-Beater_makePresetActive(Beater *self, int n)
+Beater_makePresetActive(Beater *self, int n)
{
int i, j, len;
-
+
self->preCall = -1;
len = self->preset[n][0];
if (len != self->taps) {
self->taps = len;
Beater_makeTable(self, 0);
}
-
+
j = 0;
for (i=0; i<self->taps; i++) {
self->sequence[i] = self->preset[n][i+1];
if (self->sequence[i] == 1)
self->tapList[j++] = i;
}
-
+
self->tapLength = j;
}
@@ -1965,20 +1965,20 @@ static void
Beater_generate_i(Beater *self) {
int i, j;
double tm;
-
+
tm = PyFloat_AS_DOUBLE(self->time);
-
+
self->tapDur = (MYFLT)tm;
Beater_calculateDurations(self);
if (self->currentTime == -1.0) {
self->currentTime = tm;
- }
-
+ }
+
for (i=0; i<(self->poly*self->bufsize); i++) {
self->buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
}
-
+
for (i=0; i<self->bufsize; i++) {
self->tap_buffer_streams[i + self->voiceCount * self->bufsize] = (MYFLT)self->currentTap;
for (j=0; j<self->poly; j++) {
@@ -1987,7 +1987,7 @@ Beater_generate_i(Beater *self) {
self->dur_buffer_streams[i + self->voiceCount * self->bufsize] = self->durations[self->tapCount];
if (self->currentTime >= tm) {
self->currentTime -= tm;
- if (self->tapCount == (self->last_taps-1))
+ if (self->tapCount == (self->last_taps-2))
self->end_buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
if (self->sequence[self->tapCount] == 1) {
self->currentTap = self->tapCount;
@@ -2007,11 +2007,11 @@ Beater_generate_i(Beater *self) {
Beater_restore(self);
Beater_makeTable(self, 0);
Beater_makeSequence(self);
- }
+ }
else if (self->fillEnd == 1 && self->preCall != -1) {
Beater_restore(self);
Beater_makePresetActive(self, self->preCall);
- }
+ }
else if (self->fillEnd == 1) {
Beater_restore(self);
}
@@ -2023,7 +2023,7 @@ Beater_generate_i(Beater *self) {
self->newFlag == 1) {
Beater_makeTable(self, 0);
Beater_makeSequence(self);
- }
+ }
}
}
self->currentTime += self->sampleToSec;
@@ -2034,7 +2034,7 @@ static void
Beater_generate_a(Beater *self) {
double tm;
int i, j;
-
+
MYFLT *time = Stream_getData((Stream *)self->time_stream);
self->tapDur = time[0];
@@ -2042,12 +2042,12 @@ Beater_generate_a(Beater *self) {
if (self->currentTime == -1.0) {
self->currentTime = (double)time[0];
- }
-
+ }
+
for (i=0; i<(self->poly*self->bufsize); i++) {
self->buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
}
-
+
for (i=0; i<self->bufsize; i++) {
tm = (double)time[i];
self->tap_buffer_streams[i + self->voiceCount * self->bufsize] = (MYFLT)self->currentTap;
@@ -2057,7 +2057,7 @@ Beater_generate_a(Beater *self) {
self->dur_buffer_streams[i + self->voiceCount * self->bufsize] = self->durations[self->tapCount];
if (self->currentTime >= tm) {
self->currentTime -= tm;
- if (self->tapCount == (self->last_taps-1))
+ if (self->tapCount == (self->last_taps-2))
self->end_buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
if (self->sequence[self->tapCount] == 1) {
self->currentTap = self->tapCount;
@@ -2081,7 +2081,7 @@ Beater_generate_a(Beater *self) {
else if (self->fillEnd == 1 && self->preCall != -1) {
Beater_restore(self);
Beater_makePresetActive(self, self->preCall);
- }
+ }
else if (self->fillEnd == 1) {
Beater_restore(self);
}
@@ -2094,7 +2094,7 @@ Beater_generate_a(Beater *self) {
self->tapDur = time[i];
Beater_makeTable(self, 0);
Beater_makeSequence(self);
- }
+ }
}
}
self->currentTime += self->sampleToSec;
@@ -2105,41 +2105,41 @@ MYFLT *
Beater_getSamplesBuffer(Beater *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
MYFLT *
Beater_getTapBuffer(Beater *self)
{
return (MYFLT *)self->tap_buffer_streams;
-}
+}
MYFLT *
Beater_getAmpBuffer(Beater *self)
{
return (MYFLT *)self->amp_buffer_streams;
-}
+}
MYFLT *
Beater_getDurBuffer(Beater *self)
{
return (MYFLT *)self->dur_buffer_streams;
-}
+}
MYFLT *
Beater_getEndBuffer(Beater *self)
{
return (MYFLT *)self->end_buffer_streams;
-}
+}
static void
Beater_setProcMode(Beater *self)
{
int procmode = self->modebuffer[0];
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Beater_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Beater_generate_a;
break;
}
@@ -2148,23 +2148,23 @@ Beater_setProcMode(Beater *self)
static void
Beater_compute_next_data_frame(Beater *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
Beater_traverse(Beater *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->time);
- Py_VISIT(self->time_stream);
+ Py_VISIT(self->time);
+ Py_VISIT(self->time_stream);
return 0;
}
-static int
+static int
Beater_clear(Beater *self)
{
pyo_CLEAR
- Py_CLEAR(self->time);
+ Py_CLEAR(self->time);
Py_CLEAR(self->time_stream);
return 0;
}
@@ -2190,20 +2190,20 @@ Beater_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *timetmp=NULL;
Beater *self;
self = (Beater *)type->tp_alloc(type, 0);
-
+
for (i=0; i<32; i++) {
for (j=0; j<64; j++) {
self->preset[i][j] = 0;
}
}
-
+
self->preCall = -1;
self->time = PyFloat_FromDouble(0.125);
self->tapDur = 0.125;
self->poly = 1;
self->voiceCount = 0;
self->modebuffer[0] = 0;
-
+
self->taps = 16;
self->tapCount = 0;
self->currentTap = 0;
@@ -2213,31 +2213,31 @@ Beater_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->last_taps = self->last_weight1 = self->last_weight2 = self->last_weight3 = -1;
self->newFlag = self->fillStart = self->fillEnd = 0;
self->tapLength = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Beater_compute_next_data_frame);
self->mode_func_ptr = Beater_setProcMode;
-
+
self->sampleToSec = 1. / self->sr;
self->currentTime = -1.0;
Stream_setStreamActive(self->stream, 0);
static char *kwlist[] = {"time", "taps", "weight1", "weight2", "weight3", "poly", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oiiiii", kwlist, &timetmp, &self->taps, &self->weight1, &self->weight2, &self->weight3, &self->poly))
Py_RETURN_NONE;
-
+
if (timetmp) {
PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
Server_generateSeed((Server *)self->server, BEATER_ID);
-
+
self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
self->tap_buffer_streams = (MYFLT *)realloc(self->tap_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
self->amp_buffer_streams = (MYFLT *)realloc(self->amp_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
@@ -2247,13 +2247,13 @@ Beater_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->buffer_streams[i] = self->tap_buffer_streams[i] = self->amp_buffer_streams[i] = self->dur_buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
}
self->amplitudes = (MYFLT *)realloc(self->amplitudes, self->poly * sizeof(MYFLT));
- for (i=0; i<self->poly; i++) {
+ for (i=0; i<self->poly; i++) {
self->amplitudes[i] = 0.0;
}
-
+
Beater_makeTable(self, 0);
Beater_makeSequence(self);
-
+
return (PyObject *)self;
}
@@ -2267,14 +2267,14 @@ static PyObject *
Beater_setTime(Beater *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->time);
@@ -2293,35 +2293,46 @@ Beater_setTime(Beater *self, PyObject *arg)
MYFLT *time = Stream_getData((Stream *)self->time_stream);
self->tapDur = time[0];
}
-
+
(*self->mode_func_ptr)(self);
-
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+Beater_reset(Beater *self)
+{
+ self->voiceCount = 0;
+ self->tapCount = 0;
+ self->currentTap = 0;
+ self->currentTime = -1.0;
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Beater_setTaps(Beater *self, PyObject *arg)
-{
+{
if (PyInt_Check(arg))
self->taps = PyInt_AS_LONG(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Beater_setWeights(Beater *self, PyObject *args, PyObject *kwds)
-{
+{
PyObject *w1=NULL, *w2=NULL, *w3=NULL;
-
+
static char *kwlist[] = {"weight1", "weight2", "weight3", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", kwlist, &w1, &w2, &w3)) {
Py_INCREF(Py_None);
return Py_None;
- }
-
+ }
+
if (PyInt_Check(w1))
self->weight1 = PyInt_AS_LONG(w1);
@@ -2333,11 +2344,11 @@ Beater_setWeights(Beater *self, PyObject *args, PyObject *kwds)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Beater_newPattern(Beater *self)
-{
+{
self->newFlag = 1;
Py_INCREF(Py_None);
return Py_None;
@@ -2345,7 +2356,7 @@ Beater_newPattern(Beater *self)
static PyObject *
Beater_fillPattern(Beater *self)
-{
+{
self->fillStart = 1;
Py_INCREF(Py_None);
return Py_None;
@@ -2355,17 +2366,17 @@ static PyObject *
Beater_storePreset(Beater *self, PyObject *arg)
{
int i, n;
-
+
if (PyInt_Check(arg)) {
n = PyInt_AS_LONG(arg);
self->preset[n][0] = self->taps;
for (i=0; i<self->taps; i++) {
self->preset[n][i+1] = self->sequence[i];
- }
+ }
}
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
}
static PyObject *
@@ -2377,32 +2388,32 @@ Beater_recallPreset(Beater *self, PyObject *arg)
if (x >= 0 && x < 32)
self->preCall = x;
}
-
+
if (Stream_getStreamActive(self->stream) == 0)
Beater_makePresetActive(self, self->preCall);
-
+
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
-}
+}
static PyObject *
Beater_getPresets(Beater *self) {
int i, j;
PyObject *list, *tmp;
-
+
list = PyList_New(0);
for (i=0; i<32; i++) {
if (self->preset[i][0] != 0) {
tmp = PyList_New(0);
- PyList_Append(tmp, PyInt_FromLong(self->preset[i][0]));
+ PyList_Append(tmp, PyInt_FromLong(self->preset[i][0]));
for (j=0; j<self->preset[i][0]; j++) {
PyList_Append(tmp, PyInt_FromLong(self->preset[i][j+1]));
}
PyList_Append(list, tmp);
}
}
-
+
return list;
}
@@ -2418,14 +2429,14 @@ Beater_setPresets(Beater *self, PyObject *arg) {
if (PyList_Check(tmp)) {
len2 = PyInt_AsLong(PyList_GetItem(tmp, 0));
self->preset[i][0] = len2;
- for (j=0; j<len2; j++) {
+ for (j=0; j<len2; j++) {
self->preset[i][j+1] = PyInt_AsLong(PyList_GetItem(tmp, j+1));
}
}
}
- }
+ }
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
}
static PyMemberDef Beater_members[] = {
@@ -2449,6 +2460,7 @@ static PyMethodDef Beater_methods[] = {
{"recall", (PyCFunction)Beater_recallPreset, METH_O, "Recall a pattern previously stored in a memory slot."},
{"getPresets", (PyCFunction)Beater_getPresets, METH_NOARGS, "Returns the list of stored presets."},
{"setPresets", (PyCFunction)Beater_setPresets, METH_O, "Store a list of presets."},
+ {"reset", (PyCFunction)Beater_reset, METH_NOARGS, "Resets counters to 0."},
{NULL} /* Sentinel */
};
@@ -2500,7 +2512,7 @@ PyTypeObject BeaterType = {
typedef struct {
pyo_audio_HEAD
Beater *mainPlayer;
- int chnl;
+ int chnl;
int modebuffer[2];
} Beat;
@@ -2518,36 +2530,36 @@ static void
Beat_setProcMode(Beat *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Beat_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Beat_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Beat_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Beat_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Beat_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Beat_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Beat_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Beat_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Beat_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -2559,7 +2571,7 @@ Beat_compute_next_data_frame(Beat *self)
tmp = Beater_getSamplesBuffer((Beater *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -2571,11 +2583,11 @@ Beat_traverse(Beat *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Beat_clear(Beat *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -2594,37 +2606,37 @@ Beat_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL;
Beat *self;
self = (Beat *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Beat_compute_next_data_frame);
self->mode_func_ptr = Beat_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (Beater *)maintmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Beat_getServer(Beat* self) { GET_SERVER };
static PyObject * Beat_getStream(Beat* self) { GET_STREAM };
-static PyObject * Beat_setMul(Beat *self, PyObject *arg) { SET_MUL };
-static PyObject * Beat_setAdd(Beat *self, PyObject *arg) { SET_ADD };
-static PyObject * Beat_setSub(Beat *self, PyObject *arg) { SET_SUB };
-static PyObject * Beat_setDiv(Beat *self, PyObject *arg) { SET_DIV };
+static PyObject * Beat_setMul(Beat *self, PyObject *arg) { SET_MUL };
+static PyObject * Beat_setAdd(Beat *self, PyObject *arg) { SET_ADD };
+static PyObject * Beat_setSub(Beat *self, PyObject *arg) { SET_SUB };
+static PyObject * Beat_setDiv(Beat *self, PyObject *arg) { SET_DIV };
static PyObject * Beat_play(Beat *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Beat_out(Beat *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2750,7 +2762,7 @@ PyTypeObject BeatType = {
typedef struct {
pyo_audio_HEAD
Beater *mainPlayer;
- int chnl;
+ int chnl;
int modebuffer[2];
} BeatTapStream;
@@ -2768,36 +2780,36 @@ static void
BeatTapStream_setProcMode(BeatTapStream *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = BeatTapStream_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = BeatTapStream_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = BeatTapStream_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = BeatTapStream_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = BeatTapStream_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = BeatTapStream_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = BeatTapStream_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = BeatTapStream_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = BeatTapStream_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -2809,7 +2821,7 @@ BeatTapStream_compute_next_data_frame(BeatTapStream *self)
tmp = Beater_getTapBuffer((Beater *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -2821,11 +2833,11 @@ BeatTapStream_traverse(BeatTapStream *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
BeatTapStream_clear(BeatTapStream *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -2844,37 +2856,37 @@ BeatTapStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL;
BeatTapStream *self;
self = (BeatTapStream *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, BeatTapStream_compute_next_data_frame);
self->mode_func_ptr = BeatTapStream_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (Beater *)maintmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * BeatTapStream_getServer(BeatTapStream* self) { GET_SERVER };
static PyObject * BeatTapStream_getStream(BeatTapStream* self) { GET_STREAM };
-static PyObject * BeatTapStream_setMul(BeatTapStream *self, PyObject *arg) { SET_MUL };
-static PyObject * BeatTapStream_setAdd(BeatTapStream *self, PyObject *arg) { SET_ADD };
-static PyObject * BeatTapStream_setSub(BeatTapStream *self, PyObject *arg) { SET_SUB };
-static PyObject * BeatTapStream_setDiv(BeatTapStream *self, PyObject *arg) { SET_DIV };
+static PyObject * BeatTapStream_setMul(BeatTapStream *self, PyObject *arg) { SET_MUL };
+static PyObject * BeatTapStream_setAdd(BeatTapStream *self, PyObject *arg) { SET_ADD };
+static PyObject * BeatTapStream_setSub(BeatTapStream *self, PyObject *arg) { SET_SUB };
+static PyObject * BeatTapStream_setDiv(BeatTapStream *self, PyObject *arg) { SET_DIV };
static PyObject * BeatTapStream_play(BeatTapStream *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * BeatTapStream_out(BeatTapStream *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2906,7 +2918,7 @@ static PyMethodDef BeatTapStream_methods[] = {
{"setMul", (PyCFunction)BeatTapStream_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)BeatTapStream_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)BeatTapStream_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)BeatTapStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {"setDiv", (PyCFunction)BeatTapStream_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -3000,7 +3012,7 @@ PyTypeObject BeatTapStreamType = {
typedef struct {
pyo_audio_HEAD
Beater *mainPlayer;
- int chnl;
+ int chnl;
int modebuffer[2];
} BeatAmpStream;
@@ -3018,36 +3030,36 @@ static void
BeatAmpStream_setProcMode(BeatAmpStream *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = BeatAmpStream_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = BeatAmpStream_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = BeatAmpStream_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = BeatAmpStream_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = BeatAmpStream_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = BeatAmpStream_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = BeatAmpStream_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = BeatAmpStream_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = BeatAmpStream_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -3059,7 +3071,7 @@ BeatAmpStream_compute_next_data_frame(BeatAmpStream *self)
tmp = Beater_getAmpBuffer((Beater *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -3071,11 +3083,11 @@ BeatAmpStream_traverse(BeatAmpStream *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
BeatAmpStream_clear(BeatAmpStream *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -3094,37 +3106,37 @@ BeatAmpStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL;
BeatAmpStream *self;
self = (BeatAmpStream *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, BeatAmpStream_compute_next_data_frame);
self->mode_func_ptr = BeatAmpStream_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (Beater *)maintmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * BeatAmpStream_getServer(BeatAmpStream* self) { GET_SERVER };
static PyObject * BeatAmpStream_getStream(BeatAmpStream* self) { GET_STREAM };
-static PyObject * BeatAmpStream_setMul(BeatAmpStream *self, PyObject *arg) { SET_MUL };
-static PyObject * BeatAmpStream_setAdd(BeatAmpStream *self, PyObject *arg) { SET_ADD };
-static PyObject * BeatAmpStream_setSub(BeatAmpStream *self, PyObject *arg) { SET_SUB };
-static PyObject * BeatAmpStream_setDiv(BeatAmpStream *self, PyObject *arg) { SET_DIV };
+static PyObject * BeatAmpStream_setMul(BeatAmpStream *self, PyObject *arg) { SET_MUL };
+static PyObject * BeatAmpStream_setAdd(BeatAmpStream *self, PyObject *arg) { SET_ADD };
+static PyObject * BeatAmpStream_setSub(BeatAmpStream *self, PyObject *arg) { SET_SUB };
+static PyObject * BeatAmpStream_setDiv(BeatAmpStream *self, PyObject *arg) { SET_DIV };
static PyObject * BeatAmpStream_play(BeatAmpStream *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * BeatAmpStream_out(BeatAmpStream *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3156,7 +3168,7 @@ static PyMethodDef BeatAmpStream_methods[] = {
{"setMul", (PyCFunction)BeatAmpStream_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)BeatAmpStream_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)BeatAmpStream_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)BeatAmpStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {"setDiv", (PyCFunction)BeatAmpStream_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -3250,7 +3262,7 @@ PyTypeObject BeatAmpStreamType = {
typedef struct {
pyo_audio_HEAD
Beater *mainPlayer;
- int chnl;
+ int chnl;
int modebuffer[2];
} BeatDurStream;
@@ -3268,36 +3280,36 @@ static void
BeatDurStream_setProcMode(BeatDurStream *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = BeatDurStream_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = BeatDurStream_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = BeatDurStream_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = BeatDurStream_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = BeatDurStream_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = BeatDurStream_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = BeatDurStream_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = BeatDurStream_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = BeatDurStream_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -3309,7 +3321,7 @@ BeatDurStream_compute_next_data_frame(BeatDurStream *self)
tmp = Beater_getDurBuffer((Beater *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -3321,11 +3333,11 @@ BeatDurStream_traverse(BeatDurStream *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
BeatDurStream_clear(BeatDurStream *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -3344,37 +3356,37 @@ BeatDurStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL;
BeatDurStream *self;
self = (BeatDurStream *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, BeatDurStream_compute_next_data_frame);
self->mode_func_ptr = BeatDurStream_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (Beater *)maintmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * BeatDurStream_getServer(BeatDurStream* self) { GET_SERVER };
static PyObject * BeatDurStream_getStream(BeatDurStream* self) { GET_STREAM };
-static PyObject * BeatDurStream_setMul(BeatDurStream *self, PyObject *arg) { SET_MUL };
-static PyObject * BeatDurStream_setAdd(BeatDurStream *self, PyObject *arg) { SET_ADD };
-static PyObject * BeatDurStream_setSub(BeatDurStream *self, PyObject *arg) { SET_SUB };
-static PyObject * BeatDurStream_setDiv(BeatDurStream *self, PyObject *arg) { SET_DIV };
+static PyObject * BeatDurStream_setMul(BeatDurStream *self, PyObject *arg) { SET_MUL };
+static PyObject * BeatDurStream_setAdd(BeatDurStream *self, PyObject *arg) { SET_ADD };
+static PyObject * BeatDurStream_setSub(BeatDurStream *self, PyObject *arg) { SET_SUB };
+static PyObject * BeatDurStream_setDiv(BeatDurStream *self, PyObject *arg) { SET_DIV };
static PyObject * BeatDurStream_play(BeatDurStream *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * BeatDurStream_out(BeatDurStream *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3500,7 +3512,7 @@ PyTypeObject BeatDurStreamType = {
typedef struct {
pyo_audio_HEAD
Beater *mainPlayer;
- int chnl;
+ int chnl;
int modebuffer[2];
} BeatEndStream;
@@ -3518,36 +3530,36 @@ static void
BeatEndStream_setProcMode(BeatEndStream *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = BeatEndStream_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = BeatEndStream_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = BeatEndStream_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = BeatEndStream_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = BeatEndStream_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = BeatEndStream_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = BeatEndStream_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = BeatEndStream_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = BeatEndStream_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -3559,7 +3571,7 @@ BeatEndStream_compute_next_data_frame(BeatEndStream *self)
tmp = Beater_getEndBuffer((Beater *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -3571,11 +3583,11 @@ BeatEndStream_traverse(BeatEndStream *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
BeatEndStream_clear(BeatEndStream *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -3594,37 +3606,37 @@ BeatEndStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL;
BeatEndStream *self;
self = (BeatEndStream *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, BeatEndStream_compute_next_data_frame);
self->mode_func_ptr = BeatEndStream_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (Beater *)maintmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * BeatEndStream_getServer(BeatEndStream* self) { GET_SERVER };
static PyObject * BeatEndStream_getStream(BeatEndStream* self) { GET_STREAM };
-static PyObject * BeatEndStream_setMul(BeatEndStream *self, PyObject *arg) { SET_MUL };
-static PyObject * BeatEndStream_setAdd(BeatEndStream *self, PyObject *arg) { SET_ADD };
-static PyObject * BeatEndStream_setSub(BeatEndStream *self, PyObject *arg) { SET_SUB };
-static PyObject * BeatEndStream_setDiv(BeatEndStream *self, PyObject *arg) { SET_DIV };
+static PyObject * BeatEndStream_setMul(BeatEndStream *self, PyObject *arg) { SET_MUL };
+static PyObject * BeatEndStream_setAdd(BeatEndStream *self, PyObject *arg) { SET_ADD };
+static PyObject * BeatEndStream_setSub(BeatEndStream *self, PyObject *arg) { SET_SUB };
+static PyObject * BeatEndStream_setDiv(BeatEndStream *self, PyObject *arg) { SET_DIV };
static PyObject * BeatEndStream_play(BeatEndStream *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * BeatEndStream_out(BeatEndStream *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3656,7 +3668,7 @@ static PyMethodDef BeatEndStream_methods[] = {
{"setMul", (PyCFunction)BeatEndStream_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)BeatEndStream_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)BeatEndStream_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)BeatEndStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {"setDiv", (PyCFunction)BeatEndStream_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -3743,3 +3755,1582 @@ PyTypeObject BeatEndStreamType = {
0, /* tp_alloc */
BeatEndStream_new, /* tp_new */
};
+
+/****************/
+/**** TrigBurster *****/
+/****************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ int modebuffer[1];
+ int poly;
+ int voiceCount;
+ MYFLT time;
+ MYFLT a_time;
+ int count;
+ int a_count;
+ MYFLT expand;
+ MYFLT a_expand;
+ MYFLT ampfade;
+ MYFLT a_ampfade;
+ int flag;
+ double sampleToSec;
+ double currentTime;
+ double targetTime;
+ int currentCount;
+ int *currentTap;
+ MYFLT *currentAmp;
+ MYFLT *currentDur;
+ MYFLT *buffer_streams;
+ MYFLT *tap_buffer_streams;
+ MYFLT *amp_buffer_streams;
+ MYFLT *dur_buffer_streams;
+ MYFLT *end_buffer_streams;
+} TrigBurster;
+
+static void
+TrigBurster_generate_i(TrigBurster *self) {
+ int i, j;
+
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+
+ for (i=0; i<(self->poly*self->bufsize); i++) {
+ self->buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
+ }
+
+ for (i=0; i<self->bufsize; i++) {
+ if (in[i] == 1.0) {
+ self->flag = 1;
+ self->currentCount = 0;
+ self->a_time = self->targetTime = self->currentTime = self->time;
+ self->a_count = self->count;
+ self->a_expand = self->expand;
+ self->a_ampfade = self->ampfade;
+ }
+ if (self->flag == 1) {
+ if (self->currentTime >= self->targetTime) {
+ self->currentTime -= self->targetTime;
+ self->targetTime = self->a_time * MYPOW(self->a_expand, self->currentCount);
+ self->currentTap[self->voiceCount] = self->currentCount;
+ self->currentAmp[self->voiceCount] = MYPOW(self->a_ampfade, self->currentCount);
+ self->currentDur[self->voiceCount] = self->targetTime;
+ self->buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
+ self->currentCount++;
+ if (self->currentCount == (self->a_count - 1))
+ self->end_buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
+ if (self->currentCount == self->a_count)
+ self->flag = 0;
+ self->voiceCount++;
+ if (self->voiceCount == self->poly)
+ self->voiceCount = 0;
+ }
+ self->currentTime += self->sampleToSec;
+ }
+ for (j=0; j<self->poly; j++) {
+ self->tap_buffer_streams[i + j * self->bufsize] = (MYFLT)self->currentTap[j];
+ self->amp_buffer_streams[i + j * self->bufsize] = self->currentAmp[j];
+ self->dur_buffer_streams[i + j * self->bufsize] = self->currentDur[j];
+ }
+ }
+}
+
+MYFLT *
+TrigBurster_getSamplesBuffer(TrigBurster *self)
+{
+ return (MYFLT *)self->buffer_streams;
+}
+
+MYFLT *
+TrigBurster_getTapBuffer(TrigBurster *self)
+{
+ return (MYFLT *)self->tap_buffer_streams;
+}
+
+MYFLT *
+TrigBurster_getAmpBuffer(TrigBurster *self)
+{
+ return (MYFLT *)self->amp_buffer_streams;
+}
+
+MYFLT *
+TrigBurster_getDurBuffer(TrigBurster *self)
+{
+ return (MYFLT *)self->dur_buffer_streams;
+}
+
+MYFLT *
+TrigBurster_getEndBuffer(TrigBurster *self)
+{
+ return (MYFLT *)self->end_buffer_streams;
+}
+
+static void
+TrigBurster_setProcMode(TrigBurster *self)
+{
+ self->proc_func_ptr = TrigBurster_generate_i;
+}
+
+static void
+TrigBurster_compute_next_data_frame(TrigBurster *self)
+{
+ (*self->proc_func_ptr)(self);
+}
+
+static int
+TrigBurster_traverse(TrigBurster *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ return 0;
+}
+
+static int
+TrigBurster_clear(TrigBurster *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ return 0;
+}
+
+static void
+TrigBurster_dealloc(TrigBurster* self)
+{
+ pyo_DEALLOC
+ free(self->buffer_streams);
+ free(self->tap_buffer_streams);
+ free(self->amp_buffer_streams);
+ free(self->dur_buffer_streams);
+ free(self->end_buffer_streams);
+ free(self->currentTap);
+ free(self->currentAmp);
+ free(self->currentDur);
+ TrigBurster_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+TrigBurster_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *inputtmp, *input_streamtmp;
+ TrigBurster *self;
+ self = (TrigBurster *)type->tp_alloc(type, 0);
+
+
+ self->poly = 1;
+ self->voiceCount = 0;
+ self->time = self->a_time = 0.25;
+ self->count = self->a_count = 10;
+ self->expand = self->a_expand = 1.0;
+ self->ampfade = self->a_ampfade = 1.0;
+ self->currentCount = 0;
+ self->targetTime = 0.0;
+ self->currentTime = -1.0;
+ self->flag = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, TrigBurster_compute_next_data_frame);
+ self->mode_func_ptr = TrigBurster_setProcMode;
+
+ self->sampleToSec = 1. / self->sr;
+
+ Stream_setStreamActive(self->stream, 1);
+
+ static char *kwlist[] = {"input", "time", "count", "expand", "ampfade", "poly", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FIFFI, kwlist, &inputtmp, &self->time, &self->count, &self->expand, &self->ampfade, &self->poly))
+ Py_RETURN_NONE;
+
+ INIT_INPUT_STREAM
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
+ self->tap_buffer_streams = (MYFLT *)realloc(self->tap_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
+ self->amp_buffer_streams = (MYFLT *)realloc(self->amp_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
+ self->dur_buffer_streams = (MYFLT *)realloc(self->dur_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
+ self->end_buffer_streams = (MYFLT *)realloc(self->end_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
+ for (i=0; i<(self->poly*self->bufsize); i++) {
+ self->buffer_streams[i] = self->tap_buffer_streams[i] = self->amp_buffer_streams[i] = self->dur_buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
+ }
+
+ self->currentTap = (int *)realloc(self->currentTap, self->poly * sizeof(int));
+ self->currentAmp = (MYFLT *)realloc(self->currentAmp, self->poly * sizeof(MYFLT));
+ self->currentDur = (MYFLT *)realloc(self->currentDur, self->poly * sizeof(MYFLT));
+ for (i=0; i<(self->poly); i++) {
+ self->currentTap[i] = 0;
+ self->currentAmp[i] = self->currentDur[i] = 0.0;
+ }
+
+ return (PyObject *)self;
+}
+
+static PyObject * TrigBurster_getServer(TrigBurster* self) { GET_SERVER };
+static PyObject * TrigBurster_getStream(TrigBurster* self) { GET_STREAM };
+
+static PyObject * TrigBurster_play(TrigBurster *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * TrigBurster_stop(TrigBurster *self) { STOP };
+
+static PyObject *
+TrigBurster_setTime(TrigBurster *self, PyObject *arg)
+{
+ if (PyNumber_Check(arg))
+ self->time = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
+ if (self->time <= 0.01)
+ self->time = 0.01;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+TrigBurster_setCount(TrigBurster *self, PyObject *arg)
+{
+ if (PyInt_Check(arg))
+ self->count = PyInt_AS_LONG(arg);
+ if (self->count < 1)
+ self->count = 1;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+TrigBurster_setExpand(TrigBurster *self, PyObject *arg)
+{
+ if (PyNumber_Check(arg))
+ self->expand = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
+ if (self->expand <= 0.1)
+ self->expand = 0.1;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+TrigBurster_setAmpfade(TrigBurster *self, PyObject *arg)
+{
+ if (PyNumber_Check(arg))
+ self->ampfade = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
+ if (self->ampfade <= 0.1)
+ self->ampfade = 0.1;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef TrigBurster_members[] = {
+ {"server", T_OBJECT_EX, offsetof(TrigBurster, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(TrigBurster, stream), 0, "Stream object."},
+ {"input", T_OBJECT_EX, offsetof(TrigBurster, input), 0, "Input sound object."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef TrigBurster_methods[] = {
+ {"getServer", (PyCFunction)TrigBurster_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)TrigBurster_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)TrigBurster_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"stop", (PyCFunction)TrigBurster_stop, METH_NOARGS, "Stops computing."},
+ {"setTime", (PyCFunction)TrigBurster_setTime, METH_O, "Sets the base time of the serie."},
+ {"setCount", (PyCFunction)TrigBurster_setCount, METH_O, "Sets the number of trigs in the serie."},
+ {"setExpand", (PyCFunction)TrigBurster_setExpand, METH_O, "Sets the time's expansion factor of the serie."},
+ {"setAmpfade", (PyCFunction)TrigBurster_setAmpfade, METH_O, "Sets the amplitude's expansion factor of the serie."},
+ {NULL} /* Sentinel */
+};
+
+PyTypeObject TrigBursterType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.TrigBurster_base", /*tp_name*/
+ sizeof(TrigBurster), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)TrigBurster_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "TrigBurster objects. Create an algorithmic beat sequence.", /* tp_doc */
+ (traverseproc)TrigBurster_traverse, /* tp_traverse */
+ (inquiry)TrigBurster_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ TrigBurster_methods, /* tp_methods */
+ TrigBurster_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ TrigBurster_new, /* tp_new */
+};
+
+/************************************************************************************************/
+/* TrigBurst streamer object per channel */
+/************************************************************************************************/
+typedef struct {
+ pyo_audio_HEAD
+ TrigBurster *mainPlayer;
+ int chnl;
+ int modebuffer[2];
+} TrigBurst;
+
+static void TrigBurst_postprocessing_ii(TrigBurst *self) { POST_PROCESSING_II };
+static void TrigBurst_postprocessing_ai(TrigBurst *self) { POST_PROCESSING_AI };
+static void TrigBurst_postprocessing_ia(TrigBurst *self) { POST_PROCESSING_IA };
+static void TrigBurst_postprocessing_aa(TrigBurst *self) { POST_PROCESSING_AA };
+static void TrigBurst_postprocessing_ireva(TrigBurst *self) { POST_PROCESSING_IREVA };
+static void TrigBurst_postprocessing_areva(TrigBurst *self) { POST_PROCESSING_AREVA };
+static void TrigBurst_postprocessing_revai(TrigBurst *self) { POST_PROCESSING_REVAI };
+static void TrigBurst_postprocessing_revaa(TrigBurst *self) { POST_PROCESSING_REVAA };
+static void TrigBurst_postprocessing_revareva(TrigBurst *self) { POST_PROCESSING_REVAREVA };
+
+static void
+TrigBurst_setProcMode(TrigBurst *self) {
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = TrigBurst_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = TrigBurst_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = TrigBurst_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = TrigBurst_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = TrigBurst_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = TrigBurst_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = TrigBurst_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = TrigBurst_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = TrigBurst_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+TrigBurst_compute_next_data_frame(TrigBurst *self)
+{
+ int i;
+ MYFLT *tmp;
+ int offset = self->chnl * self->bufsize;
+ tmp = TrigBurster_getSamplesBuffer((TrigBurster *)self->mainPlayer);
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = tmp[i + offset];
+ }
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+TrigBurst_traverse(TrigBurst *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->mainPlayer);
+ return 0;
+}
+
+static int
+TrigBurst_clear(TrigBurst *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->mainPlayer);
+ return 0;
+}
+
+static void
+TrigBurst_dealloc(TrigBurst* self)
+{
+ pyo_DEALLOC
+ TrigBurst_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+TrigBurst_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *maintmp=NULL;
+ TrigBurst *self;
+ self = (TrigBurst *)type->tp_alloc(type, 0);
+
+ self->chnl = 0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, TrigBurst_compute_next_data_frame);
+ self->mode_func_ptr = TrigBurst_setProcMode;
+
+ static char *kwlist[] = {"mainPlayer", "chnl", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
+ Py_RETURN_NONE;
+
+ Py_XDECREF(self->mainPlayer);
+ Py_INCREF(maintmp);
+ self->mainPlayer = (TrigBurster *)maintmp;
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * TrigBurst_getServer(TrigBurst* self) { GET_SERVER };
+static PyObject * TrigBurst_getStream(TrigBurst* self) { GET_STREAM };
+static PyObject * TrigBurst_setMul(TrigBurst *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigBurst_setAdd(TrigBurst *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigBurst_setSub(TrigBurst *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigBurst_setDiv(TrigBurst *self, PyObject *arg) { SET_DIV };
+
+static PyObject * TrigBurst_play(TrigBurst *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * TrigBurst_out(TrigBurst *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * TrigBurst_stop(TrigBurst *self) { STOP };
+
+static PyObject * TrigBurst_multiply(TrigBurst *self, PyObject *arg) { MULTIPLY };
+static PyObject * TrigBurst_inplace_multiply(TrigBurst *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * TrigBurst_add(TrigBurst *self, PyObject *arg) { ADD };
+static PyObject * TrigBurst_inplace_add(TrigBurst *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * TrigBurst_sub(TrigBurst *self, PyObject *arg) { SUB };
+static PyObject * TrigBurst_inplace_sub(TrigBurst *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * TrigBurst_div(TrigBurst *self, PyObject *arg) { DIV };
+static PyObject * TrigBurst_inplace_div(TrigBurst *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef TrigBurst_members[] = {
+ {"server", T_OBJECT_EX, offsetof(TrigBurst, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(TrigBurst, stream), 0, "Stream object."},
+ {"mul", T_OBJECT_EX, offsetof(TrigBurst, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(TrigBurst, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef TrigBurst_methods[] = {
+ {"getServer", (PyCFunction)TrigBurst_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)TrigBurst_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)TrigBurst_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)TrigBurst_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)TrigBurst_stop, METH_NOARGS, "Stops computing."},
+ {"setMul", (PyCFunction)TrigBurst_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)TrigBurst_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)TrigBurst_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)TrigBurst_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods TrigBurst_as_number = {
+ (binaryfunc)TrigBurst_add, /*nb_add*/
+ (binaryfunc)TrigBurst_sub, /*nb_subtract*/
+ (binaryfunc)TrigBurst_multiply, /*nb_multiply*/
+ (binaryfunc)TrigBurst_div, /*nb_divide*/
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_neg*/
+ 0, /*nb_pos*/
+ 0, /*(unaryfunc)array_abs,*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ 0, /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ 0, /*nb_oct*/
+ 0, /*nb_hex*/
+ (binaryfunc)TrigBurst_inplace_add, /*inplace_add*/
+ (binaryfunc)TrigBurst_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)TrigBurst_inplace_multiply, /*inplace_multiply*/
+ (binaryfunc)TrigBurst_inplace_div, /*inplace_divide*/
+ 0, /*inplace_remainder*/
+ 0, /*inplace_power*/
+ 0, /*inplace_lshift*/
+ 0, /*inplace_rshift*/
+ 0, /*inplace_and*/
+ 0, /*inplace_xor*/
+ 0, /*inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject TrigBurstType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.TrigBurst_base", /*tp_name*/
+ sizeof(TrigBurst), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)TrigBurst_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &TrigBurst_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "TrigBurst objects. Reads a channel from a TrigBurster.", /* tp_doc */
+ (traverseproc)TrigBurst_traverse, /* tp_traverse */
+ (inquiry)TrigBurst_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ TrigBurst_methods, /* tp_methods */
+ TrigBurst_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ TrigBurst_new, /* tp_new */
+};
+
+/************************************************************************************************/
+/* TrigBurstTapStream object per channel */
+/************************************************************************************************/
+typedef struct {
+ pyo_audio_HEAD
+ TrigBurster *mainPlayer;
+ int chnl;
+ int modebuffer[2];
+} TrigBurstTapStream;
+
+static void TrigBurstTapStream_postprocessing_ii(TrigBurstTapStream *self) { POST_PROCESSING_II };
+static void TrigBurstTapStream_postprocessing_ai(TrigBurstTapStream *self) { POST_PROCESSING_AI };
+static void TrigBurstTapStream_postprocessing_ia(TrigBurstTapStream *self) { POST_PROCESSING_IA };
+static void TrigBurstTapStream_postprocessing_aa(TrigBurstTapStream *self) { POST_PROCESSING_AA };
+static void TrigBurstTapStream_postprocessing_ireva(TrigBurstTapStream *self) { POST_PROCESSING_IREVA };
+static void TrigBurstTapStream_postprocessing_areva(TrigBurstTapStream *self) { POST_PROCESSING_AREVA };
+static void TrigBurstTapStream_postprocessing_revai(TrigBurstTapStream *self) { POST_PROCESSING_REVAI };
+static void TrigBurstTapStream_postprocessing_revaa(TrigBurstTapStream *self) { POST_PROCESSING_REVAA };
+static void TrigBurstTapStream_postprocessing_revareva(TrigBurstTapStream *self) { POST_PROCESSING_REVAREVA };
+
+static void
+TrigBurstTapStream_setProcMode(TrigBurstTapStream *self) {
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = TrigBurstTapStream_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = TrigBurstTapStream_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = TrigBurstTapStream_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = TrigBurstTapStream_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = TrigBurstTapStream_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = TrigBurstTapStream_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = TrigBurstTapStream_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = TrigBurstTapStream_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = TrigBurstTapStream_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+TrigBurstTapStream_compute_next_data_frame(TrigBurstTapStream *self)
+{
+ int i;
+ MYFLT *tmp;
+ int offset = self->chnl * self->bufsize;
+ tmp = TrigBurster_getTapBuffer((TrigBurster *)self->mainPlayer);
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = tmp[i + offset];
+ }
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+TrigBurstTapStream_traverse(TrigBurstTapStream *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->mainPlayer);
+ return 0;
+}
+
+static int
+TrigBurstTapStream_clear(TrigBurstTapStream *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->mainPlayer);
+ return 0;
+}
+
+static void
+TrigBurstTapStream_dealloc(TrigBurstTapStream* self)
+{
+ pyo_DEALLOC
+ TrigBurstTapStream_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+TrigBurstTapStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *maintmp=NULL;
+ TrigBurstTapStream *self;
+ self = (TrigBurstTapStream *)type->tp_alloc(type, 0);
+
+ self->chnl = 0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, TrigBurstTapStream_compute_next_data_frame);
+ self->mode_func_ptr = TrigBurstTapStream_setProcMode;
+
+ static char *kwlist[] = {"mainPlayer", "chnl", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
+ Py_RETURN_NONE;
+
+ Py_XDECREF(self->mainPlayer);
+ Py_INCREF(maintmp);
+ self->mainPlayer = (TrigBurster *)maintmp;
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * TrigBurstTapStream_getServer(TrigBurstTapStream* self) { GET_SERVER };
+static PyObject * TrigBurstTapStream_getStream(TrigBurstTapStream* self) { GET_STREAM };
+static PyObject * TrigBurstTapStream_setMul(TrigBurstTapStream *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigBurstTapStream_setAdd(TrigBurstTapStream *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigBurstTapStream_setSub(TrigBurstTapStream *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigBurstTapStream_setDiv(TrigBurstTapStream *self, PyObject *arg) { SET_DIV };
+
+static PyObject * TrigBurstTapStream_play(TrigBurstTapStream *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * TrigBurstTapStream_out(TrigBurstTapStream *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * TrigBurstTapStream_stop(TrigBurstTapStream *self) { STOP };
+
+static PyObject * TrigBurstTapStream_multiply(TrigBurstTapStream *self, PyObject *arg) { MULTIPLY };
+static PyObject * TrigBurstTapStream_inplace_multiply(TrigBurstTapStream *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * TrigBurstTapStream_add(TrigBurstTapStream *self, PyObject *arg) { ADD };
+static PyObject * TrigBurstTapStream_inplace_add(TrigBurstTapStream *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * TrigBurstTapStream_sub(TrigBurstTapStream *self, PyObject *arg) { SUB };
+static PyObject * TrigBurstTapStream_inplace_sub(TrigBurstTapStream *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * TrigBurstTapStream_div(TrigBurstTapStream *self, PyObject *arg) { DIV };
+static PyObject * TrigBurstTapStream_inplace_div(TrigBurstTapStream *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef TrigBurstTapStream_members[] = {
+ {"server", T_OBJECT_EX, offsetof(TrigBurstTapStream, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(TrigBurstTapStream, stream), 0, "Stream object."},
+ {"mul", T_OBJECT_EX, offsetof(TrigBurstTapStream, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(TrigBurstTapStream, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef TrigBurstTapStream_methods[] = {
+ {"getServer", (PyCFunction)TrigBurstTapStream_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)TrigBurstTapStream_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)TrigBurstTapStream_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)TrigBurstTapStream_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)TrigBurstTapStream_stop, METH_NOARGS, "Stops computing."},
+ {"setMul", (PyCFunction)TrigBurstTapStream_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)TrigBurstTapStream_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)TrigBurstTapStream_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)TrigBurstTapStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods TrigBurstTapStream_as_number = {
+ (binaryfunc)TrigBurstTapStream_add, /*nb_add*/
+ (binaryfunc)TrigBurstTapStream_sub, /*nb_subtract*/
+ (binaryfunc)TrigBurstTapStream_multiply, /*nb_multiply*/
+ (binaryfunc)TrigBurstTapStream_div, /*nb_divide*/
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_neg*/
+ 0, /*nb_pos*/
+ 0, /*(unaryfunc)array_abs,*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ 0, /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ 0, /*nb_oct*/
+ 0, /*nb_hex*/
+ (binaryfunc)TrigBurstTapStream_inplace_add, /*inplace_add*/
+ (binaryfunc)TrigBurstTapStream_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)TrigBurstTapStream_inplace_multiply, /*inplace_multiply*/
+ (binaryfunc)TrigBurstTapStream_inplace_div, /*inplace_divide*/
+ 0, /*inplace_remainder*/
+ 0, /*inplace_power*/
+ 0, /*inplace_lshift*/
+ 0, /*inplace_rshift*/
+ 0, /*inplace_and*/
+ 0, /*inplace_xor*/
+ 0, /*inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject TrigBurstTapStreamType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.TrigBurstTapStream_base", /*tp_name*/
+ sizeof(TrigBurstTapStream), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)TrigBurstTapStream_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &TrigBurstTapStream_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "TrigBurstTapStream objects. Reads the current tap from a TrigBurster object.", /* tp_doc */
+ (traverseproc)TrigBurstTapStream_traverse, /* tp_traverse */
+ (inquiry)TrigBurstTapStream_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ TrigBurstTapStream_methods, /* tp_methods */
+ TrigBurstTapStream_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ TrigBurstTapStream_new, /* tp_new */
+};
+
+/************************************************************************************************/
+/* TrigBurstAmpStream object per channel */
+/************************************************************************************************/
+typedef struct {
+ pyo_audio_HEAD
+ TrigBurster *mainPlayer;
+ int chnl;
+ int modebuffer[2];
+} TrigBurstAmpStream;
+
+static void TrigBurstAmpStream_postprocessing_ii(TrigBurstAmpStream *self) { POST_PROCESSING_II };
+static void TrigBurstAmpStream_postprocessing_ai(TrigBurstAmpStream *self) { POST_PROCESSING_AI };
+static void TrigBurstAmpStream_postprocessing_ia(TrigBurstAmpStream *self) { POST_PROCESSING_IA };
+static void TrigBurstAmpStream_postprocessing_aa(TrigBurstAmpStream *self) { POST_PROCESSING_AA };
+static void TrigBurstAmpStream_postprocessing_ireva(TrigBurstAmpStream *self) { POST_PROCESSING_IREVA };
+static void TrigBurstAmpStream_postprocessing_areva(TrigBurstAmpStream *self) { POST_PROCESSING_AREVA };
+static void TrigBurstAmpStream_postprocessing_revai(TrigBurstAmpStream *self) { POST_PROCESSING_REVAI };
+static void TrigBurstAmpStream_postprocessing_revaa(TrigBurstAmpStream *self) { POST_PROCESSING_REVAA };
+static void TrigBurstAmpStream_postprocessing_revareva(TrigBurstAmpStream *self) { POST_PROCESSING_REVAREVA };
+
+static void
+TrigBurstAmpStream_setProcMode(TrigBurstAmpStream *self) {
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+TrigBurstAmpStream_compute_next_data_frame(TrigBurstAmpStream *self)
+{
+ int i;
+ MYFLT *tmp;
+ int offset = self->chnl * self->bufsize;
+ tmp = TrigBurster_getAmpBuffer((TrigBurster *)self->mainPlayer);
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = tmp[i + offset];
+ }
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+TrigBurstAmpStream_traverse(TrigBurstAmpStream *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->mainPlayer);
+ return 0;
+}
+
+static int
+TrigBurstAmpStream_clear(TrigBurstAmpStream *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->mainPlayer);
+ return 0;
+}
+
+static void
+TrigBurstAmpStream_dealloc(TrigBurstAmpStream* self)
+{
+ pyo_DEALLOC
+ TrigBurstAmpStream_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+TrigBurstAmpStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *maintmp=NULL;
+ TrigBurstAmpStream *self;
+ self = (TrigBurstAmpStream *)type->tp_alloc(type, 0);
+
+ self->chnl = 0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, TrigBurstAmpStream_compute_next_data_frame);
+ self->mode_func_ptr = TrigBurstAmpStream_setProcMode;
+
+ static char *kwlist[] = {"mainPlayer", "chnl", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
+ Py_RETURN_NONE;
+
+ Py_XDECREF(self->mainPlayer);
+ Py_INCREF(maintmp);
+ self->mainPlayer = (TrigBurster *)maintmp;
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * TrigBurstAmpStream_getServer(TrigBurstAmpStream* self) { GET_SERVER };
+static PyObject * TrigBurstAmpStream_getStream(TrigBurstAmpStream* self) { GET_STREAM };
+static PyObject * TrigBurstAmpStream_setMul(TrigBurstAmpStream *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigBurstAmpStream_setAdd(TrigBurstAmpStream *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigBurstAmpStream_setSub(TrigBurstAmpStream *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigBurstAmpStream_setDiv(TrigBurstAmpStream *self, PyObject *arg) { SET_DIV };
+
+static PyObject * TrigBurstAmpStream_play(TrigBurstAmpStream *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * TrigBurstAmpStream_out(TrigBurstAmpStream *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * TrigBurstAmpStream_stop(TrigBurstAmpStream *self) { STOP };
+
+static PyObject * TrigBurstAmpStream_multiply(TrigBurstAmpStream *self, PyObject *arg) { MULTIPLY };
+static PyObject * TrigBurstAmpStream_inplace_multiply(TrigBurstAmpStream *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * TrigBurstAmpStream_add(TrigBurstAmpStream *self, PyObject *arg) { ADD };
+static PyObject * TrigBurstAmpStream_inplace_add(TrigBurstAmpStream *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * TrigBurstAmpStream_sub(TrigBurstAmpStream *self, PyObject *arg) { SUB };
+static PyObject * TrigBurstAmpStream_inplace_sub(TrigBurstAmpStream *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * TrigBurstAmpStream_div(TrigBurstAmpStream *self, PyObject *arg) { DIV };
+static PyObject * TrigBurstAmpStream_inplace_div(TrigBurstAmpStream *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef TrigBurstAmpStream_members[] = {
+ {"server", T_OBJECT_EX, offsetof(TrigBurstAmpStream, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(TrigBurstAmpStream, stream), 0, "Stream object."},
+ {"mul", T_OBJECT_EX, offsetof(TrigBurstAmpStream, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(TrigBurstAmpStream, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef TrigBurstAmpStream_methods[] = {
+ {"getServer", (PyCFunction)TrigBurstAmpStream_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)TrigBurstAmpStream_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)TrigBurstAmpStream_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)TrigBurstAmpStream_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)TrigBurstAmpStream_stop, METH_NOARGS, "Stops computing."},
+ {"setMul", (PyCFunction)TrigBurstAmpStream_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)TrigBurstAmpStream_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)TrigBurstAmpStream_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)TrigBurstAmpStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods TrigBurstAmpStream_as_number = {
+ (binaryfunc)TrigBurstAmpStream_add, /*nb_add*/
+ (binaryfunc)TrigBurstAmpStream_sub, /*nb_subtract*/
+ (binaryfunc)TrigBurstAmpStream_multiply, /*nb_multiply*/
+ (binaryfunc)TrigBurstAmpStream_div, /*nb_divide*/
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_neg*/
+ 0, /*nb_pos*/
+ 0, /*(unaryfunc)array_abs,*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ 0, /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ 0, /*nb_oct*/
+ 0, /*nb_hex*/
+ (binaryfunc)TrigBurstAmpStream_inplace_add, /*inplace_add*/
+ (binaryfunc)TrigBurstAmpStream_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)TrigBurstAmpStream_inplace_multiply, /*inplace_multiply*/
+ (binaryfunc)TrigBurstAmpStream_inplace_div, /*inplace_divide*/
+ 0, /*inplace_remainder*/
+ 0, /*inplace_power*/
+ 0, /*inplace_lshift*/
+ 0, /*inplace_rshift*/
+ 0, /*inplace_and*/
+ 0, /*inplace_xor*/
+ 0, /*inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject TrigBurstAmpStreamType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.TrigBurstAmpStream_base", /*tp_name*/
+ sizeof(TrigBurstAmpStream), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)TrigBurstAmpStream_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &TrigBurstAmpStream_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "TrigBurstAmpStream objects. Reads a amplitude channel from a TrigBurster object.", /* tp_doc */
+ (traverseproc)TrigBurstAmpStream_traverse, /* tp_traverse */
+ (inquiry)TrigBurstAmpStream_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ TrigBurstAmpStream_methods, /* tp_methods */
+ TrigBurstAmpStream_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ TrigBurstAmpStream_new, /* tp_new */
+};
+
+/************************************************************************************************/
+/* TrigBurstDurStream object per channel */
+/************************************************************************************************/
+typedef struct {
+ pyo_audio_HEAD
+ TrigBurster *mainPlayer;
+ int chnl;
+ int modebuffer[2];
+} TrigBurstDurStream;
+
+static void TrigBurstDurStream_postprocessing_ii(TrigBurstDurStream *self) { POST_PROCESSING_II };
+static void TrigBurstDurStream_postprocessing_ai(TrigBurstDurStream *self) { POST_PROCESSING_AI };
+static void TrigBurstDurStream_postprocessing_ia(TrigBurstDurStream *self) { POST_PROCESSING_IA };
+static void TrigBurstDurStream_postprocessing_aa(TrigBurstDurStream *self) { POST_PROCESSING_AA };
+static void TrigBurstDurStream_postprocessing_ireva(TrigBurstDurStream *self) { POST_PROCESSING_IREVA };
+static void TrigBurstDurStream_postprocessing_areva(TrigBurstDurStream *self) { POST_PROCESSING_AREVA };
+static void TrigBurstDurStream_postprocessing_revai(TrigBurstDurStream *self) { POST_PROCESSING_REVAI };
+static void TrigBurstDurStream_postprocessing_revaa(TrigBurstDurStream *self) { POST_PROCESSING_REVAA };
+static void TrigBurstDurStream_postprocessing_revareva(TrigBurstDurStream *self) { POST_PROCESSING_REVAREVA };
+
+static void
+TrigBurstDurStream_setProcMode(TrigBurstDurStream *self) {
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = TrigBurstDurStream_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = TrigBurstDurStream_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = TrigBurstDurStream_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = TrigBurstDurStream_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = TrigBurstDurStream_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = TrigBurstDurStream_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = TrigBurstDurStream_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = TrigBurstDurStream_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = TrigBurstDurStream_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+TrigBurstDurStream_compute_next_data_frame(TrigBurstDurStream *self)
+{
+ int i;
+ MYFLT *tmp;
+ int offset = self->chnl * self->bufsize;
+ tmp = TrigBurster_getDurBuffer((TrigBurster *)self->mainPlayer);
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = tmp[i + offset];
+ }
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+TrigBurstDurStream_traverse(TrigBurstDurStream *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->mainPlayer);
+ return 0;
+}
+
+static int
+TrigBurstDurStream_clear(TrigBurstDurStream *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->mainPlayer);
+ return 0;
+}
+
+static void
+TrigBurstDurStream_dealloc(TrigBurstDurStream* self)
+{
+ pyo_DEALLOC
+ TrigBurstDurStream_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+TrigBurstDurStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *maintmp=NULL;
+ TrigBurstDurStream *self;
+ self = (TrigBurstDurStream *)type->tp_alloc(type, 0);
+
+ self->chnl = 0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, TrigBurstDurStream_compute_next_data_frame);
+ self->mode_func_ptr = TrigBurstDurStream_setProcMode;
+
+ static char *kwlist[] = {"mainPlayer", "chnl", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
+ Py_RETURN_NONE;
+
+ Py_XDECREF(self->mainPlayer);
+ Py_INCREF(maintmp);
+ self->mainPlayer = (TrigBurster *)maintmp;
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * TrigBurstDurStream_getServer(TrigBurstDurStream* self) { GET_SERVER };
+static PyObject * TrigBurstDurStream_getStream(TrigBurstDurStream* self) { GET_STREAM };
+static PyObject * TrigBurstDurStream_setMul(TrigBurstDurStream *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigBurstDurStream_setAdd(TrigBurstDurStream *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigBurstDurStream_setSub(TrigBurstDurStream *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigBurstDurStream_setDiv(TrigBurstDurStream *self, PyObject *arg) { SET_DIV };
+
+static PyObject * TrigBurstDurStream_play(TrigBurstDurStream *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * TrigBurstDurStream_out(TrigBurstDurStream *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * TrigBurstDurStream_stop(TrigBurstDurStream *self) { STOP };
+
+static PyObject * TrigBurstDurStream_multiply(TrigBurstDurStream *self, PyObject *arg) { MULTIPLY };
+static PyObject * TrigBurstDurStream_inplace_multiply(TrigBurstDurStream *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * TrigBurstDurStream_add(TrigBurstDurStream *self, PyObject *arg) { ADD };
+static PyObject * TrigBurstDurStream_inplace_add(TrigBurstDurStream *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * TrigBurstDurStream_sub(TrigBurstDurStream *self, PyObject *arg) { SUB };
+static PyObject * TrigBurstDurStream_inplace_sub(TrigBurstDurStream *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * TrigBurstDurStream_div(TrigBurstDurStream *self, PyObject *arg) { DIV };
+static PyObject * TrigBurstDurStream_inplace_div(TrigBurstDurStream *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef TrigBurstDurStream_members[] = {
+ {"server", T_OBJECT_EX, offsetof(TrigBurstDurStream, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(TrigBurstDurStream, stream), 0, "Stream object."},
+ {"mul", T_OBJECT_EX, offsetof(TrigBurstDurStream, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(TrigBurstDurStream, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef TrigBurstDurStream_methods[] = {
+ {"getServer", (PyCFunction)TrigBurstDurStream_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)TrigBurstDurStream_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)TrigBurstDurStream_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)TrigBurstDurStream_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)TrigBurstDurStream_stop, METH_NOARGS, "Stops computing."},
+ {"setMul", (PyCFunction)TrigBurstDurStream_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)TrigBurstDurStream_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)TrigBurstDurStream_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)TrigBurstDurStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods TrigBurstDurStream_as_number = {
+ (binaryfunc)TrigBurstDurStream_add, /*nb_add*/
+ (binaryfunc)TrigBurstDurStream_sub, /*nb_subtract*/
+ (binaryfunc)TrigBurstDurStream_multiply, /*nb_multiply*/
+ (binaryfunc)TrigBurstDurStream_div, /*nb_divide*/
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_neg*/
+ 0, /*nb_pos*/
+ 0, /*(unaryfunc)array_abs,*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ 0, /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ 0, /*nb_oct*/
+ 0, /*nb_hex*/
+ (binaryfunc)TrigBurstDurStream_inplace_add, /*inplace_add*/
+ (binaryfunc)TrigBurstDurStream_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)TrigBurstDurStream_inplace_multiply, /*inplace_multiply*/
+ (binaryfunc)TrigBurstDurStream_inplace_div, /*inplace_divide*/
+ 0, /*inplace_remainder*/
+ 0, /*inplace_power*/
+ 0, /*inplace_lshift*/
+ 0, /*inplace_rshift*/
+ 0, /*inplace_and*/
+ 0, /*inplace_xor*/
+ 0, /*inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject TrigBurstDurStreamType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.TrigBurstDurStream_base", /*tp_name*/
+ sizeof(TrigBurstDurStream), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)TrigBurstDurStream_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &TrigBurstDurStream_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "TrigBurstDurStream objects. Reads a duration channel from a TrigBurster object.", /* tp_doc */
+ (traverseproc)TrigBurstDurStream_traverse, /* tp_traverse */
+ (inquiry)TrigBurstDurStream_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ TrigBurstDurStream_methods, /* tp_methods */
+ TrigBurstDurStream_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ TrigBurstDurStream_new, /* tp_new */
+};
+
+/************************************************************************************************/
+/* TrigBurstEndStream object per channel */
+/************************************************************************************************/
+typedef struct {
+ pyo_audio_HEAD
+ TrigBurster *mainPlayer;
+ int chnl;
+ int modebuffer[2];
+} TrigBurstEndStream;
+
+static void TrigBurstEndStream_postprocessing_ii(TrigBurstEndStream *self) { POST_PROCESSING_II };
+static void TrigBurstEndStream_postprocessing_ai(TrigBurstEndStream *self) { POST_PROCESSING_AI };
+static void TrigBurstEndStream_postprocessing_ia(TrigBurstEndStream *self) { POST_PROCESSING_IA };
+static void TrigBurstEndStream_postprocessing_aa(TrigBurstEndStream *self) { POST_PROCESSING_AA };
+static void TrigBurstEndStream_postprocessing_ireva(TrigBurstEndStream *self) { POST_PROCESSING_IREVA };
+static void TrigBurstEndStream_postprocessing_areva(TrigBurstEndStream *self) { POST_PROCESSING_AREVA };
+static void TrigBurstEndStream_postprocessing_revai(TrigBurstEndStream *self) { POST_PROCESSING_REVAI };
+static void TrigBurstEndStream_postprocessing_revaa(TrigBurstEndStream *self) { POST_PROCESSING_REVAA };
+static void TrigBurstEndStream_postprocessing_revareva(TrigBurstEndStream *self) { POST_PROCESSING_REVAREVA };
+
+static void
+TrigBurstEndStream_setProcMode(TrigBurstEndStream *self) {
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = TrigBurstEndStream_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = TrigBurstEndStream_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = TrigBurstEndStream_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = TrigBurstEndStream_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = TrigBurstEndStream_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = TrigBurstEndStream_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = TrigBurstEndStream_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = TrigBurstEndStream_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = TrigBurstEndStream_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+TrigBurstEndStream_compute_next_data_frame(TrigBurstEndStream *self)
+{
+ int i;
+ MYFLT *tmp;
+ int offset = self->chnl * self->bufsize;
+ tmp = TrigBurster_getEndBuffer((TrigBurster *)self->mainPlayer);
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = tmp[i + offset];
+ }
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+TrigBurstEndStream_traverse(TrigBurstEndStream *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->mainPlayer);
+ return 0;
+}
+
+static int
+TrigBurstEndStream_clear(TrigBurstEndStream *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->mainPlayer);
+ return 0;
+}
+
+static void
+TrigBurstEndStream_dealloc(TrigBurstEndStream* self)
+{
+ pyo_DEALLOC
+ TrigBurstEndStream_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+TrigBurstEndStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *maintmp=NULL;
+ TrigBurstEndStream *self;
+ self = (TrigBurstEndStream *)type->tp_alloc(type, 0);
+
+ self->chnl = 0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, TrigBurstEndStream_compute_next_data_frame);
+ self->mode_func_ptr = TrigBurstEndStream_setProcMode;
+
+ static char *kwlist[] = {"mainPlayer", "chnl", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
+ Py_RETURN_NONE;
+
+ Py_XDECREF(self->mainPlayer);
+ Py_INCREF(maintmp);
+ self->mainPlayer = (TrigBurster *)maintmp;
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * TrigBurstEndStream_getServer(TrigBurstEndStream* self) { GET_SERVER };
+static PyObject * TrigBurstEndStream_getStream(TrigBurstEndStream* self) { GET_STREAM };
+static PyObject * TrigBurstEndStream_setMul(TrigBurstEndStream *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigBurstEndStream_setAdd(TrigBurstEndStream *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigBurstEndStream_setSub(TrigBurstEndStream *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigBurstEndStream_setDiv(TrigBurstEndStream *self, PyObject *arg) { SET_DIV };
+
+static PyObject * TrigBurstEndStream_play(TrigBurstEndStream *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * TrigBurstEndStream_out(TrigBurstEndStream *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * TrigBurstEndStream_stop(TrigBurstEndStream *self) { STOP };
+
+static PyObject * TrigBurstEndStream_multiply(TrigBurstEndStream *self, PyObject *arg) { MULTIPLY };
+static PyObject * TrigBurstEndStream_inplace_multiply(TrigBurstEndStream *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * TrigBurstEndStream_add(TrigBurstEndStream *self, PyObject *arg) { ADD };
+static PyObject * TrigBurstEndStream_inplace_add(TrigBurstEndStream *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * TrigBurstEndStream_sub(TrigBurstEndStream *self, PyObject *arg) { SUB };
+static PyObject * TrigBurstEndStream_inplace_sub(TrigBurstEndStream *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * TrigBurstEndStream_div(TrigBurstEndStream *self, PyObject *arg) { DIV };
+static PyObject * TrigBurstEndStream_inplace_div(TrigBurstEndStream *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef TrigBurstEndStream_members[] = {
+ {"server", T_OBJECT_EX, offsetof(TrigBurstEndStream, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(TrigBurstEndStream, stream), 0, "Stream object."},
+ {"mul", T_OBJECT_EX, offsetof(TrigBurstEndStream, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(TrigBurstEndStream, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef TrigBurstEndStream_methods[] = {
+ {"getServer", (PyCFunction)TrigBurstEndStream_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)TrigBurstEndStream_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)TrigBurstEndStream_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)TrigBurstEndStream_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)TrigBurstEndStream_stop, METH_NOARGS, "Stops computing."},
+ {"setMul", (PyCFunction)TrigBurstEndStream_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)TrigBurstEndStream_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)TrigBurstEndStream_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)TrigBurstEndStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods TrigBurstEndStream_as_number = {
+ (binaryfunc)TrigBurstEndStream_add, /*nb_add*/
+ (binaryfunc)TrigBurstEndStream_sub, /*nb_subtract*/
+ (binaryfunc)TrigBurstEndStream_multiply, /*nb_multiply*/
+ (binaryfunc)TrigBurstEndStream_div, /*nb_divide*/
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_neg*/
+ 0, /*nb_pos*/
+ 0, /*(unaryfunc)array_abs,*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ 0, /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ 0, /*nb_oct*/
+ 0, /*nb_hex*/
+ (binaryfunc)TrigBurstEndStream_inplace_add, /*inplace_add*/
+ (binaryfunc)TrigBurstEndStream_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)TrigBurstEndStream_inplace_multiply, /*inplace_multiply*/
+ (binaryfunc)TrigBurstEndStream_inplace_div, /*inplace_divide*/
+ 0, /*inplace_remainder*/
+ 0, /*inplace_power*/
+ 0, /*inplace_lshift*/
+ 0, /*inplace_rshift*/
+ 0, /*inplace_and*/
+ 0, /*inplace_xor*/
+ 0, /*inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject TrigBurstEndStreamType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.TrigBurstEndStream_base", /*tp_name*/
+ sizeof(TrigBurstEndStream), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)TrigBurstEndStream_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &TrigBurstEndStream_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "TrigBurstEndStream objects. Reads a duration channel from a TrigBurster object.", /* tp_doc */
+ (traverseproc)TrigBurstEndStream_traverse, /* tp_traverse */
+ (inquiry)TrigBurstEndStream_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ TrigBurstEndStream_methods, /* tp_methods */
+ TrigBurstEndStream_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ TrigBurstEndStream_new, /* tp_new */
+};
\ No newline at end of file
diff --git a/src/objects/midimodule.c b/src/objects/midimodule.c
index cc35226..0bf5a3d 100644
--- a/src/objects/midimodule.c
+++ b/src/objects/midimodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -39,7 +39,7 @@ CtlScan_setProcMode(CtlScan *self) {}
static void
CtlScan_compute_next_data_frame(CtlScan *self)
-{
+{
PmEvent *buffer;
int i, count;
@@ -61,7 +61,7 @@ CtlScan_compute_next_data_frame(CtlScan *self)
PyObject_Call((PyObject *)self->callable, tup, NULL);
}
if (self->toprint == 1)
- printf("ctl number : %i, ctl value : %i, midi channel : %i\n", self->ctlnumber, value, status - 0xB0 + 1);
+ printf("ctl number : %i, ctl value : %i, midi channel : %i\n", self->ctlnumber, value, status - 0xB0 + 1);
}
}
}
@@ -75,7 +75,7 @@ CtlScan_traverse(CtlScan *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
CtlScan_clear(CtlScan *self)
{
pyo_CLEAR
@@ -95,7 +95,7 @@ static PyObject *
CtlScan_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *calltmp=NULL;
+ PyObject *calltmp=NULL;
CtlScan *self;
self = (CtlScan *)type->tp_alloc(type, 0);
@@ -116,7 +116,7 @@ CtlScan_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
return (PyObject *)self;
}
@@ -127,21 +127,29 @@ static PyObject * CtlScan_play(CtlScan *self, PyObject *args, PyObject *kwds) {
static PyObject * CtlScan_stop(CtlScan *self) { STOP };
static PyObject *
+CtlScan_reset(CtlScan *self)
+{
+ self->ctlnumber = -1;
+ Py_INCREF(Py_None);
+ return Py_None;
+};
+
+static PyObject *
CtlScan_setFunction(CtlScan *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (! PyCallable_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The callable attribute must be a valid Python function.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_XDECREF(self->callable);
Py_INCREF(tmp);
self->callable = tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -149,11 +157,11 @@ CtlScan_setFunction(CtlScan *self, PyObject *arg)
static PyObject *
CtlScan_setToprint(CtlScan *self, PyObject *arg)
{
-
+
if (PyInt_Check(arg)) {
self->toprint = PyInt_AsLong(arg);
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -168,6 +176,7 @@ static PyMethodDef CtlScan_methods[] = {
{"_getStream", (PyCFunction)CtlScan_getStream, METH_NOARGS, "Returns stream object."},
{"play", (PyCFunction)CtlScan_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"stop", (PyCFunction)CtlScan_stop, METH_NOARGS, "Stops computing."},
+ {"reset", (PyCFunction)CtlScan_reset, METH_NOARGS, "Resets the scanned number."},
{"setFunction", (PyCFunction)CtlScan_setFunction, METH_O, "Sets the function to be called."},
{"setToprint", (PyCFunction)CtlScan_setToprint, METH_O, "If True, print values to the console."},
{NULL} /* Sentinel */
@@ -228,20 +237,20 @@ CtlScan2_setProcMode(CtlScan2 *self) {}
static void
CtlScan2_compute_next_data_frame(CtlScan2 *self)
-{
+{
PmEvent *buffer;
int i, count, midichnl;
-
+
buffer = Server_getMidiEventBuffer((Server *)self->server);
count = Server_getMidiEventCount((Server *)self->server);
-
+
if (count > 0) {
PyObject *tup;
for (i=count-1; i>=0; i--) {
int status = Pm_MessageStatus(buffer[i].message); // Temp note event holders
int number = Pm_MessageData1(buffer[i].message);
int value = Pm_MessageData2(buffer[i].message);
-
+
if ((status & 0xF0) == 0xB0) {
midichnl = status - 0xB0 + 1;
if (number != self->ctlnumber || midichnl != self->midichnl) {
@@ -253,7 +262,7 @@ CtlScan2_compute_next_data_frame(CtlScan2 *self)
PyObject_Call((PyObject *)self->callable, tup, NULL);
}
if (self->toprint == 1)
- printf("ctl number : %i, ctl value : %i, midi channel : %i\n", self->ctlnumber, value, midichnl);
+ printf("ctl number : %i, ctl value : %i, midi channel : %i\n", self->ctlnumber, value, midichnl);
}
}
}
@@ -267,7 +276,7 @@ CtlScan2_traverse(CtlScan2 *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
CtlScan2_clear(CtlScan2 *self)
{
pyo_CLEAR
@@ -287,28 +296,28 @@ static PyObject *
CtlScan2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *calltmp=NULL;
+ PyObject *calltmp=NULL;
CtlScan2 *self;
self = (CtlScan2 *)type->tp_alloc(type, 0);
-
+
self->ctlnumber = self->midichnl = -1;
self->toprint = 1;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, CtlScan2_compute_next_data_frame);
self->mode_func_ptr = CtlScan2_setProcMode;
-
+
static char *kwlist[] = {"callable", "toprint", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &calltmp, &self->toprint))
Py_RETURN_NONE;
-
+
if (calltmp) {
PyObject_CallMethod((PyObject *)self, "setFunction", "O", calltmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
return (PyObject *)self;
}
@@ -319,21 +328,29 @@ static PyObject * CtlScan2_play(CtlScan2 *self, PyObject *args, PyObject *kwds)
static PyObject * CtlScan2_stop(CtlScan2 *self) { STOP };
static PyObject *
+CtlScan2_reset(CtlScan2 *self)
+{
+ self->ctlnumber = self->midichnl = -1;
+ Py_INCREF(Py_None);
+ return Py_None;
+};
+
+static PyObject *
CtlScan2_setFunction(CtlScan2 *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (! PyCallable_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The callable attribute must be a valid Python function.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_XDECREF(self->callable);
Py_INCREF(tmp);
self->callable = tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -341,11 +358,11 @@ CtlScan2_setFunction(CtlScan2 *self, PyObject *arg)
static PyObject *
CtlScan2_setToprint(CtlScan2 *self, PyObject *arg)
{
-
+
if (PyInt_Check(arg)) {
self->toprint = PyInt_AsLong(arg);
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -360,6 +377,7 @@ static PyMethodDef CtlScan2_methods[] = {
{"_getStream", (PyCFunction)CtlScan2_getStream, METH_NOARGS, "Returns stream object."},
{"play", (PyCFunction)CtlScan2_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"stop", (PyCFunction)CtlScan2_stop, METH_NOARGS, "Stops computing."},
+ {"reset", (PyCFunction)CtlScan2_reset, METH_NOARGS, "Reset scanned numbers."},
{"setFunction", (PyCFunction)CtlScan2_setFunction, METH_O, "Sets the function to be called."},
{"setToprint", (PyCFunction)CtlScan2_setToprint, METH_O, "If True, print values to the console."},
{NULL} /* Sentinel */
@@ -438,31 +456,31 @@ Midictl_setProcMode(Midictl *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Midictl_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Midictl_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Midictl_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Midictl_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Midictl_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Midictl_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Midictl_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Midictl_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Midictl_postprocessing_revareva;
break;
}
@@ -476,7 +494,7 @@ void translateMidi(Midictl *self, PmEvent *buffer, int count)
int status = Pm_MessageStatus(buffer[i].message); // Temp note event holders
int number = Pm_MessageData1(buffer[i].message);
int value = Pm_MessageData2(buffer[i].message);
-
+
if (self->channel == 0) {
if ((status & 0xF0) == 0xB0)
ok = 1;
@@ -495,12 +513,12 @@ void translateMidi(Midictl *self, PmEvent *buffer, int count)
self->value = (value / 127.) * (self->maxscale - self->minscale) + self->minscale;
break;
}
- }
+ }
}
static void
Midictl_compute_next_data_frame(Midictl *self)
-{
+{
PmEvent *tmp;
int i, count;
MYFLT step;
@@ -510,7 +528,7 @@ Midictl_compute_next_data_frame(Midictl *self)
if (count > 0)
translateMidi((Midictl *)self, tmp, count);
-
+
if (self->interp == 0) {
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->value;
@@ -520,7 +538,7 @@ Midictl_compute_next_data_frame(Midictl *self)
step = (self->value - self->oldValue) / self->bufsize;
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->oldValue + step;
- }
+ }
}
(*self->muladd_func_ptr)(self);
}
@@ -532,7 +550,7 @@ Midictl_traverse(Midictl *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Midictl_clear(Midictl *self)
{
pyo_CLEAR
@@ -550,7 +568,7 @@ Midictl_dealloc(Midictl* self)
static PyObject *
Midictl_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- int i;
+ int i;
PyObject *multmp=NULL, *addtmp=NULL;
Midictl *self;
self = (Midictl *)type->tp_alloc(type, 0);
@@ -572,7 +590,7 @@ Midictl_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_I_FFFIOO, kwlist, &self->ctlnumber, &self->minscale, &self->maxscale, &self->oldValue, &self->channel, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -580,22 +598,22 @@ Midictl_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->value = self->oldValue;
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Midictl_getServer(Midictl* self) { GET_SERVER };
static PyObject * Midictl_getStream(Midictl* self) { GET_STREAM };
-static PyObject * Midictl_setMul(Midictl *self, PyObject *arg) { SET_MUL };
-static PyObject * Midictl_setAdd(Midictl *self, PyObject *arg) { SET_ADD };
-static PyObject * Midictl_setSub(Midictl *self, PyObject *arg) { SET_SUB };
-static PyObject * Midictl_setDiv(Midictl *self, PyObject *arg) { SET_DIV };
+static PyObject * Midictl_setMul(Midictl *self, PyObject *arg) { SET_MUL };
+static PyObject * Midictl_setAdd(Midictl *self, PyObject *arg) { SET_ADD };
+static PyObject * Midictl_setSub(Midictl *self, PyObject *arg) { SET_SUB };
+static PyObject * Midictl_setDiv(Midictl *self, PyObject *arg) { SET_DIV };
static PyObject * Midictl_play(Midictl *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Midictl_stop(Midictl *self) { STOP };
@@ -613,14 +631,14 @@ static PyObject *
Midictl_setInterpolation(Midictl *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNum = PyInt_Check(arg);
-
+
if (isNum == 1) {
tmp = PyInt_AsLong(arg);
if (tmp == 0)
@@ -628,7 +646,7 @@ Midictl_setInterpolation(Midictl *self, PyObject *arg)
else
self->interp = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -637,19 +655,19 @@ static PyObject *
Midictl_setValue(Midictl *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNum = PyNumber_Check(arg);
-
+
if (isNum == 1) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
self->oldValue = self->value = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -658,56 +676,56 @@ static PyObject *
Midictl_setMinScale(Midictl *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNum = PyNumber_Check(arg);
-
+
if (isNum == 1) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
self->minscale = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Midictl_setMaxScale(Midictl *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNum = PyNumber_Check(arg);
-
+
if (isNum == 1) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
self->maxscale = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Midictl_setCtlNumber(Midictl *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 128)
@@ -716,29 +734,29 @@ Midictl_setCtlNumber(Midictl *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Midictl_setChannel(Midictl *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 128)
self->channel = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Midictl_members[] = {
{"server", T_OBJECT_EX, offsetof(Midictl, server), 0, "Pyo server."},
@@ -876,33 +894,33 @@ Bendin_setProcMode(Bendin *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Bendin_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Bendin_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Bendin_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Bendin_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Bendin_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Bendin_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Bendin_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Bendin_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Bendin_postprocessing_revareva;
break;
}
@@ -917,7 +935,7 @@ void Bendin_translateMidi(Bendin *self, PmEvent *buffer, int count)
int status = Pm_MessageStatus(buffer[i].message); // Temp note event holders
int number = Pm_MessageData1(buffer[i].message);
int value = Pm_MessageData2(buffer[i].message);
-
+
if (self->channel == 0) {
if ((status & 0xF0) == 0xe0)
ok = 1;
@@ -930,7 +948,7 @@ void Bendin_translateMidi(Bendin *self, PmEvent *buffer, int count)
else
ok = 0;
}
-
+
if (ok == 1) {
self->oldValue = self->value;
val = (number + (value << 7) - 8192) / 8192.0 * self->range;
@@ -940,26 +958,26 @@ void Bendin_translateMidi(Bendin *self, PmEvent *buffer, int count)
self->value = MYPOW(1.0594630943593, val);
break;
}
- }
+ }
}
static void
Bendin_compute_next_data_frame(Bendin *self)
-{
+{
PmEvent *tmp;
int i, count;
-
+
tmp = Server_getMidiEventBuffer((Server *)self->server);
count = Server_getMidiEventCount((Server *)self->server);
-
+
if (count > 0)
Bendin_translateMidi((Bendin *)self, tmp, count);
MYFLT step = (self->value - self->oldValue) / self->bufsize;
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->oldValue + step;
- }
-
+ }
+
(*self->muladd_func_ptr)(self);
}
@@ -970,7 +988,7 @@ Bendin_traverse(Bendin *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Bendin_clear(Bendin *self)
{
pyo_CLEAR
@@ -989,10 +1007,10 @@ static PyObject *
Bendin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *multmp=NULL, *addtmp=NULL;
+ PyObject *multmp=NULL, *addtmp=NULL;
Bendin *self;
self = (Bendin *)type->tp_alloc(type, 0);
-
+
self->channel = 0;
self->scale = 0;
self->value = 0.;
@@ -1000,42 +1018,42 @@ Bendin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->range = 2.;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Bendin_compute_next_data_frame);
self->mode_func_ptr = Bendin_setProcMode;
static char *kwlist[] = {"brange", "scale", "channel", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__FIIOO, kwlist, &self->range, &self->scale, &self->channel, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
if (self->scale == 0)
self->oldValue = self->value = 0.;
else
self->oldValue = self->value = 1.;
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Bendin_getServer(Bendin* self) { GET_SERVER };
static PyObject * Bendin_getStream(Bendin* self) { GET_STREAM };
-static PyObject * Bendin_setMul(Bendin *self, PyObject *arg) { SET_MUL };
-static PyObject * Bendin_setAdd(Bendin *self, PyObject *arg) { SET_ADD };
-static PyObject * Bendin_setSub(Bendin *self, PyObject *arg) { SET_SUB };
-static PyObject * Bendin_setDiv(Bendin *self, PyObject *arg) { SET_DIV };
+static PyObject * Bendin_setMul(Bendin *self, PyObject *arg) { SET_MUL };
+static PyObject * Bendin_setAdd(Bendin *self, PyObject *arg) { SET_ADD };
+static PyObject * Bendin_setSub(Bendin *self, PyObject *arg) { SET_SUB };
+static PyObject * Bendin_setDiv(Bendin *self, PyObject *arg) { SET_DIV };
static PyObject * Bendin_play(Bendin *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Bendin_stop(Bendin *self) { STOP };
@@ -1053,58 +1071,58 @@ static PyObject *
Bendin_setBrange(Bendin *self, PyObject *arg)
{
MYFLT tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNum = PyNumber_Check(arg);
-
+
if (isNum == 1) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
if (tmp >= 0.0 && tmp < 128.0)
self->range = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Bendin_setChannel(Bendin *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 128)
self->channel = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Bendin_setScale(Bendin *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp == 0)
@@ -1112,10 +1130,10 @@ Bendin_setScale(Bendin *self, PyObject *arg)
else if (tmp == 1)
self->scale = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Bendin_members[] = {
@@ -1251,33 +1269,33 @@ Touchin_setProcMode(Touchin *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Touchin_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Touchin_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Touchin_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Touchin_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Touchin_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Touchin_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Touchin_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Touchin_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Touchin_postprocessing_revareva;
break;
}
@@ -1304,32 +1322,32 @@ void Touchin_translateMidi(Touchin *self, PmEvent *buffer, int count)
else
ok = 0;
}
-
+
if (ok == 1) {
self->oldValue = self->value;
self->value = (number / 127.) * (self->maxscale - self->minscale) + self->minscale;
break;
}
- }
+ }
}
static void
Touchin_compute_next_data_frame(Touchin *self)
-{
+{
PmEvent *tmp;
int i, count;
-
+
tmp = Server_getMidiEventBuffer((Server *)self->server);
count = Server_getMidiEventCount((Server *)self->server);
-
+
if (count > 0)
Touchin_translateMidi((Touchin *)self, tmp, count);
MYFLT step = (self->value - self->oldValue) / self->bufsize;
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->oldValue + step;
- }
-
+ }
+
(*self->muladd_func_ptr)(self);
}
@@ -1340,7 +1358,7 @@ Touchin_traverse(Touchin *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Touchin_clear(Touchin *self)
{
pyo_CLEAR
@@ -1359,10 +1377,10 @@ static PyObject *
Touchin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *multmp=NULL, *addtmp=NULL;
+ PyObject *multmp=NULL, *addtmp=NULL;
Touchin *self;
self = (Touchin *)type->tp_alloc(type, 0);
-
+
self->channel = 0;
self->value = 0.;
self->oldValue = 0.;
@@ -1370,39 +1388,39 @@ Touchin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->maxscale = 1.;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Touchin_compute_next_data_frame);
self->mode_func_ptr = Touchin_setProcMode;
static char *kwlist[] = {"minscale", "maxscale", "init", "channel", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__FFFIOO, kwlist, &self->minscale, &self->maxscale, &self->oldValue, &self->channel, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->value = self->oldValue;
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Touchin_getServer(Touchin* self) { GET_SERVER };
static PyObject * Touchin_getStream(Touchin* self) { GET_STREAM };
-static PyObject * Touchin_setMul(Touchin *self, PyObject *arg) { SET_MUL };
-static PyObject * Touchin_setAdd(Touchin *self, PyObject *arg) { SET_ADD };
-static PyObject * Touchin_setSub(Touchin *self, PyObject *arg) { SET_SUB };
-static PyObject * Touchin_setDiv(Touchin *self, PyObject *arg) { SET_DIV };
+static PyObject * Touchin_setMul(Touchin *self, PyObject *arg) { SET_MUL };
+static PyObject * Touchin_setAdd(Touchin *self, PyObject *arg) { SET_ADD };
+static PyObject * Touchin_setSub(Touchin *self, PyObject *arg) { SET_SUB };
+static PyObject * Touchin_setDiv(Touchin *self, PyObject *arg) { SET_DIV };
static PyObject * Touchin_play(Touchin *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Touchin_stop(Touchin *self) { STOP };
@@ -1420,65 +1438,65 @@ static PyObject *
Touchin_setMinScale(Touchin *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNum = PyNumber_Check(arg);
-
+
if (isNum == 1) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
self->minscale = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Touchin_setMaxScale(Touchin *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNum = PyNumber_Check(arg);
-
+
if (isNum == 1) {
tmp = PyFloat_AsDouble(PyNumber_Float(arg));
self->maxscale = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Touchin_setChannel(Touchin *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 128)
self->channel = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Touchin_members[] = {
{"server", T_OBJECT_EX, offsetof(Touchin, server), 0, "Pyo server."},
@@ -1609,33 +1627,33 @@ Programin_setProcMode(Programin *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Programin_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Programin_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Programin_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Programin_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Programin_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Programin_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Programin_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Programin_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Programin_postprocessing_revareva;
break;
}
@@ -1645,11 +1663,11 @@ Programin_setProcMode(Programin *self)
void Programin_translateMidi(Programin *self, PmEvent *buffer, int count)
{
int i, ok;
-
+
for (i=count-1; i>=0; i--) {
int status = Pm_MessageStatus(buffer[i].message); // Temp note event holders
int number = Pm_MessageData1(buffer[i].message);
-
+
if (self->channel == 0) {
if ((status & 0xF0) == 0xc0)
ok = 1;
@@ -1662,30 +1680,30 @@ void Programin_translateMidi(Programin *self, PmEvent *buffer, int count)
else
ok = 0;
}
-
+
if (ok == 1) {
self->value = (MYFLT)number;
break;
}
- }
+ }
}
static void
Programin_compute_next_data_frame(Programin *self)
-{
+{
PmEvent *tmp;
int i, count;
-
+
tmp = Server_getMidiEventBuffer((Server *)self->server);
count = Server_getMidiEventCount((Server *)self->server);
-
+
if (count > 0)
Programin_translateMidi((Programin *)self, tmp, count);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->value;
- }
-
+ }
+
(*self->muladd_func_ptr)(self);
}
@@ -1696,7 +1714,7 @@ Programin_traverse(Programin *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Programin_clear(Programin *self)
{
pyo_CLEAR
@@ -1715,45 +1733,45 @@ static PyObject *
Programin_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *multmp=NULL, *addtmp=NULL;
+ PyObject *multmp=NULL, *addtmp=NULL;
Programin *self;
self = (Programin *)type->tp_alloc(type, 0);
-
+
self->channel = 0;
self->value = 0.;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Programin_compute_next_data_frame);
self->mode_func_ptr = Programin_setProcMode;
static char *kwlist[] = {"channel", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "iOO", kwlist, &self->channel, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Programin_getServer(Programin* self) { GET_SERVER };
static PyObject * Programin_getStream(Programin* self) { GET_STREAM };
-static PyObject * Programin_setMul(Programin *self, PyObject *arg) { SET_MUL };
-static PyObject * Programin_setAdd(Programin *self, PyObject *arg) { SET_ADD };
-static PyObject * Programin_setSub(Programin *self, PyObject *arg) { SET_SUB };
-static PyObject * Programin_setDiv(Programin *self, PyObject *arg) { SET_DIV };
+static PyObject * Programin_setMul(Programin *self, PyObject *arg) { SET_MUL };
+static PyObject * Programin_setAdd(Programin *self, PyObject *arg) { SET_ADD };
+static PyObject * Programin_setSub(Programin *self, PyObject *arg) { SET_SUB };
+static PyObject * Programin_setDiv(Programin *self, PyObject *arg) { SET_DIV };
static PyObject * Programin_play(Programin *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Programin_stop(Programin *self) { STOP };
@@ -1771,23 +1789,23 @@ static PyObject *
Programin_setChannel(Programin *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 128)
self->channel = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Programin_members[] = {
{"server", T_OBJECT_EX, offsetof(Programin, server), 0, "Pyo server."},
@@ -1905,6 +1923,7 @@ typedef struct {
int centralkey;
int channel;
int stealing;
+ MYFLT *trigger_streams;
} MidiNote;
static void
@@ -1918,7 +1937,7 @@ pitchIsIn(int *buf, int pitch, int len) {
if (buf[i*2] == pitch) {
isIn = 1;
break;
- }
+ }
}
return isIn;
}
@@ -1931,7 +1950,7 @@ int firstEmpty(int *buf, int len) {
if (buf[i*2+1] == 0) {
voice = i;
break;
- }
+ }
}
return voice;
}
@@ -1945,8 +1964,8 @@ int nextEmptyVoice(int *buf, int voice, int len) {
next = tmp;
break;
}
- }
- return next;
+ }
+ return next;
}
int whichVoice(int *buf, int pitch, int len) {
@@ -1965,7 +1984,7 @@ int whichVoice(int *buf, int pitch, int len) {
void grabMidiNotes(MidiNote *self, PmEvent *buffer, int count)
{
int i, ok, voice, kind;
-
+
for (i=0; i<count; i++) {
int status = Pm_MessageStatus(buffer[i].message); // Temp note event holders
int pitch = Pm_MessageData1(buffer[i].message);
@@ -1983,7 +2002,7 @@ void grabMidiNotes(MidiNote *self, PmEvent *buffer, int count)
else
ok = 0;
}
-
+
if (ok == 1) {
if ((status & 0xF0) == 0x80)
kind = 0;
@@ -2000,34 +2019,41 @@ void grabMidiNotes(MidiNote *self, PmEvent *buffer, int count)
self->vcount = voice;
self->notebuf[voice*2] = pitch;
self->notebuf[voice*2+1] = velocity;
+ self->trigger_streams[self->bufsize*(self->vcount*2)] = 1.0;
}
}
else {
self->vcount = (self->vcount + 1) % self->voices;
self->notebuf[self->vcount*2] = pitch;
self->notebuf[self->vcount*2+1] = velocity;
+ self->trigger_streams[self->bufsize*(self->vcount*2)] = 1.0;
}
- }
+ }
else if (pitchIsIn(self->notebuf, pitch, self->voices) == 1 && kind == 0 && pitch >= self->first && pitch <= self->last) {
//printf("%i, %i, %i\n", status, pitch, velocity);
voice = whichVoice(self->notebuf, pitch, self->voices);
self->notebuf[voice*2] = -1;
self->notebuf[voice*2+1] = 0.;
+ self->trigger_streams[self->bufsize*(voice*2+1)] = 1.0;
}
}
- }
-}
+ }
+}
static void
MidiNote_compute_next_data_frame(MidiNote *self)
-{
+{
PmEvent *tmp;
- int count;
-
+ int i, count;
+
+ for (i=0; i<self->bufsize*self->voices*2; i++) {
+ self->trigger_streams[i] = 0.0;
+ }
+
tmp = Server_getMidiEventBuffer((Server *)self->server);
count = Server_getMidiEventCount((Server *)self->server);
if (count > 0)
- grabMidiNotes((MidiNote *)self, tmp, count);
+ grabMidiNotes((MidiNote *)self, tmp, count);
}
static int
@@ -2037,7 +2063,7 @@ MidiNote_traverse(MidiNote *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
MidiNote_clear(MidiNote *self)
{
pyo_CLEAR
@@ -2049,15 +2075,22 @@ MidiNote_dealloc(MidiNote* self)
{
pyo_DEALLOC
free(self->notebuf);
+ free(self->trigger_streams);
MidiNote_clear(self);
self->ob_type->tp_free((PyObject*)self);
}
+static MYFLT *
+MidiNote_get_trigger_buffer(MidiNote *self)
+{
+ return self->trigger_streams;
+}
+
static PyObject *
MidiNote_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
-
+
MidiNote *self;
self = (MidiNote *)type->tp_alloc(type, 0);
@@ -2068,19 +2101,24 @@ MidiNote_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->last = 127;
self->channel = 0;
self->stealing = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, MidiNote_compute_next_data_frame);
self->mode_func_ptr = MidiNote_setProcMode;
static char *kwlist[] = {"voices", "scale", "first", "last", "channel", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iiiii", kwlist, &self->voices, &self->scale, &self->first, &self->last, &self->channel))
Py_RETURN_NONE;
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->notebuf = (int *)realloc(self->notebuf, self->voices * 2 * sizeof(int));
+ self->trigger_streams = (MYFLT *)realloc(self->trigger_streams, self->bufsize * self->voices * 2 * sizeof(MYFLT));
+
+ for (i=0; i<self->bufsize*self->voices*2; i++) {
+ self->trigger_streams[i] = 0.0;
+ }
for (i=0; i<self->voices; i++) {
self->notebuf[i*2] = -1;
@@ -2088,9 +2126,9 @@ MidiNote_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
self->centralkey = (self->first + self->last) / 2;
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -2123,62 +2161,62 @@ static PyObject *
MidiNote_setChannel(MidiNote *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 128)
self->channel = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
MidiNote_setCentralKey(MidiNote *self, PyObject *arg)
{
int tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= self->first && tmp <= self->last)
self->centralkey = tmp;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
MidiNote_setStealing(MidiNote *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1)
self->stealing = PyInt_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef MidiNote_members[] = {
{"server", T_OBJECT_EX, offsetof(MidiNote, server), 0, "Pyo server."},
@@ -2264,33 +2302,33 @@ Notein_setProcMode(Notein *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Notein_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Notein_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Notein_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Notein_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Notein_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Notein_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Notein_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Notein_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Notein_postprocessing_revareva;
break;
}
@@ -2301,18 +2339,18 @@ Notein_compute_next_data_frame(Notein *self)
{
int i;
MYFLT tmp = MidiNote_getValue(self->handler, self->voice, self->mode);
-
+
if (self->mode == 0 && tmp != -1) {
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp;
- }
- }
+ }
+ }
else if (self->mode == 1) {
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp;
- }
+ }
(*self->muladd_func_ptr)(self);
- }
+ }
}
static int
@@ -2323,11 +2361,11 @@ Notein_traverse(Notein *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Notein_clear(Notein *self)
{
pyo_CLEAR
- Py_CLEAR(self->handler);
+ Py_CLEAR(self->handler);
return 0;
}
@@ -2346,46 +2384,46 @@ Notein_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *handlertmp=NULL, *multmp=NULL, *addtmp=NULL;
Notein *self;
self = (Notein *)type->tp_alloc(type, 0);
-
+
self->voice = 0;
self->mode = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Notein_compute_next_data_frame);
self->mode_func_ptr = Notein_setProcMode;
static char *kwlist[] = {"handler", "voice", "mode", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iiOO", kwlist, &handlertmp, &self->voice, &self->mode, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->handler);
Py_INCREF(handlertmp);
self->handler = (MidiNote *)handlertmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Notein_getServer(Notein* self) { GET_SERVER };
static PyObject * Notein_getStream(Notein* self) { GET_STREAM };
-static PyObject * Notein_setMul(Notein *self, PyObject *arg) { SET_MUL };
-static PyObject * Notein_setAdd(Notein *self, PyObject *arg) { SET_ADD };
-static PyObject * Notein_setSub(Notein *self, PyObject *arg) { SET_SUB };
-static PyObject * Notein_setDiv(Notein *self, PyObject *arg) { SET_DIV };
+static PyObject * Notein_setMul(Notein *self, PyObject *arg) { SET_MUL };
+static PyObject * Notein_setAdd(Notein *self, PyObject *arg) { SET_ADD };
+static PyObject * Notein_setSub(Notein *self, PyObject *arg) { SET_SUB };
+static PyObject * Notein_setDiv(Notein *self, PyObject *arg) { SET_DIV };
static PyObject * Notein_play(Notein *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Notein_stop(Notein *self) { STOP };
@@ -2503,37 +2541,293 @@ Notein_members, /* tp_members */
Notein_new, /* tp_new */
};
+/* NoteinTrig trig streamer */
typedef struct {
pyo_audio_HEAD
- PyObject *input;
- Stream *input_stream;
+ MidiNote *handler;
int modebuffer[2];
- int fademode;
- int changed;
- MYFLT topValue;
- MYFLT offsetAmp;
- MYFLT initAmp;
- MYFLT sustainAmp;
- MYFLT attack;
- MYFLT decay;
- MYFLT sustain;
- MYFLT release;
- MYFLT invAttack;
- MYFLT initAmpMinusOffsetAmp;
- MYFLT attackPlusDecay;
- MYFLT invDecay;
- MYFLT initAmpMinusSustainAmp;
- MYFLT invRelease;
- double currentTime;
- MYFLT sampleToSec;
-} MidiAdsr;
+ int voice;
+ int mode; /* 0 = noteon, 1 = noteoff */
+} NoteinTrig;
+
+static void NoteinTrig_postprocessing_ii(NoteinTrig *self) { POST_PROCESSING_II };
+static void NoteinTrig_postprocessing_ai(NoteinTrig *self) { POST_PROCESSING_AI };
+static void NoteinTrig_postprocessing_ia(NoteinTrig *self) { POST_PROCESSING_IA };
+static void NoteinTrig_postprocessing_aa(NoteinTrig *self) { POST_PROCESSING_AA };
+static void NoteinTrig_postprocessing_ireva(NoteinTrig *self) { POST_PROCESSING_IREVA };
+static void NoteinTrig_postprocessing_areva(NoteinTrig *self) { POST_PROCESSING_AREVA };
+static void NoteinTrig_postprocessing_revai(NoteinTrig *self) { POST_PROCESSING_REVAI };
+static void NoteinTrig_postprocessing_revaa(NoteinTrig *self) { POST_PROCESSING_REVAA };
+static void NoteinTrig_postprocessing_revareva(NoteinTrig *self) { POST_PROCESSING_REVAREVA };
static void
-MidiAdsr_generates(MidiAdsr *self) {
- MYFLT val;
- int i;
-
- MYFLT *in = Stream_getData((Stream *)self->input_stream);
+NoteinTrig_setProcMode(NoteinTrig *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = NoteinTrig_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = NoteinTrig_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = NoteinTrig_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = NoteinTrig_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = NoteinTrig_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = NoteinTrig_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = NoteinTrig_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = NoteinTrig_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = NoteinTrig_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+NoteinTrig_compute_next_data_frame(NoteinTrig *self)
+{
+ int i;
+ MYFLT *tmp = MidiNote_get_trigger_buffer(self->handler);
+
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = tmp[self->bufsize*(self->voice*2+self->mode)+i];
+ }
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+NoteinTrig_traverse(NoteinTrig *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->handler);
+ return 0;
+}
+
+static int
+NoteinTrig_clear(NoteinTrig *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->handler);
+ return 0;
+}
+
+static void
+NoteinTrig_dealloc(NoteinTrig* self)
+{
+ pyo_DEALLOC
+ NoteinTrig_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+NoteinTrig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *handlertmp=NULL, *multmp=NULL, *addtmp=NULL;
+ NoteinTrig *self;
+ self = (NoteinTrig *)type->tp_alloc(type, 0);
+
+ self->voice = 0;
+ self->mode = 0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, NoteinTrig_compute_next_data_frame);
+ self->mode_func_ptr = NoteinTrig_setProcMode;
+
+ static char *kwlist[] = {"handler", "voice", "mode", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iiOO", kwlist, &handlertmp, &self->voice, &self->mode, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ Py_XDECREF(self->handler);
+ Py_INCREF(handlertmp);
+ self->handler = (MidiNote *)handlertmp;
+
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ }
+
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * NoteinTrig_getServer(NoteinTrig* self) { GET_SERVER };
+static PyObject * NoteinTrig_getStream(NoteinTrig* self) { GET_STREAM };
+static PyObject * NoteinTrig_setMul(NoteinTrig *self, PyObject *arg) { SET_MUL };
+static PyObject * NoteinTrig_setAdd(NoteinTrig *self, PyObject *arg) { SET_ADD };
+static PyObject * NoteinTrig_setSub(NoteinTrig *self, PyObject *arg) { SET_SUB };
+static PyObject * NoteinTrig_setDiv(NoteinTrig *self, PyObject *arg) { SET_DIV };
+
+static PyObject * NoteinTrig_play(NoteinTrig *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * NoteinTrig_stop(NoteinTrig *self) { STOP };
+
+static PyObject * NoteinTrig_multiply(NoteinTrig *self, PyObject *arg) { MULTIPLY };
+static PyObject * NoteinTrig_inplace_multiply(NoteinTrig *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * NoteinTrig_add(NoteinTrig *self, PyObject *arg) { ADD };
+static PyObject * NoteinTrig_inplace_add(NoteinTrig *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * NoteinTrig_sub(NoteinTrig *self, PyObject *arg) { SUB };
+static PyObject * NoteinTrig_inplace_sub(NoteinTrig *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * NoteinTrig_div(NoteinTrig *self, PyObject *arg) { DIV };
+static PyObject * NoteinTrig_inplace_div(NoteinTrig *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef NoteinTrig_members[] = {
+{"server", T_OBJECT_EX, offsetof(NoteinTrig, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(NoteinTrig, stream), 0, "Stream object."},
+{"mul", T_OBJECT_EX, offsetof(NoteinTrig, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(NoteinTrig, add), 0, "Add factor."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef NoteinTrig_methods[] = {
+{"getServer", (PyCFunction)NoteinTrig_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)NoteinTrig_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)NoteinTrig_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"stop", (PyCFunction)NoteinTrig_stop, METH_NOARGS, "Stops computing."},
+{"setMul", (PyCFunction)NoteinTrig_setMul, METH_O, "Sets NoteinTrig mul factor."},
+{"setAdd", (PyCFunction)NoteinTrig_setAdd, METH_O, "Sets NoteinTrig add factor."},
+{"setSub", (PyCFunction)NoteinTrig_setSub, METH_O, "Sets inverse add factor."},
+{"setDiv", (PyCFunction)NoteinTrig_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
+};
+
+static PyNumberMethods NoteinTrig_as_number = {
+(binaryfunc)NoteinTrig_add, /*nb_add*/
+(binaryfunc)NoteinTrig_sub, /*nb_subtract*/
+(binaryfunc)NoteinTrig_multiply, /*nb_multiply*/
+(binaryfunc)NoteinTrig_div, /*nb_divide*/
+0, /*nb_remainder*/
+0, /*nb_divmod*/
+0, /*nb_power*/
+0, /*nb_neg*/
+0, /*nb_pos*/
+0, /*(unaryfunc)array_abs,*/
+0, /*nb_nonzero*/
+0, /*nb_invert*/
+0, /*nb_lshift*/
+0, /*nb_rshift*/
+0, /*nb_and*/
+0, /*nb_xor*/
+0, /*nb_or*/
+0, /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+0, /*nb_oct*/
+0, /*nb_hex*/
+(binaryfunc)NoteinTrig_inplace_add, /*inplace_add*/
+(binaryfunc)NoteinTrig_inplace_sub, /*inplace_subtract*/
+(binaryfunc)NoteinTrig_inplace_multiply, /*inplace_multiply*/
+(binaryfunc)NoteinTrig_inplace_div, /*inplace_divide*/
+0, /*inplace_remainder*/
+0, /*inplace_power*/
+0, /*inplace_lshift*/
+0, /*inplace_rshift*/
+0, /*inplace_and*/
+0, /*inplace_xor*/
+0, /*inplace_or*/
+0, /*nb_floor_divide*/
+0, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+0, /*nb_inplace_true_divide*/
+0, /* nb_index */
+};
+
+PyTypeObject NoteinTrigType = {
+PyObject_HEAD_INIT(NULL)
+0, /*ob_size*/
+"_pyo.NoteinTrig_base", /*tp_name*/
+sizeof(NoteinTrig), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)NoteinTrig_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_compare*/
+0, /*tp_repr*/
+&NoteinTrig_as_number, /*tp_as_number*/
+0, /*tp_as_sequence*/
+0, /*tp_as_mapping*/
+0, /*tp_hash */
+0, /*tp_call*/
+0, /*tp_str*/
+0, /*tp_getattro*/
+0, /*tp_setattro*/
+0, /*tp_as_buffer*/
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+"NoteinTrig objects. Stream noteon or noteoff trigger from a Notein voice.", /* tp_doc */
+(traverseproc)NoteinTrig_traverse, /* tp_traverse */
+(inquiry)NoteinTrig_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+NoteinTrig_methods, /* tp_methods */
+NoteinTrig_members, /* tp_members */
+0, /* tp_getset */
+0, /* tp_base */
+0, /* tp_dict */
+0, /* tp_descr_get */
+0, /* tp_descr_set */
+0, /* tp_dictoffset */
+0, /* tp_init */
+0, /* tp_alloc */
+NoteinTrig_new, /* tp_new */
+};
+
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ int modebuffer[2];
+ int fademode;
+ int changed;
+ MYFLT topValue;
+ MYFLT offsetAmp;
+ MYFLT initAmp;
+ MYFLT sustainAmp;
+ MYFLT attack;
+ MYFLT decay;
+ MYFLT sustain;
+ MYFLT release;
+ MYFLT invAttack;
+ MYFLT initAmpMinusOffsetAmp;
+ MYFLT attackPlusDecay;
+ MYFLT invDecay;
+ MYFLT initAmpMinusSustainAmp;
+ MYFLT invRelease;
+ double currentTime;
+ MYFLT sampleToSec;
+} MidiAdsr;
+
+static void
+MidiAdsr_generates(MidiAdsr *self) {
+ MYFLT val;
+ int i;
+
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
for (i=0; i<self->bufsize; i++) {
if (self->fademode == 0 && in[i] > 0.0) {
@@ -2543,7 +2837,7 @@ MidiAdsr_generates(MidiAdsr *self) {
self->sustainAmp = self->initAmp * self->sustain;
self->currentTime = 0.0;
self->invAttack = 1.0 / self->attack;
- self->invDecay = 1.0 / self->decay;
+ self->invDecay = 1.0 / self->decay;
self->attackPlusDecay = self->attack + self->decay;
self->initAmpMinusOffsetAmp = self->initAmp - self->offsetAmp;
self->initAmpMinusSustainAmp = self->initAmp - self->sustainAmp;
@@ -2553,7 +2847,7 @@ MidiAdsr_generates(MidiAdsr *self) {
self->currentTime = 0.0;
self->invRelease = 1.0 / self->release;
}
-
+
if (self->fademode == 1) {
if (self->currentTime <= self->attack)
val = self->currentTime * self->invAttack * self->initAmpMinusOffsetAmp + self->offsetAmp;
@@ -2562,15 +2856,15 @@ MidiAdsr_generates(MidiAdsr *self) {
else
val = self->sustainAmp;
self->topValue = val;
- }
- else {
+ }
+ else {
if (self->currentTime <= self->release)
val = self->topValue * (1. - self->currentTime * self->invRelease);
- else
+ else
val = 0.;
- }
+ }
self->data[i] = val;
- self->currentTime += self->sampleToSec;
+ self->currentTime += self->sampleToSec;
}
}
@@ -2589,44 +2883,44 @@ MidiAdsr_setProcMode(MidiAdsr *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = MidiAdsr_generates;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = MidiAdsr_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = MidiAdsr_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = MidiAdsr_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = MidiAdsr_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = MidiAdsr_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = MidiAdsr_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = MidiAdsr_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = MidiAdsr_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = MidiAdsr_postprocessing_revareva;
break;
- }
+ }
}
static void
MidiAdsr_compute_next_data_frame(MidiAdsr *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2639,7 +2933,7 @@ MidiAdsr_traverse(MidiAdsr *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
MidiAdsr_clear(MidiAdsr *self)
{
pyo_CLEAR
@@ -2663,7 +2957,7 @@ MidiAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
MidiAdsr *self;
self = (MidiAdsr *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->topValue = 0.0;
@@ -2674,7 +2968,7 @@ MidiAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sustain = 0.707;
self->release = 0.1;
self->currentTime = 0.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, MidiAdsr_compute_next_data_frame);
self->mode_func_ptr = MidiAdsr_setProcMode;
@@ -2682,22 +2976,22 @@ MidiAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sampleToSec = 1. / self->sr;
static char *kwlist[] = {"input", "attack", "decay", "sustain", "release", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FFFFOO, kwlist, &inputtmp, &self->attack, &self->decay, &self->sustain, &self->release, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
if (self->attack < 0.000001)
self->attack = 0.000001;
if (self->decay < 0.000001)
@@ -2716,10 +3010,10 @@ MidiAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * MidiAdsr_getServer(MidiAdsr* self) { GET_SERVER };
static PyObject * MidiAdsr_getStream(MidiAdsr* self) { GET_STREAM };
-static PyObject * MidiAdsr_setMul(MidiAdsr *self, PyObject *arg) { SET_MUL };
-static PyObject * MidiAdsr_setAdd(MidiAdsr *self, PyObject *arg) { SET_ADD };
-static PyObject * MidiAdsr_setSub(MidiAdsr *self, PyObject *arg) { SET_SUB };
-static PyObject * MidiAdsr_setDiv(MidiAdsr *self, PyObject *arg) { SET_DIV };
+static PyObject * MidiAdsr_setMul(MidiAdsr *self, PyObject *arg) { SET_MUL };
+static PyObject * MidiAdsr_setAdd(MidiAdsr *self, PyObject *arg) { SET_ADD };
+static PyObject * MidiAdsr_setSub(MidiAdsr *self, PyObject *arg) { SET_SUB };
+static PyObject * MidiAdsr_setDiv(MidiAdsr *self, PyObject *arg) { SET_DIV };
static PyObject * MidiAdsr_play(MidiAdsr *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * MidiAdsr_stop(MidiAdsr *self) { STOP }
@@ -2751,7 +3045,7 @@ MidiAdsr_setDecay(MidiAdsr *self, PyObject *arg)
self->decay = PyFloat_AsDouble(PyNumber_Float(arg));
if (self->decay < 0.000001)
self->decay = 0.000001;
- self->invDecay = 1.0 / self->decay;
+ self->invDecay = 1.0 / self->decay;
self->attackPlusDecay = self->attack + self->decay;
Py_INCREF(Py_None);
return Py_None;
@@ -2920,9 +3214,9 @@ static void
MidiDelAdsr_generates(MidiDelAdsr *self) {
MYFLT val;
int i;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (self->fademode == 0 && in[i] > 0.0) {
self->fademode = 1;
@@ -2931,7 +3225,7 @@ MidiDelAdsr_generates(MidiDelAdsr *self) {
self->sustainAmp = self->initAmp * self->sustain;
self->currentTime = 0.0;
self->invAttack = 1.0 / self->attack;
- self->invDecay = 1.0 / self->decay;
+ self->invDecay = 1.0 / self->decay;
self->delayPlusAttack = self->delay + self->attack;
self->delayPlusAttackPlusDecay = self->delay + self->attack + self->decay;
self->initAmpMinusOffsetAmp = self->initAmp - self->offsetAmp;
@@ -2942,7 +3236,7 @@ MidiDelAdsr_generates(MidiDelAdsr *self) {
self->currentTime = 0.0;
self->invRelease = 1.0 / self->release;
}
-
+
if (self->fademode == 1) {
if (self->currentTime < self->delay)
val = 0.0;
@@ -2953,15 +3247,15 @@ MidiDelAdsr_generates(MidiDelAdsr *self) {
else
val = self->sustainAmp;
self->topValue = val;
- }
- else {
+ }
+ else {
if (self->currentTime <= self->release)
val = self->topValue * (1. - self->currentTime * self->invRelease);
- else
+ else
val = 0.;
- }
+ }
self->data[i] = val;
- self->currentTime += self->sampleToSec;
+ self->currentTime += self->sampleToSec;
}
}
@@ -2980,44 +3274,44 @@ MidiDelAdsr_setProcMode(MidiDelAdsr *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = MidiDelAdsr_generates;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = MidiDelAdsr_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = MidiDelAdsr_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = MidiDelAdsr_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = MidiDelAdsr_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = MidiDelAdsr_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = MidiDelAdsr_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = MidiDelAdsr_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = MidiDelAdsr_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = MidiDelAdsr_postprocessing_revareva;
break;
- }
+ }
}
static void
MidiDelAdsr_compute_next_data_frame(MidiDelAdsr *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3030,7 +3324,7 @@ MidiDelAdsr_traverse(MidiDelAdsr *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
MidiDelAdsr_clear(MidiDelAdsr *self)
{
pyo_CLEAR
@@ -3054,7 +3348,7 @@ MidiDelAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
MidiDelAdsr *self;
self = (MidiDelAdsr *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->topValue = 0.0;
@@ -3066,28 +3360,28 @@ MidiDelAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sustain = 0.707;
self->release = 0.1;
self->currentTime = 0.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, MidiDelAdsr_compute_next_data_frame);
self->mode_func_ptr = MidiDelAdsr_setProcMode;
-
+
self->sampleToSec = 1. / self->sr;
static char *kwlist[] = {"input", "delay", "attack", "decay", "sustain", "release", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FFFFFOO, kwlist, &inputtmp, &self->delay, &self->attack, &self->decay, &self->sustain, &self->release, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
if (self->attack < 0.000001)
@@ -3100,18 +3394,18 @@ MidiDelAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sustain = 0.0;
else if (self->sustain > 1.0)
self->sustain = 1.0;
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * MidiDelAdsr_getServer(MidiDelAdsr* self) { GET_SERVER };
static PyObject * MidiDelAdsr_getStream(MidiDelAdsr* self) { GET_STREAM };
-static PyObject * MidiDelAdsr_setMul(MidiDelAdsr *self, PyObject *arg) { SET_MUL };
-static PyObject * MidiDelAdsr_setAdd(MidiDelAdsr *self, PyObject *arg) { SET_ADD };
-static PyObject * MidiDelAdsr_setSub(MidiDelAdsr *self, PyObject *arg) { SET_SUB };
-static PyObject * MidiDelAdsr_setDiv(MidiDelAdsr *self, PyObject *arg) { SET_DIV };
+static PyObject * MidiDelAdsr_setMul(MidiDelAdsr *self, PyObject *arg) { SET_MUL };
+static PyObject * MidiDelAdsr_setAdd(MidiDelAdsr *self, PyObject *arg) { SET_ADD };
+static PyObject * MidiDelAdsr_setSub(MidiDelAdsr *self, PyObject *arg) { SET_SUB };
+static PyObject * MidiDelAdsr_setDiv(MidiDelAdsr *self, PyObject *arg) { SET_DIV };
static PyObject * MidiDelAdsr_play(MidiDelAdsr *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * MidiDelAdsr_stop(MidiDelAdsr *self) { STOP }
@@ -3154,7 +3448,7 @@ MidiDelAdsr_setDecay(MidiDelAdsr *self, PyObject *arg)
self->decay = PyFloat_AsDouble(PyNumber_Float(arg));
if (self->decay < 0.000001)
self->decay = 0.000001;
- self->invDecay = 1.0 / self->decay;
+ self->invDecay = 1.0 / self->decay;
self->delayPlusAttackPlusDecay = self->delay + self->attack + self->decay;
Py_INCREF(Py_None);
return Py_None;
@@ -3293,3 +3587,167 @@ PyTypeObject MidiDelAdsrType = {
MidiDelAdsr_new, /* tp_new */
};
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *callable;
+} RawMidi;
+
+static void
+RawMidi_setProcMode(RawMidi *self) {}
+
+static void
+RawMidi_compute_next_data_frame(RawMidi *self)
+{
+ PmEvent *buffer;
+ int i, count, status, data1, data2;
+
+ buffer = Server_getMidiEventBuffer((Server *)self->server);
+ count = Server_getMidiEventCount((Server *)self->server);
+
+ if (count > 0) {
+ PyObject *tup;
+ for (i=count-1; i>=0; i--) {
+ status = Pm_MessageStatus(buffer[i].message); // Temp note event holders
+ data1 = Pm_MessageData1(buffer[i].message);
+ data2 = Pm_MessageData2(buffer[i].message);
+ tup = PyTuple_New(3);
+ PyTuple_SetItem(tup, 0, PyInt_FromLong(status));
+ PyTuple_SetItem(tup, 1, PyInt_FromLong(data1));
+ PyTuple_SetItem(tup, 2, PyInt_FromLong(data2));
+ PyObject_Call((PyObject *)self->callable, tup, NULL);
+ }
+ }
+}
+
+static int
+RawMidi_traverse(RawMidi *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->callable);
+ return 0;
+}
+
+static int
+RawMidi_clear(RawMidi *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->callable);
+ return 0;
+}
+
+static void
+RawMidi_dealloc(RawMidi* self)
+{
+ pyo_DEALLOC
+ RawMidi_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+RawMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *calltmp=NULL;
+ RawMidi *self;
+ self = (RawMidi *)type->tp_alloc(type, 0);
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, RawMidi_compute_next_data_frame);
+ self->mode_func_ptr = RawMidi_setProcMode;
+
+ static char *kwlist[] = {"callable", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &calltmp))
+ Py_RETURN_NONE;
+
+ if (calltmp) {
+ PyObject_CallMethod((PyObject *)self, "setFunction", "O", calltmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ return (PyObject *)self;
+}
+
+static PyObject * RawMidi_getServer(RawMidi* self) { GET_SERVER };
+static PyObject * RawMidi_getStream(RawMidi* self) { GET_STREAM };
+
+static PyObject * RawMidi_play(RawMidi *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * RawMidi_stop(RawMidi *self) { STOP };
+
+static PyObject *
+RawMidi_setFunction(RawMidi *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ if (! PyCallable_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError, "The callable attribute must be a valid Python function.");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ tmp = arg;
+ Py_XDECREF(self->callable);
+ Py_INCREF(tmp);
+ self->callable = tmp;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef RawMidi_members[] = {
+ {"server", T_OBJECT_EX, offsetof(RawMidi, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(RawMidi, stream), 0, "Stream object."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef RawMidi_methods[] = {
+ {"getServer", (PyCFunction)RawMidi_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)RawMidi_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)RawMidi_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"stop", (PyCFunction)RawMidi_stop, METH_NOARGS, "Stops computing."},
+ {"setFunction", (PyCFunction)RawMidi_setFunction, METH_O, "Sets the function to be called."},
+ {NULL} /* Sentinel */
+};
+
+PyTypeObject RawMidiType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.RawMidi_base", /*tp_name*/
+ sizeof(RawMidi), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)RawMidi_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "RawMidi objects. Calls a function with midi data as arguments.", /* tp_doc */
+ (traverseproc)RawMidi_traverse, /* tp_traverse */
+ (inquiry)RawMidi_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ RawMidi_methods, /* tp_methods */
+ RawMidi_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ RawMidi_new, /* tp_new */
+};
diff --git a/src/objects/noisemodule.c b/src/objects/noisemodule.c
index 681b905..2245fad 100644
--- a/src/objects/noisemodule.c
+++ b/src/objects/noisemodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -44,7 +44,7 @@ Noise_generate(Noise *self) {
static void
Noise_generate_cheap(Noise *self) {
int i;
-
+
for (i=0; i<self->bufsize; i++) {
self->seed = (self->seed * 15625 + 1) & 0xFFFF;
self->data[i] = (self->seed - 0x8000) * 3.0517578125e-05;
@@ -66,7 +66,7 @@ Noise_setProcMode(Noise *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (self->type) {
case 0:
self->proc_func_ptr = Noise_generate;
@@ -76,31 +76,31 @@ Noise_setProcMode(Noise *self)
break;
}
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Noise_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Noise_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Noise_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Noise_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Noise_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Noise_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Noise_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Noise_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Noise_postprocessing_revareva;
break;
}
@@ -109,7 +109,7 @@ Noise_setProcMode(Noise *self)
static void
Noise_compute_next_data_frame(Noise *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -120,7 +120,7 @@ Noise_traverse(Noise *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Noise_clear(Noise *self)
{
pyo_CLEAR
@@ -142,7 +142,7 @@ Noise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *multmp=NULL, *addtmp=NULL;
Noise *self;
self = (Noise *)type->tp_alloc(type, 0);
-
+
self->type = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
@@ -152,35 +152,35 @@ Noise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Noise_setProcMode;
static char *kwlist[] = {"mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist, &multmp, &addtmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Server_generateSeed((Server *)self->server, NOISE_ID);
-
+
self->seed = rand();
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Noise_getServer(Noise* self) { GET_SERVER };
static PyObject * Noise_getStream(Noise* self) { GET_STREAM };
-static PyObject * Noise_setMul(Noise *self, PyObject *arg) { SET_MUL };
-static PyObject * Noise_setAdd(Noise *self, PyObject *arg) { SET_ADD };
-static PyObject * Noise_setSub(Noise *self, PyObject *arg) { SET_SUB };
-static PyObject * Noise_setDiv(Noise *self, PyObject *arg) { SET_DIV };
+static PyObject * Noise_setMul(Noise *self, PyObject *arg) { SET_MUL };
+static PyObject * Noise_setAdd(Noise *self, PyObject *arg) { SET_ADD };
+static PyObject * Noise_setSub(Noise *self, PyObject *arg) { SET_SUB };
+static PyObject * Noise_setDiv(Noise *self, PyObject *arg) { SET_DIV };
static PyObject * Noise_play(Noise *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Noise_out(Noise *self, PyObject *args, PyObject *kwds) { OUT };
@@ -197,12 +197,12 @@ static PyObject * Noise_inplace_div(Noise *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
Noise_setType(Noise *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
if (PyInt_AS_LONG(arg) == 0)
self->type = 0;
else if (PyInt_AS_LONG(arg) == 1)
@@ -212,7 +212,7 @@ Noise_setType(Noise *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Noise_members[] = {
{"server", T_OBJECT_EX, offsetof(Noise, server), 0, "Pyo server."},
@@ -336,7 +336,7 @@ static void
PinkNoise_generate(PinkNoise *self) {
MYFLT in, val;
int i;
-
+
for (i=0; i<self->bufsize; i++) {
in = rand()/((MYFLT)(RAND_MAX)+1)*1.98-0.99;
self->c0 = self->c0 * 0.99886 + in * 0.0555179;
@@ -366,33 +366,33 @@ PinkNoise_setProcMode(PinkNoise *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = PinkNoise_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = PinkNoise_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = PinkNoise_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = PinkNoise_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = PinkNoise_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = PinkNoise_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = PinkNoise_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = PinkNoise_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = PinkNoise_postprocessing_revareva;
break;
}
@@ -401,7 +401,7 @@ PinkNoise_setProcMode(PinkNoise *self)
static void
PinkNoise_compute_next_data_frame(PinkNoise *self)
{
- PinkNoise_generate(self);
+ PinkNoise_generate(self);
(*self->muladd_func_ptr)(self);
}
@@ -412,7 +412,7 @@ PinkNoise_traverse(PinkNoise *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PinkNoise_clear(PinkNoise *self)
{
pyo_CLEAR
@@ -434,32 +434,32 @@ PinkNoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *multmp=NULL, *addtmp=NULL;
PinkNoise *self;
self = (PinkNoise *)type->tp_alloc(type, 0);
-
+
self->c0 = self->c1 = self->c2 = self->c3 = self->c4 = self->c5 = self->c6 = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, PinkNoise_compute_next_data_frame);
self->mode_func_ptr = PinkNoise_setProcMode;
static char *kwlist[] = {"mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
Server_generateSeed((Server *)self->server, PINKNOISE_ID);
return (PyObject *)self;
@@ -467,10 +467,10 @@ PinkNoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * PinkNoise_getServer(PinkNoise* self) { GET_SERVER };
static PyObject * PinkNoise_getStream(PinkNoise* self) { GET_STREAM };
-static PyObject * PinkNoise_setMul(PinkNoise *self, PyObject *arg) { SET_MUL };
-static PyObject * PinkNoise_setAdd(PinkNoise *self, PyObject *arg) { SET_ADD };
-static PyObject * PinkNoise_setSub(PinkNoise *self, PyObject *arg) { SET_SUB };
-static PyObject * PinkNoise_setDiv(PinkNoise *self, PyObject *arg) { SET_DIV };
+static PyObject * PinkNoise_setMul(PinkNoise *self, PyObject *arg) { SET_MUL };
+static PyObject * PinkNoise_setAdd(PinkNoise *self, PyObject *arg) { SET_ADD };
+static PyObject * PinkNoise_setSub(PinkNoise *self, PyObject *arg) { SET_SUB };
+static PyObject * PinkNoise_setDiv(PinkNoise *self, PyObject *arg) { SET_DIV };
static PyObject * PinkNoise_play(PinkNoise *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * PinkNoise_out(PinkNoise *self, PyObject *args, PyObject *kwds) { OUT };
@@ -602,7 +602,7 @@ static void
BrownNoise_generate(BrownNoise *self) {
MYFLT rnd, val;
int i;
-
+
for (i=0; i<self->bufsize; i++) {
rnd = rand()/((MYFLT)(RAND_MAX)+1)*1.98-0.99;
val = self->c1 * rnd + self->c2 * self->y1;
@@ -626,33 +626,33 @@ BrownNoise_setProcMode(BrownNoise *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = BrownNoise_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = BrownNoise_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = BrownNoise_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = BrownNoise_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = BrownNoise_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = BrownNoise_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = BrownNoise_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = BrownNoise_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = BrownNoise_postprocessing_revareva;
break;
}
@@ -661,7 +661,7 @@ BrownNoise_setProcMode(BrownNoise *self)
static void
BrownNoise_compute_next_data_frame(BrownNoise *self)
{
- BrownNoise_generate(self);
+ BrownNoise_generate(self);
(*self->muladd_func_ptr)(self);
}
@@ -672,7 +672,7 @@ BrownNoise_traverse(BrownNoise *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
BrownNoise_clear(BrownNoise *self)
{
pyo_CLEAR
@@ -695,47 +695,47 @@ BrownNoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *multmp=NULL, *addtmp=NULL;
BrownNoise *self;
self = (BrownNoise *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->y1 = self->c1 = self->c2 = 0.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, BrownNoise_compute_next_data_frame);
self->mode_func_ptr = BrownNoise_setProcMode;
static char *kwlist[] = {"mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
b = 2.0 - MYCOS(TWOPI * 20.0 / self->sr);
self->c2 = (b - MYSQRT(b * b - 1.0));
self->c1 = 1.0 - self->c2;
-
+
(*self->mode_func_ptr)(self);
-
+
Server_generateSeed((Server *)self->server, BROWNNOISE_ID);
-
+
return (PyObject *)self;
}
static PyObject * BrownNoise_getServer(BrownNoise* self) { GET_SERVER };
static PyObject * BrownNoise_getStream(BrownNoise* self) { GET_STREAM };
-static PyObject * BrownNoise_setMul(BrownNoise *self, PyObject *arg) { SET_MUL };
-static PyObject * BrownNoise_setAdd(BrownNoise *self, PyObject *arg) { SET_ADD };
-static PyObject * BrownNoise_setSub(BrownNoise *self, PyObject *arg) { SET_SUB };
-static PyObject * BrownNoise_setDiv(BrownNoise *self, PyObject *arg) { SET_DIV };
+static PyObject * BrownNoise_setMul(BrownNoise *self, PyObject *arg) { SET_MUL };
+static PyObject * BrownNoise_setAdd(BrownNoise *self, PyObject *arg) { SET_ADD };
+static PyObject * BrownNoise_setSub(BrownNoise *self, PyObject *arg) { SET_SUB };
+static PyObject * BrownNoise_setDiv(BrownNoise *self, PyObject *arg) { SET_DIV };
static PyObject * BrownNoise_play(BrownNoise *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * BrownNoise_out(BrownNoise *self, PyObject *args, PyObject *kwds) { OUT };
@@ -854,4 +854,3 @@ PyTypeObject BrownNoiseType = {
0, /* tp_alloc */
BrownNoise_new, /* tp_new */
};
-
diff --git a/src/objects/oscbankmodule.c b/src/objects/oscbankmodule.c
index b8b4cd3..b8a8f3f 100644
--- a/src/objects/oscbankmodule.c
+++ b/src/objects/oscbankmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -87,7 +87,7 @@ OscBank_setFrequencies(OscBank *self, MYFLT freq, MYFLT spread) {
int i, seed;
MYFLT rnd;
MYFLT scl = freq * spread;
-
+
if (self->fjit == 1) {
seed = rand();
for (i=0; i<self->stages; i++) {
@@ -133,7 +133,7 @@ OscBank_pickNewArnds(OscBank *self, MYFLT arndf, MYFLT arnda) {
arnda = 0.0;
else if (arnda > 1.0)
arnda = 1.0;
-
+
seed = rand();
for (i=0; i<self->stages; i++) {
self->aOldValues[i] = self->aValues[i];
@@ -154,7 +154,7 @@ OscBank_readframes(OscBank *self) {
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
}
-
+
if (self->modebuffer[2] == 0)
freq = PyFloat_AS_DOUBLE(self->freq);
else
@@ -183,7 +183,7 @@ OscBank_readframes(OscBank *self) {
arnda = PyFloat_AS_DOUBLE(self->arnda);
else
arnda = Stream_getData((Stream *)self->arnda_stream)[0];
-
+
if (freq != self->lastFreq || spread != self->lastSpread) {
self->lastFreq = freq;
self->lastSpread = spread;
@@ -201,7 +201,7 @@ OscBank_readframes(OscBank *self) {
if (frnda == 0.0 && arnda == 0.0) {
amp = self->amplitude;
- for (j=0; j<self->stages; j++) {
+ for (j=0; j<self->stages; j++) {
inc = self->frequencies[j] * tabscl;
pos = self->pointerPos[j];
for (i=0; i<self->bufsize; i++) {
@@ -289,7 +289,7 @@ OscBank_readframes(OscBank *self) {
}
self->atime += self->ainc;
}
-
+
}
static void OscBank_postprocessing_ii(OscBank *self) { POST_PROCESSING_II };
@@ -311,40 +311,40 @@ OscBank_setProcMode(OscBank *self)
self->proc_func_ptr = OscBank_readframes;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = OscBank_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = OscBank_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = OscBank_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = OscBank_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = OscBank_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = OscBank_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = OscBank_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = OscBank_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = OscBank_postprocessing_revareva;
break;
- }
+ }
}
static void
OscBank_compute_next_data_frame(OscBank *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -353,42 +353,42 @@ OscBank_traverse(OscBank *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->spread);
- Py_VISIT(self->spread_stream);
- Py_VISIT(self->slope);
- Py_VISIT(self->slope_stream);
- Py_VISIT(self->frndf);
- Py_VISIT(self->frndf_stream);
- Py_VISIT(self->frnda);
- Py_VISIT(self->frnda_stream);
- Py_VISIT(self->arndf);
- Py_VISIT(self->arndf_stream);
- Py_VISIT(self->arnda);
- Py_VISIT(self->arnda_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->spread);
+ Py_VISIT(self->spread_stream);
+ Py_VISIT(self->slope);
+ Py_VISIT(self->slope_stream);
+ Py_VISIT(self->frndf);
+ Py_VISIT(self->frndf_stream);
+ Py_VISIT(self->frnda);
+ Py_VISIT(self->frnda_stream);
+ Py_VISIT(self->arndf);
+ Py_VISIT(self->arndf_stream);
+ Py_VISIT(self->arnda);
+ Py_VISIT(self->arnda_stream);
return 0;
}
-static int
+static int
OscBank_clear(OscBank *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->spread);
- Py_CLEAR(self->spread_stream);
- Py_CLEAR(self->slope);
- Py_CLEAR(self->slope_stream);
- Py_CLEAR(self->frndf);
- Py_CLEAR(self->frndf_stream);
- Py_CLEAR(self->frnda);
- Py_CLEAR(self->frnda_stream);
- Py_CLEAR(self->arndf);
- Py_CLEAR(self->arndf_stream);
- Py_CLEAR(self->arnda);
- Py_CLEAR(self->arnda_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->spread);
+ Py_CLEAR(self->spread_stream);
+ Py_CLEAR(self->slope);
+ Py_CLEAR(self->slope_stream);
+ Py_CLEAR(self->frndf);
+ Py_CLEAR(self->frndf_stream);
+ Py_CLEAR(self->frnda);
+ Py_CLEAR(self->frnda_stream);
+ Py_CLEAR(self->arndf);
+ Py_CLEAR(self->arndf_stream);
+ Py_CLEAR(self->arnda);
+ Py_CLEAR(self->arnda_stream);
return 0;
}
@@ -415,7 +415,7 @@ OscBank_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *freqtmp=NULL, *spreadtmp=NULL, *slopetmp=NULL, *frndftmp=NULL, *frndatmp=NULL, *arndftmp=NULL, *arndatmp=NULL, *multmp=NULL, *addtmp=NULL;
OscBank *self;
self = (OscBank *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100.0);
self->spread = PyFloat_FromDouble(1.0);
self->slope = PyFloat_FromDouble(0.9);
@@ -440,23 +440,20 @@ OscBank_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[6] = 0;
self->modebuffer[7] = 0;
self->modebuffer[8] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, OscBank_compute_next_data_frame);
self->mode_func_ptr = OscBank_setProcMode;
static char *kwlist[] = {"table", "freq", "spread", "slope", "frndf", "frnda", "arndf", "arnda", "num", "fjit", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOOOOiiOO", kwlist, &tabletmp, &freqtmp, &spreadtmp, &slopetmp, &frndftmp, &frndatmp, &arndftmp, &arndatmp, &self->stages, &self->fjit, &multmp, &addtmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of OscBank must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of OscBank must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
@@ -464,7 +461,7 @@ OscBank_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (spreadtmp) {
PyObject_CallMethod((PyObject *)self, "setSpread", "O", spreadtmp);
}
@@ -486,17 +483,17 @@ OscBank_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (arndatmp) {
PyObject_CallMethod((PyObject *)self, "setArnda", "O", arndatmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
self->pointerPos = (MYFLT *)realloc(self->pointerPos, self->stages * sizeof(MYFLT));
@@ -507,11 +504,11 @@ OscBank_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->aOldValues = (MYFLT *)realloc(self->aOldValues, self->stages * sizeof(MYFLT));
self->aValues = (MYFLT *)realloc(self->aValues, self->stages * sizeof(MYFLT));
self->aDiffs = (MYFLT *)realloc(self->aDiffs, self->stages * sizeof(MYFLT));
-
+
for (i=0; i<self->stages; i++) {
self->pointerPos[i] = self->frequencies[i] = self->fOldValues[i] = self->fValues[i] = self->fDiffs[i] = self->aOldValues[i] = self->aValues[i] = self->aDiffs[i] = 0.0;
}
-
+
self->amplitude = 1. / self->stages;
Server_generateSeed((Server *)self->server, OSCBANK_ID);
@@ -521,10 +518,10 @@ OscBank_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * OscBank_getServer(OscBank* self) { GET_SERVER };
static PyObject * OscBank_getStream(OscBank* self) { GET_STREAM };
-static PyObject * OscBank_setMul(OscBank *self, PyObject *arg) { SET_MUL };
-static PyObject * OscBank_setAdd(OscBank *self, PyObject *arg) { SET_ADD };
-static PyObject * OscBank_setSub(OscBank *self, PyObject *arg) { SET_SUB };
-static PyObject * OscBank_setDiv(OscBank *self, PyObject *arg) { SET_DIV };
+static PyObject * OscBank_setMul(OscBank *self, PyObject *arg) { SET_MUL };
+static PyObject * OscBank_setAdd(OscBank *self, PyObject *arg) { SET_ADD };
+static PyObject * OscBank_setSub(OscBank *self, PyObject *arg) { SET_SUB };
+static PyObject * OscBank_setDiv(OscBank *self, PyObject *arg) { SET_DIV };
static PyObject * OscBank_play(OscBank *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * OscBank_out(OscBank *self, PyObject *args, PyObject *kwds) { OUT };
@@ -550,32 +547,32 @@ static PyObject *
OscBank_setTable(OscBank *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscBank_setFreq(OscBank *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -594,20 +591,20 @@ OscBank_setFreq(OscBank *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscBank_setSpread(OscBank *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->spread);
@@ -626,20 +623,20 @@ OscBank_setSpread(OscBank *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscBank_setSlope(OscBank *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->slope);
@@ -655,23 +652,23 @@ OscBank_setSlope(OscBank *self, PyObject *arg)
self->slope_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscBank_setFrndf(OscBank *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->frndf);
@@ -687,23 +684,23 @@ OscBank_setFrndf(OscBank *self, PyObject *arg)
self->frndf_stream = (Stream *)streamtmp;
self->modebuffer[5] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscBank_setFrnda(OscBank *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->frnda);
@@ -719,23 +716,23 @@ OscBank_setFrnda(OscBank *self, PyObject *arg)
self->frnda_stream = (Stream *)streamtmp;
self->modebuffer[6] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscBank_setArndf(OscBank *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->arndf);
@@ -751,23 +748,23 @@ OscBank_setArndf(OscBank *self, PyObject *arg)
self->arndf_stream = (Stream *)streamtmp;
self->modebuffer[7] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscBank_setArnda(OscBank *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->arnda);
@@ -783,14 +780,14 @@ OscBank_setArnda(OscBank *self, PyObject *arg)
self->arnda_stream = (Stream *)streamtmp;
self->modebuffer[8] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscBank_setFjit(OscBank *self, PyObject *arg)
-{
+{
int isInt = PyInt_Check(arg);
if (isInt) {
@@ -799,7 +796,7 @@ OscBank_setFjit(OscBank *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef OscBank_members[] = {
{"server", T_OBJECT_EX, offsetof(OscBank, server), 0, "Pyo server."},
@@ -921,4 +918,3 @@ PyTypeObject OscBankType = {
0, /* tp_alloc */
OscBank_new, /* tp_new */
};
-
diff --git a/src/objects/oscilmodule.c b/src/objects/oscilmodule.c
index ca15b18..aac2444 100644
--- a/src/objects/oscilmodule.c
+++ b/src/objects/oscilmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -29,8 +29,8 @@
#include "interpolation.h"
static MYFLT SINE_ARRAY[513] = {0.0, 0.012271538285719925, 0.024541228522912288, 0.036807222941358832, 0.049067674327418015, 0.061320736302208578, 0.073564563599667426, 0.085797312344439894, 0.098017140329560604, 0.11022220729388306, 0.1224106751992162, 0.13458070850712617, 0.14673047445536175, 0.15885814333386145, 0.17096188876030122, 0.18303988795514095, 0.19509032201612825, 0.20711137619221856, 0.2191012401568698, 0.23105810828067111, 0.24298017990326387, 0.25486565960451457, 0.26671275747489837, 0.27851968938505306, 0.29028467725446233, 0.30200594931922808, 0.31368174039889152, 0.32531029216226293, 0.33688985339222005, 0.34841868024943456, 0.35989503653498811, 0.37131719395183754, 0.38268343236508978, 0.3939920400610481, 0.40524131400498986, 0.41642956009763715, 0.42755509343028208, 0.43861623853852766, 0.44961132965460654, 0.46053871095824001, 0.47139673682599764, 0.48218377207912272, 0.49289819222978404, 0.50353838372571758, 0.51410274419322166, 0.52458968267846895, 0.53499761988709715, 0.54532498842204646, 0.55557023301960218, 0.56573181078361312, 0.57580819141784534, 0.58579785745643886, 0.59569930449243336, 0.60551104140432555, 0.61523159058062682, 0.62485948814238634, 0.63439328416364549, 0.64383154288979139, 0.65317284295377676, 0.66241577759017178, 0.67155895484701833, 0.68060099779545302, 0.68954054473706683, 0.69837624940897292, 0.70710678118654746, 0.71573082528381859, 0.72424708295146689, 0.7326542716724127, 0.74095112535495899, 0.74913639452345926, 0.75720884650648446, 0.76516726562245885, 0.77301045336273688, 0.78073722857209438, 0.78834642762660623, 0.79583690460888346, 0.80320753148064483, 0.81045719825259477, 0.81758481315158371, 0.82458930278502529, 0.83146961230254512, 0.83822470555483797, 0.84485356524970701, 0.8513551931052652, 0.85772861000027212, 0.8639728561215867, 0.87008699110871135, 0.87607009419540649, 0.88192126434835494, 0.88763962040285393, 0.89322430119551532, 0.89867446569395382, 0.90398929312344334, 0.90916798309052238, 0.91420975570353069, 0.91911385169005777, 0.92387953251128674, 0.92850608047321548, 0.93299279883473885, 0.93733901191257496, 0.94154406518302081, 0.94560732538052128, 0.94952818059303667, 0.95330604035419375, 0.95694033573220894, 0.96043051941556579, 0.96377606579543984, 0.96697647104485207, 0.97003125319454397, 0.97293995220556007, 0.97570213003852857, 0.97831737071962765, 0.98078528040323043, 0.98310548743121629, 0.98527764238894122, 0.98730141815785843, 0.98917650996478101, 0.99090263542778001, 0.99247953459870997, 0.99390697000235606, 0.99518472667219682, 0.996312612182778, 0.99729045667869021, 0.99811811290014918, 0.99879545620517241, 0.99932238458834954, 0.99969881869620425, 0.9999247018391445, 1.0, 0.9999247018391445, 0.99969881869620425, 0.99932238458834954, 0.99879545620517241, 0.99811811290014918, 0.99729045667869021, 0.996312612182778, 0.99518472667219693, 0.99390697000235606, 0.99247953459870997, 0.99090263542778001, 0.98917650996478101, 0.98730141815785843, 0.98527764238894122, 0.98310548743121629, 0.98078528040323043, 0.97831737071962765, 0.97570213003852857, 0.97293995220556018, 0.97003125319454397, 0.96697647104485207, 0.96377606579543984, 0.9604305194155659, 0.95694033573220894, 0.95330604035419386, 0.94952818059303667, 0.94560732538052139, 0.94154406518302081, 0.93733901191257496, 0.93299279883473885, 0.92850608047321559, 0.92387953251128674, 0.91911385169005777, 0.91420975570353069, 0.90916798309052249, 0.90398929312344345, 0.89867446569395393, 0.89322430119551521, 0.88763962040285393, 0.88192126434835505, 0.8760700941954066, 0.87008699110871146, 0.86397285612158681, 0.85772861000027212, 0.8513551931052652, 0.84485356524970723, 0.83822470555483819, 0.83146961230254546, 0.82458930278502529, 0.81758481315158371, 0.81045719825259477, 0.80320753148064494, 0.79583690460888357, 0.78834642762660634, 0.7807372285720946, 0.7730104533627371, 0.76516726562245907, 0.75720884650648479, 0.74913639452345926, 0.74095112535495899, 0.73265427167241282, 0.724247082951467, 0.71573082528381871, 0.70710678118654757, 0.69837624940897292, 0.68954054473706705, 0.68060099779545324, 0.67155895484701855, 0.66241577759017201, 0.65317284295377664, 0.64383154288979139, 0.63439328416364549, 0.62485948814238634, 0.61523159058062693, 0.60551104140432555, 0.59569930449243347, 0.58579785745643898, 0.57580819141784545, 0.56573181078361345, 0.55557023301960218, 0.54532498842204635, 0.53499761988709715, 0.52458968267846895, 0.51410274419322177, 0.50353838372571758, 0.49289819222978415, 0.48218377207912289, 0.47139673682599781, 0.46053871095824023, 0.44961132965460687, 0.43861623853852755, 0.42755509343028203, 0.41642956009763715, 0.40524131400498986, 0.39399204006104815, 0.38268343236508984, 0.37131719395183765, 0.35989503653498833, 0.34841868024943479, 0.33688985339222027, 0.3253102921622632, 0.31368174039889141, 0.30200594931922803, 0.29028467725446233, 0.27851968938505312, 0.26671275747489848, 0.25486565960451468, 0.24298017990326404, 0.2310581082806713, 0.21910124015687002, 0.20711137619221884, 0.19509032201612858, 0.1830398879551409, 0.17096188876030119, 0.15885814333386145, 0.1467304744553618, 0.13458070850712628, 0.12241067519921635, 0.11022220729388325, 0.09801714032956084, 0.085797312344440158, 0.073564563599667745, 0.061320736302208495, 0.049067674327417973, 0.036807222941358832, 0.024541228522912326, 0.012271538285720007, 1.2246467991473532e-16, -0.012271538285719761, -0.024541228522912083, -0.036807222941358582, -0.049067674327417724, -0.061320736302208245, -0.073564563599667496, -0.085797312344439922, -0.09801714032956059, -0.110222207293883, -0.1224106751992161, -0.13458070850712606, -0.14673047445536158, -0.15885814333386122, -0.17096188876030097, -0.18303988795514067, -0.19509032201612836, -0.20711137619221862, -0.21910124015686983, -0.23105810828067111, -0.24298017990326382, -0.25486565960451446, -0.26671275747489825, -0.27851968938505289, -0.29028467725446216, -0.30200594931922781, -0.31368174039889118, -0.32531029216226304, -0.33688985339222011, -0.34841868024943456, -0.35989503653498811, -0.37131719395183749, -0.38268343236508967, -0.39399204006104793, -0.40524131400498969, -0.41642956009763693, -0.42755509343028181, -0.43861623853852733, -0.44961132965460665, -0.46053871095824006, -0.47139673682599764, -0.48218377207912272, -0.49289819222978393, -0.50353838372571746, -0.51410274419322155, -0.52458968267846873, -0.53499761988709693, -0.54532498842204613, -0.55557023301960196, -0.56573181078361323, -0.57580819141784534, -0.58579785745643886, -0.59569930449243325, -0.60551104140432543, -0.61523159058062671, -0.62485948814238623, -0.63439328416364527, -0.64383154288979128, -0.65317284295377653, -0.66241577759017178, -0.67155895484701844, -0.68060099779545302, -0.68954054473706683, -0.6983762494089728, -0.70710678118654746, -0.71573082528381848, -0.72424708295146667, -0.73265427167241259, -0.74095112535495877, -0.74913639452345904, -0.75720884650648423, -0.76516726562245885, -0.77301045336273666, -0.78073722857209438, -0.78834642762660589, -0.79583690460888334, -0.80320753148064505, -0.81045719825259466, -0.81758481315158371, -0.82458930278502507, -0.83146961230254524, -0.83822470555483775, -0.84485356524970712, -0.85135519310526486, -0.85772861000027201, -0.86397285612158647, -0.87008699110871135, -0.87607009419540671, -0.88192126434835494, -0.88763962040285405, -0.89322430119551521, -0.89867446569395382, -0.90398929312344312, -0.90916798309052238, -0.91420975570353047, -0.91911385169005766, -0.92387953251128652, -0.92850608047321548, -0.93299279883473896, -0.93733901191257485, -0.94154406518302081, -0.94560732538052117, -0.94952818059303667, -0.95330604035419375, -0.95694033573220882, -0.96043051941556568, -0.96377606579543984, -0.96697647104485218, -0.97003125319454397, -0.97293995220556018, -0.97570213003852846, -0.97831737071962765, -0.98078528040323032, -0.98310548743121629, -0.98527764238894111, -0.98730141815785832, -0.9891765099647809, -0.99090263542778001, -0.99247953459871008, -0.99390697000235606, -0.99518472667219693, -0.996312612182778, -0.99729045667869021, -0.99811811290014918, -0.99879545620517241, -0.99932238458834943, -0.99969881869620425, -0.9999247018391445, -1.0, -0.9999247018391445, -0.99969881869620425, -0.99932238458834954, -0.99879545620517241, -0.99811811290014918, -0.99729045667869021, -0.996312612182778, -0.99518472667219693, -0.99390697000235606, -0.99247953459871008, -0.99090263542778001, -0.9891765099647809, -0.98730141815785843, -0.98527764238894122, -0.9831054874312164, -0.98078528040323043, -0.97831737071962777, -0.97570213003852857, -0.97293995220556029, -0.97003125319454397, -0.96697647104485229, -0.96377606579543995, -0.96043051941556579, -0.95694033573220894, -0.95330604035419375, -0.94952818059303679, -0.94560732538052128, -0.94154406518302092, -0.93733901191257496, -0.93299279883473907, -0.92850608047321559, -0.92387953251128663, -0.91911385169005788, -0.91420975570353058, -0.90916798309052249, -0.90398929312344334, -0.89867446569395404, -0.89322430119551532, -0.88763962040285416, -0.88192126434835505, -0.87607009419540693, -0.87008699110871146, -0.8639728561215867, -0.85772861000027223, -0.85135519310526508, -0.84485356524970734, -0.83822470555483797, -0.83146961230254557, -0.82458930278502529, -0.81758481315158404, -0.81045719825259488, -0.80320753148064528, -0.79583690460888368, -0.78834642762660612, -0.78073722857209471, -0.77301045336273688, -0.76516726562245918, -0.75720884650648457, -0.7491363945234597, -0.74095112535495922, -0.73265427167241315, -0.72424708295146711, -0.71573082528381904, -0.70710678118654768, -0.69837624940897269, -0.68954054473706716, -0.68060099779545302, -0.67155895484701866, -0.66241577759017178, -0.65317284295377709, -0.6438315428897915, -0.63439328416364593, -0.62485948814238645, -0.61523159058062737, -0.60551104140432566, -0.59569930449243325, -0.58579785745643909, -0.57580819141784523, -0.56573181078361356, -0.55557023301960218, -0.5453249884220468, -0.53499761988709726, -0.52458968267846939, -0.51410274419322188, -0.50353838372571813, -0.49289819222978426, -0.48218377207912261, -0.47139673682599792, -0.46053871095823995, -0.44961132965460698, -0.43861623853852766, -0.42755509343028253, -0.41642956009763726, -0.40524131400499042, -0.39399204006104827, -0.38268343236509039, -0.37131719395183777, -0.359895036534988, -0.3484186802494349, -0.33688985339222, -0.32531029216226331, -0.31368174039889152, -0.30200594931922853, -0.29028467725446244, -0.27851968938505367, -0.26671275747489859, -0.25486565960451435, -0.24298017990326418, -0.23105810828067103, -0.21910124015687016, -0.20711137619221853, -0.19509032201612872, -0.18303988795514103, -0.17096188876030177, -0.15885814333386158, -0.14673047445536239, -0.13458070850712642, -0.12241067519921603, -0.11022220729388338, -0.09801714032956052, -0.085797312344440282, -0.073564563599667426, -0.06132073630220905, -0.049067674327418091, -0.036807222941359394, -0.024541228522912451, -0.012271538285720572, 0.0};
-static MYFLT COSINE_ARRAY[513] = {1.0, 0.9999247018391445, 0.9996988186962042, 0.9993223845883495, 0.9987954562051724, 0.9981181129001492, 0.9972904566786902, 0.996312612182778, 0.9951847266721969, 0.9939069700023561, 0.99247953459871, 0.99090263542778, 0.989176509964781, 0.9873014181578584, 0.9852776423889412, 0.9831054874312163, 0.9807852804032304, 0.9783173707196277, 0.9757021300385286, 0.9729399522055602, 0.970031253194544, 0.9669764710448521, 0.9637760657954398, 0.9604305194155658, 0.9569403357322088, 0.9533060403541939, 0.9495281805930367, 0.9456073253805213, 0.9415440651830208, 0.937339011912575, 0.932992798834739, 0.9285060804732156, 0.9238795325112867, 0.9191138516900578, 0.9142097557035307, 0.9091679830905224, 0.9039892931234433, 0.8986744656939538, 0.8932243011955153, 0.8876396204028539, 0.881921264348355, 0.8760700941954066, 0.8700869911087115, 0.8639728561215868, 0.8577286100002721, 0.8513551931052652, 0.8448535652497071, 0.8382247055548381, 0.8314696123025452, 0.8245893027850253, 0.8175848131515837, 0.8104571982525948, 0.8032075314806449, 0.7958369046088836, 0.7883464276266063, 0.7807372285720945, 0.773010453362737, 0.765167265622459, 0.7572088465064846, 0.7491363945234594, 0.7409511253549591, 0.7326542716724128, 0.724247082951467, 0.7157308252838186, 0.7071067811865476, 0.6983762494089729, 0.6895405447370669, 0.6806009977954531, 0.6715589548470183, 0.6624157775901718, 0.6531728429537768, 0.6438315428897915, 0.6343932841636455, 0.6248594881423865, 0.6152315905806268, 0.6055110414043255, 0.5956993044924335, 0.5857978574564389, 0.5758081914178453, 0.5657318107836132, 0.5555702330196023, 0.5453249884220465, 0.5349976198870973, 0.5245896826784688, 0.5141027441932217, 0.5035383837257176, 0.4928981922297841, 0.48218377207912283, 0.4713967368259978, 0.46053871095824, 0.4496113296546066, 0.4386162385385277, 0.4275550934302822, 0.4164295600976373, 0.40524131400498986, 0.3939920400610481, 0.38268343236508984, 0.3713171939518376, 0.3598950365349883, 0.3484186802494345, 0.33688985339222005, 0.325310292162263, 0.3136817403988916, 0.3020059493192282, 0.29028467725446233, 0.27851968938505306, 0.2667127574748984, 0.2548656596045146, 0.24298017990326398, 0.23105810828067128, 0.21910124015686977, 0.20711137619221856, 0.19509032201612833, 0.18303988795514106, 0.17096188876030136, 0.1588581433338614, 0.14673047445536175, 0.13458070850712622, 0.12241067519921628, 0.11022220729388318, 0.09801714032956077, 0.08579731234443988, 0.07356456359966745, 0.06132073630220865, 0.049067674327418126, 0.03680722294135899, 0.024541228522912264, 0.012271538285719944, 6.123031769111886e-17, -0.012271538285719823, -0.024541228522912142, -0.036807222941358866, -0.04906767432741801, -0.06132073630220853, -0.07356456359966733, -0.08579731234443976, -0.09801714032956065, -0.11022220729388306, -0.12241067519921615, -0.1345807085071261, -0.14673047445536164, -0.15885814333386128, -0.17096188876030124, -0.18303988795514092, -0.1950903220161282, -0.20711137619221845, -0.21910124015686966, -0.23105810828067114, -0.24298017990326387, -0.2548656596045145, -0.2667127574748983, -0.27851968938505295, -0.29028467725446216, -0.3020059493192281, -0.3136817403988914, -0.32531029216226287, -0.33688985339221994, -0.3484186802494344, -0.35989503653498817, -0.3713171939518375, -0.3826834323650897, -0.393992040061048, -0.40524131400498975, -0.416429560097637, -0.42755509343028186, -0.4386162385385274, -0.4496113296546067, -0.46053871095824006, -0.4713967368259977, -0.4821837720791227, -0.492898192229784, -0.5035383837257175, -0.5141027441932217, -0.5245896826784687, -0.534997619887097, -0.5453249884220462, -0.555570233019602, -0.5657318107836132, -0.5758081914178453, -0.5857978574564389, -0.5956993044924334, -0.6055110414043254, -0.6152315905806267, -0.6248594881423862, -0.6343932841636454, -0.6438315428897913, -0.6531728429537765, -0.6624157775901719, -0.6715589548470184, -0.680600997795453, -0.6895405447370669, -0.6983762494089728, -0.7071067811865475, -0.7157308252838186, -0.7242470829514668, -0.7326542716724127, -0.7409511253549589, -0.7491363945234591, -0.7572088465064846, -0.765167265622459, -0.773010453362737, -0.7807372285720945, -0.7883464276266062, -0.7958369046088835, -0.8032075314806448, -0.8104571982525947, -0.8175848131515836, -0.8245893027850251, -0.8314696123025453, -0.8382247055548381, -0.8448535652497071, -0.8513551931052652, -0.857728610000272, -0.8639728561215867, -0.8700869911087113, -0.8760700941954065, -0.8819212643483549, -0.8876396204028538, -0.8932243011955152, -0.8986744656939539, -0.9039892931234433, -0.9091679830905224, -0.9142097557035307, -0.9191138516900578, -0.9238795325112867, -0.9285060804732155, -0.9329927988347388, -0.9373390119125748, -0.9415440651830207, -0.9456073253805212, -0.9495281805930367, -0.9533060403541939, -0.9569403357322088, -0.9604305194155658,
--0.9637760657954398, -0.9669764710448521, -0.970031253194544, -0.9729399522055601, -0.9757021300385285, -0.9783173707196275, -0.9807852804032304, -0.9831054874312163, -0.9852776423889412, -0.9873014181578584, -0.989176509964781, -0.99090263542778, -0.99247953459871, -0.9939069700023561, -0.9951847266721968, -0.996312612182778, -0.9972904566786902, -0.9981181129001492, -0.9987954562051724, -0.9993223845883495, -0.9996988186962042, -0.9999247018391445, -1.0, -0.9999247018391445, -0.9996988186962042, -0.9993223845883495, -0.9987954562051724, -0.9981181129001492, -0.9972904566786902, -0.996312612182778, -0.9951847266721969, -0.9939069700023561, -0.99247953459871, -0.99090263542778, -0.989176509964781, -0.9873014181578584, -0.9852776423889413, -0.9831054874312164, -0.9807852804032304, -0.9783173707196277, -0.9757021300385286, -0.9729399522055602, -0.970031253194544, -0.9669764710448522, -0.96377606579544, -0.9604305194155659, -0.9569403357322089, -0.953306040354194, -0.9495281805930368, -0.9456073253805213, -0.9415440651830208, -0.937339011912575, -0.932992798834739, -0.9285060804732156, -0.9238795325112868, -0.9191138516900578, -0.9142097557035307, -0.9091679830905225, -0.9039892931234434, -0.898674465693954, -0.8932243011955153, -0.8876396204028539, -0.881921264348355, -0.8760700941954066, -0.8700869911087115, -0.8639728561215868, -0.8577286100002721, -0.8513551931052653, -0.8448535652497072, -0.8382247055548382, -0.8314696123025455, -0.8245893027850253, -0.8175848131515837, -0.8104571982525948, -0.8032075314806449, -0.7958369046088836, -0.7883464276266063, -0.7807372285720946, -0.7730104533627371, -0.7651672656224591, -0.7572088465064848, -0.7491363945234593, -0.7409511253549591, -0.7326542716724128, -0.724247082951467, -0.7157308252838187, -0.7071067811865477, -0.698376249408973, -0.689540544737067, -0.6806009977954532, -0.6715589548470187, -0.662415777590172, -0.6531728429537771, -0.6438315428897915, -0.6343932841636459, -0.6248594881423865, -0.6152315905806273, -0.6055110414043257, -0.5956993044924331, -0.5857978574564391, -0.5758081914178452, -0.5657318107836135, -0.5555702330196022, -0.5453249884220468, -0.5349976198870973, -0.5245896826784694, -0.5141027441932218, -0.503538383725718, -0.4928981922297842, -0.48218377207912255, -0.47139673682599786, -0.4605387109582399, -0.44961132965460693, -0.4386162385385276, -0.4275550934302825, -0.4164295600976372, -0.40524131400499036, -0.3939920400610482, -0.38268343236509034, -0.37131719395183777, -0.35989503653498794, -0.34841868024943484, -0.33688985339221994, -0.3253102921622633, -0.31368174039889146, -0.30200594931922853, -0.29028467725446244, -0.2785196893850536, -0.26671275747489853, -0.25486565960451435, -0.24298017990326412, -0.23105810828067094, -0.2191012401568701, -0.20711137619221848, -0.19509032201612866, -0.18303988795514095, -0.1709618887603017, -0.15885814333386153, -0.1467304744553623, -0.13458070850712636, -0.12241067519921596, -0.11022220729388331, -0.09801714032956045, -0.08579731234444023, -0.07356456359966736, -0.061320736302208995, -0.04906767432741803, -0.03680722294135933, -0.02454122852291239, -0.012271538285720512, -1.836909530733566e-16, 0.012271538285720144, 0.02454122852291202, 0.036807222941358964, 0.04906767432741766, 0.06132073630220863, 0.07356456359966698, 0.08579731234443985, 0.09801714032956009, 0.11022220729388293, 0.1224106751992156, 0.13458070850712597, 0.14673047445536194, 0.15885814333386117, 0.17096188876030133, 0.1830398879551406, 0.1950903220161283, 0.20711137619221812, 0.21910124015686974, 0.23105810828067058, 0.24298017990326376, 0.25486565960451396, 0.2667127574748982, 0.2785196893850533, 0.29028467725446205, 0.30200594931922814, 0.31368174039889113, 0.3253102921622629, 0.3368898533922196, 0.3484186802494345, 0.3598950365349876, 0.3713171939518374, 0.38268343236509, 0.3939920400610479, 0.40524131400499, 0.4164295600976369, 0.42755509343028214, 0.43861623853852727, 0.4496113296546066, 0.46053871095823956, 0.4713967368259976, 0.4821837720791222, 0.49289819222978387, 0.5035383837257178, 0.5141027441932216, 0.5245896826784691, 0.5349976198870969, 0.5453249884220465, 0.5555702330196018, 0.5657318107836131, 0.5758081914178449, 0.5857978574564388, 0.5956993044924329, 0.6055110414043253, 0.615231590580627, 0.6248594881423861, 0.6343932841636456, 0.6438315428897912, 0.6531728429537768, 0.6624157775901715, 0.6715589548470183, 0.6806009977954527, 0.6895405447370668, 0.6983762494089724, 0.7071067811865474, 0.7157308252838188, 0.7242470829514667, 0.7326542716724129, 0.7409511253549589, 0.7491363945234594, 0.7572088465064842, 0.7651672656224588, 0.7730104533627367, 0.7807372285720944, 0.7883464276266059, 0.7958369046088833, 0.803207531480645, 0.8104571982525947, 0.8175848131515837, 0.8245893027850251, 0.8314696123025452, 0.8382247055548377,
+static MYFLT COSINE_ARRAY[513] = {1.0, 0.9999247018391445, 0.9996988186962042, 0.9993223845883495, 0.9987954562051724, 0.9981181129001492, 0.9972904566786902, 0.996312612182778, 0.9951847266721969, 0.9939069700023561, 0.99247953459871, 0.99090263542778, 0.989176509964781, 0.9873014181578584, 0.9852776423889412, 0.9831054874312163, 0.9807852804032304, 0.9783173707196277, 0.9757021300385286, 0.9729399522055602, 0.970031253194544, 0.9669764710448521, 0.9637760657954398, 0.9604305194155658, 0.9569403357322088, 0.9533060403541939, 0.9495281805930367, 0.9456073253805213, 0.9415440651830208, 0.937339011912575, 0.932992798834739, 0.9285060804732156, 0.9238795325112867, 0.9191138516900578, 0.9142097557035307, 0.9091679830905224, 0.9039892931234433, 0.8986744656939538, 0.8932243011955153, 0.8876396204028539, 0.881921264348355, 0.8760700941954066, 0.8700869911087115, 0.8639728561215868, 0.8577286100002721, 0.8513551931052652, 0.8448535652497071, 0.8382247055548381, 0.8314696123025452, 0.8245893027850253, 0.8175848131515837, 0.8104571982525948, 0.8032075314806449, 0.7958369046088836, 0.7883464276266063, 0.7807372285720945, 0.773010453362737, 0.765167265622459, 0.7572088465064846, 0.7491363945234594, 0.7409511253549591, 0.7326542716724128, 0.724247082951467, 0.7157308252838186, 0.7071067811865476, 0.6983762494089729, 0.6895405447370669, 0.6806009977954531, 0.6715589548470183, 0.6624157775901718, 0.6531728429537768, 0.6438315428897915, 0.6343932841636455, 0.6248594881423865, 0.6152315905806268, 0.6055110414043255, 0.5956993044924335, 0.5857978574564389, 0.5758081914178453, 0.5657318107836132, 0.5555702330196023, 0.5453249884220465, 0.5349976198870973, 0.5245896826784688, 0.5141027441932217, 0.5035383837257176, 0.4928981922297841, 0.48218377207912283, 0.4713967368259978, 0.46053871095824, 0.4496113296546066, 0.4386162385385277, 0.4275550934302822, 0.4164295600976373, 0.40524131400498986, 0.3939920400610481, 0.38268343236508984, 0.3713171939518376, 0.3598950365349883, 0.3484186802494345, 0.33688985339222005, 0.325310292162263, 0.3136817403988916, 0.3020059493192282, 0.29028467725446233, 0.27851968938505306, 0.2667127574748984, 0.2548656596045146, 0.24298017990326398, 0.23105810828067128, 0.21910124015686977, 0.20711137619221856, 0.19509032201612833, 0.18303988795514106, 0.17096188876030136, 0.1588581433338614, 0.14673047445536175, 0.13458070850712622, 0.12241067519921628, 0.11022220729388318, 0.09801714032956077, 0.08579731234443988, 0.07356456359966745, 0.06132073630220865, 0.049067674327418126, 0.03680722294135899, 0.024541228522912264, 0.012271538285719944, 6.123031769111886e-17, -0.012271538285719823, -0.024541228522912142, -0.036807222941358866, -0.04906767432741801, -0.06132073630220853, -0.07356456359966733, -0.08579731234443976, -0.09801714032956065, -0.11022220729388306, -0.12241067519921615, -0.1345807085071261, -0.14673047445536164, -0.15885814333386128, -0.17096188876030124, -0.18303988795514092, -0.1950903220161282, -0.20711137619221845, -0.21910124015686966, -0.23105810828067114, -0.24298017990326387, -0.2548656596045145, -0.2667127574748983, -0.27851968938505295, -0.29028467725446216, -0.3020059493192281, -0.3136817403988914, -0.32531029216226287, -0.33688985339221994, -0.3484186802494344, -0.35989503653498817, -0.3713171939518375, -0.3826834323650897, -0.393992040061048, -0.40524131400498975, -0.416429560097637, -0.42755509343028186, -0.4386162385385274, -0.4496113296546067, -0.46053871095824006, -0.4713967368259977, -0.4821837720791227, -0.492898192229784, -0.5035383837257175, -0.5141027441932217, -0.5245896826784687, -0.534997619887097, -0.5453249884220462, -0.555570233019602, -0.5657318107836132, -0.5758081914178453, -0.5857978574564389, -0.5956993044924334, -0.6055110414043254, -0.6152315905806267, -0.6248594881423862, -0.6343932841636454, -0.6438315428897913, -0.6531728429537765, -0.6624157775901719, -0.6715589548470184, -0.680600997795453, -0.6895405447370669, -0.6983762494089728, -0.7071067811865475, -0.7157308252838186, -0.7242470829514668, -0.7326542716724127, -0.7409511253549589, -0.7491363945234591, -0.7572088465064846, -0.765167265622459, -0.773010453362737, -0.7807372285720945, -0.7883464276266062, -0.7958369046088835, -0.8032075314806448, -0.8104571982525947, -0.8175848131515836, -0.8245893027850251, -0.8314696123025453, -0.8382247055548381, -0.8448535652497071, -0.8513551931052652, -0.857728610000272, -0.8639728561215867, -0.8700869911087113, -0.8760700941954065, -0.8819212643483549, -0.8876396204028538, -0.8932243011955152, -0.8986744656939539, -0.9039892931234433, -0.9091679830905224, -0.9142097557035307, -0.9191138516900578, -0.9238795325112867, -0.9285060804732155, -0.9329927988347388, -0.9373390119125748, -0.9415440651830207, -0.9456073253805212, -0.9495281805930367, -0.9533060403541939, -0.9569403357322088, -0.9604305194155658,
+-0.9637760657954398, -0.9669764710448521, -0.970031253194544, -0.9729399522055601, -0.9757021300385285, -0.9783173707196275, -0.9807852804032304, -0.9831054874312163, -0.9852776423889412, -0.9873014181578584, -0.989176509964781, -0.99090263542778, -0.99247953459871, -0.9939069700023561, -0.9951847266721968, -0.996312612182778, -0.9972904566786902, -0.9981181129001492, -0.9987954562051724, -0.9993223845883495, -0.9996988186962042, -0.9999247018391445, -1.0, -0.9999247018391445, -0.9996988186962042, -0.9993223845883495, -0.9987954562051724, -0.9981181129001492, -0.9972904566786902, -0.996312612182778, -0.9951847266721969, -0.9939069700023561, -0.99247953459871, -0.99090263542778, -0.989176509964781, -0.9873014181578584, -0.9852776423889413, -0.9831054874312164, -0.9807852804032304, -0.9783173707196277, -0.9757021300385286, -0.9729399522055602, -0.970031253194544, -0.9669764710448522, -0.96377606579544, -0.9604305194155659, -0.9569403357322089, -0.953306040354194, -0.9495281805930368, -0.9456073253805213, -0.9415440651830208, -0.937339011912575, -0.932992798834739, -0.9285060804732156, -0.9238795325112868, -0.9191138516900578, -0.9142097557035307, -0.9091679830905225, -0.9039892931234434, -0.898674465693954, -0.8932243011955153, -0.8876396204028539, -0.881921264348355, -0.8760700941954066, -0.8700869911087115, -0.8639728561215868, -0.8577286100002721, -0.8513551931052653, -0.8448535652497072, -0.8382247055548382, -0.8314696123025455, -0.8245893027850253, -0.8175848131515837, -0.8104571982525948, -0.8032075314806449, -0.7958369046088836, -0.7883464276266063, -0.7807372285720946, -0.7730104533627371, -0.7651672656224591, -0.7572088465064848, -0.7491363945234593, -0.7409511253549591, -0.7326542716724128, -0.724247082951467, -0.7157308252838187, -0.7071067811865477, -0.698376249408973, -0.689540544737067, -0.6806009977954532, -0.6715589548470187, -0.662415777590172, -0.6531728429537771, -0.6438315428897915, -0.6343932841636459, -0.6248594881423865, -0.6152315905806273, -0.6055110414043257, -0.5956993044924331, -0.5857978574564391, -0.5758081914178452, -0.5657318107836135, -0.5555702330196022, -0.5453249884220468, -0.5349976198870973, -0.5245896826784694, -0.5141027441932218, -0.503538383725718, -0.4928981922297842, -0.48218377207912255, -0.47139673682599786, -0.4605387109582399, -0.44961132965460693, -0.4386162385385276, -0.4275550934302825, -0.4164295600976372, -0.40524131400499036, -0.3939920400610482, -0.38268343236509034, -0.37131719395183777, -0.35989503653498794, -0.34841868024943484, -0.33688985339221994, -0.3253102921622633, -0.31368174039889146, -0.30200594931922853, -0.29028467725446244, -0.2785196893850536, -0.26671275747489853, -0.25486565960451435, -0.24298017990326412, -0.23105810828067094, -0.2191012401568701, -0.20711137619221848, -0.19509032201612866, -0.18303988795514095, -0.1709618887603017, -0.15885814333386153, -0.1467304744553623, -0.13458070850712636, -0.12241067519921596, -0.11022220729388331, -0.09801714032956045, -0.08579731234444023, -0.07356456359966736, -0.061320736302208995, -0.04906767432741803, -0.03680722294135933, -0.02454122852291239, -0.012271538285720512, -1.836909530733566e-16, 0.012271538285720144, 0.02454122852291202, 0.036807222941358964, 0.04906767432741766, 0.06132073630220863, 0.07356456359966698, 0.08579731234443985, 0.09801714032956009, 0.11022220729388293, 0.1224106751992156, 0.13458070850712597, 0.14673047445536194, 0.15885814333386117, 0.17096188876030133, 0.1830398879551406, 0.1950903220161283, 0.20711137619221812, 0.21910124015686974, 0.23105810828067058, 0.24298017990326376, 0.25486565960451396, 0.2667127574748982, 0.2785196893850533, 0.29028467725446205, 0.30200594931922814, 0.31368174039889113, 0.3253102921622629, 0.3368898533922196, 0.3484186802494345, 0.3598950365349876, 0.3713171939518374, 0.38268343236509, 0.3939920400610479, 0.40524131400499, 0.4164295600976369, 0.42755509343028214, 0.43861623853852727, 0.4496113296546066, 0.46053871095823956, 0.4713967368259976, 0.4821837720791222, 0.49289819222978387, 0.5035383837257178, 0.5141027441932216, 0.5245896826784691, 0.5349976198870969, 0.5453249884220465, 0.5555702330196018, 0.5657318107836131, 0.5758081914178449, 0.5857978574564388, 0.5956993044924329, 0.6055110414043253, 0.615231590580627, 0.6248594881423861, 0.6343932841636456, 0.6438315428897912, 0.6531728429537768, 0.6624157775901715, 0.6715589548470183, 0.6806009977954527, 0.6895405447370668, 0.6983762494089724, 0.7071067811865474, 0.7157308252838188, 0.7242470829514667, 0.7326542716724129, 0.7409511253549589, 0.7491363945234594, 0.7572088465064842, 0.7651672656224588, 0.7730104533627367, 0.7807372285720944, 0.7883464276266059, 0.7958369046088833, 0.803207531480645, 0.8104571982525947, 0.8175848131515837, 0.8245893027850251, 0.8314696123025452, 0.8382247055548377,
0.844853565249707, 0.8513551931052649, 0.857728610000272, 0.8639728561215864, 0.8700869911087113, 0.8760700941954067, 0.8819212643483548, 0.8876396204028539, 0.8932243011955151, 0.8986744656939538, 0.9039892931234431, 0.9091679830905224, 0.9142097557035305, 0.9191138516900577, 0.9238795325112865, 0.9285060804732155, 0.932992798834739, 0.9373390119125748, 0.9415440651830208, 0.9456073253805212, 0.9495281805930367, 0.9533060403541936, 0.9569403357322088, 0.9604305194155657, 0.9637760657954398, 0.9669764710448522, 0.970031253194544, 0.9729399522055602, 0.9757021300385285, 0.9783173707196277, 0.9807852804032303, 0.9831054874312163, 0.9852776423889411, 0.9873014181578583, 0.9891765099647809, 0.99090263542778, 0.99247953459871, 0.9939069700023561, 0.9951847266721969, 0.996312612182778, 0.9972904566786902, 0.9981181129001492, 0.9987954562051724, 0.9993223845883494, 0.9996988186962042, 0.9999247018391445, 1.0};
static MYFLT ONE_OVER_512 = 1.0 / 512.0;
static const MYFLT ROSSLER_SCALE = 0.05757;
@@ -74,11 +74,11 @@ static void
Sine_readframes_ii(Sine *self) {
MYFLT inc, fr, ph, pos, fpart;
int i, ipart;
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
ph = PyFloat_AS_DOUBLE(self->phase) * 512;
inc = fr * 512 / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->pointerPos = Sine_clip(self->pointerPos);
pos = self->pointerPos + ph;
@@ -95,10 +95,10 @@ static void
Sine_readframes_ai(Sine *self) {
MYFLT inc, ph, pos, fpart, fac;
int i, ipart;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
ph = PyFloat_AS_DOUBLE(self->phase) * 512;
-
+
fac = 512 / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * fac;
@@ -117,11 +117,11 @@ static void
Sine_readframes_ia(Sine *self) {
MYFLT inc, fr, pos, fpart;
int i, ipart;
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
inc = fr * 512 / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->pointerPos = Sine_clip(self->pointerPos);
pos = self->pointerPos + ph[i] * 512;
@@ -138,10 +138,10 @@ static void
Sine_readframes_aa(Sine *self) {
MYFLT inc, pos, fpart, fac;
int i, ipart;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
-
+
fac = 512 / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * fac;
@@ -172,48 +172,48 @@ Sine_setProcMode(Sine *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Sine_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Sine_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Sine_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Sine_readframes_aa;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Sine_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Sine_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Sine_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Sine_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Sine_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Sine_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Sine_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Sine_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Sine_postprocessing_revareva;
break;
}
@@ -222,7 +222,7 @@ Sine_setProcMode(Sine *self)
static void
Sine_compute_next_data_frame(Sine *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -230,21 +230,21 @@ static int
Sine_traverse(Sine *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->phase);
- Py_VISIT(self->phase_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->phase);
+ Py_VISIT(self->phase_stream);
return 0;
}
-static int
+static int
Sine_clear(Sine *self)
{
pyo_CLEAR
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->phase);
- Py_CLEAR(self->phase_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->phase);
+ Py_CLEAR(self->phase_stream);
return 0;
}
@@ -264,7 +264,7 @@ Sine_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Sine *self;
self = (Sine *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->phase = PyFloat_FromDouble(0.0);
self->modebuffer[0] = 0;
@@ -272,34 +272,34 @@ Sine_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->pointerPos = 0.;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Sine_compute_next_data_frame);
self->mode_func_ptr = Sine_setProcMode;
-
+
static char *kwlist[] = {"freq", "phase", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &phasetmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (phasetmp) {
PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -307,10 +307,10 @@ Sine_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Sine_getServer(Sine* self) { GET_SERVER };
static PyObject * Sine_getStream(Sine* self) { GET_STREAM };
-static PyObject * Sine_setMul(Sine *self, PyObject *arg) { SET_MUL };
-static PyObject * Sine_setAdd(Sine *self, PyObject *arg) { SET_ADD };
-static PyObject * Sine_setSub(Sine *self, PyObject *arg) { SET_SUB };
-static PyObject * Sine_setDiv(Sine *self, PyObject *arg) { SET_DIV };
+static PyObject * Sine_setMul(Sine *self, PyObject *arg) { SET_MUL };
+static PyObject * Sine_setAdd(Sine *self, PyObject *arg) { SET_ADD };
+static PyObject * Sine_setSub(Sine *self, PyObject *arg) { SET_SUB };
+static PyObject * Sine_setDiv(Sine *self, PyObject *arg) { SET_DIV };
static PyObject * Sine_play(Sine *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Sine_out(Sine *self, PyObject *args, PyObject *kwds) { OUT };
@@ -329,14 +329,14 @@ static PyObject *
Sine_setFreq(Sine *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -352,25 +352,25 @@ Sine_setFreq(Sine *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Sine_setPhase(Sine *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->phase);
@@ -386,15 +386,15 @@ Sine_setPhase(Sine *self, PyObject *arg)
self->phase_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
-static PyObject *
-Sine_reset(Sine *self)
+static PyObject *
+Sine_reset(Sine *self)
{
self->pointerPos = 0.0;
Py_INCREF(Py_None);
@@ -529,11 +529,11 @@ static void
SineLoop_readframes_ii(SineLoop *self) {
MYFLT inc, fr, feed, pos, fpart;
int i, ipart;
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * 512;
inc = fr * 512 / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->pointerPos = Sine_clip(self->pointerPos);
pos = Sine_clip(self->pointerPos + self->lastValue * feed);
@@ -548,10 +548,10 @@ static void
SineLoop_readframes_ai(SineLoop *self) {
MYFLT inc, feed, pos, fpart, fac;
int i, ipart;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * 512;
-
+
fac = 512 / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * fac;
@@ -568,11 +568,11 @@ static void
SineLoop_readframes_ia(SineLoop *self) {
MYFLT inc, fr, feed, pos, fpart;
int i, ipart;
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
inc = fr * 512 / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
feed = _clip(fd[i]) * 512;
self->pointerPos = Sine_clip(self->pointerPos);
@@ -588,10 +588,10 @@ static void
SineLoop_readframes_aa(SineLoop *self) {
MYFLT inc, feed, pos, fpart, fac;
int i, ipart;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
-
+
fac = 512 / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * fac;
@@ -621,48 +621,48 @@ SineLoop_setProcMode(SineLoop *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = SineLoop_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = SineLoop_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = SineLoop_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = SineLoop_readframes_aa;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SineLoop_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SineLoop_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SineLoop_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SineLoop_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SineLoop_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SineLoop_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SineLoop_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SineLoop_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SineLoop_postprocessing_revareva;
break;
}
@@ -671,7 +671,7 @@ SineLoop_setProcMode(SineLoop *self)
static void
SineLoop_compute_next_data_frame(SineLoop *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -679,21 +679,21 @@ static int
SineLoop_traverse(SineLoop *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->feedback);
- Py_VISIT(self->feedback_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
return 0;
}
-static int
+static int
SineLoop_clear(SineLoop *self)
{
pyo_CLEAR
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
return 0;
}
@@ -712,7 +712,7 @@ SineLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *feedbacktmp=NULL, *multmp=NULL, *addtmp=NULL;
SineLoop *self;
self = (SineLoop *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->feedback = PyFloat_FromDouble(0.0);
self->modebuffer[0] = 0;
@@ -720,45 +720,45 @@ SineLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->pointerPos = self->lastValue = 0.;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SineLoop_compute_next_data_frame);
self->mode_func_ptr = SineLoop_setProcMode;
static char *kwlist[] = {"freq", "feedback", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &feedbacktmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (feedbacktmp) {
PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * SineLoop_getServer(SineLoop* self) { GET_SERVER };
static PyObject * SineLoop_getStream(SineLoop* self) { GET_STREAM };
-static PyObject * SineLoop_setMul(SineLoop *self, PyObject *arg) { SET_MUL };
-static PyObject * SineLoop_setAdd(SineLoop *self, PyObject *arg) { SET_ADD };
-static PyObject * SineLoop_setSub(SineLoop *self, PyObject *arg) { SET_SUB };
-static PyObject * SineLoop_setDiv(SineLoop *self, PyObject *arg) { SET_DIV };
+static PyObject * SineLoop_setMul(SineLoop *self, PyObject *arg) { SET_MUL };
+static PyObject * SineLoop_setAdd(SineLoop *self, PyObject *arg) { SET_ADD };
+static PyObject * SineLoop_setSub(SineLoop *self, PyObject *arg) { SET_SUB };
+static PyObject * SineLoop_setDiv(SineLoop *self, PyObject *arg) { SET_DIV };
static PyObject * SineLoop_play(SineLoop *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SineLoop_out(SineLoop *self, PyObject *args, PyObject *kwds) { OUT };
@@ -777,14 +777,14 @@ static PyObject *
SineLoop_setFreq(SineLoop *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -800,25 +800,25 @@ SineLoop_setFreq(SineLoop *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SineLoop_setFeedback(SineLoop *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->feedback);
@@ -834,12 +834,12 @@ SineLoop_setFeedback(SineLoop *self, PyObject *arg)
self->feedback_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef SineLoop_members[] = {
{"server", T_OBJECT_EX, offsetof(SineLoop, server), 0, "Pyo server."},
@@ -1009,11 +1009,11 @@ Osc_readframes_ai(Osc *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
ph = PyFloat_AS_DOUBLE(self->phase);
ph *= size;
-
+
sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * sizeOnSr;
@@ -1035,11 +1035,11 @@ Osc_readframes_ia(Osc *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
inc = fr * size / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
pha = ph[i] * size;
self->pointerPos += inc;
@@ -1060,7 +1060,7 @@ Osc_readframes_aa(Osc *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
@@ -1095,56 +1095,56 @@ Osc_setProcMode(Osc *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Osc_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Osc_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Osc_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Osc_readframes_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Osc_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Osc_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Osc_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Osc_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Osc_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Osc_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Osc_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Osc_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Osc_postprocessing_revareva;
break;
- }
+ }
}
static void
Osc_compute_next_data_frame(Osc *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1153,22 +1153,22 @@ Osc_traverse(Osc *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->phase);
- Py_VISIT(self->phase_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->phase);
+ Py_VISIT(self->phase_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
Osc_clear(Osc *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->phase);
- Py_CLEAR(self->phase_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->phase);
+ Py_CLEAR(self->phase_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -1207,15 +1207,12 @@ Osc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of Osc must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Osc must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
+
if (phasetmp) {
PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
}
@@ -1223,7 +1220,7 @@ Osc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
@@ -1231,7 +1228,7 @@ Osc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -1243,10 +1240,10 @@ Osc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Osc_getServer(Osc* self) { GET_SERVER };
static PyObject * Osc_getStream(Osc* self) { GET_STREAM };
-static PyObject * Osc_setMul(Osc *self, PyObject *arg) { SET_MUL };
-static PyObject * Osc_setAdd(Osc *self, PyObject *arg) { SET_ADD };
-static PyObject * Osc_setSub(Osc *self, PyObject *arg) { SET_SUB };
-static PyObject * Osc_setDiv(Osc *self, PyObject *arg) { SET_DIV };
+static PyObject * Osc_setMul(Osc *self, PyObject *arg) { SET_MUL };
+static PyObject * Osc_setAdd(Osc *self, PyObject *arg) { SET_ADD };
+static PyObject * Osc_setSub(Osc *self, PyObject *arg) { SET_SUB };
+static PyObject * Osc_setDiv(Osc *self, PyObject *arg) { SET_DIV };
static PyObject * Osc_play(Osc *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Osc_out(Osc *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1272,7 +1269,7 @@ static PyObject *
Osc_setTable(Osc *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
@@ -1281,23 +1278,23 @@ Osc_setTable(Osc *self, PyObject *arg)
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Osc_setFreq(Osc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1313,25 +1310,25 @@ Osc_setFreq(Osc *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Osc_setPhase(Osc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->phase);
@@ -1347,12 +1344,12 @@ Osc_setPhase(Osc *self, PyObject *arg)
self->phase_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Osc_setInterp(Osc *self, PyObject *arg)
@@ -1361,21 +1358,21 @@ Osc_setInterp(Osc *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
SET_INTERP_POINTER
-
+
Py_INCREF(Py_None);
return Py_None;
}
-static PyObject *
-Osc_reset(Osc *self)
+static PyObject *
+Osc_reset(Osc *self)
{
self->pointerPos = 0.0;
Py_INCREF(Py_None);
@@ -1517,11 +1514,11 @@ OscLoop_readframes_ii(OscLoop *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * size;
inc = fr * size / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->pointerPos += inc;
self->pointerPos = Osc_clip(self->pointerPos, size);
@@ -1542,10 +1539,10 @@ OscLoop_readframes_ai(OscLoop *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * size;
-
+
sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * sizeOnSr;
@@ -1568,11 +1565,11 @@ OscLoop_readframes_ia(OscLoop *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
inc = fr * size / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
feed = _clip(fd[i]) * size;
self->pointerPos += inc;
@@ -1594,10 +1591,10 @@ OscLoop_readframes_aa(OscLoop *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
-
+
sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * sizeOnSr;
@@ -1631,56 +1628,56 @@ OscLoop_setProcMode(OscLoop *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = OscLoop_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = OscLoop_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = OscLoop_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = OscLoop_readframes_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = OscLoop_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = OscLoop_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = OscLoop_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = OscLoop_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = OscLoop_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = OscLoop_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = OscLoop_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = OscLoop_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = OscLoop_postprocessing_revareva;
break;
- }
+ }
}
static void
OscLoop_compute_next_data_frame(OscLoop *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1689,22 +1686,22 @@ OscLoop_traverse(OscLoop *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->feedback);
- Py_VISIT(self->feedback_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
OscLoop_clear(OscLoop *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -1723,7 +1720,7 @@ OscLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *freqtmp=NULL, *feedbacktmp=NULL, *multmp=NULL, *addtmp=NULL;
OscLoop *self;
self = (OscLoop *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->feedback = PyFloat_FromDouble(0);
self->modebuffer[0] = 0;
@@ -1731,55 +1728,52 @@ OscLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->pointerPos = self->lastValue = 0.;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, OscLoop_compute_next_data_frame);
self->mode_func_ptr = OscLoop_setProcMode;
static char *kwlist[] = {"table", "freq", "feedback", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &tabletmp, &freqtmp, &feedbacktmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of OscLoop must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of OscLoop must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
+
if (feedbacktmp) {
PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
}
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * OscLoop_getServer(OscLoop* self) { GET_SERVER };
static PyObject * OscLoop_getStream(OscLoop* self) { GET_STREAM };
-static PyObject * OscLoop_setMul(OscLoop *self, PyObject *arg) { SET_MUL };
-static PyObject * OscLoop_setAdd(OscLoop *self, PyObject *arg) { SET_ADD };
-static PyObject * OscLoop_setSub(OscLoop *self, PyObject *arg) { SET_SUB };
-static PyObject * OscLoop_setDiv(OscLoop *self, PyObject *arg) { SET_DIV };
+static PyObject * OscLoop_setMul(OscLoop *self, PyObject *arg) { SET_MUL };
+static PyObject * OscLoop_setAdd(OscLoop *self, PyObject *arg) { SET_ADD };
+static PyObject * OscLoop_setSub(OscLoop *self, PyObject *arg) { SET_SUB };
+static PyObject * OscLoop_setDiv(OscLoop *self, PyObject *arg) { SET_DIV };
static PyObject * OscLoop_play(OscLoop *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * OscLoop_out(OscLoop *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1805,32 +1799,32 @@ static PyObject *
OscLoop_setTable(OscLoop *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscLoop_setFreq(OscLoop *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1846,25 +1840,25 @@ OscLoop_setFreq(OscLoop *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscLoop_setFeedback(OscLoop *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->feedback);
@@ -1880,12 +1874,12 @@ OscLoop_setFeedback(OscLoop *self, PyObject *arg)
self->feedback_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef OscLoop_members[] = {
{"server", T_OBJECT_EX, offsetof(OscLoop, server), 0, "Pyo server."},
@@ -2021,12 +2015,12 @@ OscTrig_readframes_ii(OscTrig *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
ph = PyFloat_AS_DOUBLE(self->phase);
MYFLT *tr = Stream_getData((Stream *)self->trig_stream);
inc = fr * size / self->sr;
-
+
ph *= size;
for (i=0; i<self->bufsize; i++) {
if (tr[i] == 1)
@@ -2051,12 +2045,12 @@ OscTrig_readframes_ai(OscTrig *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
ph = PyFloat_AS_DOUBLE(self->phase);
MYFLT *tr = Stream_getData((Stream *)self->trig_stream);
ph *= size;
-
+
sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * sizeOnSr;
@@ -2082,12 +2076,12 @@ OscTrig_readframes_ia(OscTrig *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
MYFLT *tr = Stream_getData((Stream *)self->trig_stream);
inc = fr * size / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
pha = ph[i] * size;
if (tr[i] == 1)
@@ -2112,11 +2106,11 @@ OscTrig_readframes_aa(OscTrig *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
MYFLT *tr = Stream_getData((Stream *)self->trig_stream);
-
+
sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * sizeOnSr;
@@ -2152,56 +2146,56 @@ OscTrig_setProcMode(OscTrig *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = OscTrig_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = OscTrig_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = OscTrig_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = OscTrig_readframes_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = OscTrig_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = OscTrig_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = OscTrig_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = OscTrig_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = OscTrig_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = OscTrig_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = OscTrig_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = OscTrig_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = OscTrig_postprocessing_revareva;
break;
- }
+ }
}
static void
OscTrig_compute_next_data_frame(OscTrig *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2210,26 +2204,26 @@ OscTrig_traverse(OscTrig *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->phase);
- Py_VISIT(self->phase_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->trig);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->phase);
+ Py_VISIT(self->phase_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->trig);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
OscTrig_clear(OscTrig *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->phase);
- Py_CLEAR(self->phase_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->trig);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->phase);
+ Py_CLEAR(self->phase_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->trig);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -2248,7 +2242,7 @@ OscTrig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *trigtmp, *freqtmp=NULL, *phasetmp=NULL, *multmp=NULL, *addtmp=NULL;
OscTrig *self;
self = (OscTrig *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1000);
self->phase = PyFloat_FromDouble(0);
self->modebuffer[0] = 0;
@@ -2257,22 +2251,19 @@ OscTrig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
self->pointerPos = 0.;
self->interp = 2;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, OscTrig_compute_next_data_frame);
self->mode_func_ptr = OscTrig_setProcMode;
-
+
static char *kwlist[] = {"table", "trig", "freq", "phase", "interp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOiOO", kwlist, &tabletmp, &trigtmp, &freqtmp, &phasetmp, &self->interp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of OscTrig must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of OscTrig must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
@@ -2280,38 +2271,38 @@ OscTrig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (trigtmp) {
PyObject_CallMethod((PyObject *)self, "setTrig", "O", trigtmp);
}
-
+
if (phasetmp) {
PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
}
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
SET_INTERP_POINTER
-
+
return (PyObject *)self;
}
static PyObject * OscTrig_getServer(OscTrig* self) { GET_SERVER };
static PyObject * OscTrig_getStream(OscTrig* self) { GET_STREAM };
-static PyObject * OscTrig_setMul(OscTrig *self, PyObject *arg) { SET_MUL };
-static PyObject * OscTrig_setAdd(OscTrig *self, PyObject *arg) { SET_ADD };
-static PyObject * OscTrig_setSub(OscTrig *self, PyObject *arg) { SET_SUB };
-static PyObject * OscTrig_setDiv(OscTrig *self, PyObject *arg) { SET_DIV };
+static PyObject * OscTrig_setMul(OscTrig *self, PyObject *arg) { SET_MUL };
+static PyObject * OscTrig_setAdd(OscTrig *self, PyObject *arg) { SET_ADD };
+static PyObject * OscTrig_setSub(OscTrig *self, PyObject *arg) { SET_SUB };
+static PyObject * OscTrig_setDiv(OscTrig *self, PyObject *arg) { SET_DIV };
static PyObject * OscTrig_play(OscTrig *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * OscTrig_out(OscTrig *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2337,32 +2328,32 @@ static PyObject *
OscTrig_setTable(OscTrig *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscTrig_setTrig(OscTrig *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_XDECREF(self->trig);
@@ -2380,20 +2371,20 @@ OscTrig_setTrig(OscTrig *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscTrig_setFreq(OscTrig *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -2409,25 +2400,25 @@ OscTrig_setFreq(OscTrig *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscTrig_setPhase(OscTrig *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->phase);
@@ -2443,12 +2434,12 @@ OscTrig_setPhase(OscTrig *self, PyObject *arg)
self->phase_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
OscTrig_setInterp(OscTrig *self, PyObject *arg)
@@ -2457,21 +2448,21 @@ OscTrig_setInterp(OscTrig *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
SET_INTERP_POINTER
-
+
Py_INCREF(Py_None);
return Py_None;
}
-static PyObject *
-OscTrig_reset(OscTrig *self)
+static PyObject *
+OscTrig_reset(OscTrig *self)
{
self->pointerPos = 0.0;
Py_INCREF(Py_None);
@@ -2612,17 +2603,17 @@ Phasor_readframes_ii(Phasor *self) {
MYFLT fr, ph;
double inc, pos;
int i;
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
ph = _clip(PyFloat_AS_DOUBLE(self->phase));
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
pos = self->pointerPos + ph;
if (pos > 1)
pos -= 1.0;
self->data[i] = pos;
-
+
self->pointerPos += inc;
if (self->pointerPos < 0)
self->pointerPos += 1.0;
@@ -2636,17 +2627,17 @@ Phasor_readframes_ai(Phasor *self) {
MYFLT ph, oneOnSr;
double inc, pos;
int i;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
ph = _clip(PyFloat_AS_DOUBLE(self->phase));
-
+
oneOnSr = 1.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
pos = self->pointerPos + ph;
if (pos > 1)
pos -= 1.0;
self->data[i] = pos;
-
+
inc = fr[i] * oneOnSr;
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -2661,12 +2652,12 @@ Phasor_readframes_ia(Phasor *self) {
MYFLT fr, pha;
double inc, pos;
int i;
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
-
+
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
pha = _clip(ph[i]);
@@ -2674,7 +2665,7 @@ Phasor_readframes_ia(Phasor *self) {
if (pos > 1)
pos -= 1.0;
self->data[i] = pos;
-
+
self->pointerPos += inc;
if (self->pointerPos < 0)
self->pointerPos += 1.0;
@@ -2688,7 +2679,7 @@ Phasor_readframes_aa(Phasor *self) {
MYFLT pha, oneOnSr;
double inc, pos;
int i;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
@@ -2696,12 +2687,12 @@ Phasor_readframes_aa(Phasor *self) {
for (i=0; i<self->bufsize; i++) {
pha = _clip(ph[i]);
-
+
pos = self->pointerPos + pha;
if (pos > 1)
pos -= 1.0;
self->data[i] = pos;
-
+
inc = fr[i] * oneOnSr;
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -2727,56 +2718,56 @@ Phasor_setProcMode(Phasor *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Phasor_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Phasor_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Phasor_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Phasor_readframes_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Phasor_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Phasor_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Phasor_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Phasor_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Phasor_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Phasor_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Phasor_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Phasor_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Phasor_postprocessing_revareva;
break;
- }
+ }
}
static void
Phasor_compute_next_data_frame(Phasor *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2784,21 +2775,21 @@ static int
Phasor_traverse(Phasor *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->phase);
- Py_VISIT(self->phase_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->phase);
+ Py_VISIT(self->phase_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
Phasor_clear(Phasor *self)
{
pyo_CLEAR
- Py_CLEAR(self->phase);
- Py_CLEAR(self->phase_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->phase);
+ Py_CLEAR(self->phase_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -2817,7 +2808,7 @@ Phasor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *phasetmp=NULL, *multmp=NULL, *addtmp=NULL;
Phasor *self;
self = (Phasor *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100);
self->phase = PyFloat_FromDouble(0);
self->modebuffer[0] = 0;
@@ -2825,16 +2816,16 @@ Phasor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->pointerPos = 0.;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Phasor_compute_next_data_frame);
self->mode_func_ptr = Phasor_setProcMode;
static char *kwlist[] = {"freq", "phase", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &phasetmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -2842,28 +2833,28 @@ Phasor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (phasetmp) {
PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Phasor_getServer(Phasor* self) { GET_SERVER };
static PyObject * Phasor_getStream(Phasor* self) { GET_STREAM };
-static PyObject * Phasor_setMul(Phasor *self, PyObject *arg) { SET_MUL };
-static PyObject * Phasor_setAdd(Phasor *self, PyObject *arg) { SET_ADD };
-static PyObject * Phasor_setSub(Phasor *self, PyObject *arg) { SET_SUB };
-static PyObject * Phasor_setDiv(Phasor *self, PyObject *arg) { SET_DIV };
+static PyObject * Phasor_setMul(Phasor *self, PyObject *arg) { SET_MUL };
+static PyObject * Phasor_setAdd(Phasor *self, PyObject *arg) { SET_ADD };
+static PyObject * Phasor_setSub(Phasor *self, PyObject *arg) { SET_SUB };
+static PyObject * Phasor_setDiv(Phasor *self, PyObject *arg) { SET_DIV };
static PyObject * Phasor_play(Phasor *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Phasor_out(Phasor *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2882,14 +2873,14 @@ static PyObject *
Phasor_setFreq(Phasor *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -2905,25 +2896,25 @@ Phasor_setFreq(Phasor *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Phasor_setPhase(Phasor *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->phase);
@@ -2939,15 +2930,15 @@ Phasor_setPhase(Phasor *self, PyObject *arg)
self->phase_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
-static PyObject *
-Phasor_reset(Phasor *self)
+static PyObject *
+Phasor_reset(Phasor *self)
{
self->pointerPos = 0.0;
Py_INCREF(Py_None);
@@ -3082,11 +3073,11 @@ Pointer_readframes_a(Pointer *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *pha = Stream_getData((Stream *)self->index_stream);
for (i=0; i<self->bufsize; i++) {
- ph = Osc_clip(pha[i] * size, size);
+ ph = Osc_clip(pha[i] * size, size);
ipart = (int)ph;
fpart = ph - ipart;
self->data[i] = tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * fpart;
@@ -3112,40 +3103,40 @@ Pointer_setProcMode(Pointer *self)
self->proc_func_ptr = Pointer_readframes_a;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Pointer_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Pointer_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Pointer_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Pointer_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Pointer_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Pointer_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Pointer_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Pointer_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Pointer_postprocessing_revareva;
break;
- }
+ }
}
static void
Pointer_compute_next_data_frame(Pointer *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3154,18 +3145,18 @@ Pointer_traverse(Pointer *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->index);
- Py_VISIT(self->index_stream);
+ Py_VISIT(self->index);
+ Py_VISIT(self->index_stream);
return 0;
}
-static int
+static int
Pointer_clear(Pointer *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->index);
- Py_CLEAR(self->index_stream);
+ Py_CLEAR(self->index);
+ Py_CLEAR(self->index_stream);
return 0;
}
@@ -3184,52 +3175,49 @@ Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *indextmp, *multmp=NULL, *addtmp=NULL;
Pointer *self;
self = (Pointer *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Pointer_compute_next_data_frame);
self->mode_func_ptr = Pointer_setProcMode;
static char *kwlist[] = {"table", "index", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &tabletmp, &indextmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of Pointer must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Pointer must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
+
if (indextmp) {
PyObject_CallMethod((PyObject *)self, "setIndex", "O", indextmp);
}
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Pointer_getServer(Pointer* self) { GET_SERVER };
static PyObject * Pointer_getStream(Pointer* self) { GET_STREAM };
-static PyObject * Pointer_setMul(Pointer *self, PyObject *arg) { SET_MUL };
-static PyObject * Pointer_setAdd(Pointer *self, PyObject *arg) { SET_ADD };
-static PyObject * Pointer_setSub(Pointer *self, PyObject *arg) { SET_SUB };
-static PyObject * Pointer_setDiv(Pointer *self, PyObject *arg) { SET_DIV };
+static PyObject * Pointer_setMul(Pointer *self, PyObject *arg) { SET_MUL };
+static PyObject * Pointer_setAdd(Pointer *self, PyObject *arg) { SET_ADD };
+static PyObject * Pointer_setSub(Pointer *self, PyObject *arg) { SET_SUB };
+static PyObject * Pointer_setDiv(Pointer *self, PyObject *arg) { SET_DIV };
static PyObject * Pointer_play(Pointer *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Pointer_out(Pointer *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3255,40 +3243,36 @@ static PyObject *
Pointer_setTable(Pointer *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Pointer_setIndex(Pointer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- int isNumber = PyNumber_Check(arg);
- if (isNumber == 1) {
- PySys_WriteStderr("TypeError: \"index\" attribute of Pointer must be a PyoObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
- }
-
+
tmp = arg;
+ if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
+ PyErr_SetString(PyExc_TypeError, "\"index\" argument of Pointer must be a PyoObject.\n");
+ Py_RETURN_NONE;
+ }
+
Py_INCREF(tmp);
Py_XDECREF(self->index);
@@ -3297,10 +3281,10 @@ Pointer_setIndex(Pointer *self, PyObject *arg)
Py_INCREF(streamtmp);
Py_XDECREF(self->index_stream);
self->index_stream = (Stream *)streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Pointer_members[] = {
{"server", T_OBJECT_EX, offsetof(Pointer, server), 0, "Pyo server."},
@@ -3438,12 +3422,12 @@ Pointer2_readframes_a(Pointer2 *self) {
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
double tableSr = TableStream_getSamplingRate(self->table);
-
+
MYFLT *pha = Stream_getData((Stream *)self->index_stream);
if (!self->autosmooth) {
for (i=0; i<self->bufsize; i++) {
- ph = Osc_clip(pha[i] * size, size);
+ ph = Osc_clip(pha[i] * size, size);
ipart = (int)ph;
fpart = ph - ipart;
self->y1 = self->y2 = self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
@@ -3489,40 +3473,40 @@ Pointer2_setProcMode(Pointer2 *self)
self->proc_func_ptr = Pointer2_readframes_a;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Pointer2_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Pointer2_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Pointer2_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Pointer2_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Pointer2_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Pointer2_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Pointer2_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Pointer2_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Pointer2_postprocessing_revareva;
break;
- }
+ }
}
static void
Pointer2_compute_next_data_frame(Pointer2 *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3531,18 +3515,18 @@ Pointer2_traverse(Pointer2 *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->index);
- Py_VISIT(self->index_stream);
+ Py_VISIT(self->index);
+ Py_VISIT(self->index_stream);
return 0;
}
-static int
+static int
Pointer2_clear(Pointer2 *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->index);
- Py_CLEAR(self->index_stream);
+ Py_CLEAR(self->index);
+ Py_CLEAR(self->index_stream);
return 0;
}
@@ -3561,57 +3545,54 @@ Pointer2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *indextmp, *multmp=NULL, *addtmp=NULL;
Pointer2 *self;
self = (Pointer2 *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->interp = 4;
self->autosmooth = 1;
self->y1 = self->y2 = self->c = self->lastPh = 0.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Pointer2_compute_next_data_frame);
self->mode_func_ptr = Pointer2_setProcMode;
static char *kwlist[] = {"table", "index", "interp", "autosmooth", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|iiOO", kwlist, &tabletmp, &indextmp, &self->interp, &self->autosmooth, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of Pointer2 must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Pointer2 must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
+
if (indextmp) {
PyObject_CallMethod((PyObject *)self, "setIndex", "O", indextmp);
}
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
SET_INTERP_POINTER
-
+
return (PyObject *)self;
}
static PyObject * Pointer2_getServer(Pointer2* self) { GET_SERVER };
static PyObject * Pointer2_getStream(Pointer2* self) { GET_STREAM };
-static PyObject * Pointer2_setMul(Pointer2 *self, PyObject *arg) { SET_MUL };
-static PyObject * Pointer2_setAdd(Pointer2 *self, PyObject *arg) { SET_ADD };
-static PyObject * Pointer2_setSub(Pointer2 *self, PyObject *arg) { SET_SUB };
-static PyObject * Pointer2_setDiv(Pointer2 *self, PyObject *arg) { SET_DIV };
+static PyObject * Pointer2_setMul(Pointer2 *self, PyObject *arg) { SET_MUL };
+static PyObject * Pointer2_setAdd(Pointer2 *self, PyObject *arg) { SET_ADD };
+static PyObject * Pointer2_setSub(Pointer2 *self, PyObject *arg) { SET_SUB };
+static PyObject * Pointer2_setDiv(Pointer2 *self, PyObject *arg) { SET_DIV };
static PyObject * Pointer2_play(Pointer2 *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Pointer2_out(Pointer2 *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3637,40 +3618,36 @@ static PyObject *
Pointer2_setTable(Pointer2 *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Pointer2_setIndex(Pointer2 *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- int isNumber = PyNumber_Check(arg);
- if (isNumber == 1) {
- PySys_WriteStderr("TypeError: \"index\" attribute of Pointer2 must be a PyoObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
- }
-
+
tmp = arg;
+ if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
+ PyErr_SetString(PyExc_TypeError, "\"index\" argument of Pointer2 must be a PyoObject.\n");
+ Py_RETURN_NONE;
+ }
+
Py_INCREF(tmp);
Py_XDECREF(self->index);
@@ -3679,10 +3656,10 @@ Pointer2_setIndex(Pointer2 *self, PyObject *arg)
Py_INCREF(streamtmp);
Py_XDECREF(self->index_stream);
self->index_stream = (Stream *)streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Pointer2_setInterp(Pointer2 *self, PyObject *arg)
@@ -3691,15 +3668,15 @@ Pointer2_setInterp(Pointer2 *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
SET_INTERP_POINTER
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3711,12 +3688,12 @@ Pointer2_setAutoSmooth(Pointer2 *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->autosmooth = PyInt_AsLong(PyNumber_Int(arg));
- }
+ }
Py_INCREF(Py_None);
return Py_None;
@@ -3850,16 +3827,16 @@ TableIndex_readframes_a(TableIndex *self) {
int i, ind;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *phase = Stream_getData((Stream *)self->index_stream);
-
+
for (i=0; i<self->bufsize; i++) {
ind = (int)phase[i];
if (ind < 0)
ind = 0;
else if (ind >= size)
ind = size - 1;
-
+
self->data[i] = tablelist[ind];
}
}
@@ -3879,44 +3856,44 @@ TableIndex_setProcMode(TableIndex *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = TableIndex_readframes_a;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TableIndex_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TableIndex_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TableIndex_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TableIndex_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TableIndex_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TableIndex_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TableIndex_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TableIndex_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TableIndex_postprocessing_revareva;
break;
- }
+ }
}
static void
TableIndex_compute_next_data_frame(TableIndex *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3925,18 +3902,18 @@ TableIndex_traverse(TableIndex *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->index);
- Py_VISIT(self->index_stream);
+ Py_VISIT(self->index);
+ Py_VISIT(self->index_stream);
return 0;
}
-static int
+static int
TableIndex_clear(TableIndex *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->index);
- Py_CLEAR(self->index_stream);
+ Py_CLEAR(self->index);
+ Py_CLEAR(self->index_stream);
return 0;
}
@@ -3955,52 +3932,49 @@ TableIndex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *indextmp, *multmp=NULL, *addtmp=NULL;
TableIndex *self;
self = (TableIndex *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TableIndex_compute_next_data_frame);
self->mode_func_ptr = TableIndex_setProcMode;
static char *kwlist[] = {"table", "index", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &tabletmp, &indextmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of TableIndex must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TableIndex must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
+
if (indextmp) {
PyObject_CallMethod((PyObject *)self, "setIndex", "O", indextmp);
}
-
+
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * TableIndex_getServer(TableIndex* self) { GET_SERVER };
static PyObject * TableIndex_getStream(TableIndex* self) { GET_STREAM };
-static PyObject * TableIndex_setMul(TableIndex *self, PyObject *arg) { SET_MUL };
-static PyObject * TableIndex_setAdd(TableIndex *self, PyObject *arg) { SET_ADD };
-static PyObject * TableIndex_setSub(TableIndex *self, PyObject *arg) { SET_SUB };
-static PyObject * TableIndex_setDiv(TableIndex *self, PyObject *arg) { SET_DIV };
+static PyObject * TableIndex_setMul(TableIndex *self, PyObject *arg) { SET_MUL };
+static PyObject * TableIndex_setAdd(TableIndex *self, PyObject *arg) { SET_ADD };
+static PyObject * TableIndex_setSub(TableIndex *self, PyObject *arg) { SET_SUB };
+static PyObject * TableIndex_setDiv(TableIndex *self, PyObject *arg) { SET_DIV };
static PyObject * TableIndex_play(TableIndex *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TableIndex_out(TableIndex *self, PyObject *args, PyObject *kwds) { OUT };
@@ -4026,52 +4000,48 @@ static PyObject *
TableIndex_setTable(TableIndex *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TableIndex_setIndex(TableIndex *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- int isNumber = PyNumber_Check(arg);
- if (isNumber == 1) {
- PySys_WriteStderr("TypeError: \"index\" attribute of TableIndex must be a PyoObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
- }
-
+
tmp = arg;
+ if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
+ PyErr_SetString(PyExc_TypeError, "\"index\" argument of TableIndex must be a PyoObject.\n");
+ Py_RETURN_NONE;
+ }
+
Py_INCREF(tmp);
Py_XDECREF(self->index);
-
+
self->index = tmp;
streamtmp = PyObject_CallMethod((PyObject *)self->index, "_getStream", NULL);
Py_INCREF(streamtmp);
Py_XDECREF(self->index_stream);
self->index_stream = (Stream *)streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TableIndex_members[] = {
{"server", T_OBJECT_EX, offsetof(TableIndex, server), 0, "Pyo server."},
@@ -4210,14 +4180,14 @@ Lookup_readframes_a(Lookup *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *pha = Stream_getData((Stream *)self->index_stream);
-
+
for (i=0; i<self->bufsize; i++) {
- ph = (Lookup_clip(pha[i]) * 0.5 + 0.5) * size;
+ ph = (Lookup_clip(pha[i]) * 0.495 + 0.5) * size;
ipart = (int)ph;
fpart = ph - ipart;
- self->data[i] = tablelist[ipart] * (1.0 - fpart) + tablelist[ipart+1] * fpart;
+ self->data[i] = tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * fpart;
}
}
@@ -4236,44 +4206,44 @@ Lookup_setProcMode(Lookup *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Lookup_readframes_a;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Lookup_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Lookup_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Lookup_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Lookup_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Lookup_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Lookup_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Lookup_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Lookup_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Lookup_postprocessing_revareva;
break;
- }
+ }
}
static void
Lookup_compute_next_data_frame(Lookup *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4282,18 +4252,18 @@ Lookup_traverse(Lookup *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->index);
- Py_VISIT(self->index_stream);
+ Py_VISIT(self->index);
+ Py_VISIT(self->index_stream);
return 0;
}
-static int
+static int
Lookup_clear(Lookup *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->index);
- Py_CLEAR(self->index_stream);
+ Py_CLEAR(self->index);
+ Py_CLEAR(self->index_stream);
return 0;
}
@@ -4312,52 +4282,49 @@ Lookup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *indextmp, *multmp=NULL, *addtmp=NULL;
Lookup *self;
self = (Lookup *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Lookup_compute_next_data_frame);
self->mode_func_ptr = Lookup_setProcMode;
static char *kwlist[] = {"table", "index", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &tabletmp, &indextmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of Lookup must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Lookup must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
+
if (indextmp) {
PyObject_CallMethod((PyObject *)self, "setIndex", "O", indextmp);
}
-
+
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Lookup_getServer(Lookup* self) { GET_SERVER };
static PyObject * Lookup_getStream(Lookup* self) { GET_STREAM };
-static PyObject * Lookup_setMul(Lookup *self, PyObject *arg) { SET_MUL };
-static PyObject * Lookup_setAdd(Lookup *self, PyObject *arg) { SET_ADD };
-static PyObject * Lookup_setSub(Lookup *self, PyObject *arg) { SET_SUB };
-static PyObject * Lookup_setDiv(Lookup *self, PyObject *arg) { SET_DIV };
+static PyObject * Lookup_setMul(Lookup *self, PyObject *arg) { SET_MUL };
+static PyObject * Lookup_setAdd(Lookup *self, PyObject *arg) { SET_ADD };
+static PyObject * Lookup_setSub(Lookup *self, PyObject *arg) { SET_SUB };
+static PyObject * Lookup_setDiv(Lookup *self, PyObject *arg) { SET_DIV };
static PyObject * Lookup_play(Lookup *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Lookup_out(Lookup *self, PyObject *args, PyObject *kwds) { OUT };
@@ -4383,52 +4350,48 @@ static PyObject *
Lookup_setTable(Lookup *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Lookup_setIndex(Lookup *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- int isNumber = PyNumber_Check(arg);
- if (isNumber == 1) {
- PySys_WriteStderr("TypeError: \"index\" attribute of Lookup must be a PyoObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
- }
-
+
tmp = arg;
+ if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
+ PyErr_SetString(PyExc_TypeError, "\"index\" argument of Lookup must be a PyoObject.\n");
+ Py_RETURN_NONE;
+ }
+
Py_INCREF(tmp);
Py_XDECREF(self->index);
-
+
self->index = tmp;
streamtmp = PyObject_CallMethod((PyObject *)self->index, "_getStream", NULL);
Py_INCREF(streamtmp);
Py_XDECREF(self->index_stream);
self->index_stream = (Stream *)streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Lookup_members[] = {
{"server", T_OBJECT_EX, offsetof(Lookup, server), 0, "Pyo server."},
@@ -4568,13 +4531,13 @@ Pulsar_readframes_iii(Pulsar *self) {
MYFLT *envlist = TableStream_getData(self->env);
int size = TableStream_getSize(self->table);
int envsize = TableStream_getSize(self->env);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
ph = PyFloat_AS_DOUBLE(self->phase);
frac = _clip(PyFloat_AS_DOUBLE(self->frac));
invfrac = 1.0 / frac;
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -4590,15 +4553,15 @@ Pulsar_readframes_iii(Pulsar *self) {
ipart = (int)t_pos;
fpart = t_pos - ipart;
tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-
+
e_pos = scl_pos * envsize;
ipart = (int)e_pos;
fpart = e_pos - ipart;
self->data[i] = tmp * (envlist[ipart] * (1.0 - fpart) + envlist[ipart+1] * fpart);
- }
+ }
else {
self->data[i] = 0.0;
- }
+ }
}
}
@@ -4611,12 +4574,12 @@ Pulsar_readframes_aii(Pulsar *self) {
MYFLT *envlist = TableStream_getData(self->env);
int size = TableStream_getSize(self->table);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
ph = PyFloat_AS_DOUBLE(self->phase);
frac = _clip(PyFloat_AS_DOUBLE(self->frac));
invfrac = 1.0 / frac;
-
+
oneOnSr = 1.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * oneOnSr;
@@ -4634,15 +4597,15 @@ Pulsar_readframes_aii(Pulsar *self) {
ipart = (int)t_pos;
fpart = t_pos - ipart;
tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-
+
e_pos = scl_pos * envsize;
ipart = (int)e_pos;
fpart = e_pos - ipart;
self->data[i] = tmp * (envlist[ipart] * (1.0 - fpart) + envlist[ipart+1] * fpart);
- }
+ }
else {
self->data[i] = 0.0;
- }
+ }
}
}
@@ -4655,13 +4618,13 @@ Pulsar_readframes_iai(Pulsar *self) {
MYFLT *envlist = TableStream_getData(self->env);
int size = TableStream_getSize(self->table);
int envsize = TableStream_getSize(self->env);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
frac = _clip(PyFloat_AS_DOUBLE(self->frac));
invfrac = 1.0 / frac;
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -4677,15 +4640,15 @@ Pulsar_readframes_iai(Pulsar *self) {
ipart = (int)t_pos;
fpart = t_pos - ipart;
tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-
+
e_pos = scl_pos * envsize;
ipart = (int)e_pos;
fpart = e_pos - ipart;
self->data[i] = tmp * (envlist[ipart] * (1.0 - fpart) + envlist[ipart+1] * fpart);
- }
+ }
else {
self->data[i] = 0.0;
- }
+ }
}
}
@@ -4698,12 +4661,12 @@ Pulsar_readframes_aai(Pulsar *self) {
MYFLT *envlist = TableStream_getData(self->env);
int size = TableStream_getSize(self->table);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
frac = _clip(PyFloat_AS_DOUBLE(self->frac));
invfrac = 1.0 / frac;
-
+
oneOnSr = 1.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * oneOnSr;
@@ -4721,15 +4684,15 @@ Pulsar_readframes_aai(Pulsar *self) {
ipart = (int)t_pos;
fpart = t_pos - ipart;
tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-
+
e_pos = scl_pos * envsize;
ipart = (int)e_pos;
fpart = e_pos - ipart;
self->data[i] = tmp * (envlist[ipart] * (1.0 - fpart) + envlist[ipart+1] * fpart);
- }
+ }
else {
self->data[i] = 0.0;
- }
+ }
}
}
@@ -4742,12 +4705,12 @@ Pulsar_readframes_iia(Pulsar *self) {
MYFLT *envlist = TableStream_getData(self->env);
int size = TableStream_getSize(self->table);
int envsize = TableStream_getSize(self->env);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
ph = PyFloat_AS_DOUBLE(self->phase);
MYFLT *frac = Stream_getData((Stream *)self->frac_stream);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
curfrac = frac[i];
self->pointerPos += inc;
@@ -4764,15 +4727,15 @@ Pulsar_readframes_iia(Pulsar *self) {
ipart = (int)t_pos;
fpart = t_pos - ipart;
tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-
+
e_pos = scl_pos * envsize;
ipart = (int)e_pos;
fpart = e_pos - ipart;
self->data[i] = tmp * (envlist[ipart] * (1.0 - fpart) + envlist[ipart+1] * fpart);
- }
+ }
else {
self->data[i] = 0.0;
- }
+ }
}
}
@@ -4785,11 +4748,11 @@ Pulsar_readframes_aia(Pulsar *self) {
MYFLT *envlist = TableStream_getData(self->env);
int size = TableStream_getSize(self->table);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
ph = PyFloat_AS_DOUBLE(self->phase);
MYFLT *frac = Stream_getData((Stream *)self->frac_stream);
-
+
oneOnSr = 1.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
curfrac = frac[i];
@@ -4808,15 +4771,15 @@ Pulsar_readframes_aia(Pulsar *self) {
ipart = (int)t_pos;
fpart = t_pos - ipart;
tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-
+
e_pos = scl_pos * envsize;
ipart = (int)e_pos;
fpart = e_pos - ipart;
self->data[i] = tmp * (envlist[ipart] * (1.0 - fpart) + envlist[ipart+1] * fpart);
- }
+ }
else {
self->data[i] = 0.0;
- }
+ }
}
}
@@ -4829,12 +4792,12 @@ Pulsar_readframes_iaa(Pulsar *self) {
MYFLT *envlist = TableStream_getData(self->env);
int size = TableStream_getSize(self->table);
int envsize = TableStream_getSize(self->env);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
MYFLT *frac = Stream_getData((Stream *)self->frac_stream);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
curfrac = frac[i];
self->pointerPos += inc;
@@ -4851,15 +4814,15 @@ Pulsar_readframes_iaa(Pulsar *self) {
ipart = (int)t_pos;
fpart = t_pos - ipart;
tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-
+
e_pos = scl_pos * envsize;
ipart = (int)e_pos;
fpart = e_pos - ipart;
self->data[i] = tmp * (envlist[ipart] * (1.0 - fpart) + envlist[ipart+1] * fpart);
- }
+ }
else {
self->data[i] = 0.0;
- }
+ }
}
}
@@ -4872,11 +4835,11 @@ Pulsar_readframes_aaa(Pulsar *self) {
MYFLT *envlist = TableStream_getData(self->env);
int size = TableStream_getSize(self->table);
int envsize = TableStream_getSize(self->env);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
MYFLT *frac = Stream_getData((Stream *)self->frac_stream);
-
+
oneOnSr = 1.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
curfrac = frac[i];
@@ -4895,15 +4858,15 @@ Pulsar_readframes_aaa(Pulsar *self) {
ipart = (int)t_pos;
fpart = t_pos - ipart;
tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-
+
e_pos = scl_pos * envsize;
ipart = (int)e_pos;
fpart = e_pos - ipart;
self->data[i] = tmp * (envlist[ipart] * (1.0 - fpart) + envlist[ipart+1] * fpart);
- }
+ }
else {
self->data[i] = 0.0;
- }
+ }
}
}
@@ -4923,68 +4886,68 @@ Pulsar_setProcMode(Pulsar *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Pulsar_readframes_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Pulsar_readframes_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Pulsar_readframes_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Pulsar_readframes_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Pulsar_readframes_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Pulsar_readframes_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Pulsar_readframes_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Pulsar_readframes_aaa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Pulsar_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Pulsar_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Pulsar_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Pulsar_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Pulsar_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Pulsar_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Pulsar_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Pulsar_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Pulsar_postprocessing_revareva;
break;
- }
+ }
}
static void
Pulsar_compute_next_data_frame(Pulsar *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4994,26 +4957,26 @@ Pulsar_traverse(Pulsar *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->table);
Py_VISIT(self->env);
- Py_VISIT(self->phase);
- Py_VISIT(self->phase_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->frac);
+ Py_VISIT(self->phase);
+ Py_VISIT(self->phase_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->frac);
Py_VISIT(self->frac_stream);
return 0;
}
-static int
+static int
Pulsar_clear(Pulsar *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
Py_CLEAR(self->env);
- Py_CLEAR(self->phase);
- Py_CLEAR(self->phase_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->frac);
+ Py_CLEAR(self->phase);
+ Py_CLEAR(self->phase_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->frac);
Py_CLEAR(self->frac_stream);
return 0;
}
@@ -5033,7 +4996,7 @@ Pulsar_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *envtmp, *freqtmp=NULL, *phasetmp=NULL, *fractmp=NULL, *multmp=NULL, *addtmp=NULL;
Pulsar *self;
self = (Pulsar *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100);
self->phase = PyFloat_FromDouble(0);
self->frac = PyFloat_FromDouble(0.5);
@@ -5044,32 +5007,26 @@ Pulsar_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
self->pointerPos = 0.;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Pulsar_compute_next_data_frame);
self->mode_func_ptr = Pulsar_setProcMode;
static char *kwlist[] = {"table", "env", "freq", "frac", "phase", "interp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOOiOO", kwlist, &tabletmp, &envtmp, &freqtmp, &fractmp, &phasetmp, &self->interp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of Pulsar must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Pulsar must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
if ( PyObject_HasAttrString((PyObject *)envtmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"env\" argument of Pulsar must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"env\" argument of Pulsar must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->env);
self->env = PyObject_CallMethod((PyObject *)envtmp, "getTableStream", "");
@@ -5077,7 +5034,7 @@ Pulsar_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (phasetmp) {
PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
}
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -5085,30 +5042,30 @@ Pulsar_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (fractmp) {
PyObject_CallMethod((PyObject *)self, "setFrac", "O", fractmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
SET_INTERP_POINTER
-
+
return (PyObject *)self;
}
static PyObject * Pulsar_getServer(Pulsar* self) { GET_SERVER };
static PyObject * Pulsar_getStream(Pulsar* self) { GET_STREAM };
-static PyObject * Pulsar_setMul(Pulsar *self, PyObject *arg) { SET_MUL };
-static PyObject * Pulsar_setAdd(Pulsar *self, PyObject *arg) { SET_ADD };
-static PyObject * Pulsar_setSub(Pulsar *self, PyObject *arg) { SET_SUB };
-static PyObject * Pulsar_setDiv(Pulsar *self, PyObject *arg) { SET_DIV };
+static PyObject * Pulsar_setMul(Pulsar *self, PyObject *arg) { SET_MUL };
+static PyObject * Pulsar_setAdd(Pulsar *self, PyObject *arg) { SET_ADD };
+static PyObject * Pulsar_setSub(Pulsar *self, PyObject *arg) { SET_SUB };
+static PyObject * Pulsar_setDiv(Pulsar *self, PyObject *arg) { SET_DIV };
static PyObject * Pulsar_play(Pulsar *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Pulsar_out(Pulsar *self, PyObject *args, PyObject *kwds) { OUT };
@@ -5141,50 +5098,50 @@ static PyObject *
Pulsar_setTable(Pulsar *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Pulsar_setEnv(Pulsar *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->env);
self->env = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Pulsar_setFreq(Pulsar *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -5200,25 +5157,25 @@ Pulsar_setFreq(Pulsar *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Pulsar_setPhase(Pulsar *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->phase);
@@ -5234,25 +5191,25 @@ Pulsar_setPhase(Pulsar *self, PyObject *arg)
self->phase_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Pulsar_setFrac(Pulsar *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->frac);
@@ -5268,12 +5225,12 @@ Pulsar_setFrac(Pulsar *self, PyObject *arg)
self->frac_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Pulsar_setInterp(Pulsar *self, PyObject *arg)
@@ -5282,15 +5239,15 @@ Pulsar_setInterp(Pulsar *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
SET_INTERP_POINTER
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -5426,7 +5383,7 @@ typedef struct {
double pointerPos;
MYFLT *trigsBuffer;
TriggerStream *trig_stream;
- int init;
+ int init;
int interp; /* 0 = default to 2, 1 = nointerp, 2 = linear, 3 = cos, 4 = cubic */
MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
} TableRead;
@@ -5437,10 +5394,10 @@ TableRead_readframes_i(TableRead *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr * size / self->sr;
-
+
if (self->go == 0)
PyObject_CallMethod((PyObject *)self, "stop", NULL);
@@ -5452,7 +5409,7 @@ TableRead_readframes_i(TableRead *self) {
else
self->init = 0;
self->pointerPos = size + self->pointerPos;
- }
+ }
else if (self->pointerPos >= size) {
self->trigsBuffer[i] = 1.0;
if (self->loop == 1)
@@ -5467,7 +5424,7 @@ TableRead_readframes_i(TableRead *self) {
}
else
self->data[i] = 0.0;
-
+
self->pointerPos += inc;
}
}
@@ -5478,9 +5435,9 @@ TableRead_readframes_a(TableRead *self) {
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
sizeOnSr = size / self->sr;
if (self->go == 0)
@@ -5494,7 +5451,7 @@ TableRead_readframes_a(TableRead *self) {
else
self->init = 0;
self->pointerPos = size + self->pointerPos;
- }
+ }
else if (self->pointerPos >= size) {
self->trigsBuffer[i] = 1.0;
if (self->loop == 1)
@@ -5506,10 +5463,10 @@ TableRead_readframes_a(TableRead *self) {
ipart = (int)self->pointerPos;
fpart = self->pointerPos - ipart;
self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
- }
+ }
else
self->data[i] = 0.0;
-
+
inc = fr[i] * sizeOnSr;
self->pointerPos += inc;
}
@@ -5531,50 +5488,50 @@ TableRead_setProcMode(TableRead *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = TableRead_readframes_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = TableRead_readframes_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TableRead_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TableRead_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TableRead_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TableRead_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TableRead_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TableRead_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TableRead_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TableRead_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TableRead_postprocessing_revareva;
break;
- }
+ }
}
static void
TableRead_compute_next_data_frame(TableRead *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -5583,20 +5540,20 @@ TableRead_traverse(TableRead *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
TableRead_clear(TableRead *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -5617,7 +5574,7 @@ TableRead_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
TableRead *self;
self = (TableRead *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1);
self->loop = 0;
self->init = 1;
@@ -5626,22 +5583,19 @@ TableRead_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->pointerPos = 0.;
self->interp = 2;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TableRead_compute_next_data_frame);
self->mode_func_ptr = TableRead_setProcMode;
static char *kwlist[] = {"table", "freq", "loop", "interp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OiiOO", kwlist, &tabletmp, &freqtmp, &self->loop, &self->interp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of TableRead must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TableRead must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
@@ -5649,65 +5603,65 @@ TableRead_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
-
+
tablelist = TableStream_getData(self->table);
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
self->data[i] = tablelist[0];
- }
+ }
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
-
+
(*self->mode_func_ptr)(self);
SET_INTERP_POINTER
self->init = 1;
-
+
return (PyObject *)self;
}
static PyObject * TableRead_getServer(TableRead* self) { GET_SERVER };
static PyObject * TableRead_getStream(TableRead* self) { GET_STREAM };
static PyObject * TableRead_getTriggerStream(TableRead* self) { GET_TRIGGER_STREAM };
-static PyObject * TableRead_setMul(TableRead *self, PyObject *arg) { SET_MUL };
-static PyObject * TableRead_setAdd(TableRead *self, PyObject *arg) { SET_ADD };
-static PyObject * TableRead_setSub(TableRead *self, PyObject *arg) { SET_SUB };
-static PyObject * TableRead_setDiv(TableRead *self, PyObject *arg) { SET_DIV };
+static PyObject * TableRead_setMul(TableRead *self, PyObject *arg) { SET_MUL };
+static PyObject * TableRead_setAdd(TableRead *self, PyObject *arg) { SET_ADD };
+static PyObject * TableRead_setSub(TableRead *self, PyObject *arg) { SET_SUB };
+static PyObject * TableRead_setDiv(TableRead *self, PyObject *arg) { SET_DIV };
-static PyObject * TableRead_play(TableRead *self, PyObject *args, PyObject *kwds)
-{
+static PyObject * TableRead_play(TableRead *self, PyObject *args, PyObject *kwds)
+{
self->pointerPos = 0.0;
self->init = 1;
self->go = 1;
- PLAY
+ PLAY
};
-static PyObject * TableRead_out(TableRead *self, PyObject *args, PyObject *kwds)
-{
+static PyObject * TableRead_out(TableRead *self, PyObject *args, PyObject *kwds)
+{
self->pointerPos = 0.0;
self->init = 1;
self->go = 1;
- OUT
+ OUT
};
-static PyObject * TableRead_stop(TableRead *self)
-{
+static PyObject * TableRead_stop(TableRead *self)
+{
self->go = 0;
- STOP
+ STOP
};
static PyObject * TableRead_multiply(TableRead *self, PyObject *arg) { MULTIPLY };
@@ -5730,32 +5684,32 @@ static PyObject *
TableRead_setTable(TableRead *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TableRead_setFreq(TableRead *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -5771,12 +5725,12 @@ TableRead_setFreq(TableRead *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TableRead_setLoop(TableRead *self, PyObject *arg)
@@ -5785,9 +5739,9 @@ TableRead_setLoop(TableRead *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->loop = PyInt_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -5799,21 +5753,21 @@ TableRead_setInterp(TableRead *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
SET_INTERP_POINTER
-
+
Py_INCREF(Py_None);
return Py_None;
}
-static PyObject *
-TableRead_reset(TableRead *self)
+static PyObject *
+TableRead_reset(TableRead *self)
{
self->pointerPos = 0.0;
Py_INCREF(Py_None);
@@ -5956,22 +5910,22 @@ static void
Fm_readframes_iii(Fm *self) {
MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
int i, ipart;
-
+
MYFLT car = PyFloat_AS_DOUBLE(self->car);
MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
MYFLT ind = PyFloat_AS_DOUBLE(self->index);
-
+
mod_freq = car * rat;
mod_amp = mod_freq * ind;
mod_delta = mod_freq * self->scaleFactor;
-
+
for (i=0; i<self->bufsize; i++) {
self->pointerPos_mod = Sine_clip(self->pointerPos_mod);
ipart = (int)self->pointerPos_mod;
fpart = self->pointerPos_mod - ipart;
mod_val = mod_amp * (SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart);
self->pointerPos_mod += mod_delta;
-
+
car_freq = car + mod_val;
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
@@ -5986,7 +5940,7 @@ static void
Fm_readframes_aii(Fm *self) {
MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
int i, ipart;
-
+
MYFLT *car = Stream_getData((Stream *)self->car_stream);
MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
MYFLT ind = PyFloat_AS_DOUBLE(self->index);
@@ -6000,7 +5954,7 @@ Fm_readframes_aii(Fm *self) {
fpart = self->pointerPos_mod - ipart;
mod_val = mod_amp * (SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart);
self->pointerPos_mod += mod_delta;
-
+
car_freq = car[i] + mod_val;
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
@@ -6015,7 +5969,7 @@ static void
Fm_readframes_iai(Fm *self) {
MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
int i, ipart;
-
+
MYFLT car = PyFloat_AS_DOUBLE(self->car);
MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
MYFLT ind = PyFloat_AS_DOUBLE(self->index);
@@ -6029,7 +5983,7 @@ Fm_readframes_iai(Fm *self) {
fpart = self->pointerPos_mod - ipart;
mod_val = mod_amp * (SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart);
self->pointerPos_mod += mod_delta;
-
+
car_freq = car + mod_val;
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
@@ -6044,7 +5998,7 @@ static void
Fm_readframes_aai(Fm *self) {
MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
int i, ipart;
-
+
MYFLT *car = Stream_getData((Stream *)self->car_stream);
MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
MYFLT ind = PyFloat_AS_DOUBLE(self->index);
@@ -6058,7 +6012,7 @@ Fm_readframes_aai(Fm *self) {
fpart = self->pointerPos_mod - ipart;
mod_val = mod_amp * (SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart);
self->pointerPos_mod += mod_delta;
-
+
car_freq = car[i] + mod_val;
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
@@ -6072,14 +6026,14 @@ static void
Fm_readframes_iia(Fm *self) {
MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
int i, ipart;
-
+
MYFLT car = PyFloat_AS_DOUBLE(self->car);
MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
MYFLT *ind = Stream_getData((Stream *)self->index_stream);
-
+
mod_freq = car * rat;
mod_delta = mod_freq * self->scaleFactor;
-
+
for (i=0; i<self->bufsize; i++) {
mod_amp = mod_freq * ind[i];
self->pointerPos_mod = Sine_clip(self->pointerPos_mod);
@@ -6087,7 +6041,7 @@ Fm_readframes_iia(Fm *self) {
fpart = self->pointerPos_mod - ipart;
mod_val = mod_amp * (SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart);
self->pointerPos_mod += mod_delta;
-
+
car_freq = car + mod_val;
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
@@ -6102,11 +6056,11 @@ static void
Fm_readframes_aia(Fm *self) {
MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
int i, ipart;
-
+
MYFLT *car = Stream_getData((Stream *)self->car_stream);
MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
MYFLT *ind = Stream_getData((Stream *)self->index_stream);
-
+
for (i=0; i<self->bufsize; i++) {
mod_freq = car[i] * rat;
mod_amp = mod_freq * ind[i];
@@ -6116,7 +6070,7 @@ Fm_readframes_aia(Fm *self) {
fpart = self->pointerPos_mod - ipart;
mod_val = mod_amp * (SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart);
self->pointerPos_mod += mod_delta;
-
+
car_freq = car[i] + mod_val;
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
@@ -6131,11 +6085,11 @@ static void
Fm_readframes_iaa(Fm *self) {
MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
int i, ipart;
-
+
MYFLT car = PyFloat_AS_DOUBLE(self->car);
MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
MYFLT *ind = Stream_getData((Stream *)self->index_stream);
-
+
for (i=0; i<self->bufsize; i++) {
mod_freq = car * rat[i];
mod_amp = mod_freq * ind[i];
@@ -6145,7 +6099,7 @@ Fm_readframes_iaa(Fm *self) {
fpart = self->pointerPos_mod - ipart;
mod_val = mod_amp * (SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart);
self->pointerPos_mod += mod_delta;
-
+
car_freq = car + mod_val;
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
@@ -6160,11 +6114,11 @@ static void
Fm_readframes_aaa(Fm *self) {
MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
int i, ipart;
-
+
MYFLT *car = Stream_getData((Stream *)self->car_stream);
MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
MYFLT *ind = Stream_getData((Stream *)self->index_stream);
-
+
for (i=0; i<self->bufsize; i++) {
mod_freq = car[i] * rat[i];
mod_amp = mod_freq * ind[i];
@@ -6174,7 +6128,7 @@ Fm_readframes_aaa(Fm *self) {
fpart = self->pointerPos_mod - ipart;
mod_val = mod_amp * (SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart);
self->pointerPos_mod += mod_delta;
-
+
car_freq = car[i] + mod_val;
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
@@ -6201,60 +6155,60 @@ Fm_setProcMode(Fm *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Fm_readframes_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Fm_readframes_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Fm_readframes_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Fm_readframes_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Fm_readframes_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Fm_readframes_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Fm_readframes_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Fm_readframes_aaa;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Fm_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Fm_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Fm_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Fm_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Fm_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Fm_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Fm_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Fm_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Fm_postprocessing_revareva;
break;
}
@@ -6263,7 +6217,7 @@ Fm_setProcMode(Fm *self)
static void
Fm_compute_next_data_frame(Fm *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -6271,25 +6225,25 @@ static int
Fm_traverse(Fm *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->car);
- Py_VISIT(self->car_stream);
- Py_VISIT(self->ratio);
- Py_VISIT(self->ratio_stream);
- Py_VISIT(self->index);
- Py_VISIT(self->index_stream);
+ Py_VISIT(self->car);
+ Py_VISIT(self->car_stream);
+ Py_VISIT(self->ratio);
+ Py_VISIT(self->ratio_stream);
+ Py_VISIT(self->index);
+ Py_VISIT(self->index_stream);
return 0;
}
-static int
+static int
Fm_clear(Fm *self)
{
pyo_CLEAR
- Py_CLEAR(self->car);
- Py_CLEAR(self->car_stream);
- Py_CLEAR(self->ratio);
- Py_CLEAR(self->ratio_stream);
- Py_CLEAR(self->index);
- Py_CLEAR(self->index_stream);
+ Py_CLEAR(self->car);
+ Py_CLEAR(self->car_stream);
+ Py_CLEAR(self->ratio);
+ Py_CLEAR(self->ratio_stream);
+ Py_CLEAR(self->index);
+ Py_CLEAR(self->index_stream);
return 0;
}
@@ -6308,7 +6262,7 @@ Fm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *cartmp=NULL, *ratiotmp=NULL, *indextmp=NULL, *multmp=NULL, *addtmp=NULL;
Fm *self;
self = (Fm *)type->tp_alloc(type, 0);
-
+
self->car = PyFloat_FromDouble(100);
self->ratio = PyFloat_FromDouble(0.5);
self->index = PyFloat_FromDouble(5);
@@ -6318,7 +6272,7 @@ Fm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
self->pointerPos_car = self->pointerPos_mod = 0.;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Fm_compute_next_data_frame);
self->mode_func_ptr = Fm_setProcMode;
@@ -6326,14 +6280,14 @@ Fm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->scaleFactor = 512.0 / self->sr;
static char *kwlist[] = {"carrier", "ratio", "index", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", kwlist, &cartmp, &ratiotmp, &indextmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (cartmp) {
PyObject_CallMethod((PyObject *)self, "setCarrier", "O", cartmp);
}
-
+
if (ratiotmp) {
PyObject_CallMethod((PyObject *)self, "setRatio", "O", ratiotmp);
}
@@ -6341,17 +6295,17 @@ Fm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (indextmp) {
PyObject_CallMethod((PyObject *)self, "setIndex", "O", indextmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -6359,10 +6313,10 @@ Fm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Fm_getServer(Fm* self) { GET_SERVER };
static PyObject * Fm_getStream(Fm* self) { GET_STREAM };
-static PyObject * Fm_setMul(Fm *self, PyObject *arg) { SET_MUL };
-static PyObject * Fm_setAdd(Fm *self, PyObject *arg) { SET_ADD };
-static PyObject * Fm_setSub(Fm *self, PyObject *arg) { SET_SUB };
-static PyObject * Fm_setDiv(Fm *self, PyObject *arg) { SET_DIV };
+static PyObject * Fm_setMul(Fm *self, PyObject *arg) { SET_MUL };
+static PyObject * Fm_setAdd(Fm *self, PyObject *arg) { SET_ADD };
+static PyObject * Fm_setSub(Fm *self, PyObject *arg) { SET_SUB };
+static PyObject * Fm_setDiv(Fm *self, PyObject *arg) { SET_DIV };
static PyObject * Fm_play(Fm *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Fm_out(Fm *self, PyObject *args, PyObject *kwds) { OUT };
@@ -6381,14 +6335,14 @@ static PyObject *
Fm_setCarrier(Fm *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->car);
@@ -6404,25 +6358,25 @@ Fm_setCarrier(Fm *self, PyObject *arg)
self->car_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Fm_setRatio(Fm *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->ratio);
@@ -6438,25 +6392,25 @@ Fm_setRatio(Fm *self, PyObject *arg)
self->ratio_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Fm_setIndex(Fm *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->index);
@@ -6472,12 +6426,12 @@ Fm_setIndex(Fm *self, PyObject *arg)
self->index_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Fm_members[] = {
{"server", T_OBJECT_EX, offsetof(Fm, server), 0, "Pyo server."},
@@ -6618,7 +6572,7 @@ CrossFm_readframes(CrossFm *self) {
MYFLT rat[self->bufsize];
MYFLT ind1[self->bufsize];
MYFLT ind2[self->bufsize];
-
+
if (self->modebuffer[2] == 0) {
MYFLT tmpcar = PyFloat_AS_DOUBLE(self->car);
for (i=0; i<self->bufsize; i++) {
@@ -6631,7 +6585,7 @@ CrossFm_readframes(CrossFm *self) {
car[i] = tmpcar[i];
}
}
-
+
if (self->modebuffer[3] == 0) {
MYFLT tmprat = PyFloat_AS_DOUBLE(self->ratio);
for (i=0; i<self->bufsize; i++) {
@@ -6644,26 +6598,26 @@ CrossFm_readframes(CrossFm *self) {
rat[i] = tmprat[i];
}
}
-
+
if (self->modebuffer[4] == 0) {
MYFLT tmpind1 = PyFloat_AS_DOUBLE(self->ind1);
for (i=0; i<self->bufsize; i++) {
ind1[i] = tmpind1;
}
- }
+ }
else {
MYFLT *tmpind1 = Stream_getData((Stream *)self->ind1_stream);
for (i=0; i<self->bufsize; i++) {
ind1[i] = tmpind1[i];
}
}
-
+
if (self->modebuffer[5] == 0) {
MYFLT tmpind2 = PyFloat_AS_DOUBLE(self->ind2);
for (i=0; i<self->bufsize; i++) {
ind2[i] = tmpind2;
}
- }
+ }
else {
MYFLT *tmpind2 = Stream_getData((Stream *)self->ind2_stream);
for (i=0; i<self->bufsize; i++) {
@@ -6681,7 +6635,7 @@ CrossFm_readframes(CrossFm *self) {
fpart = self->pointerPos_mod - ipart;
mod_val = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
self->pointerPos_mod += mod_delta;
-
+
car_freq = car[i] + (mod_val * mod_amp);
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
@@ -6710,33 +6664,33 @@ CrossFm_setProcMode(CrossFm *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
self->proc_func_ptr = CrossFm_readframes;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = CrossFm_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = CrossFm_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = CrossFm_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = CrossFm_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = CrossFm_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = CrossFm_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = CrossFm_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = CrossFm_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = CrossFm_postprocessing_revareva;
break;
}
@@ -6745,7 +6699,7 @@ CrossFm_setProcMode(CrossFm *self)
static void
CrossFm_compute_next_data_frame(CrossFm *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -6753,29 +6707,29 @@ static int
CrossFm_traverse(CrossFm *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->car);
- Py_VISIT(self->car_stream);
- Py_VISIT(self->ratio);
- Py_VISIT(self->ratio_stream);
- Py_VISIT(self->ind1);
- Py_VISIT(self->ind1_stream);
- Py_VISIT(self->ind2);
- Py_VISIT(self->ind2_stream);
+ Py_VISIT(self->car);
+ Py_VISIT(self->car_stream);
+ Py_VISIT(self->ratio);
+ Py_VISIT(self->ratio_stream);
+ Py_VISIT(self->ind1);
+ Py_VISIT(self->ind1_stream);
+ Py_VISIT(self->ind2);
+ Py_VISIT(self->ind2_stream);
return 0;
}
-static int
+static int
CrossFm_clear(CrossFm *self)
{
pyo_CLEAR
- Py_CLEAR(self->car);
- Py_CLEAR(self->car_stream);
- Py_CLEAR(self->ratio);
- Py_CLEAR(self->ratio_stream);
- Py_CLEAR(self->ind1);
- Py_CLEAR(self->ind1_stream);
- Py_CLEAR(self->ind2);
- Py_CLEAR(self->ind2_stream);
+ Py_CLEAR(self->car);
+ Py_CLEAR(self->car_stream);
+ Py_CLEAR(self->ratio);
+ Py_CLEAR(self->ratio_stream);
+ Py_CLEAR(self->ind1);
+ Py_CLEAR(self->ind1_stream);
+ Py_CLEAR(self->ind2);
+ Py_CLEAR(self->ind2_stream);
return 0;
}
@@ -6794,7 +6748,7 @@ CrossFm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *cartmp=NULL, *ratiotmp=NULL, *ind1tmp=NULL, *ind2tmp=NULL, *multmp=NULL, *addtmp=NULL;
CrossFm *self;
self = (CrossFm *)type->tp_alloc(type, 0);
-
+
self->car = PyFloat_FromDouble(100);
self->ratio = PyFloat_FromDouble(0.5);
self->ind1 = PyFloat_FromDouble(2);
@@ -6807,26 +6761,26 @@ CrossFm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[5] = 0;
self->pointerPos_car = self->pointerPos_mod = 0.;
self->car_val = 0.;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, CrossFm_compute_next_data_frame);
self->mode_func_ptr = CrossFm_setProcMode;
-
+
self->scaleFactor = 512.0 / self->sr;
static char *kwlist[] = {"carrier", "ratio", "ind1", "ind2", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOO", kwlist, &cartmp, &ratiotmp, &ind1tmp, &ind2tmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (cartmp) {
PyObject_CallMethod((PyObject *)self, "setCarrier", "O", cartmp);
}
-
+
if (ratiotmp) {
PyObject_CallMethod((PyObject *)self, "setRatio", "O", ratiotmp);
}
-
+
if (ind1tmp) {
PyObject_CallMethod((PyObject *)self, "setInd1", "O", ind1tmp);
}
@@ -6834,28 +6788,28 @@ CrossFm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (ind2tmp) {
PyObject_CallMethod((PyObject *)self, "setInd2", "O", ind2tmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * CrossFm_getServer(CrossFm* self) { GET_SERVER };
static PyObject * CrossFm_getStream(CrossFm* self) { GET_STREAM };
-static PyObject * CrossFm_setMul(CrossFm *self, PyObject *arg) { SET_MUL };
-static PyObject * CrossFm_setAdd(CrossFm *self, PyObject *arg) { SET_ADD };
-static PyObject * CrossFm_setSub(CrossFm *self, PyObject *arg) { SET_SUB };
-static PyObject * CrossFm_setDiv(CrossFm *self, PyObject *arg) { SET_DIV };
+static PyObject * CrossFm_setMul(CrossFm *self, PyObject *arg) { SET_MUL };
+static PyObject * CrossFm_setAdd(CrossFm *self, PyObject *arg) { SET_ADD };
+static PyObject * CrossFm_setSub(CrossFm *self, PyObject *arg) { SET_SUB };
+static PyObject * CrossFm_setDiv(CrossFm *self, PyObject *arg) { SET_DIV };
static PyObject * CrossFm_play(CrossFm *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * CrossFm_out(CrossFm *self, PyObject *args, PyObject *kwds) { OUT };
@@ -6874,14 +6828,14 @@ static PyObject *
CrossFm_setCarrier(CrossFm *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->car);
@@ -6897,25 +6851,25 @@ CrossFm_setCarrier(CrossFm *self, PyObject *arg)
self->car_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
CrossFm_setRatio(CrossFm *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->ratio);
@@ -6931,25 +6885,25 @@ CrossFm_setRatio(CrossFm *self, PyObject *arg)
self->ratio_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
CrossFm_setInd1(CrossFm *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->ind1);
@@ -6965,25 +6919,25 @@ CrossFm_setInd1(CrossFm *self, PyObject *arg)
self->ind1_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
CrossFm_setInd2(CrossFm *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->ind2);
@@ -6999,12 +6953,12 @@ CrossFm_setInd2(CrossFm *self, PyObject *arg)
self->ind2_stream = (Stream *)streamtmp;
self->modebuffer[5] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef CrossFm_members[] = {
{"server", T_OBJECT_EX, offsetof(CrossFm, server), 0, "Pyo server."},
@@ -7130,14 +7084,14 @@ typedef struct {
Stream *harms_stream;
int modebuffer[4];
MYFLT phase;
-
+
} Blit;
static void
Blit_readframes_ii(Blit *self) {
MYFLT p, m, rate, val;
int i, nHarms;
-
+
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT hrms = PyFloat_AS_DOUBLE(self->harms);
@@ -7165,13 +7119,13 @@ static void
Blit_readframes_ai(Blit *self) {
MYFLT p, m, rate, val;
int i, nHarms;
-
+
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
MYFLT hrms = PyFloat_AS_DOUBLE(self->harms);
nHarms = (int)hrms;
m = 2.0 * nHarms + 1.0;
-
+
for (i=0; i<self->bufsize; i++) {
p = self->sr / freq[i];
rate = PI / p;
@@ -7184,7 +7138,7 @@ Blit_readframes_ai(Blit *self) {
self->phase += rate;
if (self->phase >= PI)
self->phase -= PI;
-
+
self->data[i] = val;
}
}
@@ -7193,13 +7147,13 @@ static void
Blit_readframes_ia(Blit *self) {
MYFLT p, m, rate, val;
int i, nHarms;
-
+
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *hrms = Stream_getData((Stream *)self->harms_stream);
p = self->sr / freq;
rate = PI / p;
-
+
for (i=0; i<self->bufsize; i++) {
nHarms = (int)hrms[i];
m = 2.0 * nHarms + 1.0;
@@ -7212,7 +7166,7 @@ Blit_readframes_ia(Blit *self) {
self->phase += rate;
if (self->phase >= PI)
self->phase -= PI;
-
+
self->data[i] = val;
}
}
@@ -7221,10 +7175,10 @@ static void
Blit_readframes_aa(Blit *self) {
MYFLT p, m, rate, val;
int i, nHarms;
-
+
MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
MYFLT *hrms = Stream_getData((Stream *)self->harms_stream);
-
+
for (i=0; i<self->bufsize; i++) {
nHarms = (int)hrms[i];
m = 2.0 * nHarms + 1.0;
@@ -7239,7 +7193,7 @@ Blit_readframes_aa(Blit *self) {
self->phase += rate;
if (self->phase >= PI)
self->phase -= PI;
-
+
self->data[i] = val;
}
}
@@ -7260,48 +7214,48 @@ Blit_setProcMode(Blit *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Blit_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Blit_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Blit_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Blit_readframes_aa;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Blit_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Blit_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Blit_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Blit_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Blit_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Blit_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Blit_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Blit_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Blit_postprocessing_revareva;
break;
}
@@ -7310,7 +7264,7 @@ Blit_setProcMode(Blit *self)
static void
Blit_compute_next_data_frame(Blit *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -7318,21 +7272,21 @@ static int
Blit_traverse(Blit *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->harms);
- Py_VISIT(self->harms_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->harms);
+ Py_VISIT(self->harms_stream);
return 0;
}
-static int
+static int
Blit_clear(Blit *self)
{
pyo_CLEAR
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->harms);
- Py_CLEAR(self->harms_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->harms);
+ Py_CLEAR(self->harms_stream);
return 0;
}
@@ -7351,7 +7305,7 @@ Blit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *harmstmp=NULL, *multmp=NULL, *addtmp=NULL;
Blit *self;
self = (Blit *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100);
self->harms = PyFloat_FromDouble(40);
self->modebuffer[0] = 0;
@@ -7359,20 +7313,20 @@ Blit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->phase = 0.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Blit_compute_next_data_frame);
self->mode_func_ptr = Blit_setProcMode;
static char *kwlist[] = {"freq", "harms", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &harmstmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (harmstmp) {
PyObject_CallMethod((PyObject *)self, "setHarms", "O", harmstmp);
}
@@ -7380,13 +7334,13 @@ Blit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -7394,10 +7348,10 @@ Blit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Blit_getServer(Blit* self) { GET_SERVER };
static PyObject * Blit_getStream(Blit* self) { GET_STREAM };
-static PyObject * Blit_setMul(Blit *self, PyObject *arg) { SET_MUL };
-static PyObject * Blit_setAdd(Blit *self, PyObject *arg) { SET_ADD };
-static PyObject * Blit_setSub(Blit *self, PyObject *arg) { SET_SUB };
-static PyObject * Blit_setDiv(Blit *self, PyObject *arg) { SET_DIV };
+static PyObject * Blit_setMul(Blit *self, PyObject *arg) { SET_MUL };
+static PyObject * Blit_setAdd(Blit *self, PyObject *arg) { SET_ADD };
+static PyObject * Blit_setSub(Blit *self, PyObject *arg) { SET_SUB };
+static PyObject * Blit_setDiv(Blit *self, PyObject *arg) { SET_DIV };
static PyObject * Blit_play(Blit *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Blit_out(Blit *self, PyObject *args, PyObject *kwds) { OUT };
@@ -7416,14 +7370,14 @@ static PyObject *
Blit_setFreq(Blit *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -7439,25 +7393,25 @@ Blit_setFreq(Blit *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Blit_setHarms(Blit *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->harms);
@@ -7473,12 +7427,12 @@ Blit_setHarms(Blit *self, PyObject *arg)
self->harms_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Blit_members[] = {
{"server", T_OBJECT_EX, offsetof(Blit, server), 0, "Pyo server."},
@@ -7613,7 +7567,7 @@ static void
Rossler_readframes_ii(Rossler *self) {
MYFLT delta, pit, chao;
int i;
-
+
pit = PyFloat_AS_DOUBLE(self->pitch);
chao = PyFloat_AS_DOUBLE(self->chaos);
if (pit < 0.0)
@@ -7630,16 +7584,16 @@ Rossler_readframes_ii(Rossler *self) {
chao = 10.0;
else
chao = chao * 7.0 + 3.0;
-
+
for (i=0; i<self->bufsize; i++) {
self->vDX = -self->vY - self->vZ;
self->vDY = self->vX + self->pA * self->vY;
self->vDZ = self->pB + self->vZ * (self->vX - chao);
-
+
self->vX += self->vDX * delta;
self->vY += self->vDY * delta;
self->vZ += self->vDZ * delta;
-
+
self->data[i] = self->vX * ROSSLER_SCALE;
self->altBuffer[i] = self->vY * ROSSLER_ALT_SCALE;
}
@@ -7649,7 +7603,7 @@ static void
Rossler_readframes_ai(Rossler *self) {
MYFLT delta, pit, chao;
int i;
-
+
MYFLT *fr = Stream_getData((Stream *)self->pitch_stream);
chao = PyFloat_AS_DOUBLE(self->chaos);
if (chao < 0.0)
@@ -7658,7 +7612,7 @@ Rossler_readframes_ai(Rossler *self) {
chao = 10.0;
else
chao = chao * 7.0 + 3.0;
-
+
for (i=0; i<self->bufsize; i++) {
pit = fr[i];
if (pit < 0.0)
@@ -7671,11 +7625,11 @@ Rossler_readframes_ai(Rossler *self) {
self->vDX = -self->vY - self->vZ;
self->vDY = self->vX + self->pA * self->vY;
self->vDZ = self->pB + self->vZ * (self->vX - chao);
-
+
self->vX += self->vDX * delta;
self->vY += self->vDY * delta;
self->vZ += self->vDZ * delta;
-
+
self->data[i] = self->vX * ROSSLER_SCALE;
self->altBuffer[i] = self->vY * ROSSLER_ALT_SCALE;
}
@@ -7685,7 +7639,7 @@ static void
Rossler_readframes_ia(Rossler *self) {
MYFLT delta, pit, chao;
int i;
-
+
pit = PyFloat_AS_DOUBLE(self->pitch);
MYFLT *ch = Stream_getData((Stream *)self->chaos_stream);
@@ -7696,7 +7650,7 @@ Rossler_readframes_ia(Rossler *self) {
else
pit = pit * 999.0 + 1.0;
delta = self->scalePitch * pit;
-
+
for (i=0; i<self->bufsize; i++) {
chao = ch[i];
if (chao < 0.0)
@@ -7704,15 +7658,15 @@ Rossler_readframes_ia(Rossler *self) {
else if (chao > 1.0)
chao = 10.0;
else
- chao = chao * 7.0 + 3.0;
+ chao = chao * 7.0 + 3.0;
self->vDX = -self->vY - self->vZ;
self->vDY = self->vX + self->pA * self->vY;
self->vDZ = self->pB + self->vZ * (self->vX - chao);
-
+
self->vX += self->vDX * delta;
self->vY += self->vDY * delta;
self->vZ += self->vDZ * delta;
-
+
self->data[i] = self->vX * ROSSLER_SCALE;
self->altBuffer[i] = self->vY * ROSSLER_ALT_SCALE;
}
@@ -7722,7 +7676,7 @@ static void
Rossler_readframes_aa(Rossler *self) {
MYFLT delta, pit, chao;
int i;
-
+
MYFLT *fr = Stream_getData((Stream *)self->pitch_stream);
MYFLT *ch = Stream_getData((Stream *)self->chaos_stream);
@@ -7735,22 +7689,22 @@ Rossler_readframes_aa(Rossler *self) {
else
pit = pit * 999.0 + 1.0;
delta = self->scalePitch * pit;
-
+
chao = ch[i];
if (chao < 0.0)
chao = 3.0;
else if (chao > 1.0)
chao = 10.0;
else
- chao = chao * 7.0 + 3.0;
+ chao = chao * 7.0 + 3.0;
self->vDX = -self->vY - self->vZ;
self->vDY = self->vX + self->pA * self->vY;
self->vDZ = self->pB + self->vZ * (self->vX - chao);
-
+
self->vX += self->vDX * delta;
self->vY += self->vDY * delta;
self->vZ += self->vDZ * delta;
-
+
self->data[i] = self->vX * ROSSLER_SCALE;
self->altBuffer[i] = self->vY * ROSSLER_ALT_SCALE;
}
@@ -7772,48 +7726,48 @@ Rossler_setProcMode(Rossler *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Rossler_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Rossler_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Rossler_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Rossler_readframes_aa;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Rossler_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Rossler_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Rossler_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Rossler_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Rossler_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Rossler_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Rossler_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Rossler_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Rossler_postprocessing_revareva;
break;
}
@@ -7822,7 +7776,7 @@ Rossler_setProcMode(Rossler *self)
static void
Rossler_compute_next_data_frame(Rossler *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -7830,21 +7784,21 @@ static int
Rossler_traverse(Rossler *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->pitch);
- Py_VISIT(self->pitch_stream);
- Py_VISIT(self->chaos);
- Py_VISIT(self->chaos_stream);
+ Py_VISIT(self->pitch);
+ Py_VISIT(self->pitch_stream);
+ Py_VISIT(self->chaos);
+ Py_VISIT(self->chaos_stream);
return 0;
}
-static int
+static int
Rossler_clear(Rossler *self)
{
pyo_CLEAR
- Py_CLEAR(self->pitch);
- Py_CLEAR(self->pitch_stream);
- Py_CLEAR(self->chaos);
- Py_CLEAR(self->chaos_stream);
+ Py_CLEAR(self->pitch);
+ Py_CLEAR(self->pitch_stream);
+ Py_CLEAR(self->chaos);
+ Py_CLEAR(self->chaos_stream);
return 0;
}
@@ -7864,9 +7818,9 @@ Rossler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pitchtmp=NULL, *chaostmp=NULL, *multmp=NULL, *addtmp=NULL;
Rossler *self;
self = (Rossler *)type->tp_alloc(type, 0);
-
- self->pitch = PyFloat_FromDouble(0.25);
- self->chaos = PyFloat_FromDouble(0.5);
+
+ self->pitch = PyFloat_FromDouble(0.25);
+ self->chaos = PyFloat_FromDouble(0.5);
self->pA = 0.15;
self->pB = 0.20;
self->vDX = self->vDY = self->vDZ = 0.0;
@@ -7875,18 +7829,18 @@ Rossler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Rossler_compute_next_data_frame);
self->mode_func_ptr = Rossler_setProcMode;
-
+
self->scalePitch = 2.91 / self->sr;
static char *kwlist[] = {"pitch", "chaos", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &pitchtmp, &chaostmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (pitchtmp) {
PyObject_CallMethod((PyObject *)self, "setPitch", "O", pitchtmp);
}
@@ -7894,23 +7848,23 @@ Rossler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (chaostmp) {
PyObject_CallMethod((PyObject *)self, "setChaos", "O", chaostmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->altBuffer = (MYFLT *)realloc(self->altBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->altBuffer[i] = 0.0;
- }
-
+ }
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -7918,10 +7872,10 @@ Rossler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Rossler_getServer(Rossler* self) { GET_SERVER };
static PyObject * Rossler_getStream(Rossler* self) { GET_STREAM };
-static PyObject * Rossler_setMul(Rossler *self, PyObject *arg) { SET_MUL };
-static PyObject * Rossler_setAdd(Rossler *self, PyObject *arg) { SET_ADD };
-static PyObject * Rossler_setSub(Rossler *self, PyObject *arg) { SET_SUB };
-static PyObject * Rossler_setDiv(Rossler *self, PyObject *arg) { SET_DIV };
+static PyObject * Rossler_setMul(Rossler *self, PyObject *arg) { SET_MUL };
+static PyObject * Rossler_setAdd(Rossler *self, PyObject *arg) { SET_ADD };
+static PyObject * Rossler_setSub(Rossler *self, PyObject *arg) { SET_SUB };
+static PyObject * Rossler_setDiv(Rossler *self, PyObject *arg) { SET_DIV };
static PyObject * Rossler_play(Rossler *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Rossler_out(Rossler *self, PyObject *args, PyObject *kwds) { OUT };
@@ -7940,14 +7894,14 @@ static PyObject *
Rossler_setPitch(Rossler *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pitch);
@@ -7963,25 +7917,25 @@ Rossler_setPitch(Rossler *self, PyObject *arg)
self->pitch_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Rossler_setChaos(Rossler *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->chaos);
@@ -7997,18 +7951,18 @@ Rossler_setChaos(Rossler *self, PyObject *arg)
self->chaos_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
MYFLT *
Rossler_getAltBuffer(Rossler *self)
{
return (MYFLT *)self->altBuffer;
-}
+}
static PyMemberDef Rossler_members[] = {
{"server", T_OBJECT_EX, offsetof(Rossler, server), 0, "Pyo server."},
@@ -8139,36 +8093,36 @@ static void
RosslerAlt_setProcMode(RosslerAlt *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = RosslerAlt_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = RosslerAlt_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = RosslerAlt_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = RosslerAlt_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = RosslerAlt_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = RosslerAlt_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = RosslerAlt_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = RosslerAlt_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = RosslerAlt_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -8179,7 +8133,7 @@ RosslerAlt_compute_next_data_frame(RosslerAlt *self)
tmp = Rossler_getAltBuffer((Rossler *)self->mainRossler);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -8191,11 +8145,11 @@ RosslerAlt_traverse(RosslerAlt *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
RosslerAlt_clear(RosslerAlt *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainRossler);
+ Py_CLEAR(self->mainRossler);
return 0;
}
@@ -8214,19 +8168,19 @@ RosslerAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
RosslerAlt *self;
self = (RosslerAlt *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, RosslerAlt_compute_next_data_frame);
self->mode_func_ptr = RosslerAlt_setProcMode;
static char *kwlist[] = {"mainRossler", "mul", "alt", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &maintmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainRossler);
Py_INCREF(maintmp);
self->mainRossler = (Rossler *)maintmp;
@@ -8234,24 +8188,24 @@ RosslerAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * RosslerAlt_getServer(RosslerAlt* self) { GET_SERVER };
static PyObject * RosslerAlt_getStream(RosslerAlt* self) { GET_STREAM };
-static PyObject * RosslerAlt_setMul(RosslerAlt *self, PyObject *arg) { SET_MUL };
-static PyObject * RosslerAlt_setAdd(RosslerAlt *self, PyObject *arg) { SET_ADD };
-static PyObject * RosslerAlt_setSub(RosslerAlt *self, PyObject *arg) { SET_SUB };
-static PyObject * RosslerAlt_setDiv(RosslerAlt *self, PyObject *arg) { SET_DIV };
+static PyObject * RosslerAlt_setMul(RosslerAlt *self, PyObject *arg) { SET_MUL };
+static PyObject * RosslerAlt_setAdd(RosslerAlt *self, PyObject *arg) { SET_ADD };
+static PyObject * RosslerAlt_setSub(RosslerAlt *self, PyObject *arg) { SET_SUB };
+static PyObject * RosslerAlt_setDiv(RosslerAlt *self, PyObject *arg) { SET_DIV };
static PyObject * RosslerAlt_play(RosslerAlt *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * RosslerAlt_out(RosslerAlt *self, PyObject *args, PyObject *kwds) { OUT };
@@ -8283,7 +8237,7 @@ static PyMethodDef RosslerAlt_methods[] = {
{"setMul", (PyCFunction)RosslerAlt_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)RosslerAlt_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)RosslerAlt_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)RosslerAlt_setDiv, METH_O, "Sets inverse mul factor."},
+ {"setDiv", (PyCFunction)RosslerAlt_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
static PyNumberMethods RosslerAlt_as_number = {
@@ -8394,7 +8348,7 @@ static void
Lorenz_readframes_ii(Lorenz *self) {
MYFLT delta, pit, chao;
int i;
-
+
pit = PyFloat_AS_DOUBLE(self->pitch);
chao = PyFloat_AS_DOUBLE(self->chaos);
if (pit < 0.0)
@@ -8404,23 +8358,23 @@ Lorenz_readframes_ii(Lorenz *self) {
else
pit = pit * 749.0 + 1.0;
delta = self->oneOnSr * pit;
-
+
if (chao < 0.0)
chao = 0.5;
else if (chao > 1.0)
chao = 3.0;
else
chao = chao * 2.5 + 0.5;
-
+
for (i=0; i<self->bufsize; i++) {
self->vDX = self->pA * (self->vY - self->vX);
self->vDY = self->vX * (self->pB - self->vZ) - self->vY;
self->vDZ = self->vX * self->vY - chao * self->vZ;
-
+
self->vX += self->vDX * delta;
self->vY += self->vDY * delta;
self->vZ += self->vDZ * delta;
-
+
self->data[i] = self->vX * LORENZ_SCALE;
self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
}
@@ -8430,7 +8384,7 @@ static void
Lorenz_readframes_ai(Lorenz *self) {
MYFLT delta, pit, chao;
int i;
-
+
MYFLT *fr = Stream_getData((Stream *)self->pitch_stream);
chao = PyFloat_AS_DOUBLE(self->chaos);
if (chao < 0.0)
@@ -8439,7 +8393,7 @@ Lorenz_readframes_ai(Lorenz *self) {
chao = 3.0;
else
chao = chao * 2.5 + 0.5;
-
+
for (i=0; i<self->bufsize; i++) {
pit = fr[i];
if (pit < 0.0)
@@ -8452,11 +8406,11 @@ Lorenz_readframes_ai(Lorenz *self) {
self->vDX = self->pA * (self->vY - self->vX);
self->vDY = self->vX * (self->pB - self->vZ) - self->vY;
self->vDZ = self->vX * self->vY - chao * self->vZ;
-
+
self->vX += self->vDX * delta;
self->vY += self->vDY * delta;
self->vZ += self->vDZ * delta;
-
+
self->data[i] = self->vX * LORENZ_SCALE;
self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
}
@@ -8466,10 +8420,10 @@ static void
Lorenz_readframes_ia(Lorenz *self) {
MYFLT delta, pit, chao;
int i;
-
+
pit = PyFloat_AS_DOUBLE(self->pitch);
MYFLT *ch = Stream_getData((Stream *)self->chaos_stream);
-
+
if (pit < 0.0)
pit = 1.0;
else if (pit > 1.0)
@@ -8477,7 +8431,7 @@ Lorenz_readframes_ia(Lorenz *self) {
else
pit = pit * 749.0 + 1.0;
delta = self->oneOnSr * pit;
-
+
for (i=0; i<self->bufsize; i++) {
chao = ch[i];
if (chao < 0.0)
@@ -8485,15 +8439,15 @@ Lorenz_readframes_ia(Lorenz *self) {
else if (chao > 1.0)
chao = 3.0;
else
- chao = chao * 2.5 + 0.5;
+ chao = chao * 2.5 + 0.5;
self->vDX = self->pA * (self->vY - self->vX);
self->vDY = self->vX * (self->pB - self->vZ) - self->vY;
self->vDZ = self->vX * self->vY - chao * self->vZ;
-
+
self->vX += self->vDX * delta;
self->vY += self->vDY * delta;
self->vZ += self->vDZ * delta;
-
+
self->data[i] = self->vX * LORENZ_SCALE;
self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
}
@@ -8503,10 +8457,10 @@ static void
Lorenz_readframes_aa(Lorenz *self) {
MYFLT delta, pit, chao;
int i;
-
+
MYFLT *fr = Stream_getData((Stream *)self->pitch_stream);
MYFLT *ch = Stream_getData((Stream *)self->chaos_stream);
-
+
for (i=0; i<self->bufsize; i++) {
pit = fr[i];
if (pit < 0.0)
@@ -8516,22 +8470,22 @@ Lorenz_readframes_aa(Lorenz *self) {
else
pit = pit * 749.0 + 1.0;
delta = self->oneOnSr * pit;
-
+
chao = ch[i];
if (chao < 0.0)
chao = 0.5;
else if (chao > 1.0)
chao = 3.0;
else
- chao = chao * 2.5 + 0.5;
+ chao = chao * 2.5 + 0.5;
self->vDX = self->pA * (self->vY - self->vX);
self->vDY = self->vX * (self->pB - self->vZ) - self->vY;
self->vDZ = self->vX * self->vY - chao * self->vZ;
-
+
self->vX += self->vDX * delta;
self->vY += self->vDY * delta;
self->vZ += self->vDZ * delta;
-
+
self->data[i] = self->vX * LORENZ_SCALE;
self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
}
@@ -8553,48 +8507,48 @@ Lorenz_setProcMode(Lorenz *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Lorenz_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Lorenz_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Lorenz_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Lorenz_readframes_aa;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Lorenz_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Lorenz_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Lorenz_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Lorenz_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Lorenz_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Lorenz_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Lorenz_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Lorenz_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Lorenz_postprocessing_revareva;
break;
}
@@ -8603,7 +8557,7 @@ Lorenz_setProcMode(Lorenz *self)
static void
Lorenz_compute_next_data_frame(Lorenz *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -8611,21 +8565,21 @@ static int
Lorenz_traverse(Lorenz *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->pitch);
- Py_VISIT(self->pitch_stream);
- Py_VISIT(self->chaos);
- Py_VISIT(self->chaos_stream);
+ Py_VISIT(self->pitch);
+ Py_VISIT(self->pitch_stream);
+ Py_VISIT(self->chaos);
+ Py_VISIT(self->chaos_stream);
return 0;
}
-static int
+static int
Lorenz_clear(Lorenz *self)
{
pyo_CLEAR
- Py_CLEAR(self->pitch);
- Py_CLEAR(self->pitch_stream);
- Py_CLEAR(self->chaos);
- Py_CLEAR(self->chaos_stream);
+ Py_CLEAR(self->pitch);
+ Py_CLEAR(self->pitch_stream);
+ Py_CLEAR(self->chaos);
+ Py_CLEAR(self->chaos_stream);
return 0;
}
@@ -8645,9 +8599,9 @@ Lorenz_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pitchtmp=NULL, *chaostmp=NULL, *multmp=NULL, *addtmp=NULL;
Lorenz *self;
self = (Lorenz *)type->tp_alloc(type, 0);
-
- self->pitch = PyFloat_FromDouble(0.25);
- self->chaos = PyFloat_FromDouble(0.5);
+
+ self->pitch = PyFloat_FromDouble(0.25);
+ self->chaos = PyFloat_FromDouble(0.5);
self->pA = 10.0;
self->pB = 28.0;
self->vDX = self->vDY = self->vDZ = 0.0;
@@ -8656,53 +8610,53 @@ Lorenz_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Lorenz_compute_next_data_frame);
self->mode_func_ptr = Lorenz_setProcMode;
-
+
self->oneOnSr = 1.0 / self->sr;
-
+
static char *kwlist[] = {"pitch", "chaos", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &pitchtmp, &chaostmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (pitchtmp) {
PyObject_CallMethod((PyObject *)self, "setPitch", "O", pitchtmp);
}
-
+
if (chaostmp) {
PyObject_CallMethod((PyObject *)self, "setChaos", "O", chaostmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->altBuffer = (MYFLT *)realloc(self->altBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->altBuffer[i] = 0.0;
- }
-
+ }
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Lorenz_getServer(Lorenz* self) { GET_SERVER };
static PyObject * Lorenz_getStream(Lorenz* self) { GET_STREAM };
-static PyObject * Lorenz_setMul(Lorenz *self, PyObject *arg) { SET_MUL };
-static PyObject * Lorenz_setAdd(Lorenz *self, PyObject *arg) { SET_ADD };
-static PyObject * Lorenz_setSub(Lorenz *self, PyObject *arg) { SET_SUB };
-static PyObject * Lorenz_setDiv(Lorenz *self, PyObject *arg) { SET_DIV };
+static PyObject * Lorenz_setMul(Lorenz *self, PyObject *arg) { SET_MUL };
+static PyObject * Lorenz_setAdd(Lorenz *self, PyObject *arg) { SET_ADD };
+static PyObject * Lorenz_setSub(Lorenz *self, PyObject *arg) { SET_SUB };
+static PyObject * Lorenz_setDiv(Lorenz *self, PyObject *arg) { SET_DIV };
static PyObject * Lorenz_play(Lorenz *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Lorenz_out(Lorenz *self, PyObject *args, PyObject *kwds) { OUT };
@@ -8721,14 +8675,14 @@ static PyObject *
Lorenz_setPitch(Lorenz *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pitch);
@@ -8744,25 +8698,25 @@ Lorenz_setPitch(Lorenz *self, PyObject *arg)
self->pitch_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Lorenz_setChaos(Lorenz *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->chaos);
@@ -8778,18 +8732,18 @@ Lorenz_setChaos(Lorenz *self, PyObject *arg)
self->chaos_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
MYFLT *
Lorenz_getAltBuffer(Lorenz *self)
{
return (MYFLT *)self->altBuffer;
-}
+}
static PyMemberDef Lorenz_members[] = {
{"server", T_OBJECT_EX, offsetof(Lorenz, server), 0, "Pyo server."},
@@ -8920,36 +8874,36 @@ static void
LorenzAlt_setProcMode(LorenzAlt *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = LorenzAlt_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = LorenzAlt_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = LorenzAlt_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = LorenzAlt_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = LorenzAlt_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = LorenzAlt_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = LorenzAlt_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = LorenzAlt_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = LorenzAlt_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -8960,7 +8914,7 @@ LorenzAlt_compute_next_data_frame(LorenzAlt *self)
tmp = Lorenz_getAltBuffer((Lorenz *)self->mainLorenz);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -8972,11 +8926,11 @@ LorenzAlt_traverse(LorenzAlt *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
LorenzAlt_clear(LorenzAlt *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainLorenz);
+ Py_CLEAR(self->mainLorenz);
return 0;
}
@@ -8995,44 +8949,44 @@ LorenzAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
LorenzAlt *self;
self = (LorenzAlt *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, LorenzAlt_compute_next_data_frame);
self->mode_func_ptr = LorenzAlt_setProcMode;
static char *kwlist[] = {"mainLorenz", "mul", "alt", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &maintmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainLorenz);
Py_INCREF(maintmp);
self->mainLorenz = (Lorenz *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * LorenzAlt_getServer(LorenzAlt* self) { GET_SERVER };
static PyObject * LorenzAlt_getStream(LorenzAlt* self) { GET_STREAM };
-static PyObject * LorenzAlt_setMul(LorenzAlt *self, PyObject *arg) { SET_MUL };
-static PyObject * LorenzAlt_setAdd(LorenzAlt *self, PyObject *arg) { SET_ADD };
-static PyObject * LorenzAlt_setSub(LorenzAlt *self, PyObject *arg) { SET_SUB };
-static PyObject * LorenzAlt_setDiv(LorenzAlt *self, PyObject *arg) { SET_DIV };
+static PyObject * LorenzAlt_setMul(LorenzAlt *self, PyObject *arg) { SET_MUL };
+static PyObject * LorenzAlt_setAdd(LorenzAlt *self, PyObject *arg) { SET_ADD };
+static PyObject * LorenzAlt_setSub(LorenzAlt *self, PyObject *arg) { SET_SUB };
+static PyObject * LorenzAlt_setDiv(LorenzAlt *self, PyObject *arg) { SET_DIV };
static PyObject * LorenzAlt_play(LorenzAlt *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * LorenzAlt_out(LorenzAlt *self, PyObject *args, PyObject *kwds) { OUT };
@@ -9064,7 +9018,7 @@ static PyMethodDef LorenzAlt_methods[] = {
{"setMul", (PyCFunction)LorenzAlt_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)LorenzAlt_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)LorenzAlt_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)LorenzAlt_setDiv, METH_O, "Sets inverse mul factor."},
+ {"setDiv", (PyCFunction)LorenzAlt_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
static PyNumberMethods LorenzAlt_as_number = {
@@ -9174,11 +9128,11 @@ static void
SumOsc_readframes_iii(SumOsc *self) {
MYFLT mod_freq, mod_delta, freq_delta, x, y, ind2, theta_minus_beta, sin1, sin2, cos1;
int i, ipart;
-
+
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
MYFLT ind = PyFloat_AS_DOUBLE(self->index);
-
+
freq_delta = freq * self->scaleFactor;
mod_freq = freq * rat;
mod_delta = mod_freq * self->scaleFactor;
@@ -9201,7 +9155,7 @@ SumOsc_readframes_iii(SumOsc *self) {
self->beta += mod_delta;
self->theta = Sine_clip(self->theta);
self->beta = Sine_clip(self->beta);
-
+
/* DC filtering */
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x; self->yn1 = y;
@@ -9214,7 +9168,7 @@ static void
SumOsc_readframes_aii(SumOsc *self) {
MYFLT freq, mod_freq, mod_delta, freq_delta, x, y, ind2, theta_minus_beta, sin1, sin2, cos1;
int i, ipart;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
MYFLT ind = PyFloat_AS_DOUBLE(self->index);
@@ -9242,7 +9196,7 @@ SumOsc_readframes_aii(SumOsc *self) {
self->beta += mod_delta;
self->theta = Sine_clip(self->theta);
self->beta = Sine_clip(self->beta);
-
+
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x; self->yn1 = y;
@@ -9254,7 +9208,7 @@ static void
SumOsc_readframes_iai(SumOsc *self) {
MYFLT ratio, mod_freq, mod_delta, freq_delta, x, y, ind2, theta_minus_beta, sin1, sin2, cos1;
int i, ipart;
-
+
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
MYFLT ind = PyFloat_AS_DOUBLE(self->index);
@@ -9282,7 +9236,7 @@ SumOsc_readframes_iai(SumOsc *self) {
self->beta += mod_delta;
self->theta = Sine_clip(self->theta);
self->beta = Sine_clip(self->beta);
-
+
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x; self->yn1 = y;
@@ -9294,7 +9248,7 @@ static void
SumOsc_readframes_aai(SumOsc *self) {
MYFLT freq, ratio, mod_freq, mod_delta, freq_delta, x, y, ind2, theta_minus_beta, sin1, sin2, cos1;
int i, ipart;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
MYFLT ind = PyFloat_AS_DOUBLE(self->index);
@@ -9323,7 +9277,7 @@ SumOsc_readframes_aai(SumOsc *self) {
self->beta += mod_delta;
self->theta = Sine_clip(self->theta);
self->beta = Sine_clip(self->beta);
-
+
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x; self->yn1 = y;
@@ -9335,7 +9289,7 @@ static void
SumOsc_readframes_iia(SumOsc *self) {
MYFLT ind, mod_freq, mod_delta, freq_delta, x, y, ind2, theta_minus_beta, sin1, sin2, cos1;
int i, ipart;
-
+
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
MYFLT *index = Stream_getData((Stream *)self->index_stream);
@@ -9363,19 +9317,19 @@ SumOsc_readframes_iia(SumOsc *self) {
self->beta += mod_delta;
self->theta = Sine_clip(self->theta);
self->beta = Sine_clip(self->beta);
-
+
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x; self->yn1 = y;
self->data[i] = y * (1 - ind2);
- }
+ }
}
static void
SumOsc_readframes_aia(SumOsc *self) {
MYFLT freq, ind, mod_freq, mod_delta, freq_delta, x, y, ind2, theta_minus_beta, sin1, sin2, cos1;
int i, ipart;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
MYFLT *index = Stream_getData((Stream *)self->index_stream);
@@ -9403,19 +9357,19 @@ SumOsc_readframes_aia(SumOsc *self) {
self->beta += mod_delta;
self->theta = Sine_clip(self->theta);
self->beta = Sine_clip(self->beta);
-
+
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x; self->yn1 = y;
self->data[i] = y * (1 - ind2);
- }
+ }
}
static void
SumOsc_readframes_iaa(SumOsc *self) {
MYFLT ratio, ind, mod_freq, mod_delta, freq_delta, x, y, ind2, theta_minus_beta, sin1, sin2, cos1;
int i, ipart;
-
+
MYFLT freq = PyFloat_AS_DOUBLE(self->freq);
MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
MYFLT *index = Stream_getData((Stream *)self->index_stream);
@@ -9444,19 +9398,19 @@ SumOsc_readframes_iaa(SumOsc *self) {
self->beta += mod_delta;
self->theta = Sine_clip(self->theta);
self->beta = Sine_clip(self->beta);
-
+
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x; self->yn1 = y;
self->data[i] = y * (1 - ind2);
- }
+ }
}
static void
SumOsc_readframes_aaa(SumOsc *self) {
MYFLT freq, ratio, ind, mod_freq, mod_delta, freq_delta, x, y, ind2, theta_minus_beta, sin1, sin2, cos1;
int i, ipart;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
MYFLT *index = Stream_getData((Stream *)self->index_stream);
@@ -9485,12 +9439,12 @@ SumOsc_readframes_aaa(SumOsc *self) {
self->beta += mod_delta;
self->theta = Sine_clip(self->theta);
self->beta = Sine_clip(self->beta);
-
+
y = x - self->xn1 + 0.995 * self->yn1;
self->xn1 = x; self->yn1 = y;
self->data[i] = y * (1 - ind2);
- }
+ }
}
static void SumOsc_postprocessing_ii(SumOsc *self) { POST_PROCESSING_II };
@@ -9509,60 +9463,60 @@ SumOsc_setProcMode(SumOsc *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = SumOsc_readframes_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = SumOsc_readframes_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = SumOsc_readframes_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = SumOsc_readframes_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = SumOsc_readframes_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = SumOsc_readframes_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = SumOsc_readframes_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = SumOsc_readframes_aaa;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SumOsc_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SumOsc_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SumOsc_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SumOsc_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SumOsc_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SumOsc_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SumOsc_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SumOsc_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SumOsc_postprocessing_revareva;
break;
}
@@ -9571,7 +9525,7 @@ SumOsc_setProcMode(SumOsc *self)
static void
SumOsc_compute_next_data_frame(SumOsc *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -9579,25 +9533,25 @@ static int
SumOsc_traverse(SumOsc *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->ratio);
- Py_VISIT(self->ratio_stream);
- Py_VISIT(self->index);
- Py_VISIT(self->index_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->ratio);
+ Py_VISIT(self->ratio_stream);
+ Py_VISIT(self->index);
+ Py_VISIT(self->index_stream);
return 0;
}
-static int
+static int
SumOsc_clear(SumOsc *self)
{
pyo_CLEAR
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->ratio);
- Py_CLEAR(self->ratio_stream);
- Py_CLEAR(self->index);
- Py_CLEAR(self->index_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->ratio);
+ Py_CLEAR(self->ratio_stream);
+ Py_CLEAR(self->index);
+ Py_CLEAR(self->index_stream);
return 0;
}
@@ -9616,7 +9570,7 @@ SumOsc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *ratiotmp=NULL, *indextmp=NULL, *multmp=NULL, *addtmp=NULL;
SumOsc *self;
self = (SumOsc *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100);
self->ratio = PyFloat_FromDouble(0.5);
self->index = PyFloat_FromDouble(0.5);
@@ -9627,7 +9581,7 @@ SumOsc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[4] = 0;
self->theta = self->beta = 0.;
self->xn1 = self->yn1 = 0.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SumOsc_compute_next_data_frame);
self->mode_func_ptr = SumOsc_setProcMode;
@@ -9635,14 +9589,14 @@ SumOsc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->scaleFactor = 512.0 / self->sr;
static char *kwlist[] = {"freq", "ratio", "index", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", kwlist, &freqtmp, &ratiotmp, &indextmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (ratiotmp) {
PyObject_CallMethod((PyObject *)self, "setRatio", "O", ratiotmp);
}
@@ -9650,17 +9604,17 @@ SumOsc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (indextmp) {
PyObject_CallMethod((PyObject *)self, "setIndex", "O", indextmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -9668,10 +9622,10 @@ SumOsc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * SumOsc_getServer(SumOsc* self) { GET_SERVER };
static PyObject * SumOsc_getStream(SumOsc* self) { GET_STREAM };
-static PyObject * SumOsc_setMul(SumOsc *self, PyObject *arg) { SET_MUL };
-static PyObject * SumOsc_setAdd(SumOsc *self, PyObject *arg) { SET_ADD };
-static PyObject * SumOsc_setSub(SumOsc *self, PyObject *arg) { SET_SUB };
-static PyObject * SumOsc_setDiv(SumOsc *self, PyObject *arg) { SET_DIV };
+static PyObject * SumOsc_setMul(SumOsc *self, PyObject *arg) { SET_MUL };
+static PyObject * SumOsc_setAdd(SumOsc *self, PyObject *arg) { SET_ADD };
+static PyObject * SumOsc_setSub(SumOsc *self, PyObject *arg) { SET_SUB };
+static PyObject * SumOsc_setDiv(SumOsc *self, PyObject *arg) { SET_DIV };
static PyObject * SumOsc_play(SumOsc *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SumOsc_out(SumOsc *self, PyObject *args, PyObject *kwds) { OUT };
@@ -9690,14 +9644,14 @@ static PyObject *
SumOsc_setFreq(SumOsc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -9713,25 +9667,25 @@ SumOsc_setFreq(SumOsc *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SumOsc_setRatio(SumOsc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->ratio);
@@ -9747,25 +9701,25 @@ SumOsc_setRatio(SumOsc *self, PyObject *arg)
self->ratio_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SumOsc_setIndex(SumOsc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->index);
@@ -9781,12 +9735,12 @@ SumOsc_setIndex(SumOsc *self, PyObject *arg)
self->index_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef SumOsc_members[] = {
{"server", T_OBJECT_EX, offsetof(SumOsc, server), 0, "Pyo server."},
@@ -9964,12 +9918,12 @@ SuperSaw_readframes_iii(SuperSaw *self) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
+ fr = self->nyquist;
det_ind = (int)(det * 126);
bal_ind = (int)(bal * 126);
-
- if (fr != self->lastFilterFreq) {
+
+ if (fr != self->lastFilterFreq) {
self->lastFilterFreq = fr;
self->w0 = TWOPI * fr / self->sr;
self->c = MYCOS(self->w0);
@@ -10023,8 +9977,8 @@ SuperSaw_readframes_aii(SuperSaw *self) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
- if (fr != self->lastFilterFreq) {
+ fr = self->nyquist;
+ if (fr != self->lastFilterFreq) {
self->lastFilterFreq = fr;
self->w0 = TWOPI * fr / self->sr;
self->c = MYCOS(self->w0);
@@ -10066,11 +10020,11 @@ SuperSaw_readframes_iai(SuperSaw *self) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
+ fr = self->nyquist;
bal_ind = (int)(bal * 126);
-
- if (fr != self->lastFilterFreq) {
+
+ if (fr != self->lastFilterFreq) {
self->lastFilterFreq = fr;
self->w0 = TWOPI * fr / self->sr;
self->c = MYCOS(self->w0);
@@ -10119,8 +10073,8 @@ SuperSaw_readframes_aai(SuperSaw *self) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
- if (fr != self->lastFilterFreq) {
+ fr = self->nyquist;
+ if (fr != self->lastFilterFreq) {
self->lastFilterFreq = fr;
self->w0 = TWOPI * fr / self->sr;
self->c = MYCOS(self->w0);
@@ -10164,11 +10118,11 @@ SuperSaw_readframes_iia(SuperSaw *self) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
+ fr = self->nyquist;
det_ind = (int)(det * 126);
-
- if (fr != self->lastFilterFreq) {
+
+ if (fr != self->lastFilterFreq) {
self->lastFilterFreq = fr;
self->w0 = TWOPI * fr / self->sr;
self->c = MYCOS(self->w0);
@@ -10221,8 +10175,8 @@ SuperSaw_readframes_aia(SuperSaw *self) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
- if (fr != self->lastFilterFreq) {
+ fr = self->nyquist;
+ if (fr != self->lastFilterFreq) {
self->lastFilterFreq = fr;
self->w0 = TWOPI * fr / self->sr;
self->c = MYCOS(self->w0);
@@ -10265,9 +10219,9 @@ SuperSaw_readframes_iaa(SuperSaw *self) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
-
- if (fr != self->lastFilterFreq) {
+ fr = self->nyquist;
+
+ if (fr != self->lastFilterFreq) {
self->lastFilterFreq = fr;
self->w0 = TWOPI * fr / self->sr;
self->c = MYCOS(self->w0);
@@ -10315,8 +10269,8 @@ SuperSaw_readframes_aaa(SuperSaw *self) {
if (fr <= 1.0)
fr = 1.0;
else if (fr >= self->nyquist)
- fr = self->nyquist;
- if (fr != self->lastFilterFreq) {
+ fr = self->nyquist;
+ if (fr != self->lastFilterFreq) {
self->lastFilterFreq = fr;
self->w0 = TWOPI * fr / self->sr;
self->c = MYCOS(self->w0);
@@ -10364,68 +10318,68 @@ SuperSaw_setProcMode(SuperSaw *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = SuperSaw_readframes_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = SuperSaw_readframes_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = SuperSaw_readframes_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = SuperSaw_readframes_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = SuperSaw_readframes_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = SuperSaw_readframes_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = SuperSaw_readframes_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = SuperSaw_readframes_aaa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SuperSaw_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SuperSaw_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SuperSaw_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SuperSaw_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SuperSaw_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SuperSaw_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SuperSaw_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SuperSaw_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SuperSaw_postprocessing_revareva;
break;
- }
+ }
}
static void
SuperSaw_compute_next_data_frame(SuperSaw *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -10433,25 +10387,25 @@ static int
SuperSaw_traverse(SuperSaw *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
- Py_VISIT(self->detune);
- Py_VISIT(self->detune_stream);
- Py_VISIT(self->bal);
- Py_VISIT(self->bal_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->detune);
+ Py_VISIT(self->detune_stream);
+ Py_VISIT(self->bal);
+ Py_VISIT(self->bal_stream);
return 0;
}
-static int
+static int
SuperSaw_clear(SuperSaw *self)
{
pyo_CLEAR
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->detune);
- Py_CLEAR(self->detune_stream);
- Py_CLEAR(self->bal);
- Py_CLEAR(self->bal_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->detune);
+ Py_CLEAR(self->detune_stream);
+ Py_CLEAR(self->bal);
+ Py_CLEAR(self->bal_stream);
return 0;
}
@@ -10470,7 +10424,7 @@ SuperSaw_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *detunetmp=NULL, *baltmp=NULL, *multmp=NULL, *addtmp=NULL;
SuperSaw *self;
self = (SuperSaw *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100);
self->detune = PyFloat_FromDouble(0.5);
self->bal = PyFloat_FromDouble(0.7);
@@ -10488,7 +10442,7 @@ SuperSaw_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->pointerPos[6] = 0.75;
self->lastFilterFreq = -1.0;
self->x1 = self->x2 = self->y1 = self->y2 = 0.0;
-
+
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
@@ -10497,10 +10451,10 @@ SuperSaw_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = SuperSaw_setProcMode;
static char *kwlist[] = {"freq", "detune", "bal", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", kwlist, &freqtmp, &detunetmp, &baltmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -10512,28 +10466,28 @@ SuperSaw_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (baltmp) {
PyObject_CallMethod((PyObject *)self, "setBal", "O", baltmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * SuperSaw_getServer(SuperSaw* self) { GET_SERVER };
static PyObject * SuperSaw_getStream(SuperSaw* self) { GET_STREAM };
-static PyObject * SuperSaw_setMul(SuperSaw *self, PyObject *arg) { SET_MUL };
-static PyObject * SuperSaw_setAdd(SuperSaw *self, PyObject *arg) { SET_ADD };
-static PyObject * SuperSaw_setSub(SuperSaw *self, PyObject *arg) { SET_SUB };
-static PyObject * SuperSaw_setDiv(SuperSaw *self, PyObject *arg) { SET_DIV };
+static PyObject * SuperSaw_setMul(SuperSaw *self, PyObject *arg) { SET_MUL };
+static PyObject * SuperSaw_setAdd(SuperSaw *self, PyObject *arg) { SET_ADD };
+static PyObject * SuperSaw_setSub(SuperSaw *self, PyObject *arg) { SET_SUB };
+static PyObject * SuperSaw_setDiv(SuperSaw *self, PyObject *arg) { SET_DIV };
static PyObject * SuperSaw_play(SuperSaw *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SuperSaw_out(SuperSaw *self, PyObject *args, PyObject *kwds) { OUT };
@@ -10552,14 +10506,14 @@ static PyObject *
SuperSaw_setFreq(SuperSaw *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -10575,25 +10529,25 @@ SuperSaw_setFreq(SuperSaw *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SuperSaw_setDetune(SuperSaw *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->detune);
@@ -10609,25 +10563,25 @@ SuperSaw_setDetune(SuperSaw *self, PyObject *arg)
self->detune_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SuperSaw_setBal(SuperSaw *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->bal);
@@ -10643,12 +10597,12 @@ SuperSaw_setBal(SuperSaw *self, PyObject *arg)
self->bal_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef SuperSaw_members[] = {
{"server", T_OBJECT_EX, offsetof(SuperSaw, server), 0, "Pyo server."},
@@ -10778,12 +10732,12 @@ static void
RCOsc_readframes_ii(RCOsc *self) {
MYFLT fr, sh, inc, down_phase, up_phase;
int i;
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
sh = _clip(PyFloat_AS_DOUBLE(self->sharp));
sh = sh * sh * 99.0 + 1.0;
inc = fr * 2 / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
if (self->pointerPos < 1) {
down_phase = 1.0 - self->pointerPos;
@@ -10806,11 +10760,11 @@ static void
RCOsc_readframes_ai(RCOsc *self) {
MYFLT sh, down_phase, up_phase, twoOverSr;
int i;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
sh = _clip(PyFloat_AS_DOUBLE(self->sharp));
sh = sh * sh * 99.0 + 1.0;
-
+
twoOverSr = 2.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
if (self->pointerPos < 1) {
@@ -10834,14 +10788,14 @@ static void
RCOsc_readframes_ia(RCOsc *self) {
MYFLT fr, sh, inc, down_phase, up_phase;
int i;
-
+
fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT *sharp = Stream_getData((Stream *)self->sharp_stream);
inc = fr * 2 / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
sh = _clip(sharp[i]);
- sh = sh * sh * 99.0 + 1.0;
+ sh = sh * sh * 99.0 + 1.0;
if (self->pointerPos < 1) {
down_phase = 1.0 - self->pointerPos;
up_phase = 1.0;
@@ -10863,14 +10817,14 @@ static void
RCOsc_readframes_aa(RCOsc *self) {
MYFLT sh, down_phase, up_phase, twoOverSr;
int i;
-
+
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT *sharp = Stream_getData((Stream *)self->sharp_stream);
-
+
twoOverSr = 2.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
sh = _clip(sharp[i]);
- sh = sh * sh * 99.0 + 1.0;
+ sh = sh * sh * 99.0 + 1.0;
if (self->pointerPos < 1) {
down_phase = 1.0 - self->pointerPos;
up_phase = 1.0;
@@ -10904,56 +10858,56 @@ RCOsc_setProcMode(RCOsc *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = RCOsc_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = RCOsc_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = RCOsc_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = RCOsc_readframes_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = RCOsc_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = RCOsc_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = RCOsc_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = RCOsc_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = RCOsc_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = RCOsc_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = RCOsc_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = RCOsc_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = RCOsc_postprocessing_revareva;
break;
- }
+ }
}
static void
RCOsc_compute_next_data_frame(RCOsc *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -10961,21 +10915,21 @@ static int
RCOsc_traverse(RCOsc *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->sharp);
- Py_VISIT(self->sharp_stream);
- Py_VISIT(self->freq);
- Py_VISIT(self->freq_stream);
+ Py_VISIT(self->sharp);
+ Py_VISIT(self->sharp_stream);
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
return 0;
}
-static int
+static int
RCOsc_clear(RCOsc *self)
{
pyo_CLEAR
- Py_CLEAR(self->sharp);
- Py_CLEAR(self->sharp_stream);
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->sharp);
+ Py_CLEAR(self->sharp_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
return 0;
}
@@ -10994,7 +10948,7 @@ RCOsc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *sharptmp=NULL, *multmp=NULL, *addtmp=NULL;
RCOsc *self;
self = (RCOsc *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(100);
self->sharp = PyFloat_FromDouble(0.25);
self->modebuffer[0] = 0;
@@ -11002,16 +10956,16 @@ RCOsc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->pointerPos = 0.;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, RCOsc_compute_next_data_frame);
self->mode_func_ptr = RCOsc_setProcMode;
static char *kwlist[] = {"freq", "sharp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &sharptmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -11019,28 +10973,28 @@ RCOsc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (sharptmp) {
PyObject_CallMethod((PyObject *)self, "setSharp", "O", sharptmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * RCOsc_getServer(RCOsc* self) { GET_SERVER };
static PyObject * RCOsc_getStream(RCOsc* self) { GET_STREAM };
-static PyObject * RCOsc_setMul(RCOsc *self, PyObject *arg) { SET_MUL };
-static PyObject * RCOsc_setAdd(RCOsc *self, PyObject *arg) { SET_ADD };
-static PyObject * RCOsc_setSub(RCOsc *self, PyObject *arg) { SET_SUB };
-static PyObject * RCOsc_setDiv(RCOsc *self, PyObject *arg) { SET_DIV };
+static PyObject * RCOsc_setMul(RCOsc *self, PyObject *arg) { SET_MUL };
+static PyObject * RCOsc_setAdd(RCOsc *self, PyObject *arg) { SET_ADD };
+static PyObject * RCOsc_setSub(RCOsc *self, PyObject *arg) { SET_SUB };
+static PyObject * RCOsc_setDiv(RCOsc *self, PyObject *arg) { SET_DIV };
static PyObject * RCOsc_play(RCOsc *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * RCOsc_out(RCOsc *self, PyObject *args, PyObject *kwds) { OUT };
@@ -11059,14 +11013,14 @@ static PyObject *
RCOsc_setFreq(RCOsc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -11082,25 +11036,25 @@ RCOsc_setFreq(RCOsc *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
RCOsc_setSharp(RCOsc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->sharp);
@@ -11116,15 +11070,15 @@ RCOsc_setSharp(RCOsc *self, PyObject *arg)
self->sharp_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
-static PyObject *
-RCOsc_reset(RCOsc *self)
+static PyObject *
+RCOsc_reset(RCOsc *self)
{
self->pointerPos = 0.0;
Py_INCREF(Py_None);
@@ -11262,7 +11216,7 @@ TableScale_readframes_ii(TableScale *self) {
mul = PyFloat_AS_DOUBLE(self->mul);
add = PyFloat_AS_DOUBLE(self->add);
-
+
num = size < osize ? size : osize;
for (i=0; i<num; i++) {
outlist[i] = tablelist[i] * mul + add;
@@ -11280,7 +11234,7 @@ TableScale_readframes_ai(TableScale *self) {
MYFLT *mul = Stream_getData((Stream *)self->mul_stream);
add = PyFloat_AS_DOUBLE(self->add);
-
+
num = size < osize ? size : osize;
for (i=0; i<num; i++) {
outlist[i] = tablelist[i] * mul[i] + add;
@@ -11298,7 +11252,7 @@ TableScale_readframes_ia(TableScale *self) {
mul = PyFloat_AS_DOUBLE(self->mul);
MYFLT *add = Stream_getData((Stream *)self->add_stream);
-
+
num = size < osize ? size : osize;
for (i=0; i<num; i++) {
outlist[i] = tablelist[i] * mul + add[i];
@@ -11315,7 +11269,7 @@ TableScale_readframes_aa(TableScale *self) {
MYFLT *mul = Stream_getData((Stream *)self->mul_stream);
MYFLT *add = Stream_getData((Stream *)self->add_stream);
-
+
num = size < osize ? size : osize;
for (i=0; i<num; i++) {
outlist[i] = tablelist[i] * mul[i] + add[i];
@@ -11329,25 +11283,25 @@ TableScale_setProcMode(TableScale *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (muladdmode) {
- case 0:
+ case 0:
self->proc_func_ptr = TableScale_readframes_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = TableScale_readframes_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = TableScale_readframes_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = TableScale_readframes_aa;
break;
- }
+ }
}
static void
TableScale_compute_next_data_frame(TableScale *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -11359,7 +11313,7 @@ TableScale_traverse(TableScale *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
TableScale_clear(TableScale *self)
{
pyo_CLEAR
@@ -11383,35 +11337,29 @@ TableScale_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *tabletmp, *outtabletmp, *multmp=NULL, *addtmp=NULL;
TableScale *self;
self = (TableScale *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TableScale_compute_next_data_frame);
self->mode_func_ptr = TableScale_setProcMode;
static char *kwlist[] = {"table", "outtable", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &tabletmp, &outtabletmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of TableScale must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TableScale must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
+
if ( PyObject_HasAttrString((PyObject *)outtabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"outtable\" argument of TableScale must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"outtable\" argument of TableScale must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->outtable);
self->outtable = PyObject_CallMethod((PyObject *)outtabletmp, "getTableStream", "");
@@ -11423,20 +11371,20 @@ TableScale_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * TableScale_getServer(TableScale* self) { GET_SERVER };
static PyObject * TableScale_getStream(TableScale* self) { GET_STREAM };
-static PyObject * TableScale_setMul(TableScale *self, PyObject *arg) { SET_MUL };
-static PyObject * TableScale_setAdd(TableScale *self, PyObject *arg) { SET_ADD };
-static PyObject * TableScale_setSub(TableScale *self, PyObject *arg) { SET_SUB };
-static PyObject * TableScale_setDiv(TableScale *self, PyObject *arg) { SET_DIV };
+static PyObject * TableScale_setMul(TableScale *self, PyObject *arg) { SET_MUL };
+static PyObject * TableScale_setAdd(TableScale *self, PyObject *arg) { SET_ADD };
+static PyObject * TableScale_setSub(TableScale *self, PyObject *arg) { SET_SUB };
+static PyObject * TableScale_setDiv(TableScale *self, PyObject *arg) { SET_DIV };
static PyObject * TableScale_play(TableScale *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TableScale_out(TableScale *self, PyObject *args, PyObject *kwds) { OUT };
@@ -11462,19 +11410,19 @@ static PyObject *
TableScale_setTable(TableScale *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TableScale_getOuttable(TableScale* self)
@@ -11487,19 +11435,19 @@ static PyObject *
TableScale_setOuttable(TableScale *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->outtable);
self->outtable = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TableScale_members[] = {
{"server", T_OBJECT_EX, offsetof(TableScale, server), 0, "Pyo server."},
diff --git a/src/objects/oscmodule.c b/src/objects/oscmodule.c
index 51fb4ef..e40c8cc 100644
--- a/src/objects/oscmodule.c
+++ b/src/objects/oscmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -71,7 +71,7 @@ OscReceiver_traverse(OscReceiver *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
OscReceiver_clear(OscReceiver *self)
{
pyo_CLEAR
@@ -96,45 +96,45 @@ OscReceiver_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pathtmp;
OscReceiver *self;
self = (OscReceiver *)type->tp_alloc(type, 0);
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, OscReceiver_compute_next_data_frame);
static char *kwlist[] = {"port", "address", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "iO", kwlist, &self->port, &pathtmp))
Py_RETURN_NONE;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->dict = PyDict_New();
-
+
if (PyString_Check(pathtmp) || PyList_Check(pathtmp)) {
- Py_INCREF(pathtmp);
+ Py_INCREF(pathtmp);
Py_XDECREF(self->address_path);
self->address_path = pathtmp;
}
else {
PyErr_SetString(PyExc_TypeError, "The address attributes must be a string or a list of strings.");
Py_RETURN_NONE;
- }
-
+ }
+
if (PyString_Check(self->address_path)) {
PyDict_SetItem(self->dict, self->address_path, PyFloat_FromDouble(0.));
- }
+ }
else if (PyList_Check(self->address_path)) {
int lsize = PyList_Size(self->address_path);
for (i=0; i<lsize; i++) {
PyDict_SetItem(self->dict, PyList_GET_ITEM(self->address_path, i), PyFloat_FromDouble(0.));
- }
+ }
}
-
+
char buf[20];
sprintf(buf, "%i", self->port);
self->osc_server = lo_server_new(buf, error);
-
+
lo_server_add_method(self->osc_server, NULL, TYPE_F, OscReceiver_handler, self);
-
+
return (PyObject *)self;
}
@@ -144,13 +144,13 @@ OscReceiver_addAddress(OscReceiver *self, PyObject *arg)
int i;
if (PyString_Check(arg)) {
PyDict_SetItem(self->dict, arg, PyFloat_FromDouble(0.));
- }
+ }
else if (PyList_Check(arg)) {
Py_ssize_t lsize = PyList_Size(arg);
for (i=0; i<lsize; i++) {
PyDict_SetItem(self->dict, PyList_GET_ITEM(arg, i), PyFloat_FromDouble(0.));
- }
- }
+ }
+ }
Py_INCREF(Py_None);
return Py_None;
}
@@ -161,13 +161,13 @@ OscReceiver_delAddress(OscReceiver *self, PyObject *arg)
int i;
if (PyString_Check(arg)) {
PyDict_DelItem(self->dict, arg);
- }
+ }
else if (PyList_Check(arg)) {
Py_ssize_t lsize = PyList_Size(arg);
for (i=0; i<lsize; i++) {
PyDict_DelItem(self->dict, PyList_GET_ITEM(arg, i));
- }
- }
+ }
+ }
Py_INCREF(Py_None);
return Py_None;
}
@@ -176,16 +176,16 @@ static PyObject *
OscReceiver_setValue(OscReceiver *self, PyObject *args, PyObject *kwds)
{
PyObject *address, *value;
-
+
static char *kwlist[] = {"address", "value", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &address, &value))
Py_RETURN_NONE;
PyDict_SetItem(self->dict, address, value);
Py_RETURN_NONE;
}
-
+
static PyObject * OscReceiver_getServer(OscReceiver* self) { GET_SERVER };
static PyObject * OscReceiver_getStream(OscReceiver* self) { GET_STREAM };
@@ -272,33 +272,33 @@ OscReceive_setProcMode(OscReceive *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = OscReceive_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = OscReceive_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = OscReceive_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = OscReceive_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = OscReceive_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = OscReceive_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = OscReceive_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = OscReceive_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = OscReceive_postprocessing_revareva;
break;
}
@@ -309,17 +309,17 @@ OscReceive_compute_next_data_frame(OscReceive *self)
{
int i;
MYFLT val = OscReceiver_getValue((OscReceiver *)self->input, self->address_path);
-
+
if (self->interpolation == 1) {
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->value = self->value + (val - self->value) * self->factor;
- }
+ }
}
else {
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->value = val;
- }
+ }
}
(*self->muladd_func_ptr)(self);
@@ -334,7 +334,7 @@ OscReceive_traverse(OscReceive *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
OscReceive_clear(OscReceive *self)
{
pyo_CLEAR
@@ -383,22 +383,22 @@ OscReceive_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
if (! PyString_Check(pathtmp)) {
PyErr_SetString(PyExc_TypeError, "The address attributes must be a string.");
Py_RETURN_NONE;
- }
-
- Py_INCREF(pathtmp);
+ }
+
+ Py_INCREF(pathtmp);
Py_XDECREF(self->address_path);
self->address_path = pathtmp;
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -411,19 +411,19 @@ OscReceive_setInterpolation(OscReceive *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->interpolation = PyInt_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject * OscReceive_getServer(OscReceive* self) { GET_SERVER };
static PyObject * OscReceive_getStream(OscReceive* self) { GET_STREAM };
-static PyObject * OscReceive_setMul(OscReceive *self, PyObject *arg) { SET_MUL };
-static PyObject * OscReceive_setAdd(OscReceive *self, PyObject *arg) { SET_ADD };
-static PyObject * OscReceive_setSub(OscReceive *self, PyObject *arg) { SET_SUB };
-static PyObject * OscReceive_setDiv(OscReceive *self, PyObject *arg) { SET_DIV };
+static PyObject * OscReceive_setMul(OscReceive *self, PyObject *arg) { SET_MUL };
+static PyObject * OscReceive_setAdd(OscReceive *self, PyObject *arg) { SET_ADD };
+static PyObject * OscReceive_setSub(OscReceive *self, PyObject *arg) { SET_SUB };
+static PyObject * OscReceive_setDiv(OscReceive *self, PyObject *arg) { SET_DIV };
static PyObject * OscReceive_play(OscReceive *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * OscReceive_stop(OscReceive *self) { STOP };
@@ -563,9 +563,9 @@ OscSend_compute_next_data_frame(OscSend *self)
self->count = 0;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
float value = (float)in[0];
-
+
char *path = PyString_AsString(self->address_path);
-
+
if (lo_send(self->address, path, "f", value) == -1) {
printf("OSC error %d: %s\n", lo_address_errno(self->address), lo_address_errstr(self->address));
}
@@ -582,7 +582,7 @@ OscSend_traverse(OscSend *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
OscSend_clear(OscSend *self)
{
pyo_CLEAR
@@ -607,36 +607,36 @@ OscSend_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *pathtmp;
OscSend *self;
self = (OscSend *)type->tp_alloc(type, 0);
-
+
self->host = NULL;
self->count = 0;
self->bufrate = 1;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, OscSend_compute_next_data_frame);
static char *kwlist[] = {"input", "port", "address", "host", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OiO|s", kwlist, &inputtmp, &self->port, &pathtmp, &self->host))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
if (! PyString_Check(pathtmp)) {
PyErr_SetString(PyExc_TypeError, "The address attributes must be a string.");
Py_RETURN_NONE;
- }
-
- Py_INCREF(pathtmp);
+ }
+
+ Py_INCREF(pathtmp);
Py_XDECREF(self->address_path);
self->address_path = pathtmp;
-
+
char buf[20];
sprintf(buf, "%i", self->port);
self->address = lo_address_new(self->host, buf);
-
+
return (PyObject *)self;
}
@@ -647,11 +647,11 @@ OscSend_setBufferRate(OscSend *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->bufrate = PyInt_AsLong(arg);
if (self->bufrate < 1)
self->bufrate = 1;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -735,30 +735,65 @@ typedef struct {
static void
OscDataSend_compute_next_data_frame(OscDataSend *self)
-{
- int i;
+{
+ int i, j = 0;
+ Py_ssize_t blobsize = 0;
+ PyObject *datalist = NULL;
+ char *blobdata = NULL;
+ uint8_t midi[4];
+ lo_blob *blob = NULL;
+
lo_message *msg;
char *path = PyString_AsString(self->address_path);
-
+
if (self->something_to_send == 1) {
msg = lo_message_new();
for (i=0; i<self->num_items; i++) {
switch (self->types[i]) {
case LO_INT32:
- lo_message_add_int32(msg, PyInt_AsLong(PyList_GetItem(self->value, i)));
+ lo_message_add_int32(msg, PyInt_AS_LONG(PyList_GET_ITEM(self->value, i)));
break;
case LO_INT64:
- lo_message_add_int64(msg, (long)PyLong_AsLong(PyList_GetItem(self->value, i)));
+ lo_message_add_int64(msg, (long)PyLong_AsLong(PyList_GET_ITEM(self->value, i)));
break;
case LO_FLOAT:
- lo_message_add_float(msg, PyFloat_AsDouble(PyList_GetItem(self->value, i)));
+ lo_message_add_float(msg, PyFloat_AS_DOUBLE(PyList_GET_ITEM(self->value, i)));
break;
case LO_DOUBLE:
- lo_message_add_double(msg, (double)PyFloat_AsDouble(PyList_GetItem(self->value, i)));
+ lo_message_add_double(msg, (double)PyFloat_AS_DOUBLE(PyList_GET_ITEM(self->value, i)));
break;
case LO_STRING:
- lo_message_add_string(msg, PyString_AsString(PyList_GetItem(self->value, i)));
+ lo_message_add_string(msg, PyString_AsString(PyList_GET_ITEM(self->value, i)));
+ break;
+ case LO_CHAR:
+ lo_message_add_char(msg, (char)PyString_AsString(PyList_GET_ITEM(self->value, i))[0]);
+ break;
+ case LO_BLOB:
+ datalist = PyList_GET_ITEM(self->value, i);
+ blobsize = PyList_Size(datalist);
+ blobdata = (char *)malloc(blobsize * sizeof(char));
+ for (j=0; j<blobsize; j++) {
+ blobdata[j] = (char)PyString_AsString(PyList_GET_ITEM(datalist, j))[0];
+ }
+ blob = lo_blob_new(blobsize * sizeof(char), blobdata);
+ lo_message_add_blob(msg, blob);
+ break;
+ case LO_MIDI:
+ datalist = PyList_GET_ITEM(self->value, i);
+ for (j=0; j<4; j++) {
+ midi[j] = (uint8_t)PyInt_AS_LONG(PyList_GET_ITEM(datalist, j));
+ }
+ lo_message_add_midi(msg, midi);
+ break;
+ case LO_NIL:
+ lo_message_add_nil(msg);
+ break;
+ case LO_TRUE:
+ lo_message_add_true(msg);
+ break;
+ case LO_FALSE:
+ lo_message_add_false(msg);
break;
default:
break;
@@ -769,8 +804,11 @@ OscDataSend_compute_next_data_frame(OscDataSend *self)
}
self->something_to_send = 0;
lo_message_free(msg);
+ if (blob != NULL)
+ lo_blob_free(blob);
+ if (blobdata != NULL)
+ free(blobdata);
}
-
}
static int
@@ -782,7 +820,7 @@ OscDataSend_traverse(OscDataSend *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
OscDataSend_clear(OscDataSend *self)
{
pyo_CLEAR
@@ -806,34 +844,34 @@ OscDataSend_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pathtmp;
OscDataSend *self;
self = (OscDataSend *)type->tp_alloc(type, 0);
-
+
self->host = NULL;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, OscDataSend_compute_next_data_frame);
static char *kwlist[] = {"types", "port", "address", "host", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "siO|s", kwlist, &self->types, &self->port, &pathtmp, &self->host))
Py_RETURN_NONE;
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
if (! PyString_Check(pathtmp)) {
PyErr_SetString(PyExc_TypeError, "The address attributes must be a string.");
Py_RETURN_NONE;
- }
-
+ }
+
self->num_items = strlen(self->types);
-
- Py_INCREF(pathtmp);
+
+ Py_INCREF(pathtmp);
Py_XDECREF(self->address_path);
self->address_path = pathtmp;
-
+
char buf[20];
sprintf(buf, "%i", self->port);
self->address = lo_address_new(self->host, buf);
-
+
return (PyObject *)self;
}
@@ -845,14 +883,14 @@ static PyObject * OscDataSend_stop(OscDataSend *self) { STOP };
static PyObject *
OscDataSend_send(OscDataSend *self, PyObject *arg)
-{
+{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
if (PyList_Check(arg)) {
tmp = arg;
Py_XDECREF(self->value);
@@ -861,11 +899,11 @@ OscDataSend_send(OscDataSend *self, PyObject *arg)
self->something_to_send = 1;
}
else
- printf("argument to send() method must be a tuple of values.\n");
+ printf("argument to send() method must be a list of values.\n");
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef OscDataSend_members[] = {
{"server", T_OBJECT_EX, offsetof(OscDataSend, server), 0, "Pyo server."},
@@ -937,45 +975,84 @@ int OscDataReceive_handler(const char *path, const char *types, lo_arg **argv, i
void *data, void *user_data)
{
OscDataReceive *self = user_data;
- PyObject *tup, *result;
+ PyObject *tup, *result=NULL;
+ lo_blob *blob = NULL;
+ char *blobdata = NULL;
+ uint32_t blobsize = 0;
+ PyObject *charlist = NULL;
tup = PyTuple_New(argc+1);
- int i, ok = 0;
-
+ int i, ok = 0, j = 0;
+
Py_ssize_t lsize = PyList_Size(self->address_path);
for (i=0; i<lsize; i++) {
- if (lo_pattern_match(path, PyString_AsString(PyList_GetItem(self->address_path, i)))) {
+ if (lo_pattern_match(path, PyString_AsString(PyList_GET_ITEM(self->address_path, i)))) {
ok = 1;
break;
}
}
-
+
if (ok) {
- PyTuple_SetItem(tup, 0, PyString_FromString(path));
+ PyTuple_SET_ITEM(tup, 0, PyString_FromString(path));
for (i=0; i<argc; i++) {
switch (types[i]) {
case LO_INT32:
- PyTuple_SetItem(tup, i+1, PyInt_FromLong(argv[i]->i));
+ PyTuple_SET_ITEM(tup, i+1, PyInt_FromLong(argv[i]->i));
break;
case LO_INT64:
- PyTuple_SetItem(tup, i+1, PyLong_FromLong(argv[i]->h));
+ PyTuple_SET_ITEM(tup, i+1, PyLong_FromLong(argv[i]->h));
break;
case LO_FLOAT:
- PyTuple_SetItem(tup, i+1, PyFloat_FromDouble(argv[i]->f));
+ PyTuple_SET_ITEM(tup, i+1, PyFloat_FromDouble(argv[i]->f));
break;
case LO_DOUBLE:
- PyTuple_SetItem(tup, i+1, PyFloat_FromDouble(argv[i]->d));
+ PyTuple_SET_ITEM(tup, i+1, PyFloat_FromDouble(argv[i]->d));
break;
case LO_STRING:
- PyTuple_SetItem(tup, i+1, PyString_FromString(&argv[i]->s));
+ PyTuple_SET_ITEM(tup, i+1, PyString_FromString(&argv[i]->s));
+ break;
+ case LO_CHAR:
+ PyTuple_SET_ITEM(tup, i+1, PyString_FromFormat("%c", argv[i]->c));
+ break;
+ case LO_BLOB:
+ blob = (lo_blob)argv[i];
+ blobsize = lo_blob_datasize(blob);
+ blobdata = lo_blob_dataptr(blob);
+ charlist = PyList_New(blobsize);
+ for (j=0; j<blobsize; j++) {
+ PyList_SET_ITEM(charlist, j, PyString_FromFormat("%c", blobdata[j]));
+ }
+ PyTuple_SET_ITEM(tup, i+1, charlist);
+ break;
+ case LO_MIDI:
+ charlist = PyList_New(4);
+ for (j=0; j<4; j++) {
+ PyList_SET_ITEM(charlist, j, PyInt_FromLong(argv[i]->m[j]));
+ }
+ PyTuple_SET_ITEM(tup, i+1, charlist);
+ break;
+ case LO_NIL:
+ Py_INCREF(Py_None);
+ PyTuple_SET_ITEM(tup, i+1, Py_None);
+ break;
+ case LO_TRUE:
+ Py_INCREF(Py_True);
+ PyTuple_SET_ITEM(tup, i+1, Py_True);
+ break;
+ case LO_FALSE:
+ Py_INCREF(Py_False);
+ PyTuple_SET_ITEM(tup, i+1, Py_False);
break;
default:
break;
}
}
- result = PyObject_Call(self->callable, tup, NULL);
+ result = PyObject_Call(self->callable, tup, NULL);
if (result == NULL)
PyErr_Print();
}
+ Py_XDECREF(tup);
+ Py_XDECREF(result);
+ Py_XDECREF(charlist);
return 0;
}
@@ -994,7 +1071,7 @@ OscDataReceive_traverse(OscDataReceive *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
OscDataReceive_clear(OscDataReceive *self)
{
pyo_CLEAR
@@ -1019,36 +1096,36 @@ OscDataReceive_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pathtmp, *calltmp;
OscDataReceive *self;
self = (OscDataReceive *)type->tp_alloc(type, 0);
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, OscDataReceive_compute_next_data_frame);
static char *kwlist[] = {"port", "address", "callable", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "iOO", kwlist, &self->port, &pathtmp, &calltmp))
Py_RETURN_NONE;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Py_XDECREF(self->callable);
self->callable = calltmp;
-
+
if (PyString_Check(pathtmp) || PyList_Check(pathtmp)) {
- Py_INCREF(pathtmp);
+ Py_INCREF(pathtmp);
Py_XDECREF(self->address_path);
self->address_path = pathtmp;
}
else {
PyErr_SetString(PyExc_TypeError, "The address attributes must be a string or a list of strings.");
Py_RETURN_NONE;
- }
+ }
char buf[20];
sprintf(buf, "%i", self->port);
self->osc_server = lo_server_new(buf, error);
-
+
lo_server_add_method(self->osc_server, NULL, NULL, OscDataReceive_handler, self);
-
+
return (PyObject *)self;
}
@@ -1171,7 +1248,7 @@ int OscListReceiver_handler(const char *path, const char *types, lo_arg **argv,
return 0;
}
-PyObject *
+PyObject *
OscListReceiver_getValue(OscListReceiver *self, PyObject *path)
{
PyObject *tmp;
@@ -1194,7 +1271,7 @@ OscListReceiver_traverse(OscListReceiver *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
OscListReceiver_clear(OscListReceiver *self)
{
pyo_CLEAR
@@ -1219,30 +1296,30 @@ OscListReceiver_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pathtmp, *flist;
OscListReceiver *self;
self = (OscListReceiver *)type->tp_alloc(type, 0);
-
+
self->num = 8;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, OscListReceiver_compute_next_data_frame);
static char *kwlist[] = {"port", "address", "num", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "iO|i", kwlist, &self->port, &pathtmp, &self->num))
Py_RETURN_NONE;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->dict = PyDict_New();
-
+
if (PyString_Check(pathtmp) || PyList_Check(pathtmp)) {
- Py_INCREF(pathtmp);
+ Py_INCREF(pathtmp);
Py_XDECREF(self->address_path);
self->address_path = pathtmp;
}
else {
PyErr_SetString(PyExc_TypeError, "The address attributes must be a string or a list of strings.");
Py_RETURN_NONE;
- }
+ }
if (PyString_Check(self->address_path)) {
flist = PyList_New(self->num);
@@ -1250,7 +1327,7 @@ OscListReceiver_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyList_SET_ITEM(flist, j, PyFloat_FromDouble(0.));
}
PyDict_SetItem(self->dict, self->address_path, flist);
- }
+ }
else if (PyList_Check(self->address_path)) {
int lsize = PyList_Size(self->address_path);
for (i=0; i<lsize; i++) {
@@ -1259,15 +1336,15 @@ OscListReceiver_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyList_SET_ITEM(flist, j, PyFloat_FromDouble(0.));
}
PyDict_SetItem(self->dict, PyList_GET_ITEM(self->address_path, i), flist);
- }
+ }
}
-
+
char buf[20];
sprintf(buf, "%i", self->port);
self->osc_server = lo_server_new(buf, error);
-
+
lo_server_add_method(self->osc_server, NULL, NULL, OscListReceiver_handler, self);
-
+
return (PyObject *)self;
}
@@ -1283,7 +1360,7 @@ OscListReceiver_addAddress(OscListReceiver *self, PyObject *arg)
PyList_SET_ITEM(flist, j, PyFloat_FromDouble(0.));
}
PyDict_SetItem(self->dict, arg, flist);
- }
+ }
else if (PyList_Check(arg)) {
Py_ssize_t lsize = PyList_Size(arg);
for (i=0; i<lsize; i++) {
@@ -1292,8 +1369,8 @@ OscListReceiver_addAddress(OscListReceiver *self, PyObject *arg)
PyList_SET_ITEM(flist, j, PyFloat_FromDouble(0.));
}
PyDict_SetItem(self->dict, PyList_GET_ITEM(arg, i), flist);
- }
- }
+ }
+ }
Py_INCREF(Py_None);
return Py_None;
}
@@ -1304,13 +1381,13 @@ OscListReceiver_delAddress(OscListReceiver *self, PyObject *arg)
int i;
if (PyString_Check(arg)) {
PyDict_DelItem(self->dict, arg);
- }
+ }
else if (PyList_Check(arg)) {
Py_ssize_t lsize = PyList_Size(arg);
for (i=0; i<lsize; i++) {
PyDict_DelItem(self->dict, PyList_GET_ITEM(arg, i));
- }
- }
+ }
+ }
Py_INCREF(Py_None);
return Py_None;
}
@@ -1321,10 +1398,10 @@ OscListReceiver_setValue(OscListReceiver *self, PyObject *args, PyObject *kwds)
PyObject *address, *value;
static char *kwlist[] = {"address", "value", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &address, &value))
Py_RETURN_NONE;
-
+
PyDict_SetItem(self->dict, address, value);
Py_RETURN_NONE;
}
@@ -1416,33 +1493,33 @@ OscListReceive_setProcMode(OscListReceive *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = OscListReceive_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = OscListReceive_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = OscListReceive_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = OscListReceive_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = OscListReceive_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = OscListReceive_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = OscListReceive_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = OscListReceive_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = OscListReceive_postprocessing_revareva;
break;
}
@@ -1456,17 +1533,17 @@ OscListReceive_compute_next_data_frame(OscListReceive *self)
MYFLT val = PyFloat_AsDouble(PyList_GET_ITEM(flist, self->order));
if (self->interpolation == 1) {
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->value = self->value + (val - self->value) * self->factor;
- }
+ }
}
else {
for (i=0; i<self->bufsize; i++) {
self->data[i] = self->value = val;
- }
+ }
}
-
+
(*self->muladd_func_ptr)(self);
}
@@ -1479,7 +1556,7 @@ OscListReceive_traverse(OscListReceive *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
OscListReceive_clear(OscListReceive *self)
{
pyo_CLEAR
@@ -1503,50 +1580,50 @@ OscListReceive_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp=NULL, *pathtmp=NULL, *multmp=NULL, *addtmp=NULL;;
OscListReceive *self;
self = (OscListReceive *)type->tp_alloc(type, 0);
-
+
self->order = 0;
self->value = 0.;
self->interpolation = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
-
+
self->factor = 1. / (0.01 * self->sr);
-
+
Stream_setFunctionPtr(self->stream, OscListReceive_compute_next_data_frame);
self->mode_func_ptr = OscListReceive_setProcMode;
static char *kwlist[] = {"input", "address", "order", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOi|OO", kwlist, &inputtmp, &pathtmp, &self->order, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->input);
Py_INCREF(inputtmp);
self->input = inputtmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
if (! PyString_Check(pathtmp)) {
PyErr_SetString(PyExc_TypeError, "The address attributes must be a string.");
Py_RETURN_NONE;
- }
-
- Py_INCREF(pathtmp);
+ }
+
+ Py_INCREF(pathtmp);
Py_XDECREF(self->address_path);
self->address_path = pathtmp;
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -1557,19 +1634,19 @@ OscListReceive_setInterpolation(OscListReceive *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->interpolation = PyInt_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject * OscListReceive_getServer(OscListReceive* self) { GET_SERVER };
static PyObject * OscListReceive_getStream(OscListReceive* self) { GET_STREAM };
-static PyObject * OscListReceive_setMul(OscListReceive *self, PyObject *arg) { SET_MUL };
-static PyObject * OscListReceive_setAdd(OscListReceive *self, PyObject *arg) { SET_ADD };
-static PyObject * OscListReceive_setSub(OscListReceive *self, PyObject *arg) { SET_SUB };
-static PyObject * OscListReceive_setDiv(OscListReceive *self, PyObject *arg) { SET_DIV };
+static PyObject * OscListReceive_setMul(OscListReceive *self, PyObject *arg) { SET_MUL };
+static PyObject * OscListReceive_setAdd(OscListReceive *self, PyObject *arg) { SET_ADD };
+static PyObject * OscListReceive_setSub(OscListReceive *self, PyObject *arg) { SET_SUB };
+static PyObject * OscListReceive_setDiv(OscListReceive *self, PyObject *arg) { SET_DIV };
static PyObject * OscListReceive_play(OscListReceive *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * OscListReceive_stop(OscListReceive *self) { STOP };
@@ -1686,4 +1763,4 @@ PyTypeObject OscListReceiveType = {
0, /* tp_init */
0, /* tp_alloc */
OscListReceive_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/panmodule.c b/src/objects/panmodule.c
index 7cdc876..4b5d858 100644
--- a/src/objects/panmodule.c
+++ b/src/objects/panmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -53,10 +53,10 @@ static void
Panner_splitter_thru(Panner *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->buffer_streams[i] = in[i];
- }
+ }
}
static void
@@ -64,17 +64,17 @@ Panner_splitter_st_i(Panner *self) {
MYFLT val, inval;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT pan = PyFloat_AS_DOUBLE(self->pan);
pan = P_clip(pan);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
val = inval * MYSQRT(1.0 - pan);
self->buffer_streams[i] = val;
val = inval * MYSQRT(pan);
self->buffer_streams[i+self->bufsize] = val;
- }
+ }
}
static void
@@ -82,9 +82,9 @@ Panner_splitter_st_a(Panner *self) {
MYFLT val, inval, panval;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT *pan = Stream_getData((Stream *)self->pan_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
panval = P_clip(pan[i]);
@@ -92,7 +92,7 @@ Panner_splitter_st_a(Panner *self) {
self->buffer_streams[i] = val;
val = inval * MYSQRT(panval);
self->buffer_streams[i+self->bufsize] = val;
- }
+ }
}
static void
@@ -103,10 +103,10 @@ Panner_splitter_ii(Panner *self) {
MYFLT pan = PyFloat_AS_DOUBLE(self->pan);
MYFLT spd = PyFloat_AS_DOUBLE(self->spread);
-
+
pan = P_clip(pan);
spd = P_clip(spd);
-
+
sprd = 20.0 - (MYSQRT(spd) * 20.0) + 0.1;
for (i=0; i<self->bufsize; i++) {
@@ -116,7 +116,7 @@ Panner_splitter_ii(Panner *self) {
val = inval * MYPOW(MYCOS((pan - phase) * TWOPI) * 0.5 + 0.5, sprd);
self->buffer_streams[i+j*self->bufsize] = val;
}
- }
+ }
}
static void
@@ -124,14 +124,14 @@ Panner_splitter_ai(Panner *self) {
MYFLT val, inval, phase, sprd;
int j, i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT *pan = Stream_getData((Stream *)self->pan_stream);
MYFLT spd = PyFloat_AS_DOUBLE(self->spread);
spd = P_clip(spd);
-
+
sprd = 20.0 - (MYSQRT(spd) * 20.0) + 0.1;
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
for (j=0; j<self->chnls; j++) {
@@ -139,7 +139,7 @@ Panner_splitter_ai(Panner *self) {
val = inval * MYPOW(MYCOS((P_clip(pan[i]) - phase) * TWOPI) * 0.5 + 0.5, sprd);
self->buffer_streams[i+j*self->bufsize] = val;
}
- }
+ }
}
static void
@@ -147,12 +147,12 @@ Panner_splitter_ia(Panner *self) {
MYFLT val, inval, phase, spdval, sprd;
int j, i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT pan = PyFloat_AS_DOUBLE(self->pan);
MYFLT *spd = Stream_getData((Stream *)self->spread_stream);
pan = P_clip(pan);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
spdval = P_clip(spd[i]);
@@ -162,7 +162,7 @@ Panner_splitter_ia(Panner *self) {
val = inval * MYPOW(MYCOS((pan - phase) * TWOPI) * 0.5 + 0.5, sprd);
self->buffer_streams[i+j*self->bufsize] = val;
}
- }
+ }
}
static void
@@ -170,11 +170,11 @@ Panner_splitter_aa(Panner *self) {
MYFLT val, inval, phase, spdval, sprd;
int j, i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT *pan = Stream_getData((Stream *)self->pan_stream);
MYFLT *spd = Stream_getData((Stream *)self->spread_stream);
-
-
+
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
spdval = P_clip(spd[i]);
@@ -184,56 +184,56 @@ Panner_splitter_aa(Panner *self) {
val = inval * MYPOW(MYCOS((P_clip(pan[i]) - phase) * TWOPI) * 0.5 + 0.5, sprd);
self->buffer_streams[i+j*self->bufsize] = val;
}
- }
+ }
}
MYFLT *
Panner_getSamplesBuffer(Panner *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
Panner_setProcMode(Panner *self)
-{
+{
int procmode;
procmode = self->modebuffer[0] + self->modebuffer[1] * 10;
if (self->chnls > 2) {
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Panner_splitter_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Panner_splitter_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Panner_splitter_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Panner_splitter_aa;
break;
- }
- }
+ }
+ }
else if (self->chnls == 2) {
switch (self->modebuffer[0]) {
- case 0:
+ case 0:
self->proc_func_ptr = Panner_splitter_st_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Panner_splitter_st_a;
break;
- }
- }
+ }
+ }
else if (self->chnls == 1) {
self->proc_func_ptr = Panner_splitter_thru;
- }
+ }
}
static void
Panner_compute_next_data_frame(Panner *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -249,7 +249,7 @@ Panner_traverse(Panner *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Panner_clear(Panner *self)
{
pyo_CLEAR
@@ -278,7 +278,7 @@ Panner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *pantmp=NULL, *spreadtmp=NULL;
Panner *self;
self = (Panner *)type->tp_alloc(type, 0);
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Panner_compute_next_data_frame);
self->mode_func_ptr = Panner_setProcMode;
@@ -326,14 +326,14 @@ static PyObject *
Panner_setPan(Panner *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pan);
@@ -349,25 +349,25 @@ Panner_setPan(Panner *self, PyObject *arg)
self->pan_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Panner_setSpread(Panner *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->spread);
@@ -383,12 +383,12 @@ Panner_setSpread(Panner *self, PyObject *arg)
self->spread_stream = (Stream *)streamtmp;
self->modebuffer[1] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Panner_members[] = {
{"server", T_OBJECT_EX, offsetof(Panner, server), 0, "Pyo server."},
@@ -476,33 +476,33 @@ Pan_setProcMode(Pan *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Pan_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Pan_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Pan_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Pan_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Pan_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Pan_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Pan_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Pan_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Pan_postprocessing_revareva;
break;
}
@@ -517,7 +517,7 @@ Pan_compute_next_data_frame(Pan *self)
tmp = Panner_getSamplesBuffer((Panner *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -529,11 +529,11 @@ Pan_traverse(Pan *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Pan_clear(Pan *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -552,44 +552,44 @@ Pan_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
Pan *self;
self = (Pan *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Pan_compute_next_data_frame);
self->mode_func_ptr = Pan_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (Panner *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Pan_getServer(Pan* self) { GET_SERVER };
static PyObject * Pan_getStream(Pan* self) { GET_STREAM };
-static PyObject * Pan_setMul(Pan *self, PyObject *arg) { SET_MUL };
-static PyObject * Pan_setAdd(Pan *self, PyObject *arg) { SET_ADD };
-static PyObject * Pan_setSub(Pan *self, PyObject *arg) { SET_SUB };
-static PyObject * Pan_setDiv(Pan *self, PyObject *arg) { SET_DIV };
+static PyObject * Pan_setMul(Pan *self, PyObject *arg) { SET_MUL };
+static PyObject * Pan_setAdd(Pan *self, PyObject *arg) { SET_ADD };
+static PyObject * Pan_setSub(Pan *self, PyObject *arg) { SET_SUB };
+static PyObject * Pan_setDiv(Pan *self, PyObject *arg) { SET_DIV };
static PyObject * Pan_play(Pan *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Pan_out(Pan *self, PyObject *args, PyObject *kwds) { OUT };
@@ -729,10 +729,10 @@ static void
SPanner_splitter_thru(SPanner *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->buffer_streams[i] = in[i];
- }
+ }
}
static void
@@ -740,17 +740,17 @@ SPanner_splitter_st_i(SPanner *self) {
MYFLT val, inval;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT pan = PyFloat_AS_DOUBLE(self->pan);
pan = P_clip(pan);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
val = inval * MYSQRT(1.0 - pan);
self->buffer_streams[i] = val;
val = inval * MYSQRT(pan);
self->buffer_streams[i+self->bufsize] = val;
- }
+ }
}
static void
@@ -758,9 +758,9 @@ SPanner_splitter_st_a(SPanner *self) {
MYFLT val, inval, panval;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
MYFLT *pan = Stream_getData((Stream *)self->pan_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
panval = P_clip(pan[i]);
@@ -768,7 +768,7 @@ SPanner_splitter_st_a(SPanner *self) {
self->buffer_streams[i] = val;
val = inval * MYSQRT(panval);
self->buffer_streams[i+self->bufsize] = val;
- }
+ }
}
static void
@@ -783,7 +783,7 @@ SPanner_splitter_i(SPanner *self) {
self->buffer_streams[i+self->k1] = 0.0;
self->buffer_streams[i+self->k2] = 0.0;
}
-
+
min = 0;
self->k1 = 0;
self->k2 = self->bufsize;
@@ -799,7 +799,7 @@ SPanner_splitter_i(SPanner *self) {
self->k2 = j * self->bufsize;
break;
}
- }
+ }
pan = P_clip((pan - min) * self->chnls);
pan1 = MYSQRT(1.0 - pan);
@@ -810,7 +810,7 @@ SPanner_splitter_i(SPanner *self) {
self->buffer_streams[i+self->k1] = val;
val = inval * pan2;
self->buffer_streams[i+self->k2] = val;
- }
+ }
}
static void
@@ -820,19 +820,19 @@ SPanner_splitter_a(SPanner *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *apan = Stream_getData((Stream *)self->pan_stream);
MYFLT fchnls = (MYFLT)self->chnls;
-
+
len = self->chnls * self->bufsize;
for (i=0; i<len; i++) {
self->buffer_streams[i] = 0.0;
}
-
+
for (i=0; i<self->bufsize; i++) {
pan = apan[i];
inval = in[i];
min = 0;
self->k1 = 0;
self->k2 = self->bufsize;
-
+
for (j=self->chnls; j>0; j--) {
j1 = j - 1;
min = j1 / fchnls;
@@ -840,61 +840,61 @@ SPanner_splitter_a(SPanner *self) {
self->k1 = j1 * self->bufsize;
if (j == self->chnls)
self->k2 = 0;
- else
+ else
self->k2 = j * self->bufsize;
break;
}
- }
-
+ }
+
pan = P_clip((pan - min) * self->chnls);
val = inval * MYSQRT(1.0 - pan);
self->buffer_streams[i+self->k1] = val;
val = inval * MYSQRT(pan);
self->buffer_streams[i+self->k2] = val;
- }
+ }
}
MYFLT *
SPanner_getSamplesBuffer(SPanner *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
SPanner_setProcMode(SPanner *self)
-{
+{
int procmode;
procmode = self->modebuffer[0];
-
+
if (self->chnls > 2) {
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = SPanner_splitter_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = SPanner_splitter_a;
break;
- }
- }
+ }
+ }
else if (self->chnls == 2) {
switch (self->modebuffer[0]) {
- case 0:
+ case 0:
self->proc_func_ptr = SPanner_splitter_st_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = SPanner_splitter_st_a;
break;
- }
- }
+ }
+ }
else if (self->chnls == 1) {
self->proc_func_ptr = SPanner_splitter_thru;
- }
+ }
}
static void
SPanner_compute_next_data_frame(SPanner *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -908,7 +908,7 @@ SPanner_traverse(SPanner *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
SPanner_clear(SPanner *self)
{
pyo_CLEAR
@@ -935,11 +935,11 @@ SPanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *pantmp=NULL;
SPanner *self;
self = (SPanner *)type->tp_alloc(type, 0);
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SPanner_compute_next_data_frame);
self->mode_func_ptr = SPanner_setProcMode;
-
+
self->pan = PyFloat_FromDouble(0.5);
self->chnls = 2;
self->k1 = 0;
@@ -947,12 +947,12 @@ SPanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[0] = 0;
static char *kwlist[] = {"input", "outs", "pan", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iO", kwlist, &inputtmp, &self->chnls, &pantmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (pantmp) {
PyObject_CallMethod((PyObject *)self, "setPan", "O", pantmp);
}
@@ -961,16 +961,16 @@ SPanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (self->chnls < 1)
self->chnls = 1;
-
+
self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->chnls * self->bufsize * sizeof(MYFLT));
-
+
(*self->mode_func_ptr)(self);
int len = self->chnls*self->bufsize;
for (i=0; i<len; i++) {
self->buffer_streams[i] = 0.0;
}
-
+
return (PyObject *)self;
}
@@ -984,14 +984,14 @@ static PyObject *
SPanner_setPan(SPanner *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pan);
@@ -1007,12 +1007,12 @@ SPanner_setPan(SPanner *self, PyObject *arg)
self->pan_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef SPanner_members[] = {
{"server", T_OBJECT_EX, offsetof(SPanner, server), 0, "Pyo server."},
@@ -1098,33 +1098,33 @@ SPan_setProcMode(SPan *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SPan_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SPan_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SPan_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SPan_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SPan_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SPan_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SPan_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SPan_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SPan_postprocessing_revareva;
break;
}
@@ -1139,7 +1139,7 @@ SPan_compute_next_data_frame(SPan *self)
tmp = SPanner_getSamplesBuffer((SPanner *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -1151,11 +1151,11 @@ SPan_traverse(SPan *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
SPan_clear(SPan *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -1174,44 +1174,44 @@ SPan_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
SPan *self;
self = (SPan *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SPan_compute_next_data_frame);
self->mode_func_ptr = SPan_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (SPanner *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * SPan_getServer(SPan* self) { GET_SERVER };
static PyObject * SPan_getStream(SPan* self) { GET_STREAM };
-static PyObject * SPan_setMul(SPan *self, PyObject *arg) { SET_MUL };
-static PyObject * SPan_setAdd(SPan *self, PyObject *arg) { SET_ADD };
-static PyObject * SPan_setSub(SPan *self, PyObject *arg) { SET_SUB };
-static PyObject * SPan_setDiv(SPan *self, PyObject *arg) { SET_DIV };
+static PyObject * SPan_setMul(SPan *self, PyObject *arg) { SET_MUL };
+static PyObject * SPan_setAdd(SPan *self, PyObject *arg) { SET_ADD };
+static PyObject * SPan_setSub(SPan *self, PyObject *arg) { SET_SUB };
+static PyObject * SPan_setDiv(SPan *self, PyObject *arg) { SET_DIV };
static PyObject * SPan_play(SPan *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SPan_out(SPan *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1354,7 +1354,7 @@ Switcher_clip_voice(Switcher *self, MYFLT v) {
return 0.0;
else if (v > chnls)
return chnls;
- else
+ else
return v;
}
@@ -1364,7 +1364,7 @@ Switcher_splitter_i(Switcher *self) {
int j1, j, i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT voice = Switcher_clip_voice(self, PyFloat_AS_DOUBLE(self->voice));
-
+
for (i=0; i<self->bufsize; i++) {
self->buffer_streams[i+self->k1] = 0.0;
self->buffer_streams[i+self->k2] = 0.0;
@@ -1375,7 +1375,7 @@ Switcher_splitter_i(Switcher *self) {
if (j1 >= (self->chnls-1)) {
j1--; j--;
}
-
+
self->k1 = j1 * self->bufsize;
self->k2 = j * self->bufsize;
@@ -1389,7 +1389,7 @@ Switcher_splitter_i(Switcher *self) {
self->buffer_streams[i+self->k1] = val;
val = inval * voice2;
self->buffer_streams[i+self->k2] = val;
- }
+ }
}
static void
@@ -1398,12 +1398,12 @@ Switcher_splitter_a(Switcher *self) {
int i, j, j1, len;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *avoice = Stream_getData((Stream *)self->voice_stream);
-
+
len = self->chnls * self->bufsize;
for (i=0; i<len; i++) {
self->buffer_streams[i] = 0.0;
}
-
+
for (i=0; i<self->bufsize; i++) {
voice = Switcher_clip_voice(self, avoice[i]);
inval = in[i];
@@ -1413,31 +1413,31 @@ Switcher_splitter_a(Switcher *self) {
if (j1 >= (self->chnls-1)) {
j1--; j--;
}
-
+
self->k1 = j1 * self->bufsize;
self->k2 = j * self->bufsize;
-
+
voice = P_clip(voice - j1);
-
+
self->buffer_streams[i+self->k1] = inval * MYSQRT(1.0 - voice);
self->buffer_streams[i+self->k2] = inval * MYSQRT(voice);
- }
+ }
}
MYFLT *
Switcher_getSamplesBuffer(Switcher *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
Switcher_setProcMode(Switcher *self)
-{
+{
switch (self->modebuffer[0]) {
- case 0:
+ case 0:
self->proc_func_ptr = Switcher_splitter_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Switcher_splitter_a;
break;
}
@@ -1446,7 +1446,7 @@ Switcher_setProcMode(Switcher *self)
static void
Switcher_compute_next_data_frame(Switcher *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -1460,7 +1460,7 @@ Switcher_traverse(Switcher *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Switcher_clear(Switcher *self)
{
pyo_CLEAR
@@ -1487,11 +1487,11 @@ Switcher_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *voicetmp=NULL;
Switcher *self;
self = (Switcher *)type->tp_alloc(type, 0);
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Switcher_compute_next_data_frame);
self->mode_func_ptr = Switcher_setProcMode;
-
+
self->voice = PyFloat_FromDouble(0.0);
self->chnls = 2;
self->k1 = 0;
@@ -1499,27 +1499,27 @@ Switcher_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[0] = 0;
static char *kwlist[] = {"input", "outs", "voice", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iO", kwlist, &inputtmp, &self->chnls, &voicetmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (voicetmp) {
PyObject_CallMethod((PyObject *)self, "setVoice", "O", voicetmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->chnls * self->bufsize * sizeof(MYFLT));
-
+
(*self->mode_func_ptr)(self);
-
+
int len = self->chnls*self->bufsize;
for (i=0; i<len; i++) {
self->buffer_streams[i] = 0.0;
}
-
+
return (PyObject *)self;
}
@@ -1533,14 +1533,14 @@ static PyObject *
Switcher_setVoice(Switcher *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->voice);
@@ -1556,12 +1556,12 @@ Switcher_setVoice(Switcher *self, PyObject *arg)
self->voice_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Switcher_members[] = {
{"server", T_OBJECT_EX, offsetof(Switcher, server), 0, "Pyo server."},
@@ -1647,33 +1647,33 @@ Switch_setProcMode(Switch *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Switch_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Switch_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Switch_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Switch_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Switch_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Switch_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Switch_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Switch_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Switch_postprocessing_revareva;
break;
}
@@ -1688,7 +1688,7 @@ Switch_compute_next_data_frame(Switch *self)
tmp = Switcher_getSamplesBuffer((Switcher *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -1700,11 +1700,11 @@ Switch_traverse(Switch *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Switch_clear(Switch *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -1723,44 +1723,44 @@ Switch_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
Switch *self;
self = (Switch *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Switch_compute_next_data_frame);
self->mode_func_ptr = Switch_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (Switcher *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Switch_getServer(Switch* self) { GET_SERVER };
static PyObject * Switch_getStream(Switch* self) { GET_STREAM };
-static PyObject * Switch_setMul(Switch *self, PyObject *arg) { SET_MUL };
-static PyObject * Switch_setAdd(Switch *self, PyObject *arg) { SET_ADD };
-static PyObject * Switch_setSub(Switch *self, PyObject *arg) { SET_SUB };
-static PyObject * Switch_setDiv(Switch *self, PyObject *arg) { SET_DIV };
+static PyObject * Switch_setMul(Switch *self, PyObject *arg) { SET_MUL };
+static PyObject * Switch_setAdd(Switch *self, PyObject *arg) { SET_ADD };
+static PyObject * Switch_setSub(Switch *self, PyObject *arg) { SET_SUB };
+static PyObject * Switch_setDiv(Switch *self, PyObject *arg) { SET_DIV };
static PyObject * Switch_play(Switch *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Switch_out(Switch *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1890,7 +1890,7 @@ typedef struct {
Stream **trigger_streams;
int maxVoices;
int *voices;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
} VoiceManager;
static void
@@ -1902,7 +1902,7 @@ VoiceManager_generate(VoiceManager *self) {
for (i=0; i<self->bufsize; i++)
self->data[i] = -1.0;
- if (self->maxVoices > 0) {
+ if (self->maxVoices > 0) {
for (i=0; i<self->bufsize; i++) {
for (j=0; j<self->maxVoices; j++) {
if (Stream_getData(self->trigger_streams[j])[i] == 1.0)
@@ -1936,44 +1936,44 @@ VoiceManager_setProcMode(VoiceManager *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = VoiceManager_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = VoiceManager_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = VoiceManager_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = VoiceManager_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = VoiceManager_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = VoiceManager_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = VoiceManager_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = VoiceManager_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = VoiceManager_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = VoiceManager_postprocessing_revareva;
break;
- }
+ }
}
static void
VoiceManager_compute_next_data_frame(VoiceManager *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1987,7 +1987,7 @@ VoiceManager_traverse(VoiceManager *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
VoiceManager_clear(VoiceManager *self)
{
pyo_CLEAR
@@ -2016,10 +2016,10 @@ VoiceManager_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self = (VoiceManager *)type->tp_alloc(type, 0);
self->voices = NULL;
- self->maxVoices = 0;
+ self->maxVoices = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, VoiceManager_compute_next_data_frame);
self->mode_func_ptr = VoiceManager_setProcMode;
@@ -2028,21 +2028,21 @@ VoiceManager_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &triggerstmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (triggerstmp && triggerstmp != Py_None) {
PyObject_CallMethod((PyObject *)self, "setTriggers", "O", triggerstmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -2052,10 +2052,10 @@ VoiceManager_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * VoiceManager_getServer(VoiceManager* self) { GET_SERVER };
static PyObject * VoiceManager_getStream(VoiceManager* self) { GET_STREAM };
-static PyObject * VoiceManager_setMul(VoiceManager *self, PyObject *arg) { SET_MUL };
-static PyObject * VoiceManager_setAdd(VoiceManager *self, PyObject *arg) { SET_ADD };
-static PyObject * VoiceManager_setSub(VoiceManager *self, PyObject *arg) { SET_SUB };
-static PyObject * VoiceManager_setDiv(VoiceManager *self, PyObject *arg) { SET_DIV };
+static PyObject * VoiceManager_setMul(VoiceManager *self, PyObject *arg) { SET_MUL };
+static PyObject * VoiceManager_setAdd(VoiceManager *self, PyObject *arg) { SET_ADD };
+static PyObject * VoiceManager_setSub(VoiceManager *self, PyObject *arg) { SET_SUB };
+static PyObject * VoiceManager_setDiv(VoiceManager *self, PyObject *arg) { SET_DIV };
static PyObject * VoiceManager_play(VoiceManager *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * VoiceManager_stop(VoiceManager *self) { STOP };
@@ -2073,13 +2073,13 @@ static PyObject *
VoiceManager_setTriggers(VoiceManager *self, PyObject *arg)
{
int i;
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The triggers attribute must be a list.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->maxVoices = PyList_Size(arg);
self->trigger_streams = (Stream **)realloc(self->trigger_streams, self->maxVoices * sizeof(Stream *));
self->voices = (int *)realloc(self->voices, self->maxVoices * sizeof(int));
@@ -2089,7 +2089,7 @@ VoiceManager_setTriggers(VoiceManager *self, PyObject *arg)
}
Py_RETURN_NONE;
-}
+}
static PyMemberDef VoiceManager_members[] = {
{"server", T_OBJECT_EX, offsetof(VoiceManager, server), 0, "Pyo server."},
@@ -2226,7 +2226,7 @@ Mixer_generate(Mixer *self) {
for (i=0; i<(self->num_outs * self->bufsize); i++) {
self->buffer_streams[i] = 0.0;
}
-
+
keys = PyDict_Keys(self->inputs);
num = PyList_Size(keys);
@@ -2248,7 +2248,7 @@ Mixer_generate(Mixer *self) {
tmpCount = 0;
tmpStepVal = (amp - currentAmp) / self->timeStep;
PyList_SetItem(list_of_last_gains, k, PyFloat_FromDouble(amp));
- }
+ }
for (i=0; i<self->bufsize; i++) {
if (tmpCount == (self->timeStep - 1)) {
currentAmp = amp;
@@ -2257,7 +2257,7 @@ Mixer_generate(Mixer *self) {
else if (tmpCount < self->timeStep) {
currentAmp += tmpStepVal;
tmpCount++;
- }
+ }
self->buffer_streams[self->bufsize * k + i] += st[i] * currentAmp;
}
PyList_SetItem(list_of_current_gains, k, PyFloat_FromDouble(currentAmp));
@@ -2272,7 +2272,7 @@ MYFLT *
Mixer_getSamplesBuffer(Mixer *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
Mixer_setProcMode(Mixer *self)
@@ -2283,7 +2283,7 @@ Mixer_setProcMode(Mixer *self)
static void
Mixer_compute_next_data_frame(Mixer *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -2299,7 +2299,7 @@ Mixer_traverse(Mixer *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Mixer_clear(Mixer *self)
{
pyo_CLEAR
@@ -2328,7 +2328,7 @@ Mixer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *timetmp=NULL;
Mixer *self;
self = (Mixer *)type->tp_alloc(type, 0);
-
+
self->inputs = PyDict_New();
self->gains = PyDict_New();
self->lastGains = PyDict_New();
@@ -2338,26 +2338,26 @@ Mixer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->num_outs = 2;
self->time = 0.025;
self->timeStep = (long)(self->time * self->sr);
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Mixer_compute_next_data_frame);
self->mode_func_ptr = Mixer_setProcMode;
static char *kwlist[] = {"outs", "time", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iO", kwlist, &self->num_outs, &timetmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (timetmp) {
PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->num_outs * self->bufsize * sizeof(MYFLT));
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -2372,20 +2372,20 @@ Mixer_setTime(Mixer *self, PyObject *arg)
{
int i, j, num;
PyObject *tmp, *keys, *key, *list_of_time_counts;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
if (isNumber == 1) {
self->time = PyFloat_AS_DOUBLE(PyNumber_Float(tmp));
self->timeStep = (long)(self->time * self->sr);
-
+
keys = PyDict_Keys(self->inputs);
num = PyList_Size(keys);
if (num != 0) {
@@ -2394,14 +2394,14 @@ Mixer_setTime(Mixer *self, PyObject *arg)
list_of_time_counts = PyDict_GetItem(self->timeCounts, key);
for (i=0; i<self->num_outs; i++) {
PyList_SET_ITEM(list_of_time_counts, i, PyLong_FromLong(self->timeStep-1));
- }
+ }
}
- }
+ }
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Mixer_addInput(Mixer *self, PyObject *args, PyObject *kwds)
@@ -2416,12 +2416,12 @@ Mixer_addInput(Mixer *self, PyObject *args, PyObject *kwds)
PyObject *voice;
static char *kwlist[] = {"voice", "input", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &voice, &tmp)) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
PyDict_SetItem(self->inputs, voice, tmp);
initGains = PyList_New(self->num_outs);
initLastGains = PyList_New(self->num_outs);
@@ -2440,16 +2440,16 @@ Mixer_addInput(Mixer *self, PyObject *args, PyObject *kwds)
PyDict_SetItem(self->currentGains, voice, initCurrentGains);
PyDict_SetItem(self->stepVals, voice, initStepVals);
PyDict_SetItem(self->timeCounts, voice, initTimeCounts);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Mixer_delInput(Mixer *self, PyObject *arg)
{
int ret;
-
+
PyObject *key = arg;
ret = PyDict_DelItem(self->inputs, key);
if (ret == 0) {
@@ -2458,14 +2458,14 @@ Mixer_delInput(Mixer *self, PyObject *arg)
PyDict_DelItem(self->currentGains, key);
PyDict_DelItem(self->stepVals, key);
PyDict_DelItem(self->timeCounts, key);
- }
+ }
else {
Py_INCREF(Py_None);
return Py_None;
}
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
}
static PyObject *
@@ -2474,18 +2474,18 @@ Mixer_setAmp(Mixer *self, PyObject *args, PyObject *kwds)
int tmpout;
PyObject *tmpin, *amp;
static char *kwlist[] = {"vin", "vout", "amp", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OiO", kwlist, &tmpin, &tmpout, &)) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
if (! PyNumber_Check(amp)) {
printf("Amplitude must be a number!n");
Py_INCREF(Py_None);
- return Py_None;
+ return Py_None;
}
-
+
Py_INCREF(amp);
PyList_SET_ITEM(PyDict_GetItem(self->gains, tmpin), tmpout, PyNumber_Float(amp));
@@ -2580,33 +2580,33 @@ MixerVoice_setProcMode(MixerVoice *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = MixerVoice_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = MixerVoice_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = MixerVoice_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = MixerVoice_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = MixerVoice_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = MixerVoice_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = MixerVoice_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = MixerVoice_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = MixerVoice_postprocessing_revareva;
break;
}
@@ -2621,7 +2621,7 @@ MixerVoice_compute_next_data_frame(MixerVoice *self)
tmp = Mixer_getSamplesBuffer((Mixer *)self->mainMixer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -2633,11 +2633,11 @@ MixerVoice_traverse(MixerVoice *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
MixerVoice_clear(MixerVoice *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainMixer);
+ Py_CLEAR(self->mainMixer);
return 0;
}
@@ -2656,42 +2656,42 @@ MixerVoice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
MixerVoice *self;
self = (MixerVoice *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, MixerVoice_compute_next_data_frame);
self->mode_func_ptr = MixerVoice_setProcMode;
static char *kwlist[] = {"mainMixer", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
Py_XDECREF(self->mainMixer);
Py_INCREF(maintmp);
self->mainMixer = (Mixer *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
return (PyObject *)self;
}
static PyObject * MixerVoice_getServer(MixerVoice* self) { GET_SERVER };
static PyObject * MixerVoice_getStream(MixerVoice* self) { GET_STREAM };
-static PyObject * MixerVoice_setMul(MixerVoice *self, PyObject *arg) { SET_MUL };
-static PyObject * MixerVoice_setAdd(MixerVoice *self, PyObject *arg) { SET_ADD };
-static PyObject * MixerVoice_setSub(MixerVoice *self, PyObject *arg) { SET_SUB };
-static PyObject * MixerVoice_setDiv(MixerVoice *self, PyObject *arg) { SET_DIV };
+static PyObject * MixerVoice_setMul(MixerVoice *self, PyObject *arg) { SET_MUL };
+static PyObject * MixerVoice_setAdd(MixerVoice *self, PyObject *arg) { SET_ADD };
+static PyObject * MixerVoice_setSub(MixerVoice *self, PyObject *arg) { SET_SUB };
+static PyObject * MixerVoice_setDiv(MixerVoice *self, PyObject *arg) { SET_DIV };
static PyObject * MixerVoice_play(MixerVoice *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * MixerVoice_out(MixerVoice *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2820,7 +2820,7 @@ typedef struct {
PyObject *voice;
Stream *voice_stream;
int chSize;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} Selector;
static MYFLT
@@ -2830,7 +2830,7 @@ Selector_clip_voice(Selector *self, MYFLT v) {
return 0.0;
else if (v > chSize)
return chSize;
- else
+ else
return v;
}
@@ -2852,7 +2852,7 @@ Selector_generate_i(Selector *self) {
voice = P_clip(voice - j1);
voice1 = MYSQRT(1.0 - voice);
voice2 = MYSQRT(voice);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = st1[i] * voice1 + st2[i] * voice2;
}
@@ -2865,14 +2865,14 @@ Selector_generate_a(Selector *self) {
MYFLT *st1, *st2;
MYFLT *vc = Stream_getData((Stream *)self->voice_stream);
- old_j1 = 0;
+ old_j1 = 0;
old_j = 1;
st1 = Stream_getData((Stream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->inputs, old_j1), "_getStream", NULL));
st2 = Stream_getData((Stream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->inputs, old_j), "_getStream", NULL));
-
+
for (i=0; i<self->bufsize; i++) {
voice = Selector_clip_voice(self, vc[i]);
-
+
j1 = (int)voice;
j = j1 + 1;
if (j1 >= (self->chSize-1)) {
@@ -2881,11 +2881,11 @@ Selector_generate_a(Selector *self) {
if (j1 != old_j1) {
st1 = Stream_getData((Stream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->inputs, j1), "_getStream", NULL));
old_j1 = j1;
- }
+ }
if (j != old_j) {
st2 = Stream_getData((Stream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->inputs, j), "_getStream", NULL));
old_j = j;
- }
+ }
voice = P_clip(voice - j1);
@@ -2909,50 +2909,50 @@ Selector_setProcMode(Selector *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Selector_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Selector_generate_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Selector_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Selector_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Selector_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Selector_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Selector_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Selector_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Selector_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Selector_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Selector_postprocessing_revareva;
break;
- }
+ }
}
static void
Selector_compute_next_data_frame(Selector *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2966,7 +2966,7 @@ Selector_traverse(Selector *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Selector_clear(Selector *self)
{
pyo_CLEAR
@@ -2991,39 +2991,39 @@ Selector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputstmp=NULL, *voicetmp=NULL, *multmp=NULL, *addtmp=NULL;
Selector *self;
self = (Selector *)type->tp_alloc(type, 0);
-
+
self->voice = PyFloat_FromDouble(0.);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Selector_compute_next_data_frame);
self->mode_func_ptr = Selector_setProcMode;
static char *kwlist[] = {"inputs", "voice", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputstmp, &voicetmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (inputstmp) {
PyObject_CallMethod((PyObject *)self, "setInputs", "O", inputstmp);
}
-
+
if (voicetmp) {
PyObject_CallMethod((PyObject *)self, "setVoice", "O", voicetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3031,10 +3031,10 @@ Selector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Selector_getServer(Selector* self) { GET_SERVER };
static PyObject * Selector_getStream(Selector* self) { GET_STREAM };
-static PyObject * Selector_setMul(Selector *self, PyObject *arg) { SET_MUL };
-static PyObject * Selector_setAdd(Selector *self, PyObject *arg) { SET_ADD };
-static PyObject * Selector_setSub(Selector *self, PyObject *arg) { SET_SUB };
-static PyObject * Selector_setDiv(Selector *self, PyObject *arg) { SET_DIV };
+static PyObject * Selector_setMul(Selector *self, PyObject *arg) { SET_MUL };
+static PyObject * Selector_setAdd(Selector *self, PyObject *arg) { SET_ADD };
+static PyObject * Selector_setSub(Selector *self, PyObject *arg) { SET_SUB };
+static PyObject * Selector_setDiv(Selector *self, PyObject *arg) { SET_DIV };
static PyObject * Selector_play(Selector *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Selector_out(Selector *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3053,13 +3053,13 @@ static PyObject *
Selector_setInputs(Selector *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The inputs attribute must be a list.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
self->chSize = PyList_Size(tmp);
Py_INCREF(tmp);
@@ -3068,20 +3068,20 @@ Selector_setInputs(Selector *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Selector_setVoice(Selector *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->voice);
@@ -3097,12 +3097,12 @@ Selector_setVoice(Selector *self, PyObject *arg)
self->voice_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Selector_members[] = {
{"server", T_OBJECT_EX, offsetof(Selector, server), 0, "Pyo server."},
@@ -3213,4 +3213,3 @@ Selector_members, /* tp_members */
Selector_new, /* tp_new */
};
-
diff --git a/src/objects/patternmodule.c b/src/objects/patternmodule.c
index 9733bdd..49bcfae 100644
--- a/src/objects/patternmodule.c
+++ b/src/objects/patternmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -41,7 +41,7 @@ Pattern_generate_i(Pattern *self) {
MYFLT tm;
int i, flag;
PyObject *result;
-
+
flag = 0;
tm = PyFloat_AS_DOUBLE(self->time);
@@ -49,7 +49,7 @@ Pattern_generate_i(Pattern *self) {
if (self->currentTime >= tm) {
flag = 1;
self->currentTime = 0.;
- }
+ }
self->currentTime += self->sampleToSec;
}
@@ -65,16 +65,16 @@ static void
Pattern_generate_a(Pattern *self) {
int i, flag;
PyObject *result;
-
+
MYFLT *tm = Stream_getData((Stream *)self->time_stream);
-
+
flag = 0;
for (i=0; i<self->bufsize; i++) {
if (self->currentTime >= tm[i]) {
flag = 1;
self->currentTime = 0.;
- }
-
+ }
+
self->currentTime += self->sampleToSec;
}
if (flag == 1 || self->init == 1) {
@@ -82,7 +82,7 @@ Pattern_generate_a(Pattern *self) {
result = PyObject_Call((PyObject *)self->callable, PyTuple_New(0), NULL);
if (result == NULL)
PyErr_Print();
- }
+ }
}
@@ -91,10 +91,10 @@ Pattern_setProcMode(Pattern *self)
{
int procmode = self->modebuffer[0];
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Pattern_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Pattern_generate_a;
break;
}
@@ -103,7 +103,7 @@ Pattern_setProcMode(Pattern *self)
static void
Pattern_compute_next_data_frame(Pattern *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -111,17 +111,17 @@ Pattern_traverse(Pattern *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->callable);
- Py_VISIT(self->time);
- Py_VISIT(self->time_stream);
+ Py_VISIT(self->time);
+ Py_VISIT(self->time_stream);
return 0;
}
-static int
+static int
Pattern_clear(Pattern *self)
{
pyo_CLEAR
Py_CLEAR(self->callable);
- Py_CLEAR(self->time);
+ Py_CLEAR(self->time);
Py_CLEAR(self->time_stream);
return 0;
}
@@ -141,7 +141,7 @@ Pattern_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *timetmp=NULL, *calltmp=NULL;
Pattern *self;
self = (Pattern *)type->tp_alloc(type, 0);
-
+
self->time = PyFloat_FromDouble(1.);
self->modebuffer[0] = 0;
self->init = 1;
@@ -151,38 +151,38 @@ Pattern_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Pattern_setProcMode;
Stream_setStreamActive(self->stream, 0);
-
+
self->sampleToSec = 1. / self->sr;
self->currentTime = 0.;
static char *kwlist[] = {"callable", "time", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|O", kwlist, &calltmp, &timetmp))
Py_RETURN_NONE;
-
+
if (calltmp) {
PyObject_CallMethod((PyObject *)self, "setFunction", "O", calltmp);
}
-
+
if (timetmp) {
PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Pattern_getServer(Pattern* self) { GET_SERVER };
static PyObject * Pattern_getStream(Pattern* self) { GET_STREAM };
-static PyObject *
-Pattern_play(Pattern *self, PyObject *args, PyObject *kwds)
-{
+static PyObject *
+Pattern_play(Pattern *self, PyObject *args, PyObject *kwds)
+{
self->init = 1;
- PLAY
+ PLAY
};
static PyObject * Pattern_stop(Pattern *self) { STOP };
@@ -191,34 +191,34 @@ static PyObject *
Pattern_setFunction(Pattern *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (! PyCallable_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The callable attribute must be a valid Python function.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_XDECREF(self->callable);
Py_INCREF(tmp);
self->callable = tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Pattern_setTime(Pattern *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->time);
@@ -234,12 +234,12 @@ Pattern_setTime(Pattern *self, PyObject *arg)
self->time_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Pattern_members[] = {
{"server", T_OBJECT_EX, offsetof(Pattern, server), 0, "Pyo server."},
@@ -315,16 +315,16 @@ typedef struct {
static void
Score_selector(Score *self) {
int i, inval;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = (int)in[i];
if (inval != self->last_value) {
sprintf(self->curfname, "%s%i()\n", self->fname, inval);
PyRun_SimpleString(self->curfname);
self->last_value = inval;
- }
+ }
}
}
@@ -337,23 +337,23 @@ Score_setProcMode(Score *self)
static void
Score_compute_next_data_frame(Score *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
Score_traverse(Score *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
return 0;
}
-static int
+static int
Score_clear(Score *self)
{
pyo_CLEAR
- Py_CLEAR(self->input);
+ Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
return 0;
}
@@ -373,24 +373,24 @@ Score_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp;
Score *self;
self = (Score *)type->tp_alloc(type, 0);
-
+
self->last_value = -99;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Score_compute_next_data_frame);
self->mode_func_ptr = Score_setProcMode;
static char *kwlist[] = {"input", "fname", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|s", kwlist, &inputtmp, &self->fname))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -481,7 +481,7 @@ CallAfter_generate(CallAfter *self) {
tuple = PyTuple_New(1);
PyTuple_SET_ITEM(tuple, 0, self->arg);
}
- result = PyObject_Call(self->callable, tuple, NULL);
+ result = PyObject_Call(self->callable, tuple, NULL);
if (result == NULL)
PyErr_Print();
PyObject_CallMethod((PyObject *)self, "stop", NULL);
@@ -493,14 +493,14 @@ CallAfter_generate(CallAfter *self) {
static void
CallAfter_setProcMode(CallAfter *self)
-{
+{
self->proc_func_ptr = CallAfter_generate;
}
static void
CallAfter_compute_next_data_frame(CallAfter *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -512,7 +512,7 @@ CallAfter_traverse(CallAfter *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
CallAfter_clear(CallAfter *self)
{
pyo_CLEAR
@@ -536,10 +536,10 @@ CallAfter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *calltmp=NULL, *argtmp=NULL;
CallAfter *self;
self = (CallAfter *)type->tp_alloc(type, 0);
-
+
self->time = 1.;
self->arg = Py_None;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, CallAfter_compute_next_data_frame);
self->mode_func_ptr = CallAfter_setProcMode;
@@ -548,10 +548,10 @@ CallAfter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->currentTime = 0.;
static char *kwlist[] = {"callable", "time", "arg", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FO, kwlist, &calltmp, &self->time, &argtmp))
Py_RETURN_NONE;
-
+
if (! PyCallable_Check(calltmp))
Py_RETURN_NONE;
@@ -560,15 +560,15 @@ CallAfter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_INCREF(argtmp);
self->arg = argtmp;
}
-
+
Py_INCREF(calltmp);
Py_XDECREF(self->callable);
self->callable = calltmp;
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -632,4 +632,4 @@ CallAfter_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
CallAfter_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/phasevocmodule.c b/src/objects/phasevocmodule.c
index af5d3dc..e90a232 100644
--- a/src/objects/phasevocmodule.c
+++ b/src/objects/phasevocmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -30,7 +30,7 @@
#include "fft.h"
#include "wind.h"
-static int
+static int
isPowerOfTwo(int x) {
return (x != 0) && ((x & (x - 1)) == 0);
}
@@ -52,9 +52,9 @@ typedef struct {
MYFLT scale;
MYFLT *input_buffer;
MYFLT *inframe;
- MYFLT *outframe;
- MYFLT *real;
- MYFLT *imag;
+ MYFLT *outframe;
+ MYFLT *real;
+ MYFLT *imag;
MYFLT *lastPhase;
MYFLT **twiddle;
MYFLT *window;
@@ -77,20 +77,20 @@ PVAnal_realloc_memories(PVAnal *self) {
n8 = self->size >> 3;
self->input_buffer = (MYFLT *)realloc(self->input_buffer, self->size * sizeof(MYFLT));
self->inframe = (MYFLT *)realloc(self->inframe, self->size * sizeof(MYFLT));
- self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
+ self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
for (i=0; i<self->size; i++)
self->input_buffer[i] = self->inframe[i] = self->outframe[i] = 0.0;
- self->lastPhase = (MYFLT *)realloc(self->lastPhase, self->hsize * sizeof(MYFLT));
- self->real = (MYFLT *)realloc(self->real, self->hsize * sizeof(MYFLT));
- self->imag = (MYFLT *)realloc(self->imag, self->hsize * sizeof(MYFLT));
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->lastPhase = (MYFLT *)realloc(self->lastPhase, self->hsize * sizeof(MYFLT));
+ self->real = (MYFLT *)realloc(self->real, self->hsize * sizeof(MYFLT));
+ self->imag = (MYFLT *)realloc(self->imag, self->hsize * sizeof(MYFLT));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->hsize; i++)
self->lastPhase[i] = self->real[i] = self->imag[i] = 0.0;
self->twiddle = (MYFLT **)realloc(self->twiddle, 4 * sizeof(MYFLT *));
@@ -113,7 +113,7 @@ PVAnal_process(PVAnal *self) {
int i, k, mod;
MYFLT real, imag, mag, phase, tmp;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->input_buffer[self->incount] = in[i];
self->count[i] = self->incount;
@@ -156,14 +156,14 @@ PVAnal_process(PVAnal *self) {
static void
PVAnal_setProcMode(PVAnal *self)
-{
- self->proc_func_ptr = PVAnal_process;
+{
+ self->proc_func_ptr = PVAnal_process;
}
static void
PVAnal_compute_next_data_frame(PVAnal *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -176,7 +176,7 @@ PVAnal_traverse(PVAnal *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PVAnal_clear(PVAnal *self)
{
pyo_CLEAR
@@ -193,9 +193,9 @@ PVAnal_dealloc(PVAnal* self)
pyo_DEALLOC
free(self->input_buffer);
free(self->inframe);
- free(self->outframe);
- free(self->real);
- free(self->imag);
+ free(self->outframe);
+ free(self->real);
+ free(self->imag);
free(self->lastPhase);
for(i=0; i<4; i++) {
free(self->twiddle[i]);
@@ -229,12 +229,12 @@ PVAnal_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVAnal_setProcMode;
static char *kwlist[] = {"input", "size", "olaps", "wintype", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iii", kwlist, &inputtmp, &self->size, &self->olaps, &self->wintype))
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -265,7 +265,7 @@ static PyObject * PVAnal_stop(PVAnal *self) { STOP };
static PyObject *
PVAnal_setSize(PVAnal *self, PyObject *arg)
-{
+{
int k;
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->size = PyInt_AsLong(arg);
@@ -277,15 +277,15 @@ PVAnal_setSize(PVAnal *self, PyObject *arg)
printf("FFT size must be a power-of-2, using the next power-of-2 greater than size : %d\n", self->size);
}
PVAnal_realloc_memories(self);
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
PVAnal_setOverlaps(PVAnal *self, PyObject *arg)
-{
+{
int k;
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->olaps = PyInt_AsLong(arg);
@@ -297,20 +297,20 @@ PVAnal_setOverlaps(PVAnal *self, PyObject *arg)
printf("FFT overlaps must be a power-of-2, using the next power-of-2 greater than olaps : %d\n", self->olaps);
}
PVAnal_realloc_memories(self);
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
PVAnal_setWinType(PVAnal *self, PyObject *arg)
-{
+{
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->wintype = PyInt_AsLong(arg);
gen_window(self->window, self->size, self->wintype);
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -398,9 +398,9 @@ typedef struct {
MYFLT *output_buffer;
MYFLT *outputAccum;
MYFLT *inframe;
- MYFLT *outframe;
- MYFLT *real;
- MYFLT *imag;
+ MYFLT *outframe;
+ MYFLT *real;
+ MYFLT *imag;
MYFLT *sumPhase;
MYFLT **twiddle;
MYFLT *window;
@@ -421,15 +421,15 @@ PVSynth_realloc_memories(PVSynth *self) {
n8 = self->size >> 3;
self->output_buffer = (MYFLT *)realloc(self->output_buffer, self->size * sizeof(MYFLT));
self->inframe = (MYFLT *)realloc(self->inframe, self->size * sizeof(MYFLT));
- self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
+ self->outframe = (MYFLT *)realloc(self->outframe, self->size * sizeof(MYFLT));
for (i=0; i<self->size; i++)
self->output_buffer[i] = self->inframe[i] = self->outframe[i] = 0.0;
- self->sumPhase = (MYFLT *)realloc(self->sumPhase, self->hsize * sizeof(MYFLT));
- self->real = (MYFLT *)realloc(self->real, self->hsize * sizeof(MYFLT));
- self->imag = (MYFLT *)realloc(self->imag, self->hsize * sizeof(MYFLT));
+ self->sumPhase = (MYFLT *)realloc(self->sumPhase, self->hsize * sizeof(MYFLT));
+ self->real = (MYFLT *)realloc(self->real, self->hsize * sizeof(MYFLT));
+ self->imag = (MYFLT *)realloc(self->imag, self->hsize * sizeof(MYFLT));
for (i=0; i<self->hsize; i++)
self->sumPhase[i] = self->real[i] = self->imag[i] = 0.0;
- self->outputAccum = (MYFLT *)realloc(self->outputAccum, (self->size+self->hopsize) * sizeof(MYFLT));
+ self->outputAccum = (MYFLT *)realloc(self->outputAccum, (self->size+self->hopsize) * sizeof(MYFLT));
for (i=0; i<(self->size+self->hopsize); i++)
self->outputAccum[i] = 0.0;
self->twiddle = (MYFLT **)realloc(self->twiddle, 4 * sizeof(MYFLT *));
@@ -461,14 +461,14 @@ PVSynth_process(PVSynth *self) {
if (count[i] >= (self->size-1)) {
for (k=0; k<self->hsize; k++) {
mag = magn[self->overcount][k];
- tmp = freq[self->overcount][k];
+ tmp = freq[self->overcount][k];
tmp = (tmp - k * self->scale) * self->factor;
self->sumPhase[k] += tmp;
phase = self->sumPhase[k];
self->real[k] = mag * MYCOS(phase);
self->imag[k] = mag * MYSIN(phase);
}
-
+
self->inframe[0] = self->real[0];
self->inframe[self->hsize] = 0.0;
for (k=1; k<self->hsize; k++) {
@@ -509,34 +509,34 @@ PVSynth_setProcMode(PVSynth *self)
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
- self->proc_func_ptr = PVSynth_process;
+ self->proc_func_ptr = PVSynth_process;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = PVSynth_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = PVSynth_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = PVSynth_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = PVSynth_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = PVSynth_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = PVSynth_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = PVSynth_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = PVSynth_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = PVSynth_postprocessing_revareva;
break;
}
@@ -545,7 +545,7 @@ PVSynth_setProcMode(PVSynth *self)
static void
PVSynth_compute_next_data_frame(PVSynth *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -559,7 +559,7 @@ PVSynth_traverse(PVSynth *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PVSynth_clear(PVSynth *self)
{
pyo_CLEAR
@@ -577,9 +577,9 @@ PVSynth_dealloc(PVSynth* self)
free(self->output_buffer);
free(self->outputAccum);
free(self->inframe);
- free(self->outframe);
- free(self->real);
- free(self->imag);
+ free(self->outframe);
+ free(self->real);
+ free(self->imag);
free(self->sumPhase);
for(i=0; i<4; i++) {
free(self->twiddle[i]);
@@ -607,16 +607,13 @@ PVSynth_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVSynth_setProcMode;
static char *kwlist[] = {"input", "wintype", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &inputtmp, &self->wintype, &multmp, &addtmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVSynth \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVSynth must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -628,11 +625,11 @@ PVSynth_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->size = PVStream_getFFTsize(self->input_stream);
self->olaps = PVStream_getOlaps(self->input_stream);
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
@@ -653,9 +650,8 @@ PVSynth_setInput(PVSynth *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVSynth \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVSynth must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -665,19 +661,19 @@ PVSynth_setInput(PVSynth *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVSynth_setWinType(PVSynth *self, PyObject *arg)
-{
+{
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->wintype = PyInt_AsLong(arg);
gen_window(self->window, self->size, self->wintype);
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -685,10 +681,10 @@ PVSynth_setWinType(PVSynth *self, PyObject *arg)
static PyObject * PVSynth_getServer(PVSynth* self) { GET_SERVER };
static PyObject * PVSynth_getStream(PVSynth* self) { GET_STREAM };
//static PyObject * PVSynth_getPVStream(PVSynth* self) { GET_PV_STREAM };
-static PyObject * PVSynth_setMul(PVSynth *self, PyObject *arg) { SET_MUL };
-static PyObject * PVSynth_setAdd(PVSynth *self, PyObject *arg) { SET_ADD };
-static PyObject * PVSynth_setSub(PVSynth *self, PyObject *arg) { SET_SUB };
-static PyObject * PVSynth_setDiv(PVSynth *self, PyObject *arg) { SET_DIV };
+static PyObject * PVSynth_setMul(PVSynth *self, PyObject *arg) { SET_MUL };
+static PyObject * PVSynth_setAdd(PVSynth *self, PyObject *arg) { SET_ADD };
+static PyObject * PVSynth_setSub(PVSynth *self, PyObject *arg) { SET_SUB };
+static PyObject * PVSynth_setDiv(PVSynth *self, PyObject *arg) { SET_DIV };
static PyObject * PVSynth_play(PVSynth *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * PVSynth_out(PVSynth *self, PyObject *args, PyObject *kwds) { OUT };
@@ -978,41 +974,41 @@ PVAddSynth_setProcMode(PVAddSynth *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVAddSynth_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVAddSynth_process_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = PVAddSynth_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = PVAddSynth_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = PVAddSynth_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = PVAddSynth_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = PVAddSynth_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = PVAddSynth_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = PVAddSynth_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = PVAddSynth_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = PVAddSynth_postprocessing_revareva;
break;
}
@@ -1021,7 +1017,7 @@ PVAddSynth_setProcMode(PVAddSynth *self)
static void
PVAddSynth_compute_next_data_frame(PVAddSynth *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1036,7 +1032,7 @@ PVAddSynth_traverse(PVAddSynth *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PVAddSynth_clear(PVAddSynth *self)
{
pyo_CLEAR
@@ -1082,16 +1078,13 @@ PVAddSynth_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVAddSynth_setProcMode;
static char *kwlist[] = {"input", "pitch", "num", "first", "inc", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OiiiOO", kwlist, &inputtmp, &pitchtmp, &self->num, &self->first, &self->inc, &multmp, &addtmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVAddSynth \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVAddSynth must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -1107,11 +1100,11 @@ PVAddSynth_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (pitchtmp) {
PyObject_CallMethod((PyObject *)self, "setPitch", "O", pitchtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
@@ -1122,7 +1115,7 @@ PVAddSynth_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<8192; i++)
self->table[i] = (MYFLT)(MYSIN(TWOPI * i / 8192.0));
self->table[8192] = 0.0;
-
+
PVAddSynth_realloc_memories(self);
(*self->mode_func_ptr)(self);
@@ -1137,9 +1130,8 @@ PVAddSynth_setInput(PVAddSynth *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVAddSynth \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVAddSynth must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -1149,23 +1141,23 @@ PVAddSynth_setInput(PVAddSynth *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVAddSynth_setPitch(PVAddSynth *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pitch);
@@ -1181,16 +1173,16 @@ PVAddSynth_setPitch(PVAddSynth *self, PyObject *arg)
self->pitch_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
PVAddSynth_setNum(PVAddSynth *self, PyObject *arg)
-{
+{
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->num = PyInt_AsLong(arg);
if (self->num < 1)
@@ -1198,15 +1190,15 @@ PVAddSynth_setNum(PVAddSynth *self, PyObject *arg)
else if (self->num > self->hsize)
self->num = self->hsize;
self->update = 1;
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
PVAddSynth_setFirst(PVAddSynth *self, PyObject *arg)
-{
+{
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->first = PyInt_AsLong(arg);
if (self->first < 0)
@@ -1214,15 +1206,15 @@ PVAddSynth_setFirst(PVAddSynth *self, PyObject *arg)
else if (self->first > self->hsize)
self->first = self->hsize;
self->update = 1;
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
PVAddSynth_setInc(PVAddSynth *self, PyObject *arg)
-{
+{
if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->inc = PyInt_AsLong(arg);
if (self->inc < 1)
@@ -1230,18 +1222,18 @@ PVAddSynth_setInc(PVAddSynth *self, PyObject *arg)
else if (self->inc > self->hsize)
self->inc = self->hsize;
self->update = 1;
- }
-
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject * PVAddSynth_getServer(PVAddSynth* self) { GET_SERVER };
static PyObject * PVAddSynth_getStream(PVAddSynth* self) { GET_STREAM };
-static PyObject * PVAddSynth_setMul(PVAddSynth *self, PyObject *arg) { SET_MUL };
-static PyObject * PVAddSynth_setAdd(PVAddSynth *self, PyObject *arg) { SET_ADD };
-static PyObject * PVAddSynth_setSub(PVAddSynth *self, PyObject *arg) { SET_SUB };
-static PyObject * PVAddSynth_setDiv(PVAddSynth *self, PyObject *arg) { SET_DIV };
+static PyObject * PVAddSynth_setMul(PVAddSynth *self, PyObject *arg) { SET_MUL };
+static PyObject * PVAddSynth_setAdd(PVAddSynth *self, PyObject *arg) { SET_ADD };
+static PyObject * PVAddSynth_setSub(PVAddSynth *self, PyObject *arg) { SET_SUB };
+static PyObject * PVAddSynth_setDiv(PVAddSynth *self, PyObject *arg) { SET_DIV };
static PyObject * PVAddSynth_play(PVAddSynth *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * PVAddSynth_out(PVAddSynth *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1396,14 +1388,14 @@ PVTranspose_realloc_memories(PVTranspose *self) {
self->hopsize = self->size / self->olaps;
inputLatency = self->size - self->hopsize;
self->overcount = 0;
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -1492,24 +1484,24 @@ PVTranspose_process_a(PVTranspose *self) {
static void
PVTranspose_setProcMode(PVTranspose *self)
-{
+{
int procmode;
procmode = self->modebuffer[0];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVTranspose_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVTranspose_process_a;
break;
- }
+ }
}
static void
PVTranspose_compute_next_data_frame(PVTranspose *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -1519,20 +1511,20 @@ PVTranspose_traverse(PVTranspose *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->pv_stream);
- Py_VISIT(self->transpo);
- Py_VISIT(self->transpo_stream);
+ Py_VISIT(self->transpo);
+ Py_VISIT(self->transpo_stream);
return 0;
}
-static int
+static int
PVTranspose_clear(PVTranspose *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->pv_stream);
- Py_CLEAR(self->transpo);
- Py_CLEAR(self->transpo_stream);
+ Py_CLEAR(self->transpo);
+ Py_CLEAR(self->transpo_stream);
return 0;
}
@@ -1568,16 +1560,13 @@ PVTranspose_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVTranspose_setProcMode;
static char *kwlist[] = {"input", "transpo", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|O", kwlist, &inputtmp, &transpotmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVTranspose \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVTranspose must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -1593,7 +1582,7 @@ PVTranspose_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (transpotmp) {
PyObject_CallMethod((PyObject *)self, "setTranspo", "O", transpotmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -1621,9 +1610,8 @@ PVTranspose_setInput(PVTranspose *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVTranspose \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVTranspose must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -1633,23 +1621,23 @@ PVTranspose_setInput(PVTranspose *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVTranspose_setTranspo(PVTranspose *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->transpo);
@@ -1665,9 +1653,9 @@ PVTranspose_setTranspo(PVTranspose *self, PyObject *arg)
self->transpo_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1752,6 +1740,7 @@ typedef struct {
int hopsize;
int overcount;
MYFLT *l_magn;
+ MYFLT *l_freq;
MYFLT **magn;
MYFLT **freq;
int *count;
@@ -1765,9 +1754,10 @@ PVVerb_realloc_memories(PVVerb *self) {
self->hopsize = self->size / self->olaps;
inputLatency = self->size - self->hopsize;
self->overcount = 0;
- self->l_magn = (MYFLT *)realloc(self->l_magn, self->hsize * sizeof(MYFLT));
+ self->l_magn = (MYFLT *)realloc(self->l_magn, self->hsize * sizeof(MYFLT));
+ self->l_freq = (MYFLT *)realloc(self->l_freq, self->hsize * sizeof(MYFLT));
for (i=0; i<self->hsize; i++)
- self->l_magn[i] = 0.0;
+ self->l_magn[i] = self->l_freq[i] = 0.0;
self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
@@ -1775,7 +1765,7 @@ PVVerb_realloc_memories(PVVerb *self) {
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -1788,7 +1778,7 @@ PVVerb_realloc_memories(PVVerb *self) {
static void
PVVerb_process_ii(PVVerb *self) {
int i, k;
- MYFLT revtime, damp, mag, amp;
+ MYFLT revtime, damp, mag, amp, fre;
MYFLT **magn = PVStream_getMagn((PVStream *)self->input_stream);
MYFLT **freq = PVStream_getFreq((PVStream *)self->input_stream);
int *count = PVStream_getCount((PVStream *)self->input_stream);
@@ -1819,11 +1809,15 @@ PVVerb_process_ii(PVVerb *self) {
amp = 1.0;
for (k=0; k<self->hsize; k++) {
mag = magn[self->overcount][k];
- if (mag > self->l_magn[k])
+ fre = freq[self->overcount][k];
+ if (mag > self->l_magn[k]) {
self->magn[self->overcount][k] = self->l_magn[k] = mag;
- else
+ self->freq[self->overcount][k] = self->l_freq[k] = fre;
+ }
+ else {
self->magn[self->overcount][k] = self->l_magn[k] = mag + (self->l_magn[k] - mag) * revtime * amp;
- self->freq[self->overcount][k] = freq[self->overcount][k];
+ self->freq[self->overcount][k] = self->l_freq[k] = fre + (self->l_freq[k] - fre) * revtime * amp;
+ }
amp *= damp;
}
self->overcount++;
@@ -1836,7 +1830,7 @@ PVVerb_process_ii(PVVerb *self) {
static void
PVVerb_process_ai(PVVerb *self) {
int i, k;
- MYFLT revtime, damp, mag, amp;
+ MYFLT revtime, damp, mag, amp, fre;
MYFLT **magn = PVStream_getMagn((PVStream *)self->input_stream);
MYFLT **freq = PVStream_getFreq((PVStream *)self->input_stream);
int *count = PVStream_getCount((PVStream *)self->input_stream);
@@ -1868,11 +1862,15 @@ PVVerb_process_ai(PVVerb *self) {
amp = 1.0;
for (k=0; k<self->hsize; k++) {
mag = magn[self->overcount][k];
- if (mag > self->l_magn[k])
+ fre = freq[self->overcount][k];
+ if (mag > self->l_magn[k]) {
self->magn[self->overcount][k] = self->l_magn[k] = mag;
- else
+ self->freq[self->overcount][k] = self->l_freq[k] = fre;
+ }
+ else {
self->magn[self->overcount][k] = self->l_magn[k] = mag + (self->l_magn[k] - mag) * revtime * amp;
- self->freq[self->overcount][k] = freq[self->overcount][k];
+ self->freq[self->overcount][k] = self->l_freq[k] = fre + (self->l_freq[k] - fre) * revtime * amp;
+ }
amp *= damp;
}
self->overcount++;
@@ -1885,7 +1883,7 @@ PVVerb_process_ai(PVVerb *self) {
static void
PVVerb_process_ia(PVVerb *self) {
int i, k;
- MYFLT revtime, damp, mag, amp;
+ MYFLT revtime, damp, mag, amp, fre;
MYFLT **magn = PVStream_getMagn((PVStream *)self->input_stream);
MYFLT **freq = PVStream_getFreq((PVStream *)self->input_stream);
int *count = PVStream_getCount((PVStream *)self->input_stream);
@@ -1917,11 +1915,15 @@ PVVerb_process_ia(PVVerb *self) {
amp = 1.0;
for (k=0; k<self->hsize; k++) {
mag = magn[self->overcount][k];
- if (mag > self->l_magn[k])
+ fre = freq[self->overcount][k];
+ if (mag > self->l_magn[k]) {
self->magn[self->overcount][k] = self->l_magn[k] = mag;
- else
+ self->freq[self->overcount][k] = self->l_freq[k] = fre;
+ }
+ else {
self->magn[self->overcount][k] = self->l_magn[k] = mag + (self->l_magn[k] - mag) * revtime * amp;
- self->freq[self->overcount][k] = freq[self->overcount][k];
+ self->freq[self->overcount][k] = self->l_freq[k] = fre + (self->l_freq[k] - fre) * revtime * amp;
+ }
amp *= damp;
}
self->overcount++;
@@ -1934,7 +1936,7 @@ PVVerb_process_ia(PVVerb *self) {
static void
PVVerb_process_aa(PVVerb *self) {
int i, k;
- MYFLT revtime, damp, mag, amp;
+ MYFLT revtime, damp, mag, amp, fre;
MYFLT **magn = PVStream_getMagn((PVStream *)self->input_stream);
MYFLT **freq = PVStream_getFreq((PVStream *)self->input_stream);
int *count = PVStream_getCount((PVStream *)self->input_stream);
@@ -1967,11 +1969,15 @@ PVVerb_process_aa(PVVerb *self) {
amp = 1.0;
for (k=0; k<self->hsize; k++) {
mag = magn[self->overcount][k];
- if (mag > self->l_magn[k])
+ fre = freq[self->overcount][k];
+ if (mag > self->l_magn[k]) {
self->magn[self->overcount][k] = self->l_magn[k] = mag;
- else
+ self->freq[self->overcount][k] = self->l_freq[k] = fre;
+ }
+ else {
self->magn[self->overcount][k] = self->l_magn[k] = mag + (self->l_magn[k] - mag) * revtime * amp;
- self->freq[self->overcount][k] = freq[self->overcount][k];
+ self->freq[self->overcount][k] = self->l_freq[k] = fre + (self->l_freq[k] - fre) * revtime * amp;
+ }
amp *= damp;
}
self->overcount++;
@@ -1983,30 +1989,30 @@ PVVerb_process_aa(PVVerb *self) {
static void
PVVerb_setProcMode(PVVerb *self)
-{
+{
int procmode;
procmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVVerb_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVVerb_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = PVVerb_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = PVVerb_process_aa;
break;
- }
+ }
}
static void
PVVerb_compute_next_data_frame(PVVerb *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -2016,24 +2022,24 @@ PVVerb_traverse(PVVerb *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->pv_stream);
- Py_VISIT(self->revtime);
- Py_VISIT(self->revtime_stream);
- Py_VISIT(self->damp);
- Py_VISIT(self->damp_stream);
+ Py_VISIT(self->revtime);
+ Py_VISIT(self->revtime_stream);
+ Py_VISIT(self->damp);
+ Py_VISIT(self->damp_stream);
return 0;
}
-static int
+static int
PVVerb_clear(PVVerb *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->pv_stream);
- Py_CLEAR(self->revtime);
- Py_CLEAR(self->revtime_stream);
- Py_CLEAR(self->damp);
- Py_CLEAR(self->damp_stream);
+ Py_CLEAR(self->revtime);
+ Py_CLEAR(self->revtime_stream);
+ Py_CLEAR(self->damp);
+ Py_CLEAR(self->damp_stream);
return 0;
}
@@ -2049,6 +2055,7 @@ PVVerb_dealloc(PVVerb* self)
free(self->magn);
free(self->freq);
free(self->l_magn);
+ free(self->l_freq);
free(self->count);
PVVerb_clear(self);
self->ob_type->tp_free((PyObject*)self);
@@ -2071,16 +2078,13 @@ PVVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVVerb_setProcMode;
static char *kwlist[] = {"input", "revtime", "damp", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &revtimetmp, &damptmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVVerb \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVVerb must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -2100,7 +2104,7 @@ PVVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (damptmp) {
PyObject_CallMethod((PyObject *)self, "setDamp", "O", damptmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -2128,9 +2132,8 @@ PVVerb_setInput(PVVerb *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVVerb \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVVerb must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -2140,23 +2143,23 @@ PVVerb_setInput(PVVerb *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVVerb_setRevtime(PVVerb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->revtime);
@@ -2172,9 +2175,9 @@ PVVerb_setRevtime(PVVerb *self, PyObject *arg)
self->revtime_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2183,14 +2186,14 @@ static PyObject *
PVVerb_setDamp(PVVerb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->damp);
@@ -2206,9 +2209,9 @@ PVVerb_setDamp(PVVerb *self, PyObject *arg)
self->damp_stream = (Stream *)streamtmp;
self->modebuffer[1] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2314,7 +2317,7 @@ PVGate_realloc_memories(PVGate *self) {
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -2478,30 +2481,30 @@ PVGate_process_aa(PVGate *self) {
static void
PVGate_setProcMode(PVGate *self)
-{
+{
int procmode;
procmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVGate_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVGate_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = PVGate_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = PVGate_process_aa;
break;
- }
+ }
}
static void
PVGate_compute_next_data_frame(PVGate *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -2511,24 +2514,24 @@ PVGate_traverse(PVGate *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->pv_stream);
- Py_VISIT(self->thresh);
- Py_VISIT(self->thresh_stream);
- Py_VISIT(self->damp);
- Py_VISIT(self->damp_stream);
+ Py_VISIT(self->thresh);
+ Py_VISIT(self->thresh_stream);
+ Py_VISIT(self->damp);
+ Py_VISIT(self->damp_stream);
return 0;
}
-static int
+static int
PVGate_clear(PVGate *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->pv_stream);
- Py_CLEAR(self->thresh);
- Py_CLEAR(self->thresh_stream);
- Py_CLEAR(self->damp);
- Py_CLEAR(self->damp_stream);
+ Py_CLEAR(self->thresh);
+ Py_CLEAR(self->thresh_stream);
+ Py_CLEAR(self->damp);
+ Py_CLEAR(self->damp_stream);
return 0;
}
@@ -2565,16 +2568,13 @@ PVGate_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVGate_setProcMode;
static char *kwlist[] = {"input", "thresh", "damp", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &threshtmp, &damptmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVGate \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVGate must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -2594,7 +2594,7 @@ PVGate_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (damptmp) {
PyObject_CallMethod((PyObject *)self, "setDamp", "O", damptmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -2622,9 +2622,8 @@ PVGate_setInput(PVGate *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVGate \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVGate must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -2634,23 +2633,23 @@ PVGate_setInput(PVGate *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVGate_setThresh(PVGate *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->thresh);
@@ -2666,9 +2665,9 @@ PVGate_setThresh(PVGate *self, PyObject *arg)
self->thresh_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2677,14 +2676,14 @@ static PyObject *
PVGate_setDamp(PVGate *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->damp);
@@ -2700,9 +2699,9 @@ PVGate_setDamp(PVGate *self, PyObject *arg)
self->damp_stream = (Stream *)streamtmp;
self->modebuffer[1] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2801,14 +2800,14 @@ PVCross_realloc_memories(PVCross *self) {
self->hopsize = self->size / self->olaps;
inputLatency = self->size - self->hopsize;
self->overcount = 0;
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -2885,24 +2884,24 @@ PVCross_process_a(PVCross *self) {
static void
PVCross_setProcMode(PVCross *self)
-{
+{
int procmode;
procmode = self->modebuffer[0];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVCross_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVCross_process_a;
break;
- }
+ }
}
static void
PVCross_compute_next_data_frame(PVCross *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -2914,12 +2913,12 @@ PVCross_traverse(PVCross *self, visitproc visit, void *arg)
Py_VISIT(self->input2);
Py_VISIT(self->input2_stream);
Py_VISIT(self->pv_stream);
- Py_VISIT(self->fade);
- Py_VISIT(self->fade_stream);
+ Py_VISIT(self->fade);
+ Py_VISIT(self->fade_stream);
return 0;
}
-static int
+static int
PVCross_clear(PVCross *self)
{
pyo_CLEAR
@@ -2928,8 +2927,8 @@ PVCross_clear(PVCross *self)
Py_CLEAR(self->input2);
Py_CLEAR(self->input2_stream);
Py_CLEAR(self->pv_stream);
- Py_CLEAR(self->fade);
- Py_CLEAR(self->fade_stream);
+ Py_CLEAR(self->fade);
+ Py_CLEAR(self->fade_stream);
return 0;
}
@@ -2965,16 +2964,13 @@ PVCross_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVCross_setProcMode;
static char *kwlist[] = {"input", "input2", "fade", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|O", kwlist, &inputtmp, &input2tmp, &fadetmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVCross \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVCross must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -2985,11 +2981,8 @@ PVCross_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->input_stream = (PVStream *)input_streamtmp;
if ( PyObject_HasAttrString((PyObject *)input2tmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVCross \"input2\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input2\" argument of PVCross must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(input2tmp);
Py_XDECREF(self->input2);
@@ -3005,7 +2998,7 @@ PVCross_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (fadetmp) {
PyObject_CallMethod((PyObject *)self, "setFade", "O", fadetmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -3033,9 +3026,8 @@ PVCross_setInput(PVCross *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVCross \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVCross must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -3045,10 +3037,10 @@ PVCross_setInput(PVCross *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVCross_setInput2(PVCross *self, PyObject *arg)
@@ -3057,9 +3049,8 @@ PVCross_setInput2(PVCross *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVCross \"input2\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input2\" argument of PVCross must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -3069,23 +3060,23 @@ PVCross_setInput2(PVCross *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVCross_setFade(PVCross *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->fade);
@@ -3101,9 +3092,9 @@ PVCross_setFade(PVCross *self, PyObject *arg)
self->fade_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3199,14 +3190,14 @@ PVMult_realloc_memories(PVMult *self) {
self->hopsize = self->size / self->olaps;
inputLatency = self->size - self->hopsize;
self->overcount = 0;
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -3255,7 +3246,7 @@ PVMult_setProcMode(PVMult *self)
static void
PVMult_compute_next_data_frame(PVMult *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -3270,7 +3261,7 @@ PVMult_traverse(PVMult *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PVMult_clear(PVMult *self)
{
pyo_CLEAR
@@ -3313,16 +3304,13 @@ PVMult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVMult_setProcMode;
static char *kwlist[] = {"input", "input2", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &inputtmp, &input2tmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMult \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVMult must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -3333,11 +3321,8 @@ PVMult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->input_stream = (PVStream *)input_streamtmp;
if ( PyObject_HasAttrString((PyObject *)input2tmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMult \"input2\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input2\" argument of PVMult must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(input2tmp);
Py_XDECREF(self->input2);
@@ -3349,7 +3334,7 @@ PVMult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->size = PVStream_getFFTsize(self->input_stream);
self->olaps = PVStream_getOlaps(self->input_stream);
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -3377,9 +3362,8 @@ PVMult_setInput(PVMult *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMult \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVMult must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -3389,10 +3373,10 @@ PVMult_setInput(PVMult *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVMult_setInput2(PVMult *self, PyObject *arg)
@@ -3401,9 +3385,8 @@ PVMult_setInput2(PVMult *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMult \"input2\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input2\" argument of PVMult must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -3413,10 +3396,10 @@ PVMult_setInput2(PVMult *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef PVMult_members[] = {
{"server", T_OBJECT_EX, offsetof(PVMult, server), 0, "Pyo server."},
@@ -3510,14 +3493,14 @@ PVMorph_realloc_memories(PVMorph *self) {
self->hopsize = self->size / self->olaps;
inputLatency = self->size - self->hopsize;
self->overcount = 0;
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -3604,24 +3587,24 @@ PVMorph_process_a(PVMorph *self) {
static void
PVMorph_setProcMode(PVMorph *self)
-{
+{
int procmode;
procmode = self->modebuffer[0];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVMorph_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVMorph_process_a;
break;
- }
+ }
}
static void
PVMorph_compute_next_data_frame(PVMorph *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -3633,12 +3616,12 @@ PVMorph_traverse(PVMorph *self, visitproc visit, void *arg)
Py_VISIT(self->input2);
Py_VISIT(self->input2_stream);
Py_VISIT(self->pv_stream);
- Py_VISIT(self->fade);
- Py_VISIT(self->fade_stream);
+ Py_VISIT(self->fade);
+ Py_VISIT(self->fade_stream);
return 0;
}
-static int
+static int
PVMorph_clear(PVMorph *self)
{
pyo_CLEAR
@@ -3647,8 +3630,8 @@ PVMorph_clear(PVMorph *self)
Py_CLEAR(self->input2);
Py_CLEAR(self->input2_stream);
Py_CLEAR(self->pv_stream);
- Py_CLEAR(self->fade);
- Py_CLEAR(self->fade_stream);
+ Py_CLEAR(self->fade);
+ Py_CLEAR(self->fade_stream);
return 0;
}
@@ -3684,16 +3667,13 @@ PVMorph_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVMorph_setProcMode;
static char *kwlist[] = {"input", "input2", "fade", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|O", kwlist, &inputtmp, &input2tmp, &fadetmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMorph \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVMorph must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -3704,11 +3684,8 @@ PVMorph_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->input_stream = (PVStream *)input_streamtmp;
if ( PyObject_HasAttrString((PyObject *)input2tmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMorph \"input2\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input2\" argument of PVMorph must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(input2tmp);
Py_XDECREF(self->input2);
@@ -3724,7 +3701,7 @@ PVMorph_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (fadetmp) {
PyObject_CallMethod((PyObject *)self, "setFade", "O", fadetmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -3752,9 +3729,8 @@ PVMorph_setInput(PVMorph *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMorph \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVMorph must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -3764,10 +3740,10 @@ PVMorph_setInput(PVMorph *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVMorph_setInput2(PVMorph *self, PyObject *arg)
@@ -3776,9 +3752,8 @@ PVMorph_setInput2(PVMorph *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMorph \"input2\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input2\" argument of PVMorph must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -3788,23 +3763,23 @@ PVMorph_setInput2(PVMorph *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVMorph_setFade(PVMorph *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->fade);
@@ -3820,9 +3795,9 @@ PVMorph_setFade(PVMorph *self, PyObject *arg)
self->fade_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3921,14 +3896,14 @@ PVFilter_realloc_memories(PVFilter *self) {
self->hopsize = self->size / self->olaps;
inputLatency = self->size - self->hopsize;
self->overcount = 0;
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -4014,7 +3989,7 @@ PVFilter_process_a(PVFilter *self) {
}
factor = (MYFLT)tsize / self->hsize;
-
+
for (i=0; i<self->bufsize; i++) {
self->count[i] = count[i];
if (count[i] >= (self->size-1)) {
@@ -4053,24 +4028,24 @@ PVFilter_process_a(PVFilter *self) {
static void
PVFilter_setProcMode(PVFilter *self)
-{
+{
int procmode;
procmode = self->modebuffer[0];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVFilter_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVFilter_process_a;
break;
- }
+ }
}
static void
PVFilter_compute_next_data_frame(PVFilter *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -4080,21 +4055,21 @@ PVFilter_traverse(PVFilter *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->pv_stream);
- Py_VISIT(self->gain);
- Py_VISIT(self->gain_stream);
+ Py_VISIT(self->gain);
+ Py_VISIT(self->gain_stream);
Py_VISIT(self->table);
return 0;
}
-static int
+static int
PVFilter_clear(PVFilter *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->pv_stream);
- Py_CLEAR(self->gain);
- Py_CLEAR(self->gain_stream);
+ Py_CLEAR(self->gain);
+ Py_CLEAR(self->gain_stream);
Py_CLEAR(self->table);
return 0;
}
@@ -4126,23 +4101,20 @@ PVFilter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->gain = PyFloat_FromDouble(1);
self->size = 1024;
self->olaps = 4;
- self->mode = 0; /* 0 : index outside table range clipped to 0
+ self->mode = 0; /* 0 : index outside table range clipped to 0
1 : index between 0 and hsize are scaled over table length */
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, PVFilter_compute_next_data_frame);
self->mode_func_ptr = PVFilter_setProcMode;
static char *kwlist[] = {"input", "table", "gain", "mode", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|Oi", kwlist, &inputtmp, &tabletmp, &gaintmp, &self->mode))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVFilter \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVFilter must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -4161,7 +4133,7 @@ PVFilter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (gaintmp) {
PyObject_CallMethod((PyObject *)self, "setGain", "O", gaintmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -4189,9 +4161,8 @@ PVFilter_setInput(PVFilter *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVFilter \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVFilter must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -4201,23 +4172,23 @@ PVFilter_setInput(PVFilter *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVFilter_setGain(PVFilter *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->gain);
@@ -4233,9 +4204,9 @@ PVFilter_setGain(PVFilter *self, PyObject *arg)
self->gain_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -4251,7 +4222,7 @@ static PyObject *
PVFilter_setTable(PVFilter *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
@@ -4260,10 +4231,10 @@ PVFilter_setTable(PVFilter *self, PyObject *arg)
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVFilter_setMode(PVFilter *self, PyObject *arg)
@@ -4277,10 +4248,10 @@ PVFilter_setMode(PVFilter *self, PyObject *arg)
else
self->mode = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef PVFilter_members[] = {
{"server", T_OBJECT_EX, offsetof(PVFilter, server), 0, "Pyo server."},
@@ -4383,22 +4354,22 @@ PVDelay_realloc_memories(PVDelay *self) {
self->numFrames = (int)(self->maxdelay * self->sr / self->hopsize + 0.5);
self->overcount = 0;
self->framecount = 0;
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
- self->magn_buf = (MYFLT **)realloc(self->magn_buf, self->numFrames * sizeof(MYFLT *));
+ }
+ self->magn_buf = (MYFLT **)realloc(self->magn_buf, self->numFrames * sizeof(MYFLT *));
self->freq_buf = (MYFLT **)realloc(self->freq_buf, self->numFrames * sizeof(MYFLT *));
for (i=0; i<self->numFrames; i++) {
self->magn_buf[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq_buf[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn_buf[i][j] = self->freq_buf[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -4543,7 +4514,7 @@ PVDelay_process_scaled(PVDelay *self) {
static void
PVDelay_setProcMode(PVDelay *self)
-{
+{
if (self->mode == 0)
self->proc_func_ptr = PVDelay_process_zero;
else
@@ -4553,7 +4524,7 @@ PVDelay_setProcMode(PVDelay *self)
static void
PVDelay_compute_next_data_frame(PVDelay *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -4568,7 +4539,7 @@ PVDelay_traverse(PVDelay *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PVDelay_clear(PVDelay *self)
{
pyo_CLEAR
@@ -4619,16 +4590,13 @@ PVDelay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVDelay_setProcMode;
static char *kwlist[] = {"input", "deltable", "feedtable", "maxdelay", "mode", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_OOO_FI, kwlist, &inputtmp, &deltabletmp, &feedtabletmp, &self->maxdelay, &self->mode))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVDelay \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVDelay must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -4646,7 +4614,7 @@ PVDelay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_XDECREF(self->feedtable);
self->feedtable = PyObject_CallMethod((PyObject *)feedtabletmp, "getTableStream", "");
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -4675,9 +4643,8 @@ PVDelay_setInput(PVDelay *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVDelay \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVDelay must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -4687,10 +4654,10 @@ PVDelay_setInput(PVDelay *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVDelay_getDeltable(PVDelay* self)
@@ -4703,7 +4670,7 @@ static PyObject *
PVDelay_setDeltable(PVDelay *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
@@ -4712,10 +4679,10 @@ PVDelay_setDeltable(PVDelay *self, PyObject *arg)
tmp = arg;
Py_DECREF(self->deltable);
self->deltable = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVDelay_getFeedtable(PVDelay* self)
@@ -4728,7 +4695,7 @@ static PyObject *
PVDelay_setFeedtable(PVDelay *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
@@ -4737,10 +4704,10 @@ PVDelay_setFeedtable(PVDelay *self, PyObject *arg)
tmp = arg;
Py_DECREF(self->feedtable);
self->feedtable = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVDelay_setMode(PVDelay *self, PyObject *arg)
@@ -4756,10 +4723,10 @@ PVDelay_setMode(PVDelay *self, PyObject *arg)
}
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef PVDelay_members[] = {
{"server", T_OBJECT_EX, offsetof(PVDelay, server), 0, "Pyo server."},
@@ -4865,22 +4832,22 @@ PVBuffer_realloc_memories(PVBuffer *self) {
self->numFrames = (int)(self->length * self->sr / self->hopsize + 0.5);
self->overcount = 0;
self->framecount = 0;
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
- self->magn_buf = (MYFLT **)realloc(self->magn_buf, self->numFrames * sizeof(MYFLT *));
+ }
+ self->magn_buf = (MYFLT **)realloc(self->magn_buf, self->numFrames * sizeof(MYFLT *));
self->freq_buf = (MYFLT **)realloc(self->freq_buf, self->numFrames * sizeof(MYFLT *));
for (i=0; i<self->numFrames; i++) {
self->magn_buf[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq_buf[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn_buf[i][j] = self->freq_buf[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -4997,15 +4964,15 @@ PVBuffer_process_a(PVBuffer *self) {
static void
PVBuffer_setProcMode(PVBuffer *self)
-{
+{
int procmode;
procmode = self->modebuffer[0];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVBuffer_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVBuffer_process_a;
break;
} }
@@ -5013,7 +4980,7 @@ PVBuffer_setProcMode(PVBuffer *self)
static void
PVBuffer_compute_next_data_frame(PVBuffer *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -5030,7 +4997,7 @@ PVBuffer_traverse(PVBuffer *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PVBuffer_clear(PVBuffer *self)
{
pyo_CLEAR
@@ -5074,7 +5041,7 @@ PVBuffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PVBuffer *self;
self = (PVBuffer *)type->tp_alloc(type, 0);
- self->pitch = PyFloat_FromDouble(1);
+ self->pitch = PyFloat_FromDouble(1);
self->size = 1024;
self->olaps = 4;
self->length = 1.0;
@@ -5083,16 +5050,13 @@ PVBuffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVBuffer_setProcMode;
static char *kwlist[] = {"input", "index", "pitch", "length", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_OO_OF, kwlist, &inputtmp, &indextmp, &pitchtmp, &self->length))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVBuffer \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVBuffer must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -5112,7 +5076,7 @@ PVBuffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (pitchtmp) {
PyObject_CallMethod((PyObject *)self, "setPitch", "O", pitchtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -5130,9 +5094,9 @@ static PyObject * PVBuffer_getServer(PVBuffer* self) { GET_SERVER };
static PyObject * PVBuffer_getStream(PVBuffer* self) { GET_STREAM };
static PyObject * PVBuffer_getPVStream(PVBuffer* self) { GET_PV_STREAM };
-static PyObject * PVBuffer_play(PVBuffer *self, PyObject *args, PyObject *kwds) {
+static PyObject * PVBuffer_play(PVBuffer *self, PyObject *args, PyObject *kwds) {
self->framecount = 0;
- PLAY
+ PLAY
};
static PyObject * PVBuffer_stop(PVBuffer *self) { STOP };
@@ -5144,9 +5108,8 @@ PVBuffer_setInput(PVBuffer *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVBuffer \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVBuffer must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -5156,31 +5119,27 @@ PVBuffer_setInput(PVBuffer *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVBuffer_setIndex(PVBuffer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- int isNumber = PyNumber_Check(arg);
- if (isNumber == 1) {
- PySys_WriteStderr("TypeError: \"index\" attribute of PVBuffer must be a PyoObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
- }
-
+
tmp = arg;
+ if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
+ PyErr_SetString(PyExc_TypeError, "\"index\" argument of PVBuffer must be a PyoObject.\n");
+ Py_RETURN_NONE;
+ }
+
Py_INCREF(tmp);
Py_XDECREF(self->index);
@@ -5189,23 +5148,23 @@ PVBuffer_setIndex(PVBuffer *self, PyObject *arg)
Py_INCREF(streamtmp);
Py_XDECREF(self->index_stream);
self->index_stream = (Stream *)streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVBuffer_setPitch(PVBuffer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->pitch);
@@ -5221,12 +5180,12 @@ PVBuffer_setPitch(PVBuffer *self, PyObject *arg)
self->pitch_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef PVBuffer_members[] = {
{"server", T_OBJECT_EX, offsetof(PVBuffer, server), 0, "Pyo server."},
@@ -5320,14 +5279,14 @@ PVShift_realloc_memories(PVShift *self) {
self->hopsize = self->size / self->olaps;
inputLatency = self->size - self->hopsize;
self->overcount = 0;
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -5420,24 +5379,24 @@ PVShift_process_a(PVShift *self) {
static void
PVShift_setProcMode(PVShift *self)
-{
+{
int procmode;
procmode = self->modebuffer[0];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVShift_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVShift_process_a;
break;
- }
+ }
}
static void
PVShift_compute_next_data_frame(PVShift *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -5447,20 +5406,20 @@ PVShift_traverse(PVShift *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->pv_stream);
- Py_VISIT(self->shift);
- Py_VISIT(self->shift_stream);
+ Py_VISIT(self->shift);
+ Py_VISIT(self->shift_stream);
return 0;
}
-static int
+static int
PVShift_clear(PVShift *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->pv_stream);
- Py_CLEAR(self->shift);
- Py_CLEAR(self->shift_stream);
+ Py_CLEAR(self->shift);
+ Py_CLEAR(self->shift_stream);
return 0;
}
@@ -5496,16 +5455,13 @@ PVShift_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVShift_setProcMode;
static char *kwlist[] = {"input", "shift", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|O", kwlist, &inputtmp, &shifttmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVShift \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVShift must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -5521,7 +5477,7 @@ PVShift_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (shifttmp) {
PyObject_CallMethod((PyObject *)self, "setShift", "O", shifttmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -5549,9 +5505,8 @@ PVShift_setInput(PVShift *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVShift \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVShift must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -5561,23 +5516,23 @@ PVShift_setInput(PVShift *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVShift_setShift(PVShift *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->shift);
@@ -5593,9 +5548,9 @@ PVShift_setShift(PVShift *self, PyObject *arg)
self->shift_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -5696,7 +5651,7 @@ PVAmpMod_realloc_memories(PVAmpMod *self) {
inputLatency = self->size - self->hopsize;
self->overcount = 0;
self->factor = 8192.0 / (self->sr / self->hopsize);
- self->pointers = (MYFLT *)realloc(self->pointers, self->hsize * sizeof(MYFLT));
+ self->pointers = (MYFLT *)realloc(self->pointers, self->hsize * sizeof(MYFLT));
for (i=0; i<self->hsize; i++)
self->pointers[i] = 0.0;
self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
@@ -5706,7 +5661,7 @@ PVAmpMod_realloc_memories(PVAmpMod *self) {
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -5728,7 +5683,7 @@ PVAmpMod_process_ii(PVAmpMod *self) {
bfreq = PyFloat_AS_DOUBLE(self->basefreq);
spread = PyFloat_AS_DOUBLE(self->spread);
spread *= 0.001;
- spread += 1.0;
+ spread += 1.0;
if (self->size != size || self->olaps != olaps) {
self->size = size;
@@ -5769,7 +5724,7 @@ PVAmpMod_process_ai(PVAmpMod *self) {
MYFLT *bf = Stream_getData((Stream *)self->basefreq_stream);
spread = PyFloat_AS_DOUBLE(self->spread);
spread *= 0.001;
- spread += 1.0;
+ spread += 1.0;
if (self->size != size || self->olaps != olaps) {
self->size = size;
@@ -5822,7 +5777,7 @@ PVAmpMod_process_ia(PVAmpMod *self) {
if (count[i] >= (self->size-1)) {
spread = sp[i];
spread *= 0.001;
- spread += 1.0;
+ spread += 1.0;
for (k=0; k<self->hsize; k++) {
pos = self->pointers[k];
self->magn[self->overcount][k] = magn[self->overcount][k] * self->table[(int)pos];
@@ -5865,7 +5820,7 @@ PVAmpMod_process_aa(PVAmpMod *self) {
bfreq = bf[i];
spread = sp[i];
spread *= 0.001;
- spread += 1.0;
+ spread += 1.0;
for (k=0; k<self->hsize; k++) {
pos = self->pointers[k];
self->magn[self->overcount][k] = magn[self->overcount][k] * self->table[(int)pos];
@@ -5886,30 +5841,30 @@ PVAmpMod_process_aa(PVAmpMod *self) {
static void
PVAmpMod_setProcMode(PVAmpMod *self)
-{
+{
int procmode;
procmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVAmpMod_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVAmpMod_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = PVAmpMod_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = PVAmpMod_process_aa;
break;
- }
+ }
}
static void
PVAmpMod_compute_next_data_frame(PVAmpMod *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -5919,24 +5874,24 @@ PVAmpMod_traverse(PVAmpMod *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->pv_stream);
- Py_VISIT(self->basefreq);
- Py_VISIT(self->basefreq_stream);
- Py_VISIT(self->spread);
- Py_VISIT(self->spread_stream);
+ Py_VISIT(self->basefreq);
+ Py_VISIT(self->basefreq_stream);
+ Py_VISIT(self->spread);
+ Py_VISIT(self->spread_stream);
return 0;
}
-static int
+static int
PVAmpMod_clear(PVAmpMod *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->pv_stream);
- Py_CLEAR(self->basefreq);
- Py_CLEAR(self->basefreq_stream);
- Py_CLEAR(self->spread);
- Py_CLEAR(self->spread_stream);
+ Py_CLEAR(self->basefreq);
+ Py_CLEAR(self->basefreq_stream);
+ Py_CLEAR(self->spread);
+ Py_CLEAR(self->spread_stream);
return 0;
}
@@ -5975,16 +5930,13 @@ PVAmpMod_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVAmpMod_setProcMode;
static char *kwlist[] = {"input", "basefreq", "spread", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &basefreqtmp, &spreadtmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVAmpMod \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVAmpMod must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -6004,7 +5956,7 @@ PVAmpMod_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (spreadtmp) {
PyObject_CallMethod((PyObject *)self, "setSpread", "O", spreadtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -6037,9 +5989,8 @@ PVAmpMod_setInput(PVAmpMod *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVAmpMod \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVAmpMod must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -6049,23 +6000,23 @@ PVAmpMod_setInput(PVAmpMod *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVAmpMod_setBasefreq(PVAmpMod *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->basefreq);
@@ -6081,9 +6032,9 @@ PVAmpMod_setBasefreq(PVAmpMod *self, PyObject *arg)
self->basefreq_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -6092,14 +6043,14 @@ static PyObject *
PVAmpMod_setSpread(PVAmpMod *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->spread);
@@ -6115,9 +6066,9 @@ PVAmpMod_setSpread(PVAmpMod *self, PyObject *arg)
self->spread_stream = (Stream *)streamtmp;
self->modebuffer[1] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -6232,7 +6183,7 @@ PVFreqMod_realloc_memories(PVFreqMod *self) {
inputLatency = self->size - self->hopsize;
self->overcount = 0;
self->factor = 8192.0 / (self->sr / self->hopsize);
- self->pointers = (MYFLT *)realloc(self->pointers, self->hsize * sizeof(MYFLT));
+ self->pointers = (MYFLT *)realloc(self->pointers, self->hsize * sizeof(MYFLT));
for (i=0; i<self->hsize; i++)
self->pointers[i] = 0.0;
self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
@@ -6242,7 +6193,7 @@ PVFreqMod_realloc_memories(PVFreqMod *self) {
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -6264,7 +6215,7 @@ PVFreqMod_process_ii(PVFreqMod *self) {
bfreq = PyFloat_AS_DOUBLE(self->basefreq);
spread = PyFloat_AS_DOUBLE(self->spread);
spread *= 0.001;
- spread += 1.0;
+ spread += 1.0;
if (self->modebuffer[2] == 0)
depth = PyFloat_AS_DOUBLE(self->depth);
@@ -6322,7 +6273,7 @@ PVFreqMod_process_ai(PVFreqMod *self) {
MYFLT *bf = Stream_getData((Stream *)self->basefreq_stream);
spread = PyFloat_AS_DOUBLE(self->spread);
spread *= 0.001;
- spread += 1.0;
+ spread += 1.0;
if (self->modebuffer[2] == 0)
depth = PyFloat_AS_DOUBLE(self->depth);
@@ -6401,7 +6352,7 @@ PVFreqMod_process_ia(PVFreqMod *self) {
if (count[i] >= (self->size-1)) {
spread = sp[i];
spread *= 0.001;
- spread += 1.0;
+ spread += 1.0;
freqPerBin = self->sr / self->size;
for (k=0; k<self->hsize; k++) {
self->magn[self->overcount][k] = self->freq[self->overcount][k] = 0.0;
@@ -6461,7 +6412,7 @@ PVFreqMod_process_aa(PVFreqMod *self) {
bfreq = bf[i];
spread = sp[i];
spread *= 0.001;
- spread += 1.0;
+ spread += 1.0;
freqPerBin = self->sr / self->size;
for (k=0; k<self->hsize; k++) {
self->magn[self->overcount][k] = self->freq[self->overcount][k] = 0.0;
@@ -6490,30 +6441,30 @@ PVFreqMod_process_aa(PVFreqMod *self) {
static void
PVFreqMod_setProcMode(PVFreqMod *self)
-{
+{
int procmode;
procmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = PVFreqMod_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = PVFreqMod_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = PVFreqMod_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = PVFreqMod_process_aa;
break;
- }
+ }
}
static void
PVFreqMod_compute_next_data_frame(PVFreqMod *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -6523,28 +6474,28 @@ PVFreqMod_traverse(PVFreqMod *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->pv_stream);
- Py_VISIT(self->basefreq);
- Py_VISIT(self->basefreq_stream);
- Py_VISIT(self->spread);
- Py_VISIT(self->spread_stream);
- Py_VISIT(self->depth);
- Py_VISIT(self->depth_stream);
+ Py_VISIT(self->basefreq);
+ Py_VISIT(self->basefreq_stream);
+ Py_VISIT(self->spread);
+ Py_VISIT(self->spread_stream);
+ Py_VISIT(self->depth);
+ Py_VISIT(self->depth_stream);
return 0;
}
-static int
+static int
PVFreqMod_clear(PVFreqMod *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->pv_stream);
- Py_CLEAR(self->basefreq);
- Py_CLEAR(self->basefreq_stream);
- Py_CLEAR(self->spread);
- Py_CLEAR(self->spread_stream);
- Py_CLEAR(self->depth);
- Py_CLEAR(self->depth_stream);
+ Py_CLEAR(self->basefreq);
+ Py_CLEAR(self->basefreq_stream);
+ Py_CLEAR(self->spread);
+ Py_CLEAR(self->spread_stream);
+ Py_CLEAR(self->depth);
+ Py_CLEAR(self->depth_stream);
return 0;
}
@@ -6584,16 +6535,13 @@ PVFreqMod_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVFreqMod_setProcMode;
static char *kwlist[] = {"input", "basefreq", "spread", "depth", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &basefreqtmp, &spreadtmp, &depthtmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVFreqMod \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVFreqMod must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -6617,7 +6565,7 @@ PVFreqMod_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (depthtmp) {
PyObject_CallMethod((PyObject *)self, "setDepth", "O", depthtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -6650,9 +6598,8 @@ PVFreqMod_setInput(PVFreqMod *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVFreqMod \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVFreqMod must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -6662,23 +6609,23 @@ PVFreqMod_setInput(PVFreqMod *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVFreqMod_setBasefreq(PVFreqMod *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->basefreq);
@@ -6694,9 +6641,9 @@ PVFreqMod_setBasefreq(PVFreqMod *self, PyObject *arg)
self->basefreq_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -6705,14 +6652,14 @@ static PyObject *
PVFreqMod_setSpread(PVFreqMod *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->spread);
@@ -6728,9 +6675,9 @@ PVFreqMod_setSpread(PVFreqMod *self, PyObject *arg)
self->spread_stream = (Stream *)streamtmp;
self->modebuffer[1] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -6739,14 +6686,14 @@ static PyObject *
PVFreqMod_setDepth(PVFreqMod *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->depth);
@@ -6762,9 +6709,9 @@ PVFreqMod_setDepth(PVFreqMod *self, PyObject *arg)
self->depth_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -6896,22 +6843,22 @@ PVBufLoops_realloc_memories(PVBufLoops *self) {
self->speeds[i] = 1.0;
self->pointers[i] = 0.0;
}
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
- self->magn_buf = (MYFLT **)realloc(self->magn_buf, self->numFrames * sizeof(MYFLT *));
+ }
+ self->magn_buf = (MYFLT **)realloc(self->magn_buf, self->numFrames * sizeof(MYFLT *));
self->freq_buf = (MYFLT **)realloc(self->freq_buf, self->numFrames * sizeof(MYFLT *));
for (i=0; i<self->numFrames; i++) {
self->magn_buf[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq_buf[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn_buf[i][j] = self->freq_buf[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -6941,12 +6888,12 @@ PVBufLoops_setSpeeds(PVBufLoops *self, MYFLT low, MYFLT high) {
for (i=0; i<self->hsize; i++)
self->speeds[i] = low + tmp * (1.0 - MYPOW(1.0-(float)i/self->hsize, 3.0));
break;
- case 3: /* random uniform */
+ case 3: /* random uniform */
tmp = high - low;
for (i=0; i<self->hsize; i++)
- self->speeds[i] = RANDOM_UNIFORM * tmp + low;
+ self->speeds[i] = RANDOM_UNIFORM * tmp + low;
break;
- case 4: /* random exponential min */
+ case 4: /* random exponential min */
for (i=0; i<self->hsize; i++) {
tmp = -MYLOG(RANDOM_UNIFORM) * 0.05;
tmp = tmp < 0 ? 0.0 : tmp;
@@ -6954,15 +6901,15 @@ PVBufLoops_setSpeeds(PVBufLoops *self, MYFLT low, MYFLT high) {
self->speeds[i] = tmp * (high - low) + low;
}
break;
- case 5: /* random exponential max */
+ case 5: /* random exponential max */
for (i=0; i<self->hsize; i++) {
tmp = 1.0 - (-MYLOG(RANDOM_UNIFORM) * 0.05);
tmp = tmp < 0 ? 0.0 : tmp;
tmp = tmp > 1.0 ? 1.0 : tmp;
- self->speeds[i] = tmp * (high - low) + low;
+ self->speeds[i] = tmp * (high - low) + low;
}
break;
- case 6: /* random bi-exponential */
+ case 6: /* random bi-exponential */
for (i=0; i<self->hsize; i++) {
tmp = RANDOM_UNIFORM * 2.0;
if (tmp > 1.0)
@@ -6971,7 +6918,7 @@ PVBufLoops_setSpeeds(PVBufLoops *self, MYFLT low, MYFLT high) {
tmp = 0.5 * (MYLOG(tmp) * 0.05) + 0.5;
tmp = tmp < 0 ? 0.0 : tmp;
tmp = tmp > 1.0 ? 1.0 : tmp;
- self->speeds[i] = tmp * (high - low) + low;
+ self->speeds[i] = tmp * (high - low) + low;
}
break;
default: /* linear */
@@ -7049,14 +6996,14 @@ PVBufLoops_process(PVBufLoops *self) {
static void
PVBufLoops_setProcMode(PVBufLoops *self)
-{
+{
self->proc_func_ptr = PVBufLoops_process;
}
static void
PVBufLoops_compute_next_data_frame(PVBufLoops *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -7073,7 +7020,7 @@ PVBufLoops_traverse(PVBufLoops *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PVBufLoops_clear(PVBufLoops *self)
{
pyo_CLEAR
@@ -7123,7 +7070,7 @@ PVBufLoops_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->high = PyFloat_FromDouble(1.0);
self->last_low = self->last_high = -1.0;
self->mode = 0;
- self->last_mode = -1;
+ self->last_mode = -1;
self->size = 1024;
self->olaps = 4;
self->length = 1.0;
@@ -7132,16 +7079,13 @@ PVBufLoops_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVBufLoops_setProcMode;
static char *kwlist[] = {"input", "low", "high", "mode", "length", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OOIF, kwlist, &inputtmp, &lowtmp, &hightmp, &self->mode, &self->length))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVBufLoops \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVBufLoops must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -7161,7 +7105,7 @@ PVBufLoops_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (hightmp) {
PyObject_CallMethod((PyObject *)self, "setHigh", "O", hightmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -7179,12 +7123,12 @@ static PyObject * PVBufLoops_getServer(PVBufLoops* self) { GET_SERVER };
static PyObject * PVBufLoops_getStream(PVBufLoops* self) { GET_STREAM };
static PyObject * PVBufLoops_getPVStream(PVBufLoops* self) { GET_PV_STREAM };
-static PyObject * PVBufLoops_play(PVBufLoops *self, PyObject *args, PyObject *kwds) {
+static PyObject * PVBufLoops_play(PVBufLoops *self, PyObject *args, PyObject *kwds) {
int k;
for (k=0; k<self->hsize; k++)
self->pointers[k] = 0.0;
self->framecount = 0;
- PLAY
+ PLAY
};
static PyObject * PVBufLoops_stop(PVBufLoops *self) { STOP };
@@ -7196,9 +7140,8 @@ PVBufLoops_setInput(PVBufLoops *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVBufLoops \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVBufLoops must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -7208,23 +7151,23 @@ PVBufLoops_setInput(PVBufLoops *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVBufLoops_setLow(PVBufLoops *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->low);
@@ -7243,20 +7186,20 @@ PVBufLoops_setLow(PVBufLoops *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVBufLoops_setHigh(PVBufLoops *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->high);
@@ -7275,7 +7218,7 @@ PVBufLoops_setHigh(PVBufLoops *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVBufLoops_setMode(PVBufLoops *self, PyObject *arg)
@@ -7285,9 +7228,9 @@ PVBufLoops_setMode(PVBufLoops *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 7)
@@ -7296,7 +7239,7 @@ PVBufLoops_setMode(PVBufLoops *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVBufLoops_reset(PVBufLoops *self) {
@@ -7413,22 +7356,22 @@ PVBufTabLoops_realloc_memories(PVBufTabLoops *self) {
for (i=0; i<self->hsize; i++) {
self->pointers[i] = 0.0;
}
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
- self->magn_buf = (MYFLT **)realloc(self->magn_buf, self->numFrames * sizeof(MYFLT *));
+ }
+ self->magn_buf = (MYFLT **)realloc(self->magn_buf, self->numFrames * sizeof(MYFLT *));
self->freq_buf = (MYFLT **)realloc(self->freq_buf, self->numFrames * sizeof(MYFLT *));
for (i=0; i<self->numFrames; i++) {
self->magn_buf[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq_buf[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn_buf[i][j] = self->freq_buf[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -7494,14 +7437,14 @@ PVBufTabLoops_process(PVBufTabLoops *self) {
static void
PVBufTabLoops_setProcMode(PVBufTabLoops *self)
-{
+{
self->proc_func_ptr = PVBufTabLoops_process;
}
static void
PVBufTabLoops_compute_next_data_frame(PVBufTabLoops *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -7515,7 +7458,7 @@ PVBufTabLoops_traverse(PVBufTabLoops *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PVBufTabLoops_clear(PVBufTabLoops *self)
{
pyo_CLEAR
@@ -7565,16 +7508,13 @@ PVBufTabLoops_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVBufTabLoops_setProcMode;
static char *kwlist[] = {"input", "speed", "length", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_OO_F, kwlist, &inputtmp, &speedtmp, &self->length))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVBufTabLoops \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVBufTabLoops must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -7589,7 +7529,7 @@ PVBufTabLoops_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_XDECREF(self->speed);
self->speed = PyObject_CallMethod((PyObject *)speedtmp, "getTableStream", "");
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -7607,12 +7547,12 @@ static PyObject * PVBufTabLoops_getServer(PVBufTabLoops* self) { GET_SERVER };
static PyObject * PVBufTabLoops_getStream(PVBufTabLoops* self) { GET_STREAM };
static PyObject * PVBufTabLoops_getPVStream(PVBufTabLoops* self) { GET_PV_STREAM };
-static PyObject * PVBufTabLoops_play(PVBufTabLoops *self, PyObject *args, PyObject *kwds) {
+static PyObject * PVBufTabLoops_play(PVBufTabLoops *self, PyObject *args, PyObject *kwds) {
int k;
for (k=0; k<self->hsize; k++)
self->pointers[k] = 0.0;
self->framecount = 0;
- PLAY
+ PLAY
};
static PyObject * PVBufTabLoops_stop(PVBufTabLoops *self) { STOP };
@@ -7624,9 +7564,8 @@ PVBufTabLoops_setInput(PVBufTabLoops *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVBufTabLoops \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVBufTabLoops must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -7636,28 +7575,28 @@ PVBufTabLoops_setInput(PVBufTabLoops *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVBufTabLoops_setSpeed(PVBufTabLoops *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->speed);
self->speed = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVBufTabLoops_reset(PVBufTabLoops *self) {
@@ -7758,14 +7697,14 @@ PVMix_realloc_memories(PVMix *self) {
self->hopsize = self->size / self->olaps;
inputLatency = self->size - self->hopsize;
self->overcount = 0;
- self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
+ self->magn = (MYFLT **)realloc(self->magn, self->olaps * sizeof(MYFLT *));
self->freq = (MYFLT **)realloc(self->freq, self->olaps * sizeof(MYFLT *));
for (i=0; i<self->olaps; i++) {
self->magn[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
self->freq[i] = (MYFLT *)malloc(self->hsize * sizeof(MYFLT));
for (j=0; j<self->hsize; j++)
self->magn[i][j] = self->freq[i][j] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++)
self->count[i] = inputLatency;
PVStream_setFFTsize(self->pv_stream, self->size);
@@ -7821,7 +7760,7 @@ PVMix_setProcMode(PVMix *self)
static void
PVMix_compute_next_data_frame(PVMix *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -7836,7 +7775,7 @@ PVMix_traverse(PVMix *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
PVMix_clear(PVMix *self)
{
pyo_CLEAR
@@ -7879,16 +7818,13 @@ PVMix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = PVMix_setProcMode;
static char *kwlist[] = {"input", "input2", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &inputtmp, &input2tmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMix \"input\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVMix must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
Py_XDECREF(self->input);
@@ -7899,11 +7835,8 @@ PVMix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->input_stream = (PVStream *)input_streamtmp;
if ( PyObject_HasAttrString((PyObject *)input2tmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMix \"input2\" argument must be a PyoPVObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"input2\" argument of PVMix must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(input2tmp);
Py_XDECREF(self->input2);
@@ -7915,7 +7848,7 @@ PVMix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->size = PVStream_getFFTsize(self->input_stream);
self->olaps = PVStream_getOlaps(self->input_stream);
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
MAKE_NEW_PV_STREAM(self->pv_stream, &PVStreamType, NULL);
@@ -7943,9 +7876,8 @@ PVMix_setInput(PVMix *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMix \"input\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input\" argument of PVMix must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -7955,10 +7887,10 @@ PVMix_setInput(PVMix *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input_stream);
self->input_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
PVMix_setInput2(PVMix *self, PyObject *arg)
@@ -7967,9 +7899,8 @@ PVMix_setInput2(PVMix *self, PyObject *arg)
inputtmp = arg;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
- PySys_WriteStderr("TypeError: PVMix \"input2\" argument must be a PyoPVObject.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ PyErr_SetString(PyExc_TypeError, "\"input2\" argument of PVMix must be a PyoPVObject.\n");
+ Py_RETURN_NONE;
}
Py_INCREF(inputtmp);
@@ -7979,10 +7910,10 @@ PVMix_setInput2(PVMix *self, PyObject *arg)
Py_INCREF(input_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (PVStream *)input_streamtmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef PVMix_members[] = {
{"server", T_OBJECT_EX, offsetof(PVMix, server), 0, "Pyo server."},
@@ -8044,4 +7975,4 @@ PVMix_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
PVMix_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/randommodule.c b/src/objects/randommodule.c
index b1e4e85..5fccbab 100644
--- a/src/objects/randommodule.c
+++ b/src/objects/randommodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -38,7 +38,7 @@ typedef struct {
MYFLT oldValue;
MYFLT diff;
MYFLT time;
- int modebuffer[5]; // need at least 2 slots for mul & add
+ int modebuffer[5]; // need at least 2 slots for mul & add
} Randi;
static void
@@ -50,7 +50,7 @@ Randi_generate_iii(Randi *self) {
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT range = ma - mi;
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -73,7 +73,7 @@ Randi_generate_aii(Randi *self) {
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
range = ma - mi[i];
self->time += inc;
@@ -97,7 +97,7 @@ Randi_generate_iai(Randi *self) {
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
range = ma[i] - mi;
self->time += inc;
@@ -121,7 +121,7 @@ Randi_generate_aai(Randi *self) {
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
range = ma[i] - mi[i];
self->time += inc;
@@ -145,7 +145,7 @@ Randi_generate_iia(Randi *self) {
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT range = ma - mi;
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -168,7 +168,7 @@ Randi_generate_aia(Randi *self) {
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
range = ma - mi[i];
@@ -192,7 +192,7 @@ Randi_generate_iaa(Randi *self) {
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
range = ma[i] - mi;
@@ -216,7 +216,7 @@ Randi_generate_aaa(Randi *self) {
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
range = ma[i] - mi[i];
@@ -249,68 +249,68 @@ Randi_setProcMode(Randi *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Randi_generate_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Randi_generate_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Randi_generate_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Randi_generate_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Randi_generate_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Randi_generate_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Randi_generate_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Randi_generate_aaa;
- break;
- }
+ break;
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Randi_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Randi_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Randi_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Randi_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Randi_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Randi_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Randi_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Randi_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Randi_postprocessing_revareva;
break;
- }
+ }
}
static void
Randi_compute_next_data_frame(Randi *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -320,23 +320,23 @@ Randi_traverse(Randi *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->freq);
Py_VISIT(self->freq_stream);
- Py_VISIT(self->min);
- Py_VISIT(self->min_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->min);
+ Py_VISIT(self->min_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
Randi_clear(Randi *self)
{
pyo_CLEAR
Py_CLEAR(self->freq);
Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->min);
- Py_CLEAR(self->min_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->min);
+ Py_CLEAR(self->min_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -356,7 +356,7 @@ Randi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *mintmp=NULL, *maxtmp=NULL, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
Randi *self;
self = (Randi *)type->tp_alloc(type, 0);
-
+
self->min = PyFloat_FromDouble(0.);
self->max = PyFloat_FromDouble(1.);
self->freq = PyFloat_FromDouble(1.);
@@ -367,20 +367,20 @@ Randi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Randi_compute_next_data_frame);
self->mode_func_ptr = Randi_setProcMode;
static char *kwlist[] = {"min", "max", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", kwlist, &mintmp, &maxtmp, &freqtmp, &multmp, &addtmp))
- Py_RETURN_NONE;
+ Py_RETURN_NONE;
if (mintmp) {
PyObject_CallMethod((PyObject *)self, "setMin", "O", mintmp);
}
-
+
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
@@ -388,15 +388,15 @@ Randi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Server_generateSeed((Server *)self->server, RANDI_ID);
@@ -409,7 +409,7 @@ Randi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
ma = PyFloat_AS_DOUBLE(self->max);
else
ma = Stream_getData((Stream *)self->max_stream)[0];
-
+
self->value = self->oldValue = (mi + ma) * 0.5;
(*self->mode_func_ptr)(self);
@@ -419,10 +419,10 @@ Randi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Randi_getServer(Randi* self) { GET_SERVER };
static PyObject * Randi_getStream(Randi* self) { GET_STREAM };
-static PyObject * Randi_setMul(Randi *self, PyObject *arg) { SET_MUL };
-static PyObject * Randi_setAdd(Randi *self, PyObject *arg) { SET_ADD };
-static PyObject * Randi_setSub(Randi *self, PyObject *arg) { SET_SUB };
-static PyObject * Randi_setDiv(Randi *self, PyObject *arg) { SET_DIV };
+static PyObject * Randi_setMul(Randi *self, PyObject *arg) { SET_MUL };
+static PyObject * Randi_setAdd(Randi *self, PyObject *arg) { SET_ADD };
+static PyObject * Randi_setSub(Randi *self, PyObject *arg) { SET_SUB };
+static PyObject * Randi_setDiv(Randi *self, PyObject *arg) { SET_DIV };
static PyObject * Randi_play(Randi *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Randi_out(Randi *self, PyObject *args, PyObject *kwds) { OUT };
@@ -441,14 +441,14 @@ static PyObject *
Randi_setMin(Randi *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->min);
@@ -464,25 +464,25 @@ Randi_setMin(Randi *self, PyObject *arg)
self->min_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Randi_setMax(Randi *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -498,25 +498,25 @@ Randi_setMax(Randi *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Randi_setFreq(Randi *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -532,12 +532,12 @@ Randi_setFreq(Randi *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Randi_members[] = {
{"server", T_OBJECT_EX, offsetof(Randi, server), 0, "Pyo server."},
@@ -663,7 +663,7 @@ typedef struct {
Stream *freq_stream;
MYFLT value;
MYFLT time;
- int modebuffer[5]; // need at least 2 slots for mul & add
+ int modebuffer[5]; // need at least 2 slots for mul & add
} Randh;
static void
@@ -675,7 +675,7 @@ Randh_generate_iii(Randh *self) {
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT range = ma - mi;
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -696,7 +696,7 @@ Randh_generate_aii(Randh *self) {
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
range = ma - mi[i];
self->time += inc;
@@ -718,7 +718,7 @@ Randh_generate_iai(Randh *self) {
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
range = ma[i] - mi;
self->time += inc;
@@ -740,7 +740,7 @@ Randh_generate_aai(Randh *self) {
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
range = ma[i] - mi[i];
self->time += inc;
@@ -762,7 +762,7 @@ Randh_generate_iia(Randh *self) {
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
MYFLT range = ma - mi;
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -783,7 +783,7 @@ Randh_generate_aia(Randh *self) {
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
range = ma - mi[i];
@@ -805,7 +805,7 @@ Randh_generate_iaa(Randh *self) {
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
range = ma[i] - mi;
@@ -827,7 +827,7 @@ Randh_generate_aaa(Randh *self) {
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
range = ma[i] - mi[i];
@@ -858,68 +858,68 @@ Randh_setProcMode(Randh *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Randh_generate_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Randh_generate_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Randh_generate_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Randh_generate_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Randh_generate_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Randh_generate_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Randh_generate_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Randh_generate_aaa;
- break;
- }
+ break;
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Randh_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Randh_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Randh_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Randh_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Randh_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Randh_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Randh_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Randh_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Randh_postprocessing_revareva;
break;
- }
+ }
}
static void
Randh_compute_next_data_frame(Randh *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -929,23 +929,23 @@ Randh_traverse(Randh *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->freq);
Py_VISIT(self->freq_stream);
- Py_VISIT(self->min);
- Py_VISIT(self->min_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->min);
+ Py_VISIT(self->min_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
Randh_clear(Randh *self)
{
pyo_CLEAR
Py_CLEAR(self->freq);
Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->min);
- Py_CLEAR(self->min_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->min);
+ Py_CLEAR(self->min_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -965,7 +965,7 @@ Randh_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *mintmp=NULL, *maxtmp=NULL, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
Randh *self;
self = (Randh *)type->tp_alloc(type, 0);
-
+
self->min = PyFloat_FromDouble(0.);
self->max = PyFloat_FromDouble(1.);
self->freq = PyFloat_FromDouble(1.);
@@ -976,38 +976,38 @@ Randh_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Randh_compute_next_data_frame);
self->mode_func_ptr = Randh_setProcMode;
static char *kwlist[] = {"min", "max", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", kwlist, &mintmp, &maxtmp, &freqtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (mintmp) {
PyObject_CallMethod((PyObject *)self, "setMin", "O", mintmp);
}
-
+
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
Server_generateSeed((Server *)self->server, RANDH_ID);
if (self->modebuffer[2] == 0)
@@ -1018,9 +1018,9 @@ Randh_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
ma = PyFloat_AS_DOUBLE(self->max);
else
ma = Stream_getData((Stream *)self->max_stream)[0];
-
+
self->value = (mi + ma) * 0.5;
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1028,10 +1028,10 @@ Randh_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Randh_getServer(Randh* self) { GET_SERVER };
static PyObject * Randh_getStream(Randh* self) { GET_STREAM };
-static PyObject * Randh_setMul(Randh *self, PyObject *arg) { SET_MUL };
-static PyObject * Randh_setAdd(Randh *self, PyObject *arg) { SET_ADD };
-static PyObject * Randh_setSub(Randh *self, PyObject *arg) { SET_SUB };
-static PyObject * Randh_setDiv(Randh *self, PyObject *arg) { SET_DIV };
+static PyObject * Randh_setMul(Randh *self, PyObject *arg) { SET_MUL };
+static PyObject * Randh_setAdd(Randh *self, PyObject *arg) { SET_ADD };
+static PyObject * Randh_setSub(Randh *self, PyObject *arg) { SET_SUB };
+static PyObject * Randh_setDiv(Randh *self, PyObject *arg) { SET_DIV };
static PyObject * Randh_play(Randh *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Randh_out(Randh *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1050,14 +1050,14 @@ static PyObject *
Randh_setMin(Randh *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->min);
@@ -1073,25 +1073,25 @@ Randh_setMin(Randh *self, PyObject *arg)
self->min_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Randh_setMax(Randh *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -1107,25 +1107,25 @@ Randh_setMax(Randh *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Randh_setFreq(Randh *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1141,12 +1141,12 @@ Randh_setFreq(Randh *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Randh_members[] = {
{"server", T_OBJECT_EX, offsetof(Randh, server), 0, "Pyo server."},
@@ -1270,7 +1270,7 @@ typedef struct {
MYFLT *choice;
MYFLT value;
MYFLT time;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} Choice;
static void
@@ -1279,7 +1279,7 @@ Choice_generate_i(Choice *self) {
MYFLT inc;
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -1297,7 +1297,7 @@ Choice_generate_a(Choice *self) {
int i;
MYFLT inc;
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -1327,50 +1327,50 @@ Choice_setProcMode(Choice *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Choice_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Choice_generate_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Choice_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Choice_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Choice_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Choice_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Choice_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Choice_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Choice_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Choice_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Choice_postprocessing_revareva;
break;
- }
+ }
}
static void
Choice_compute_next_data_frame(Choice *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1383,7 +1383,7 @@ Choice_traverse(Choice *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Choice_clear(Choice *self)
{
pyo_CLEAR
@@ -1408,23 +1408,23 @@ Choice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *choicetmp=NULL, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
Choice *self;
self = (Choice *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1.);
self->value = 0.0;
self->time = 1.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Choice_compute_next_data_frame);
self->mode_func_ptr = Choice_setProcMode;
static char *kwlist[] = {"choice", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &choicetmp, &freqtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (choicetmp) {
PyObject_CallMethod((PyObject *)self, "setChoice", "O", choicetmp);
}
@@ -1432,17 +1432,17 @@ Choice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
Server_generateSeed((Server *)self->server, CHOICE_ID);
(*self->mode_func_ptr)(self);
@@ -1452,10 +1452,10 @@ Choice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Choice_getServer(Choice* self) { GET_SERVER };
static PyObject * Choice_getStream(Choice* self) { GET_STREAM };
-static PyObject * Choice_setMul(Choice *self, PyObject *arg) { SET_MUL };
-static PyObject * Choice_setAdd(Choice *self, PyObject *arg) { SET_ADD };
-static PyObject * Choice_setSub(Choice *self, PyObject *arg) { SET_SUB };
-static PyObject * Choice_setDiv(Choice *self, PyObject *arg) { SET_DIV };
+static PyObject * Choice_setMul(Choice *self, PyObject *arg) { SET_MUL };
+static PyObject * Choice_setAdd(Choice *self, PyObject *arg) { SET_ADD };
+static PyObject * Choice_setSub(Choice *self, PyObject *arg) { SET_SUB };
+static PyObject * Choice_setDiv(Choice *self, PyObject *arg) { SET_DIV };
static PyObject * Choice_play(Choice *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Choice_out(Choice *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1475,38 +1475,38 @@ Choice_setChoice(Choice *self, PyObject *arg)
{
int i;
PyObject *tmp;
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The choice attribute must be a list.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
self->chSize = PyList_Size(tmp);
self->choice = (MYFLT *)realloc(self->choice, self->chSize * sizeof(MYFLT));
for (i=0; i<self->chSize; i++) {
self->choice[i] = PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(tmp, i)));
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Choice_setFreq(Choice *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1522,12 +1522,12 @@ Choice_setFreq(Choice *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Choice_members[] = {
{"server", T_OBJECT_EX, offsetof(Choice, server), 0, "Pyo server."},
@@ -1648,7 +1648,7 @@ typedef struct {
Stream *freq_stream;
MYFLT value;
MYFLT time;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
} RandInt;
static void
@@ -1658,7 +1658,7 @@ RandInt_generate_ii(RandInt *self) {
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -1678,7 +1678,7 @@ RandInt_generate_ai(RandInt *self) {
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -1697,7 +1697,7 @@ RandInt_generate_ia(RandInt *self) {
MYFLT inc;
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -1717,7 +1717,7 @@ RandInt_generate_aa(RandInt *self) {
MYFLT inc;
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -1747,56 +1747,56 @@ RandInt_setProcMode(RandInt *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = RandInt_generate_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = RandInt_generate_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = RandInt_generate_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = RandInt_generate_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = RandInt_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = RandInt_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = RandInt_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = RandInt_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = RandInt_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = RandInt_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = RandInt_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = RandInt_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = RandInt_postprocessing_revareva;
break;
- }
+ }
}
static void
RandInt_compute_next_data_frame(RandInt *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1806,19 +1806,19 @@ RandInt_traverse(RandInt *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->freq);
Py_VISIT(self->freq_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
RandInt_clear(RandInt *self)
{
pyo_CLEAR
Py_CLEAR(self->freq);
Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -1837,7 +1837,7 @@ RandInt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maxtmp=NULL, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
RandInt *self;
self = (RandInt *)type->tp_alloc(type, 0);
-
+
self->max = PyFloat_FromDouble(100.);
self->freq = PyFloat_FromDouble(1.);
self->value = 0.0;
@@ -1846,32 +1846,32 @@ RandInt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, RandInt_compute_next_data_frame);
self->mode_func_ptr = RandInt_setProcMode;
static char *kwlist[] = {"max", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &maxtmp, &freqtmp, &multmp, &addtmp))
Py_RETURN_NONE;
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Server_generateSeed((Server *)self->server, RANDINT_ID);
@@ -1883,10 +1883,10 @@ RandInt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * RandInt_getServer(RandInt* self) { GET_SERVER };
static PyObject * RandInt_getStream(RandInt* self) { GET_STREAM };
-static PyObject * RandInt_setMul(RandInt *self, PyObject *arg) { SET_MUL };
-static PyObject * RandInt_setAdd(RandInt *self, PyObject *arg) { SET_ADD };
-static PyObject * RandInt_setSub(RandInt *self, PyObject *arg) { SET_SUB };
-static PyObject * RandInt_setDiv(RandInt *self, PyObject *arg) { SET_DIV };
+static PyObject * RandInt_setMul(RandInt *self, PyObject *arg) { SET_MUL };
+static PyObject * RandInt_setAdd(RandInt *self, PyObject *arg) { SET_ADD };
+static PyObject * RandInt_setSub(RandInt *self, PyObject *arg) { SET_SUB };
+static PyObject * RandInt_setDiv(RandInt *self, PyObject *arg) { SET_DIV };
static PyObject * RandInt_play(RandInt *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * RandInt_out(RandInt *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1905,14 +1905,14 @@ static PyObject *
RandInt_setMax(RandInt *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -1928,25 +1928,25 @@ RandInt_setMax(RandInt *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
RandInt_setFreq(RandInt *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -1962,12 +1962,12 @@ RandInt_setFreq(RandInt *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef RandInt_members[] = {
{"server", T_OBJECT_EX, offsetof(RandInt, server), 0, "Pyo server."},
@@ -2090,7 +2090,7 @@ typedef struct {
MYFLT value;
MYFLT time;
MYFLT inc;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
} RandDur;
static void
@@ -2099,7 +2099,7 @@ RandDur_generate_ii(RandDur *self) {
MYFLT range;
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
self->time += self->inc;
if (self->time < 0.0)
@@ -2124,7 +2124,7 @@ RandDur_generate_ai(RandDur *self) {
MYFLT range, mi;
MYFLT *min = Stream_getData((Stream *)self->min_stream);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
self->time += self->inc;
if (self->time < 0.0)
@@ -2150,7 +2150,7 @@ RandDur_generate_ia(RandDur *self) {
MYFLT range;
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->time += self->inc;
if (self->time < 0.0)
@@ -2175,7 +2175,7 @@ RandDur_generate_aa(RandDur *self) {
MYFLT range, mi;
MYFLT *min = Stream_getData((Stream *)self->min_stream);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->time += self->inc;
if (self->time < 0.0)
@@ -2211,56 +2211,56 @@ RandDur_setProcMode(RandDur *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = RandDur_generate_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = RandDur_generate_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = RandDur_generate_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = RandDur_generate_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = RandDur_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = RandDur_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = RandDur_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = RandDur_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = RandDur_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = RandDur_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = RandDur_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = RandDur_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = RandDur_postprocessing_revareva;
break;
- }
+ }
}
static void
RandDur_compute_next_data_frame(RandDur *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2268,21 +2268,21 @@ static int
RandDur_traverse(RandDur *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->min);
- Py_VISIT(self->min_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->min);
+ Py_VISIT(self->min_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
RandDur_clear(RandDur *self)
{
pyo_CLEAR
- Py_CLEAR(self->min);
- Py_CLEAR(self->min_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->min);
+ Py_CLEAR(self->min_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -2302,7 +2302,7 @@ RandDur_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *mintmp=NULL, *maxtmp=NULL, *multmp=NULL, *addtmp=NULL;
RandDur *self;
self = (RandDur *)type->tp_alloc(type, 0);
-
+
self->min = PyFloat_FromDouble(0.01);
self->max = PyFloat_FromDouble(1.);
self->value = self->inc = 0.0;
@@ -2311,34 +2311,34 @@ RandDur_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, RandDur_compute_next_data_frame);
self->mode_func_ptr = RandDur_setProcMode;
static char *kwlist[] = {"min", "max", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &mintmp, &maxtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (mintmp) {
PyObject_CallMethod((PyObject *)self, "setMin", "O", mintmp);
}
-
+
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
Server_generateSeed((Server *)self->server, RANDDUR_ID);
if (self->modebuffer[2] == 0)
@@ -2349,7 +2349,7 @@ RandDur_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
ma = PyFloat_AS_DOUBLE(self->max);
else
ma = Stream_getData((Stream *)self->max_stream)[0];
-
+
self->value = (mi + ma) * 0.5;
if (self->value == 0.0)
self->inc = 0.0;
@@ -2363,10 +2363,10 @@ RandDur_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * RandDur_getServer(RandDur* self) { GET_SERVER };
static PyObject * RandDur_getStream(RandDur* self) { GET_STREAM };
-static PyObject * RandDur_setMul(RandDur *self, PyObject *arg) { SET_MUL };
-static PyObject * RandDur_setAdd(RandDur *self, PyObject *arg) { SET_ADD };
-static PyObject * RandDur_setSub(RandDur *self, PyObject *arg) { SET_SUB };
-static PyObject * RandDur_setDiv(RandDur *self, PyObject *arg) { SET_DIV };
+static PyObject * RandDur_setMul(RandDur *self, PyObject *arg) { SET_MUL };
+static PyObject * RandDur_setAdd(RandDur *self, PyObject *arg) { SET_ADD };
+static PyObject * RandDur_setSub(RandDur *self, PyObject *arg) { SET_SUB };
+static PyObject * RandDur_setDiv(RandDur *self, PyObject *arg) { SET_DIV };
static PyObject * RandDur_play(RandDur *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * RandDur_out(RandDur *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2385,14 +2385,14 @@ static PyObject *
RandDur_setMin(RandDur *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->min);
@@ -2408,25 +2408,25 @@ RandDur_setMin(RandDur *self, PyObject *arg)
self->min_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
RandDur_setMax(RandDur *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -2442,12 +2442,12 @@ RandDur_setMax(RandDur *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef RandDur_members[] = {
{"server", T_OBJECT_EX, offsetof(RandDur, server), 0, "Pyo server."},
@@ -2586,18 +2586,18 @@ typedef struct {
int loopCountRec;
int loopLen;
int loopStop;
- int modebuffer[5]; // need at least 2 slots for mul & add
+ int modebuffer[5]; // need at least 2 slots for mul & add
} Xnoise;
// no parameter
static MYFLT
Xnoise_uniform(Xnoise *self) {
- return RANDOM_UNIFORM;
+ return RANDOM_UNIFORM;
}
static MYFLT
Xnoise_linear_min(Xnoise *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a < b) return a;
else return b;
@@ -2605,7 +2605,7 @@ Xnoise_linear_min(Xnoise *self) {
static MYFLT
Xnoise_linear_max(Xnoise *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a > b) return a;
else return b;
@@ -2613,7 +2613,7 @@ Xnoise_linear_max(Xnoise *self) {
static MYFLT
Xnoise_triangle(Xnoise *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
return ((a + b) * 0.5);
}
@@ -2622,7 +2622,7 @@ Xnoise_triangle(Xnoise *self) {
static MYFLT
Xnoise_expon_min(Xnoise *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = -MYLOG(RANDOM_UNIFORM) / self->xx1;
+ MYFLT val = -MYLOG(RANDOM_UNIFORM) / self->xx1;
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2631,7 +2631,7 @@ Xnoise_expon_min(Xnoise *self) {
static MYFLT
Xnoise_expon_max(Xnoise *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = 1.0 - (-MYLOG(RANDOM_UNIFORM) / self->xx1);
+ MYFLT val = 1.0 - (-MYLOG(RANDOM_UNIFORM) / self->xx1);
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2643,7 +2643,7 @@ Xnoise_biexpon(Xnoise *self) {
MYFLT polar, val;
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
MYFLT sum = RANDOM_UNIFORM * 2.0;
-
+
if (sum > 1.0) {
polar = -1;
sum = 2.0 - sum;
@@ -2665,14 +2665,14 @@ Xnoise_cauchy(Xnoise *self) {
rnd = RANDOM_UNIFORM;
}
while (rnd == 0.5);
-
+
if (rand() < (RAND_MAX / 2))
dir = -1;
else
dir = 1;
-
+
val = 0.5 * (MYTAN(rnd) * self->xx1 * dir) + 0.5;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2683,10 +2683,10 @@ static MYFLT
Xnoise_weibull(Xnoise *self) {
MYFLT rnd, val;
if (self->xx2 <= 0.0) self->xx2 = 0.00001;
-
+
rnd = 1.0 / (1.0 - RANDOM_UNIFORM);
val = self->xx1 * MYPOW(MYLOG(rnd), (1.0 / self->xx2));
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2696,10 +2696,10 @@ Xnoise_weibull(Xnoise *self) {
static MYFLT
Xnoise_gaussian(Xnoise *self) {
MYFLT rnd, val;
-
+
rnd = (RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM);
val = (self->xx2 * (rnd - 3.0) * 0.33 + self->xx1);
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2728,7 +2728,7 @@ Xnoise_poisson(Xnoise *self) {
}
}
val = self->poisson_buffer[rand() % self->poisson_tab] / 12.0 * self->xx2;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2738,22 +2738,22 @@ Xnoise_poisson(Xnoise *self) {
static MYFLT
Xnoise_walker(Xnoise *self) {
int modulo, dir;
-
+
if (self->xx2 < 0.002) self->xx2 = 0.002;
-
+
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
return self->walkerValue;
}
@@ -2763,26 +2763,26 @@ Xnoise_loopseg(Xnoise *self) {
int modulo, dir;
if (self->loopChoice == 0) {
-
+
self->loopCountPlay = self->loopTime = 0;
if (self->xx2 < 0.002) self->xx2 = 0.002;
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
-
+
if (self->loopCountRec < self->loopLen)
self->loopChoice = 0;
else {
@@ -2792,22 +2792,22 @@ Xnoise_loopseg(Xnoise *self) {
}
else {
self->loopCountRec = 0;
-
+
self->walkerValue = self->loop_buffer[self->loopCountPlay++];
-
+
if (self->loopCountPlay < self->loopLen)
self->loopChoice = 1;
else {
self->loopCountPlay = 0;
self->loopTime++;
}
-
+
if (self->loopTime == self->loopStop) {
self->loopChoice = 0;
self->loopLen = (rand() % 10) + 3;
}
}
-
+
return self->walkerValue;
}
@@ -2840,7 +2840,7 @@ Xnoise_generate_aii(Xnoise *self) {
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -2862,7 +2862,7 @@ Xnoise_generate_iai(Xnoise *self) {
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -2884,7 +2884,7 @@ Xnoise_generate_aai(Xnoise *self) {
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -2906,7 +2906,7 @@ Xnoise_generate_iia(Xnoise *self) {
self->xx1 = PyFloat_AS_DOUBLE(self->x1);
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -2927,7 +2927,7 @@ Xnoise_generate_aia(Xnoise *self) {
MYFLT *x1 = Stream_getData((Stream *)self->x1_stream);
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -2949,7 +2949,7 @@ Xnoise_generate_iaa(Xnoise *self) {
self->xx1 = PyFloat_AS_DOUBLE(self->x1);
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -2971,7 +2971,7 @@ Xnoise_generate_aaa(Xnoise *self) {
MYFLT *x1 = Stream_getData((Stream *)self->x1_stream);
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -3001,7 +3001,7 @@ static void
Xnoise_setRandomType(Xnoise *self)
{
- switch (self->type) {
+ switch (self->type) {
case 0:
self->type_func_ptr = Xnoise_uniform;
break;
@@ -3041,7 +3041,7 @@ Xnoise_setRandomType(Xnoise *self)
case 12:
self->type_func_ptr = Xnoise_loopseg;
break;
- }
+ }
}
static void
@@ -3050,68 +3050,68 @@ Xnoise_setProcMode(Xnoise *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Xnoise_generate_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Xnoise_generate_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Xnoise_generate_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Xnoise_generate_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = Xnoise_generate_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = Xnoise_generate_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = Xnoise_generate_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = Xnoise_generate_aaa;
- break;
- }
+ break;
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Xnoise_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Xnoise_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Xnoise_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Xnoise_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Xnoise_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Xnoise_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Xnoise_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Xnoise_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Xnoise_postprocessing_revareva;
break;
- }
+ }
}
static void
Xnoise_compute_next_data_frame(Xnoise *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3121,23 +3121,23 @@ Xnoise_traverse(Xnoise *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->freq);
Py_VISIT(self->freq_stream);
- Py_VISIT(self->x1);
- Py_VISIT(self->x1_stream);
- Py_VISIT(self->x2);
- Py_VISIT(self->x2_stream);
+ Py_VISIT(self->x1);
+ Py_VISIT(self->x1_stream);
+ Py_VISIT(self->x2);
+ Py_VISIT(self->x2_stream);
return 0;
}
-static int
+static int
Xnoise_clear(Xnoise *self)
{
pyo_CLEAR
Py_CLEAR(self->freq);
Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->x1);
- Py_CLEAR(self->x1_stream);
- Py_CLEAR(self->x2);
- Py_CLEAR(self->x2_stream);
+ Py_CLEAR(self->x1);
+ Py_CLEAR(self->x1_stream);
+ Py_CLEAR(self->x2);
+ Py_CLEAR(self->x2_stream);
return 0;
}
@@ -3156,7 +3156,7 @@ Xnoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *x1tmp=NULL, *x2tmp=NULL, *multmp=NULL, *addtmp=NULL;
Xnoise *self;
self = (Xnoise *)type->tp_alloc(type, 0);
-
+
self->x1 = PyFloat_FromDouble(0.5);
self->x2 = PyFloat_FromDouble(0.5);
self->freq = PyFloat_FromDouble(1.);
@@ -3168,9 +3168,9 @@ Xnoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
-
+
Server_generateSeed((Server *)self->server, XNOISE_ID);
self->poisson_tab = 0;
@@ -3181,41 +3181,41 @@ Xnoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<15; i++) {
self->loop_buffer[i] = 0.0;
}
- self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
+ self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
self->loopLen = (rand() % 10) + 3;
-
+
Stream_setFunctionPtr(self->stream, Xnoise_compute_next_data_frame);
self->mode_func_ptr = Xnoise_setProcMode;
static char *kwlist[] = {"type", "freq", "x1", "x2", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iOOOOO", kwlist, &self->type, &freqtmp, &x1tmp, &x2tmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (x1tmp) {
PyObject_CallMethod((PyObject *)self, "setX1", "O", x1tmp);
}
-
+
if (x2tmp) {
PyObject_CallMethod((PyObject *)self, "setX2", "O", x2tmp);
}
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Xnoise_setRandomType(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3223,10 +3223,10 @@ Xnoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Xnoise_getServer(Xnoise* self) { GET_SERVER };
static PyObject * Xnoise_getStream(Xnoise* self) { GET_STREAM };
-static PyObject * Xnoise_setMul(Xnoise *self, PyObject *arg) { SET_MUL };
-static PyObject * Xnoise_setAdd(Xnoise *self, PyObject *arg) { SET_ADD };
-static PyObject * Xnoise_setSub(Xnoise *self, PyObject *arg) { SET_SUB };
-static PyObject * Xnoise_setDiv(Xnoise *self, PyObject *arg) { SET_DIV };
+static PyObject * Xnoise_setMul(Xnoise *self, PyObject *arg) { SET_MUL };
+static PyObject * Xnoise_setAdd(Xnoise *self, PyObject *arg) { SET_ADD };
+static PyObject * Xnoise_setSub(Xnoise *self, PyObject *arg) { SET_SUB };
+static PyObject * Xnoise_setDiv(Xnoise *self, PyObject *arg) { SET_DIV };
static PyObject * Xnoise_play(Xnoise *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Xnoise_out(Xnoise *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3243,14 +3243,14 @@ static PyObject * Xnoise_inplace_div(Xnoise *self, PyObject *arg) { INPLACE_DIV
static PyObject *
Xnoise_setType(Xnoise *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyInt_Check(arg);
-
+
if (isNumber == 1) {
self->type = PyInt_AsLong(arg);
Xnoise_setRandomType(self);
@@ -3258,20 +3258,20 @@ Xnoise_setType(Xnoise *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Xnoise_setX1(Xnoise *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x1);
@@ -3287,25 +3287,25 @@ Xnoise_setX1(Xnoise *self, PyObject *arg)
self->x1_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Xnoise_setX2(Xnoise *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x2);
@@ -3321,25 +3321,25 @@ Xnoise_setX2(Xnoise *self, PyObject *arg)
self->x2_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Xnoise_setFreq(Xnoise *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -3355,12 +3355,12 @@ Xnoise_setFreq(Xnoise *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Xnoise_members[] = {
{"server", T_OBJECT_EX, offsetof(Xnoise, server), 0, "Pyo server."},
@@ -3506,7 +3506,7 @@ typedef struct {
int loopCountRec;
int loopLen;
int loopStop;
- int modebuffer[5]; // need at least 2 slots for mul & add
+ int modebuffer[5]; // need at least 2 slots for mul & add
} XnoiseMidi;
static MYFLT
@@ -3515,12 +3515,12 @@ XnoiseMidi_convert(XnoiseMidi *self) {
MYFLT val;
midival = (int)((self->value * (self->range_max-self->range_min)) + self->range_min);
-
+
if (midival < 0)
midival = 0;
else if (midival > 127)
midival = 127;
-
+
if (self->scale == 0)
val = (MYFLT)midival;
else if (self->scale == 1)
@@ -3529,19 +3529,19 @@ XnoiseMidi_convert(XnoiseMidi *self) {
val = MYPOW(1.0594630943593, midival - self->centralkey);
else
val = midival;
-
+
return val;
}
// no parameter
static MYFLT
XnoiseMidi_uniform(XnoiseMidi *self) {
- return RANDOM_UNIFORM;
+ return RANDOM_UNIFORM;
}
static MYFLT
XnoiseMidi_linear_min(XnoiseMidi *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a < b) return a;
else return b;
@@ -3549,7 +3549,7 @@ XnoiseMidi_linear_min(XnoiseMidi *self) {
static MYFLT
XnoiseMidi_linear_max(XnoiseMidi *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a > b) return a;
else return b;
@@ -3557,7 +3557,7 @@ XnoiseMidi_linear_max(XnoiseMidi *self) {
static MYFLT
XnoiseMidi_triangle(XnoiseMidi *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
return ((a + b) * 0.5);
}
@@ -3566,7 +3566,7 @@ XnoiseMidi_triangle(XnoiseMidi *self) {
static MYFLT
XnoiseMidi_expon_min(XnoiseMidi *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = -MYLOG(RANDOM_UNIFORM) / self->xx1;
+ MYFLT val = -MYLOG(RANDOM_UNIFORM) / self->xx1;
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3575,7 +3575,7 @@ XnoiseMidi_expon_min(XnoiseMidi *self) {
static MYFLT
XnoiseMidi_expon_max(XnoiseMidi *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = 1.0 - (-MYLOG(RANDOM_UNIFORM) / self->xx1);
+ MYFLT val = 1.0 - (-MYLOG(RANDOM_UNIFORM) / self->xx1);
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3587,16 +3587,16 @@ XnoiseMidi_biexpon(XnoiseMidi *self) {
MYFLT polar, val;
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
MYFLT sum = RANDOM_UNIFORM * 2.0;
-
+
if (sum > 1.0) {
polar = -1;
sum = 2.0 - sum;
}
else
polar = 1;
-
+
val = 0.5 * (polar * MYLOG(sum) / self->xx1) + 0.5;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3609,14 +3609,14 @@ XnoiseMidi_cauchy(XnoiseMidi *self) {
rnd = RANDOM_UNIFORM;
}
while (rnd == 0.5);
-
+
if (rand() < (RAND_MAX / 2))
dir = -1;
else
dir = 1;
-
+
val = 0.5 * (MYTAN(rnd) * self->xx1 * dir) + 0.5;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3627,10 +3627,10 @@ static MYFLT
XnoiseMidi_weibull(XnoiseMidi *self) {
MYFLT rnd, val;
if (self->xx2 <= 0.0) self->xx2 = 0.00001;
-
+
rnd = 1.0 / (1.0 - RANDOM_UNIFORM);
val = self->xx1 * MYPOW(MYLOG(rnd), (1.0 / self->xx2));
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3640,10 +3640,10 @@ XnoiseMidi_weibull(XnoiseMidi *self) {
static MYFLT
XnoiseMidi_gaussian(XnoiseMidi *self) {
MYFLT rnd, val;
-
+
rnd = (RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM);
val = (self->xx2 * (rnd - 3.0) * 0.33 + self->xx1);
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3657,7 +3657,7 @@ XnoiseMidi_poisson(XnoiseMidi *self) {
MYFLT val;
if (self->xx1 < 0.1) self->xx1 = 0.1;
if (self->xx2 < 0.1) self->xx2 = 0.1;
-
+
if (self->xx1 != self->lastPoissonX1) {
self->lastPoissonX1 = self->xx1;
self->poisson_tab = 0;
@@ -3672,7 +3672,7 @@ XnoiseMidi_poisson(XnoiseMidi *self) {
}
}
val = self->poisson_buffer[rand() % self->poisson_tab] / 12.0 * self->xx2;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3682,22 +3682,22 @@ XnoiseMidi_poisson(XnoiseMidi *self) {
static MYFLT
XnoiseMidi_walker(XnoiseMidi *self) {
int modulo, dir;
-
+
if (self->xx2 < 0.002) self->xx2 = 0.002;
-
+
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
return self->walkerValue;
}
@@ -3705,28 +3705,28 @@ XnoiseMidi_walker(XnoiseMidi *self) {
static MYFLT
XnoiseMidi_loopseg(XnoiseMidi *self) {
int modulo, dir;
-
+
if (self->loopChoice == 0) {
-
+
self->loopCountPlay = self->loopTime = 0;
-
+
if (self->xx2 < 0.002) self->xx2 = 0.002;
-
+
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
-
+
if (self->loopCountRec < self->loopLen)
self->loopChoice = 0;
else {
@@ -3736,22 +3736,22 @@ XnoiseMidi_loopseg(XnoiseMidi *self) {
}
else {
self->loopCountRec = 0;
-
+
self->walkerValue = self->loop_buffer[self->loopCountPlay++];
-
+
if (self->loopCountPlay < self->loopLen)
self->loopChoice = 1;
else {
self->loopCountPlay = 0;
self->loopTime++;
}
-
+
if (self->loopTime == self->loopStop) {
self->loopChoice = 0;
self->loopLen = (rand() % 10) + 3;
}
}
-
+
return self->walkerValue;
}
@@ -3763,7 +3763,7 @@ XnoiseMidi_generate_iii(XnoiseMidi *self) {
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -3785,7 +3785,7 @@ XnoiseMidi_generate_aii(XnoiseMidi *self) {
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -3808,7 +3808,7 @@ XnoiseMidi_generate_iai(XnoiseMidi *self) {
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -3831,7 +3831,7 @@ XnoiseMidi_generate_aai(XnoiseMidi *self) {
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += inc;
if (self->time < 0.0)
@@ -3854,7 +3854,7 @@ XnoiseMidi_generate_iia(XnoiseMidi *self) {
self->xx1 = PyFloat_AS_DOUBLE(self->x1);
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -3876,7 +3876,7 @@ XnoiseMidi_generate_aia(XnoiseMidi *self) {
MYFLT *x1 = Stream_getData((Stream *)self->x1_stream);
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -3899,7 +3899,7 @@ XnoiseMidi_generate_iaa(XnoiseMidi *self) {
self->xx1 = PyFloat_AS_DOUBLE(self->x1);
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -3922,7 +3922,7 @@ XnoiseMidi_generate_aaa(XnoiseMidi *self) {
MYFLT *x1 = Stream_getData((Stream *)self->x1_stream);
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inc = fr[i] / self->sr;
self->time += inc;
@@ -3952,8 +3952,8 @@ static void XnoiseMidi_postprocessing_revareva(XnoiseMidi *self) { POST_PROCESSI
static void
XnoiseMidi_setRandomType(XnoiseMidi *self)
{
-
- switch (self->type) {
+
+ switch (self->type) {
case 0:
self->type_func_ptr = XnoiseMidi_uniform;
break;
@@ -3993,7 +3993,7 @@ XnoiseMidi_setRandomType(XnoiseMidi *self)
case 12:
self->type_func_ptr = XnoiseMidi_loopseg;
break;
- }
+ }
}
static void
@@ -4002,68 +4002,68 @@ XnoiseMidi_setProcMode(XnoiseMidi *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = XnoiseMidi_generate_iii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = XnoiseMidi_generate_aii;
break;
- case 10:
+ case 10:
self->proc_func_ptr = XnoiseMidi_generate_iai;
break;
- case 11:
+ case 11:
self->proc_func_ptr = XnoiseMidi_generate_aai;
break;
- case 100:
+ case 100:
self->proc_func_ptr = XnoiseMidi_generate_iia;
break;
- case 101:
+ case 101:
self->proc_func_ptr = XnoiseMidi_generate_aia;
break;
- case 110:
+ case 110:
self->proc_func_ptr = XnoiseMidi_generate_iaa;
break;
- case 111:
+ case 111:
self->proc_func_ptr = XnoiseMidi_generate_aaa;
- break;
- }
+ break;
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = XnoiseMidi_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = XnoiseMidi_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = XnoiseMidi_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = XnoiseMidi_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = XnoiseMidi_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = XnoiseMidi_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = XnoiseMidi_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = XnoiseMidi_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = XnoiseMidi_postprocessing_revareva;
break;
- }
+ }
}
static void
XnoiseMidi_compute_next_data_frame(XnoiseMidi *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4073,23 +4073,23 @@ XnoiseMidi_traverse(XnoiseMidi *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->freq);
Py_VISIT(self->freq_stream);
- Py_VISIT(self->x1);
- Py_VISIT(self->x1_stream);
- Py_VISIT(self->x2);
- Py_VISIT(self->x2_stream);
+ Py_VISIT(self->x1);
+ Py_VISIT(self->x1_stream);
+ Py_VISIT(self->x2);
+ Py_VISIT(self->x2_stream);
return 0;
}
-static int
+static int
XnoiseMidi_clear(XnoiseMidi *self)
{
pyo_CLEAR
Py_CLEAR(self->freq);
Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->x1);
- Py_CLEAR(self->x1_stream);
- Py_CLEAR(self->x2);
- Py_CLEAR(self->x2_stream);
+ Py_CLEAR(self->x1);
+ Py_CLEAR(self->x1_stream);
+ Py_CLEAR(self->x2);
+ Py_CLEAR(self->x2_stream);
return 0;
}
@@ -4108,7 +4108,7 @@ XnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *x1tmp=NULL, *x2tmp=NULL, *rangetmp=NULL, *multmp=NULL, *addtmp=NULL;
XnoiseMidi *self;
self = (XnoiseMidi *)type->tp_alloc(type, 0);
-
+
self->x1 = PyFloat_FromDouble(0.5);
self->x2 = PyFloat_FromDouble(0.5);
self->freq = PyFloat_FromDouble(1.);
@@ -4124,7 +4124,7 @@ XnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
Server_generateSeed((Server *)self->server, XNOISEMIDI_ID);
@@ -4137,25 +4137,25 @@ XnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<15; i++) {
self->loop_buffer[i] = 0.0;
}
- self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
+ self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
self->loopLen = (rand() % 10) + 3;
-
+
Stream_setFunctionPtr(self->stream, XnoiseMidi_compute_next_data_frame);
self->mode_func_ptr = XnoiseMidi_setProcMode;
static char *kwlist[] = {"type", "freq", "x1", "x2", "scale", "range", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iOOOiOOO", kwlist, &self->type, &freqtmp, &x1tmp, &x2tmp, &self->scale, &rangetmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (x1tmp) {
PyObject_CallMethod((PyObject *)self, "setX1", "O", x1tmp);
}
-
+
if (x2tmp) {
PyObject_CallMethod((PyObject *)self, "setX2", "O", x2tmp);
}
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
@@ -4163,19 +4163,19 @@ XnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (rangetmp) {
PyObject_CallMethod((PyObject *)self, "setRange", "O", rangetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
XnoiseMidi_setRandomType(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -4183,10 +4183,10 @@ XnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * XnoiseMidi_getServer(XnoiseMidi* self) { GET_SERVER };
static PyObject * XnoiseMidi_getStream(XnoiseMidi* self) { GET_STREAM };
-static PyObject * XnoiseMidi_setMul(XnoiseMidi *self, PyObject *arg) { SET_MUL };
-static PyObject * XnoiseMidi_setAdd(XnoiseMidi *self, PyObject *arg) { SET_ADD };
-static PyObject * XnoiseMidi_setSub(XnoiseMidi *self, PyObject *arg) { SET_SUB };
-static PyObject * XnoiseMidi_setDiv(XnoiseMidi *self, PyObject *arg) { SET_DIV };
+static PyObject * XnoiseMidi_setMul(XnoiseMidi *self, PyObject *arg) { SET_MUL };
+static PyObject * XnoiseMidi_setAdd(XnoiseMidi *self, PyObject *arg) { SET_ADD };
+static PyObject * XnoiseMidi_setSub(XnoiseMidi *self, PyObject *arg) { SET_SUB };
+static PyObject * XnoiseMidi_setDiv(XnoiseMidi *self, PyObject *arg) { SET_DIV };
static PyObject * XnoiseMidi_play(XnoiseMidi *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * XnoiseMidi_out(XnoiseMidi *self, PyObject *args, PyObject *kwds) { OUT };
@@ -4203,34 +4203,34 @@ static PyObject * XnoiseMidi_inplace_div(XnoiseMidi *self, PyObject *arg) { INPL
static PyObject *
XnoiseMidi_setType(XnoiseMidi *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyInt_Check(arg);
-
+
if (isNumber == 1) {
self->type = PyInt_AsLong(arg);
XnoiseMidi_setRandomType(self);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
XnoiseMidi_setScale(XnoiseMidi *self, PyObject *arg)
-{
+{
int tmp;
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyInt_Check(arg);
-
+
if (isNumber == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp <= 2)
@@ -4241,11 +4241,11 @@ XnoiseMidi_setScale(XnoiseMidi *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
XnoiseMidi_setRange(XnoiseMidi *self, PyObject *args)
-{
+{
if (args == NULL) {
Py_INCREF(Py_None);
return Py_None;
@@ -4261,20 +4261,20 @@ XnoiseMidi_setRange(XnoiseMidi *self, PyObject *args)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
XnoiseMidi_setX1(XnoiseMidi *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x1);
@@ -4290,25 +4290,25 @@ XnoiseMidi_setX1(XnoiseMidi *self, PyObject *arg)
self->x1_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
XnoiseMidi_setX2(XnoiseMidi *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x2);
@@ -4324,25 +4324,25 @@ XnoiseMidi_setX2(XnoiseMidi *self, PyObject *arg)
self->x2_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
XnoiseMidi_setFreq(XnoiseMidi *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -4358,12 +4358,12 @@ XnoiseMidi_setFreq(XnoiseMidi *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef XnoiseMidi_members[] = {
{"server", T_OBJECT_EX, offsetof(XnoiseMidi, server), 0, "Pyo server."},
@@ -4510,18 +4510,18 @@ typedef struct {
int loopCountRec;
int loopLen;
int loopStop;
- int modebuffer[6]; // need at least 2 slots for mul & add
+ int modebuffer[6]; // need at least 2 slots for mul & add
} XnoiseDur;
// no parameter
static MYFLT
XnoiseDur_uniform(XnoiseDur *self) {
- return RANDOM_UNIFORM;
+ return RANDOM_UNIFORM;
}
static MYFLT
XnoiseDur_linear_min(XnoiseDur *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a < b) return a;
else return b;
@@ -4529,7 +4529,7 @@ XnoiseDur_linear_min(XnoiseDur *self) {
static MYFLT
XnoiseDur_linear_max(XnoiseDur *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a > b) return a;
else return b;
@@ -4537,7 +4537,7 @@ XnoiseDur_linear_max(XnoiseDur *self) {
static MYFLT
XnoiseDur_triangle(XnoiseDur *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
return ((a + b) * 0.5);
}
@@ -4546,7 +4546,7 @@ XnoiseDur_triangle(XnoiseDur *self) {
static MYFLT
XnoiseDur_expon_min(XnoiseDur *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = -MYLOG(RANDOM_UNIFORM) / self->xx1;
+ MYFLT val = -MYLOG(RANDOM_UNIFORM) / self->xx1;
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -4555,7 +4555,7 @@ XnoiseDur_expon_min(XnoiseDur *self) {
static MYFLT
XnoiseDur_expon_max(XnoiseDur *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = 1.0 - (-MYLOG(RANDOM_UNIFORM) / self->xx1);
+ MYFLT val = 1.0 - (-MYLOG(RANDOM_UNIFORM) / self->xx1);
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -4567,16 +4567,16 @@ XnoiseDur_biexpon(XnoiseDur *self) {
MYFLT polar, val;
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
MYFLT sum = RANDOM_UNIFORM * 2.0;
-
+
if (sum > 1.0) {
polar = -1;
sum = 2.0 - sum;
}
else
polar = 1;
-
+
val = 0.5 * (polar * MYLOG(sum) / self->xx1) + 0.5;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -4589,14 +4589,14 @@ XnoiseDur_cauchy(XnoiseDur *self) {
rnd = RANDOM_UNIFORM;
}
while (rnd == 0.5);
-
+
if (rand() < (RAND_MAX / 2))
dir = -1;
else
dir = 1;
-
+
val = 0.5 * (MYTAN(rnd) * self->xx1 * dir) + 0.5;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -4607,10 +4607,10 @@ static MYFLT
XnoiseDur_weibull(XnoiseDur *self) {
MYFLT rnd, val;
if (self->xx2 <= 0.0) self->xx2 = 0.00001;
-
+
rnd = 1.0 / (1.0 - RANDOM_UNIFORM);
val = self->xx1 * MYPOW(MYLOG(rnd), (1.0 / self->xx2));
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -4620,10 +4620,10 @@ XnoiseDur_weibull(XnoiseDur *self) {
static MYFLT
XnoiseDur_gaussian(XnoiseDur *self) {
MYFLT rnd, val;
-
+
rnd = (RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM);
val = (self->xx2 * (rnd - 3.0) * 0.33 + self->xx1);
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -4637,7 +4637,7 @@ XnoiseDur_poisson(XnoiseDur *self) {
MYFLT val;
if (self->xx1 < 0.1) self->xx1 = 0.1;
if (self->xx2 < 0.1) self->xx2 = 0.1;
-
+
if (self->xx1 != self->lastPoissonX1) {
self->lastPoissonX1 = self->xx1;
self->poisson_tab = 0;
@@ -4652,7 +4652,7 @@ XnoiseDur_poisson(XnoiseDur *self) {
}
}
val = self->poisson_buffer[rand() % self->poisson_tab] / 12.0 * self->xx2;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -4662,22 +4662,22 @@ XnoiseDur_poisson(XnoiseDur *self) {
static MYFLT
XnoiseDur_walker(XnoiseDur *self) {
int modulo, dir;
-
+
if (self->xx2 < 0.002) self->xx2 = 0.002;
-
+
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
return self->walkerValue;
}
@@ -4685,28 +4685,28 @@ XnoiseDur_walker(XnoiseDur *self) {
static MYFLT
XnoiseDur_loopseg(XnoiseDur *self) {
int modulo, dir;
-
+
if (self->loopChoice == 0) {
-
+
self->loopCountPlay = self->loopTime = 0;
-
+
if (self->xx2 < 0.002) self->xx2 = 0.002;
-
+
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
-
+
if (self->loopCountRec < self->loopLen)
self->loopChoice = 0;
else {
@@ -4716,22 +4716,22 @@ XnoiseDur_loopseg(XnoiseDur *self) {
}
else {
self->loopCountRec = 0;
-
+
self->walkerValue = self->loop_buffer[self->loopCountPlay++];
-
+
if (self->loopCountPlay < self->loopLen)
self->loopChoice = 1;
else {
self->loopCountPlay = 0;
self->loopTime++;
}
-
+
if (self->loopTime == self->loopStop) {
self->loopChoice = 0;
self->loopLen = (rand() % 10) + 3;
}
}
-
+
return self->walkerValue;
}
@@ -4739,7 +4739,7 @@ static void
XnoiseDur_generate(XnoiseDur *self) {
int i;
MYFLT min, max;
-
+
for (i=0; i<self->bufsize; i++) {
self->time += self->inc;
if (self->time < 0.0)
@@ -4787,8 +4787,8 @@ static void XnoiseDur_postprocessing_revareva(XnoiseDur *self) { POST_PROCESSING
static void
XnoiseDur_setRandomType(XnoiseDur *self)
{
-
- switch (self->type) {
+
+ switch (self->type) {
case 0:
self->type_func_ptr = XnoiseDur_uniform;
break;
@@ -4828,7 +4828,7 @@ XnoiseDur_setRandomType(XnoiseDur *self)
case 12:
self->type_func_ptr = XnoiseDur_loopseg;
break;
- }
+ }
}
static void
@@ -4836,44 +4836,44 @@ XnoiseDur_setProcMode(XnoiseDur *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = XnoiseDur_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = XnoiseDur_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = XnoiseDur_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = XnoiseDur_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = XnoiseDur_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = XnoiseDur_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = XnoiseDur_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = XnoiseDur_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = XnoiseDur_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = XnoiseDur_postprocessing_revareva;
break;
- }
+ }
}
static void
XnoiseDur_compute_next_data_frame(XnoiseDur *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4885,14 +4885,14 @@ XnoiseDur_traverse(XnoiseDur *self, visitproc visit, void *arg)
Py_VISIT(self->min_stream);
Py_VISIT(self->max);
Py_VISIT(self->max_stream);
- Py_VISIT(self->x1);
- Py_VISIT(self->x1_stream);
- Py_VISIT(self->x2);
- Py_VISIT(self->x2_stream);
+ Py_VISIT(self->x1);
+ Py_VISIT(self->x1_stream);
+ Py_VISIT(self->x2);
+ Py_VISIT(self->x2_stream);
return 0;
}
-static int
+static int
XnoiseDur_clear(XnoiseDur *self)
{
pyo_CLEAR
@@ -4900,10 +4900,10 @@ XnoiseDur_clear(XnoiseDur *self)
Py_CLEAR(self->min_stream);
Py_CLEAR(self->max);
Py_CLEAR(self->max_stream);
- Py_CLEAR(self->x1);
- Py_CLEAR(self->x1_stream);
- Py_CLEAR(self->x2);
- Py_CLEAR(self->x2_stream);
+ Py_CLEAR(self->x1);
+ Py_CLEAR(self->x1_stream);
+ Py_CLEAR(self->x2);
+ Py_CLEAR(self->x2_stream);
return 0;
}
@@ -4923,7 +4923,7 @@ XnoiseDur_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *mintmp=NULL, *maxtmp=NULL, *x1tmp=NULL, *x2tmp=NULL, *multmp=NULL, *addtmp=NULL;
XnoiseDur *self;
self = (XnoiseDur *)type->tp_alloc(type, 0);
-
+
self->x1 = PyFloat_FromDouble(0.5);
self->x2 = PyFloat_FromDouble(0.5);
self->min = PyFloat_FromDouble(0.0);
@@ -4936,11 +4936,11 @@ XnoiseDur_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
self->modebuffer[5] = 0;
-
+
INIT_OBJECT_COMMON
-
+
Server_generateSeed((Server *)self->server, XNOISEDUR_ID);
-
+
self->poisson_tab = 0;
self->lastPoissonX1 = -99.0;
for (i=0; i<2000; i++) {
@@ -4949,41 +4949,41 @@ XnoiseDur_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<15; i++) {
self->loop_buffer[i] = 0.0;
}
- self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
+ self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
self->loopLen = (rand() % 10) + 3;
-
+
Stream_setFunctionPtr(self->stream, XnoiseDur_compute_next_data_frame);
self->mode_func_ptr = XnoiseDur_setProcMode;
static char *kwlist[] = {"type", "min", "max", "x1", "x2", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iOOOOOO", kwlist, &self->type, &mintmp, &maxtmp, &x1tmp, &x2tmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (x1tmp) {
PyObject_CallMethod((PyObject *)self, "setX1", "O", x1tmp);
}
-
+
if (x2tmp) {
PyObject_CallMethod((PyObject *)self, "setX2", "O", x2tmp);
}
-
+
if (mintmp) {
PyObject_CallMethod((PyObject *)self, "setMin", "O", mintmp);
}
-
+
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
if (self->modebuffer[2] == 0)
@@ -4994,15 +4994,15 @@ XnoiseDur_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
ma = PyFloat_AS_DOUBLE(self->max);
else
ma = Stream_getData((Stream *)self->max_stream)[0];
-
+
self->value = (mi + ma) * 0.5;
if (self->value == 0.0)
self->inc = 0.0;
else
self->inc = (1.0 / self->value) / self->sr;
-
+
XnoiseDur_setRandomType(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -5010,10 +5010,10 @@ XnoiseDur_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * XnoiseDur_getServer(XnoiseDur* self) { GET_SERVER };
static PyObject * XnoiseDur_getStream(XnoiseDur* self) { GET_STREAM };
-static PyObject * XnoiseDur_setMul(XnoiseDur *self, PyObject *arg) { SET_MUL };
-static PyObject * XnoiseDur_setAdd(XnoiseDur *self, PyObject *arg) { SET_ADD };
-static PyObject * XnoiseDur_setSub(XnoiseDur *self, PyObject *arg) { SET_SUB };
-static PyObject * XnoiseDur_setDiv(XnoiseDur *self, PyObject *arg) { SET_DIV };
+static PyObject * XnoiseDur_setMul(XnoiseDur *self, PyObject *arg) { SET_MUL };
+static PyObject * XnoiseDur_setAdd(XnoiseDur *self, PyObject *arg) { SET_ADD };
+static PyObject * XnoiseDur_setSub(XnoiseDur *self, PyObject *arg) { SET_SUB };
+static PyObject * XnoiseDur_setDiv(XnoiseDur *self, PyObject *arg) { SET_DIV };
static PyObject * XnoiseDur_play(XnoiseDur *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * XnoiseDur_out(XnoiseDur *self, PyObject *args, PyObject *kwds) { OUT };
@@ -5030,35 +5030,35 @@ static PyObject * XnoiseDur_inplace_div(XnoiseDur *self, PyObject *arg) { INPLAC
static PyObject *
XnoiseDur_setType(XnoiseDur *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyInt_Check(arg);
-
+
if (isNumber == 1) {
self->type = PyInt_AsLong(arg);
XnoiseDur_setRandomType(self);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
XnoiseDur_setX1(XnoiseDur *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x1);
@@ -5074,25 +5074,25 @@ XnoiseDur_setX1(XnoiseDur *self, PyObject *arg)
self->x1_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
XnoiseDur_setX2(XnoiseDur *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x2);
@@ -5108,25 +5108,25 @@ XnoiseDur_setX2(XnoiseDur *self, PyObject *arg)
self->x2_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
XnoiseDur_setMin(XnoiseDur *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->min);
@@ -5142,25 +5142,25 @@ XnoiseDur_setMin(XnoiseDur *self, PyObject *arg)
self->min_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
XnoiseDur_setMax(XnoiseDur *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -5176,12 +5176,12 @@ XnoiseDur_setMax(XnoiseDur *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[5] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef XnoiseDur_members[] = {
{"server", T_OBJECT_EX, offsetof(XnoiseDur, server), 0, "Pyo server."},
@@ -5312,7 +5312,7 @@ typedef struct {
MYFLT time;
MYFLT *trigsBuffer;
TriggerStream *trig_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} Urn;
static void
@@ -5331,13 +5331,13 @@ Urn_choose(Urn *self) {
int x = 0;
int value = 0;
int i, pick;
-
+
pick = rand() % self->length;
while (pick == self->lastvalue)
pick = rand() % self->length;
for (i=0; i<self->length; i++) {
- if (i != pick)
+ if (i != pick)
self->list[x++] = self->list[i];
else
value = self->list[i];
@@ -5354,7 +5354,7 @@ Urn_generate_i(Urn *self) {
int i;
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
MYFLT inc = fr / self->sr;
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
self->time += inc;
@@ -5377,7 +5377,7 @@ Urn_generate_a(Urn *self) {
int i;
MYFLT inc;
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
inc = fr[i] / self->sr;
@@ -5412,50 +5412,50 @@ Urn_setProcMode(Urn *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Urn_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Urn_generate_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Urn_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Urn_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Urn_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Urn_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Urn_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Urn_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Urn_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Urn_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Urn_postprocessing_revareva;
break;
- }
+ }
}
static void
Urn_compute_next_data_frame(Urn *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -5465,17 +5465,17 @@ Urn_traverse(Urn *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->freq);
Py_VISIT(self->freq_stream);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
Urn_clear(Urn *self)
{
pyo_CLEAR
Py_CLEAR(self->freq);
Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -5496,7 +5496,7 @@ Urn_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
Urn *self;
self = (Urn *)type->tp_alloc(type, 0);
-
+
self->freq = PyFloat_FromDouble(1.);
self->max = 100;
self->length = 0;
@@ -5506,36 +5506,36 @@ Urn_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Urn_compute_next_data_frame);
self->mode_func_ptr = Urn_setProcMode;
static char *kwlist[] = {"max", "freq", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iOOO", kwlist, &self->max, &freqtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
if (freqtmp) {
PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
-
+ }
+
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
@@ -5551,10 +5551,10 @@ Urn_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Urn_getServer(Urn* self) { GET_SERVER };
static PyObject * Urn_getStream(Urn* self) { GET_STREAM };
static PyObject * Urn_getTriggerStream(Urn* self) { GET_TRIGGER_STREAM };
-static PyObject * Urn_setMul(Urn *self, PyObject *arg) { SET_MUL };
-static PyObject * Urn_setAdd(Urn *self, PyObject *arg) { SET_ADD };
-static PyObject * Urn_setSub(Urn *self, PyObject *arg) { SET_SUB };
-static PyObject * Urn_setDiv(Urn *self, PyObject *arg) { SET_DIV };
+static PyObject * Urn_setMul(Urn *self, PyObject *arg) { SET_MUL };
+static PyObject * Urn_setAdd(Urn *self, PyObject *arg) { SET_ADD };
+static PyObject * Urn_setSub(Urn *self, PyObject *arg) { SET_SUB };
+static PyObject * Urn_setDiv(Urn *self, PyObject *arg) { SET_DIV };
static PyObject * Urn_play(Urn *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Urn_out(Urn *self, PyObject *args, PyObject *kwds) { OUT };
@@ -5571,7 +5571,7 @@ static PyObject * Urn_inplace_div(Urn *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
Urn_setMax(Urn *self, PyObject *arg)
-{
+{
if (PyNumber_Check(arg) == 1)
self->max = PyInt_AsLong(arg);
@@ -5579,20 +5579,20 @@ Urn_setMax(Urn *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Urn_setFreq(Urn *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->freq);
@@ -5608,12 +5608,12 @@ Urn_setFreq(Urn *self, PyObject *arg)
self->freq_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Urn_members[] = {
{"server", T_OBJECT_EX, offsetof(Urn, server), 0, "Pyo server."},
@@ -5723,4 +5723,4 @@ Urn_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
Urn_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/recordmodule.c b/src/objects/recordmodule.c
index 1ce6d30..b612fe4 100644
--- a/src/objects/recordmodule.c
+++ b/src/objects/recordmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -50,16 +50,16 @@ Record_process(Record *self) {
MYFLT *in;
totlen = self->chnls*self->bufsize*self->buffering;
-
+
if (self->count == self->buffering) {
self->count = 0;
for (i=0; i<totlen; i++) {
self->buffer[i] = 0.0;
}
- }
+ }
offset = self->bufsize * self->chnls * self->count;
-
+
for (j=0; j<self->listlen; j++) {
chnl = j % self->chnls;
in = Stream_getData((Stream *)PyList_GET_ITEM(self->input_stream_list, j));
@@ -68,21 +68,21 @@ Record_process(Record *self) {
}
}
self->count++;
-
+
if (self->count == self->buffering)
SF_WRITE(self->recfile, self->buffer, totlen);
}
static void
Record_setProcMode(Record *self)
-{
- self->proc_func_ptr = Record_process;
+{
+ self->proc_func_ptr = Record_process;
}
static void
Record_compute_next_data_frame(Record *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -94,7 +94,7 @@ Record_traverse(Record *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Record_clear(Record *self)
{
pyo_CLEAR
@@ -123,20 +123,20 @@ Record_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *input_listtmp;
Record *self;
self = (Record *)type->tp_alloc(type, 0);
-
+
self->chnls = 2;
self->buffering = 4;
self->count = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Record_compute_next_data_frame);
self->mode_func_ptr = Record_setProcMode;
static char *kwlist[] = {"input", "filename", "chnls", "fileformat", "sampletype", "buffering", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|iiii", kwlist, &input_listtmp, &self->recpath, &self->chnls, &fileformat, &sampletype, &self->buffering))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->input_list);
self->input_list = input_listtmp;
self->listlen = PyList_Size(self->input_list);
@@ -148,7 +148,7 @@ Record_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
/* Prepare sfinfo */
self->recinfo.samplerate = (int)self->sr;
self->recinfo.channels = self->chnls;
-
+
switch (fileformat) {
case 0:
self->recinfo.format = SF_FORMAT_WAV;
@@ -200,21 +200,21 @@ Record_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
break;
}
}
-
+
/* Open the output file. */
- if (! (self->recfile = sf_open(self->recpath, SFM_WRITE, &self->recinfo))) {
+ if (! (self->recfile = sf_open(self->recpath, SFM_WRITE, &self->recinfo))) {
printf ("Not able to open output file %s.\n", self->recpath);
Py_RETURN_NONE;
- }
+ }
buflen = self->bufsize * self->chnls * self->buffering;
self->buffer = (MYFLT *)realloc(self->buffer, buflen * sizeof(MYFLT));
for (i=0; i<buflen; i++) {
self->buffer[i] = 0.;
- }
-
+ }
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -224,8 +224,8 @@ static PyObject * Record_getServer(Record* self) { GET_SERVER };
static PyObject * Record_getStream(Record* self) { GET_STREAM };
static PyObject * Record_play(Record *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Record_stop(Record *self)
-{
+static PyObject * Record_stop(Record *self)
+{
sf_close(self->recfile);
STOP
};
@@ -307,9 +307,9 @@ typedef struct {
static void
ControlRec_process(ControlRec *self) {
int i;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->dur > 0.0) {
for (i=0; i<self->bufsize; i++) {
if ((self->time % self->modulo) == 0 && self->count < self->size) {
@@ -319,7 +319,7 @@ ControlRec_process(ControlRec *self) {
self->time++;
if (self->count >= self->size)
PyObject_CallMethod((PyObject *)self, "stop", NULL);
- }
+ }
}
else {
for (i=0; i<self->bufsize; i++) {
@@ -333,14 +333,14 @@ ControlRec_process(ControlRec *self) {
static void
ControlRec_setProcMode(ControlRec *self)
-{
- self->proc_func_ptr = ControlRec_process;
+{
+ self->proc_func_ptr = ControlRec_process;
}
static void
ControlRec_compute_next_data_frame(ControlRec *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -353,7 +353,7 @@ ControlRec_traverse(ControlRec *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
ControlRec_clear(ControlRec *self)
{
pyo_CLEAR
@@ -381,33 +381,33 @@ ControlRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp;
ControlRec *self;
self = (ControlRec *)type->tp_alloc(type, 0);
-
+
self->dur = 0.0;
self->rate = 1000;
self->tmp_list = PyList_New(0);
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, ControlRec_compute_next_data_frame);
self->mode_func_ptr = ControlRec_setProcMode;
static char *kwlist[] = {"input", "rate", "dur", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_IF, kwlist, &inputtmp, &self->rate, &self->dur))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
if (self->dur > 0.0) {
self->size = (long)(self->dur * self->rate + 1);
self->buffer = (MYFLT *)realloc(self->buffer, self->size * sizeof(MYFLT));
for (j=0; j<self->size; j++) {
self->buffer[j] = 0.0;
- }
- }
+ }
+ }
self->modulo = (int)(self->sr / self->rate);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -416,9 +416,9 @@ ControlRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * ControlRec_getServer(ControlRec* self) { GET_SERVER };
static PyObject * ControlRec_getStream(ControlRec* self) { GET_STREAM };
-static PyObject * ControlRec_play(ControlRec *self, PyObject *args, PyObject *kwds) {
+static PyObject * ControlRec_play(ControlRec *self, PyObject *args, PyObject *kwds) {
self->count = self->time = 0;
- PLAY
+ PLAY
};
static PyObject * ControlRec_stop(ControlRec *self) { STOP };
@@ -428,7 +428,7 @@ ControlRec_getData(ControlRec *self) {
int i;
PyObject *data, *point;
MYFLT time, timescl = 1.0 / self->rate;
-
+
if (self->dur > 0.0) {
data = PyList_New(self->size);
for (i=0; i<self->size; i++) {
@@ -437,7 +437,7 @@ ControlRec_getData(ControlRec *self) {
PyTuple_SET_ITEM(point, 0, PyFloat_FromDouble(time));
PyTuple_SET_ITEM(point, 1, PyFloat_FromDouble(self->buffer[i]));
PyList_SetItem(data, i, point);
- }
+ }
}
else {
Py_ssize_t size = PyList_Size(self->tmp_list);
@@ -448,7 +448,7 @@ ControlRec_getData(ControlRec *self) {
PyTuple_SET_ITEM(point, 0, PyFloat_FromDouble(time));
PyTuple_SET_ITEM(point, 1, PyList_GET_ITEM(self->tmp_list, i));
PyList_SetItem(data, i, point);
- }
+ }
}
return data;
}
@@ -536,16 +536,16 @@ ControlRead_readframes_i(ControlRead *self) {
MYFLT fpart;
long i, mod;
MYFLT invmodulo = 1.0 / self->modulo;
-
+
if (self->go == 0)
PyObject_CallMethod((PyObject *)self, "stop", NULL);
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
if (self->go == 1) {
mod = self->time % self->modulo;
fpart = mod * invmodulo;
- self->data[i] = (*self->interp_func_ptr)(self->values, (int)self->count, fpart, (int)self->size);
+ self->data[i] = (*self->interp_func_ptr)(self->values, (int)self->count, fpart, (int)self->size);
}
else {
mod = -1;
@@ -581,44 +581,44 @@ ControlRead_setProcMode(ControlRead *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = ControlRead_readframes_i;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = ControlRead_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = ControlRead_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = ControlRead_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = ControlRead_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = ControlRead_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = ControlRead_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = ControlRead_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = ControlRead_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = ControlRead_postprocessing_revareva;
break;
- }
+ }
}
static void
ControlRead_compute_next_data_frame(ControlRead *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -626,15 +626,15 @@ static int
ControlRead_traverse(ControlRead *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
ControlRead_clear(ControlRead *self)
{
pyo_CLEAR
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -655,74 +655,74 @@ ControlRead_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *valuestmp, *multmp=NULL, *addtmp=NULL;
ControlRead *self;
self = (ControlRead *)type->tp_alloc(type, 0);
-
+
self->loop = 0;
self->rate = 1000;
self->interp = 2;
self->go = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, ControlRead_compute_next_data_frame);
self->mode_func_ptr = ControlRead_setProcMode;
static char *kwlist[] = {"values", "rate", "loop", "interp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iiiOO", kwlist, &valuestmp, &self->rate, &self->loop, &self->interp, &multmp, &addtmp))
Py_RETURN_NONE;
if (valuestmp) {
PyObject_CallMethod((PyObject *)self, "setValues", "O", valuestmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
+ }
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
-
+
self->modulo = (int)(self->sr / self->rate);
(*self->mode_func_ptr)(self);
-
+
SET_INTERP_POINTER
-
+
return (PyObject *)self;
}
static PyObject * ControlRead_getServer(ControlRead* self) { GET_SERVER };
static PyObject * ControlRead_getStream(ControlRead* self) { GET_STREAM };
static PyObject * ControlRead_getTriggerStream(ControlRead* self) { GET_TRIGGER_STREAM };
-static PyObject * ControlRead_setMul(ControlRead *self, PyObject *arg) { SET_MUL };
-static PyObject * ControlRead_setAdd(ControlRead *self, PyObject *arg) { SET_ADD };
-static PyObject * ControlRead_setSub(ControlRead *self, PyObject *arg) { SET_SUB };
-static PyObject * ControlRead_setDiv(ControlRead *self, PyObject *arg) { SET_DIV };
+static PyObject * ControlRead_setMul(ControlRead *self, PyObject *arg) { SET_MUL };
+static PyObject * ControlRead_setAdd(ControlRead *self, PyObject *arg) { SET_ADD };
+static PyObject * ControlRead_setSub(ControlRead *self, PyObject *arg) { SET_SUB };
+static PyObject * ControlRead_setDiv(ControlRead *self, PyObject *arg) { SET_DIV };
-static PyObject * ControlRead_play(ControlRead *self, PyObject *args, PyObject *kwds)
-{
+static PyObject * ControlRead_play(ControlRead *self, PyObject *args, PyObject *kwds)
+{
self->count = self->time = 0;
self->go = 1;
- PLAY
+ PLAY
};
-static PyObject * ControlRead_stop(ControlRead *self)
-{
+static PyObject * ControlRead_stop(ControlRead *self)
+{
self->go = 0;
- STOP
+ STOP
};
static PyObject * ControlRead_multiply(ControlRead *self, PyObject *arg) { MULTIPLY };
@@ -738,21 +738,21 @@ static PyObject *
ControlRead_setValues(ControlRead *self, PyObject *arg)
{
Py_ssize_t i;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->size = PyList_Size(arg);
self->values = (MYFLT *)realloc(self->values, self->size * sizeof(MYFLT));
for (i=0; i<self->size; i++) {
self->values[i] = PyFloat_AS_DOUBLE(PyList_GET_ITEM(arg, i));
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
ControlRead_setRate(ControlRead *self, PyObject *arg)
@@ -761,10 +761,10 @@ ControlRead_setRate(ControlRead *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->rate = PyInt_AsLong(arg);
self->modulo = (int)(self->sr / self->rate);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -776,9 +776,9 @@ ControlRead_setLoop(ControlRead *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->loop = PyInt_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -790,15 +790,15 @@ ControlRead_setInterp(ControlRead *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
SET_INTERP_POINTER
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -934,10 +934,10 @@ static void
NoteinRec_process(NoteinRec *self) {
int i;
MYFLT pit, vel;
-
+
MYFLT *inp = Stream_getData((Stream *)self->inputp_stream);
MYFLT *inv = Stream_getData((Stream *)self->inputv_stream);
-
+
for (i=0; i<self->bufsize; i++) {
pit = inp[i];
vel = inv[i];
@@ -954,14 +954,14 @@ NoteinRec_process(NoteinRec *self) {
static void
NoteinRec_setProcMode(NoteinRec *self)
-{
- self->proc_func_ptr = NoteinRec_process;
+{
+ self->proc_func_ptr = NoteinRec_process;
}
static void
NoteinRec_compute_next_data_frame(NoteinRec *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -978,7 +978,7 @@ NoteinRec_traverse(NoteinRec *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
NoteinRec_clear(NoteinRec *self)
{
pyo_CLEAR
@@ -1007,21 +1007,21 @@ NoteinRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputptmp, *inputp_streamtmp, *inputvtmp, *inputv_streamtmp;
NoteinRec *self;
self = (NoteinRec *)type->tp_alloc(type, 0);
-
+
self->tmp_list_p = PyList_New(0);
self->tmp_list_v = PyList_New(0);
self->tmp_list_t = PyList_New(0);
self->last_pitch = self->last_vel = 0.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, NoteinRec_compute_next_data_frame);
self->mode_func_ptr = NoteinRec_setProcMode;
static char *kwlist[] = {"inputp", "inputv", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &inputptmp, &inputvtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->inputp);
self->inputp = inputptmp;
inputp_streamtmp = PyObject_CallMethod((PyObject *)self->inputp, "_getStream", NULL);
@@ -1035,20 +1035,20 @@ NoteinRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_INCREF(inputv_streamtmp);
Py_XDECREF(self->inputv_stream);
self->inputv_stream = (Stream *)inputv_streamtmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * NoteinRec_getServer(NoteinRec* self) { GET_SERVER };
static PyObject * NoteinRec_getStream(NoteinRec* self) { GET_STREAM };
-static PyObject * NoteinRec_play(NoteinRec *self, PyObject *args, PyObject *kwds) {
+static PyObject * NoteinRec_play(NoteinRec *self, PyObject *args, PyObject *kwds) {
self->time = 0;
- PLAY
+ PLAY
};
static PyObject * NoteinRec_stop(NoteinRec *self) { STOP };
@@ -1057,10 +1057,10 @@ static PyObject *
NoteinRec_getData(NoteinRec *self) {
int i;
PyObject *data, *point;
-
+
Py_ssize_t size = PyList_Size(self->tmp_list_p);
data = PyList_New(size);
-
+
for (i=0; i<size; i++) {
point = PyTuple_New(3);
PyTuple_SET_ITEM(point, 0, PyList_GET_ITEM(self->tmp_list_t, i));
@@ -1151,17 +1151,17 @@ typedef struct {
static void
NoteinRead_readframes_i(NoteinRead *self) {
long i;
-
+
if (self->go == 0)
PyObject_CallMethod((PyObject *)self, "stop", NULL);
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
if (self->go == 1) {
if (self->time >= self->timestamps[self->count]) {
self->value = self->values[self->count];
self->data[i] = self->value;
- self->count++;
+ self->count++;
}
else
self->data[i] = self->value;
@@ -1195,44 +1195,44 @@ NoteinRead_setProcMode(NoteinRead *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = NoteinRead_readframes_i;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = NoteinRead_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = NoteinRead_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = NoteinRead_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = NoteinRead_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = NoteinRead_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = NoteinRead_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = NoteinRead_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = NoteinRead_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = NoteinRead_postprocessing_revareva;
break;
- }
+ }
}
static void
NoteinRead_compute_next_data_frame(NoteinRead *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1240,15 +1240,15 @@ static int
NoteinRead_traverse(NoteinRead *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
NoteinRead_clear(NoteinRead *self)
{
pyo_CLEAR
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -1270,26 +1270,26 @@ NoteinRead_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *valuestmp, *timestampstmp, *multmp=NULL, *addtmp=NULL;
NoteinRead *self;
self = (NoteinRead *)type->tp_alloc(type, 0);
-
+
self->value = 0.0;
self->loop = 0;
self->go = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, NoteinRead_compute_next_data_frame);
self->mode_func_ptr = NoteinRead_setProcMode;
static char *kwlist[] = {"values", "timestamps", "loop", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|iOO", kwlist, &valuestmp, ×tampstmp, &self->loop, &multmp, &addtmp))
Py_RETURN_NONE;
if (valuestmp) {
PyObject_CallMethod((PyObject *)self, "setValues", "O", valuestmp);
}
-
+
if (timestampstmp) {
PyObject_CallMethod((PyObject *)self, "setTimestamps", "O", timestampstmp);
}
@@ -1297,46 +1297,46 @@ NoteinRead_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
+ }
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * NoteinRead_getServer(NoteinRead* self) { GET_SERVER };
static PyObject * NoteinRead_getStream(NoteinRead* self) { GET_STREAM };
static PyObject * NoteinRead_getTriggerStream(NoteinRead* self) { GET_TRIGGER_STREAM };
-static PyObject * NoteinRead_setMul(NoteinRead *self, PyObject *arg) { SET_MUL };
-static PyObject * NoteinRead_setAdd(NoteinRead *self, PyObject *arg) { SET_ADD };
-static PyObject * NoteinRead_setSub(NoteinRead *self, PyObject *arg) { SET_SUB };
-static PyObject * NoteinRead_setDiv(NoteinRead *self, PyObject *arg) { SET_DIV };
+static PyObject * NoteinRead_setMul(NoteinRead *self, PyObject *arg) { SET_MUL };
+static PyObject * NoteinRead_setAdd(NoteinRead *self, PyObject *arg) { SET_ADD };
+static PyObject * NoteinRead_setSub(NoteinRead *self, PyObject *arg) { SET_SUB };
+static PyObject * NoteinRead_setDiv(NoteinRead *self, PyObject *arg) { SET_DIV };
-static PyObject * NoteinRead_play(NoteinRead *self, PyObject *args, PyObject *kwds)
-{
+static PyObject * NoteinRead_play(NoteinRead *self, PyObject *args, PyObject *kwds)
+{
self->count = self->time = 0;
self->go = 1;
- PLAY
+ PLAY
};
-static PyObject * NoteinRead_stop(NoteinRead *self)
-{
+static PyObject * NoteinRead_stop(NoteinRead *self)
+{
self->go = 0;
- STOP
+ STOP
};
static PyObject * NoteinRead_multiply(NoteinRead *self, PyObject *arg) { MULTIPLY };
@@ -1352,42 +1352,42 @@ static PyObject *
NoteinRead_setValues(NoteinRead *self, PyObject *arg)
{
Py_ssize_t i;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->size = PyList_Size(arg);
self->values = (MYFLT *)realloc(self->values, self->size * sizeof(MYFLT));
for (i=0; i<self->size; i++) {
self->values[i] = PyFloat_AS_DOUBLE(PyList_GET_ITEM(arg, i));
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
NoteinRead_setTimestamps(NoteinRead *self, PyObject *arg)
{
Py_ssize_t i;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->size = PyList_Size(arg);
self->timestamps = (long *)realloc(self->timestamps, self->size * sizeof(long));
for (i=0; i<self->size; i++) {
self->timestamps[i] = (long)(PyFloat_AS_DOUBLE(PyList_GET_ITEM(arg, i)) * self->sr);
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
-
+
static PyObject *
NoteinRead_setLoop(NoteinRead *self, PyObject *arg)
{
@@ -1395,9 +1395,9 @@ NoteinRead_setLoop(NoteinRead *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->loop = PyInt_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1509,4 +1509,4 @@ PyTypeObject NoteinReadType = {
0, /* tp_init */
0, /* tp_alloc */
NoteinRead_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/selectmodule.c b/src/objects/selectmodule.c
index 64906fb..aa423d2 100644
--- a/src/objects/selectmodule.c
+++ b/src/objects/selectmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -31,7 +31,7 @@ typedef struct {
Stream *input_stream;
long value;
MYFLT last_value;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
} Select;
static void
@@ -40,14 +40,14 @@ Select_selector(Select *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
if (inval == self->value && inval != self->last_value)
val = 1;
else
val = 0;
-
+
self->last_value = inval;
self->data[i] = val;
}
@@ -67,47 +67,47 @@ static void
Select_setProcMode(Select *self)
{
int muladdmode;
-
+
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
self->proc_func_ptr = Select_selector;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Select_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Select_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Select_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Select_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Select_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Select_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Select_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Select_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Select_postprocessing_revareva;
break;
- }
-
+ }
+
}
static void
Select_compute_next_data_frame(Select *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -115,16 +115,16 @@ static int
Select_traverse(Select *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
return 0;
}
-static int
+static int
Select_clear(Select *self)
{
pyo_CLEAR
- Py_CLEAR(self->input);
+ Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
return 0;
}
@@ -144,7 +144,7 @@ Select_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
Select *self;
self = (Select *)type->tp_alloc(type, 0);
-
+
self->value = 0;
self->last_value = -99.0;
self->modebuffer[0] = 0;
@@ -155,7 +155,7 @@ Select_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Select_setProcMode;
static char *kwlist[] = {"input", "value", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &inputtmp, &self->value, &multmp, &addtmp))
Py_RETURN_NONE;
@@ -164,24 +164,24 @@ Select_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Select_getServer(Select* self) { GET_SERVER };
static PyObject * Select_getStream(Select* self) { GET_STREAM };
-static PyObject * Select_setMul(Select *self, PyObject *arg) { SET_MUL };
-static PyObject * Select_setAdd(Select *self, PyObject *arg) { SET_ADD };
-static PyObject * Select_setSub(Select *self, PyObject *arg) { SET_SUB };
-static PyObject * Select_setDiv(Select *self, PyObject *arg) { SET_DIV };
+static PyObject * Select_setMul(Select *self, PyObject *arg) { SET_MUL };
+static PyObject * Select_setAdd(Select *self, PyObject *arg) { SET_ADD };
+static PyObject * Select_setSub(Select *self, PyObject *arg) { SET_SUB };
+static PyObject * Select_setDiv(Select *self, PyObject *arg) { SET_DIV };
static PyObject * Select_play(Select *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Select_stop(Select *self) { STOP };
@@ -202,14 +202,14 @@ Select_setValue(Select *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
- if (PyLong_Check(arg) || PyInt_Check(arg)) {
+
+ if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->value = PyLong_AsLong(arg);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Select_members[] = {
{"server", T_OBJECT_EX, offsetof(Select, server), 0, "Pyo server."},
@@ -321,7 +321,7 @@ typedef struct {
PyObject *input;
Stream *input_stream;
MYFLT last_value;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
} Change;
static void
@@ -330,7 +330,7 @@ Change_selector(Change *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
if (inval < (self->last_value - 0.00001) || inval > (self->last_value + 0.00001)) {
@@ -363,40 +363,40 @@ Change_setProcMode(Change *self)
self->proc_func_ptr = Change_selector;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Change_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Change_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Change_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Change_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Change_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Change_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Change_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Change_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Change_postprocessing_revareva;
break;
- }
+ }
}
static void
Change_compute_next_data_frame(Change *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -404,16 +404,16 @@ static int
Change_traverse(Change *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
return 0;
}
-static int
+static int
Change_clear(Change *self)
{
pyo_CLEAR
- Py_CLEAR(self->input);
+ Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
return 0;
}
@@ -443,7 +443,7 @@ Change_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Change_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
@@ -452,24 +452,24 @@ Change_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Change_getServer(Change* self) { GET_SERVER };
static PyObject * Change_getStream(Change* self) { GET_STREAM };
-static PyObject * Change_setMul(Change *self, PyObject *arg) { SET_MUL };
-static PyObject * Change_setAdd(Change *self, PyObject *arg) { SET_ADD };
-static PyObject * Change_setSub(Change *self, PyObject *arg) { SET_SUB };
-static PyObject * Change_setDiv(Change *self, PyObject *arg) { SET_DIV };
+static PyObject * Change_setMul(Change *self, PyObject *arg) { SET_MUL };
+static PyObject * Change_setAdd(Change *self, PyObject *arg) { SET_ADD };
+static PyObject * Change_setSub(Change *self, PyObject *arg) { SET_SUB };
+static PyObject * Change_setDiv(Change *self, PyObject *arg) { SET_DIV };
static PyObject * Change_play(Change *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Change_stop(Change *self) { STOP };
@@ -585,4 +585,4 @@ Change_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
Change_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/sfplayermodule.c b/src/objects/sfplayermodule.c
index 4e6c5ef..0a9c2e7 100644
--- a/src/objects/sfplayermodule.c
+++ b/src/objects/sfplayermodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -58,9 +58,9 @@ MYFLT max_arr(MYFLT *a,int n)
MYFLT m;
m=*a;
for (i=1; i<n; i++) {
- if (m < *(a+i))
+ if (m < *(a+i))
m = *(a+i);
- }
+ }
return m;
}
@@ -70,9 +70,9 @@ MYFLT min_arr(MYFLT *a,int n)
MYFLT m;
m=*a;
for (i=1; i<n; i++) {
- if (m > *(a+i))
+ if (m > *(a+i))
m = *(a+i);
- }
+ }
return m;
}
@@ -87,12 +87,12 @@ SfPlayer_readframes_i(SfPlayer *self) {
else
sp = Stream_getData((Stream *)self->speed_stream)[0];
delta = MYFABS(sp) * self->srScale;
-
+
buflen = (int)(self->bufsize * delta + 0.5) + 64;
totlen = self->sndChnls*buflen;
MYFLT buffer[totlen];
MYFLT buffer2[self->sndChnls][buflen];
-
+
if (sp > 0) { /* forward reading */
if (self->pointerPos >= self->sndSize) {
self->pointerPos -= self->sndSize - self->startPos;
@@ -100,19 +100,19 @@ SfPlayer_readframes_i(SfPlayer *self) {
PyObject_CallMethod((PyObject *)self, "stop", NULL);
for (i=0; i<(self->bufsize * self->sndChnls); i++) {
self->samplesBuffer[i] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
}
return;
}
- }
+ }
index = (int)self->pointerPos;
sf_seek(self->sf, index, SEEK_SET); /* sets position pointer in the file */
/* fill a buffer with enough samples to satisfy speed reading */
/* if not enough samples left in the file */
- if ((index+buflen) > self->sndSize) {
+ if ((index+buflen) > self->sndSize) {
shortbuflen = self->sndSize - index;
pad = (buflen-shortbuflen)*self->sndChnls;
SF_READ(self->sf, buffer, shortbuflen*self->sndChnls);
@@ -128,16 +128,16 @@ SfPlayer_readframes_i(SfPlayer *self) {
for (i=0; i<(pad); i++) {
buffer[i+shortbuflen*self->sndChnls] = buftemp[i];
}
- }
+ }
}
else /* without zero padding */
SF_READ(self->sf, buffer, totlen);
-
+
/* de-interleave samples */
for (i=0; i<totlen; i++) {
buffer2[i%self->sndChnls][(int)(i/self->sndChnls)] = buffer[i];
}
-
+
/* fill samplesBuffer with samples */
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
@@ -146,7 +146,7 @@ SfPlayer_readframes_i(SfPlayer *self) {
frac = bufpos - bufindex;
for (j=0; j<self->sndChnls; j++) {
self->samplesBuffer[i+(j*self->bufsize)] = (*self->interp_func_ptr)(buffer2[j], bufindex, frac, buflen);
- }
+ }
self->pointerPos += delta;
}
if (self->pointerPos >= self->sndSize)
@@ -165,16 +165,16 @@ SfPlayer_readframes_i(SfPlayer *self) {
PyObject_CallMethod((PyObject *)self, "stop", NULL);
for (i=0; i<(self->bufsize * self->sndChnls); i++) {
self->samplesBuffer[i] = 0.0;
- }
+ }
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
}
return;
}
}
-
+
index = (int)self->pointerPos + 1;
-
+
/* fill a buffer with enough samples to satisfy speed reading */
/* if not enough samples to read in the file */
if ((index-buflen) < 0) {
@@ -195,35 +195,35 @@ SfPlayer_readframes_i(SfPlayer *self) {
buffer[i] = buftemp[i];
}
}
-
+
MYFLT buftemp2[shortbuflen*self->sndChnls];
sf_seek(self->sf, 0, SEEK_SET); /* sets position pointer in the file */
SF_READ(self->sf, buftemp2, shortbuflen*self->sndChnls);
for (i=0; i<(shortbuflen*self->sndChnls); i++) {
buffer[i+padlen] = buftemp2[i];
- }
+ }
}
else /* without zero padding */
sf_seek(self->sf, index-buflen, SEEK_SET); /* sets position pointer in the file */
SF_READ(self->sf, buffer, totlen);
-
+
/* de-interleave samples */
for (i=0; i<totlen; i++) {
buffer2[i%self->sndChnls][(int)(i/self->sndChnls)] = buffer[i];
}
-
+
/* reverse arrays */
MYFLT swap;
for (i=0; i<self->sndChnls; i++) {
int a;
- int b = buflen;
+ int b = buflen;
for (a=0; a<--b; a++) { //increment a and decrement b until they meet eachother
swap = buffer2[i][a]; //put what's in a into swap space
buffer2[i][a] = buffer2[i][b]; //put what's in b into a
buffer2[i][b] = swap; //put what's in the swap (a) into b
}
}
-
+
/* fill stream buffer with samples */
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
@@ -247,7 +247,7 @@ SfPlayer_readframes_i(SfPlayer *self) {
self->samplesBuffer[i] = 0.0;
}
}
-}
+}
static void
SfPlayer_setProcMode(SfPlayer *self)
@@ -258,26 +258,26 @@ SfPlayer_setProcMode(SfPlayer *self)
static void
SfPlayer_compute_next_data_frame(SfPlayer *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
SfPlayer_traverse(SfPlayer *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->speed);
- Py_VISIT(self->speed_stream);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->speed);
+ Py_VISIT(self->speed_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
SfPlayer_clear(SfPlayer *self)
{
pyo_CLEAR
- Py_CLEAR(self->speed);
- Py_CLEAR(self->speed_stream);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->speed);
+ Py_CLEAR(self->speed_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -301,7 +301,7 @@ SfPlayer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *speedtmp=NULL;
SfPlayer *self;
self = (SfPlayer *)type->tp_alloc(type, 0);
-
+
self->speed = PyFloat_FromDouble(1);
self->loop = 0;
self->interp = 2;
@@ -313,20 +313,20 @@ SfPlayer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = SfPlayer_setProcMode;
static char *kwlist[] = {"path", "speed", "loop", "offset", "interp", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_S__OIFI, kwlist, &self->path, &speedtmp, &self->loop, &offset, &self->interp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (speedtmp) {
PyObject_CallMethod((PyObject *)self, "setSpeed", "O", speedtmp);
}
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
SET_INTERP_POINTER
-
+
/* Open the sound file. */
self->info.format = 0;
self->sf = sf_open(self->path, SFM_READ, &self->info);
@@ -344,17 +344,17 @@ SfPlayer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
+ }
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
-
+
self->startPos = offset * self->sr * self->srScale;
if (self->startPos < 0.0 || self->startPos >= self->sndSize)
self->startPos = 0.0;
-
+
self->pointerPos = self->startPos;
-
+
return (PyObject *)self;
}
@@ -363,7 +363,7 @@ static PyObject * SfPlayer_getStream(SfPlayer* self) { GET_STREAM };
static PyObject * SfPlayer_getTriggerStream(SfPlayer* self) { GET_TRIGGER_STREAM };
static PyObject * SfPlayer_play(SfPlayer *self, PyObject *args, PyObject *kwds)
-{
+{
self->init = 1;
self->pointerPos = self->startPos;
PLAY
@@ -382,14 +382,14 @@ static PyObject *
SfPlayer_setSpeed(SfPlayer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->speed);
@@ -405,12 +405,12 @@ SfPlayer_setSpeed(SfPlayer *self, PyObject *arg)
self->speed_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SfPlayer_setSound(SfPlayer *self, PyObject *arg)
@@ -420,7 +420,7 @@ SfPlayer_setSound(SfPlayer *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->path = PyString_AsString(arg);
sf_close(self->sf);
@@ -436,12 +436,12 @@ SfPlayer_setSound(SfPlayer *self, PyObject *arg)
self->sndSr = self->info.samplerate;
//self->sndChnls = self->info.channels;
self->srScale = self->sndSr / self->sr;
-
+
//self->samplesBuffer = (MYFLT *)realloc(self->samplesBuffer, self->bufsize * self->sndChnls * sizeof(MYFLT));
-
+
self->startPos = 0.0;
self->pointerPos = self->startPos;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -453,9 +453,9 @@ SfPlayer_setLoop(SfPlayer *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->loop = PyInt_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -467,14 +467,14 @@ SfPlayer_setOffset(SfPlayer *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
if (isNumber == 1) {
self->startPos = PyFloat_AsDouble(PyNumber_Float(arg)) * self->sr * self->srScale;
if (self->startPos < 0.0 || self->startPos >= self->sndSize)
self->startPos = 0.0;
- }
+ }
Py_INCREF(Py_None);
return Py_None;
@@ -487,15 +487,15 @@ SfPlayer_setInterp(SfPlayer *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
+ }
SET_INTERP_POINTER
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -504,7 +504,7 @@ MYFLT *
SfPlayer_getSamplesBuffer(SfPlayer *self)
{
return (MYFLT *)self->samplesBuffer;
-}
+}
static PyMemberDef SfPlayer_members[] = {
{"server", T_OBJECT_EX, offsetof(SfPlayer, server), 0, "Pyo server."},
@@ -578,7 +578,7 @@ typedef struct {
pyo_audio_HEAD
SfPlayer *mainPlayer;
int modebuffer[2];
- int chnl;
+ int chnl;
} SfPlay;
static void SfPlay_postprocessing_ii(SfPlay *self) { POST_PROCESSING_II };
@@ -596,33 +596,33 @@ SfPlay_setProcMode(SfPlay *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SfPlay_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SfPlay_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SfPlay_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SfPlay_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SfPlay_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SfPlay_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SfPlay_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SfPlay_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SfPlay_postprocessing_revareva;
break;
}
@@ -637,7 +637,7 @@ SfPlay_compute_next_data_frame(SfPlay *self)
tmp = SfPlayer_getSamplesBuffer((SfPlayer *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -649,11 +649,11 @@ SfPlay_traverse(SfPlay *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
SfPlay_clear(SfPlay *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -672,45 +672,45 @@ SfPlay_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
SfPlay *self;
self = (SfPlay *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SfPlay_compute_next_data_frame);
self->mode_func_ptr = SfPlay_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (SfPlayer *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * SfPlay_getServer(SfPlay* self) { GET_SERVER };
static PyObject * SfPlay_getStream(SfPlay* self) { GET_STREAM };
-static PyObject * SfPlay_setMul(SfPlay *self, PyObject *arg) { SET_MUL };
-static PyObject * SfPlay_setAdd(SfPlay *self, PyObject *arg) { SET_ADD };
-static PyObject * SfPlay_setSub(SfPlay *self, PyObject *arg) { SET_SUB };
-static PyObject * SfPlay_setDiv(SfPlay *self, PyObject *arg) { SET_DIV };
+static PyObject * SfPlay_setMul(SfPlay *self, PyObject *arg) { SET_MUL };
+static PyObject * SfPlay_setAdd(SfPlay *self, PyObject *arg) { SET_ADD };
+static PyObject * SfPlay_setSub(SfPlay *self, PyObject *arg) { SET_SUB };
+static PyObject * SfPlay_setDiv(SfPlay *self, PyObject *arg) { SET_DIV };
static PyObject * SfPlay_play(SfPlay *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SfPlay_out(SfPlay *self, PyObject *args, PyObject *kwds) { OUT };
@@ -874,7 +874,7 @@ SfMarkerShuffler_readframes_i(SfMarkerShuffler *self) {
sp = Stream_getData((Stream *)self->speed_stream)[0];
delta = MYFABS(sp) * self->srScale;
-
+
buflen = (int)(self->bufsize * delta + 0.5) + 64;
totlen = self->sndChnls*buflen;
MYFLT buffer[totlen];
@@ -894,7 +894,7 @@ SfMarkerShuffler_readframes_i(SfMarkerShuffler *self) {
}
index = (int)self->pointerPos;
sf_seek(self->sf, index, SEEK_SET); /* sets position pointer in the file */
-
+
/* fill a buffer with enough samples to satisfy speed reading */
/* if not enough samples to read in the file */
if ((index+buflen) > self->endPos) {
@@ -913,12 +913,12 @@ SfMarkerShuffler_readframes_i(SfMarkerShuffler *self) {
}
else /* without wraparound */
SF_READ(self->sf, buffer, totlen);
-
+
/* de-interleave samples */
for (i=0; i<totlen; i++) {
buffer2[i%self->sndChnls][(int)(i/self->sndChnls)] = buffer[i];
}
-
+
/* fill data with samples */
for (i=0; i<self->bufsize; i++) {
bufpos = self->pointerPos - index;
@@ -926,7 +926,7 @@ SfMarkerShuffler_readframes_i(SfMarkerShuffler *self) {
frac = bufpos - bufindex;
for (j=0; j<self->sndChnls; j++) {
self->samplesBuffer[i+(j*self->bufsize)] = (*self->interp_func_ptr)(buffer2[j], bufindex, frac, buflen);
- }
+ }
self->pointerPos += delta;
}
if (self->pointerPos >= self->endPos) {
@@ -940,9 +940,9 @@ SfMarkerShuffler_readframes_i(SfMarkerShuffler *self) {
self->lastDir = self->startPos = -1;
SfMarkerShuffler_chooseNewMark((SfMarkerShuffler *)self, 0);
self->pointerPos = self->startPos;
- }
+ }
index = (int)self->pointerPos + 1;
-
+
/* fill a buffer with enough samples to satisfy speed reading */
/* if not enough samples to read in the file */
if ((index-buflen) < self->endPos) {
@@ -957,13 +957,13 @@ SfMarkerShuffler_readframes_i(SfMarkerShuffler *self) {
for (i=0; i<padlen; i++) {
buffer[i] = buftemp[i];
}
-
+
MYFLT buftemp2[shortbuflen*self->sndChnls];
sf_seek(self->sf, self->endPos, SEEK_SET); /* sets position pointer in the file */
SF_READ(self->sf, buftemp2, shortbuflen*self->sndChnls);
for (i=0; i<(shortbuflen*self->sndChnls); i++) {
buffer[i+padlen] = buftemp2[i];
- }
+ }
}
else { /* without wraparound */
sf_seek(self->sf, index-buflen, SEEK_SET); /* sets position pointer in the file */
@@ -973,19 +973,19 @@ SfMarkerShuffler_readframes_i(SfMarkerShuffler *self) {
for (i=0; i<totlen; i++) {
buffer2[i%self->sndChnls][(int)(i/self->sndChnls)] = buffer[i];
}
-
+
/* reverse arrays */
MYFLT swap;
for (i=0; i<self->sndChnls; i++) {
int a;
- int b = buflen;
+ int b = buflen;
for (a=0; a<--b; a++) { //increment a and decrement b until they meet eachother
swap = buffer2[i][a]; //put what's in a into swap space
buffer2[i][a] = buffer2[i][b]; //put what's in b into a
buffer2[i][b] = swap; //put what's in the swap (a) into b
}
}
-
+
/* fill stream buffer with samples */
for (i=0; i<self->bufsize; i++) {
bufpos = index - self->pointerPos;
@@ -1008,7 +1008,7 @@ SfMarkerShuffler_readframes_i(SfMarkerShuffler *self) {
self->samplesBuffer[i] = 0.0;
}
}
-}
+}
static void
SfMarkerShuffler_setProcMode(SfMarkerShuffler *self)
@@ -1019,11 +1019,11 @@ SfMarkerShuffler_setProcMode(SfMarkerShuffler *self)
static void
SfMarkerShuffler_compute_next_data_frame(SfMarkerShuffler *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static void
-SfMarkerShuffler_chooseNewMark(SfMarkerShuffler *self, int dir)
+SfMarkerShuffler_chooseNewMark(SfMarkerShuffler *self, int dir)
{
int mark;
if (dir == 1) {
@@ -1036,7 +1036,7 @@ SfMarkerShuffler_chooseNewMark(SfMarkerShuffler *self, int dir)
self->startPos = self->nextStartPos;
self->endPos = self->nextEndPos;
}
-
+
mark = (int)(self->markers_size * (rand()/((MYFLT)(RAND_MAX)+1)));
self->nextStartPos = self->markers[mark] * self->srScale;
self->nextEndPos = self->markers[mark+1] * self->srScale;
@@ -1051,7 +1051,7 @@ SfMarkerShuffler_chooseNewMark(SfMarkerShuffler *self, int dir)
self->startPos = self->nextStartPos;
self->endPos = self->nextEndPos;
}
-
+
mark = self->markers_size - (int)(self->markers_size * (rand()/((MYFLT)(RAND_MAX)+1)));
self->nextStartPos = self->markers[mark] * self->srScale;
self->nextEndPos = self->markers[mark-1] * self->srScale;
@@ -1067,7 +1067,7 @@ SfMarkerShuffler_setMarkers(SfMarkerShuffler *self, PyObject *markerstmp)
self->markers[0] = 0.;
for (i=0; i<len; i++) {
self->markers[i+1] = PyFloat_AsDouble(PyList_GetItem(markerstmp, i));
- }
+ }
self->markers[len+1] = self->sndSize;
self->markers_size = (int)len+1;
}
@@ -1076,17 +1076,17 @@ static int
SfMarkerShuffler_traverse(SfMarkerShuffler *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->speed);
- Py_VISIT(self->speed_stream);
+ Py_VISIT(self->speed);
+ Py_VISIT(self->speed_stream);
return 0;
}
-static int
+static int
SfMarkerShuffler_clear(SfMarkerShuffler *self)
{
pyo_CLEAR
- Py_CLEAR(self->speed);
- Py_CLEAR(self->speed_stream);
+ Py_CLEAR(self->speed);
+ Py_CLEAR(self->speed_stream);
return 0;
}
@@ -1109,7 +1109,7 @@ SfMarkerShuffler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *speedtmp=NULL, *markerstmp=NULL;
SfMarkerShuffler *self;
self = (SfMarkerShuffler *)type->tp_alloc(type, 0);
-
+
self->speed = PyFloat_FromDouble(1);
self->interp = 2;
self->startPos = -1;
@@ -1121,18 +1121,18 @@ SfMarkerShuffler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = SfMarkerShuffler_setProcMode;
static char *kwlist[] = {"path", "markers", "speed", "interp", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "sO|Oi", kwlist, &self->path, &markerstmp, &speedtmp, &self->interp))
Py_RETURN_NONE;
if (speedtmp) {
PyObject_CallMethod((PyObject *)self, "setSpeed", "O", speedtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
if (self->interp == 0)
self->interp = 2;
if (self->interp == 1)
@@ -1143,7 +1143,7 @@ SfMarkerShuffler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->interp_func_ptr = cosine;
else if (self->interp == 4)
self->interp_func_ptr = cubic;
-
+
/* Open the sound file. */
self->info.format = 0;
self->sf = sf_open(self->path, SFM_READ, &self->info);
@@ -1163,7 +1163,7 @@ SfMarkerShuffler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->samplesBuffer = (MYFLT *)realloc(self->samplesBuffer, self->bufsize * self->sndChnls * sizeof(MYFLT));
Server_generateSeed((Server *)self->server, SFMARKERSHUFFLER_ID);
-
+
return (PyObject *)self;
}
@@ -1178,14 +1178,14 @@ static PyObject *
SfMarkerShuffler_setSpeed(SfMarkerShuffler *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->speed);
@@ -1201,12 +1201,12 @@ SfMarkerShuffler_setSpeed(SfMarkerShuffler *self, PyObject *arg)
self->speed_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SfMarkerShuffler_setInterp(SfMarkerShuffler *self, PyObject *arg)
@@ -1215,13 +1215,13 @@ SfMarkerShuffler_setInterp(SfMarkerShuffler *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
if (self->interp == 0)
self->interp = 2;
if (self->interp == 1)
@@ -1232,7 +1232,7 @@ SfMarkerShuffler_setInterp(SfMarkerShuffler *self, PyObject *arg)
self->interp_func_ptr = cosine;
else if (self->interp == 4)
self->interp_func_ptr = cubic;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1241,7 +1241,7 @@ MYFLT *
SfMarkerShuffler_getSamplesBuffer(SfMarkerShuffler *self)
{
return (MYFLT *)self->samplesBuffer;
-}
+}
static PyMemberDef SfMarkerShuffler_members[] = {
{"server", T_OBJECT_EX, offsetof(SfMarkerShuffler, server), 0, "Pyo server."},
@@ -1310,7 +1310,7 @@ typedef struct {
pyo_audio_HEAD
SfMarkerShuffler *mainPlayer;
int modebuffer[2];
- int chnl;
+ int chnl;
} SfMarkerShuffle;
static void SfMarkerShuffle_postprocessing_ii(SfMarkerShuffle *self) { POST_PROCESSING_II };
@@ -1330,31 +1330,31 @@ SfMarkerShuffle_setProcMode(SfMarkerShuffle *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SfMarkerShuffle_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SfMarkerShuffle_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SfMarkerShuffle_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SfMarkerShuffle_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SfMarkerShuffle_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SfMarkerShuffle_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SfMarkerShuffle_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SfMarkerShuffle_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SfMarkerShuffle_postprocessing_revareva;
break;
}
@@ -1369,7 +1369,7 @@ SfMarkerShuffle_compute_next_data_frame(SfMarkerShuffle *self)
tmp = SfMarkerShuffler_getSamplesBuffer((SfMarkerShuffler *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -1381,11 +1381,11 @@ SfMarkerShuffle_traverse(SfMarkerShuffle *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
SfMarkerShuffle_clear(SfMarkerShuffle *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -1404,45 +1404,45 @@ SfMarkerShuffle_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
SfMarkerShuffle *self;
self = (SfMarkerShuffle *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SfMarkerShuffle_compute_next_data_frame);
self->mode_func_ptr = SfMarkerShuffle_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (SfMarkerShuffler *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * SfMarkerShuffle_getServer(SfMarkerShuffle* self) { GET_SERVER };
static PyObject * SfMarkerShuffle_getStream(SfMarkerShuffle* self) { GET_STREAM };
-static PyObject * SfMarkerShuffle_setMul(SfMarkerShuffle *self, PyObject *arg) { SET_MUL };
-static PyObject * SfMarkerShuffle_setAdd(SfMarkerShuffle *self, PyObject *arg) { SET_ADD };
-static PyObject * SfMarkerShuffle_setSub(SfMarkerShuffle *self, PyObject *arg) { SET_SUB };
-static PyObject * SfMarkerShuffle_setDiv(SfMarkerShuffle *self, PyObject *arg) { SET_DIV };
+static PyObject * SfMarkerShuffle_setMul(SfMarkerShuffle *self, PyObject *arg) { SET_MUL };
+static PyObject * SfMarkerShuffle_setAdd(SfMarkerShuffle *self, PyObject *arg) { SET_ADD };
+static PyObject * SfMarkerShuffle_setSub(SfMarkerShuffle *self, PyObject *arg) { SET_SUB };
+static PyObject * SfMarkerShuffle_setDiv(SfMarkerShuffle *self, PyObject *arg) { SET_DIV };
static PyObject * SfMarkerShuffle_play(SfMarkerShuffle *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SfMarkerShuffle_out(SfMarkerShuffle *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1602,19 +1602,19 @@ SfMarkerLooper_readframes_i(SfMarkerLooper *self) {
MYFLT sp, frac, bufpos, delta, tmp;
int i, j, totlen, buflen, shortbuflen, bufindex;
sf_count_t index;
-
- if (self->modebuffer[0] == 0)
+
+ if (self->modebuffer[0] == 0)
sp = PyFloat_AS_DOUBLE(self->speed);
else
sp = Stream_getData((Stream *)self->speed_stream)[0];
delta = MYFABS(sp) * self->srScale;
-
+
buflen = (int)(self->bufsize * delta + 0.5) + 64;
totlen = self->sndChnls*buflen;
MYFLT buffer[totlen];
MYFLT buffer2[self->sndChnls][buflen];
-
+
if (sp > 0) { /* reading forward */
if (self->startPos == -1 || self->lastDir == 0) {
self->lastDir = 1;
@@ -1629,13 +1629,13 @@ SfMarkerLooper_readframes_i(SfMarkerLooper *self) {
}
index = (int)self->pointerPos;
sf_seek(self->sf, index, SEEK_SET); /* sets position pointer in the file */
-
+
/* fill a buffer with enough samples to satisfy speed reading */
/* if not enough samples to read in the file */
if ((index+buflen) > self->endPos) {
shortbuflen = self->endPos - index;
SF_READ(self->sf, buffer, shortbuflen*self->sndChnls);
-
+
/* wrap around and read new samples if loop */
int pad = buflen - shortbuflen;
int padlen = pad*self->sndChnls;
@@ -1648,12 +1648,12 @@ SfMarkerLooper_readframes_i(SfMarkerLooper *self) {
}
else /* without zero padding */
SF_READ(self->sf, buffer, totlen);
-
+
/* de-interleave samples */
for (i=0; i<totlen; i++) {
buffer2[i%self->sndChnls][(int)(i/self->sndChnls)] = buffer[i];
}
-
+
/* fill data with samples */
for (i=0; i<self->bufsize; i++) {
bufpos = self->pointerPos - index;
@@ -1661,7 +1661,7 @@ SfMarkerLooper_readframes_i(SfMarkerLooper *self) {
frac = bufpos - bufindex;
for (j=0; j<self->sndChnls; j++) {
self->samplesBuffer[i+(j*self->bufsize)] = (*self->interp_func_ptr)(buffer2[j], bufindex, frac, buflen);
- }
+ }
self->pointerPos += delta;
}
if (self->pointerPos >= self->endPos) {
@@ -1675,16 +1675,16 @@ SfMarkerLooper_readframes_i(SfMarkerLooper *self) {
self->lastDir = self->startPos = -1;
SfMarkerLooper_chooseNewMark((SfMarkerLooper *)self, 0);
self->pointerPos = self->startPos;
- }
+ }
index = (int)self->pointerPos + 1;
-
+
/* fill a buffer with enough samples to satisfy speed reading */
/* if not enough samples to read in the file */
if ((index-buflen) < self->endPos) {
shortbuflen = index - self->endPos;
int pad = buflen - shortbuflen;
int padlen = pad*self->sndChnls;
-
+
/* wrap around and read new samples if loop */
MYFLT buftemp[padlen];
sf_seek(self->sf, (int)self->nextStartPos-pad, SEEK_SET);
@@ -1692,13 +1692,13 @@ SfMarkerLooper_readframes_i(SfMarkerLooper *self) {
for (i=0; i<padlen; i++) {
buffer[i] = buftemp[i];
}
-
+
MYFLT buftemp2[shortbuflen*self->sndChnls];
sf_seek(self->sf, self->endPos, SEEK_SET); /* sets position pointer in the file */
SF_READ(self->sf, buftemp2, shortbuflen*self->sndChnls);
for (i=0; i<(shortbuflen*self->sndChnls); i++) {
buffer[i+padlen] = buftemp2[i];
- }
+ }
}
else { /* without zero padding */
sf_seek(self->sf, index-buflen, SEEK_SET); /* sets position pointer in the file */
@@ -1708,19 +1708,19 @@ SfMarkerLooper_readframes_i(SfMarkerLooper *self) {
for (i=0; i<totlen; i++) {
buffer2[i%self->sndChnls][(int)(i/self->sndChnls)] = buffer[i];
}
-
+
/* reverse arrays */
MYFLT swap;
for (i=0; i<self->sndChnls; i++) {
int a;
- int b = buflen;
+ int b = buflen;
for (a=0; a<--b; a++) { //increment a and decrement b until they meet eachother
swap = buffer2[i][a]; //put what's in a into swap space
buffer2[i][a] = buffer2[i][b]; //put what's in b into a
buffer2[i][b] = swap; //put what's in the swap (a) into b
}
}
-
+
/* fill stream buffer with samples */
for (i=0; i<self->bufsize; i++) {
bufpos = index - self->pointerPos;
@@ -1743,7 +1743,7 @@ SfMarkerLooper_readframes_i(SfMarkerLooper *self) {
self->samplesBuffer[i] = 0.0;
}
}
-}
+}
static void
SfMarkerLooper_setProcMode(SfMarkerLooper *self)
@@ -1754,14 +1754,14 @@ SfMarkerLooper_setProcMode(SfMarkerLooper *self)
static void
SfMarkerLooper_compute_next_data_frame(SfMarkerLooper *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static void
-SfMarkerLooper_chooseNewMark(SfMarkerLooper *self, int dir)
+SfMarkerLooper_chooseNewMark(SfMarkerLooper *self, int dir)
{
int mark;
-
+
if (self->modebuffer[1] == 0)
mark = (int)(PyFloat_AS_DOUBLE(self->mark));
else
@@ -1770,7 +1770,7 @@ SfMarkerLooper_chooseNewMark(SfMarkerLooper *self, int dir)
if (mark < 0 || mark >= self->markers_size) {
mark = self->markers_size / 2;
}
-
+
self->old_mark = mark;
if (dir == 1) {
@@ -1809,7 +1809,7 @@ SfMarkerLooper_setMarkers(SfMarkerLooper *self, PyObject *markerstmp)
self->markers[0] = 0.;
for (i=0; i<len; i++) {
self->markers[i+1] = PyFloat_AsDouble(PyList_GetItem(markerstmp, i));
- }
+ }
self->markers[len+1] = self->sndSize;
self->markers_size = (int)len+1;
}
@@ -1818,21 +1818,21 @@ static int
SfMarkerLooper_traverse(SfMarkerLooper *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->speed);
- Py_VISIT(self->speed_stream);
- Py_VISIT(self->mark);
- Py_VISIT(self->mark_stream);
+ Py_VISIT(self->speed);
+ Py_VISIT(self->speed_stream);
+ Py_VISIT(self->mark);
+ Py_VISIT(self->mark_stream);
return 0;
}
-static int
+static int
SfMarkerLooper_clear(SfMarkerLooper *self)
{
pyo_CLEAR
- Py_CLEAR(self->speed);
- Py_CLEAR(self->speed_stream);
- Py_CLEAR(self->mark);
- Py_CLEAR(self->mark_stream);
+ Py_CLEAR(self->speed);
+ Py_CLEAR(self->speed_stream);
+ Py_CLEAR(self->mark);
+ Py_CLEAR(self->mark_stream);
return 0;
}
@@ -1855,7 +1855,7 @@ SfMarkerLooper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *speedtmp=NULL, *marktmp=NULL, *markerstmp=NULL;
SfMarkerLooper *self;
self = (SfMarkerLooper *)type->tp_alloc(type, 0);
-
+
self->speed = PyFloat_FromDouble(1);
self->mark = PyFloat_FromDouble(0);
self->interp = 2;
@@ -1863,18 +1863,18 @@ SfMarkerLooper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->endPos = -1;
self->old_mark = -1;
self->lastDir = 1;
- self->modebuffer[0] = 0;
+ self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SfMarkerLooper_compute_next_data_frame);
self->mode_func_ptr = SfMarkerLooper_setProcMode;
static char *kwlist[] = {"path", "markers", "speed", "mark", "interp", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "sO|OOi", kwlist, &self->path, &markerstmp, &speedtmp, &marktmp, &self->interp))
Py_RETURN_NONE;
-
+
if (speedtmp) {
PyObject_CallMethod((PyObject *)self, "setSpeed", "O", speedtmp);
}
@@ -1882,11 +1882,11 @@ SfMarkerLooper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (marktmp) {
PyObject_CallMethod((PyObject *)self, "setMark", "O", marktmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
if (self->interp == 0)
self->interp = 2;
if (self->interp == 1)
@@ -1897,7 +1897,7 @@ SfMarkerLooper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->interp_func_ptr = cosine;
else if (self->interp == 4)
self->interp_func_ptr = cubic;
-
+
/* Open the sound file. */
self->info.format = 0;
self->sf = sf_open(self->path, SFM_READ, &self->info);
@@ -1910,14 +1910,14 @@ SfMarkerLooper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sndSr = self->info.samplerate;
self->sndChnls = self->info.channels;
self->srScale = self->sndSr / self->sr;
-
+
Py_INCREF(markerstmp);
SfMarkerLooper_setMarkers((SfMarkerLooper *)self, markerstmp);
-
+
self->samplesBuffer = (MYFLT *)realloc(self->samplesBuffer, self->bufsize * self->sndChnls * sizeof(MYFLT));
-
+
Server_generateSeed((Server *)self->server, SFMARKERLOOPER_ID);
-
+
return (PyObject *)self;
}
@@ -1932,14 +1932,14 @@ static PyObject *
SfMarkerLooper_setSpeed(SfMarkerLooper *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->speed);
@@ -1955,23 +1955,23 @@ SfMarkerLooper_setSpeed(SfMarkerLooper *self, PyObject *arg)
self->speed_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SfMarkerLooper_setMark(SfMarkerLooper *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->mark);
@@ -1990,7 +1990,7 @@ SfMarkerLooper_setMark(SfMarkerLooper *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SfMarkerLooper_setInterp(SfMarkerLooper *self, PyObject *arg)
@@ -1999,13 +1999,13 @@ SfMarkerLooper_setInterp(SfMarkerLooper *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
if (self->interp == 0)
self->interp = 2;
if (self->interp == 1)
@@ -2016,7 +2016,7 @@ SfMarkerLooper_setInterp(SfMarkerLooper *self, PyObject *arg)
self->interp_func_ptr = cosine;
else if (self->interp == 4)
self->interp_func_ptr = cubic;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2025,7 +2025,7 @@ MYFLT *
SfMarkerLooper_getSamplesBuffer(SfMarkerLooper *self)
{
return (MYFLT *)self->samplesBuffer;
-}
+}
static PyMemberDef SfMarkerLooper_members[] = {
{"server", T_OBJECT_EX, offsetof(SfMarkerLooper, server), 0, "Pyo server."},
@@ -2096,7 +2096,7 @@ typedef struct {
pyo_audio_HEAD
SfMarkerLooper *mainPlayer;
int modebuffer[2];
- int chnl;
+ int chnl;
} SfMarkerLoop;
static void SfMarkerLoop_postprocessing_ii(SfMarkerLoop *self) { POST_PROCESSING_II };
@@ -2114,33 +2114,33 @@ SfMarkerLoop_setProcMode(SfMarkerLoop *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SfMarkerLoop_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SfMarkerLoop_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SfMarkerLoop_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SfMarkerLoop_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SfMarkerLoop_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SfMarkerLoop_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SfMarkerLoop_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SfMarkerLoop_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SfMarkerLoop_postprocessing_revareva;
break;
}
@@ -2155,7 +2155,7 @@ SfMarkerLoop_compute_next_data_frame(SfMarkerLoop *self)
tmp = SfMarkerLooper_getSamplesBuffer((SfMarkerLooper *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -2167,11 +2167,11 @@ SfMarkerLoop_traverse(SfMarkerLoop *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
SfMarkerLoop_clear(SfMarkerLoop *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -2190,45 +2190,45 @@ SfMarkerLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
SfMarkerLoop *self;
self = (SfMarkerLoop *)type->tp_alloc(type, 0);
-
+
self->chnl = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SfMarkerLoop_compute_next_data_frame);
self->mode_func_ptr = SfMarkerLoop_setProcMode;
static char *kwlist[] = {"mainPlayer", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (SfMarkerLooper *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * SfMarkerLoop_getServer(SfMarkerLoop* self) { GET_SERVER };
static PyObject * SfMarkerLoop_getStream(SfMarkerLoop* self) { GET_STREAM };
-static PyObject * SfMarkerLoop_setMul(SfMarkerLoop *self, PyObject *arg) { SET_MUL };
-static PyObject * SfMarkerLoop_setAdd(SfMarkerLoop *self, PyObject *arg) { SET_ADD };
-static PyObject * SfMarkerLoop_setSub(SfMarkerLoop *self, PyObject *arg) { SET_SUB };
-static PyObject * SfMarkerLoop_setDiv(SfMarkerLoop *self, PyObject *arg) { SET_DIV };
+static PyObject * SfMarkerLoop_setMul(SfMarkerLoop *self, PyObject *arg) { SET_MUL };
+static PyObject * SfMarkerLoop_setAdd(SfMarkerLoop *self, PyObject *arg) { SET_ADD };
+static PyObject * SfMarkerLoop_setSub(SfMarkerLoop *self, PyObject *arg) { SET_SUB };
+static PyObject * SfMarkerLoop_setDiv(SfMarkerLoop *self, PyObject *arg) { SET_DIV };
static PyObject * SfMarkerLoop_play(SfMarkerLoop *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SfMarkerLoop_out(SfMarkerLoop *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2346,4 +2346,4 @@ PyTypeObject SfMarkerLoopType = {
0, /* tp_init */
0, /* tp_alloc */
SfMarkerLoop_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/sigmodule.c b/src/objects/sigmodule.c
index 7cd4cf0..dcc0aa0 100644
--- a/src/objects/sigmodule.c
+++ b/src/objects/sigmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -47,33 +47,33 @@ Sig_setProcMode(Sig *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Sig_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Sig_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Sig_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Sig_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Sig_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Sig_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Sig_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Sig_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Sig_postprocessing_revareva;
break;
}
@@ -94,7 +94,7 @@ Sig_compute_next_data_frame(Sig *self)
for (i=0; i<self->bufsize; i++) {
self->data[i] = vals[i];
}
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -102,17 +102,17 @@ static int
Sig_traverse(Sig *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->value);
- Py_VISIT(self->value_stream);
+ Py_VISIT(self->value);
+ Py_VISIT(self->value_stream);
return 0;
}
-static int
+static int
Sig_clear(Sig *self)
{
pyo_CLEAR
- Py_CLEAR(self->value);
- Py_CLEAR(self->value_stream);
+ Py_CLEAR(self->value);
+ Py_CLEAR(self->value_stream);
return 0;
}
@@ -131,7 +131,7 @@ Sig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *valuetmp=NULL, *multmp=NULL, *addtmp=NULL;
Sig *self;
self = (Sig *)type->tp_alloc(type, 0);
-
+
self->value = PyFloat_FromDouble(0.0);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
@@ -142,28 +142,28 @@ Sig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = Sig_setProcMode;
static char *kwlist[] = {"value", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &valuetmp, &multmp, &addtmp))
- Py_RETURN_NONE;
+ Py_RETURN_NONE;
if (valuetmp) {
PyObject_CallMethod((PyObject *)self, "setValue", "O", valuetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
Sig_compute_next_data_frame((Sig *)self);
-
+
return (PyObject *)self;
}
@@ -171,14 +171,14 @@ static PyObject *
Sig_setValue(Sig *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->value);
@@ -194,17 +194,17 @@ Sig_setValue(Sig *self, PyObject *arg)
self->value_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject * Sig_getServer(Sig* self) { GET_SERVER };
static PyObject * Sig_getStream(Sig* self) { GET_STREAM };
-static PyObject * Sig_setMul(Sig *self, PyObject *arg) { SET_MUL };
-static PyObject * Sig_setAdd(Sig *self, PyObject *arg) { SET_ADD };
-static PyObject * Sig_setSub(Sig *self, PyObject *arg) { SET_SUB };
-static PyObject * Sig_setDiv(Sig *self, PyObject *arg) { SET_DIV };
+static PyObject * Sig_setMul(Sig *self, PyObject *arg) { SET_MUL };
+static PyObject * Sig_setAdd(Sig *self, PyObject *arg) { SET_ADD };
+static PyObject * Sig_setSub(Sig *self, PyObject *arg) { SET_SUB };
+static PyObject * Sig_setDiv(Sig *self, PyObject *arg) { SET_DIV };
static PyObject * Sig_play(Sig *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Sig_out(Sig *self, PyObject *args, PyObject *kwds) { OUT };
@@ -358,7 +358,7 @@ SigTo_generates_i(SigTo *self) {
for (i=0; i<self->bufsize; i++)
self->data[i] = self->currentValue = self->lastValue = value;
}
- else {
+ else {
for (i=0; i<self->bufsize; i++) {
if (self->timeCount == (self->timeStep - 1)) {
self->currentValue = value;
@@ -367,13 +367,13 @@ SigTo_generates_i(SigTo *self) {
else if (self->timeCount < self->timeStep) {
self->currentValue += self->stepVal;
self->timeCount++;
- }
+ }
self->data[i] = self->currentValue;
}
}
}
else {
- MYFLT *vals = Stream_getData((Stream *)self->value_stream);
+ MYFLT *vals = Stream_getData((Stream *)self->value_stream);
if (self->timeStep <= 0) {
for (i=0; i<self->bufsize; i++) {
value = vals[i];
@@ -388,8 +388,8 @@ SigTo_generates_i(SigTo *self) {
self->timeStep = (long)(self->time * self->sr);
self->stepVal = (value - self->currentValue) / self->timeStep;
self->lastValue = value;
- }
-
+ }
+
if (self->timeCount == (self->timeStep - 1)) {
self->currentValue = value;
self->timeCount++;
@@ -397,7 +397,7 @@ SigTo_generates_i(SigTo *self) {
else if (self->timeCount < self->timeStep) {
self->currentValue += self->stepVal;
self->timeCount++;
- }
+ }
self->data[i] = self->currentValue;
}
}
@@ -421,33 +421,33 @@ SigTo_setProcMode(SigTo *self)
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
self->proc_func_ptr = SigTo_generates_i;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SigTo_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SigTo_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SigTo_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SigTo_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SigTo_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SigTo_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SigTo_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SigTo_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SigTo_postprocessing_revareva;
break;
}
@@ -456,7 +456,7 @@ SigTo_setProcMode(SigTo *self)
static void
SigTo_compute_next_data_frame(SigTo *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -464,17 +464,17 @@ static int
SigTo_traverse(SigTo *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->value);
- Py_VISIT(self->value_stream);
+ Py_VISIT(self->value);
+ Py_VISIT(self->value_stream);
return 0;
}
-static int
+static int
SigTo_clear(SigTo *self)
{
pyo_CLEAR
- Py_CLEAR(self->value);
- Py_CLEAR(self->value_stream);
+ Py_CLEAR(self->value);
+ Py_CLEAR(self->value_stream);
return 0;
}
@@ -502,16 +502,16 @@ SigTo_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SigTo_compute_next_data_frame);
self->mode_func_ptr = SigTo_setProcMode;
static char *kwlist[] = {"value", "time", "init", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OFOO, kwlist, &valuetmp, &timetmp, &inittmp, &multmp, &addtmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (valuetmp) {
PyObject_CallMethod((PyObject *)self, "setValue", "O", valuetmp);
}
@@ -519,26 +519,26 @@ SigTo_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (timetmp) {
PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->lastValue = self->currentValue = inittmp;
self->timeStep = (long)(self->time * self->sr);
-
+
(*self->mode_func_ptr)(self);
for(i=0; i<self->bufsize; i++) {
self->data[i] = self->currentValue;
}
-
+
return (PyObject *)self;
}
@@ -546,14 +546,14 @@ static PyObject *
SigTo_setValue(SigTo *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->value);
@@ -569,39 +569,39 @@ SigTo_setValue(SigTo *self, PyObject *arg)
self->value_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
SigTo_setTime(SigTo *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
if (isNumber == 1) {
self->time = PyFloat_AS_DOUBLE(PyNumber_Float(tmp));
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject * SigTo_getServer(SigTo* self) { GET_SERVER };
static PyObject * SigTo_getStream(SigTo* self) { GET_STREAM };
-static PyObject * SigTo_setMul(SigTo *self, PyObject *arg) { SET_MUL };
-static PyObject * SigTo_setAdd(SigTo *self, PyObject *arg) { SET_ADD };
-static PyObject * SigTo_setSub(SigTo *self, PyObject *arg) { SET_SUB };
-static PyObject * SigTo_setDiv(SigTo *self, PyObject *arg) { SET_DIV };
+static PyObject * SigTo_setMul(SigTo *self, PyObject *arg) { SET_MUL };
+static PyObject * SigTo_setAdd(SigTo *self, PyObject *arg) { SET_ADD };
+static PyObject * SigTo_setSub(SigTo *self, PyObject *arg) { SET_SUB };
+static PyObject * SigTo_setDiv(SigTo *self, PyObject *arg) { SET_DIV };
static PyObject * SigTo_play(SigTo *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SigTo_stop(SigTo *self) { STOP };
@@ -751,9 +751,9 @@ VarPort_generates_i(VarPort *self) {
self->timeCount = 0;
self->stepVal = (self->value - self->currentValue) / (self->timeStep+1);
self->lastValue = self->value;
- }
-
- if (self->flag == 1) {
+ }
+
+ if (self->flag == 1) {
for (i=0; i<self->bufsize; i++) {
if (self->timeCount >= self->timeStep)
self->currentValue = self->value;
@@ -770,7 +770,7 @@ VarPort_generates_i(VarPort *self) {
self->data[i] = self->currentValue;
}
}
-
+
if (self->timeCount >= self->timeout && self->flag == 1) {
self->flag = 0;
if (self->callable != Py_None) {
@@ -787,7 +787,7 @@ VarPort_generates_i(VarPort *self) {
PyErr_Print();
return;
}
- }
+ }
}
}
@@ -806,35 +806,35 @@ VarPort_setProcMode(VarPort *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = VarPort_generates_i;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = VarPort_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = VarPort_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = VarPort_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = VarPort_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = VarPort_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = VarPort_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = VarPort_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = VarPort_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = VarPort_postprocessing_revareva;
break;
}
@@ -843,7 +843,7 @@ VarPort_setProcMode(VarPort *self)
static void
VarPort_compute_next_data_frame(VarPort *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -856,7 +856,7 @@ VarPort_traverse(VarPort *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
VarPort_clear(VarPort *self)
{
pyo_CLEAR
@@ -881,8 +881,8 @@ VarPort_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *valuetmp=NULL, *timetmp=NULL, *calltmp=NULL, *argtmp=NULL, *multmp=NULL, *addtmp=NULL;
VarPort *self;
self = (VarPort *)type->tp_alloc(type, 0);
-
- self->flag = 1;
+
+ self->flag = 1;
self->time = 0.025;
self->timeStep = (long)(self->time * self->sr);
self->timeout = (long)((self->time + 0.1) * self->sr);
@@ -899,22 +899,22 @@ VarPort_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = VarPort_setProcMode;
static char *kwlist[] = {"value", "time", "init", "callable", "arg", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OFOOOO, kwlist, &valuetmp, &timetmp, &inittmp, &calltmp, &argtmp, &multmp, &addtmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (valuetmp) {
PyObject_CallMethod((PyObject *)self, "setValue", "O", valuetmp);
}
-
+
if (timetmp) {
PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
@@ -930,17 +930,17 @@ VarPort_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_INCREF(argtmp);
self->arg = argtmp;
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->lastValue = self->currentValue = inittmp;
-
+
(*self->mode_func_ptr)(self);
-
+
for(i=0; i<self->bufsize; i++) {
self->data[i] = self->currentValue;
}
-
+
return (PyObject *)self;
}
@@ -948,37 +948,37 @@ static PyObject *
VarPort_setValue(VarPort *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
if (isNumber == 1)
self->value = PyFloat_AsDouble(PyNumber_Float(tmp));
else
self->value = self->lastValue;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
VarPort_setTime(VarPort *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
if (isNumber == 1) {
@@ -986,37 +986,37 @@ VarPort_setTime(VarPort *self, PyObject *arg)
self->timeStep = (long)(self->time * self->sr);
self->timeout = (long)((self->time + 0.1) * self->sr);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
VarPort_setFunction(VarPort *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (! PyCallable_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The function attribute must be callable.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_XDECREF(self->callable);
Py_INCREF(tmp);
self->callable = tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject * VarPort_getServer(VarPort* self) { GET_SERVER };
static PyObject * VarPort_getStream(VarPort* self) { GET_STREAM };
-static PyObject * VarPort_setMul(VarPort *self, PyObject *arg) { SET_MUL };
-static PyObject * VarPort_setAdd(VarPort *self, PyObject *arg) { SET_ADD };
-static PyObject * VarPort_setSub(VarPort *self, PyObject *arg) { SET_SUB };
-static PyObject * VarPort_setDiv(VarPort *self, PyObject *arg) { SET_DIV };
+static PyObject * VarPort_setMul(VarPort *self, PyObject *arg) { SET_MUL };
+static PyObject * VarPort_setAdd(VarPort *self, PyObject *arg) { SET_ADD };
+static PyObject * VarPort_setSub(VarPort *self, PyObject *arg) { SET_SUB };
+static PyObject * VarPort_setDiv(VarPort *self, PyObject *arg) { SET_DIV };
static PyObject * VarPort_play(VarPort *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * VarPort_stop(VarPort *self) { STOP };
@@ -1136,4 +1136,3 @@ PyTypeObject VarPortType = {
0, /* tp_alloc */
VarPort_new, /* tp_new */
};
-
diff --git a/src/objects/tablemodule.c b/src/objects/tablemodule.c
index 285deb9..d4169c2 100644
--- a/src/objects/tablemodule.c
+++ b/src/objects/tablemodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -53,13 +53,13 @@ MYFLT *
TableStream_getData(TableStream *self)
{
return (MYFLT *)self->data;
-}
+}
void
TableStream_setData(TableStream *self, MYFLT *data)
{
self->data = data;
-}
+}
int
TableStream_getSize(TableStream *self)
@@ -71,7 +71,7 @@ void
TableStream_setSize(TableStream *self, int size)
{
self->size = size;
-}
+}
double
TableStream_getSamplingRate(TableStream *self)
@@ -83,7 +83,7 @@ void
TableStream_setSamplingRate(TableStream *self, double sr)
{
self->samplingRate = sr;
-}
+}
PyTypeObject TableStreamType = {
PyObject_HEAD_INIT(NULL)
@@ -139,15 +139,15 @@ static void
HarmTable_generate(HarmTable *self) {
int i, j, ampsize;
MYFLT factor, amplitude, val;
-
+
ampsize = PyList_Size(self->amplist);
MYFLT array[ampsize];
for(j=0; j<ampsize; j++) {
array[j] = PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(self->amplist, j)));
- }
-
+ }
+
factor = 1. / (self->size * 0.5) * PI;
-
+
for(i=0; i<self->size; i++) {
val = 0;
for(j=0; j<ampsize; j++) {
@@ -160,7 +160,7 @@ HarmTable_generate(HarmTable *self) {
}
val = self->data[0];
- self->data[self->size] = val;
+ self->data[self->size] = val;
}
static int
@@ -171,7 +171,7 @@ HarmTable_traverse(HarmTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
HarmTable_clear(HarmTable *self)
{
pyo_table_CLEAR
@@ -193,9 +193,9 @@ HarmTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *amplist=NULL;
HarmTable *self;
self = (HarmTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->amplist = PyList_New(0);
PyList_Append(self->amplist, PyFloat_FromDouble(1.));
self->size = 8192;
@@ -203,10 +203,10 @@ HarmTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"list", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", kwlist, &list, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (amplist) {
Py_INCREF(amplist);
Py_DECREF(self->amplist);
@@ -241,9 +241,12 @@ static PyObject * HarmTable_pow(HarmTable *self, PyObject *args, PyObject *kwds)
static PyObject * HarmTable_copy(HarmTable *self, PyObject *arg) { COPY };
static PyObject * HarmTable_setTable(HarmTable *self, PyObject *arg) { SET_TABLE };
static PyObject * HarmTable_getTable(HarmTable *self) { GET_TABLE };
-static PyObject * HarmTable_getViewTable(HarmTable *self) { GET_VIEW_TABLE };
+static PyObject * HarmTable_getViewTable(HarmTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * HarmTable_put(HarmTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * HarmTable_get(HarmTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * HarmTable_add(HarmTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * HarmTable_sub(HarmTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * HarmTable_mul(HarmTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
HarmTable_setSize(HarmTable *self, PyObject *value)
@@ -252,19 +255,19 @@ HarmTable_setSize(HarmTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
- self->size = PyInt_AsLong(value);
+
+ self->size = PyInt_AsLong(value);
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
HarmTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -282,18 +285,18 @@ HarmTable_replace(HarmTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->amplist);
- self->amplist = value;
-
+ self->amplist = value;
+
HarmTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -309,7 +312,7 @@ static PyMethodDef HarmTable_methods[] = {
{"getServer", (PyCFunction)HarmTable_getServer, METH_NOARGS, "Returns server object."},
{"setTable", (PyCFunction)HarmTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)HarmTable_getTable, METH_NOARGS, "Returns a list of table samples."},
-{"getViewTable", (PyCFunction)HarmTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+{"getViewTable", (PyCFunction)HarmTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)HarmTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"normalize", (PyCFunction)HarmTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
{"reset", (PyCFunction)HarmTable_reset, METH_NOARGS, "Resets table samples to 0.0"},
@@ -329,6 +332,9 @@ static PyMethodDef HarmTable_methods[] = {
{"put", (PyCFunction)HarmTable_put, METH_VARARGS|METH_KEYWORDS, "Puts a value at specified position in the table."},
{"get", (PyCFunction)HarmTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
{"replace", (PyCFunction)HarmTable_replace, METH_O, "Sets the harmonics amplitude list and generates a new waveform table."},
+{"add", (PyCFunction)HarmTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)HarmTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)HarmTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -386,18 +392,18 @@ static void
ChebyTable_generate(ChebyTable *self) {
int i, j, ampsize, halfsize;
MYFLT amplitude, val, ihalfsize, index, x;
-
+
ampsize = PyList_Size(self->amplist);
if (ampsize > 12)
ampsize = 12;
MYFLT array[ampsize];
for(j=0; j<ampsize; j++) {
array[j] = PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(self->amplist, j)));
- }
-
+ }
+
halfsize = self->size / 2;
ihalfsize = 1.0 / halfsize;
-
+
x = 0.0;
for(i=0; i<self->size; i++) {
val = 0;
@@ -446,9 +452,9 @@ ChebyTable_generate(ChebyTable *self) {
}
self->data[i] = val;
}
-
+
val = self->data[self->size-1];
- self->data[self->size] = val;
+ self->data[self->size] = val;
}
static int
@@ -459,7 +465,7 @@ ChebyTable_traverse(ChebyTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
ChebyTable_clear(ChebyTable *self)
{
pyo_table_CLEAR
@@ -481,26 +487,26 @@ ChebyTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *amplist=NULL;
ChebyTable *self;
self = (ChebyTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->amplist = PyList_New(0);
PyList_Append(self->amplist, PyFloat_FromDouble(1.));
self->size = 8192;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"list", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", kwlist, &list, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (amplist) {
Py_INCREF(amplist);
Py_DECREF(self->amplist);
self->amplist = amplist;
}
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
@@ -508,7 +514,7 @@ ChebyTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -529,9 +535,12 @@ static PyObject * ChebyTable_pow(ChebyTable *self, PyObject *args, PyObject *kwd
static PyObject * ChebyTable_copy(ChebyTable *self, PyObject *arg) { COPY };
static PyObject * ChebyTable_setTable(ChebyTable *self, PyObject *arg) { SET_TABLE };
static PyObject * ChebyTable_getTable(ChebyTable *self) { GET_TABLE };
-static PyObject * ChebyTable_getViewTable(ChebyTable *self) { GET_VIEW_TABLE };
+static PyObject * ChebyTable_getViewTable(ChebyTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * ChebyTable_put(ChebyTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * ChebyTable_get(ChebyTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * ChebyTable_add(ChebyTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * ChebyTable_sub(ChebyTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * ChebyTable_mul(ChebyTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
ChebyTable_setSize(ChebyTable *self, PyObject *value)
@@ -540,19 +549,19 @@ ChebyTable_setSize(ChebyTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
- self->size = PyInt_AsLong(value);
-
+
+ self->size = PyInt_AsLong(value);
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
ChebyTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -570,18 +579,18 @@ ChebyTable_replace(ChebyTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->amplist);
- self->amplist = value;
-
+ self->amplist = value;
+
ChebyTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -597,7 +606,7 @@ ChebyTable_getNormTable(ChebyTable *self, PyObject *value)
long sym = PyInt_AS_LONG(value);
MYFLT samps[halfsize];
PyObject *samples = PyList_New(halfsize);
-
+
if (sym == 0) {
for (i=0; i<self->size; i++) {
if (self->data[i] > maxval)
@@ -641,18 +650,18 @@ ChebyTable_getNormTable(ChebyTable *self, PyObject *value)
if (val > maxval)
maxval = val;
}
-
+
for (i=0; i<halfsize; i++) {
val = samps[i];
if (val == -1.0)
samps[i] = maxval;
}
-
+
last = samps[0];
for (i=1; i<halfsize; i++) {
last = samps[i] = samps[i] + (last - samps[i]) * 0.95;
}
-
+
for (i=0; i<halfsize; i++) {
PyList_SET_ITEM(samples, i, PyFloat_FromDouble(samps[i]));
}
@@ -671,7 +680,7 @@ static PyMethodDef ChebyTable_methods[] = {
{"copy", (PyCFunction)ChebyTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)ChebyTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)ChebyTable_getTable, METH_NOARGS, "Returns a list of table samples."},
-{"getViewTable", (PyCFunction)ChebyTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+{"getViewTable", (PyCFunction)ChebyTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)ChebyTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)ChebyTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)ChebyTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -691,6 +700,9 @@ static PyMethodDef ChebyTable_methods[] = {
{"get", (PyCFunction)ChebyTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
{"replace", (PyCFunction)ChebyTable_replace, METH_O, "Sets the harmonics amplitude list and generates a new waveform table."},
{"getNormTable", (PyCFunction)ChebyTable_getNormTable, METH_O, "Computes and returns the normalization function for the current polynomial"},
+{"add", (PyCFunction)ChebyTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)ChebyTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)ChebyTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -747,15 +759,15 @@ static void
HannTable_generate(HannTable *self) {
int i, halfSize;
MYFLT val;
-
+
halfSize = self->size / 2 - 1;
-
+
for(i=0; i<self->size; i++) {
val = 0.5 + (MYCOS(TWOPI * (i - halfSize) / self->size) * 0.5);
self->data[i] = val;
}
val = self->data[0];
- self->data[self->size] = val;
+ self->data[self->size] = val;
}
static int
@@ -765,7 +777,7 @@ HannTable_traverse(HannTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
HannTable_clear(HannTable *self)
{
pyo_table_CLEAR
@@ -785,18 +797,18 @@ HannTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
HannTable *self;
self = (HannTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->size = 8192;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
-
+
static char *kwlist[] = {"size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
@@ -804,7 +816,7 @@ HannTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -825,9 +837,12 @@ static PyObject * HannTable_pow(HannTable *self, PyObject *args, PyObject *kwds)
static PyObject * HannTable_copy(HannTable *self, PyObject *arg) { COPY };
static PyObject * HannTable_setTable(HannTable *self, PyObject *arg) { SET_TABLE };
static PyObject * HannTable_getTable(HannTable *self) { GET_TABLE };
-static PyObject * HannTable_getViewTable(HannTable *self) { GET_VIEW_TABLE };
+static PyObject * HannTable_getViewTable(HannTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * HannTable_put(HannTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * HannTable_get(HannTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * HannTable_add(HannTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * HannTable_sub(HannTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * HannTable_mul(HannTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
HannTable_setSize(HannTable *self, PyObject *value)
@@ -836,19 +851,19 @@ HannTable_setSize(HannTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
- self->size = PyInt_AsLong(value);
-
+
+ self->size = PyInt_AsLong(value);
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
HannTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -870,7 +885,7 @@ static PyMethodDef HannTable_methods[] = {
{"copy", (PyCFunction)HannTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)HannTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)HannTable_getTable, METH_NOARGS, "Returns a list of table samples."},
-{"getViewTable", (PyCFunction)HannTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+{"getViewTable", (PyCFunction)HannTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)HannTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)HannTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)HannTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -888,6 +903,9 @@ static PyMethodDef HannTable_methods[] = {
{"getSize", (PyCFunction)HannTable_getSize, METH_NOARGS, "Return the size of the table in samples"},
{"put", (PyCFunction)HannTable_put, METH_VARARGS|METH_KEYWORDS, "Puts a value at specified position in the table."},
{"get", (PyCFunction)HannTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
+{"add", (PyCFunction)HannTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)HannTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)HannTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -946,11 +964,11 @@ static void
SincTable_generate(SincTable *self) {
int i, half, halfMinusOne;
MYFLT scl, val;
-
+
half = self->size / 2;
-
+
if (self->windowed) {
- halfMinusOne = half - 1;
+ halfMinusOne = half - 1;
for(i=0; i<self->size; i++) {
scl = (MYFLT)(i - half) / half * self->freq;
if (scl == 0.0)
@@ -969,9 +987,9 @@ SincTable_generate(SincTable *self) {
else
val = (MYSIN(scl) / scl);
self->data[i] = val;
- }
+ }
}
- self->data[self->size] = self->data[0];
+ self->data[self->size] = self->data[0];
}
static int
@@ -981,7 +999,7 @@ SincTable_traverse(SincTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
SincTable_clear(SincTable *self)
{
pyo_table_CLEAR
@@ -1001,28 +1019,28 @@ SincTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
SincTable *self;
self = (SincTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->size = 8192;
self->freq = TWOPI;
self->windowed = 0;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"freq", "windowed", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__FII, kwlist, &self->freq, &self->windowed, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
SincTable_generate(self);
-
+
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -1043,23 +1061,26 @@ static PyObject * SincTable_pow(SincTable *self, PyObject *args, PyObject *kwds)
static PyObject * SincTable_copy(SincTable *self, PyObject *arg) { COPY };
static PyObject * SincTable_setTable(SincTable *self, PyObject *arg) { SET_TABLE };
static PyObject * SincTable_getTable(SincTable *self) { GET_TABLE };
-static PyObject * SincTable_getViewTable(SincTable *self) { GET_VIEW_TABLE };
+static PyObject * SincTable_getViewTable(SincTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * SincTable_put(SincTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * SincTable_get(SincTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * SincTable_add(SincTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * SincTable_sub(SincTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * SincTable_mul(SincTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
SincTable_setFreq(SincTable *self, PyObject *value)
{
-
+
if (! PyNumber_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The freq attribute value must be a number.");
return PyInt_FromLong(-1);
}
-
- self->freq = PyFloat_AsDouble(PyNumber_Float(value));
-
+
+ self->freq = PyFloat_AsDouble(PyNumber_Float(value));
+
SincTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1067,16 +1088,16 @@ SincTable_setFreq(SincTable *self, PyObject *value)
static PyObject *
SincTable_setWindowed(SincTable *self, PyObject *value)
{
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The windowed attribute value must be a boolean.");
return PyInt_FromLong(-1);
}
-
- self->windowed = PyInt_AsLong(value);
-
+
+ self->windowed = PyInt_AsLong(value);
+
SincTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1088,19 +1109,19 @@ SincTable_setSize(SincTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
- self->size = PyInt_AsLong(value);
-
+
+ self->size = PyInt_AsLong(value);
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
SincTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1122,7 +1143,7 @@ static PyMethodDef SincTable_methods[] = {
{"copy", (PyCFunction)SincTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)SincTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)SincTable_getTable, METH_NOARGS, "Returns a list of table samples."},
- {"getViewTable", (PyCFunction)SincTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+ {"getViewTable", (PyCFunction)SincTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)SincTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)SincTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)SincTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -1142,6 +1163,9 @@ static PyMethodDef SincTable_methods[] = {
{"setWindowed", (PyCFunction)SincTable_setWindowed, METH_O, "If True, an hanning window is applied on the function."},
{"put", (PyCFunction)SincTable_put, METH_VARARGS|METH_KEYWORDS, "Puts a value at specified position in the table."},
{"get", (PyCFunction)SincTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
+ {"add", (PyCFunction)SincTable_add, METH_O, "Performs table addition."},
+ {"sub", (PyCFunction)SincTable_sub, METH_O, "Performs table substraction."},
+ {"mul", (PyCFunction)SincTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -1208,7 +1232,7 @@ WinTable_traverse(WinTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
WinTable_clear(WinTable *self)
{
pyo_table_CLEAR
@@ -1228,19 +1252,19 @@ WinTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
WinTable *self;
self = (WinTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->size = 8192;
self->type = 2;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"type", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwlist, &self->type, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
@@ -1248,7 +1272,7 @@ WinTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -1269,9 +1293,12 @@ static PyObject * WinTable_pow(WinTable *self, PyObject *args, PyObject *kwds) {
static PyObject * WinTable_copy(WinTable *self, PyObject *arg) { COPY };
static PyObject * WinTable_setTable(WinTable *self, PyObject *arg) { SET_TABLE };
static PyObject * WinTable_getTable(WinTable *self) { GET_TABLE };
-static PyObject * WinTable_getViewTable(WinTable *self) { GET_VIEW_TABLE };
+static PyObject * WinTable_getViewTable(WinTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * WinTable_put(WinTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * WinTable_get(WinTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * WinTable_add(WinTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * WinTable_sub(WinTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * WinTable_mul(WinTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
WinTable_setSize(WinTable *self, PyObject *value)
@@ -1280,19 +1307,19 @@ WinTable_setSize(WinTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
- self->size = PyInt_AsLong(value);
-
+
+ self->size = PyInt_AsLong(value);
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
WinTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1310,16 +1337,16 @@ WinTable_setType(WinTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the type attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The type attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
+
self->type = PyInt_AsLong(value);
-
+
WinTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1335,7 +1362,7 @@ static PyMethodDef WinTable_methods[] = {
{"copy", (PyCFunction)WinTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)WinTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)WinTable_getTable, METH_NOARGS, "Returns a list of table samples."},
-{"getViewTable", (PyCFunction)WinTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+{"getViewTable", (PyCFunction)WinTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)WinTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)WinTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)WinTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -1354,6 +1381,9 @@ static PyMethodDef WinTable_methods[] = {
{"setType", (PyCFunction)WinTable_setType, METH_O, "Sets the type of the table."},
{"put", (PyCFunction)WinTable_put, METH_VARARGS|METH_KEYWORDS, "Puts a value at specified position in the table."},
{"get", (PyCFunction)WinTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
+{"add", (PyCFunction)WinTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)WinTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)WinTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -1410,7 +1440,7 @@ static void
ParaTable_generate(ParaTable *self) {
int i, sizeMinusOne;
MYFLT rdur, rdur2, level, slope, curve;
-
+
sizeMinusOne = self->size - 1;
rdur = 1.0 / sizeMinusOne;
rdur2 = rdur * rdur;
@@ -1424,8 +1454,8 @@ ParaTable_generate(ParaTable *self) {
slope += curve;
}
- self->data[sizeMinusOne] = self->data[0];
- self->data[self->size] = self->data[0];
+ self->data[sizeMinusOne] = self->data[0];
+ self->data[self->size] = self->data[0];
}
static int
@@ -1435,7 +1465,7 @@ ParaTable_traverse(ParaTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
ParaTable_clear(ParaTable *self)
{
pyo_table_CLEAR
@@ -1455,18 +1485,18 @@ ParaTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
ParaTable *self;
self = (ParaTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->size = 8192;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
-
+
static char *kwlist[] = {"size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
@@ -1474,7 +1504,7 @@ ParaTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -1495,9 +1525,12 @@ static PyObject * ParaTable_pow(ParaTable *self, PyObject *args, PyObject *kwds)
static PyObject * ParaTable_copy(ParaTable *self, PyObject *arg) { COPY };
static PyObject * ParaTable_setTable(ParaTable *self, PyObject *arg) { SET_TABLE };
static PyObject * ParaTable_getTable(ParaTable *self) { GET_TABLE };
-static PyObject * ParaTable_getViewTable(ParaTable *self) { GET_VIEW_TABLE };
+static PyObject * ParaTable_getViewTable(ParaTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * ParaTable_put(ParaTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * ParaTable_get(ParaTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * ParaTable_add(ParaTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * ParaTable_sub(ParaTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * ParaTable_mul(ParaTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
ParaTable_setSize(ParaTable *self, PyObject *value)
@@ -1506,19 +1539,19 @@ ParaTable_setSize(ParaTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
- self->size = PyInt_AsLong(value);
-
+
+ self->size = PyInt_AsLong(value);
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
ParaTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1540,7 +1573,7 @@ static PyMethodDef ParaTable_methods[] = {
{"copy", (PyCFunction)ParaTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)ParaTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)ParaTable_getTable, METH_NOARGS, "Returns a list of table samples."},
- {"getViewTable", (PyCFunction)ParaTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+ {"getViewTable", (PyCFunction)ParaTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)ParaTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)ParaTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)ParaTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -1558,6 +1591,9 @@ static PyMethodDef ParaTable_methods[] = {
{"getSize", (PyCFunction)ParaTable_getSize, METH_NOARGS, "Return the size of the table in samples"},
{"put", (PyCFunction)ParaTable_put, METH_VARARGS|METH_KEYWORDS, "Puts a value at specified position in the table."},
{"get", (PyCFunction)ParaTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
+ {"add", (PyCFunction)ParaTable_add, METH_O, "Performs table addition."},
+ {"sub", (PyCFunction)ParaTable_sub, METH_O, "Performs table substraction."},
+ {"mul", (PyCFunction)ParaTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -1618,12 +1654,12 @@ LinTable_generate(LinTable *self) {
PyObject *tup, *tup2;
int x1, y1;
MYFLT x2, y2, diff;
-
+
y1 = 0;
y2 = 0.0;
listsize = PyList_Size(self->pointslist);
-
+
for(i=0; i<(listsize-1); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
@@ -1649,7 +1685,7 @@ LinTable_generate(LinTable *self) {
else {
self->data[self->size-1] = y2;
self->data[self->size] = y2;
- }
+ }
}
static int
@@ -1660,7 +1696,7 @@ LinTable_traverse(LinTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
LinTable_clear(LinTable *self)
{
pyo_table_CLEAR
@@ -1682,19 +1718,19 @@ LinTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pointslist=NULL;
LinTable *self;
self = (LinTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->pointslist = PyList_New(0);
self->size = 8192;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"list", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", kwlist, &pointslist, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (pointslist) {
Py_INCREF(pointslist);
Py_DECREF(self->pointslist);
@@ -1704,7 +1740,7 @@ LinTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(0), PyFloat_FromDouble(0.)));
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(self->size), PyFloat_FromDouble(1.)));
}
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
@@ -1712,7 +1748,7 @@ LinTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -1733,9 +1769,12 @@ static PyObject * LinTable_pow(LinTable *self, PyObject *args, PyObject *kwds) {
static PyObject * LinTable_copy(LinTable *self, PyObject *arg) { COPY };
static PyObject * LinTable_setTable(LinTable *self, PyObject *arg) { SET_TABLE };
static PyObject * LinTable_getTable(LinTable *self) { GET_TABLE };
-static PyObject * LinTable_getViewTable(LinTable *self) { GET_VIEW_TABLE };
+static PyObject * LinTable_getViewTable(LinTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * LinTable_put(LinTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * LinTable_get(LinTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * LinTable_add(LinTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * LinTable_sub(LinTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * LinTable_mul(LinTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
LinTable_setSize(LinTable *self, PyObject *value)
@@ -1749,37 +1788,37 @@ LinTable_setSize(LinTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
old_size = self->size;
- self->size = PyInt_AsLong(value);
-
+ self->size = PyInt_AsLong(value);
+
factor = (MYFLT)(self->size) / old_size;
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
Py_ssize_t listsize = PyList_Size(self->pointslist);
PyObject *listtemp = PyList_New(0);
-
+
for(i=0; i<(listsize); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
x2 = PyNumber_Float(PyTuple_GET_ITEM(tup, 1));
PyList_Append(listtemp, PyTuple_Pack(2, PyInt_FromLong((int)(x1*factor)), x2));
}
-
+
Py_INCREF(listtemp);
Py_DECREF(self->pointslist);
self->pointslist = listtemp;
-
+
LinTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1804,18 +1843,18 @@ LinTable_replace(LinTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
LinTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1832,7 +1871,7 @@ static PyMethodDef LinTable_methods[] = {
{"copy", (PyCFunction)LinTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)LinTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)LinTable_getTable, METH_NOARGS, "Returns a list of table samples."},
-{"getViewTable", (PyCFunction)LinTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+{"getViewTable", (PyCFunction)LinTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)LinTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)LinTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)LinTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -1852,6 +1891,9 @@ static PyMethodDef LinTable_methods[] = {
{"get", (PyCFunction)LinTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
{"getPoints", (PyCFunction)LinTable_getPoints, METH_NOARGS, "Return the list of points."},
{"replace", (PyCFunction)LinTable_replace, METH_O, "Sets the harmonics amplitude list and generates a new waveform table."},
+{"add", (PyCFunction)LinTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)LinTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)LinTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -1912,12 +1954,12 @@ LogTable_generate(LogTable *self) {
PyObject *tup, *tup2;
int x1, y1;
MYFLT x2, y2, diff, range, logrange, logmin, ratio, low, high;
-
+
y1 = 0;
y2 = 0.0;
-
+
listsize = PyList_Size(self->pointslist);
-
+
for(i=0; i<(listsize-1); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
@@ -1954,7 +1996,7 @@ LogTable_generate(LogTable *self) {
for(j=0; j<steps; j++) {
ratio = ((x2 + diff * j) - low) / range;
self->data[x1+j] = MYPOW(10, ratio * logrange + logmin);
- }
+ }
}
}
if (y1 < (self->size-1)) {
@@ -1967,7 +2009,7 @@ LogTable_generate(LogTable *self) {
else {
self->data[self->size-1] = y2;
self->data[self->size] = y2;
- }
+ }
}
static int
@@ -1978,7 +2020,7 @@ LogTable_traverse(LogTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
LogTable_clear(LogTable *self)
{
pyo_table_CLEAR
@@ -2000,19 +2042,19 @@ LogTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pointslist=NULL;
LogTable *self;
self = (LogTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->pointslist = PyList_New(0);
self->size = 8192;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
-
+
static char *kwlist[] = {"list", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", kwlist, &pointslist, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (pointslist) {
Py_INCREF(pointslist);
Py_DECREF(self->pointslist);
@@ -2022,15 +2064,15 @@ LogTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(0), PyFloat_FromDouble(0.)));
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(self->size), PyFloat_FromDouble(1.)));
}
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
LogTable_generate(self);
-
+
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -2051,9 +2093,12 @@ static PyObject * LogTable_pow(LogTable *self, PyObject *args, PyObject *kwds) {
static PyObject * LogTable_copy(LogTable *self, PyObject *arg) { COPY };
static PyObject * LogTable_setTable(LogTable *self, PyObject *arg) { SET_TABLE };
static PyObject * LogTable_getTable(LogTable *self) { GET_TABLE };
-static PyObject * LogTable_getViewTable(LogTable *self) { GET_VIEW_TABLE };
+static PyObject * LogTable_getViewTable(LogTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * LogTable_put(LogTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * LogTable_get(LogTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * LogTable_add(LogTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * LogTable_sub(LogTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * LogTable_mul(LogTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
LogTable_setSize(LogTable *self, PyObject *value)
@@ -2062,42 +2107,42 @@ LogTable_setSize(LogTable *self, PyObject *value)
PyObject *tup, *x2;
int old_size, x1;
MYFLT factor;
-
+
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
+
old_size = self->size;
- self->size = PyInt_AsLong(value);
-
+ self->size = PyInt_AsLong(value);
+
factor = (MYFLT)(self->size) / old_size;
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
Py_ssize_t listsize = PyList_Size(self->pointslist);
-
+
PyObject *listtemp = PyList_New(0);
-
+
for(i=0; i<(listsize); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
x2 = PyNumber_Float(PyTuple_GET_ITEM(tup, 1));
PyList_Append(listtemp, PyTuple_Pack(2, PyInt_FromLong((int)(x1*factor)), x2));
}
-
+
Py_INCREF(listtemp);
Py_DECREF(self->pointslist);
self->pointslist = listtemp;
-
+
LogTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2122,18 +2167,18 @@ LogTable_replace(LogTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
LogTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2150,7 +2195,7 @@ static PyMethodDef LogTable_methods[] = {
{"copy", (PyCFunction)LogTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)LogTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)LogTable_getTable, METH_NOARGS, "Returns a list of table samples."},
- {"getViewTable", (PyCFunction)LogTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+ {"getViewTable", (PyCFunction)LogTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)LogTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)LogTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)LogTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -2170,6 +2215,9 @@ static PyMethodDef LogTable_methods[] = {
{"get", (PyCFunction)LogTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
{"getPoints", (PyCFunction)LogTable_getPoints, METH_NOARGS, "Return the list of points."},
{"replace", (PyCFunction)LogTable_replace, METH_O, "Sets the harmonics amplitude list and generates a new waveform table."},
+ {"add", (PyCFunction)LogTable_add, METH_O, "Performs table addition."},
+ {"sub", (PyCFunction)LogTable_sub, METH_O, "Performs table substraction."},
+ {"mul", (PyCFunction)LogTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -2230,20 +2278,20 @@ CosTable_generate(CosTable *self) {
PyObject *tup, *tup2;
int x1, y1;
MYFLT x2, y2, mu, mu2;
-
+
y1 = 0;
y2 = 0.0;
-
+
listsize = PyList_Size(self->pointslist);
-
+
for(i=0; i<(listsize-1); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
- x2 = PyFloat_AsDouble(PyNumber_Float(PyTuple_GET_ITEM(tup, 1)));
+ x2 = PyFloat_AsDouble(PyNumber_Float(PyTuple_GET_ITEM(tup, 1)));
tup2 = PyList_GET_ITEM(self->pointslist, i+1);
y1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup2, 0)));
y2 = PyFloat_AsDouble(PyNumber_Float(PyTuple_GET_ITEM(tup2, 1)));
-
+
steps = y1 - x1;
if (steps <= 0)
continue;
@@ -2263,7 +2311,7 @@ CosTable_generate(CosTable *self) {
else {
self->data[self->size-1] = y2;
self->data[self->size] = y2;
- }
+ }
}
static int
@@ -2274,7 +2322,7 @@ CosTable_traverse(CosTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
CosTable_clear(CosTable *self)
{
pyo_table_CLEAR
@@ -2296,19 +2344,19 @@ CosTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pointslist=NULL;
CosTable *self;
self = (CosTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->pointslist = PyList_New(0);
self->size = 8192;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"list", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", kwlist, &pointslist, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (pointslist) {
Py_INCREF(pointslist);
Py_DECREF(self->pointslist);
@@ -2318,7 +2366,7 @@ CosTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(0), PyFloat_FromDouble(0.)));
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(self->size), PyFloat_FromDouble(1.)));
}
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
@@ -2326,7 +2374,7 @@ CosTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -2347,9 +2395,12 @@ static PyObject * CosTable_pow(CosTable *self, PyObject *args, PyObject *kwds) {
static PyObject * CosTable_copy(CosTable *self, PyObject *arg) { COPY };
static PyObject * CosTable_setTable(CosTable *self, PyObject *arg) { SET_TABLE };
static PyObject * CosTable_getTable(CosTable *self) { GET_TABLE };
-static PyObject * CosTable_getViewTable(CosTable *self) { GET_VIEW_TABLE };
+static PyObject * CosTable_getViewTable(CosTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * CosTable_put(CosTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * CosTable_get(CosTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * CosTable_add(CosTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * CosTable_sub(CosTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * CosTable_mul(CosTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
CosTable_setSize(CosTable *self, PyObject *value)
@@ -2358,42 +2409,42 @@ CosTable_setSize(CosTable *self, PyObject *value)
PyObject *tup, *x2;
int old_size, x1;
MYFLT factor;
-
+
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
+
old_size = self->size;
- self->size = PyInt_AsLong(value);
-
+ self->size = PyInt_AsLong(value);
+
factor = (MYFLT)(self->size) / old_size;
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
Py_ssize_t listsize = PyList_Size(self->pointslist);
-
+
PyObject *listtemp = PyList_New(0);
-
+
for(i=0; i<(listsize); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
x2 = PyNumber_Float(PyTuple_GET_ITEM(tup, 1));
PyList_Append(listtemp, PyTuple_Pack(2, PyInt_FromLong((int)(x1*factor)), x2));
}
-
+
Py_INCREF(listtemp);
Py_DECREF(self->pointslist);
self->pointslist = listtemp;
-
+
CosTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2418,18 +2469,18 @@ CosTable_replace(CosTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
CosTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2446,7 +2497,7 @@ static PyMethodDef CosTable_methods[] = {
{"copy", (PyCFunction)CosTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)CosTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)CosTable_getTable, METH_NOARGS, "Returns a list of table samples."},
-{"getViewTable", (PyCFunction)CosTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+{"getViewTable", (PyCFunction)CosTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)CosTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)CosTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)CosTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -2466,6 +2517,9 @@ static PyMethodDef CosTable_methods[] = {
{"get", (PyCFunction)CosTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
{"getPoints", (PyCFunction)CosTable_getPoints, METH_NOARGS, "Return the list of points."},
{"replace", (PyCFunction)CosTable_replace, METH_O, "Sets the harmonics amplitude list and generates a new waveform table."},
+{"add", (PyCFunction)CosTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)CosTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)CosTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -2526,12 +2580,12 @@ CosLogTable_generate(CosLogTable *self) {
PyObject *tup, *tup2;
int x1, y1;
MYFLT x2, y2, range, logrange, logmin, ratio, low, high, mu;
-
+
y1 = 0;
y2 = 0.0;
-
+
listsize = PyList_Size(self->pointslist);
-
+
for(i=0; i<(listsize-1); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
@@ -2551,7 +2605,7 @@ CosLogTable_generate(CosLogTable *self) {
low = x2;
high = y2;
}
-
+
steps = y1 - x1;
range = high - low;
logrange = MYLOG10(high) - MYLOG10(low);
@@ -2570,7 +2624,7 @@ CosLogTable_generate(CosLogTable *self) {
mu = x2 *(1.0-mu) + y2*mu;
ratio = (mu - low) / range;
self->data[x1+j] = MYPOW(10, ratio * logrange + logmin);
- }
+ }
}
}
if (y1 < (self->size-1)) {
@@ -2583,7 +2637,7 @@ CosLogTable_generate(CosLogTable *self) {
else {
self->data[self->size-1] = y2;
self->data[self->size] = y2;
- }
+ }
}
static int
@@ -2594,7 +2648,7 @@ CosLogTable_traverse(CosLogTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
CosLogTable_clear(CosLogTable *self)
{
pyo_table_CLEAR
@@ -2616,19 +2670,19 @@ CosLogTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *pointslist=NULL;
CosLogTable *self;
self = (CosLogTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->pointslist = PyList_New(0);
self->size = 8192;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
-
+
static char *kwlist[] = {"list", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", kwlist, &pointslist, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (pointslist) {
Py_INCREF(pointslist);
Py_DECREF(self->pointslist);
@@ -2638,15 +2692,15 @@ CosLogTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(0), PyFloat_FromDouble(0.)));
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(self->size), PyFloat_FromDouble(1.)));
}
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
CosLogTable_generate(self);
-
+
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -2667,9 +2721,12 @@ static PyObject * CosLogTable_pow(CosLogTable *self, PyObject *args, PyObject *k
static PyObject * CosLogTable_copy(CosLogTable *self, PyObject *arg) { COPY };
static PyObject * CosLogTable_setTable(CosLogTable *self, PyObject *arg) { SET_TABLE };
static PyObject * CosLogTable_getTable(CosLogTable *self) { GET_TABLE };
-static PyObject * CosLogTable_getViewTable(CosLogTable *self) { GET_VIEW_TABLE };
+static PyObject * CosLogTable_getViewTable(CosLogTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * CosLogTable_put(CosLogTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * CosLogTable_get(CosLogTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * CosLogTable_add(CosLogTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * CosLogTable_sub(CosLogTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * CosLogTable_mul(CosLogTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
CosLogTable_setSize(CosLogTable *self, PyObject *value)
@@ -2678,42 +2735,42 @@ CosLogTable_setSize(CosLogTable *self, PyObject *value)
PyObject *tup, *x2;
int old_size, x1;
MYFLT factor;
-
+
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
+
old_size = self->size;
- self->size = PyInt_AsLong(value);
-
+ self->size = PyInt_AsLong(value);
+
factor = (MYFLT)(self->size) / old_size;
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
Py_ssize_t listsize = PyList_Size(self->pointslist);
-
+
PyObject *listtemp = PyList_New(0);
-
+
for(i=0; i<(listsize); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
x2 = PyNumber_Float(PyTuple_GET_ITEM(tup, 1));
PyList_Append(listtemp, PyTuple_Pack(2, PyInt_FromLong((int)(x1*factor)), x2));
}
-
+
Py_INCREF(listtemp);
Py_DECREF(self->pointslist);
self->pointslist = listtemp;
-
+
CosLogTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2738,18 +2795,18 @@ CosLogTable_replace(CosLogTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
CosLogTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2766,7 +2823,7 @@ static PyMethodDef CosLogTable_methods[] = {
{"copy", (PyCFunction)CosLogTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)CosLogTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)CosLogTable_getTable, METH_NOARGS, "Returns a list of table samples."},
- {"getViewTable", (PyCFunction)CosLogTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+ {"getViewTable", (PyCFunction)CosLogTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)CosLogTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)CosLogTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)CosLogTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -2786,6 +2843,9 @@ static PyMethodDef CosLogTable_methods[] = {
{"get", (PyCFunction)CosLogTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
{"getPoints", (PyCFunction)CosLogTable_getPoints, METH_NOARGS, "Return the list of points."},
{"replace", (PyCFunction)CosLogTable_replace, METH_O, "Sets the harmonics amplitude list and generates a new waveform table."},
+ {"add", (PyCFunction)CosLogTable_add, METH_O, "Performs table addition."},
+ {"sub", (PyCFunction)CosLogTable_sub, METH_O, "Performs table substraction."},
+ {"mul", (PyCFunction)CosLogTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -2847,24 +2907,24 @@ CurveTable_generate(CurveTable *self) {
Py_ssize_t listsize;
PyObject *tup;
int x1, x2;
- MYFLT y0, y1, y2, y3;
+ MYFLT y0, y1, y2, y3;
MYFLT m0, m1, mu, mu2, mu3;
MYFLT a0, a1, a2, a3;
for (i=0; i<self->size; i++) {
self->data[i] = 0.0;
}
-
+
listsize = PyList_Size(self->pointslist);
int times[listsize+2];
MYFLT values[listsize+2];
-
+
for (i=0; i<listsize; i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
times[i+1] = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
- values[i+1] = PyFloat_AsDouble(PyNumber_Float(PyTuple_GET_ITEM(tup, 1)));
+ values[i+1] = PyFloat_AsDouble(PyNumber_Float(PyTuple_GET_ITEM(tup, 1)));
}
-
+
// sets imaginary points
times[0] = times[1] - times[2];
if (values[1] < values[2])
@@ -2878,12 +2938,12 @@ CurveTable_generate(CurveTable *self) {
values[endP] = values[endP-1] + values[endP-2];
else
values[endP] = values[endP-1] - values[endP-2];
-
+
for(i=1; i<listsize; i++) {
x1 = times[i];
- x2 = times[i+1];
+ x2 = times[i+1];
y0 = values[i-1]; y1 = values[i]; y2 = values[i+1]; y3 = values[i+2];
-
+
steps = x2 - x1;
if (steps <= 0)
continue;
@@ -2899,11 +2959,11 @@ CurveTable_generate(CurveTable *self) {
a1 = mu3 - 2.0*mu2 + mu;
a2 = mu3 - mu2;
a3 = -2.0*mu3 + 3.0*mu2;
-
+
self->data[x1+j] = (a0*y1 + a1*m0 + a2*m1 + a3*y2);
}
}
-
+
self->data[self->size] = self->data[self->size-1];
}
@@ -2915,7 +2975,7 @@ CurveTable_traverse(CurveTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
CurveTable_clear(CurveTable *self)
{
pyo_table_CLEAR
@@ -2935,23 +2995,23 @@ static PyObject *
CurveTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *pointslist=NULL;
- CurveTable *self;
+ CurveTable *self;
self = (CurveTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->pointslist = PyList_New(0);
self->size = 8192;
self->tension = 0.0;
self->bias = 0.0;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"list", "tension", "bias", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__OFFI, kwlist, &pointslist, &self->tension, &self->bias, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (pointslist) {
Py_INCREF(pointslist);
Py_DECREF(self->pointslist);
@@ -2961,7 +3021,7 @@ CurveTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(0), PyFloat_FromDouble(0.)));
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(self->size), PyFloat_FromDouble(1.)));
}
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
@@ -2969,7 +3029,7 @@ CurveTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -2990,48 +3050,51 @@ static PyObject * CurveTable_pow(CurveTable *self, PyObject *args, PyObject *kwd
static PyObject * CurveTable_copy(CurveTable *self, PyObject *arg) { COPY };
static PyObject * CurveTable_setTable(CurveTable *self, PyObject *arg) { SET_TABLE };
static PyObject * CurveTable_getTable(CurveTable *self) { GET_TABLE };
-static PyObject * CurveTable_getViewTable(CurveTable *self) { GET_VIEW_TABLE };
+static PyObject * CurveTable_getViewTable(CurveTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * CurveTable_put(CurveTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * CurveTable_get(CurveTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * CurveTable_add(CurveTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * CurveTable_sub(CurveTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * CurveTable_mul(CurveTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
CurveTable_setTension(CurveTable *self, PyObject *value)
-{
+{
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the tension attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyNumber_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The tension attribute value must be a float.");
return PyInt_FromLong(-1);
}
-
- self->tension = PyFloat_AsDouble(PyNumber_Float(value));
+
+ self->tension = PyFloat_AsDouble(PyNumber_Float(value));
CurveTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
CurveTable_setBias(CurveTable *self, PyObject *value)
-{
+{
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the bias attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyNumber_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The bias attribute value must be a float.");
return PyInt_FromLong(-1);
}
-
- self->bias = PyFloat_AsDouble(PyNumber_Float(value));
-
+
+ self->bias = PyFloat_AsDouble(PyNumber_Float(value));
+
CurveTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3043,42 +3106,42 @@ CurveTable_setSize(CurveTable *self, PyObject *value)
PyObject *tup, *x2;
int old_size, x1;
MYFLT factor;
-
+
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
+
old_size = self->size;
- self->size = PyInt_AsLong(value);
-
+ self->size = PyInt_AsLong(value);
+
factor = (MYFLT)(self->size) / old_size;
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
Py_ssize_t listsize = PyList_Size(self->pointslist);
-
+
PyObject *listtemp = PyList_New(0);
-
+
for(i=0; i<(listsize); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
x2 = PyNumber_Float(PyTuple_GET_ITEM(tup, 1));
PyList_Append(listtemp, PyTuple_Pack(2, PyInt_FromLong((int)(x1*factor)), x2));
}
-
+
Py_INCREF(listtemp);
Py_DECREF(self->pointslist);
self->pointslist = listtemp;
-
+
CurveTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3103,18 +3166,18 @@ CurveTable_replace(CurveTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
CurveTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3131,7 +3194,7 @@ static PyMethodDef CurveTable_methods[] = {
{"copy", (PyCFunction)CurveTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)CurveTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)CurveTable_getTable, METH_NOARGS, "Returns a list of table samples."},
-{"getViewTable", (PyCFunction)CurveTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+{"getViewTable", (PyCFunction)CurveTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)CurveTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)CurveTable_setData, METH_O, "Sets the table from samples in a text file."},
{"setSize", (PyCFunction)CurveTable_setSize, METH_O, "Sets the size of the table in samples"},
@@ -3153,6 +3216,9 @@ static PyMethodDef CurveTable_methods[] = {
{"fadein", (PyCFunction)CurveTable_fadein, METH_VARARGS|METH_KEYWORDS, "Apply a gradual increase in the level of the table's samples."},
{"fadeout", (PyCFunction)CurveTable_fadeout, METH_VARARGS|METH_KEYWORDS, "Apply a gradual decrease in the level of the table's samples."},
{"pow", (PyCFunction)CurveTable_pow, METH_VARARGS|METH_KEYWORDS, "Apply a power function on each sample in the table."},
+{"add", (PyCFunction)CurveTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)CurveTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)CurveTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -3214,29 +3280,29 @@ ExpTable_generate(ExpTable *self) {
Py_ssize_t listsize;
PyObject *tup;
int x1, x2;
- MYFLT y1, y2, range, inc, pointer, scl;
-
+ MYFLT y1, y2, range, inc, pointer, scl;
+
for (i=0; i<self->size; i++) {
self->data[i] = 0.0;
}
-
+
listsize = PyList_Size(self->pointslist);
int times[listsize];
MYFLT values[listsize];
-
+
for (i=0; i<listsize; i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
times[i] = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
- values[i] = PyFloat_AsDouble(PyNumber_Float(PyTuple_GET_ITEM(tup, 1)));
+ values[i] = PyFloat_AsDouble(PyNumber_Float(PyTuple_GET_ITEM(tup, 1)));
}
y1 = y2 = 0.0;
for(i=0; i<(listsize-1); i++) {
x1 = times[i];
- x2 = times[i+1];
- y1 = values[i];
+ x2 = times[i+1];
+ y1 = values[i];
y2 = values[i+1];
-
+
range = y2 - y1;
steps = x2 - x1;
if (steps <= 0)
@@ -3258,16 +3324,16 @@ ExpTable_generate(ExpTable *self) {
pointer += inc;
}
}
- }
+ }
else {
for(j=0; j<steps; j++) {
scl = MYPOW(pointer, self->exp);
self->data[x1+j] = scl * range + y1;
pointer += inc;
}
- }
+ }
}
-
+
self->data[self->size] = y2;
}
@@ -3279,7 +3345,7 @@ ExpTable_traverse(ExpTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
ExpTable_clear(ExpTable *self)
{
pyo_table_CLEAR
@@ -3299,23 +3365,23 @@ static PyObject *
ExpTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *pointslist=NULL;
- ExpTable *self;
+ ExpTable *self;
self = (ExpTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->pointslist = PyList_New(0);
self->size = 8192;
self->exp = 10.0;
self->inverse = 1;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"list", "exp", "inverse", "size", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__OFII, kwlist, &pointslist, &self->exp, &self->inverse, &self->size))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
if (pointslist) {
Py_INCREF(pointslist);
Py_DECREF(self->pointslist);
@@ -3325,7 +3391,7 @@ ExpTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(0), PyFloat_FromDouble(0.)));
PyList_Append(self->pointslist, PyTuple_Pack(2, PyInt_FromLong(self->size), PyFloat_FromDouble(1.)));
}
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
@@ -3333,7 +3399,7 @@ ExpTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -3354,48 +3420,51 @@ static PyObject * ExpTable_pow(ExpTable *self, PyObject *args, PyObject *kwds) {
static PyObject * ExpTable_copy(ExpTable *self, PyObject *arg) { COPY };
static PyObject * ExpTable_setTable(ExpTable *self, PyObject *arg) { SET_TABLE };
static PyObject * ExpTable_getTable(ExpTable *self) { GET_TABLE };
-static PyObject * ExpTable_getViewTable(ExpTable *self) { GET_VIEW_TABLE };
+static PyObject * ExpTable_getViewTable(ExpTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * ExpTable_put(ExpTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * ExpTable_get(ExpTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * ExpTable_add(ExpTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * ExpTable_sub(ExpTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * ExpTable_mul(ExpTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
ExpTable_setExp(ExpTable *self, PyObject *value)
-{
+{
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the exp attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyNumber_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The exp attribute value must be a float.");
return PyInt_FromLong(-1);
}
-
- self->exp = PyFloat_AsDouble(PyNumber_Float(value));
-
+
+ self->exp = PyFloat_AsDouble(PyNumber_Float(value));
+
ExpTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
ExpTable_setInverse(ExpTable *self, PyObject *value)
-{
+{
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the inverse attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The inverse attribute value must be a boolean (True or False or 0 or 1).");
return PyInt_FromLong(-1);
}
-
- self->inverse = PyInt_AsLong(value);
-
+
+ self->inverse = PyInt_AsLong(value);
+
ExpTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3407,42 +3476,42 @@ ExpTable_setSize(ExpTable *self, PyObject *value)
PyObject *tup, *x2;
int old_size, x1;
MYFLT factor;
-
+
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
return PyInt_FromLong(-1);
}
-
+
old_size = self->size;
- self->size = PyInt_AsLong(value);
-
+ self->size = PyInt_AsLong(value);
+
factor = (MYFLT)(self->size) / old_size;
-
+
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
TableStream_setSize(self->tablestream, self->size);
-
+
Py_ssize_t listsize = PyList_Size(self->pointslist);
-
+
PyObject *listtemp = PyList_New(0);
-
+
for(i=0; i<(listsize); i++) {
tup = PyList_GET_ITEM(self->pointslist, i);
x1 = PyInt_AsLong(PyNumber_Long(PyTuple_GET_ITEM(tup, 0)));
x2 = PyNumber_Float(PyTuple_GET_ITEM(tup, 1));
PyList_Append(listtemp, PyTuple_Pack(2, PyInt_FromLong((int)(x1*factor)), x2));
}
-
+
Py_INCREF(listtemp);
Py_DECREF(self->pointslist);
self->pointslist = listtemp;
-
+
ExpTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3467,18 +3536,18 @@ ExpTable_replace(ExpTable *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
ExpTable_generate(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -3494,7 +3563,7 @@ static PyMethodDef ExpTable_methods[] = {
{"copy", (PyCFunction)ExpTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)ExpTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)ExpTable_getTable, METH_NOARGS, "Returns a list of table samples."},
-{"getViewTable", (PyCFunction)ExpTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+{"getViewTable", (PyCFunction)ExpTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)ExpTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)ExpTable_setData, METH_O, "Sets the table from samples in a text file."},
{"setSize", (PyCFunction)ExpTable_setSize, METH_O, "Sets the size of the table in samples"},
@@ -3516,6 +3585,9 @@ static PyMethodDef ExpTable_methods[] = {
{"fadein", (PyCFunction)ExpTable_fadein, METH_VARARGS|METH_KEYWORDS, "Apply a gradual increase in the level of the table's samples."},
{"fadeout", (PyCFunction)ExpTable_fadeout, METH_VARARGS|METH_KEYWORDS, "Apply a gradual decrease in the level of the table's samples."},
{"pow", (PyCFunction)ExpTable_pow, METH_VARARGS|METH_KEYWORDS, "Apply a power function on each sample in the table."},
+{"add", (PyCFunction)ExpTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)ExpTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)ExpTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -3583,7 +3655,7 @@ SndTable_loadSound(SndTable *self) {
unsigned int i, num, num_items, num_chnls, snd_size, start, stop;
unsigned int num_count = 0;
MYFLT *tmp;
-
+
info.format = 0;
sf = sf_open(self->path, SFM_READ, &info);
if (sf == NULL)
@@ -3604,10 +3676,10 @@ SndTable_loadSound(SndTable *self) {
start = 0;
else
start = (unsigned int)(self->start * self->sndSr);
-
+
self->size = stop - start;
num_items = self->size * num_chnls;
-
+
/* Allocate space for the data to be read, then read it. */
self->data = (MYFLT *)realloc(self->data, (self->size + 1) * sizeof(MYFLT));
@@ -3621,7 +3693,7 @@ SndTable_loadSound(SndTable *self) {
for (i=0; i<num; i++) {
if ((i % num_chnls) == self->chnl) {
self->data[(int)(num_count++)] = tmp[i];
- }
+ }
}
} while (num == num_items);
sf_close(sf);
@@ -3635,11 +3707,11 @@ SndTable_loadSound(SndTable *self) {
for (i=0; i<num_items; i++) {
if ((i % num_chnls) == self->chnl) {
self->data[(int)(i/num_chnls)] = tmp[i];
- }
+ }
}
}
- self->data[self->size] = self->data[0];
+ self->data[self->size] = self->data[0];
self->start = 0.0;
self->stop = -1.0;
@@ -3656,7 +3728,7 @@ SndTable_appendSound(SndTable *self) {
unsigned int i, num_items, num_chnls, snd_size, start, stop, to_load_size, cross_in_samps, cross_point, index, real_index;
MYFLT *tmp, *tmp_data;
MYFLT cross_amp;
-
+
info.format = 0;
sf = sf_open(self->path, SFM_READ, &info);
if (sf == NULL)
@@ -3667,17 +3739,17 @@ SndTable_appendSound(SndTable *self) {
snd_size = info.frames;
self->sndSr = info.samplerate;
num_chnls = info.channels;
-
+
if (self->stop <= 0 || self->stop <= self->start || (self->stop*self->sndSr) > snd_size)
stop = snd_size;
else
stop = (unsigned int)(self->stop * self->sndSr);
-
+
if (self->start < 0 || (self->start*self->sndSr) > snd_size)
start = 0;
else
start = (unsigned int)(self->start * self->sndSr);
-
+
to_load_size = stop - start;
num_items = to_load_size * num_chnls;
cross_in_samps = (unsigned int)(self->crossfade * self->sr);
@@ -3685,11 +3757,11 @@ SndTable_appendSound(SndTable *self) {
cross_in_samps = to_load_size - 1;
if (cross_in_samps >= self->size)
cross_in_samps = self->size - 1;
-
+
/* Allocate space for the data to be read, then read it. */
tmp = (MYFLT *)malloc(num_items * sizeof(MYFLT));
tmp_data = (MYFLT *)malloc(self->size * sizeof(MYFLT));
-
+
sf_seek(sf, start, SEEK_SET);
SF_READ(sf, tmp, num_items);
sf_close(sf);
@@ -3703,7 +3775,7 @@ SndTable_appendSound(SndTable *self) {
cross_point = self->size - cross_in_samps;
self->size = self->size + to_load_size - cross_in_samps;
self->data = (MYFLT *)realloc(self->data, (self->size + 1) * sizeof(MYFLT));
-
+
if (cross_in_samps != 0) {
for (i=0; i<cross_point; i++) {
self->data[i] = tmp_data[i];
@@ -3716,7 +3788,7 @@ SndTable_appendSound(SndTable *self) {
index = (int)(i/num_chnls);
real_index = cross_point + index;
self->data[real_index] = tmp[i];
- }
+ }
}
}
else {
@@ -3730,12 +3802,12 @@ SndTable_appendSound(SndTable *self) {
}
else
self->data[real_index] = tmp[i];
- }
- }
+ }
+ }
}
-
- self->data[self->size] = self->data[0];
-
+
+ self->data[self->size] = self->data[0];
+
self->start = 0.0;
self->stop = -1.0;
free(tmp);
@@ -3749,11 +3821,11 @@ static void
SndTable_prependSound(SndTable *self) {
SNDFILE *sf;
SF_INFO info;
- unsigned int i, num_items, num_chnls, snd_size, start, stop, to_load_size, cross_in_samps, cross_point;
+ unsigned int i, num_items, num_chnls, snd_size, start, stop, to_load_size, cross_in_samps, cross_point;
unsigned int index = 0;
MYFLT *tmp, *tmp_data;
MYFLT cross_amp;
-
+
info.format = 0;
sf = sf_open(self->path, SFM_READ, &info);
if (sf == NULL)
@@ -3764,17 +3836,17 @@ SndTable_prependSound(SndTable *self) {
snd_size = info.frames;
self->sndSr = info.samplerate;
num_chnls = info.channels;
-
+
if (self->stop <= 0 || self->stop <= self->start || (self->stop*self->sndSr) > snd_size)
stop = snd_size;
else
stop = (unsigned int)(self->stop * self->sndSr);
-
+
if (self->start < 0 || (self->start*self->sndSr) > snd_size)
start = 0;
else
start = (unsigned int)(self->start * self->sndSr);
-
+
to_load_size = stop - start;
num_items = to_load_size * num_chnls;
cross_in_samps = (unsigned int)(self->crossfade * self->sr);
@@ -3782,31 +3854,31 @@ SndTable_prependSound(SndTable *self) {
cross_in_samps = to_load_size - 1;
if (cross_in_samps >= self->size)
cross_in_samps = self->size - 1;
-
+
/* Allocate space for the data to be read, then read it. */
tmp = (MYFLT *)malloc(num_items * sizeof(MYFLT));
tmp_data = (MYFLT *)malloc(self->size * sizeof(MYFLT));
-
+
sf_seek(sf, start, SEEK_SET);
SF_READ(sf, tmp, num_items);
sf_close(sf);
-
+
for (i=0; i<self->size; i++) {
tmp_data[i] = self->data[i];
}
-
+
cross_point = to_load_size - cross_in_samps;
self->size = self->size + to_load_size - cross_in_samps;
self->data = (MYFLT *)realloc(self->data, (self->size + 1) * sizeof(MYFLT));
-
+
if (self->crossfade == 0.0) {
for (i=0; i<num_items; i++) {
if ((i % num_chnls) == self->chnl) {
index = (int)(i/num_chnls);
self->data[index] = tmp[i];
- }
+ }
}
-
+
}
else {
for (i=0; i<num_items; i++) {
@@ -3818,16 +3890,16 @@ SndTable_prependSound(SndTable *self) {
}
else
self->data[index] = tmp[i];
- }
- }
+ }
+ }
}
-
+
for (i=(index+1); i<self->size; i++) {
self->data[i] = tmp_data[i - cross_point];
}
-
- self->data[self->size] = self->data[0];
-
+
+ self->data[self->size] = self->data[0];
+
self->start = 0.0;
self->stop = -1.0;
free(tmp);
@@ -3842,12 +3914,12 @@ SndTable_insertSound(SndTable *self) {
SNDFILE *sf;
SF_INFO info;
unsigned int i, num_items, num_chnls, snd_size, start, stop, to_load_size;
- unsigned int cross_in_samps, cross_point, insert_point, index;
- unsigned int read_point = 0;
+ unsigned int cross_in_samps, cross_point, insert_point, index;
+ unsigned int read_point = 0;
unsigned int real_index = 0;
MYFLT *tmp, *tmp_data;
MYFLT cross_amp;
-
+
info.format = 0;
sf = sf_open(self->path, SFM_READ, &info);
if (sf == NULL)
@@ -3858,24 +3930,24 @@ SndTable_insertSound(SndTable *self) {
snd_size = info.frames;
self->sndSr = info.samplerate;
num_chnls = info.channels;
-
+
if (self->stop <= 0 || self->stop <= self->start || (self->stop*self->sndSr) > snd_size)
stop = snd_size;
else
stop = (unsigned int)(self->stop * self->sndSr);
-
+
if (self->start < 0 || (self->start*self->sndSr) > snd_size)
start = 0;
else
start = (unsigned int)(self->start * self->sndSr);
-
+
to_load_size = stop - start;
num_items = to_load_size * num_chnls;
-
+
insert_point = (unsigned int)(self->insertPos * self->sr);
if (insert_point >= self->size)
insert_point = self->size - 1;
-
+
cross_in_samps = (unsigned int)(self->crossfade * self->sr);
if (cross_in_samps >= (to_load_size/2))
cross_in_samps = (to_load_size/2) - 5;
@@ -3887,32 +3959,32 @@ SndTable_insertSound(SndTable *self) {
/* Allocate space for the data to be read, then read it. */
tmp = (MYFLT *)malloc(num_items * sizeof(MYFLT));
tmp_data = (MYFLT *)malloc(self->size * sizeof(MYFLT));
-
+
sf_seek(sf, start, SEEK_SET);
SF_READ(sf, tmp, num_items);
sf_close(sf);
-
+
for (i=0; i<self->size; i++) {
tmp_data[i] = self->data[i];
}
-
+
self->size = self->size + to_load_size - (cross_in_samps * 2);
self->data = (MYFLT *)realloc(self->data, (self->size + 1) * sizeof(MYFLT));
-
+
cross_point = insert_point - cross_in_samps;
-
+
for (i=0; i<cross_point; i++) {
self->data[i] = tmp_data[i];
}
-
+
if (self->crossfade == 0.0) {
for (i=0; i<num_items; i++) {
if ((i % num_chnls) == self->chnl) {
index = (int)(i/num_chnls);
self->data[index+cross_point] = tmp[i];
- }
+ }
}
-
+
}
else {
for (i=0; i<num_items; i++) {
@@ -3930,18 +4002,18 @@ SndTable_insertSound(SndTable *self) {
}
else
self->data[real_index] = tmp[i];
- }
- }
+ }
+ }
}
-
+
read_point++;
for (i=(real_index+1); i<self->size; i++) {
self->data[i] = tmp_data[read_point];
read_point++;
}
-
- self->data[self->size] = self->data[0];
-
+
+ self->data[self->size] = self->data[0];
+
self->start = 0.0;
self->stop = -1.0;
free(tmp);
@@ -3958,7 +4030,7 @@ SndTable_traverse(SndTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
SndTable_clear(SndTable *self)
{
pyo_table_CLEAR
@@ -3978,9 +4050,9 @@ SndTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
SndTable *self;
-
+
self = (SndTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
self->sr = (MYFLT)PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
@@ -3992,10 +4064,10 @@ SndTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"path", "chnl", "start", "stop", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_S_IFF, kwlist, &self->path, &self->chnl, &self->start, &self->stop))
- return PyInt_FromLong(-1);
-
+ return PyInt_FromLong(-1);
+
if (strcmp(self->path, "") == 0) {
self->size = (int)self->sr;
self->data = (MYFLT *)realloc(self->data, (self->size + 1) * sizeof(MYFLT));
@@ -4013,7 +4085,7 @@ SndTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
else {
SndTable_loadSound(self);
}
-
+
return (PyObject *)self;
}
@@ -4036,9 +4108,12 @@ static PyObject * SndTable_setTable(SndTable *self, PyObject *arg) { SET_TABLE }
static PyObject * SndTable_getTable(SndTable *self) { GET_TABLE };
static PyObject * SndTable_put(SndTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * SndTable_get(SndTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * SndTable_add(SndTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * SndTable_sub(SndTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * SndTable_mul(SndTable *self, PyObject *arg) { TABLE_MUL };
-static PyObject *
-SndTable_getViewTable(SndTable *self, PyObject *args, PyObject *kwds) {
+static PyObject *
+SndTable_getViewTable(SndTable *self, PyObject *args, PyObject *kwds) {
int i, j, y, w, h, h2, step, size;
int count = 0;
int yOffset = 0;
@@ -4049,10 +4124,10 @@ SndTable_getViewTable(SndTable *self, PyObject *args, PyObject *kwds) {
PyObject *sizetmp = NULL;
static char *kwlist[] = {"size", "begin", "end", "yOffset", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__OFFI, kwlist, &sizetmp, &begin, &end, &yOffset))
- return PyInt_FromLong(-1);
-
+ return PyInt_FromLong(-1);
+
if (end <= 0.0)
end = self->size;
else {
@@ -4091,7 +4166,7 @@ SndTable_getViewTable(SndTable *self, PyObject *args, PyObject *kwds) {
h2 = h/2;
step = (int)(size / (MYFLT)(w));
fstep = (MYFLT)(w) / (size-1);
-
+
if (step == 0) {
samples = PyList_New(size);
for (i=0; i<size; i++) {
@@ -4139,8 +4214,8 @@ SndTable_getViewTable(SndTable *self, PyObject *args, PyObject *kwds) {
return samples;
};
-static PyObject *
-SndTable_getEnvelope(SndTable *self, PyObject *arg) {
+static PyObject *
+SndTable_getEnvelope(SndTable *self, PyObject *arg) {
int i, j, step, points;
long count;
MYFLT absin, last;
@@ -4150,9 +4225,9 @@ SndTable_getEnvelope(SndTable *self, PyObject *arg) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isInt = PyInt_Check(arg);
-
+
if (isInt) {
count = 0;
points = PyInt_AsLong(arg);
@@ -4178,68 +4253,68 @@ SndTable_getEnvelope(SndTable *self, PyObject *arg) {
static PyObject *
SndTable_setSound(SndTable *self, PyObject *args, PyObject *kwds)
-{
+{
static char *kwlist[] = {"path", "chnl", "start", "stop", NULL};
-
+
MYFLT stoptmp = -1.0;
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_S_IFF, kwlist, &self->path, &self->chnl, &self->start, &stoptmp)) {
Py_INCREF(Py_None);
return Py_None;
- }
-
+ }
+
self->stop = stoptmp;
SndTable_loadSound(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
SndTable_append(SndTable *self, PyObject *args, PyObject *kwds)
-{
+{
static char *kwlist[] = {"path", "crossfade", "chnl", "start", "stop", NULL};
-
+
MYFLT stoptmp = -1.0;
MYFLT crosstmp = 0.0;
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_S_FIFF, kwlist, &self->path, &crosstmp, &self->chnl, &self->start, &stoptmp)) {
Py_INCREF(Py_None);
return Py_None;
- }
-
+ }
+
self->stop = stoptmp;
if (crosstmp < 0.0)
self->crossfade = 0.0;
else
self->crossfade = crosstmp;
-
+
SndTable_appendSound(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
SndTable_insert(SndTable *self, PyObject *args, PyObject *kwds)
-{
+{
static char *kwlist[] = {"path", "pos", "crossfade", "chnl", "start", "stop", NULL};
-
+
MYFLT stoptmp = -1.0;
MYFLT crosstmp = 0.0;
MYFLT postmp = 0.0;
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_S_FFIFF, kwlist, &self->path, &postmp, &crosstmp, &self->chnl, &self->start, &stoptmp)) {
Py_INCREF(Py_None);
return Py_None;
- }
-
+ }
+
self->stop = stoptmp;
if (crosstmp < 0.0)
self->crossfade = 0.0;
else
self->crossfade = crosstmp;
-
+
if (postmp <= 0.0)
SndTable_prependSound(self);
else if (postmp >= ((self->size-1) / self->sndSr))
@@ -4248,7 +4323,7 @@ SndTable_insert(SndTable *self, PyObject *args, PyObject *kwds)
self->insertPos = postmp;
SndTable_insertSound(self);
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -4258,7 +4333,7 @@ SndTable_setSize(SndTable *self, PyObject *value)
{
Py_ssize_t i;
- self->size = PyInt_AsLong(value);
+ self->size = PyInt_AsLong(value);
self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
@@ -4270,7 +4345,7 @@ SndTable_setSize(SndTable *self, PyObject *value)
self->stop = -1.0;
TableStream_setSize(self->tablestream, self->size);
TableStream_setData(self->tablestream, self->data);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -4322,6 +4397,9 @@ static PyMethodDef SndTable_methods[] = {
{"setSize", (PyCFunction)SndTable_setSize, METH_O, "Sets the size of the table in samples"},
{"getSize", (PyCFunction)SndTable_getSize, METH_NOARGS, "Return the size of the table in samples."},
{"getRate", (PyCFunction)SndTable_getRate, METH_NOARGS, "Return the frequency (in cps) that reads the sound without pitch transposition."},
+{"add", (PyCFunction)SndTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)SndTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)SndTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -4366,7 +4444,7 @@ SndTable_members, /* tp_members */
0, /* tp_alloc */
SndTable_new, /* tp_new */
0, /* tp_free */
-0, /* tp_is_gc */
+0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
@@ -4422,7 +4500,7 @@ NewTable_traverse(NewTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
NewTable_clear(NewTable *self)
{
pyo_table_CLEAR
@@ -4444,18 +4522,18 @@ NewTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inittmp=NULL;
NewTable *self;
self = (NewTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->pointer = 0;
self->feedback = 0.0;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"length", "init", "feedback", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_F_OF, kwlist, &self->length, &inittmp, &self->feedback))
- Py_RETURN_NONE;
+ Py_RETURN_NONE;
self->sr = (MYFLT)PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
self->size = (int)(self->length * self->sr + 0.5);
@@ -4464,16 +4542,16 @@ NewTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<(self->size+1); i++) {
self->data[i] = 0.;
}
-
+
TableStream_setSize(self->tablestream, self->size);
if (inittmp && inittmp != Py_None) {
PyObject_CallMethod((PyObject *)self, "setTable", "O", inittmp);
}
-
+
TableStream_setData(self->tablestream, self->data);
TableStream_setSamplingRate(self->tablestream, self->sr);
-
+
return (PyObject *)self;
}
@@ -4496,9 +4574,12 @@ static PyObject * NewTable_setTable(NewTable *self, PyObject *arg) { SET_TABLE }
static PyObject * NewTable_getTable(NewTable *self) { GET_TABLE };
static PyObject * NewTable_put(NewTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * NewTable_get(NewTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * NewTable_add(NewTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * NewTable_sub(NewTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * NewTable_mul(NewTable *self, PyObject *arg) { TABLE_MUL };
-static PyObject *
-NewTable_getViewTable(NewTable *self, PyObject *args, PyObject *kwds) {
+static PyObject *
+NewTable_getViewTable(NewTable *self, PyObject *args, PyObject *kwds) {
int i, j, y, w, h, h2, step, size;
int count = 0;
int yOffset = 0;
@@ -4509,10 +4590,10 @@ NewTable_getViewTable(NewTable *self, PyObject *args, PyObject *kwds) {
PyObject *sizetmp = NULL;
static char *kwlist[] = {"size", "begin", "end", "yOffset", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__OFFI, kwlist, &sizetmp, &begin, &end, &yOffset))
- return PyInt_FromLong(-1);
-
+ return PyInt_FromLong(-1);
+
if (end <= 0.0)
end = self->size;
else {
@@ -4551,7 +4632,7 @@ NewTable_getViewTable(NewTable *self, PyObject *args, PyObject *kwds) {
h2 = h/2;
step = (int)(size / (MYFLT)(w));
fstep = (MYFLT)(w) / (size-1);
-
+
if (step == 0) {
samples = PyList_New(size);
for (i=0; i<size; i++) {
@@ -4631,8 +4712,8 @@ NewTable_setFeedback(NewTable *self, PyObject *value)
feed = 1.0;
self->feedback = feed;
}
-
- Py_RETURN_NONE;
+
+ Py_RETURN_NONE;
}
static PyMemberDef NewTable_members[] = {
@@ -4666,6 +4747,9 @@ static PyMethodDef NewTable_methods[] = {
{"getSize", (PyCFunction)NewTable_getSize, METH_NOARGS, "Return the size of the table in samples."},
{"getLength", (PyCFunction)NewTable_getLength, METH_NOARGS, "Return the length of the table in seconds."},
{"getRate", (PyCFunction)NewTable_getRate, METH_NOARGS, "Return the frequency (in cps) that reads the sound without pitch transposition."},
+{"add", (PyCFunction)NewTable_add, METH_O, "Performs table addition."},
+{"sub", (PyCFunction)NewTable_sub, METH_O, "Performs table substraction."},
+{"mul", (PyCFunction)NewTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -4732,7 +4816,7 @@ DataTable_traverse(DataTable *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
DataTable_clear(DataTable *self)
{
pyo_table_CLEAR
@@ -4754,35 +4838,35 @@ DataTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inittmp=NULL;
DataTable *self;
self = (DataTable *)type->tp_alloc(type, 0);
-
+
self->server = PyServer_get_server();
-
+
self->pointer = 0;
-
+
MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
static char *kwlist[] = {"size", "init", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "i|O", kwlist, &self->size, &inittmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
self->data = (MYFLT *)realloc(self->data, (self->size + 1) * sizeof(MYFLT));
-
+
for (i=0; i<(self->size+1); i++) {
self->data[i] = 0.;
}
-
+
TableStream_setSize(self->tablestream, self->size);
-
+
if (inittmp) {
PyObject_CallMethod((PyObject *)self, "setTable", "O", inittmp);
}
-
+
TableStream_setData(self->tablestream, self->data);
double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
TableStream_setSamplingRate(self->tablestream, sr);
-
+
return (PyObject *)self;
}
@@ -4803,9 +4887,12 @@ static PyObject * DataTable_pow(DataTable *self, PyObject *args, PyObject *kwds)
static PyObject * DataTable_copy(DataTable *self, PyObject *arg) { COPY };
static PyObject * DataTable_setTable(DataTable *self, PyObject *arg) { SET_TABLE };
static PyObject * DataTable_getTable(DataTable *self) { GET_TABLE };
-static PyObject * DataTable_getViewTable(DataTable *self) { GET_VIEW_TABLE };
+static PyObject * DataTable_getViewTable(DataTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
static PyObject * DataTable_put(DataTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
static PyObject * DataTable_get(DataTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * DataTable_add(DataTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * DataTable_sub(DataTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * DataTable_mul(DataTable *self, PyObject *arg) { TABLE_MUL };
static PyObject *
DataTable_getSize(DataTable *self)
@@ -4831,7 +4918,7 @@ static PyMethodDef DataTable_methods[] = {
{"copy", (PyCFunction)DataTable_copy, METH_O, "Copy data from table given in argument."},
{"setTable", (PyCFunction)DataTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)DataTable_getTable, METH_NOARGS, "Returns a list of table samples."},
- {"getViewTable", (PyCFunction)DataTable_getViewTable, METH_NOARGS, "Returns a list of pixel coordinates for drawing the table."},
+ {"getViewTable", (PyCFunction)DataTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
{"getTableStream", (PyCFunction)DataTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
{"setData", (PyCFunction)DataTable_setData, METH_O, "Sets the table from samples in a text file."},
{"normalize", (PyCFunction)DataTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
@@ -4849,6 +4936,9 @@ static PyMethodDef DataTable_methods[] = {
{"get", (PyCFunction)DataTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
{"getSize", (PyCFunction)DataTable_getSize, METH_NOARGS, "Return the size of the table in samples."},
{"getRate", (PyCFunction)DataTable_getRate, METH_NOARGS, "Return the frequency (in cps) that reads the sound without pitch transposition."},
+ {"add", (PyCFunction)DataTable_add, METH_O, "Performs table addition."},
+ {"sub", (PyCFunction)DataTable_sub, METH_O, "Performs table substraction."},
+ {"mul", (PyCFunction)DataTable_mul, METH_O, "Performs table multiplication."},
{NULL} /* Sentinel */
};
@@ -4894,65 +4984,298 @@ PyTypeObject DataTableType = {
DataTable_new, /* tp_new */
};
-/******************************/
-/* TableRec object definition */
-/******************************/
+/***********************/
+/* AtanTable structure */
+/***********************/
typedef struct {
- pyo_audio_HEAD
- PyObject *input;
- Stream *input_stream;
- NewTable *table;
- int pointer;
- int active;
- MYFLT fadetime;
- MYFLT fadeInSample;
- MYFLT *trigsBuffer;
- TriggerStream *trig_stream;
- MYFLT *time_buffer_streams;
- MYFLT *buffer;
-} TableRec;
+ pyo_table_HEAD
+ MYFLT slope;
+} AtanTable;
static void
-TableRec_compute_next_data_frame(TableRec *self)
+AtanTable_generate(AtanTable *self) {
+ int i, hsize;
+ MYFLT drv, invhsize, val, t, fac = 0;
+
+ hsize = self->size / 2;
+ invhsize = 1.0 / hsize;
+
+ drv = 1 - self->slope;
+ drv = drv * drv * drv * PI;
+ for(i=0; i<=hsize; i++) {
+ t = i * invhsize - 1;
+ val = MYATAN2(t, drv);
+ if (i == 0)
+ fac = 1.0 / -val;
+ val = val * fac;
+ self->data[i] = val;
+ self->data[self->size - i] = -val;
+ }
+}
+
+static int
+AtanTable_traverse(AtanTable *self, visitproc visit, void *arg)
{
- int i, num, upBound;
- MYFLT val;
- int size = PyInt_AsLong(NewTable_getSize((NewTable *)self->table));
+ pyo_table_VISIT
+ return 0;
+}
- for (i=0; i<self->bufsize; i++) {
- self->trigsBuffer[i] = 0.0;
- }
+static int
+AtanTable_clear(AtanTable *self)
+{
+ pyo_table_CLEAR
+ return 0;
+}
- if (!self->active) {
- for (i=0; i<self->bufsize; i++) {
- self->time_buffer_streams[i] = self->pointer;
- }
- }
+static void
+AtanTable_dealloc(AtanTable* self)
+{
+ free(self->data);
+ AtanTable_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
- if ((size - self->pointer) >= self->bufsize)
- num = self->bufsize;
- else {
- num = size - self->pointer;
- if (self->active == 1) {
- if (num <= 0)
- self->trigsBuffer[0] = 1.0;
- else
- self->trigsBuffer[num-1] = 1.0;
- self->active = 0;
- }
- }
+static PyObject *
+AtanTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ AtanTable *self;
+ self = (AtanTable *)type->tp_alloc(type, 0);
- if (self->pointer < size) {
- upBound = (int)(size - self->fadeInSample);
-
- //MYFLT buffer[num];
- //memset(&buffer, 0, sizeof(buffer));
- for (i=0; i<self->bufsize; i++) {
- self->buffer[i] = 0.0;
- }
- MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
- for (i=0; i<num; i++) {
+ self->server = PyServer_get_server();
+
+ self->size = 8192;
+ self->slope = 0.5;
+
+ MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
+
+ static char *kwlist[] = {"slope", "size", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_F_I, kwlist, &self->slope, &self->size))
+ Py_RETURN_NONE;
+
+ self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
+ TableStream_setSize(self->tablestream, self->size);
+ TableStream_setData(self->tablestream, self->data);
+ AtanTable_generate(self);
+
+ double sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
+ TableStream_setSamplingRate(self->tablestream, sr);
+
+ return (PyObject *)self;
+}
+
+static PyObject * AtanTable_getServer(AtanTable* self) { GET_SERVER };
+static PyObject * AtanTable_getTableStream(AtanTable* self) { GET_TABLE_STREAM };
+static PyObject * AtanTable_setData(AtanTable *self, PyObject *arg) { SET_TABLE_DATA };
+static PyObject * AtanTable_normalize(AtanTable *self) { NORMALIZE };
+static PyObject * AtanTable_reset(AtanTable *self) { TABLE_RESET };
+static PyObject * AtanTable_removeDC(AtanTable *self) { REMOVE_DC };
+static PyObject * AtanTable_reverse(AtanTable *self) { REVERSE };
+static PyObject * AtanTable_invert(AtanTable *self) { INVERT };
+static PyObject * AtanTable_rectify(AtanTable *self) { RECTIFY };
+static PyObject * AtanTable_bipolarGain(AtanTable *self, PyObject *args, PyObject *kwds) { TABLE_BIPOLAR_GAIN };
+static PyObject * AtanTable_lowpass(AtanTable *self, PyObject *args, PyObject *kwds) { TABLE_LOWPASS };
+static PyObject * AtanTable_fadein(AtanTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEIN };
+static PyObject * AtanTable_fadeout(AtanTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
+static PyObject * AtanTable_pow(AtanTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
+static PyObject * AtanTable_copy(AtanTable *self, PyObject *arg) { COPY };
+static PyObject * AtanTable_setTable(AtanTable *self, PyObject *arg) { SET_TABLE };
+static PyObject * AtanTable_getTable(AtanTable *self) { GET_TABLE };
+static PyObject * AtanTable_getViewTable(AtanTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
+static PyObject * AtanTable_put(AtanTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
+static PyObject * AtanTable_get(AtanTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * AtanTable_add(AtanTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * AtanTable_sub(AtanTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * AtanTable_mul(AtanTable *self, PyObject *arg) { TABLE_MUL };
+
+static PyObject *
+AtanTable_setSlope(AtanTable *self, PyObject *value)
+{
+
+ if (! PyNumber_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "The slope attribute value must be a number.");
+ return PyInt_FromLong(-1);
+ }
+
+ self->slope = PyFloat_AsDouble(PyNumber_Float(value));
+ if (self->slope < 0.0)
+ self->slope = 0.0;
+ else if (self->slope > 1.0)
+ self->slope = 1.0;
+
+ AtanTable_generate(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+AtanTable_setSize(AtanTable *self, PyObject *value)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "Cannot delete the size attribute.");
+ return PyInt_FromLong(-1);
+ }
+
+ if (! PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "The size attribute value must be an integer.");
+ return PyInt_FromLong(-1);
+ }
+
+ self->size = PyInt_AsLong(value);
+
+ self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
+ TableStream_setSize(self->tablestream, self->size);
+
+ AtanTable_generate(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+AtanTable_getSize(AtanTable *self)
+{
+ return PyInt_FromLong(self->size);
+};
+
+static PyMemberDef AtanTable_members[] = {
+ {"server", T_OBJECT_EX, offsetof(AtanTable, server), 0, "Pyo server."},
+ {"tablestream", T_OBJECT_EX, offsetof(AtanTable, tablestream), 0, "Table stream object."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef AtanTable_methods[] = {
+ {"getServer", (PyCFunction)AtanTable_getServer, METH_NOARGS, "Returns server object."},
+ {"copy", (PyCFunction)AtanTable_copy, METH_O, "Copy data from table given in argument."},
+ {"setTable", (PyCFunction)AtanTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
+ {"getTable", (PyCFunction)AtanTable_getTable, METH_NOARGS, "Returns a list of table samples."},
+ {"getViewTable", (PyCFunction)AtanTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
+ {"getTableStream", (PyCFunction)AtanTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
+ {"setData", (PyCFunction)AtanTable_setData, METH_O, "Sets the table from samples in a text file."},
+ {"normalize", (PyCFunction)AtanTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
+ {"reset", (PyCFunction)AtanTable_reset, METH_NOARGS, "Resets table samples to 0.0"},
+ {"removeDC", (PyCFunction)AtanTable_removeDC, METH_NOARGS, "Filter out DC offset from the table's data."},
+ {"reverse", (PyCFunction)AtanTable_reverse, METH_NOARGS, "Reverse the table's data."},
+ {"invert", (PyCFunction)AtanTable_invert, METH_NOARGS, "Reverse the table's data in amplitude."},
+ {"rectify", (PyCFunction)AtanTable_rectify, METH_NOARGS, "Positive rectification of the table's data."},
+ {"bipolarGain", (PyCFunction)AtanTable_bipolarGain, METH_VARARGS|METH_KEYWORDS, "Apply different amp values to positive and negative samples."},
+ {"lowpass", (PyCFunction)AtanTable_lowpass, METH_VARARGS|METH_KEYWORDS, "Apply a one-pole lowpass filter on table's samples."},
+ {"fadein", (PyCFunction)AtanTable_fadein, METH_VARARGS|METH_KEYWORDS, "Apply a gradual increase in the level of the table's samples."},
+ {"fadeout", (PyCFunction)AtanTable_fadeout, METH_VARARGS|METH_KEYWORDS, "Apply a gradual decrease in the level of the table's samples."},
+ {"pow", (PyCFunction)AtanTable_pow, METH_VARARGS|METH_KEYWORDS, "Apply a power function on each sample in the table."},
+ {"setSize", (PyCFunction)AtanTable_setSize, METH_O, "Sets the size of the table in samples"},
+ {"getSize", (PyCFunction)AtanTable_getSize, METH_NOARGS, "Return the size of the table in samples"},
+ {"setSlope", (PyCFunction)AtanTable_setSlope, METH_O, "Sets the slope of the atan function."},
+ {"put", (PyCFunction)AtanTable_put, METH_VARARGS|METH_KEYWORDS, "Puts a value at specified position in the table."},
+ {"get", (PyCFunction)AtanTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
+ {"add", (PyCFunction)AtanTable_add, METH_O, "Performs table addition."},
+ {"sub", (PyCFunction)AtanTable_sub, METH_O, "Performs table substraction."},
+ {"mul", (PyCFunction)AtanTable_mul, METH_O, "Performs table multiplication."},
+ {NULL} /* Sentinel */
+};
+
+PyTypeObject AtanTableType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.AtanTable_base", /*tp_name*/
+ sizeof(AtanTable), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)AtanTable_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+ "AtanTable objects. Generates a table filled with a sinc function.", /* tp_doc */
+ (traverseproc)AtanTable_traverse, /* tp_traverse */
+ (inquiry)AtanTable_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ AtanTable_methods, /* tp_methods */
+ AtanTable_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ AtanTable_new, /* tp_new */
+};
+
+/******************************/
+/* TableRec object definition */
+/******************************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ NewTable *table;
+ int pointer;
+ int active;
+ MYFLT fadetime;
+ MYFLT fadeInSample;
+ MYFLT *trigsBuffer;
+ TriggerStream *trig_stream;
+ MYFLT *time_buffer_streams;
+ MYFLT *buffer;
+} TableRec;
+
+static void
+TableRec_compute_next_data_frame(TableRec *self)
+{
+ int i, num, upBound;
+ MYFLT val;
+ int size = PyInt_AsLong(NewTable_getSize((NewTable *)self->table));
+
+ for (i=0; i<self->bufsize; i++) {
+ self->trigsBuffer[i] = 0.0;
+ }
+
+ if (!self->active) {
+ for (i=0; i<self->bufsize; i++) {
+ self->time_buffer_streams[i] = self->pointer;
+ }
+ }
+
+ if ((size - self->pointer) >= self->bufsize)
+ num = self->bufsize;
+ else {
+ num = size - self->pointer;
+ if (self->active == 1) {
+ if (num <= 0)
+ self->trigsBuffer[0] = 1.0;
+ else
+ self->trigsBuffer[num-1] = 1.0;
+ self->active = 0;
+ }
+ }
+
+ if (self->pointer < size) {
+ upBound = (int)(size - self->fadeInSample);
+
+ //MYFLT buffer[num];
+ //memset(&buffer, 0, sizeof(buffer));
+ for (i=0; i<self->bufsize; i++) {
+ self->buffer[i] = 0.0;
+ }
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+
+ for (i=0; i<num; i++) {
if (self->pointer < self->fadeInSample)
val = self->pointer / self->fadeInSample;
else if (self->pointer >= upBound)
@@ -4963,13 +5286,13 @@ TableRec_compute_next_data_frame(TableRec *self)
self->time_buffer_streams[i] = self->pointer++;
}
NewTable_recordChunk((NewTable *)self->table, self->buffer, num);
-
+
if (num < self->bufsize) {
for (i=num; i<self->bufsize; i++) {
self->time_buffer_streams[i] = self->pointer;
}
}
- }
+ }
}
static MYFLT *
@@ -4984,18 +5307,18 @@ TableRec_traverse(TableRec *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->table);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
TableRec_clear(TableRec *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->table);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -5017,34 +5340,31 @@ TableRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *tabletmp;
TableRec *self;
self = (TableRec *)type->tp_alloc(type, 0);
-
+
self->pointer = 0;
self->active = 1;
self->fadetime = 0.;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TableRec_compute_next_data_frame);
Stream_setStreamActive(self->stream, 0);
static char *kwlist[] = {"input", "table", "fadetime", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_OO_F, kwlist, &inputtmp, &tabletmp, &self->fadetime))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_STREAM
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of TableRec must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TableRec must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
Py_INCREF(tabletmp);
self->table = (NewTable *)tabletmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->buffer = (MYFLT *)realloc(self->buffer, self->bufsize * sizeof(MYFLT));
@@ -5053,11 +5373,11 @@ TableRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<self->bufsize; i++) {
self->buffer[i] = self->trigsBuffer[i] = self->time_buffer_streams[i] = 0.0;
- }
+ }
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
-
+
int size = PyInt_AsLong(NewTable_getSize((NewTable *)self->table));
if ((self->fadetime * self->sr) >= (size * 0.5))
self->fadetime = size * 0.499 / self->sr;
@@ -5073,11 +5393,11 @@ static PyObject * TableRec_getServer(TableRec* self) { GET_SERVER };
static PyObject * TableRec_getStream(TableRec* self) { GET_STREAM };
static PyObject * TableRec_getTriggerStream(TableRec* self) { GET_TRIGGER_STREAM };
-static PyObject * TableRec_play(TableRec *self, PyObject *args, PyObject *kwds)
-{
+static PyObject * TableRec_play(TableRec *self, PyObject *args, PyObject *kwds)
+{
self->pointer = 0;
self->active = 1;
- PLAY
+ PLAY
};
static PyObject * TableRec_stop(TableRec *self) { STOP };
@@ -5086,17 +5406,17 @@ static PyObject *
TableRec_setTable(TableRec *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->table);
self->table = (NewTable *)tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -5182,36 +5502,36 @@ static void
TableRecTimeStream_setProcMode(TableRecTimeStream *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TableRecTimeStream_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TableRecTimeStream_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TableRecTimeStream_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TableRecTimeStream_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TableRecTimeStream_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TableRecTimeStream_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TableRecTimeStream_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TableRecTimeStream_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TableRecTimeStream_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -5222,7 +5542,7 @@ TableRecTimeStream_compute_next_data_frame(TableRecTimeStream *self)
tmp = TableRec_getTimeBuffer((TableRec *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -5234,11 +5554,11 @@ TableRecTimeStream_traverse(TableRecTimeStream *self, visitproc visit, void *arg
return 0;
}
-static int
+static int
TableRecTimeStream_clear(TableRecTimeStream *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -5257,36 +5577,36 @@ TableRecTimeStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL;
TableRecTimeStream *self;
self = (TableRecTimeStream *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TableRecTimeStream_compute_next_data_frame);
self->mode_func_ptr = TableRecTimeStream_setProcMode;
static char *kwlist[] = {"mainPlayer", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &maintmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (TableRec *)maintmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * TableRecTimeStream_getServer(TableRecTimeStream* self) { GET_SERVER };
static PyObject * TableRecTimeStream_getStream(TableRecTimeStream* self) { GET_STREAM };
-static PyObject * TableRecTimeStream_setMul(TableRecTimeStream *self, PyObject *arg) { SET_MUL };
-static PyObject * TableRecTimeStream_setAdd(TableRecTimeStream *self, PyObject *arg) { SET_ADD };
-static PyObject * TableRecTimeStream_setSub(TableRecTimeStream *self, PyObject *arg) { SET_SUB };
-static PyObject * TableRecTimeStream_setDiv(TableRecTimeStream *self, PyObject *arg) { SET_DIV };
+static PyObject * TableRecTimeStream_setMul(TableRecTimeStream *self, PyObject *arg) { SET_MUL };
+static PyObject * TableRecTimeStream_setAdd(TableRecTimeStream *self, PyObject *arg) { SET_ADD };
+static PyObject * TableRecTimeStream_setSub(TableRecTimeStream *self, PyObject *arg) { SET_SUB };
+static PyObject * TableRecTimeStream_setDiv(TableRecTimeStream *self, PyObject *arg) { SET_DIV };
static PyObject * TableRecTimeStream_play(TableRecTimeStream *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TableRecTimeStream_out(TableRecTimeStream *self, PyObject *args, PyObject *kwds) { OUT };
@@ -5318,7 +5638,7 @@ static PyMethodDef TableRecTimeStream_methods[] = {
{"setMul", (PyCFunction)TableRecTimeStream_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)TableRecTimeStream_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)TableRecTimeStream_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)TableRecTimeStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {"setDiv", (PyCFunction)TableRecTimeStream_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -5446,32 +5766,32 @@ TableMorph_compute_next_data_frame(TableMorph *self)
{
int i, x, y;
MYFLT input, interp, interp1, interp2;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
int size = PyInt_AsLong(NewTable_getSize((NewTable *)self->table));
int len = PyList_Size(self->sources);
-
+
if (size != self->last_size)
TableMorph_alloc_memories(self);
input = TableMorph_clip(in[0]);
interp = input * (len - 1);
- x = (int)(interp);
+ x = (int)(interp);
y = x + 1;
-
+
MYFLT *tab1 = TableStream_getData((TableStream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->sources, x), "getTableStream", ""));
MYFLT *tab2 = TableStream_getData((TableStream *)PyObject_CallMethod((PyObject *)PyList_GET_ITEM(self->sources, y), "getTableStream", ""));
-
+
interp = MYFMOD(interp, 1.0);
interp1 = 1. - interp;
interp2 = interp;
-
+
//MYFLT buffer[size];
for (i=0; i<size; i++) {
self->buffer[i] = tab1[i] * interp1 + tab2[i] * interp2;
- }
-
+ }
+
NewTable_recordChunk((NewTable *)self->table, self->buffer, size);
}
@@ -5486,7 +5806,7 @@ TableMorph_traverse(TableMorph *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
TableMorph_clear(TableMorph *self)
{
pyo_CLEAR
@@ -5513,37 +5833,34 @@ TableMorph_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *tabletmp, *sourcestmp;
TableMorph *self;
self = (TableMorph *)type->tp_alloc(type, 0);
-
+
INIT_OBJECT_COMMON
-
+
Stream_setFunctionPtr(self->stream, TableMorph_compute_next_data_frame);
static char *kwlist[] = {"input", "table", "sources", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOO", kwlist, &inputtmp, &tabletmp, &sourcestmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_STREAM
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of TableMorph must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TableMorph must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
Py_INCREF(tabletmp);
self->table = (PyObject *)tabletmp;
-
+
Py_XDECREF(self->sources);
Py_INCREF(sourcestmp);
self->sources = (PyObject *)sourcestmp;
-
+
TableMorph_alloc_memories(self);
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
return (PyObject *)self;
}
@@ -5557,38 +5874,38 @@ static PyObject *
TableMorph_setTable(TableMorph *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->table);
self->table = (PyObject *)tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
TableMorph_setSources(TableMorph *self, PyObject *arg)
-{
+{
if (arg == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The amplitude list attribute value must be a list.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(arg);
Py_DECREF(self->sources);
self->sources = arg;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -5698,15 +6015,15 @@ TrigTableRec_compute_next_data_frame(TrigTableRec *self)
else
self->trigsBuffer[num-1] = 1.0;
self->active = 0;
- }
+ }
}
-
- if (self->pointer < size) {
+
+ if (self->pointer < size) {
upBound = size - self->fadeInSample;
-
+
MYFLT buffer[num];
memset(&buffer, 0, sizeof(buffer));
-
+
for (i=0; i<num; i++) {
if (self->pointer < self->fadeInSample)
val = self->pointer / self->fadeInSample;
@@ -5718,7 +6035,7 @@ TrigTableRec_compute_next_data_frame(TrigTableRec *self)
self->time_buffer_streams[i] = self->pointer++;
}
NewTable_recordChunk((NewTable *)self->table, buffer, num);
-
+
if (num < self->bufsize) {
for (i=num; i<self->bufsize; i++) {
self->time_buffer_streams[i] = self->pointer;
@@ -5742,14 +6059,14 @@ TrigTableRec_compute_next_data_frame(TrigTableRec *self)
else
self->trigsBuffer[num-1] = 1.0;
self->active = 0;
- }
+ }
}
-
+
upBound = size - self->fadeInSample;
-
+
MYFLT buffer[num];
memset(&buffer, 0, sizeof(buffer));
-
+
for (i=0; i<num; i++) {
if (self->pointer < self->fadeInSample) {
val = self->pointer / self->fadeInSample;
@@ -5788,11 +6105,11 @@ TrigTableRec_traverse(TrigTableRec *self, visitproc visit, void *arg)
Py_VISIT(self->trigger);
Py_VISIT(self->trigger_stream);
Py_VISIT(self->table);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
TrigTableRec_clear(TrigTableRec *self)
{
pyo_CLEAR
@@ -5801,7 +6118,7 @@ TrigTableRec_clear(TrigTableRec *self)
Py_CLEAR(self->trigger);
Py_CLEAR(self->trigger_stream);
Py_CLEAR(self->table);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -5822,20 +6139,20 @@ TrigTableRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *trigtmp, *trig_streamtmp, *tabletmp;
TrigTableRec *self;
self = (TrigTableRec *)type->tp_alloc(type, 0);
-
+
self->pointer = 0;
self->active = 0;
self->fadetime = 0.;
-
+
INIT_OBJECT_COMMON
-
+
Stream_setFunctionPtr(self->stream, TrigTableRec_compute_next_data_frame);
static char *kwlist[] = {"input", "trig", "table", "fadetime", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_OOO_F, kwlist, &inputtmp, &trigtmp, &tabletmp, &self->fadetime))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_STREAM
Py_XDECREF(self->trigger);
@@ -5845,30 +6162,27 @@ TrigTableRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_INCREF(trig_streamtmp);
Py_XDECREF(self->trigger_stream);
self->trigger_stream = (Stream *)trig_streamtmp;
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of TrigTableRec must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TrigTableRec must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
Py_INCREF(tabletmp);
self->table = (NewTable *)tabletmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
self->time_buffer_streams = (MYFLT *)realloc(self->time_buffer_streams, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = self->time_buffer_streams[i] = 0.0;
- }
+ }
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
-
+
int size = PyInt_AsLong(NewTable_getSize((NewTable *)self->table));
if ((self->fadetime * self->sr) >= (size * 0.5))
self->fadetime = size * 0.499 / self->sr;
@@ -5876,7 +6190,7 @@ TrigTableRec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->fadeInSample = 0.0;
else
self->fadeInSample = MYROUND(self->fadetime * self->sr + 0.5);
-
+
return (PyObject *)self;
}
@@ -5891,20 +6205,20 @@ static PyObject *
TrigTableRec_setTable(TrigTableRec *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->table);
self->table = (NewTable *)tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TrigTableRec_members[] = {
{"server", T_OBJECT_EX, offsetof(TrigTableRec, server), 0, "Pyo server."},
@@ -5988,36 +6302,36 @@ static void
TrigTableRecTimeStream_setProcMode(TrigTableRecTimeStream *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigTableRecTimeStream_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigTableRecTimeStream_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigTableRecTimeStream_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigTableRecTimeStream_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigTableRecTimeStream_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigTableRecTimeStream_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigTableRecTimeStream_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigTableRecTimeStream_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigTableRecTimeStream_postprocessing_revareva;
break;
- }
+ }
}
static void
@@ -6028,7 +6342,7 @@ TrigTableRecTimeStream_compute_next_data_frame(TrigTableRecTimeStream *self)
tmp = TrigTableRec_getTimeBuffer((TrigTableRec *)self->mainPlayer);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -6040,11 +6354,11 @@ TrigTableRecTimeStream_traverse(TrigTableRecTimeStream *self, visitproc visit, v
return 0;
}
-static int
+static int
TrigTableRecTimeStream_clear(TrigTableRecTimeStream *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainPlayer);
+ Py_CLEAR(self->mainPlayer);
return 0;
}
@@ -6063,36 +6377,36 @@ TrigTableRecTimeStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL;
TrigTableRecTimeStream *self;
self = (TrigTableRecTimeStream *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TrigTableRecTimeStream_compute_next_data_frame);
self->mode_func_ptr = TrigTableRecTimeStream_setProcMode;
static char *kwlist[] = {"mainPlayer", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &maintmp))
Py_RETURN_NONE;
-
+
Py_XDECREF(self->mainPlayer);
Py_INCREF(maintmp);
self->mainPlayer = (TrigTableRec *)maintmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * TrigTableRecTimeStream_getServer(TrigTableRecTimeStream* self) { GET_SERVER };
static PyObject * TrigTableRecTimeStream_getStream(TrigTableRecTimeStream* self) { GET_STREAM };
-static PyObject * TrigTableRecTimeStream_setMul(TrigTableRecTimeStream *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigTableRecTimeStream_setAdd(TrigTableRecTimeStream *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigTableRecTimeStream_setSub(TrigTableRecTimeStream *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigTableRecTimeStream_setDiv(TrigTableRecTimeStream *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigTableRecTimeStream_setMul(TrigTableRecTimeStream *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigTableRecTimeStream_setAdd(TrigTableRecTimeStream *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigTableRecTimeStream_setSub(TrigTableRecTimeStream *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigTableRecTimeStream_setDiv(TrigTableRecTimeStream *self, PyObject *arg) { SET_DIV };
static PyObject * TrigTableRecTimeStream_play(TrigTableRecTimeStream *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigTableRecTimeStream_out(TrigTableRecTimeStream *self, PyObject *args, PyObject *kwds) { OUT };
@@ -6124,7 +6438,7 @@ static PyMethodDef TrigTableRecTimeStream_methods[] = {
{"setMul", (PyCFunction)TrigTableRecTimeStream_setMul, METH_O, "Sets oscillator mul factor."},
{"setAdd", (PyCFunction)TrigTableRecTimeStream_setAdd, METH_O, "Sets oscillator add factor."},
{"setSub", (PyCFunction)TrigTableRecTimeStream_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)TrigTableRecTimeStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {"setDiv", (PyCFunction)TrigTableRecTimeStream_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -6260,18 +6574,18 @@ TablePut_traverse(TablePut *self, visitproc visit, void *arg)
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
Py_VISIT(self->table);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
TablePut_clear(TablePut *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
Py_CLEAR(self->table);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -6291,41 +6605,38 @@ TablePut_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *tabletmp;
TablePut *self;
self = (TablePut *)type->tp_alloc(type, 0);
-
+
self->pointer = 0;
self->active = 1;
self->last_value = 0.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TablePut_compute_next_data_frame);
Stream_setStreamActive(self->stream, 0);
static char *kwlist[] = {"input", "table", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &inputtmp, &tabletmp))
- Py_RETURN_NONE;
-
+ Py_RETURN_NONE;
+
INIT_INPUT_STREAM
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of TablePut must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TablePut must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
Py_INCREF(tabletmp);
self->table = (DataTable *)tabletmp;
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
+ }
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
@@ -6337,11 +6648,11 @@ static PyObject * TablePut_getServer(TablePut* self) { GET_SERVER };
static PyObject * TablePut_getStream(TablePut* self) { GET_STREAM };
static PyObject * TablePut_getTriggerStream(TablePut* self) { GET_TRIGGER_STREAM };
-static PyObject * TablePut_play(TablePut *self, PyObject *args, PyObject *kwds)
-{
+static PyObject * TablePut_play(TablePut *self, PyObject *args, PyObject *kwds)
+{
self->pointer = 0;
self->active = 1;
- PLAY
+ PLAY
};
static PyObject * TablePut_stop(TablePut *self) { STOP };
@@ -6350,17 +6661,17 @@ static PyObject *
TablePut_setTable(TablePut *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->table);
self->table = (DataTable *)tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -6425,3 +6736,222 @@ TablePut_members, /* tp_members */
0, /* tp_alloc */
TablePut_new, /* tp_new */
};
+
+/******************************/
+/* TableWrite object definition */
+/******************************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ PyObject *pos;
+ Stream *pos_stream;
+ NewTable *table;
+} TableWrite;
+
+static void
+TableWrite_compute_next_data_frame(TableWrite *self)
+{
+ int i, ipos;
+ PyObject *table;
+
+ table = PyObject_CallMethod((PyObject *)self->table, "getTableStream", "");
+ MYFLT *tablelist = TableStream_getData((TableStream *)table);
+ int size = TableStream_getSize((TableStream *)table);
+
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ MYFLT *pos = Stream_getData((Stream *)self->pos_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ ipos = (int)(pos[i] * size);
+ if (ipos < 0)
+ ipos = 0;
+ else if (ipos >= size)
+ ipos = size - 1;
+ tablelist[ipos] = in[i];
+ }
+}
+
+static int
+TableWrite_traverse(TableWrite *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->table);
+ Py_VISIT(self->pos);
+ Py_VISIT(self->pos_stream);
+ return 0;
+}
+
+static int
+TableWrite_clear(TableWrite *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->table);
+ Py_CLEAR(self->pos);
+ Py_CLEAR(self->pos_stream);
+ return 0;
+}
+
+static void
+TableWrite_dealloc(TableWrite* self)
+{
+ pyo_DEALLOC
+ TableWrite_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+TableWrite_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *inputtmp, *input_streamtmp, *postmp, *tabletmp;
+ TableWrite *self;
+ self = (TableWrite *)type->tp_alloc(type, 0);
+
+ INIT_OBJECT_COMMON
+
+ Stream_setFunctionPtr(self->stream, TableWrite_compute_next_data_frame);
+ Stream_setStreamActive(self->stream, 1);
+
+ static char *kwlist[] = {"input", "pos", "table", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOO", kwlist, &inputtmp, &postmp, &tabletmp))
+ Py_RETURN_NONE;
+
+ INIT_INPUT_STREAM
+
+ if (postmp) {
+ PyObject_CallMethod((PyObject *)self, "setPos", "O", postmp);
+ }
+
+ if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TableWrite must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
+ }
+ Py_XDECREF(self->table);
+ Py_INCREF(tabletmp);
+ self->table = (NewTable *)tabletmp;
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ return (PyObject *)self;
+}
+
+static PyObject * TableWrite_getServer(TableWrite* self) { GET_SERVER };
+static PyObject * TableWrite_getStream(TableWrite* self) { GET_STREAM };
+
+static PyObject * TableWrite_play(TableWrite *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * TableWrite_stop(TableWrite *self) { STOP };
+
+static PyObject *
+TableWrite_setPos(TableWrite *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ tmp = arg;
+ if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
+ PyErr_SetString(PyExc_TypeError, "\"pos\" argument of TableWrite must be a PyoObject.\n");
+ Py_RETURN_NONE;
+ }
+
+ Py_INCREF(tmp);
+ Py_XDECREF(self->pos);
+
+ self->pos = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->pos, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->pos_stream);
+ self->pos_stream = (Stream *)streamtmp;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+TableWrite_setTable(TableWrite *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ if (arg == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->table);
+ self->table = (NewTable *)tmp;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef TableWrite_members[] = {
+{"server", T_OBJECT_EX, offsetof(TableWrite, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(TableWrite, stream), 0, "Stream object."},
+{"input", T_OBJECT_EX, offsetof(TableWrite, input), 0, "Input sound object."},
+{"table", T_OBJECT_EX, offsetof(TableWrite, table), 0, "Table to record in."},
+{"pos", T_OBJECT_EX, offsetof(TableWrite, pos), 0, "Position in the Table to record in."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef TableWrite_methods[] = {
+{"getServer", (PyCFunction)TableWrite_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)TableWrite_getStream, METH_NOARGS, "Returns stream object."},
+{"setTable", (PyCFunction)TableWrite_setTable, METH_O, "Sets a new table."},
+{"setPos", (PyCFunction)TableWrite_setPos, METH_O, "Sets position in the sound table."},
+{"play", (PyCFunction)TableWrite_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"stop", (PyCFunction)TableWrite_stop, METH_NOARGS, "Stops computing."},
+{NULL} /* Sentinel */
+};
+
+PyTypeObject TableWriteType = {
+PyObject_HEAD_INIT(NULL)
+0, /*ob_size*/
+"_pyo.TableWrite_base", /*tp_name*/
+sizeof(TableWrite), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)TableWrite_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_compare*/
+0, /*tp_repr*/
+0, /*tp_as_number*/
+0, /*tp_as_sequence*/
+0, /*tp_as_mapping*/
+0, /*tp_hash */
+0, /*tp_call*/
+0, /*tp_str*/
+0, /*tp_getattro*/
+0, /*tp_setattro*/
+0, /*tp_as_buffer*/
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+"TableWrite objects. Record audio input in a table object.", /* tp_doc */
+(traverseproc)TableWrite_traverse, /* tp_traverse */
+(inquiry)TableWrite_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+TableWrite_methods, /* tp_methods */
+TableWrite_members, /* tp_members */
+0, /* tp_getset */
+0, /* tp_base */
+0, /* tp_dict */
+0, /* tp_descr_get */
+0, /* tp_descr_set */
+0, /* tp_dictoffset */
+0, /* tp_init */
+0, /* tp_alloc */
+TableWrite_new, /* tp_new */
+};
diff --git a/src/objects/trigmodule.c b/src/objects/trigmodule.c
index 29176d2..50c0a16 100644
--- a/src/objects/trigmodule.c
+++ b/src/objects/trigmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -34,7 +34,7 @@ typedef struct {
PyObject *max;
Stream *max_stream;
MYFLT value;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} TrigRandInt;
static void
@@ -42,11 +42,11 @@ TrigRandInt_generate_i(TrigRandInt *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1)
self->value = (MYFLT)((int)(rand()/((MYFLT)(RAND_MAX)+1)*ma));
-
+
self->data[i] = self->value;
}
}
@@ -56,11 +56,11 @@ TrigRandInt_generate_a(TrigRandInt *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1)
self->value = (MYFLT)((int)(rand()/((MYFLT)(RAND_MAX)+1)*ma[i]));
-
+
self->data[i] = self->value;
}
}
@@ -81,50 +81,50 @@ TrigRandInt_setProcMode(TrigRandInt *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = TrigRandInt_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = TrigRandInt_generate_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigRandInt_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigRandInt_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigRandInt_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigRandInt_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigRandInt_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigRandInt_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigRandInt_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigRandInt_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigRandInt_postprocessing_revareva;
break;
- }
+ }
}
static void
TrigRandInt_compute_next_data_frame(TrigRandInt *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -134,19 +134,19 @@ TrigRandInt_traverse(TrigRandInt *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
TrigRandInt_clear(TrigRandInt *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -166,38 +166,38 @@ TrigRandInt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *maxtmp=NULL, *multmp=NULL, *addtmp=NULL;
TrigRandInt *self;
self = (TrigRandInt *)type->tp_alloc(type, 0);
-
+
self->max = PyFloat_FromDouble(100.);
self->value = 0.;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TrigRandInt_compute_next_data_frame);
self->mode_func_ptr = TrigRandInt_setProcMode;
static char *kwlist[] = {"input", "max", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &maxtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
Server_generateSeed((Server *)self->server, TRIGRANDINT_ID);
if (self->modebuffer[2] == 0)
@@ -213,10 +213,10 @@ TrigRandInt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * TrigRandInt_getServer(TrigRandInt* self) { GET_SERVER };
static PyObject * TrigRandInt_getStream(TrigRandInt* self) { GET_STREAM };
-static PyObject * TrigRandInt_setMul(TrigRandInt *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigRandInt_setAdd(TrigRandInt *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigRandInt_setSub(TrigRandInt *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigRandInt_setDiv(TrigRandInt *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigRandInt_setMul(TrigRandInt *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigRandInt_setAdd(TrigRandInt *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigRandInt_setSub(TrigRandInt *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigRandInt_setDiv(TrigRandInt *self, PyObject *arg) { SET_DIV };
static PyObject * TrigRandInt_play(TrigRandInt *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigRandInt_out(TrigRandInt *self, PyObject *args, PyObject *kwds) { OUT };
@@ -235,14 +235,14 @@ static PyObject *
TrigRandInt_setMax(TrigRandInt *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -258,12 +258,12 @@ TrigRandInt_setMax(TrigRandInt *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TrigRandInt_members[] = {
{"server", T_OBJECT_EX, offsetof(TrigRandInt, server), 0, "Pyo server."},
@@ -387,7 +387,7 @@ typedef struct {
int timeStep;
MYFLT stepVal;
int timeCount;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
} TrigRand;
static void
@@ -397,7 +397,7 @@ TrigRand_generate_ii(TrigRand *self) {
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
MYFLT range = ma - mi;
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->timeCount = 0;
@@ -407,7 +407,7 @@ TrigRand_generate_ii(TrigRand *self) {
else
self->stepVal = (self->value - self->currentValue) / self->timeStep;
}
-
+
if (self->timeCount == (self->timeStep - 1)) {
self->currentValue = self->value;
self->timeCount++;
@@ -416,7 +416,7 @@ TrigRand_generate_ii(TrigRand *self) {
self->currentValue += self->stepVal;
self->timeCount++;
}
-
+
self->data[i] = self->currentValue;
}
}
@@ -427,7 +427,7 @@ TrigRand_generate_ai(TrigRand *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
MYFLT range = ma - mi[i];
if (in[i] == 1) {
@@ -447,8 +447,8 @@ TrigRand_generate_ai(TrigRand *self) {
self->currentValue += self->stepVal;
self->timeCount++;
}
-
- self->data[i] = self->currentValue;
+
+ self->data[i] = self->currentValue;
}
}
@@ -458,7 +458,7 @@ TrigRand_generate_ia(TrigRand *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
MYFLT range = ma[i] - mi;
if (in[i] == 1) {
@@ -469,7 +469,7 @@ TrigRand_generate_ia(TrigRand *self) {
else
self->stepVal = (self->value - self->currentValue) / self->timeStep;
}
-
+
if (self->timeCount == (self->timeStep - 1)) {
self->currentValue = self->value;
self->timeCount++;
@@ -478,7 +478,7 @@ TrigRand_generate_ia(TrigRand *self) {
self->currentValue += self->stepVal;
self->timeCount++;
}
-
+
self->data[i] = self->currentValue;
}
}
@@ -489,7 +489,7 @@ TrigRand_generate_aa(TrigRand *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
MYFLT range = ma[i] - mi[i];
if (in[i] == 1) {
@@ -500,7 +500,7 @@ TrigRand_generate_aa(TrigRand *self) {
else
self->stepVal = (self->value - self->currentValue) / self->timeStep;
}
-
+
if (self->timeCount == (self->timeStep - 1)) {
self->currentValue = self->value;
self->timeCount++;
@@ -509,7 +509,7 @@ TrigRand_generate_aa(TrigRand *self) {
self->currentValue += self->stepVal;
self->timeCount++;
}
-
+
self->data[i] = self->currentValue;
}
}
@@ -530,56 +530,56 @@ TrigRand_setProcMode(TrigRand *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = TrigRand_generate_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = TrigRand_generate_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = TrigRand_generate_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = TrigRand_generate_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigRand_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigRand_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigRand_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigRand_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigRand_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigRand_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigRand_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigRand_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigRand_postprocessing_revareva;
break;
- }
+ }
}
static void
TrigRand_compute_next_data_frame(TrigRand *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -589,23 +589,23 @@ TrigRand_traverse(TrigRand *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->min);
- Py_VISIT(self->min_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->min);
+ Py_VISIT(self->min_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
TrigRand_clear(TrigRand *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->min);
- Py_CLEAR(self->min_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->min);
+ Py_CLEAR(self->min_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -625,7 +625,7 @@ TrigRand_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *mintmp=NULL, *maxtmp=NULL, *multmp=NULL, *addtmp=NULL;
TrigRand *self;
self = (TrigRand *)type->tp_alloc(type, 0);
-
+
self->min = PyFloat_FromDouble(0.);
self->max = PyFloat_FromDouble(1.);
self->value = self->currentValue = 0.;
@@ -636,34 +636,34 @@ TrigRand_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TrigRand_compute_next_data_frame);
self->mode_func_ptr = TrigRand_setProcMode;
static char *kwlist[] = {"input", "min", "max", "port", "init", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OOFFOO, kwlist, &inputtmp, &mintmp, &maxtmp, &self->time, &inittmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (mintmp) {
PyObject_CallMethod((PyObject *)self, "setMin", "O", mintmp);
}
-
+
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
Server_generateSeed((Server *)self->server, TRIGRAND_ID);
@@ -678,10 +678,10 @@ TrigRand_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * TrigRand_getServer(TrigRand* self) { GET_SERVER };
static PyObject * TrigRand_getStream(TrigRand* self) { GET_STREAM };
-static PyObject * TrigRand_setMul(TrigRand *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigRand_setAdd(TrigRand *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigRand_setSub(TrigRand *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigRand_setDiv(TrigRand *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigRand_setMul(TrigRand *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigRand_setAdd(TrigRand *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigRand_setSub(TrigRand *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigRand_setDiv(TrigRand *self, PyObject *arg) { SET_DIV };
static PyObject * TrigRand_play(TrigRand *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigRand_out(TrigRand *self, PyObject *args, PyObject *kwds) { OUT };
@@ -700,14 +700,14 @@ static PyObject *
TrigRand_setMin(TrigRand *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->min);
@@ -723,25 +723,25 @@ TrigRand_setMin(TrigRand *self, PyObject *arg)
self->min_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigRand_setMax(TrigRand *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -757,35 +757,35 @@ TrigRand_setMax(TrigRand *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigRand_setPort(TrigRand *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
if (isNumber == 1) {
self->time = PyFloat_AS_DOUBLE(PyNumber_Float(tmp));
self->timeStep = (int)(self->time * self->sr);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TrigRand_members[] = {
{"server", T_OBJECT_EX, offsetof(TrigRand, server), 0, "Pyo server."},
@@ -913,14 +913,14 @@ typedef struct {
int timeStep;
MYFLT stepVal;
int timeCount;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
} TrigChoice;
static void
TrigChoice_generate(TrigChoice *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->timeCount = 0;
@@ -930,7 +930,7 @@ TrigChoice_generate(TrigChoice *self) {
else
self->stepVal = (self->value - self->currentValue) / self->timeStep;
}
-
+
if (self->timeCount == (self->timeStep - 1)) {
self->currentValue = self->value;
self->timeCount++;
@@ -939,7 +939,7 @@ TrigChoice_generate(TrigChoice *self) {
self->currentValue += self->stepVal;
self->timeCount++;
}
-
+
self->data[i] = self->currentValue;
}
}
@@ -959,44 +959,44 @@ TrigChoice_setProcMode(TrigChoice *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = TrigChoice_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigChoice_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigChoice_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigChoice_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigChoice_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigChoice_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigChoice_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigChoice_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigChoice_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigChoice_postprocessing_revareva;
break;
- }
+ }
}
static void
TrigChoice_compute_next_data_frame(TrigChoice *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1009,7 +1009,7 @@ TrigChoice_traverse(TrigChoice *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
TrigChoice_clear(TrigChoice *self)
{
pyo_CLEAR
@@ -1035,25 +1035,25 @@ TrigChoice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *choicetmp=NULL, *multmp=NULL, *addtmp=NULL;
TrigChoice *self;
self = (TrigChoice *)type->tp_alloc(type, 0);
-
+
self->value = self->currentValue = 0.;
self->time = 0.0;
self->timeCount = 0;
self->stepVal = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TrigChoice_compute_next_data_frame);
self->mode_func_ptr = TrigChoice_setProcMode;
static char *kwlist[] = {"input", "choice", "port", "init", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_OO_FFOO, kwlist, &inputtmp, &choicetmp, &self->time, &inittmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (choicetmp) {
PyObject_CallMethod((PyObject *)self, "setChoice", "O", choicetmp);
}
@@ -1061,18 +1061,18 @@ TrigChoice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
Server_generateSeed((Server *)self->server, TRIGCHOICE_ID);
self->value = self->currentValue = inittmp;
self->timeStep = (int)(self->time * self->sr);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1080,10 +1080,10 @@ TrigChoice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * TrigChoice_getServer(TrigChoice* self) { GET_SERVER };
static PyObject * TrigChoice_getStream(TrigChoice* self) { GET_STREAM };
-static PyObject * TrigChoice_setMul(TrigChoice *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigChoice_setAdd(TrigChoice *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigChoice_setSub(TrigChoice *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigChoice_setDiv(TrigChoice *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigChoice_setMul(TrigChoice *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigChoice_setAdd(TrigChoice *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigChoice_setSub(TrigChoice *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigChoice_setDiv(TrigChoice *self, PyObject *arg) { SET_DIV };
static PyObject * TrigChoice_play(TrigChoice *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigChoice_out(TrigChoice *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1103,7 +1103,7 @@ TrigChoice_setChoice(TrigChoice *self, PyObject *arg)
{
int i;
PyObject *tmp;
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The choice attribute must be a list.");
Py_INCREF(Py_None);
@@ -1116,35 +1116,35 @@ TrigChoice_setChoice(TrigChoice *self, PyObject *arg)
for (i=0; i<self->chSize; i++) {
self->choice[i] = PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(tmp, i)));
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigChoice_setPort(TrigChoice *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
if (isNumber == 1) {
self->time = PyFloat_AS_DOUBLE(PyNumber_Float(tmp));
self->timeStep = (int)(self->time * self->sr);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TrigChoice_members[] = {
{"server", T_OBJECT_EX, offsetof(TrigChoice, server), 0, "Pyo server."},
@@ -1270,7 +1270,7 @@ TrigFunc_generate(TrigFunc *self) {
int i;
PyObject *tuple, *result;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
if (self->arg == Py_None) {
@@ -1283,20 +1283,20 @@ TrigFunc_generate(TrigFunc *self) {
else {
tuple = PyTuple_New(1);
PyTuple_SET_ITEM(tuple, 0, self->arg);
- result = PyObject_Call(self->func, tuple, NULL);
+ result = PyObject_Call(self->func, tuple, NULL);
if (result == NULL) {
PyErr_Print();
return;
}
}
- }
+ }
}
}
static void
TrigFunc_compute_next_data_frame(TrigFunc *self)
{
- TrigFunc_generate(self);
+ TrigFunc_generate(self);
}
static int
@@ -1310,7 +1310,7 @@ TrigFunc_traverse(TrigFunc *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
TrigFunc_clear(TrigFunc *self)
{
pyo_CLEAR
@@ -1343,12 +1343,12 @@ TrigFunc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Stream_setFunctionPtr(self->stream, TrigFunc_compute_next_data_frame);
static char *kwlist[] = {"input", "function", "arg", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|O", kwlist, &inputtmp, &functmp, &argtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (functmp) {
PyObject_CallMethod((PyObject *)self, "setFunction", "O", functmp);
}
@@ -1356,7 +1356,7 @@ TrigFunc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (argtmp) {
PyObject_CallMethod((PyObject *)self, "setArg", "O", argtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
return (PyObject *)self;
@@ -1372,21 +1372,21 @@ static PyObject *
TrigFunc_setFunction(TrigFunc *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (! PyCallable_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The function attribute must be callable.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_XDECREF(self->func);
Py_INCREF(tmp);
self->func = tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigFunc_setArg(TrigFunc *self, PyObject *arg)
@@ -1397,10 +1397,10 @@ TrigFunc_setArg(TrigFunc *self, PyObject *arg)
Py_XDECREF(self->arg);
Py_INCREF(tmp);
self->arg = tmp;
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TrigFunc_members[] = {
{"server", T_OBJECT_EX, offsetof(TrigFunc, server), 0, "Pyo server."},
@@ -1489,7 +1489,7 @@ TrigEnv_readframes_i(TrigEnv *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
if (in[i] == 1) {
@@ -1514,11 +1514,11 @@ TrigEnv_readframes_i(TrigEnv *self) {
}
else
self->data[i] = 0.;
-
+
if (self->pointerPos > size && self->active == 1) {
self->trigsBuffer[i] = 1.0;
self->active = 0;
- }
+ }
}
}
@@ -1530,7 +1530,7 @@ TrigEnv_readframes_a(TrigEnv *self) {
MYFLT *dur_st = Stream_getData((Stream *)self->dur_stream);
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
if (in[i] == 1) {
@@ -1555,7 +1555,7 @@ TrigEnv_readframes_a(TrigEnv *self) {
}
else
self->data[i] = 0.;
-
+
if (self->pointerPos > size && self->active == 1) {
self->trigsBuffer[i] = 1.0;
self->active = 0;
@@ -1579,50 +1579,50 @@ TrigEnv_setProcMode(TrigEnv *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = TrigEnv_readframes_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = TrigEnv_readframes_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigEnv_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigEnv_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigEnv_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigEnv_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigEnv_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigEnv_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigEnv_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigEnv_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigEnv_postprocessing_revareva;
break;
- }
+ }
}
static void
TrigEnv_compute_next_data_frame(TrigEnv *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1633,22 +1633,22 @@ TrigEnv_traverse(TrigEnv *self, visitproc visit, void *arg)
Py_VISIT(self->table);
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->dur);
- Py_VISIT(self->dur_stream);
- Py_VISIT(self->trig_stream);
+ Py_VISIT(self->dur);
+ Py_VISIT(self->dur_stream);
+ Py_VISIT(self->trig_stream);
return 0;
}
-static int
+static int
TrigEnv_clear(TrigEnv *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->dur);
- Py_CLEAR(self->dur_stream);
- Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->dur);
+ Py_CLEAR(self->dur_stream);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -1668,15 +1668,15 @@ TrigEnv_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *tabletmp, *durtmp=NULL, *multmp=NULL, *addtmp=NULL;
TrigEnv *self;
self = (TrigEnv *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
self->pointerPos = 0.;
self->active = 0;
self->interp = 2;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TrigEnv_compute_next_data_frame);
self->mode_func_ptr = TrigEnv_setProcMode;
@@ -1685,47 +1685,44 @@ TrigEnv_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->current_dur = self->sr;
static char *kwlist[] = {"input", "table", "dur", "interp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OiOO", kwlist, &inputtmp, &tabletmp, &durtmp, &self->interp, &multmp, &addtmp))
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PySys_WriteStderr("TypeError: \"table\" argument of TrigEnv must be a PyoTableObject.\n");
- if (PyInt_AsLong(PyObject_CallMethod(self->server, "getIsBooted", NULL))) {
- PyObject_CallMethod(self->server, "shutdown", NULL);
- }
- Py_Exit(1);
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TrigEnv must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
Py_XDECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
+
if (durtmp) {
PyObject_CallMethod((PyObject *)self, "setDur", "O", durtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
-
+ }
+
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
-
+
(*self->mode_func_ptr)(self);
-
+
SET_INTERP_POINTER
return (PyObject *)self;
@@ -1734,10 +1731,10 @@ TrigEnv_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * TrigEnv_getServer(TrigEnv* self) { GET_SERVER };
static PyObject * TrigEnv_getStream(TrigEnv* self) { GET_STREAM };
static PyObject * TrigEnv_getTriggerStream(TrigEnv* self) { GET_TRIGGER_STREAM };
-static PyObject * TrigEnv_setMul(TrigEnv *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigEnv_setAdd(TrigEnv *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigEnv_setSub(TrigEnv *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigEnv_setDiv(TrigEnv *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigEnv_setMul(TrigEnv *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigEnv_setAdd(TrigEnv *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigEnv_setSub(TrigEnv *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigEnv_setDiv(TrigEnv *self, PyObject *arg) { SET_DIV };
static PyObject * TrigEnv_play(TrigEnv *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigEnv_out(TrigEnv *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1763,32 +1760,32 @@ static PyObject *
TrigEnv_setTable(TrigEnv *self, PyObject *arg)
{
PyObject *tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
Py_DECREF(self->table);
self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigEnv_setDur(TrigEnv *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->dur);
@@ -1804,12 +1801,12 @@ TrigEnv_setDur(TrigEnv *self, PyObject *arg)
self->dur_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigEnv_setInterp(TrigEnv *self, PyObject *arg)
@@ -1818,15 +1815,15 @@ TrigEnv_setInterp(TrigEnv *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
-
+ }
+
SET_INTERP_POINTER
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1971,7 +1968,7 @@ static void
TrigLinseg_convert_pointslist(TrigLinseg *self) {
int i;
PyObject *tup;
-
+
self->listsize = PyList_Size(self->pointslist);
self->targets = (MYFLT *)realloc(self->targets, self->listsize * sizeof(MYFLT));
self->times = (MYFLT *)realloc(self->times, self->listsize * sizeof(MYFLT));
@@ -1982,12 +1979,12 @@ TrigLinseg_convert_pointslist(TrigLinseg *self) {
}
}
-static void
+static void
TrigLinseg_reinit(TrigLinseg *self) {
if (self->newlist == 1) {
TrigLinseg_convert_pointslist((TrigLinseg *)self);
self->newlist = 0;
- }
+ }
self->currentTime = 0.0;
self->currentValue = self->targets[0];
self->which = 0;
@@ -1998,7 +1995,7 @@ static void
TrigLinseg_generate(TrigLinseg *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
if (in[i] == 1)
@@ -2011,7 +2008,7 @@ TrigLinseg_generate(TrigLinseg *self) {
self->trigsBuffer[i] = 1.0;
self->flag = 0;
self->currentValue = self->targets[self->which-1];
- }
+ }
else
if ((self->times[self->which] - self->times[self->which-1]) <= 0)
self->increment = self->targets[self->which] - self->currentValue;
@@ -2019,9 +2016,9 @@ TrigLinseg_generate(TrigLinseg *self) {
self->increment = (self->targets[self->which] - self->targets[self->which-1]) / ((self->times[self->which] - self->times[self->which-1]) / self->sampleToSec);
}
if (self->currentTime <= self->times[self->listsize-1])
- self->currentValue += self->increment;
+ self->currentValue += self->increment;
self->data[i] = (MYFLT)self->currentValue;
- self->currentTime += self->sampleToSec;
+ self->currentTime += self->sampleToSec;
}
else
self->data[i] = (MYFLT)self->currentValue;
@@ -2043,44 +2040,44 @@ TrigLinseg_setProcMode(TrigLinseg *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = TrigLinseg_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigLinseg_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigLinseg_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigLinseg_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigLinseg_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigLinseg_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigLinseg_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigLinseg_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigLinseg_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigLinseg_postprocessing_revareva;
break;
- }
+ }
}
static void
TrigLinseg_compute_next_data_frame(TrigLinseg *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2089,20 +2086,20 @@ TrigLinseg_traverse(TrigLinseg *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->pointslist);
- Py_VISIT(self->trig_stream);
- Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
+ Py_VISIT(self->trig_stream);
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
return 0;
}
-static int
+static int
TrigLinseg_clear(TrigLinseg *self)
{
pyo_CLEAR
Py_CLEAR(self->pointslist);
- Py_CLEAR(self->trig_stream);
- Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
return 0;
}
@@ -2124,11 +2121,11 @@ TrigLinseg_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *pointslist=NULL, *multmp=NULL, *addtmp=NULL;
TrigLinseg *self;
self = (TrigLinseg *)type->tp_alloc(type, 0);
-
+
self->newlist = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TrigLinseg_compute_next_data_frame);
self->mode_func_ptr = TrigLinseg_setProcMode;
@@ -2136,7 +2133,7 @@ TrigLinseg_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sampleToSec = 1. / self->sr;
static char *kwlist[] = {"input", "list", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &inputtmp, &pointslist, &multmp, &addtmp))
Py_RETURN_NONE;
@@ -2146,38 +2143,38 @@ TrigLinseg_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_XDECREF(self->pointslist);
self->pointslist = pointslist;
TrigLinseg_convert_pointslist((TrigLinseg *)self);
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
-
+ }
+
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * TrigLinseg_getServer(TrigLinseg* self) { GET_SERVER };
static PyObject * TrigLinseg_getStream(TrigLinseg* self) { GET_STREAM };
static PyObject * TrigLinseg_getTriggerStream(TrigLinseg* self) { GET_TRIGGER_STREAM };
-static PyObject * TrigLinseg_setMul(TrigLinseg *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigLinseg_setAdd(TrigLinseg *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigLinseg_setSub(TrigLinseg *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigLinseg_setDiv(TrigLinseg *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigLinseg_setMul(TrigLinseg *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigLinseg_setAdd(TrigLinseg *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigLinseg_setSub(TrigLinseg *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigLinseg_setDiv(TrigLinseg *self, PyObject *arg) { SET_DIV };
static PyObject * TrigLinseg_play(TrigLinseg *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigLinseg_stop(TrigLinseg *self) { STOP };
@@ -2198,18 +2195,18 @@ TrigLinseg_setList(TrigLinseg *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The points list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
self->newlist = 1;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2347,7 +2344,7 @@ typedef struct {
double exp;
double exp_tmp;
int inverse;
- int inverse_tmp;
+ int inverse_tmp;
MYFLT *trigsBuffer;
TriggerStream *trig_stream;
} TrigExpseg;
@@ -2356,7 +2353,7 @@ static void
TrigExpseg_convert_pointslist(TrigExpseg *self) {
int i;
PyObject *tup;
-
+
self->listsize = PyList_Size(self->pointslist);
self->targets = (MYFLT *)realloc(self->targets, self->listsize * sizeof(MYFLT));
self->times = (MYFLT *)realloc(self->times, self->listsize * sizeof(MYFLT));
@@ -2367,12 +2364,12 @@ TrigExpseg_convert_pointslist(TrigExpseg *self) {
}
}
-static void
+static void
TrigExpseg_reinit(TrigExpseg *self) {
if (self->newlist == 1) {
TrigExpseg_convert_pointslist((TrigExpseg *)self);
self->newlist = 0;
- }
+ }
self->currentTime = 0.0;
self->currentValue = self->targets[0];
self->which = 0;
@@ -2386,12 +2383,12 @@ TrigExpseg_generate(TrigExpseg *self) {
int i;
MYFLT scl;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
if (in[i] == 1)
TrigExpseg_reinit((TrigExpseg *)self);
-
+
if (self->flag == 1) {
if (self->currentTime >= self->times[self->which]) {
self->which++;
@@ -2399,7 +2396,7 @@ TrigExpseg_generate(TrigExpseg *self) {
self->trigsBuffer[i] = 1.0;
self->flag = 0;
self->currentValue = self->targets[self->which-1];
- }
+ }
else {
self->range = self->targets[self->which] - self->targets[self->which-1];
self->steps = (self->times[self->which] - self->times[self->which-1]) * self->sr;
@@ -2407,9 +2404,9 @@ TrigExpseg_generate(TrigExpseg *self) {
self->inc = 1.0;
else
self->inc = 1.0 / self->steps;
- self->pointer = 0.0;
+ self->pointer = 0.0;
}
- }
+ }
if (self->currentTime <= self->times[self->listsize-1]) {
if (self->pointer >= 1.0)
self->pointer = 1.0;
@@ -2417,12 +2414,12 @@ TrigExpseg_generate(TrigExpseg *self) {
scl = 1.0 - MYPOW(1.0 - self->pointer, self->exp);
else
scl = MYPOW(self->pointer, self->exp);
-
+
self->currentValue = scl * self->range + self->targets[self->which-1];
self->pointer += self->inc;
- }
+ }
self->data[i] = (MYFLT)self->currentValue;
- self->currentTime += self->sampleToSec;
+ self->currentTime += self->sampleToSec;
}
else
self->data[i] = (MYFLT)self->currentValue;
@@ -2444,44 +2441,44 @@ TrigExpseg_setProcMode(TrigExpseg *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = TrigExpseg_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigExpseg_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigExpseg_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigExpseg_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigExpseg_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigExpseg_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigExpseg_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigExpseg_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigExpseg_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigExpseg_postprocessing_revareva;
break;
- }
+ }
}
static void
TrigExpseg_compute_next_data_frame(TrigExpseg *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2490,20 +2487,20 @@ TrigExpseg_traverse(TrigExpseg *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->pointslist);
- Py_VISIT(self->trig_stream);
- Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
+ Py_VISIT(self->trig_stream);
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
return 0;
}
-static int
+static int
TrigExpseg_clear(TrigExpseg *self)
{
pyo_CLEAR
Py_CLEAR(self->pointslist);
- Py_CLEAR(self->trig_stream);
- Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->trig_stream);
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
return 0;
}
@@ -2525,62 +2522,62 @@ TrigExpseg_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *pointslist=NULL, *multmp=NULL, *addtmp=NULL;
TrigExpseg *self;
self = (TrigExpseg *)type->tp_alloc(type, 0);
-
+
self->newlist = 1;
self->exp = self->exp_tmp = 10;
self->inverse = self->inverse_tmp = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TrigExpseg_compute_next_data_frame);
self->mode_func_ptr = TrigExpseg_setProcMode;
-
+
self->sampleToSec = 1. / self->sr;
static char *kwlist[] = {"input", "list", "exp", "inverse", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|diOO", kwlist, &inputtmp, &pointslist, &self->exp_tmp, &self->inverse_tmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
Py_INCREF(pointslist);
Py_XDECREF(self->pointslist);
self->pointslist = pointslist;
TrigExpseg_convert_pointslist((TrigExpseg *)self);
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
-
+
for (i=0; i<self->bufsize; i++) {
self->trigsBuffer[i] = 0.0;
- }
+ }
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
TriggerStream_setData(self->trig_stream, self->trigsBuffer);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * TrigExpseg_getServer(TrigExpseg* self) { GET_SERVER };
static PyObject * TrigExpseg_getStream(TrigExpseg* self) { GET_STREAM };
static PyObject * TrigExpseg_getTriggerStream(TrigExpseg* self) { GET_TRIGGER_STREAM };
-static PyObject * TrigExpseg_setMul(TrigExpseg *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigExpseg_setAdd(TrigExpseg *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigExpseg_setSub(TrigExpseg *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigExpseg_setDiv(TrigExpseg *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigExpseg_setMul(TrigExpseg *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigExpseg_setAdd(TrigExpseg *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigExpseg_setSub(TrigExpseg *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigExpseg_setDiv(TrigExpseg *self, PyObject *arg) { SET_DIV };
static PyObject * TrigExpseg_play(TrigExpseg *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigExpseg_stop(TrigExpseg *self) { STOP };
@@ -2601,18 +2598,18 @@ TrigExpseg_setList(TrigExpseg *self, PyObject *value)
PyErr_SetString(PyExc_TypeError, "Cannot delete the list attribute.");
return PyInt_FromLong(-1);
}
-
+
if (! PyList_Check(value)) {
PyErr_SetString(PyExc_TypeError, "The points list attribute value must be a list of tuples.");
return PyInt_FromLong(-1);
}
-
+
Py_INCREF(value);
Py_DECREF(self->pointslist);
- self->pointslist = value;
-
+ self->pointslist = value;
+
self->newlist = 1;
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2624,9 +2621,9 @@ TrigExpseg_setExp(TrigExpseg *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->exp_tmp = PyFloat_AsDouble(PyNumber_Float(arg));
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2638,9 +2635,9 @@ TrigExpseg_setInverse(TrigExpseg *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
self->inverse_tmp = PyInt_AsLong(PyNumber_Int(arg));
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -2782,18 +2779,18 @@ typedef struct {
int loopCountRec;
int loopLen;
int loopStop;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
} TrigXnoise;
// no parameter
static MYFLT
TrigXnoise_uniform(TrigXnoise *self) {
- return RANDOM_UNIFORM;
+ return RANDOM_UNIFORM;
}
static MYFLT
TrigXnoise_linear_min(TrigXnoise *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a < b) return a;
else return b;
@@ -2801,7 +2798,7 @@ TrigXnoise_linear_min(TrigXnoise *self) {
static MYFLT
TrigXnoise_linear_max(TrigXnoise *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a > b) return a;
else return b;
@@ -2809,7 +2806,7 @@ TrigXnoise_linear_max(TrigXnoise *self) {
static MYFLT
TrigXnoise_triangle(TrigXnoise *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
return ((a + b) * 0.5);
}
@@ -2818,7 +2815,7 @@ TrigXnoise_triangle(TrigXnoise *self) {
static MYFLT
TrigXnoise_expon_min(TrigXnoise *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = -MYLOG(RANDOM_UNIFORM) / self->xx1;
+ MYFLT val = -MYLOG(RANDOM_UNIFORM) / self->xx1;
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2827,7 +2824,7 @@ TrigXnoise_expon_min(TrigXnoise *self) {
static MYFLT
TrigXnoise_expon_max(TrigXnoise *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = 1.0 - (-MYLOG(RANDOM_UNIFORM) / self->xx1);
+ MYFLT val = 1.0 - (-MYLOG(RANDOM_UNIFORM) / self->xx1);
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2839,16 +2836,16 @@ TrigXnoise_biexpon(TrigXnoise *self) {
MYFLT polar, val;
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
MYFLT sum = RANDOM_UNIFORM * 2.0;
-
+
if (sum > 1.0) {
polar = -1;
sum = 2.0 - sum;
}
else
polar = 1;
-
+
val = 0.5 * (polar * MYLOG(sum) / self->xx1) + 0.5;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2861,14 +2858,14 @@ TrigXnoise_cauchy(TrigXnoise *self) {
rnd = RANDOM_UNIFORM;
}
while (rnd == 0.5);
-
+
if (rand() < (RAND_MAX / 2))
dir = -1;
else
dir = 1;
-
+
val = 0.5 * (MYTAN(rnd) * self->xx1 * dir) + 0.5;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2879,10 +2876,10 @@ static MYFLT
TrigXnoise_weibull(TrigXnoise *self) {
MYFLT rnd, val;
if (self->xx2 <= 0.0) self->xx2 = 0.00001;
-
+
rnd = 1.0 / (1.0 - RANDOM_UNIFORM);
val = self->xx1 * MYPOW(MYLOG(rnd), (1.0 / self->xx2));
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2892,10 +2889,10 @@ TrigXnoise_weibull(TrigXnoise *self) {
static MYFLT
TrigXnoise_gaussian(TrigXnoise *self) {
MYFLT rnd, val;
-
+
rnd = (RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM);
val = (self->xx2 * (rnd - 3.0) * 0.33 + self->xx1);
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2909,7 +2906,7 @@ TrigXnoise_poisson(TrigXnoise *self) {
MYFLT val;
if (self->xx1 < 0.1) self->xx1 = 0.1;
if (self->xx2 < 0.1) self->xx2 = 0.1;
-
+
if (self->xx1 != self->lastPoissonX1) {
self->lastPoissonX1 = self->xx1;
self->poisson_tab = 0;
@@ -2924,7 +2921,7 @@ TrigXnoise_poisson(TrigXnoise *self) {
}
}
val = self->poisson_buffer[rand() % self->poisson_tab] / 12.0 * self->xx2;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -2934,22 +2931,22 @@ TrigXnoise_poisson(TrigXnoise *self) {
static MYFLT
TrigXnoise_walker(TrigXnoise *self) {
int modulo, dir;
-
+
if (self->xx2 < 0.002) self->xx2 = 0.002;
-
+
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
return self->walkerValue;
}
@@ -2957,28 +2954,28 @@ TrigXnoise_walker(TrigXnoise *self) {
static MYFLT
TrigXnoise_loopseg(TrigXnoise *self) {
int modulo, dir;
-
+
if (self->loopChoice == 0) {
-
+
self->loopCountPlay = self->loopTime = 0;
-
+
if (self->xx2 < 0.002) self->xx2 = 0.002;
-
+
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
-
+
if (self->loopCountRec < self->loopLen)
self->loopChoice = 0;
else {
@@ -2988,22 +2985,22 @@ TrigXnoise_loopseg(TrigXnoise *self) {
}
else {
self->loopCountRec = 0;
-
+
self->walkerValue = self->loop_buffer[self->loopCountPlay++];
-
+
if (self->loopCountPlay < self->loopLen)
self->loopChoice = 1;
else {
self->loopCountPlay = 0;
self->loopTime++;
}
-
+
if (self->loopTime == self->loopStop) {
self->loopChoice = 0;
self->loopLen = (rand() % 10) + 3;
}
}
-
+
return self->walkerValue;
}
@@ -3013,7 +3010,7 @@ TrigXnoise_generate_ii(TrigXnoise *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
self->xx1 = PyFloat_AS_DOUBLE(self->x1);
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1)
self->value = (*self->type_func_ptr)(self);
@@ -3027,7 +3024,7 @@ TrigXnoise_generate_ai(TrigXnoise *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *x1 = Stream_getData((Stream *)self->x1_stream);
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->xx1 = x1[i];
@@ -3043,7 +3040,7 @@ TrigXnoise_generate_ia(TrigXnoise *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
self->xx1 = PyFloat_AS_DOUBLE(self->x1);
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->xx2 = x2[i];
@@ -3059,7 +3056,7 @@ TrigXnoise_generate_aa(TrigXnoise *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *x1 = Stream_getData((Stream *)self->x1_stream);
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->xx1 = x1[i];
@@ -3083,8 +3080,8 @@ static void TrigXnoise_postprocessing_revareva(TrigXnoise *self) { POST_PROCESSI
static void
TrigXnoise_setRandomType(TrigXnoise *self)
{
-
- switch (self->type) {
+
+ switch (self->type) {
case 0:
self->type_func_ptr = TrigXnoise_uniform;
break;
@@ -3124,7 +3121,7 @@ TrigXnoise_setRandomType(TrigXnoise *self)
case 12:
self->type_func_ptr = TrigXnoise_loopseg;
break;
- }
+ }
}
static void
@@ -3133,56 +3130,56 @@ TrigXnoise_setProcMode(TrigXnoise *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = TrigXnoise_generate_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = TrigXnoise_generate_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = TrigXnoise_generate_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = TrigXnoise_generate_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigXnoise_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigXnoise_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigXnoise_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigXnoise_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigXnoise_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigXnoise_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigXnoise_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigXnoise_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigXnoise_postprocessing_revareva;
break;
- }
+ }
}
static void
TrigXnoise_compute_next_data_frame(TrigXnoise *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3192,23 +3189,23 @@ TrigXnoise_traverse(TrigXnoise *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->x1);
- Py_VISIT(self->x1_stream);
- Py_VISIT(self->x2);
- Py_VISIT(self->x2_stream);
+ Py_VISIT(self->x1);
+ Py_VISIT(self->x1_stream);
+ Py_VISIT(self->x2);
+ Py_VISIT(self->x2_stream);
return 0;
}
-static int
+static int
TrigXnoise_clear(TrigXnoise *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->x1);
- Py_CLEAR(self->x1_stream);
- Py_CLEAR(self->x2);
- Py_CLEAR(self->x2_stream);
+ Py_CLEAR(self->x1);
+ Py_CLEAR(self->x1_stream);
+ Py_CLEAR(self->x2);
+ Py_CLEAR(self->x2_stream);
return 0;
}
@@ -3227,7 +3224,7 @@ TrigXnoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *x1tmp=NULL, *x2tmp=NULL, *multmp=NULL, *addtmp=NULL;
TrigXnoise *self;
self = (TrigXnoise *)type->tp_alloc(type, 0);
-
+
self->x1 = PyFloat_FromDouble(0.5);
self->x2 = PyFloat_FromDouble(0.5);
self->xx1 = self->xx2 = self->walkerValue = 0.5;
@@ -3238,7 +3235,7 @@ TrigXnoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
-
+
Server_generateSeed((Server *)self->server, TRIGXNOISE_ID);
self->poisson_tab = 0;
@@ -3249,23 +3246,23 @@ TrigXnoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<15; i++) {
self->loop_buffer[i] = 0.0;
}
- self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
+ self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
self->loopLen = (rand() % 10) + 3;
-
+
Stream_setFunctionPtr(self->stream, TrigXnoise_compute_next_data_frame);
self->mode_func_ptr = TrigXnoise_setProcMode;
static char *kwlist[] = {"input", "type", "x1", "x2", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOOOO", kwlist, &inputtmp, &self->type, &x1tmp, &x2tmp, &multmp, &addtmp))
Py_RETURN_NONE;
INIT_INPUT_STREAM
-
+
if (x1tmp) {
PyObject_CallMethod((PyObject *)self, "setX1", "O", x1tmp);
}
-
+
if (x2tmp) {
PyObject_CallMethod((PyObject *)self, "setX2", "O", x2tmp);
}
@@ -3273,15 +3270,15 @@ TrigXnoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
TrigXnoise_setRandomType(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3289,10 +3286,10 @@ TrigXnoise_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * TrigXnoise_getServer(TrigXnoise* self) { GET_SERVER };
static PyObject * TrigXnoise_getStream(TrigXnoise* self) { GET_STREAM };
-static PyObject * TrigXnoise_setMul(TrigXnoise *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigXnoise_setAdd(TrigXnoise *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigXnoise_setSub(TrigXnoise *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigXnoise_setDiv(TrigXnoise *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigXnoise_setMul(TrigXnoise *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigXnoise_setAdd(TrigXnoise *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigXnoise_setSub(TrigXnoise *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigXnoise_setDiv(TrigXnoise *self, PyObject *arg) { SET_DIV };
static PyObject * TrigXnoise_play(TrigXnoise *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigXnoise_out(TrigXnoise *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3309,35 +3306,35 @@ static PyObject * TrigXnoise_inplace_div(TrigXnoise *self, PyObject *arg) { INPL
static PyObject *
TrigXnoise_setType(TrigXnoise *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyInt_Check(arg);
-
+
if (isNumber == 1) {
self->type = PyInt_AsLong(arg);
TrigXnoise_setRandomType(self);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigXnoise_setX1(TrigXnoise *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x1);
@@ -3353,25 +3350,25 @@ TrigXnoise_setX1(TrigXnoise *self, PyObject *arg)
self->x1_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigXnoise_setX2(TrigXnoise *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x2);
@@ -3387,12 +3384,12 @@ TrigXnoise_setX2(TrigXnoise *self, PyObject *arg)
self->x2_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TrigXnoise_members[] = {
{"server", T_OBJECT_EX, offsetof(TrigXnoise, server), 0, "Pyo server."},
@@ -3536,21 +3533,21 @@ typedef struct {
int loopCountRec;
int loopLen;
int loopStop;
- int modebuffer[4]; // need at least 2 slots for mul & add
+ int modebuffer[4]; // need at least 2 slots for mul & add
} TrigXnoiseMidi;
static MYFLT
TrigXnoiseMidi_convert(TrigXnoiseMidi *self) {
int midival;
MYFLT val;
-
+
midival = (int)((self->value * (self->range_max-self->range_min)) + self->range_min);
-
+
if (midival < 0)
midival = 0;
else if (midival > 127)
midival = 127;
-
+
if (self->scale == 0)
val = (MYFLT)midival;
else if (self->scale == 1)
@@ -3567,12 +3564,12 @@ TrigXnoiseMidi_convert(TrigXnoiseMidi *self) {
// no parameter
static MYFLT
TrigXnoiseMidi_uniform(TrigXnoiseMidi *self) {
- return RANDOM_UNIFORM;
+ return RANDOM_UNIFORM;
}
static MYFLT
TrigXnoiseMidi_linear_min(TrigXnoiseMidi *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a < b) return a;
else return b;
@@ -3580,7 +3577,7 @@ TrigXnoiseMidi_linear_min(TrigXnoiseMidi *self) {
static MYFLT
TrigXnoiseMidi_linear_max(TrigXnoiseMidi *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
if (a > b) return a;
else return b;
@@ -3588,7 +3585,7 @@ TrigXnoiseMidi_linear_max(TrigXnoiseMidi *self) {
static MYFLT
TrigXnoiseMidi_triangle(TrigXnoiseMidi *self) {
- MYFLT a = RANDOM_UNIFORM;
+ MYFLT a = RANDOM_UNIFORM;
MYFLT b = RANDOM_UNIFORM;
return ((a + b) * 0.5);
}
@@ -3597,7 +3594,7 @@ TrigXnoiseMidi_triangle(TrigXnoiseMidi *self) {
static MYFLT
TrigXnoiseMidi_expon_min(TrigXnoiseMidi *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = -MYLOG10(RANDOM_UNIFORM) / self->xx1;
+ MYFLT val = -MYLOG10(RANDOM_UNIFORM) / self->xx1;
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3606,7 +3603,7 @@ TrigXnoiseMidi_expon_min(TrigXnoiseMidi *self) {
static MYFLT
TrigXnoiseMidi_expon_max(TrigXnoiseMidi *self) {
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
- MYFLT val = 1.0 - (-MYLOG10(RANDOM_UNIFORM) / self->xx1);
+ MYFLT val = 1.0 - (-MYLOG10(RANDOM_UNIFORM) / self->xx1);
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3618,16 +3615,16 @@ TrigXnoiseMidi_biexpon(TrigXnoiseMidi *self) {
MYFLT polar, val;
if (self->xx1 <= 0.0) self->xx1 = 0.00001;
MYFLT sum = RANDOM_UNIFORM * 2.0;
-
+
if (sum > 1.0) {
polar = -1;
sum = 2.0 - sum;
}
else
polar = 1;
-
+
val = 0.5 * (polar * MYLOG10(sum) / self->xx1) + 0.5;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3640,14 +3637,14 @@ TrigXnoiseMidi_cauchy(TrigXnoiseMidi *self) {
rnd = RANDOM_UNIFORM;
}
while (rnd == 0.5);
-
+
if (rand() < (RAND_MAX / 2))
dir = -1;
else
dir = 1;
-
+
val = 0.5 * (MYTAN(rnd) * self->xx1 * dir) + 0.5;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3658,10 +3655,10 @@ static MYFLT
TrigXnoiseMidi_weibull(TrigXnoiseMidi *self) {
MYFLT rnd, val;
if (self->xx2 <= 0.0) self->xx2 = 0.00001;
-
+
rnd = 1.0 / (1.0 - RANDOM_UNIFORM);
val = self->xx1 * MYPOW(MYLOG(rnd), (1.0 / self->xx2));
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3671,10 +3668,10 @@ TrigXnoiseMidi_weibull(TrigXnoiseMidi *self) {
static MYFLT
TrigXnoiseMidi_gaussian(TrigXnoiseMidi *self) {
MYFLT rnd, val;
-
+
rnd = (RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM + RANDOM_UNIFORM);
val = (self->xx2 * (rnd - 3.0) * 0.33 + self->xx1);
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3688,7 +3685,7 @@ TrigXnoiseMidi_poisson(TrigXnoiseMidi *self) {
MYFLT val;
if (self->xx1 < 0.1) self->xx1 = 0.1;
if (self->xx2 < 0.1) self->xx2 = 0.1;
-
+
if (self->xx1 != self->lastPoissonX1) {
self->lastPoissonX1 = self->xx1;
self->poisson_tab = 0;
@@ -3703,7 +3700,7 @@ TrigXnoiseMidi_poisson(TrigXnoiseMidi *self) {
}
}
val = self->poisson_buffer[rand() % self->poisson_tab] / 12.0 * self->xx2;
-
+
if (val < 0.0) return 0.0;
else if (val > 1.0) return 1.0;
else return val;
@@ -3713,22 +3710,22 @@ TrigXnoiseMidi_poisson(TrigXnoiseMidi *self) {
static MYFLT
TrigXnoiseMidi_walker(TrigXnoiseMidi *self) {
int modulo, dir;
-
+
if (self->xx2 < 0.002) self->xx2 = 0.002;
-
+
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
return self->walkerValue;
}
@@ -3736,28 +3733,28 @@ TrigXnoiseMidi_walker(TrigXnoiseMidi *self) {
static MYFLT
TrigXnoiseMidi_loopseg(TrigXnoiseMidi *self) {
int modulo, dir;
-
+
if (self->loopChoice == 0) {
-
+
self->loopCountPlay = self->loopTime = 0;
-
+
if (self->xx2 < 0.002) self->xx2 = 0.002;
-
+
modulo = (int)(self->xx2 * 1000.0);
dir = rand() % 2;
-
+
if (dir == 0)
self->walkerValue = self->walkerValue + (((rand() % modulo) - (modulo / 2)) * 0.001);
else
self->walkerValue = self->walkerValue - (((rand() % modulo) - (modulo / 2)) * 0.001);
-
+
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
-
+
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
-
+
if (self->loopCountRec < self->loopLen)
self->loopChoice = 0;
else {
@@ -3767,22 +3764,22 @@ TrigXnoiseMidi_loopseg(TrigXnoiseMidi *self) {
}
else {
self->loopCountRec = 0;
-
+
self->walkerValue = self->loop_buffer[self->loopCountPlay++];
-
+
if (self->loopCountPlay < self->loopLen)
self->loopChoice = 1;
else {
self->loopCountPlay = 0;
self->loopTime++;
}
-
+
if (self->loopTime == self->loopStop) {
self->loopChoice = 0;
self->loopLen = (rand() % 10) + 3;
}
}
-
+
return self->walkerValue;
}
@@ -3792,12 +3789,12 @@ TrigXnoiseMidi_generate_ii(TrigXnoiseMidi *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
self->xx1 = PyFloat_AS_DOUBLE(self->x1);
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->value = (*self->type_func_ptr)(self);
self->value = TrigXnoiseMidi_convert(self);
- }
+ }
self->data[i] = self->value;
}
}
@@ -3808,7 +3805,7 @@ TrigXnoiseMidi_generate_ai(TrigXnoiseMidi *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *x1 = Stream_getData((Stream *)self->x1_stream);
self->xx2 = PyFloat_AS_DOUBLE(self->x2);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->xx1 = x1[i];
@@ -3825,7 +3822,7 @@ TrigXnoiseMidi_generate_ia(TrigXnoiseMidi *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
self->xx1 = PyFloat_AS_DOUBLE(self->x1);
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->xx2 = x2[i];
@@ -3842,7 +3839,7 @@ TrigXnoiseMidi_generate_aa(TrigXnoiseMidi *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *x1 = Stream_getData((Stream *)self->x1_stream);
MYFLT *x2 = Stream_getData((Stream *)self->x2_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->xx1 = x1[i];
@@ -3867,8 +3864,8 @@ static void TrigXnoiseMidi_postprocessing_revareva(TrigXnoiseMidi *self) { POST_
static void
TrigXnoiseMidi_setRandomType(TrigXnoiseMidi *self)
{
-
- switch (self->type) {
+
+ switch (self->type) {
case 0:
self->type_func_ptr = TrigXnoiseMidi_uniform;
break;
@@ -3908,7 +3905,7 @@ TrigXnoiseMidi_setRandomType(TrigXnoiseMidi *self)
case 12:
self->type_func_ptr = TrigXnoiseMidi_loopseg;
break;
- }
+ }
}
static void
@@ -3917,56 +3914,56 @@ TrigXnoiseMidi_setProcMode(TrigXnoiseMidi *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = TrigXnoiseMidi_generate_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = TrigXnoiseMidi_generate_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = TrigXnoiseMidi_generate_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = TrigXnoiseMidi_generate_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigXnoiseMidi_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigXnoiseMidi_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigXnoiseMidi_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigXnoiseMidi_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigXnoiseMidi_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigXnoiseMidi_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigXnoiseMidi_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigXnoiseMidi_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigXnoiseMidi_postprocessing_revareva;
break;
- }
+ }
}
static void
TrigXnoiseMidi_compute_next_data_frame(TrigXnoiseMidi *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3976,23 +3973,23 @@ TrigXnoiseMidi_traverse(TrigXnoiseMidi *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->x1);
- Py_VISIT(self->x1_stream);
- Py_VISIT(self->x2);
- Py_VISIT(self->x2_stream);
+ Py_VISIT(self->x1);
+ Py_VISIT(self->x1_stream);
+ Py_VISIT(self->x2);
+ Py_VISIT(self->x2_stream);
return 0;
}
-static int
+static int
TrigXnoiseMidi_clear(TrigXnoiseMidi *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->x1);
- Py_CLEAR(self->x1_stream);
- Py_CLEAR(self->x2);
- Py_CLEAR(self->x2_stream);
+ Py_CLEAR(self->x1);
+ Py_CLEAR(self->x1_stream);
+ Py_CLEAR(self->x2);
+ Py_CLEAR(self->x2_stream);
return 0;
}
@@ -4011,7 +4008,7 @@ TrigXnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *x1tmp=NULL, *x2tmp=NULL, *rangetmp=NULL, *multmp=NULL, *addtmp=NULL;
TrigXnoiseMidi *self;
self = (TrigXnoiseMidi *)type->tp_alloc(type, 0);
-
+
self->x1 = PyFloat_FromDouble(0.5);
self->x2 = PyFloat_FromDouble(0.5);
self->xx1 = self->xx2 = self->walkerValue = 0.5;
@@ -4024,9 +4021,9 @@ TrigXnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
-
+
Server_generateSeed((Server *)self->server, TRIGXNOISEMIDI_ID);
self->poisson_tab = 0;
@@ -4037,23 +4034,23 @@ TrigXnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i=0; i<15; i++) {
self->loop_buffer[i] = 0.0;
}
- self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
+ self->loopChoice = self->loopCountPlay = self->loopTime = self->loopCountRec = self->loopStop = 0;
self->loopLen = (rand() % 10) + 3;
-
+
Stream_setFunctionPtr(self->stream, TrigXnoiseMidi_compute_next_data_frame);
self->mode_func_ptr = TrigXnoiseMidi_setProcMode;
static char *kwlist[] = {"input", "type", "x1", "x2", "scale", "range", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOOiOOO", kwlist, &inputtmp, &self->type, &x1tmp, &x2tmp, &self->scale, &rangetmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (x1tmp) {
PyObject_CallMethod((PyObject *)self, "setX1", "O", x1tmp);
}
-
+
if (x2tmp) {
PyObject_CallMethod((PyObject *)self, "setX2", "O", x2tmp);
}
@@ -4061,19 +4058,19 @@ TrigXnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (rangetmp) {
PyObject_CallMethod((PyObject *)self, "setRange", "O", rangetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
TrigXnoiseMidi_setRandomType(self);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -4081,10 +4078,10 @@ TrigXnoiseMidi_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * TrigXnoiseMidi_getServer(TrigXnoiseMidi* self) { GET_SERVER };
static PyObject * TrigXnoiseMidi_getStream(TrigXnoiseMidi* self) { GET_STREAM };
-static PyObject * TrigXnoiseMidi_setMul(TrigXnoiseMidi *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigXnoiseMidi_setAdd(TrigXnoiseMidi *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigXnoiseMidi_setSub(TrigXnoiseMidi *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigXnoiseMidi_setDiv(TrigXnoiseMidi *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigXnoiseMidi_setMul(TrigXnoiseMidi *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigXnoiseMidi_setAdd(TrigXnoiseMidi *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigXnoiseMidi_setSub(TrigXnoiseMidi *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigXnoiseMidi_setDiv(TrigXnoiseMidi *self, PyObject *arg) { SET_DIV };
static PyObject * TrigXnoiseMidi_play(TrigXnoiseMidi *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigXnoiseMidi_out(TrigXnoiseMidi *self, PyObject *args, PyObject *kwds) { OUT };
@@ -4101,34 +4098,34 @@ static PyObject * TrigXnoiseMidi_inplace_div(TrigXnoiseMidi *self, PyObject *arg
static PyObject *
TrigXnoiseMidi_setType(TrigXnoiseMidi *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyInt_Check(arg);
-
+
if (isNumber == 1) {
self->type = PyInt_AsLong(arg);
TrigXnoiseMidi_setRandomType(self);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigXnoiseMidi_setScale(TrigXnoiseMidi *self, PyObject *arg)
-{
+{
int tmp;
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyInt_Check(arg);
-
+
if (isNumber == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp <= 2)
@@ -4136,43 +4133,43 @@ TrigXnoiseMidi_setScale(TrigXnoiseMidi *self, PyObject *arg)
else
printf("scale attribute must be an integer {0, 1, 2}\n");
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigXnoiseMidi_setRange(TrigXnoiseMidi *self, PyObject *args)
-{
+{
if (args == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isTuple = PyTuple_Check(args);
-
+
if (isTuple == 1) {
self->range_min = PyInt_AsLong(PyTuple_GET_ITEM(args, 0));
self->range_max = PyInt_AsLong(PyTuple_GET_ITEM(args, 1));
self->centralkey = (int)((self->range_max + self->range_min) / 2);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigXnoiseMidi_setX1(TrigXnoiseMidi *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x1);
@@ -4188,25 +4185,25 @@ TrigXnoiseMidi_setX1(TrigXnoiseMidi *self, PyObject *arg)
self->x1_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
TrigXnoiseMidi_setX2(TrigXnoiseMidi *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->x2);
@@ -4222,12 +4219,12 @@ TrigXnoiseMidi_setX2(TrigXnoiseMidi *self, PyObject *arg)
self->x2_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TrigXnoiseMidi_members[] = {
{"server", T_OBJECT_EX, offsetof(TrigXnoiseMidi, server), 0, "Pyo server."},
@@ -4355,14 +4352,14 @@ typedef struct {
int dir;
int direction;
MYFLT value;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
} Counter;
static void
Counter_generates(Counter *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->value = (MYFLT)self->tmp;
@@ -4370,22 +4367,22 @@ Counter_generates(Counter *self) {
self->tmp++;
if (self->tmp >= self->max)
self->tmp = self->min;
- }
+ }
else if (self->dir == 1) {
self->tmp--;
if (self->tmp < self->min)
self->tmp = self->max - 1;
- }
+ }
else if (self->dir == 2) {
self->tmp = self->tmp + self->direction;
if (self->tmp >= self->max) {
self->direction = -1;
self->tmp = self->max - 2;
- }
+ }
if (self->tmp <= self->min) {
self->direction = 1;
self->tmp = self->min;
- }
+ }
}
}
self->data[i] = self->value;
@@ -4407,44 +4404,44 @@ Counter_setProcMode(Counter *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Counter_generates;
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Counter_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Counter_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Counter_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Counter_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Counter_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Counter_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Counter_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Counter_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Counter_postprocessing_revareva;
break;
- }
+ }
}
static void
Counter_compute_next_data_frame(Counter *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4457,7 +4454,7 @@ Counter_traverse(Counter *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Counter_clear(Counter *self)
{
pyo_CLEAR
@@ -4481,40 +4478,40 @@ Counter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
Counter *self;
self = (Counter *)type->tp_alloc(type, 0);
-
+
self->min = 0;
self->max = 100;
self->dir = 0;
self->direction = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Counter_compute_next_data_frame);
self->mode_func_ptr = Counter_setProcMode;
static char *kwlist[] = {"input", "min", "max", "dir", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|lliOO", kwlist, &inputtmp, &self->min, &self->max, &self->dir, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
if (self->dir == 0 || self->dir == 2)
self->tmp = self->min;
else
self->tmp = self->max - 1;
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -4522,10 +4519,10 @@ Counter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Counter_getServer(Counter* self) { GET_SERVER };
static PyObject * Counter_getStream(Counter* self) { GET_STREAM };
-static PyObject * Counter_setMul(Counter *self, PyObject *arg) { SET_MUL };
-static PyObject * Counter_setAdd(Counter *self, PyObject *arg) { SET_ADD };
-static PyObject * Counter_setSub(Counter *self, PyObject *arg) { SET_SUB };
-static PyObject * Counter_setDiv(Counter *self, PyObject *arg) { SET_DIV };
+static PyObject * Counter_setMul(Counter *self, PyObject *arg) { SET_MUL };
+static PyObject * Counter_setAdd(Counter *self, PyObject *arg) { SET_ADD };
+static PyObject * Counter_setSub(Counter *self, PyObject *arg) { SET_SUB };
+static PyObject * Counter_setDiv(Counter *self, PyObject *arg) { SET_DIV };
static PyObject * Counter_play(Counter *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Counter_stop(Counter *self) { STOP };
@@ -4541,57 +4538,57 @@ static PyObject * Counter_inplace_div(Counter *self, PyObject *arg) { INPLACE_DI
static PyObject *
Counter_setMin(Counter *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- if (PyLong_Check(arg) || PyInt_Check(arg)) {
+
+ if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->min = PyLong_AsLong(arg);
}
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Counter_setMax(Counter *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- if (PyLong_Check(arg) || PyInt_Check(arg)) {
+
+ if (PyLong_Check(arg) || PyInt_Check(arg)) {
self->max = PyLong_AsLong(arg);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Counter_setDir(Counter *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- if (PyInt_Check(arg)) {
+
+ if (PyInt_Check(arg)) {
self->dir = PyInt_AsLong(arg);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Counter_reset(Counter *self, PyObject *arg)
{
int val;
-
+
if (arg == Py_None) {
if (self->dir == 0 || self->dir == 2)
val = self->min;
@@ -4599,12 +4596,12 @@ Counter_reset(Counter *self, PyObject *arg)
val = self->max - 1;
self->tmp = val;
}
-
+
else if (PyInt_Check(arg)) {
val = PyInt_AsLong(arg);
self->tmp = val;
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -4748,7 +4745,7 @@ Thresh_generates_i(Thresh *self) {
}
else if (in[i] <= thresh && self->ready == 0)
self->ready = 1;
- }
+ }
break;
case 1:
for (i=0; i<self->bufsize; i++) {
@@ -4759,7 +4756,7 @@ Thresh_generates_i(Thresh *self) {
}
else if (in[i] >= thresh && self->ready == 0)
self->ready = 1;
- }
+ }
break;
case 2:
for (i=0; i<self->bufsize; i++) {
@@ -4771,8 +4768,8 @@ Thresh_generates_i(Thresh *self) {
else if (in[i] <= thresh && self->ready == 0) {
self->data[i] = 1.0;
self->ready = 1;
- }
- }
+ }
+ }
break;
}
}
@@ -4782,7 +4779,7 @@ Thresh_generates_a(Thresh *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *thresh = Stream_getData((Stream *)self->threshold_stream);
-
+
switch (self->dir) {
case 0:
for (i=0; i<self->bufsize; i++) {
@@ -4793,7 +4790,7 @@ Thresh_generates_a(Thresh *self) {
}
else if (in[i] <= thresh[i] && self->ready == 0)
self->ready = 1;
- }
+ }
break;
case 1:
for (i=0; i<self->bufsize; i++) {
@@ -4804,7 +4801,7 @@ Thresh_generates_a(Thresh *self) {
}
else if (in[i] >= thresh[i] && self->ready == 0)
self->ready = 1;
- }
+ }
break;
case 2:
for (i=0; i<self->bufsize; i++) {
@@ -4816,7 +4813,7 @@ Thresh_generates_a(Thresh *self) {
else if (in[i] <= thresh[i] && self->ready == 0)
self->data[i] = 1.0;
self->ready = 1;
- }
+ }
break;
}
}
@@ -4833,53 +4830,53 @@ static void Thresh_postprocessing_revareva(Thresh *self) { POST_PROCESSING_REVAR
static void
Thresh_setProcMode(Thresh *self)
-{
+{
int procmode = self->modebuffer[2];
int muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Thresh_generates_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Thresh_generates_a;
break;
}
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Thresh_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Thresh_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Thresh_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Thresh_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Thresh_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Thresh_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Thresh_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Thresh_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Thresh_postprocessing_revareva;
break;
- }
+ }
}
static void
Thresh_compute_next_data_frame(Thresh *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4894,7 +4891,7 @@ Thresh_traverse(Thresh *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Thresh_clear(Thresh *self)
{
pyo_CLEAR
@@ -4920,36 +4917,36 @@ Thresh_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *thresholdtmp, *multmp=NULL, *addtmp=NULL;
Thresh *self;
self = (Thresh *)type->tp_alloc(type, 0);
-
+
self->threshold = PyFloat_FromDouble(0.);
self->dir = 0;
self->ready = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Thresh_compute_next_data_frame);
self->mode_func_ptr = Thresh_setProcMode;
static char *kwlist[] = {"input", "threshold", "dir", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OiOO", kwlist, &inputtmp, &thresholdtmp, &self->dir, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (thresholdtmp) {
PyObject_CallMethod((PyObject *)self, "setThreshold", "O", thresholdtmp);
}
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -4959,10 +4956,10 @@ Thresh_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Thresh_getServer(Thresh* self) { GET_SERVER };
static PyObject * Thresh_getStream(Thresh* self) { GET_STREAM };
-static PyObject * Thresh_setMul(Thresh *self, PyObject *arg) { SET_MUL };
-static PyObject * Thresh_setAdd(Thresh *self, PyObject *arg) { SET_ADD };
-static PyObject * Thresh_setSub(Thresh *self, PyObject *arg) { SET_SUB };
-static PyObject * Thresh_setDiv(Thresh *self, PyObject *arg) { SET_DIV };
+static PyObject * Thresh_setMul(Thresh *self, PyObject *arg) { SET_MUL };
+static PyObject * Thresh_setAdd(Thresh *self, PyObject *arg) { SET_ADD };
+static PyObject * Thresh_setSub(Thresh *self, PyObject *arg) { SET_SUB };
+static PyObject * Thresh_setDiv(Thresh *self, PyObject *arg) { SET_DIV };
static PyObject * Thresh_play(Thresh *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Thresh_stop(Thresh *self) { STOP };
@@ -4980,14 +4977,14 @@ static PyObject *
Thresh_setThreshold(Thresh *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->threshold);
@@ -5003,28 +5000,28 @@ Thresh_setThreshold(Thresh *self, PyObject *arg)
self->threshold_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Thresh_setDir(Thresh *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
- if (PyInt_Check(arg)) {
+
+ if (PyInt_Check(arg)) {
self->dir = PyInt_AsLong(arg);
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Thresh_members[] = {
{"server", T_OBJECT_EX, offsetof(Thresh, server), 0, "Pyo server."},
@@ -5158,7 +5155,7 @@ Percent_generates_i(Percent *self) {
guess = (rand()/((MYFLT)(RAND_MAX)+1)) * 100.0;
if (guess <= perc)
self->data[i] = 1.0;
- }
+ }
}
}
@@ -5168,14 +5165,14 @@ Percent_generates_a(Percent *self) {
MYFLT guess;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *perc = Stream_getData((Stream *)self->percent_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
if (in[i] == 1.0) {
guess = (rand()/((MYFLT)(RAND_MAX)+1)) * 100.0;
if (guess <= perc[i])
self->data[i] = 1.0;
- }
+ }
}
}
@@ -5191,54 +5188,54 @@ static void Percent_postprocessing_revareva(Percent *self) { POST_PROCESSING_REV
static void
Percent_setProcMode(Percent *self)
-{
+{
int muladdmode, procmode
;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Percent_generates_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Percent_generates_a;
break;
}
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Percent_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Percent_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Percent_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Percent_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Percent_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Percent_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Percent_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Percent_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Percent_postprocessing_revareva;
break;
- }
+ }
}
static void
Percent_compute_next_data_frame(Percent *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -5253,7 +5250,7 @@ Percent_traverse(Percent *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Percent_clear(Percent *self)
{
pyo_CLEAR
@@ -5279,36 +5276,36 @@ Percent_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *percenttmp, *multmp=NULL, *addtmp=NULL;
Percent *self;
self = (Percent *)type->tp_alloc(type, 0);
-
+
self->percent = PyFloat_FromDouble(50.);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Percent_compute_next_data_frame);
self->mode_func_ptr = Percent_setProcMode;
static char *kwlist[] = {"input", "percent", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &percenttmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (percenttmp) {
PyObject_CallMethod((PyObject *)self, "setPercent", "O", percenttmp);
}
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
Server_generateSeed((Server *)self->server, PERCENT_ID);
(*self->mode_func_ptr)(self);
@@ -5318,10 +5315,10 @@ Percent_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Percent_getServer(Percent* self) { GET_SERVER };
static PyObject * Percent_getStream(Percent* self) { GET_STREAM };
-static PyObject * Percent_setMul(Percent *self, PyObject *arg) { SET_MUL };
-static PyObject * Percent_setAdd(Percent *self, PyObject *arg) { SET_ADD };
-static PyObject * Percent_setSub(Percent *self, PyObject *arg) { SET_SUB };
-static PyObject * Percent_setDiv(Percent *self, PyObject *arg) { SET_DIV };
+static PyObject * Percent_setMul(Percent *self, PyObject *arg) { SET_MUL };
+static PyObject * Percent_setAdd(Percent *self, PyObject *arg) { SET_ADD };
+static PyObject * Percent_setSub(Percent *self, PyObject *arg) { SET_SUB };
+static PyObject * Percent_setDiv(Percent *self, PyObject *arg) { SET_DIV };
static PyObject * Percent_play(Percent *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Percent_stop(Percent *self) { STOP };
@@ -5339,14 +5336,14 @@ static PyObject *
Percent_setPercent(Percent *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->percent);
@@ -5362,12 +5359,12 @@ Percent_setPercent(Percent *self, PyObject *arg)
self->percent_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Percent_members[] = {
{"server", T_OBJECT_EX, offsetof(Percent, server), 0, "Pyo server."},
@@ -5496,7 +5493,7 @@ Timer_generates(Timer *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (self->started == 1) {
self->count++;
@@ -5505,14 +5502,14 @@ Timer_generates(Timer *self) {
self->started = 0;
}
}
-
+
if (in2[i] == 1 && self->started == 0) {
self->count = 0;
self->started = 1;
}
-
+
self->data[i] = self->lasttime;
- }
+ }
}
static void Timer_postprocessing_ii(Timer *self) { POST_PROCESSING_II };
@@ -5527,46 +5524,46 @@ static void Timer_postprocessing_revareva(Timer *self) { POST_PROCESSING_REVAREV
static void
Timer_setProcMode(Timer *self)
-{
+{
int muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Timer_generates;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Timer_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Timer_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Timer_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Timer_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Timer_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Timer_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Timer_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Timer_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Timer_postprocessing_revareva;
break;
- }
+ }
}
static void
Timer_compute_next_data_frame(Timer *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -5581,7 +5578,7 @@ Timer_traverse(Timer *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Timer_clear(Timer *self)
{
pyo_CLEAR
@@ -5607,41 +5604,41 @@ Timer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *input2tmp, *input2_streamtmp, *multmp=NULL, *addtmp=NULL;
Timer *self;
self = (Timer *)type->tp_alloc(type, 0);
-
+
self->count = 0;
self->started = 0;
self->lasttime = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Timer_compute_next_data_frame);
self->mode_func_ptr = Timer_setProcMode;
static char *kwlist[] = {"input", "input2", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &inputtmp, &input2tmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
Py_XDECREF(self->input2);
self->input2 = input2tmp;
input2_streamtmp = PyObject_CallMethod((PyObject *)self->input2, "_getStream", NULL);
Py_INCREF(input2_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (Stream *)input2_streamtmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -5649,10 +5646,10 @@ Timer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Timer_getServer(Timer* self) { GET_SERVER };
static PyObject * Timer_getStream(Timer* self) { GET_STREAM };
-static PyObject * Timer_setMul(Timer *self, PyObject *arg) { SET_MUL };
-static PyObject * Timer_setAdd(Timer *self, PyObject *arg) { SET_ADD };
-static PyObject * Timer_setSub(Timer *self, PyObject *arg) { SET_SUB };
-static PyObject * Timer_setDiv(Timer *self, PyObject *arg) { SET_DIV };
+static PyObject * Timer_setMul(Timer *self, PyObject *arg) { SET_MUL };
+static PyObject * Timer_setAdd(Timer *self, PyObject *arg) { SET_ADD };
+static PyObject * Timer_setSub(Timer *self, PyObject *arg) { SET_SUB };
+static PyObject * Timer_setDiv(Timer *self, PyObject *arg) { SET_DIV };
static PyObject * Timer_play(Timer *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Timer_stop(Timer *self) { STOP };
@@ -5783,14 +5780,14 @@ typedef struct {
int chCount;
MYFLT *choice;
MYFLT value;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
} Iter;
static void
Iter_generate(Iter *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
if (self->chCount >= self->chSize)
@@ -5817,44 +5814,44 @@ Iter_setProcMode(Iter *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Iter_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Iter_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Iter_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Iter_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Iter_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Iter_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Iter_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Iter_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Iter_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Iter_postprocessing_revareva;
break;
- }
+ }
}
static void
Iter_compute_next_data_frame(Iter *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -5867,7 +5864,7 @@ Iter_traverse(Iter *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Iter_clear(Iter *self)
{
pyo_CLEAR
@@ -5893,39 +5890,39 @@ Iter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *choicetmp=NULL, *multmp=NULL, *addtmp=NULL;
Iter *self;
self = (Iter *)type->tp_alloc(type, 0);
-
+
self->value = 0.;
self->chCount = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Iter_compute_next_data_frame);
self->mode_func_ptr = Iter_setProcMode;
static char *kwlist[] = {"input", "choice", "init", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_OO_FOO, kwlist, &inputtmp, &choicetmp, &inittmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (choicetmp) {
PyObject_CallMethod((PyObject *)self, "setChoice", "O", choicetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
self->value = inittmp;
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -5933,10 +5930,10 @@ Iter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Iter_getServer(Iter* self) { GET_SERVER };
static PyObject * Iter_getStream(Iter* self) { GET_STREAM };
-static PyObject * Iter_setMul(Iter *self, PyObject *arg) { SET_MUL };
-static PyObject * Iter_setAdd(Iter *self, PyObject *arg) { SET_ADD };
-static PyObject * Iter_setSub(Iter *self, PyObject *arg) { SET_SUB };
-static PyObject * Iter_setDiv(Iter *self, PyObject *arg) { SET_DIV };
+static PyObject * Iter_setMul(Iter *self, PyObject *arg) { SET_MUL };
+static PyObject * Iter_setAdd(Iter *self, PyObject *arg) { SET_ADD };
+static PyObject * Iter_setSub(Iter *self, PyObject *arg) { SET_SUB };
+static PyObject * Iter_setDiv(Iter *self, PyObject *arg) { SET_DIV };
static PyObject * Iter_play(Iter *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Iter_out(Iter *self, PyObject *args, PyObject *kwds) { OUT };
@@ -5956,27 +5953,27 @@ Iter_setChoice(Iter *self, PyObject *arg)
{
int i;
PyObject *tmp;
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The choice attribute must be a list.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
self->chSize = PyList_Size(tmp);
self->choice = (MYFLT *)realloc(self->choice, self->chSize * sizeof(MYFLT));
for (i=0; i<self->chSize; i++) {
self->choice[i] = PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(tmp, i)));
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
-static PyObject *
+static PyObject *
Iter_reset(Iter *self, PyObject *arg)
{
int tmp;
@@ -6117,8 +6114,8 @@ static void
Count_generates(Count *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
- for (i=0; i<self->bufsize; i++) {
+
+ for (i=0; i<self->bufsize; i++) {
if (in[i] == 1) {
self->count = self->min;
self->started = 1;
@@ -6131,7 +6128,7 @@ Count_generates(Count *self) {
else {
self->data[i] = self->min;
}
- }
+ }
}
static void Count_postprocessing_ii(Count *self) { POST_PROCESSING_II };
@@ -6146,46 +6143,46 @@ static void Count_postprocessing_revareva(Count *self) { POST_PROCESSING_REVAREV
static void
Count_setProcMode(Count *self)
-{
+{
int muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Count_generates;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Count_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Count_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Count_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Count_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Count_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Count_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Count_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Count_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Count_postprocessing_revareva;
break;
- }
+ }
}
static void
Count_compute_next_data_frame(Count *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -6198,7 +6195,7 @@ Count_traverse(Count *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Count_clear(Count *self)
{
pyo_CLEAR
@@ -6222,35 +6219,35 @@ Count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
Count *self;
self = (Count *)type->tp_alloc(type, 0);
-
+
self->started = 0;
self->count = 0;
self->min = 0;
self->max = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Count_compute_next_data_frame);
self->mode_func_ptr = Count_setProcMode;
static char *kwlist[] = {"input", "min", "max", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|kkOO", kwlist, &inputtmp, &self->min, &self->max, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -6258,10 +6255,10 @@ Count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Count_getServer(Count* self) { GET_SERVER };
static PyObject * Count_getStream(Count* self) { GET_STREAM };
-static PyObject * Count_setMul(Count *self, PyObject *arg) { SET_MUL };
-static PyObject * Count_setAdd(Count *self, PyObject *arg) { SET_ADD };
-static PyObject * Count_setSub(Count *self, PyObject *arg) { SET_SUB };
-static PyObject * Count_setDiv(Count *self, PyObject *arg) { SET_DIV };
+static PyObject * Count_setMul(Count *self, PyObject *arg) { SET_MUL };
+static PyObject * Count_setAdd(Count *self, PyObject *arg) { SET_ADD };
+static PyObject * Count_setSub(Count *self, PyObject *arg) { SET_SUB };
+static PyObject * Count_setDiv(Count *self, PyObject *arg) { SET_DIV };
static PyObject * Count_play(Count *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Count_stop(Count *self) { STOP };
@@ -6277,25 +6274,25 @@ static PyObject * Count_inplace_div(Count *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
Count_setMin(Count *self, PyObject *arg)
-{
- if (PyLong_Check(arg) || PyInt_Check(arg))
+{
+ if (PyLong_Check(arg) || PyInt_Check(arg))
self->min = PyLong_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Count_setMax(Count *self, PyObject *arg)
-{
+{
if (arg == Py_None)
self->max = 0;
- else if (PyLong_Check(arg) || PyInt_Check(arg))
+ else if (PyLong_Check(arg) || PyInt_Check(arg))
self->max = PyLong_AsLong(arg);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Count_members[] = {
{"server", T_OBJECT_EX, offsetof(Count, server), 0, "Pyo server."},
@@ -6422,17 +6419,17 @@ NextTrig_generates(NextTrig *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = 0.0;
if (self->gate == 1 && in[i] == 1.0) {
self->data[i] = 1.0;
self->gate = 0;
}
-
+
if (in2[i] == 1 && self->gate == 0)
self->gate = 1;
- }
+ }
}
static void NextTrig_postprocessing_ii(NextTrig *self) { POST_PROCESSING_II };
@@ -6447,46 +6444,46 @@ static void NextTrig_postprocessing_revareva(NextTrig *self) { POST_PROCESSING_R
static void
NextTrig_setProcMode(NextTrig *self)
-{
+{
int muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = NextTrig_generates;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = NextTrig_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = NextTrig_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = NextTrig_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = NextTrig_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = NextTrig_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = NextTrig_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = NextTrig_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = NextTrig_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = NextTrig_postprocessing_revareva;
break;
- }
+ }
}
static void
NextTrig_compute_next_data_frame(NextTrig *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -6501,7 +6498,7 @@ NextTrig_traverse(NextTrig *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
NextTrig_clear(NextTrig *self)
{
pyo_CLEAR
@@ -6527,39 +6524,39 @@ NextTrig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *input2tmp, *input2_streamtmp, *multmp=NULL, *addtmp=NULL;
NextTrig *self;
self = (NextTrig *)type->tp_alloc(type, 0);
-
+
self->gate = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, NextTrig_compute_next_data_frame);
self->mode_func_ptr = NextTrig_setProcMode;
static char *kwlist[] = {"input", "input2", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &inputtmp, &input2tmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
Py_XDECREF(self->input2);
self->input2 = input2tmp;
input2_streamtmp = PyObject_CallMethod((PyObject *)self->input2, "_getStream", NULL);
Py_INCREF(input2_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (Stream *)input2_streamtmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -6567,10 +6564,10 @@ NextTrig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * NextTrig_getServer(NextTrig* self) { GET_SERVER };
static PyObject * NextTrig_getStream(NextTrig* self) { GET_STREAM };
-static PyObject * NextTrig_setMul(NextTrig *self, PyObject *arg) { SET_MUL };
-static PyObject * NextTrig_setAdd(NextTrig *self, PyObject *arg) { SET_ADD };
-static PyObject * NextTrig_setSub(NextTrig *self, PyObject *arg) { SET_SUB };
-static PyObject * NextTrig_setDiv(NextTrig *self, PyObject *arg) { SET_DIV };
+static PyObject * NextTrig_setMul(NextTrig *self, PyObject *arg) { SET_MUL };
+static PyObject * NextTrig_setAdd(NextTrig *self, PyObject *arg) { SET_ADD };
+static PyObject * NextTrig_setSub(NextTrig *self, PyObject *arg) { SET_SUB };
+static PyObject * NextTrig_setDiv(NextTrig *self, PyObject *arg) { SET_DIV };
static PyObject * NextTrig_play(NextTrig *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * NextTrig_stop(NextTrig *self) { STOP };
@@ -6697,7 +6694,7 @@ typedef struct {
PyObject *value;
Stream *value_stream;
MYFLT current_value;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} TrigVal;
static void
@@ -6705,11 +6702,11 @@ TrigVal_generate_i(TrigVal *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT val = PyFloat_AS_DOUBLE(self->value);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1)
self->current_value = val;
-
+
self->data[i] = self->current_value;
}
}
@@ -6719,11 +6716,11 @@ TrigVal_generate_a(TrigVal *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *val = Stream_getData((Stream *)self->value_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] == 1)
self->current_value = val[i];
-
+
self->data[i] = self->current_value;
}
}
@@ -6744,50 +6741,50 @@ TrigVal_setProcMode(TrigVal *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = TrigVal_generate_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = TrigVal_generate_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrigVal_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrigVal_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrigVal_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrigVal_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrigVal_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrigVal_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrigVal_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrigVal_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrigVal_postprocessing_revareva;
break;
- }
+ }
}
static void
TrigVal_compute_next_data_frame(TrigVal *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -6797,19 +6794,19 @@ TrigVal_traverse(TrigVal *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
- Py_VISIT(self->value);
- Py_VISIT(self->value_stream);
+ Py_VISIT(self->value);
+ Py_VISIT(self->value_stream);
return 0;
}
-static int
+static int
TrigVal_clear(TrigVal *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->value);
- Py_CLEAR(self->value_stream);
+ Py_CLEAR(self->value);
+ Py_CLEAR(self->value_stream);
return 0;
}
@@ -6828,49 +6825,49 @@ TrigVal_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *valuetmp=NULL, *multmp=NULL, *addtmp=NULL;
TrigVal *self;
self = (TrigVal *)type->tp_alloc(type, 0);
-
+
self->value = PyFloat_FromDouble(0.);
self->current_value = 0.;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TrigVal_compute_next_data_frame);
self->mode_func_ptr = TrigVal_setProcMode;
-
+
static char *kwlist[] = {"input", "value", "init", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OFOO, kwlist, &inputtmp, &valuetmp, &self->current_value, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (valuetmp) {
PyObject_CallMethod((PyObject *)self, "setValue", "O", valuetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * TrigVal_getServer(TrigVal* self) { GET_SERVER };
static PyObject * TrigVal_getStream(TrigVal* self) { GET_STREAM };
-static PyObject * TrigVal_setMul(TrigVal *self, PyObject *arg) { SET_MUL };
-static PyObject * TrigVal_setAdd(TrigVal *self, PyObject *arg) { SET_ADD };
-static PyObject * TrigVal_setSub(TrigVal *self, PyObject *arg) { SET_SUB };
-static PyObject * TrigVal_setDiv(TrigVal *self, PyObject *arg) { SET_DIV };
+static PyObject * TrigVal_setMul(TrigVal *self, PyObject *arg) { SET_MUL };
+static PyObject * TrigVal_setAdd(TrigVal *self, PyObject *arg) { SET_ADD };
+static PyObject * TrigVal_setSub(TrigVal *self, PyObject *arg) { SET_SUB };
+static PyObject * TrigVal_setDiv(TrigVal *self, PyObject *arg) { SET_DIV };
static PyObject * TrigVal_play(TrigVal *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrigVal_out(TrigVal *self, PyObject *args, PyObject *kwds) { OUT };
@@ -6889,14 +6886,14 @@ static PyObject *
TrigVal_setValue(TrigVal *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->value);
@@ -6912,12 +6909,12 @@ TrigVal_setValue(TrigVal *self, PyObject *arg)
self->value_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef TrigVal_members[] = {
{"server", T_OBJECT_EX, offsetof(TrigVal, server), 0, "Pyo server."},
@@ -7025,4 +7022,4 @@ PyTypeObject TrigValType = {
0, /* tp_init */
0, /* tp_alloc */
TrigVal_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/utilsmodule.c b/src/objects/utilsmodule.c
index fe0bf39..3e97eb8 100644
--- a/src/objects/utilsmodule.c
+++ b/src/objects/utilsmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -45,7 +45,7 @@ static void
Print_process_time(Print *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (self->currentTime >= self->time) {
self->currentTime = 0.0;
@@ -73,15 +73,15 @@ Print_process_change(Print *self) {
printf("%s : %f\n", self->message, inval);
self->lastValue = inval;
}
- }
+ }
}
static void
Print_setProcMode(Print *self)
-{
+{
if (self->method < 0 || self->method > 1)
self->method = 0;
-
+
switch (self->method) {
case 0:
self->proc_func_ptr = Print_process_time;
@@ -89,13 +89,13 @@ Print_setProcMode(Print *self)
case 1:
self->proc_func_ptr = Print_process_change;
break;
- }
+ }
}
static void
Print_compute_next_data_frame(Print *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
}
static int
@@ -107,7 +107,7 @@ Print_traverse(Print *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Print_clear(Print *self)
{
pyo_CLEAR
@@ -135,7 +135,7 @@ Print_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->method = 0;
self->time = 0.25;
self->lastValue = -99999.0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Print_compute_next_data_frame);
self->mode_func_ptr = Print_setProcMode;
@@ -144,16 +144,16 @@ Print_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->currentTime = 0.;
static char *kwlist[] = {"input", "method", "interval", "message", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_IFS, kwlist, &inputtmp, &self->method, &self->time, &self->message))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
@@ -170,14 +170,14 @@ Print_setMethod(Print *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->method = PyInt_AsLong(arg);
(*self->mode_func_ptr)(self);
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -189,13 +189,13 @@ Print_setInterval(Print *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->time = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -207,13 +207,13 @@ Print_setMessage(Print *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isString = PyString_Check(arg);
-
+
if (isString == 1) {
self->message = PyString_AsString(arg);
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -291,14 +291,14 @@ typedef struct {
MYFLT *choice;
MYFLT value;
MYFLT last_input;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
} Snap;
static MYFLT
Snap_convert(Snap *self) {
int midival;
MYFLT val;
-
+
midival = self->value;
if (self->scale == 1)
@@ -307,7 +307,7 @@ Snap_convert(Snap *self) {
val = MYPOW(1.0594630943593, midival - 60);
else
val = midival;
-
+
return val;
}
@@ -316,7 +316,7 @@ Snap_generate(Snap *self) {
int i, j, pos;
MYFLT intmp, diff, difftmp;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
if (in[i] < (self->last_input-0.001) || in[i] > (self->last_input + 0.001)) {
int oct = 0;
@@ -332,12 +332,12 @@ Snap_generate(Snap *self) {
if (difftmp < diff) {
diff = difftmp;
pos = j;
- }
+ }
}
self->value = self->choice[pos] + (self->highbound * oct);
- self->value = Snap_convert(self);
+ self->value = Snap_convert(self);
}
-
+
self->data[i] = self->value;
}
}
@@ -357,44 +357,44 @@ Snap_setProcMode(Snap *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Snap_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Snap_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Snap_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Snap_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Snap_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Snap_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Snap_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Snap_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Snap_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Snap_postprocessing_revareva;
break;
- }
+ }
}
static void
Snap_compute_next_data_frame(Snap *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -407,7 +407,7 @@ Snap_traverse(Snap *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Snap_clear(Snap *self)
{
pyo_CLEAR
@@ -432,36 +432,36 @@ Snap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *choicetmp=NULL, *multmp=NULL, *addtmp=NULL;
Snap *self;
self = (Snap *)type->tp_alloc(type, 0);
-
+
self->value = self->last_input = 0.;
self->scale = 0;
self->highbound = 12;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Snap_compute_next_data_frame);
self->mode_func_ptr = Snap_setProcMode;
static char *kwlist[] = {"input", "choice", "scale", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|iOO", kwlist, &inputtmp, &choicetmp, &self->scale, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (choicetmp) {
PyObject_CallMethod((PyObject *)self, "setChoice", "O", choicetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -471,10 +471,10 @@ Snap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Snap_getServer(Snap* self) { GET_SERVER };
static PyObject * Snap_getStream(Snap* self) { GET_STREAM };
-static PyObject * Snap_setMul(Snap *self, PyObject *arg) { SET_MUL };
-static PyObject * Snap_setAdd(Snap *self, PyObject *arg) { SET_ADD };
-static PyObject * Snap_setSub(Snap *self, PyObject *arg) { SET_SUB };
-static PyObject * Snap_setDiv(Snap *self, PyObject *arg) { SET_DIV };
+static PyObject * Snap_setMul(Snap *self, PyObject *arg) { SET_MUL };
+static PyObject * Snap_setAdd(Snap *self, PyObject *arg) { SET_ADD };
+static PyObject * Snap_setSub(Snap *self, PyObject *arg) { SET_SUB };
+static PyObject * Snap_setDiv(Snap *self, PyObject *arg) { SET_DIV };
static PyObject * Snap_play(Snap *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Snap_out(Snap *self, PyObject *args, PyObject *kwds) { OUT };
@@ -495,47 +495,47 @@ Snap_setChoice(Snap *self, PyObject *arg)
int i, oct;
MYFLT max;
PyObject *tmp;
-
+
if (! PyList_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "The choice attribute must be a list.");
Py_INCREF(Py_None);
return Py_None;
}
-
+
tmp = arg;
self->chSize = PyList_Size(tmp);
self->choice = (MYFLT *)realloc(self->choice, self->chSize * sizeof(MYFLT));
-
+
for (i=0; i<self->chSize; i++) {
self->choice[i] = PyFloat_AS_DOUBLE(PyNumber_Float(PyList_GET_ITEM(tmp, i)));
}
-
+
max = self->choice[self->chSize-1];
-
+
oct = 12;
while (max >= oct) {
oct += 12;
}
-
+
self->highbound = oct;
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Snap_setScale(Snap *self, PyObject *arg)
-{
+{
int tmp;
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyInt_Check(arg);
-
+
if (isNumber == 1) {
tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp <= 2)
@@ -543,10 +543,10 @@ Snap_setScale(Snap *self, PyObject *arg)
else
printf("scale attribute must be an integer {0, 1, 2}\n");
}
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Snap_members[] = {
{"server", T_OBJECT_EX, offsetof(Snap, server), 0, "Pyo server."},
@@ -667,7 +667,7 @@ typedef struct {
Stream *input2_stream;
PyObject *interp;
Stream *interp_stream;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} Interp;
static void
@@ -682,8 +682,8 @@ Interp_filters_i(Interp *self) {
inter = 0.0;
else if (inter > 1.0)
inter = 1.0;
-
- amp2 = 1.0 - inter;
+
+ amp2 = 1.0 - inter;
for (i=0; i<self->bufsize; i++) {
self->data[i] = in[i] * amp2 + in2[i] * inter;
}
@@ -696,15 +696,15 @@ Interp_filters_a(Interp *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *in2 = Stream_getData((Stream *)self->input2_stream);
MYFLT *inter = Stream_getData((Stream *)self->interp_stream);
-
+
for (i=0; i<self->bufsize; i++) {
amp1 = inter[i];
if (amp1 < 0.0)
amp1 = 0.0;
else if (amp1 > 1.0)
amp1 = 1.0;
-
- amp2 = 1.0 - amp1;
+
+ amp2 = 1.0 - amp1;
self->data[i] = in[i] * amp2 + in2[i] * amp1;
}
}
@@ -725,50 +725,50 @@ Interp_setProcMode(Interp *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Interp_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Interp_filters_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Interp_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Interp_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Interp_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Interp_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Interp_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Interp_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Interp_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Interp_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Interp_postprocessing_revareva;
break;
- }
+ }
}
static void
Interp_compute_next_data_frame(Interp *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -780,12 +780,12 @@ Interp_traverse(Interp *self, visitproc visit, void *arg)
Py_VISIT(self->input_stream);
Py_VISIT(self->input2);
Py_VISIT(self->input2_stream);
- Py_VISIT(self->interp);
- Py_VISIT(self->interp_stream);
+ Py_VISIT(self->interp);
+ Py_VISIT(self->interp_stream);
return 0;
}
-static int
+static int
Interp_clear(Interp *self)
{
pyo_CLEAR
@@ -793,8 +793,8 @@ Interp_clear(Interp *self)
Py_CLEAR(self->input_stream);
Py_CLEAR(self->input2);
Py_CLEAR(self->input2_stream);
- Py_CLEAR(self->interp);
- Py_CLEAR(self->interp_stream);
+ Py_CLEAR(self->interp);
+ Py_CLEAR(self->interp_stream);
return 0;
}
@@ -813,21 +813,21 @@ Interp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *input2tmp, *input2_streamtmp, *interptmp=NULL, *multmp=NULL, *addtmp=NULL;
Interp *self;
self = (Interp *)type->tp_alloc(type, 0);
-
+
self->interp = PyFloat_FromDouble(.5);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Interp_compute_next_data_frame);
self->mode_func_ptr = Interp_setProcMode;
static char *kwlist[] = {"input", "input2", "interp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOO", kwlist, &inputtmp, &input2tmp, &interptmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
Py_XDECREF(self->input2);
@@ -836,21 +836,21 @@ Interp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_INCREF(input2_streamtmp);
Py_XDECREF(self->input2_stream);
self->input2_stream = (Stream *)input2_streamtmp;
-
+
if (interptmp) {
PyObject_CallMethod((PyObject *)self, "setInterp", "O", interptmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -858,10 +858,10 @@ Interp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Interp_getServer(Interp* self) { GET_SERVER };
static PyObject * Interp_getStream(Interp* self) { GET_STREAM };
-static PyObject * Interp_setMul(Interp *self, PyObject *arg) { SET_MUL };
-static PyObject * Interp_setAdd(Interp *self, PyObject *arg) { SET_ADD };
-static PyObject * Interp_setSub(Interp *self, PyObject *arg) { SET_SUB };
-static PyObject * Interp_setDiv(Interp *self, PyObject *arg) { SET_DIV };
+static PyObject * Interp_setMul(Interp *self, PyObject *arg) { SET_MUL };
+static PyObject * Interp_setAdd(Interp *self, PyObject *arg) { SET_ADD };
+static PyObject * Interp_setSub(Interp *self, PyObject *arg) { SET_SUB };
+static PyObject * Interp_setDiv(Interp *self, PyObject *arg) { SET_DIV };
static PyObject * Interp_play(Interp *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Interp_out(Interp *self, PyObject *args, PyObject *kwds) { OUT };
@@ -880,14 +880,14 @@ static PyObject *
Interp_setInterp(Interp *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->interp);
@@ -903,9 +903,9 @@ Interp_setInterp(Interp *self, PyObject *arg)
self->interp_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1032,7 +1032,7 @@ typedef struct {
Stream *value_stream;
MYFLT currentValue;
int flag;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} SampHold;
static void
@@ -1049,7 +1049,7 @@ SampHold_filters_i(SampHold *self) {
if (self->flag == 1) {
self->currentValue = in[i];
self->flag = 0;
- }
+ }
}
else
self->flag = 1;
@@ -1064,7 +1064,7 @@ SampHold_filters_a(SampHold *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *ctrlsig = Stream_getData((Stream *)self->controlsig_stream);
MYFLT *valsig = Stream_getData((Stream *)self->value_stream);
-
+
for (i=0; i<self->bufsize; i++) {
ctrl = ctrlsig[i];
val = valsig[i];
@@ -1072,7 +1072,7 @@ SampHold_filters_a(SampHold *self) {
if (self->flag == 1) {
self->currentValue = in[i];
self->flag = 0;
- }
+ }
}
else
self->flag = 1;
@@ -1096,50 +1096,50 @@ SampHold_setProcMode(SampHold *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = SampHold_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = SampHold_filters_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = SampHold_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = SampHold_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = SampHold_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = SampHold_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = SampHold_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = SampHold_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = SampHold_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = SampHold_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = SampHold_postprocessing_revareva;
break;
- }
+ }
}
static void
SampHold_compute_next_data_frame(SampHold *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1151,12 +1151,12 @@ SampHold_traverse(SampHold *self, visitproc visit, void *arg)
Py_VISIT(self->input_stream);
Py_VISIT(self->controlsig);
Py_VISIT(self->controlsig_stream);
- Py_VISIT(self->value);
- Py_VISIT(self->value_stream);
+ Py_VISIT(self->value);
+ Py_VISIT(self->value_stream);
return 0;
}
-static int
+static int
SampHold_clear(SampHold *self)
{
pyo_CLEAR
@@ -1164,8 +1164,8 @@ SampHold_clear(SampHold *self)
Py_CLEAR(self->input_stream);
Py_CLEAR(self->controlsig);
Py_CLEAR(self->controlsig_stream);
- Py_CLEAR(self->value);
- Py_CLEAR(self->value_stream);
+ Py_CLEAR(self->value);
+ Py_CLEAR(self->value_stream);
return 0;
}
@@ -1184,46 +1184,46 @@ SampHold_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *controlsigtmp, *controlsig_streamtmp, *valuetmp=NULL, *multmp=NULL, *addtmp=NULL;
SampHold *self;
self = (SampHold *)type->tp_alloc(type, 0);
-
+
self->value = PyFloat_FromDouble(0.0);
self->currentValue = 0.0;
self->flag = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SampHold_compute_next_data_frame);
self->mode_func_ptr = SampHold_setProcMode;
static char *kwlist[] = {"input", "controlsig", "value", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOO", kwlist, &inputtmp, &controlsigtmp, &valuetmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
Py_XDECREF(self->controlsig);
self->controlsig = controlsigtmp;
controlsig_streamtmp = PyObject_CallMethod((PyObject *)self->controlsig, "_getStream", NULL);
Py_INCREF(controlsig_streamtmp);
Py_XDECREF(self->controlsig_stream);
self->controlsig_stream = (Stream *)controlsig_streamtmp;
-
+
if (valuetmp) {
PyObject_CallMethod((PyObject *)self, "setValue", "O", valuetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1231,10 +1231,10 @@ SampHold_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * SampHold_getServer(SampHold* self) { GET_SERVER };
static PyObject * SampHold_getStream(SampHold* self) { GET_STREAM };
-static PyObject * SampHold_setMul(SampHold *self, PyObject *arg) { SET_MUL };
-static PyObject * SampHold_setAdd(SampHold *self, PyObject *arg) { SET_ADD };
-static PyObject * SampHold_setSub(SampHold *self, PyObject *arg) { SET_SUB };
-static PyObject * SampHold_setDiv(SampHold *self, PyObject *arg) { SET_DIV };
+static PyObject * SampHold_setMul(SampHold *self, PyObject *arg) { SET_MUL };
+static PyObject * SampHold_setAdd(SampHold *self, PyObject *arg) { SET_ADD };
+static PyObject * SampHold_setSub(SampHold *self, PyObject *arg) { SET_SUB };
+static PyObject * SampHold_setDiv(SampHold *self, PyObject *arg) { SET_DIV };
static PyObject * SampHold_play(SampHold *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * SampHold_out(SampHold *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1253,14 +1253,14 @@ static PyObject *
SampHold_setValue(SampHold *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->value);
@@ -1276,9 +1276,9 @@ SampHold_setValue(SampHold *self, PyObject *arg)
self->value_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1405,7 +1405,7 @@ typedef struct {
Stream *value_stream;
MYFLT currentValue;
int flag;
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} TrackHold;
static void
@@ -1422,7 +1422,7 @@ TrackHold_filters_i(TrackHold *self) {
if (self->flag == 1) {
self->currentValue = in[i];
self->flag = 0;
- }
+ }
}
else {
self->currentValue = in[i];
@@ -1439,7 +1439,7 @@ TrackHold_filters_a(TrackHold *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *ctrlsig = Stream_getData((Stream *)self->controlsig_stream);
MYFLT *valsig = Stream_getData((Stream *)self->value_stream);
-
+
for (i=0; i<self->bufsize; i++) {
ctrl = ctrlsig[i];
val = valsig[i];
@@ -1447,7 +1447,7 @@ TrackHold_filters_a(TrackHold *self) {
if (self->flag == 1) {
self->currentValue = in[i];
self->flag = 0;
- }
+ }
}
else {
self->currentValue = in[i];
@@ -1473,50 +1473,50 @@ TrackHold_setProcMode(TrackHold *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = TrackHold_filters_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = TrackHold_filters_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TrackHold_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TrackHold_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TrackHold_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TrackHold_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TrackHold_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TrackHold_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TrackHold_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TrackHold_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TrackHold_postprocessing_revareva;
break;
- }
+ }
}
static void
TrackHold_compute_next_data_frame(TrackHold *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1528,12 +1528,12 @@ TrackHold_traverse(TrackHold *self, visitproc visit, void *arg)
Py_VISIT(self->input_stream);
Py_VISIT(self->controlsig);
Py_VISIT(self->controlsig_stream);
- Py_VISIT(self->value);
- Py_VISIT(self->value_stream);
+ Py_VISIT(self->value);
+ Py_VISIT(self->value_stream);
return 0;
}
-static int
+static int
TrackHold_clear(TrackHold *self)
{
pyo_CLEAR
@@ -1541,8 +1541,8 @@ TrackHold_clear(TrackHold *self)
Py_CLEAR(self->input_stream);
Py_CLEAR(self->controlsig);
Py_CLEAR(self->controlsig_stream);
- Py_CLEAR(self->value);
- Py_CLEAR(self->value_stream);
+ Py_CLEAR(self->value);
+ Py_CLEAR(self->value_stream);
return 0;
}
@@ -1561,46 +1561,46 @@ TrackHold_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *controlsigtmp, *controlsig_streamtmp, *valuetmp=NULL, *multmp=NULL, *addtmp=NULL;
TrackHold *self;
self = (TrackHold *)type->tp_alloc(type, 0);
-
+
self->value = PyFloat_FromDouble(0.0);
self->currentValue = 0.0;
self->flag = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TrackHold_compute_next_data_frame);
self->mode_func_ptr = TrackHold_setProcMode;
static char *kwlist[] = {"input", "controlsig", "value", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOO", kwlist, &inputtmp, &controlsigtmp, &valuetmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
Py_XDECREF(self->controlsig);
self->controlsig = controlsigtmp;
controlsig_streamtmp = PyObject_CallMethod((PyObject *)self->controlsig, "_getStream", NULL);
Py_INCREF(controlsig_streamtmp);
Py_XDECREF(self->controlsig_stream);
self->controlsig_stream = (Stream *)controlsig_streamtmp;
-
+
if (valuetmp) {
PyObject_CallMethod((PyObject *)self, "setValue", "O", valuetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1608,10 +1608,10 @@ TrackHold_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * TrackHold_getServer(TrackHold* self) { GET_SERVER };
static PyObject * TrackHold_getStream(TrackHold* self) { GET_STREAM };
-static PyObject * TrackHold_setMul(TrackHold *self, PyObject *arg) { SET_MUL };
-static PyObject * TrackHold_setAdd(TrackHold *self, PyObject *arg) { SET_ADD };
-static PyObject * TrackHold_setSub(TrackHold *self, PyObject *arg) { SET_SUB };
-static PyObject * TrackHold_setDiv(TrackHold *self, PyObject *arg) { SET_DIV };
+static PyObject * TrackHold_setMul(TrackHold *self, PyObject *arg) { SET_MUL };
+static PyObject * TrackHold_setAdd(TrackHold *self, PyObject *arg) { SET_ADD };
+static PyObject * TrackHold_setSub(TrackHold *self, PyObject *arg) { SET_SUB };
+static PyObject * TrackHold_setDiv(TrackHold *self, PyObject *arg) { SET_DIV };
static PyObject * TrackHold_play(TrackHold *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TrackHold_out(TrackHold *self, PyObject *args, PyObject *kwds) { OUT };
@@ -1630,14 +1630,14 @@ static PyObject *
TrackHold_setValue(TrackHold *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->value);
@@ -1653,9 +1653,9 @@ TrackHold_setValue(TrackHold *self, PyObject *arg)
self->value_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -1779,7 +1779,7 @@ typedef struct {
PyObject *comp;
Stream *comp_stream;
MYFLT (*compare_func_ptr)(MYFLT, MYFLT); // true = 1.0, false = 0.0
- int modebuffer[3]; // need at least 2 slots for mul & add
+ int modebuffer[3]; // need at least 2 slots for mul & add
} Compare;
static MYFLT
@@ -1823,7 +1823,7 @@ Compare_process_i(Compare *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT comp = PyFloat_AS_DOUBLE(self->comp);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = (*self->compare_func_ptr)(in[i], comp);
}
@@ -1834,7 +1834,7 @@ Compare_process_a(Compare *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *comp = Stream_getData((Stream *)self->comp_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = (*self->compare_func_ptr)(in[i], comp[i]);
}
@@ -1856,50 +1856,50 @@ Compare_setProcMode(Compare *self)
int procmode, muladdmode;
procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Compare_process_i;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Compare_process_a;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Compare_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Compare_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Compare_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Compare_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Compare_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Compare_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Compare_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Compare_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Compare_postprocessing_revareva;
break;
- }
+ }
}
static void
Compare_compute_next_data_frame(Compare *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -1914,7 +1914,7 @@ Compare_traverse(Compare *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Compare_clear(Compare *self)
{
pyo_CLEAR
@@ -1940,42 +1940,42 @@ Compare_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *comptmp, *modetmp=NULL, *multmp=NULL, *addtmp=NULL;
Compare *self;
self = (Compare *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
self->compare_func_ptr = Compare_lt;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Compare_compute_next_data_frame);
self->mode_func_ptr = Compare_setProcMode;
static char *kwlist[] = {"input", "comp", "mode", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOO", kwlist, &inputtmp, &comptmp, &modetmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (comptmp) {
PyObject_CallMethod((PyObject *)self, "setComp", "O", comptmp);
}
-
+
if (modetmp) {
PyObject_CallMethod((PyObject *)self, "setMode", "O", modetmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1983,10 +1983,10 @@ Compare_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Compare_getServer(Compare* self) { GET_SERVER };
static PyObject * Compare_getStream(Compare* self) { GET_STREAM };
-static PyObject * Compare_setMul(Compare *self, PyObject *arg) { SET_MUL };
-static PyObject * Compare_setAdd(Compare *self, PyObject *arg) { SET_ADD };
-static PyObject * Compare_setSub(Compare *self, PyObject *arg) { SET_SUB };
-static PyObject * Compare_setDiv(Compare *self, PyObject *arg) { SET_DIV };
+static PyObject * Compare_setMul(Compare *self, PyObject *arg) { SET_MUL };
+static PyObject * Compare_setAdd(Compare *self, PyObject *arg) { SET_ADD };
+static PyObject * Compare_setSub(Compare *self, PyObject *arg) { SET_SUB };
+static PyObject * Compare_setDiv(Compare *self, PyObject *arg) { SET_DIV };
static PyObject * Compare_play(Compare *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Compare_stop(Compare *self) { STOP };
@@ -2004,13 +2004,13 @@ static PyObject *
Compare_setComp(Compare *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_RETURN_NONE;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_XDECREF(self->comp);
@@ -2026,27 +2026,27 @@ Compare_setComp(Compare *self, PyObject *arg)
self->comp_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
Compare_setMode(Compare *self, PyObject *arg)
-{
+{
if (arg == NULL) {
Py_RETURN_NONE;
}
-
+
if (! PyInt_Check(arg)) {
printf("mode should be a comparison operator as a string\n");
Py_RETURN_NONE;
}
int tmp = PyInt_AsLong(arg);
-
+
if (tmp == 0)
self->compare_func_ptr = Compare_lt;
else if (tmp == 1)
@@ -2059,7 +2059,7 @@ Compare_setMode(Compare *self, PyObject *arg)
self->compare_func_ptr = Compare_eq;
else if (tmp == 5)
self->compare_func_ptr = Compare_neq;
-
+
Py_RETURN_NONE;
}
@@ -2193,7 +2193,7 @@ Between_transform_ii(Between *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
if(val >= mi && val < ma)
@@ -2210,7 +2210,7 @@ Between_transform_ai(Between *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT ma = PyFloat_AS_DOUBLE(self->max);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
if(val >= mi[i] && val < ma)
@@ -2227,7 +2227,7 @@ Between_transform_ia(Between *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT mi = PyFloat_AS_DOUBLE(self->min);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
if(val >= mi && val < ma[i])
@@ -2244,7 +2244,7 @@ Between_transform_aa(Between *self) {
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *mi = Stream_getData((Stream *)self->min_stream);
MYFLT *ma = Stream_getData((Stream *)self->max_stream);
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i];
if(val >= mi[i] && val < ma[i])
@@ -2270,56 +2270,56 @@ Between_setProcMode(Between *self)
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = Between_transform_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = Between_transform_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = Between_transform_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = Between_transform_aa;
break;
- }
+ }
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Between_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Between_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Between_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Between_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Between_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Between_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Between_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Between_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Between_postprocessing_revareva;
break;
- }
+ }
}
static void
Between_compute_next_data_frame(Between *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2328,24 +2328,24 @@ Between_traverse(Between *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->min);
- Py_VISIT(self->min_stream);
- Py_VISIT(self->max);
- Py_VISIT(self->max_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->min);
+ Py_VISIT(self->min_stream);
+ Py_VISIT(self->max);
+ Py_VISIT(self->max_stream);
return 0;
}
-static int
+static int
Between_clear(Between *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
- Py_CLEAR(self->min);
- Py_CLEAR(self->min_stream);
- Py_CLEAR(self->max);
- Py_CLEAR(self->max_stream);
+ Py_CLEAR(self->min);
+ Py_CLEAR(self->min_stream);
+ Py_CLEAR(self->max);
+ Py_CLEAR(self->max_stream);
return 0;
}
@@ -2364,54 +2364,54 @@ Between_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *mintmp=NULL, *maxtmp=NULL, *multmp=NULL, *addtmp=NULL;
Between *self;
self = (Between *)type->tp_alloc(type, 0);
-
+
self->min = PyFloat_FromDouble(0.0);
self->max = PyFloat_FromDouble(1.0);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Between_compute_next_data_frame);
self->mode_func_ptr = Between_setProcMode;
static char *kwlist[] = {"input", "min", "max", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &inputtmp, &mintmp, &maxtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (mintmp) {
PyObject_CallMethod((PyObject *)self, "setMin", "O", mintmp);
}
-
+
if (maxtmp) {
PyObject_CallMethod((PyObject *)self, "setMax", "O", maxtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
-
+
return (PyObject *)self;
}
static PyObject * Between_getServer(Between* self) { GET_SERVER };
static PyObject * Between_getStream(Between* self) { GET_STREAM };
-static PyObject * Between_setMul(Between *self, PyObject *arg) { SET_MUL };
-static PyObject * Between_setAdd(Between *self, PyObject *arg) { SET_ADD };
-static PyObject * Between_setSub(Between *self, PyObject *arg) { SET_SUB };
-static PyObject * Between_setDiv(Between *self, PyObject *arg) { SET_DIV };
+static PyObject * Between_setMul(Between *self, PyObject *arg) { SET_MUL };
+static PyObject * Between_setAdd(Between *self, PyObject *arg) { SET_ADD };
+static PyObject * Between_setSub(Between *self, PyObject *arg) { SET_SUB };
+static PyObject * Between_setDiv(Between *self, PyObject *arg) { SET_DIV };
static PyObject * Between_play(Between *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Between_out(Between *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2430,14 +2430,14 @@ static PyObject *
Between_setMin(Between *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->min);
@@ -2453,25 +2453,25 @@ Between_setMin(Between *self, PyObject *arg)
self->min_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Between_setMax(Between *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->max);
@@ -2487,12 +2487,12 @@ Between_setMax(Between *self, PyObject *arg)
self->max_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Between_members[] = {
{"server", T_OBJECT_EX, offsetof(Between, server), 0, "Pyo server."},
@@ -2618,14 +2618,14 @@ typedef struct {
pyo_audio_HEAD
PyObject *input;
Stream *input_stream;
- int modebuffer[2]; // need at least 2 slots for mul & add
+ int modebuffer[2]; // need at least 2 slots for mul & add
} Denorm;
static void
Denorm_filters(Denorm *self) {
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
self->data[i] = in[i] + DENORM_RAND;
}
@@ -2646,44 +2646,44 @@ Denorm_setProcMode(Denorm *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Denorm_filters;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Denorm_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Denorm_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Denorm_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Denorm_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Denorm_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Denorm_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Denorm_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Denorm_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Denorm_postprocessing_revareva;
break;
- }
+ }
}
static void
Denorm_compute_next_data_frame(Denorm *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2696,7 +2696,7 @@ Denorm_traverse(Denorm *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Denorm_clear(Denorm *self)
{
pyo_CLEAR
@@ -2720,31 +2720,31 @@ Denorm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
Denorm *self;
self = (Denorm *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Denorm_compute_next_data_frame);
self->mode_func_ptr = Denorm_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
Server_generateSeed((Server *)self->server, DENORM_ID);
(*self->mode_func_ptr)(self);
@@ -2754,10 +2754,10 @@ Denorm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Denorm_getServer(Denorm* self) { GET_SERVER };
static PyObject * Denorm_getStream(Denorm* self) { GET_STREAM };
-static PyObject * Denorm_setMul(Denorm *self, PyObject *arg) { SET_MUL };
-static PyObject * Denorm_setAdd(Denorm *self, PyObject *arg) { SET_ADD };
-static PyObject * Denorm_setSub(Denorm *self, PyObject *arg) { SET_SUB };
-static PyObject * Denorm_setDiv(Denorm *self, PyObject *arg) { SET_DIV };
+static PyObject * Denorm_setMul(Denorm *self, PyObject *arg) { SET_MUL };
+static PyObject * Denorm_setAdd(Denorm *self, PyObject *arg) { SET_ADD };
+static PyObject * Denorm_setSub(Denorm *self, PyObject *arg) { SET_SUB };
+static PyObject * Denorm_setDiv(Denorm *self, PyObject *arg) { SET_DIV };
static PyObject * Denorm_play(Denorm *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Denorm_out(Denorm *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2895,7 +2895,7 @@ DBToA_process(DBToA *self) {
int i;
MYFLT db;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
db = in[i];
if (db <= -120.0) {
@@ -2926,44 +2926,44 @@ DBToA_setProcMode(DBToA *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = DBToA_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = DBToA_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = DBToA_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = DBToA_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = DBToA_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = DBToA_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = DBToA_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = DBToA_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = DBToA_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = DBToA_postprocessing_revareva;
break;
- }
+ }
}
static void
DBToA_compute_next_data_frame(DBToA *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -2976,7 +2976,7 @@ DBToA_traverse(DBToA *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
DBToA_clear(DBToA *self)
{
pyo_CLEAR
@@ -3000,33 +3000,33 @@ DBToA_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
DBToA *self;
self = (DBToA *)type->tp_alloc(type, 0);
-
+
self->lastdb = -120.0;
self->currentamp = MYPOW(10.0, self->lastdb * 0.05);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, DBToA_compute_next_data_frame);
self->mode_func_ptr = DBToA_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3034,10 +3034,10 @@ DBToA_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * DBToA_getServer(DBToA* self) { GET_SERVER };
static PyObject * DBToA_getStream(DBToA* self) { GET_STREAM };
-static PyObject * DBToA_setMul(DBToA *self, PyObject *arg) { SET_MUL };
-static PyObject * DBToA_setAdd(DBToA *self, PyObject *arg) { SET_ADD };
-static PyObject * DBToA_setSub(DBToA *self, PyObject *arg) { SET_SUB };
-static PyObject * DBToA_setDiv(DBToA *self, PyObject *arg) { SET_DIV };
+static PyObject * DBToA_setMul(DBToA *self, PyObject *arg) { SET_MUL };
+static PyObject * DBToA_setAdd(DBToA *self, PyObject *arg) { SET_ADD };
+static PyObject * DBToA_setSub(DBToA *self, PyObject *arg) { SET_SUB };
+static PyObject * DBToA_setDiv(DBToA *self, PyObject *arg) { SET_DIV };
static PyObject * DBToA_play(DBToA *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * DBToA_out(DBToA *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3175,7 +3175,7 @@ AToDB_process(AToDB *self) {
int i;
MYFLT amp;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
amp = in[i];
if (amp <= 0.000001) {
@@ -3206,44 +3206,44 @@ AToDB_setProcMode(AToDB *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = AToDB_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = AToDB_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = AToDB_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = AToDB_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = AToDB_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = AToDB_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = AToDB_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = AToDB_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = AToDB_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = AToDB_postprocessing_revareva;
break;
- }
+ }
}
static void
AToDB_compute_next_data_frame(AToDB *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3256,7 +3256,7 @@ AToDB_traverse(AToDB *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
AToDB_clear(AToDB *self)
{
pyo_CLEAR
@@ -3280,33 +3280,33 @@ AToDB_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
AToDB *self;
self = (AToDB *)type->tp_alloc(type, 0);
-
+
self->lastamp = 0.000001;
self->currentdb = 20.0 * MYLOG10(self->lastamp);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, AToDB_compute_next_data_frame);
self->mode_func_ptr = AToDB_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3314,10 +3314,10 @@ AToDB_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * AToDB_getServer(AToDB* self) { GET_SERVER };
static PyObject * AToDB_getStream(AToDB* self) { GET_STREAM };
-static PyObject * AToDB_setMul(AToDB *self, PyObject *arg) { SET_MUL };
-static PyObject * AToDB_setAdd(AToDB *self, PyObject *arg) { SET_ADD };
-static PyObject * AToDB_setSub(AToDB *self, PyObject *arg) { SET_SUB };
-static PyObject * AToDB_setDiv(AToDB *self, PyObject *arg) { SET_DIV };
+static PyObject * AToDB_setMul(AToDB *self, PyObject *arg) { SET_MUL };
+static PyObject * AToDB_setAdd(AToDB *self, PyObject *arg) { SET_ADD };
+static PyObject * AToDB_setSub(AToDB *self, PyObject *arg) { SET_SUB };
+static PyObject * AToDB_setDiv(AToDB *self, PyObject *arg) { SET_DIV };
static PyObject * AToDB_play(AToDB *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * AToDB_out(AToDB *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3455,7 +3455,7 @@ typedef struct {
Stream *outmax_stream;
PyObject *exp;
Stream *exp_stream;
- int modebuffer[7]; // need at least 2 slots for mul & add
+ int modebuffer[7]; // need at least 2 slots for mul & add
} Scale;
static MYFLT
@@ -3474,7 +3474,7 @@ Scale_generate(Scale *self) {
MYFLT tmp, inrange, outrange, normin;
MYFLT inmin, inmax, outmin, outmax, exp;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (self->modebuffer[2] == 0)
inmin = PyFloat_AS_DOUBLE(self->inmin);
else
@@ -3483,7 +3483,7 @@ Scale_generate(Scale *self) {
inmax = PyFloat_AS_DOUBLE(self->inmax);
else
inmax = Stream_getData((Stream *)self->inmax_stream)[0];
-
+
if (inmin < inmax) {
inrev = 0;
}
@@ -3503,7 +3503,7 @@ Scale_generate(Scale *self) {
outmax = PyFloat_AS_DOUBLE(self->outmax);
else
outmax = Stream_getData((Stream *)self->outmax_stream)[0];
-
+
if (outmin < outmax) {
outrev = 0;
}
@@ -3514,7 +3514,7 @@ Scale_generate(Scale *self) {
outrev = 1;
}
outrange = outmax - outmin;
-
+
if (self->modebuffer[6] == 0)
exp = PyFloat_AS_DOUBLE(self->exp);
else
@@ -3534,7 +3534,7 @@ Scale_generate(Scale *self) {
for (i=0; i<self->bufsize; i++) {
normin = (_scale_clip(in[i], inmin, inmax) - inmin) / inrange;
self->data[i] = normin * outrange + outmin;
- }
+ }
}
else if (inrev == 1 && outrev == 0) {
for (i=0; i<self->bufsize; i++) {
@@ -3561,7 +3561,7 @@ Scale_generate(Scale *self) {
for (i=0; i<self->bufsize; i++) {
normin = MYPOW((_scale_clip(in[i], inmin, inmax) - inmin) / inrange, exp);
self->data[i] = normin * outrange + outmin;
- }
+ }
}
else if (inrev == 1 && outrev == 0) {
for (i=0; i<self->bufsize; i++) {
@@ -3599,44 +3599,44 @@ Scale_setProcMode(Scale *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = Scale_generate;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = Scale_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = Scale_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = Scale_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = Scale_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = Scale_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = Scale_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = Scale_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = Scale_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = Scale_postprocessing_revareva;
break;
- }
+ }
}
static void
Scale_compute_next_data_frame(Scale *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -3659,7 +3659,7 @@ Scale_traverse(Scale *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
Scale_clear(Scale *self)
{
pyo_CLEAR
@@ -3693,7 +3693,7 @@ Scale_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *inmintmp=NULL, *inmaxtmp=NULL, *outmintmp=NULL, *outmaxtmp=NULL, *exptmp=NULL, *multmp=NULL, *addtmp=NULL;
Scale *self;
self = (Scale *)type->tp_alloc(type, 0);
-
+
self->inmin = PyFloat_FromDouble(0.0);
self->inmax = PyFloat_FromDouble(1.0);
self->outmin = PyFloat_FromDouble(0.0);
@@ -3706,18 +3706,18 @@ Scale_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[4] = 0;
self->modebuffer[5] = 0;
self->modebuffer[6] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Scale_compute_next_data_frame);
self->mode_func_ptr = Scale_setProcMode;
static char *kwlist[] = {"input", "inmin", "inmax", "outmin", "outmax", "exp", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOOOO", kwlist, &inputtmp, &inmintmp, &inmaxtmp, &outmintmp, &outmaxtmp, &exptmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (inmintmp) {
PyObject_CallMethod((PyObject *)self, "setInMin", "O", inmintmp);
}
@@ -3737,17 +3737,17 @@ Scale_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (exptmp) {
PyObject_CallMethod((PyObject *)self, "setExp", "O", exptmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -3755,10 +3755,10 @@ Scale_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Scale_getServer(Scale* self) { GET_SERVER };
static PyObject * Scale_getStream(Scale* self) { GET_STREAM };
-static PyObject * Scale_setMul(Scale *self, PyObject *arg) { SET_MUL };
-static PyObject * Scale_setAdd(Scale *self, PyObject *arg) { SET_ADD };
-static PyObject * Scale_setSub(Scale *self, PyObject *arg) { SET_SUB };
-static PyObject * Scale_setDiv(Scale *self, PyObject *arg) { SET_DIV };
+static PyObject * Scale_setMul(Scale *self, PyObject *arg) { SET_MUL };
+static PyObject * Scale_setAdd(Scale *self, PyObject *arg) { SET_ADD };
+static PyObject * Scale_setSub(Scale *self, PyObject *arg) { SET_SUB };
+static PyObject * Scale_setDiv(Scale *self, PyObject *arg) { SET_DIV };
static PyObject * Scale_play(Scale *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * Scale_out(Scale *self, PyObject *args, PyObject *kwds) { OUT };
@@ -3777,14 +3777,14 @@ static PyObject *
Scale_setInMin(Scale *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->inmin);
@@ -3800,25 +3800,25 @@ Scale_setInMin(Scale *self, PyObject *arg)
self->inmin_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Scale_setInMax(Scale *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->inmax);
@@ -3834,25 +3834,25 @@ Scale_setInMax(Scale *self, PyObject *arg)
self->inmax_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Scale_setOutMin(Scale *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->outmin);
@@ -3868,25 +3868,25 @@ Scale_setOutMin(Scale *self, PyObject *arg)
self->outmin_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Scale_setOutMax(Scale *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->outmax);
@@ -3902,25 +3902,25 @@ Scale_setOutMax(Scale *self, PyObject *arg)
self->outmax_stream = (Stream *)streamtmp;
self->modebuffer[5] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
Scale_setExp(Scale *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->exp);
@@ -3936,12 +3936,12 @@ Scale_setExp(Scale *self, PyObject *arg)
self->exp_stream = (Stream *)streamtmp;
self->modebuffer[6] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef Scale_members[] = {
{"server", T_OBJECT_EX, offsetof(Scale, server), 0, "Pyo server."},
@@ -4071,7 +4071,7 @@ CentsToTranspo_process(CentsToTranspo *self) {
int i;
MYFLT cents;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
cents = in[i];
if (cents != self->lastcents) {
@@ -4098,44 +4098,44 @@ CentsToTranspo_setProcMode(CentsToTranspo *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = CentsToTranspo_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = CentsToTranspo_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = CentsToTranspo_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = CentsToTranspo_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = CentsToTranspo_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = CentsToTranspo_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = CentsToTranspo_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = CentsToTranspo_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = CentsToTranspo_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = CentsToTranspo_postprocessing_revareva;
break;
- }
+ }
}
static void
CentsToTranspo_compute_next_data_frame(CentsToTranspo *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4148,7 +4148,7 @@ CentsToTranspo_traverse(CentsToTranspo *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
CentsToTranspo_clear(CentsToTranspo *self)
{
pyo_CLEAR
@@ -4172,33 +4172,33 @@ CentsToTranspo_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
CentsToTranspo *self;
self = (CentsToTranspo *)type->tp_alloc(type, 0);
-
+
self->lastcents = 0.0;
self->curtranspo = 1.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, CentsToTranspo_compute_next_data_frame);
self->mode_func_ptr = CentsToTranspo_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -4206,10 +4206,10 @@ CentsToTranspo_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * CentsToTranspo_getServer(CentsToTranspo* self) { GET_SERVER };
static PyObject * CentsToTranspo_getStream(CentsToTranspo* self) { GET_STREAM };
-static PyObject * CentsToTranspo_setMul(CentsToTranspo *self, PyObject *arg) { SET_MUL };
-static PyObject * CentsToTranspo_setAdd(CentsToTranspo *self, PyObject *arg) { SET_ADD };
-static PyObject * CentsToTranspo_setSub(CentsToTranspo *self, PyObject *arg) { SET_SUB };
-static PyObject * CentsToTranspo_setDiv(CentsToTranspo *self, PyObject *arg) { SET_DIV };
+static PyObject * CentsToTranspo_setMul(CentsToTranspo *self, PyObject *arg) { SET_MUL };
+static PyObject * CentsToTranspo_setAdd(CentsToTranspo *self, PyObject *arg) { SET_ADD };
+static PyObject * CentsToTranspo_setSub(CentsToTranspo *self, PyObject *arg) { SET_SUB };
+static PyObject * CentsToTranspo_setDiv(CentsToTranspo *self, PyObject *arg) { SET_DIV };
static PyObject * CentsToTranspo_play(CentsToTranspo *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * CentsToTranspo_out(CentsToTranspo *self, PyObject *args, PyObject *kwds) { OUT };
@@ -4347,7 +4347,7 @@ TranspoToCents_process(TranspoToCents *self) {
int i;
MYFLT transpo;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
transpo = in[i];
if (transpo != self->lasttranspo) {
@@ -4374,44 +4374,44 @@ TranspoToCents_setProcMode(TranspoToCents *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = TranspoToCents_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = TranspoToCents_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = TranspoToCents_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = TranspoToCents_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = TranspoToCents_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = TranspoToCents_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = TranspoToCents_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = TranspoToCents_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = TranspoToCents_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = TranspoToCents_postprocessing_revareva;
break;
- }
+ }
}
static void
TranspoToCents_compute_next_data_frame(TranspoToCents *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4424,7 +4424,7 @@ TranspoToCents_traverse(TranspoToCents *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
TranspoToCents_clear(TranspoToCents *self)
{
pyo_CLEAR
@@ -4448,33 +4448,33 @@ TranspoToCents_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
TranspoToCents *self;
self = (TranspoToCents *)type->tp_alloc(type, 0);
-
+
self->lasttranspo = 1.0;
self->curcents = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, TranspoToCents_compute_next_data_frame);
self->mode_func_ptr = TranspoToCents_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -4482,10 +4482,10 @@ TranspoToCents_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * TranspoToCents_getServer(TranspoToCents* self) { GET_SERVER };
static PyObject * TranspoToCents_getStream(TranspoToCents* self) { GET_STREAM };
-static PyObject * TranspoToCents_setMul(TranspoToCents *self, PyObject *arg) { SET_MUL };
-static PyObject * TranspoToCents_setAdd(TranspoToCents *self, PyObject *arg) { SET_ADD };
-static PyObject * TranspoToCents_setSub(TranspoToCents *self, PyObject *arg) { SET_SUB };
-static PyObject * TranspoToCents_setDiv(TranspoToCents *self, PyObject *arg) { SET_DIV };
+static PyObject * TranspoToCents_setMul(TranspoToCents *self, PyObject *arg) { SET_MUL };
+static PyObject * TranspoToCents_setAdd(TranspoToCents *self, PyObject *arg) { SET_ADD };
+static PyObject * TranspoToCents_setSub(TranspoToCents *self, PyObject *arg) { SET_SUB };
+static PyObject * TranspoToCents_setDiv(TranspoToCents *self, PyObject *arg) { SET_DIV };
static PyObject * TranspoToCents_play(TranspoToCents *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * TranspoToCents_out(TranspoToCents *self, PyObject *args, PyObject *kwds) { OUT };
@@ -4623,11 +4623,11 @@ MToF_process(MToF *self) {
int i;
MYFLT midi;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
midi = in[i];
if (midi != self->lastmidi) {
- self->data[i] = self->curfreq = 8.1757989156437 * MYPOW(1.0594630943593, midi);
+ self->data[i] = self->curfreq = 440.0 * MYPOW(2.0, (midi - 69) / 12.0);
self->lastmidi = midi;
}
else
@@ -4650,44 +4650,44 @@ MToF_setProcMode(MToF *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = MToF_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = MToF_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = MToF_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = MToF_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = MToF_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = MToF_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = MToF_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = MToF_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = MToF_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = MToF_postprocessing_revareva;
break;
- }
+ }
}
static void
MToF_compute_next_data_frame(MToF *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4700,7 +4700,7 @@ MToF_traverse(MToF *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
MToF_clear(MToF *self)
{
pyo_CLEAR
@@ -4724,33 +4724,33 @@ MToF_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
MToF *self;
self = (MToF *)type->tp_alloc(type, 0);
-
+
self->lastmidi = 0;
self->curfreq = 8.1757989156437;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, MToF_compute_next_data_frame);
self->mode_func_ptr = MToF_setProcMode;
static char *kwlist[] = {"input", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -4758,10 +4758,10 @@ MToF_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * MToF_getServer(MToF* self) { GET_SERVER };
static PyObject * MToF_getStream(MToF* self) { GET_STREAM };
-static PyObject * MToF_setMul(MToF *self, PyObject *arg) { SET_MUL };
-static PyObject * MToF_setAdd(MToF *self, PyObject *arg) { SET_ADD };
-static PyObject * MToF_setSub(MToF *self, PyObject *arg) { SET_SUB };
-static PyObject * MToF_setDiv(MToF *self, PyObject *arg) { SET_DIV };
+static PyObject * MToF_setMul(MToF *self, PyObject *arg) { SET_MUL };
+static PyObject * MToF_setAdd(MToF *self, PyObject *arg) { SET_ADD };
+static PyObject * MToF_setSub(MToF *self, PyObject *arg) { SET_SUB };
+static PyObject * MToF_setDiv(MToF *self, PyObject *arg) { SET_DIV };
static PyObject * MToF_play(MToF *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * MToF_out(MToF *self, PyObject *args, PyObject *kwds) { OUT };
@@ -4883,6 +4883,284 @@ PyTypeObject MToFType = {
};
/************/
+/* FToM */
+/************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ MYFLT lastfreq;
+ MYFLT curmidi;
+ int modebuffer[2]; // need at least 2 slots for mul & add
+} FToM;
+
+static void
+FToM_process(FToM *self) {
+ int i;
+ MYFLT freq;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ freq = in[i];
+ if (freq != self->lastfreq) {
+ if (freq < 8.1758)
+ freq = 8.1578;
+ self->curmidi = 12.0 * MYLOG2(freq / 440.0) + 69;
+ self->lastfreq = freq;
+ }
+ else
+ self->data[i] = self->curmidi;
+ }
+}
+
+static void FToM_postprocessing_ii(FToM *self) { POST_PROCESSING_II };
+static void FToM_postprocessing_ai(FToM *self) { POST_PROCESSING_AI };
+static void FToM_postprocessing_ia(FToM *self) { POST_PROCESSING_IA };
+static void FToM_postprocessing_aa(FToM *self) { POST_PROCESSING_AA };
+static void FToM_postprocessing_ireva(FToM *self) { POST_PROCESSING_IREVA };
+static void FToM_postprocessing_areva(FToM *self) { POST_PROCESSING_AREVA };
+static void FToM_postprocessing_revai(FToM *self) { POST_PROCESSING_REVAI };
+static void FToM_postprocessing_revaa(FToM *self) { POST_PROCESSING_REVAA };
+static void FToM_postprocessing_revareva(FToM *self) { POST_PROCESSING_REVAREVA };
+
+static void
+FToM_setProcMode(FToM *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ self->proc_func_ptr = FToM_process;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = FToM_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = FToM_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = FToM_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = FToM_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = FToM_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = FToM_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = FToM_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = FToM_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = FToM_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+FToM_compute_next_data_frame(FToM *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+FToM_traverse(FToM *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ return 0;
+}
+
+static int
+FToM_clear(FToM *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ return 0;
+}
+
+static void
+FToM_dealloc(FToM* self)
+{
+ pyo_DEALLOC
+ FToM_clear(self);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *
+FToM_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
+ FToM *self;
+ self = (FToM *)type->tp_alloc(type, 0);
+
+ self->lastfreq = 8.1758;
+ self->curmidi = 0.0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, FToM_compute_next_data_frame);
+ self->mode_func_ptr = FToM_setProcMode;
+
+ static char *kwlist[] = {"input", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ INIT_INPUT_STREAM
+
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ }
+
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ }
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * FToM_getServer(FToM* self) { GET_SERVER };
+static PyObject * FToM_getStream(FToM* self) { GET_STREAM };
+static PyObject * FToM_setMul(FToM *self, PyObject *arg) { SET_MUL };
+static PyObject * FToM_setAdd(FToM *self, PyObject *arg) { SET_ADD };
+static PyObject * FToM_setSub(FToM *self, PyObject *arg) { SET_SUB };
+static PyObject * FToM_setDiv(FToM *self, PyObject *arg) { SET_DIV };
+
+static PyObject * FToM_play(FToM *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * FToM_out(FToM *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * FToM_stop(FToM *self) { STOP };
+
+static PyObject * FToM_multiply(FToM *self, PyObject *arg) { MULTIPLY };
+static PyObject * FToM_inplace_multiply(FToM *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * FToM_add(FToM *self, PyObject *arg) { ADD };
+static PyObject * FToM_inplace_add(FToM *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * FToM_sub(FToM *self, PyObject *arg) { SUB };
+static PyObject * FToM_inplace_sub(FToM *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * FToM_div(FToM *self, PyObject *arg) { DIV };
+static PyObject * FToM_inplace_div(FToM *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef FToM_members[] = {
+ {"server", T_OBJECT_EX, offsetof(FToM, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(FToM, stream), 0, "Stream object."},
+ {"input", T_OBJECT_EX, offsetof(FToM, input), 0, "Input sound object."},
+ {"mul", T_OBJECT_EX, offsetof(FToM, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(FToM, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef FToM_methods[] = {
+ {"getServer", (PyCFunction)FToM_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)FToM_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)FToM_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"stop", (PyCFunction)FToM_stop, METH_NOARGS, "Stops computing."},
+ {"out", (PyCFunction)FToM_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"setMul", (PyCFunction)FToM_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)FToM_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)FToM_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)FToM_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods FToM_as_number = {
+ (binaryfunc)FToM_add, /*nb_add*/
+ (binaryfunc)FToM_sub, /*nb_subtract*/
+ (binaryfunc)FToM_multiply, /*nb_multiply*/
+ (binaryfunc)FToM_div, /*nb_divide*/
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_neg*/
+ 0, /*nb_pos*/
+ 0, /*(unaryfunc)array_abs,*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ 0, /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ 0, /*nb_oct*/
+ 0, /*nb_hex*/
+ (binaryfunc)FToM_inplace_add, /*inplace_add*/
+ (binaryfunc)FToM_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)FToM_inplace_multiply, /*inplace_multiply*/
+ (binaryfunc)FToM_inplace_div, /*inplace_divide*/
+ 0, /*inplace_remainder*/
+ 0, /*inplace_power*/
+ 0, /*inplace_lshift*/
+ 0, /*inplace_rshift*/
+ 0, /*inplace_and*/
+ 0, /*inplace_xor*/
+ 0, /*inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject FToMType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_pyo.FToM_base", /*tp_name*/
+ sizeof(FToM), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)FToM_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &FToM_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "FToM objects. Converts frequency to midi note.", /* tp_doc */
+ (traverseproc)FToM_traverse, /* tp_traverse */
+ (inquiry)FToM_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ FToM_methods, /* tp_methods */
+ FToM_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ FToM_new, /* tp_new */
+};
+
+/************/
/* MToT */
/************/
typedef struct {
@@ -4900,7 +5178,7 @@ MToT_process(MToT *self) {
int i;
MYFLT midi;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
midi = in[i];
if (midi != self->lastmidi) {
@@ -4927,44 +5205,44 @@ MToT_setProcMode(MToT *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
self->proc_func_ptr = MToT_process;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = MToT_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = MToT_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = MToT_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = MToT_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = MToT_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = MToT_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = MToT_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = MToT_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = MToT_postprocessing_revareva;
break;
- }
+ }
}
static void
MToT_compute_next_data_frame(MToT *self)
{
- (*self->proc_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -4977,7 +5255,7 @@ MToT_traverse(MToT *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
MToT_clear(MToT *self)
{
pyo_CLEAR
@@ -5001,34 +5279,34 @@ MToT_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
MToT *self;
self = (MToT *)type->tp_alloc(type, 0);
-
+
self->centralkey = 60.0;
self->lastmidi = 0;
self->curfreq = 8.1757989156437;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, MToT_compute_next_data_frame);
self->mode_func_ptr = MToT_setProcMode;
static char *kwlist[] = {"input", "centralkey", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FOO, kwlist, &inputtmp, &self->centralkey, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -5041,23 +5319,23 @@ MToT_setCentralKey(MToT *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
self->centralkey = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject * MToT_getServer(MToT* self) { GET_SERVER };
static PyObject * MToT_getStream(MToT* self) { GET_STREAM };
-static PyObject * MToT_setMul(MToT *self, PyObject *arg) { SET_MUL };
-static PyObject * MToT_setAdd(MToT *self, PyObject *arg) { SET_ADD };
-static PyObject * MToT_setSub(MToT *self, PyObject *arg) { SET_SUB };
-static PyObject * MToT_setDiv(MToT *self, PyObject *arg) { SET_DIV };
+static PyObject * MToT_setMul(MToT *self, PyObject *arg) { SET_MUL };
+static PyObject * MToT_setAdd(MToT *self, PyObject *arg) { SET_ADD };
+static PyObject * MToT_setSub(MToT *self, PyObject *arg) { SET_SUB };
+static PyObject * MToT_setDiv(MToT *self, PyObject *arg) { SET_DIV };
static PyObject * MToT_play(MToT *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * MToT_out(MToT *self, PyObject *args, PyObject *kwds) { OUT };
@@ -5177,4 +5455,4 @@ PyTypeObject MToTType = {
0, /* tp_init */
0, /* tp_alloc */
MToT_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/src/objects/wgverbmodule.c b/src/objects/wgverbmodule.c
index 1fa6d06..b1b304d 100644
--- a/src/objects/wgverbmodule.c
+++ b/src/objects/wgverbmodule.c
@@ -1,21 +1,21 @@
-/*************************************************************************
- * Copyright 2010 Olivier Belanger *
- * *
+/**************************************************************************
+ * Copyright 2009-2015 Olivier Belanger *
+ * *
* This file is part of pyo, a python module to help digital signal *
- * processing script creation. *
- * *
+ * processing script creation. *
+ * *
* pyo 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 3 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 3 of the *
+ * License, or (at your option) any later version. *
* *
* pyo is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
+ * GNU Lesser General Public License for more details. *
* *
- * You should have received a copy of the GNU General Public License *
- * along with pyo. If not, see <http://www.gnu.org/licenses/>. *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
@@ -78,11 +78,11 @@ static void
WGVerb_process_ii(WGVerb *self) {
MYFLT val, x, x1, xind, frac, junction, inval, filt;
int i, j, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
MYFLT freq = PyFloat_AS_DOUBLE(self->cutoff);
-
+
if (feed < 0)
feed = 0;
else if (feed > 1)
@@ -93,7 +93,7 @@ WGVerb_process_ii(WGVerb *self) {
self->damp = 2.0 - MYCOS(TWOPI * freq / self->sr);
self->damp = (self->damp - MYSQRT(self->damp * self->damp - 1.0));
}
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
junction = self->total_signal * .25;
@@ -109,7 +109,7 @@ WGVerb_process_ii(WGVerb *self) {
self->rnd_diff[j] = self->rnd_value[j] - self->rnd_oldValue[j];
}
self->rnd[j] = self->rnd_oldValue[j] + self->rnd_diff[j] * self->rnd_time[j];
-
+
xind = self->in_count[j] - (self->delays[j] + self->rnd[j]);
if (xind < 0)
xind += self->size[j];
@@ -121,7 +121,7 @@ WGVerb_process_ii(WGVerb *self) {
val *= feed;
filt = (self->lastSamples[j] - val) * self->damp + val;
self->total_signal += filt;
-
+
self->buffer[j][self->in_count[j]] = inval + junction - self->lastSamples[j];
self->lastSamples[j] = filt;
if(self->in_count[j] == 0)
@@ -129,7 +129,7 @@ WGVerb_process_ii(WGVerb *self) {
self->in_count[j]++;
if (self->in_count[j] >= self->size[j])
self->in_count[j] = 0;
- }
+ }
self->data[i] = self->total_signal * 0.25;
}
}
@@ -138,24 +138,24 @@ static void
WGVerb_process_ai(WGVerb *self) {
MYFLT val, x, x1, xind, frac, junction, inval, filt, feed;
int i, j, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *feedback = Stream_getData((Stream *)self->feedback_stream);
MYFLT freq = PyFloat_AS_DOUBLE(self->cutoff);
-
+
if (freq != self->lastFreq) {
self->lastFreq = freq;
self->damp = 2.0 - MYCOS(TWOPI * freq / self->sr);
self->damp = (self->damp - MYSQRT(self->damp * self->damp - 1.0));
}
-
+
for (i=0; i<self->bufsize; i++) {
inval = in[i];
feed = feedback[i];
if (feed < 0)
feed = 0;
else if (feed > 1)
- feed = 1;
+ feed = 1;
junction = self->total_signal * .25;
self->total_signal = 0.0;
for (j=0; j<8; j++) {
@@ -169,7 +169,7 @@ WGVerb_process_ai(WGVerb *self) {
self->rnd_diff[j] = self->rnd_value[j] - self->rnd_oldValue[j];
}
self->rnd[j] = self->rnd_oldValue[j] + self->rnd_diff[j] * self->rnd_time[j];
-
+
xind = self->in_count[j] - (self->delays[j] + self->rnd[j]);
if (xind < 0)
xind += self->size[j];
@@ -181,7 +181,7 @@ WGVerb_process_ai(WGVerb *self) {
val *= feed;
filt = (self->lastSamples[j] - val) * self->damp + val;
self->total_signal += filt;
-
+
self->buffer[j][self->in_count[j]] = inval + junction - self->lastSamples[j];
self->lastSamples[j] = filt;
if(self->in_count[j] == 0)
@@ -189,20 +189,20 @@ WGVerb_process_ai(WGVerb *self) {
self->in_count[j]++;
if (self->in_count[j] >= self->size[j])
self->in_count[j] = 0;
- }
+ }
self->data[i] = self->total_signal * 0.25;
- }
+ }
}
static void
WGVerb_process_ia(WGVerb *self) {
MYFLT val, x, x1, xind, frac, junction, inval, filt, freq;
int i, j, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT feed = PyFloat_AS_DOUBLE(self->feedback);
MYFLT *cutoff = Stream_getData((Stream *)self->cutoff_stream);
-
+
if (feed < 0)
feed = 0;
else if (feed > 1)
@@ -215,7 +215,7 @@ WGVerb_process_ia(WGVerb *self) {
self->lastFreq = freq;
self->damp = 2.0 - MYCOS(TWOPI * freq / self->sr);
self->damp = (self->damp - MYSQRT(self->damp * self->damp - 1.0));
- }
+ }
junction = self->total_signal * .25;
self->total_signal = 0.0;
for (j=0; j<8; j++) {
@@ -229,7 +229,7 @@ WGVerb_process_ia(WGVerb *self) {
self->rnd_diff[j] = self->rnd_value[j] - self->rnd_oldValue[j];
}
self->rnd[j] = self->rnd_oldValue[j] + self->rnd_diff[j] * self->rnd_time[j];
-
+
xind = self->in_count[j] - (self->delays[j] + self->rnd[j]);
if (xind < 0)
xind += self->size[j];
@@ -241,7 +241,7 @@ WGVerb_process_ia(WGVerb *self) {
val *= feed;
filt = (self->lastSamples[j] - val) * self->damp + val;
self->total_signal += filt;
-
+
self->buffer[j][self->in_count[j]] = inval + junction - self->lastSamples[j];
self->lastSamples[j] = filt;
if(self->in_count[j] == 0)
@@ -249,16 +249,16 @@ WGVerb_process_ia(WGVerb *self) {
self->in_count[j]++;
if (self->in_count[j] >= self->size[j])
self->in_count[j] = 0;
- }
+ }
self->data[i] = self->total_signal * 0.25;
- }
+ }
}
static void
WGVerb_process_aa(WGVerb *self) {
MYFLT val, x, x1, xind, frac, junction, inval, filt, feed, freq;
int i, j, ind;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *feedback = Stream_getData((Stream *)self->feedback_stream);
MYFLT *cutoff = Stream_getData((Stream *)self->cutoff_stream);
@@ -270,12 +270,12 @@ WGVerb_process_aa(WGVerb *self) {
if (feed < 0)
feed = 0;
else if (feed > 1)
- feed = 1;
+ feed = 1;
if (freq != self->lastFreq) {
self->lastFreq = freq;
self->damp = 2.0 - MYCOS(TWOPI * freq / self->sr);
self->damp = (self->damp - MYSQRT(self->damp * self->damp - 1.0));
- }
+ }
junction = self->total_signal * .25;
self->total_signal = 0.0;
for (j=0; j<8; j++) {
@@ -289,7 +289,7 @@ WGVerb_process_aa(WGVerb *self) {
self->rnd_diff[j] = self->rnd_value[j] - self->rnd_oldValue[j];
}
self->rnd[j] = self->rnd_oldValue[j] + self->rnd_diff[j] * self->rnd_time[j];
-
+
xind = self->in_count[j] - (self->delays[j] + self->rnd[j]);
if (xind < 0)
xind += self->size[j];
@@ -301,7 +301,7 @@ WGVerb_process_aa(WGVerb *self) {
val *= feed;
filt = (self->lastSamples[j] - val) * self->damp + val;
self->total_signal += filt;
-
+
self->buffer[j][self->in_count[j]] = inval + junction - self->lastSamples[j];
self->lastSamples[j] = filt;
if(self->in_count[j] == 0)
@@ -309,24 +309,24 @@ WGVerb_process_aa(WGVerb *self) {
self->in_count[j]++;
if (self->in_count[j] >= self->size[j])
self->in_count[j] = 0;
- }
+ }
self->data[i] = self->total_signal * 0.25;
- }
+ }
}
static void
WGVerb_mix_i(WGVerb *self) {
int i;
MYFLT val;
-
+
MYFLT mix = PyFloat_AS_DOUBLE(self->mix);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
if (mix < 0.0)
mix = 0.0;
else if (mix > 1.0)
mix = 1.0;
-
+
for (i=0; i<self->bufsize; i++) {
val = in[i] * (1.0 - mix) + self->data[i] * mix;
self->data[i] = val;
@@ -337,17 +337,17 @@ static void
WGVerb_mix_a(WGVerb *self) {
int i;
MYFLT mix, val;
-
+
MYFLT *mi = Stream_getData((Stream *)self->mix_stream);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
+
for (i=0; i<self->bufsize; i++) {
mix = mi[i];
if (mix < 0.0)
mix = 0.0;
else if (mix > 1.0)
mix = 1.0;
-
+
val = in[i] * (1.0 - mix) + self->data[i] * mix;
self->data[i] = val;
}
@@ -370,66 +370,66 @@ WGVerb_setProcMode(WGVerb *self)
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
mixmode = self->modebuffer[4];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = WGVerb_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = WGVerb_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = WGVerb_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = WGVerb_process_aa;
break;
- }
+ }
switch (mixmode) {
- case 0:
+ case 0:
self->mix_func_ptr = WGVerb_mix_i;
break;
- case 1:
+ case 1:
self->mix_func_ptr = WGVerb_mix_a;
break;
- }
-
+ }
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = WGVerb_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = WGVerb_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = WGVerb_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = WGVerb_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = WGVerb_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = WGVerb_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = WGVerb_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = WGVerb_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = WGVerb_postprocessing_revareva;
break;
- }
+ }
}
static void
WGVerb_compute_next_data_frame(WGVerb *self)
{
- (*self->proc_func_ptr)(self);
- (*self->mix_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
+ (*self->mix_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
@@ -438,28 +438,28 @@ WGVerb_traverse(WGVerb *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->feedback);
- Py_VISIT(self->feedback_stream);
- Py_VISIT(self->cutoff);
- Py_VISIT(self->cutoff_stream);
- Py_VISIT(self->mix);
- Py_VISIT(self->mix_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
+ Py_VISIT(self->cutoff);
+ Py_VISIT(self->cutoff_stream);
+ Py_VISIT(self->mix);
+ Py_VISIT(self->mix_stream);
return 0;
}
-static int
+static int
WGVerb_clear(WGVerb *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
- Py_CLEAR(self->cutoff);
- Py_CLEAR(self->cutoff_stream);
- Py_CLEAR(self->mix);
- Py_CLEAR(self->mix_stream);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
+ Py_CLEAR(self->cutoff);
+ Py_CLEAR(self->cutoff_stream);
+ Py_CLEAR(self->mix);
+ Py_CLEAR(self->mix_stream);
return 0;
}
@@ -470,7 +470,7 @@ WGVerb_dealloc(WGVerb* self)
pyo_DEALLOC
for (i=0; i<8; i++) {
free(self->buffer[i]);
- }
+ }
WGVerb_clear(self);
self->ob_type->tp_free((PyObject*)self);
}
@@ -482,23 +482,23 @@ WGVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *feedbacktmp=NULL, *cutofftmp=NULL, *mixtmp=NULL, *multmp=NULL, *addtmp=NULL;
WGVerb *self;
self = (WGVerb *)type->tp_alloc(type, 0);
-
+
self->feedback = PyFloat_FromDouble(0.5);
self->cutoff = PyFloat_FromDouble(5000.0);
self->mix = PyFloat_FromDouble(0.5);
self->lastFreq = self->damp = 0.0;
-
+
self->total_signal = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->modebuffer[4] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, WGVerb_compute_next_data_frame);
self->mode_func_ptr = WGVerb_setProcMode;
-
+
for (i=0; i<8; i++) {
self->in_count[i] = 0;
self->lastSamples[i] = 0.0;
@@ -511,12 +511,12 @@ WGVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
static char *kwlist[] = {"input", "feedback", "cutoff", "mix", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOO", kwlist, &inputtmp, &feedbacktmp, &cutofftmp, &mixtmp, &multmp, &addtmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
-
+
if (feedbacktmp) {
PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
}
@@ -528,15 +528,15 @@ WGVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (mixtmp) {
PyObject_CallMethod((PyObject *)self, "setMix", "O", mixtmp);
}
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
for (i=0; i<8; i++) {
@@ -544,9 +544,9 @@ WGVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->buffer[i] = (MYFLT *)realloc(self->buffer[i], (self->size[i]+1) * sizeof(MYFLT));
for (j=0; j<(self->size[i]+1); j++) {
self->buffer[i][j] = 0.;
- }
- }
-
+ }
+ }
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -554,10 +554,10 @@ WGVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * WGVerb_getServer(WGVerb* self) { GET_SERVER };
static PyObject * WGVerb_getStream(WGVerb* self) { GET_STREAM };
-static PyObject * WGVerb_setMul(WGVerb *self, PyObject *arg) { SET_MUL };
-static PyObject * WGVerb_setAdd(WGVerb *self, PyObject *arg) { SET_ADD };
-static PyObject * WGVerb_setSub(WGVerb *self, PyObject *arg) { SET_SUB };
-static PyObject * WGVerb_setDiv(WGVerb *self, PyObject *arg) { SET_DIV };
+static PyObject * WGVerb_setMul(WGVerb *self, PyObject *arg) { SET_MUL };
+static PyObject * WGVerb_setAdd(WGVerb *self, PyObject *arg) { SET_ADD };
+static PyObject * WGVerb_setSub(WGVerb *self, PyObject *arg) { SET_SUB };
+static PyObject * WGVerb_setDiv(WGVerb *self, PyObject *arg) { SET_DIV };
static PyObject * WGVerb_play(WGVerb *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * WGVerb_out(WGVerb *self, PyObject *args, PyObject *kwds) { OUT };
@@ -576,14 +576,14 @@ static PyObject *
WGVerb_setFeedback(WGVerb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->feedback);
@@ -599,25 +599,25 @@ WGVerb_setFeedback(WGVerb *self, PyObject *arg)
self->feedback_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
WGVerb_setCutoff(WGVerb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->cutoff);
@@ -633,25 +633,25 @@ WGVerb_setCutoff(WGVerb *self, PyObject *arg)
self->cutoff_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
WGVerb_setMix(WGVerb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->mix);
@@ -667,12 +667,12 @@ WGVerb_setMix(WGVerb *self, PyObject *arg)
self->mix_stream = (Stream *)streamtmp;
self->modebuffer[4] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef WGVerb_members[] = {
{"server", T_OBJECT_EX, offsetof(WGVerb, server), 0, "Pyo server."},
@@ -841,7 +841,7 @@ STReverb_process_ii(STReverb *self) {
MYFLT ref_amp_l[NUM_REFS];
MYFLT ref_amp_r[NUM_REFS];
MYFLT ref_buf[2];
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT inpos = PyFloat_AS_DOUBLE(self->inpos);
if (self->modebuffer[1] == 0)
@@ -849,12 +849,12 @@ STReverb_process_ii(STReverb *self) {
else
feed = Stream_getData((Stream *)self->revtime_stream)[0];
MYFLT freq = PyFloat_AS_DOUBLE(self->cutoff);
-
+
if (inpos < 0.0)
inpos = 0.0;
else if (inpos > 1.0)
inpos = 1.0;
-
+
if (feed < 0.01)
feed = 0.01;
feed = MYPOW(100.0, -self->avg_time/feed);
@@ -929,7 +929,7 @@ STReverb_process_ii(STReverb *self) {
self->rnd_diff[k][j] = self->rnd_value[k][j] - self->rnd_oldValue[k][j];
}
self->rnd[k][j] = self->rnd_oldValue[k][j] + self->rnd_diff[k][j] * self->rnd_time[k][j];
-
+
xind = self->in_count[k][j] - (self->delays[k][j] + self->rnd[k][j]);
if (xind < 0)
xind += self->size[k][j];
@@ -941,7 +941,7 @@ STReverb_process_ii(STReverb *self) {
val *= feed;
filt = val + (self->lastSamples[k][j] - val) * self->damp[k];
self->total_signal[k] += filt;
-
+
self->buffer[k][j][self->in_count[k][j]] = inval + junction - self->lastSamples[k][j];
self->lastSamples[k][j] = filt;
if(self->in_count[k][j] == 0)
@@ -949,7 +949,7 @@ STReverb_process_ii(STReverb *self) {
self->in_count[k][j]++;
if (self->in_count[k][j] >= self->size[k][j])
self->in_count[k][j] = 0;
- }
+ }
self->buffer_streams[i+k*self->bufsize] = self->total_signal[k] * 0.25;
}
}
@@ -962,7 +962,7 @@ STReverb_process_ai(STReverb *self) {
MYFLT ref_amp_r[NUM_REFS];
MYFLT ref_buf[2];
int i, j, k, k2, ind, half;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *pos = Stream_getData((Stream *)self->inpos_stream);
if (self->modebuffer[1] == 0)
@@ -1050,7 +1050,7 @@ STReverb_process_ai(STReverb *self) {
self->rnd_diff[k][j] = self->rnd_value[k][j] - self->rnd_oldValue[k][j];
}
self->rnd[k][j] = self->rnd_oldValue[k][j] + self->rnd_diff[k][j] * self->rnd_time[k][j];
-
+
xind = self->in_count[k][j] - (self->delays[k][j] + self->rnd[k][j]);
if (xind < 0)
xind += self->size[k][j];
@@ -1062,7 +1062,7 @@ STReverb_process_ai(STReverb *self) {
val *= feed;
filt = val + (self->lastSamples[k][j] - val) * self->damp[k];
self->total_signal[k] += filt;
-
+
self->buffer[k][j][self->in_count[k][j]] = inval + junction - self->lastSamples[k][j];
self->lastSamples[k][j] = filt;
if(self->in_count[k][j] == 0)
@@ -1070,7 +1070,7 @@ STReverb_process_ai(STReverb *self) {
self->in_count[k][j]++;
if (self->in_count[k][j] >= self->size[k][j])
self->in_count[k][j] = 0;
- }
+ }
self->buffer_streams[i+k*self->bufsize] = self->total_signal[k] * 0.25;
}
}
@@ -1083,7 +1083,7 @@ STReverb_process_ia(STReverb *self) {
MYFLT ref_amp_r[NUM_REFS];
MYFLT ref_buf[2];
int i, j, k, k2, ind, half;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT inpos = PyFloat_AS_DOUBLE(self->inpos);
if (self->modebuffer[1] == 0)
@@ -1091,12 +1091,12 @@ STReverb_process_ia(STReverb *self) {
else
feed = Stream_getData((Stream *)self->revtime_stream)[0];
MYFLT *fr = Stream_getData((Stream *)self->cutoff_stream);
-
+
if (inpos < 0.0)
inpos = 0.0;
else if (inpos > 1.0)
inpos = 1.0;
-
+
if (feed < 0.01)
feed = 0.01;
feed = MYPOW(100.0, -self->avg_time/feed);
@@ -1172,7 +1172,7 @@ STReverb_process_ia(STReverb *self) {
self->rnd_diff[k][j] = self->rnd_value[k][j] - self->rnd_oldValue[k][j];
}
self->rnd[k][j] = self->rnd_oldValue[k][j] + self->rnd_diff[k][j] * self->rnd_time[k][j];
-
+
xind = self->in_count[k][j] - (self->delays[k][j] + self->rnd[k][j]);
if (xind < 0)
xind += self->size[k][j];
@@ -1184,7 +1184,7 @@ STReverb_process_ia(STReverb *self) {
val *= feed;
filt = val + (self->lastSamples[k][j] - val) * self->damp[k];
self->total_signal[k] += filt;
-
+
self->buffer[k][j][self->in_count[k][j]] = inval + junction - self->lastSamples[k][j];
self->lastSamples[k][j] = filt;
if(self->in_count[k][j] == 0)
@@ -1192,7 +1192,7 @@ STReverb_process_ia(STReverb *self) {
self->in_count[k][j]++;
if (self->in_count[k][j] >= self->size[k][j])
self->in_count[k][j] = 0;
- }
+ }
self->buffer_streams[i+k*self->bufsize] = self->total_signal[k] * 0.25;
}
}
@@ -1205,7 +1205,7 @@ STReverb_process_aa(STReverb *self) {
MYFLT ref_amp_r[NUM_REFS];
MYFLT ref_buf[2];
int i, j, k, k2, ind, half;
-
+
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT *pos = Stream_getData((Stream *)self->inpos_stream);
if (self->modebuffer[1] == 0)
@@ -1294,7 +1294,7 @@ STReverb_process_aa(STReverb *self) {
self->rnd_diff[k][j] = self->rnd_value[k][j] - self->rnd_oldValue[k][j];
}
self->rnd[k][j] = self->rnd_oldValue[k][j] + self->rnd_diff[k][j] * self->rnd_time[k][j];
-
+
xind = self->in_count[k][j] - (self->delays[k][j] + self->rnd[k][j]);
if (xind < 0)
xind += self->size[k][j];
@@ -1306,7 +1306,7 @@ STReverb_process_aa(STReverb *self) {
val *= feed;
filt = val + (self->lastSamples[k][j] - val) * self->damp[k];
self->total_signal[k] += filt;
-
+
self->buffer[k][j][self->in_count[k][j]] = inval + junction - self->lastSamples[k][j];
self->lastSamples[k][j] = filt;
if(self->in_count[k][j] == 0)
@@ -1314,7 +1314,7 @@ STReverb_process_aa(STReverb *self) {
self->in_count[k][j]++;
if (self->in_count[k][j] >= self->size[k][j])
self->in_count[k][j] = 0;
- }
+ }
self->buffer_streams[i+k*self->bufsize] = self->total_signal[k] * 0.25;
}
}
@@ -1324,14 +1324,14 @@ static void
STReverb_mix_i(STReverb *self) {
int i, k;
MYFLT val;
-
+
MYFLT mix = PyFloat_AS_DOUBLE(self->mix);
-
+
if (mix < 0.0)
mix = 0.0;
else if (mix > 1.0)
mix = 1.0;
-
+
for (i=0; i<self->bufsize; i++) {
for (k=0; k<2; k++) {
val = self->input_buffer[k][i] + (self->buffer_streams[i+k*self->bufsize] - self->input_buffer[k][i]) * mix;
@@ -1344,16 +1344,16 @@ static void
STReverb_mix_a(STReverb *self) {
int i, k;
MYFLT mix, val;
-
+
MYFLT *mi = Stream_getData((Stream *)self->mix_stream);
-
+
for (i=0; i<self->bufsize; i++) {
mix = mi[i];
if (mix < 0.0)
mix = 0.0;
else if (mix > 1.0)
mix = 1.0;
-
+
for (k=0; k<2; k++) {
val = self->input_buffer[k][i] + (self->buffer_streams[i+k*self->bufsize] - self->input_buffer[k][i]) * mix;
self->buffer_streams[i+k*self->bufsize] = val;
@@ -1367,26 +1367,26 @@ STReverb_setProcMode(STReverb *self)
int procmode, mixmode;
procmode = self->modebuffer[0] + self->modebuffer[2] * 10;
mixmode = self->modebuffer[3];
-
+
switch (procmode) {
- case 0:
+ case 0:
self->proc_func_ptr = STReverb_process_ii;
break;
- case 1:
+ case 1:
self->proc_func_ptr = STReverb_process_ai;
break;
- case 10:
+ case 10:
self->proc_func_ptr = STReverb_process_ia;
break;
- case 11:
+ case 11:
self->proc_func_ptr = STReverb_process_aa;
break;
- }
+ }
switch (mixmode) {
- case 0:
+ case 0:
self->mix_func_ptr = STReverb_mix_i;
break;
- case 1:
+ case 1:
self->mix_func_ptr = STReverb_mix_a;
break;
}
@@ -1396,13 +1396,13 @@ MYFLT *
STReverb_getSamplesBuffer(STReverb *self)
{
return (MYFLT *)self->buffer_streams;
-}
+}
static void
STReverb_compute_next_data_frame(STReverb *self)
{
- (*self->proc_func_ptr)(self);
- (*self->mix_func_ptr)(self);
+ (*self->proc_func_ptr)(self);
+ (*self->mix_func_ptr)(self);
}
static int
@@ -1410,32 +1410,32 @@ STReverb_traverse(STReverb *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->input);
- Py_VISIT(self->input_stream);
- Py_VISIT(self->inpos);
- Py_VISIT(self->inpos_stream);
- Py_VISIT(self->revtime);
- Py_VISIT(self->revtime_stream);
- Py_VISIT(self->cutoff);
- Py_VISIT(self->cutoff_stream);
- Py_VISIT(self->mix);
- Py_VISIT(self->mix_stream);
+ Py_VISIT(self->input_stream);
+ Py_VISIT(self->inpos);
+ Py_VISIT(self->inpos_stream);
+ Py_VISIT(self->revtime);
+ Py_VISIT(self->revtime_stream);
+ Py_VISIT(self->cutoff);
+ Py_VISIT(self->cutoff_stream);
+ Py_VISIT(self->mix);
+ Py_VISIT(self->mix_stream);
return 0;
}
-static int
+static int
STReverb_clear(STReverb *self)
{
pyo_CLEAR
Py_CLEAR(self->input);
- Py_CLEAR(self->input_stream);
- Py_CLEAR(self->inpos);
- Py_CLEAR(self->inpos_stream);
- Py_CLEAR(self->revtime);
- Py_CLEAR(self->revtime_stream);
- Py_CLEAR(self->cutoff);
- Py_CLEAR(self->cutoff_stream);
- Py_CLEAR(self->mix);
- Py_CLEAR(self->mix_stream);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->inpos);
+ Py_CLEAR(self->inpos_stream);
+ Py_CLEAR(self->revtime);
+ Py_CLEAR(self->revtime_stream);
+ Py_CLEAR(self->cutoff);
+ Py_CLEAR(self->cutoff_stream);
+ Py_CLEAR(self->mix);
+ Py_CLEAR(self->mix_stream);
return 0;
}
@@ -1468,7 +1468,7 @@ STReverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *inputtmp, *input_streamtmp, *inpostmp=NULL, *revtimetmp=NULL, *cutofftmp=NULL, *mixtmp=NULL;
STReverb *self;
self = (STReverb *)type->tp_alloc(type, 0);
-
+
self->inpos = PyFloat_FromDouble(0.5);
self->revtime = PyFloat_FromDouble(0.5);
self->cutoff = PyFloat_FromDouble(5000.0);
@@ -1478,9 +1478,9 @@ STReverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
-
+
INIT_OBJECT_COMMON
-
+
self->nyquist = self->sr * 0.49;
self->srfac = self->sr / 44100.0;
@@ -1488,16 +1488,16 @@ STReverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->mode_func_ptr = STReverb_setProcMode;
static char *kwlist[] = {"input", "inpos", "revtime", "cutoff", "mix", "roomSize", "firstRefGain", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_OOOOFF, kwlist, &inputtmp, &inpostmp, &revtimetmp, &cutofftmp, &mixtmp, &roomSize, &firstRefTmp))
Py_RETURN_NONE;
-
+
INIT_INPUT_STREAM
if (inpostmp) {
PyObject_CallMethod((PyObject *)self, "setInpos", "O", inpostmp);
}
-
+
if (revtimetmp) {
PyObject_CallMethod((PyObject *)self, "setRevtime", "O", revtimetmp);
}
@@ -1537,7 +1537,7 @@ STReverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (j=0; j<(maxsize+1); j++) {
self->buffer[k][i][j] = 0.;
}
- }
+ }
}
self->avg_time /= 16.0;
@@ -1578,14 +1578,14 @@ static PyObject *
STReverb_setInpos(STReverb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->inpos);
@@ -1601,25 +1601,25 @@ STReverb_setInpos(STReverb *self, PyObject *arg)
self->inpos_stream = (Stream *)streamtmp;
self->modebuffer[0] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
STReverb_setRevtime(STReverb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->revtime);
@@ -1635,25 +1635,25 @@ STReverb_setRevtime(STReverb *self, PyObject *arg)
self->revtime_stream = (Stream *)streamtmp;
self->modebuffer[1] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
STReverb_setCutoff(STReverb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->cutoff);
@@ -1669,25 +1669,25 @@ STReverb_setCutoff(STReverb *self, PyObject *arg)
self->cutoff_stream = (Stream *)streamtmp;
self->modebuffer[2] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
STReverb_setMix(STReverb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
tmp = arg;
Py_INCREF(tmp);
Py_DECREF(self->mix);
@@ -1703,12 +1703,12 @@ STReverb_setMix(STReverb *self, PyObject *arg)
self->mix_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
-
+
(*self->mode_func_ptr)(self);
-
+
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyObject *
STReverb_setRoomSize(STReverb *self, PyObject *arg)
@@ -1716,14 +1716,14 @@ STReverb_setRoomSize(STReverb *self, PyObject *arg)
int i, j, k, din;
long maxsize;
MYFLT roomSize;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
roomSize = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
if (roomSize < 0.25)
@@ -1746,7 +1746,7 @@ STReverb_setRoomSize(STReverb *self, PyObject *arg)
for (j=0; j<(maxsize+1); j++) {
self->buffer[k][i][j] = 0.;
}
- }
+ }
}
self->avg_time /= 16.0;
@@ -1768,14 +1768,14 @@ static PyObject *
STReverb_setFirstRefGain(STReverb *self, PyObject *arg)
{
MYFLT tmp;
-
+
if (arg == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
-
+
int isNumber = PyNumber_Check(arg);
-
+
if (isNumber == 1) {
tmp = PyFloat_AS_DOUBLE(PyNumber_Float(arg));
self->firstRefGain = MYPOW(10.0, tmp * 0.05);
@@ -1783,7 +1783,7 @@ STReverb_setFirstRefGain(STReverb *self, PyObject *arg)
Py_INCREF(Py_None);
return Py_None;
-}
+}
static PyMemberDef STReverb_members[] = {
{"server", T_OBJECT_EX, offsetof(STReverb, server), 0, "Pyo server."},
@@ -1877,33 +1877,33 @@ STRev_setProcMode(STRev *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
+
switch (muladdmode) {
- case 0:
+ case 0:
self->muladd_func_ptr = STRev_postprocessing_ii;
break;
- case 1:
+ case 1:
self->muladd_func_ptr = STRev_postprocessing_ai;
break;
- case 2:
+ case 2:
self->muladd_func_ptr = STRev_postprocessing_revai;
break;
- case 10:
+ case 10:
self->muladd_func_ptr = STRev_postprocessing_ia;
break;
- case 11:
+ case 11:
self->muladd_func_ptr = STRev_postprocessing_aa;
break;
- case 12:
+ case 12:
self->muladd_func_ptr = STRev_postprocessing_revaa;
break;
- case 20:
+ case 20:
self->muladd_func_ptr = STRev_postprocessing_ireva;
break;
- case 21:
+ case 21:
self->muladd_func_ptr = STRev_postprocessing_areva;
break;
- case 22:
+ case 22:
self->muladd_func_ptr = STRev_postprocessing_revareva;
break;
}
@@ -1918,7 +1918,7 @@ STRev_compute_next_data_frame(STRev *self)
tmp = STReverb_getSamplesBuffer((STReverb *)self->mainSplitter);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i + offset];
- }
+ }
(*self->muladd_func_ptr)(self);
}
@@ -1930,11 +1930,11 @@ STRev_traverse(STRev *self, visitproc visit, void *arg)
return 0;
}
-static int
+static int
STRev_clear(STRev *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainSplitter);
+ Py_CLEAR(self->mainSplitter);
return 0;
}
@@ -1953,33 +1953,33 @@ STRev_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
STRev *self;
self = (STRev *)type->tp_alloc(type, 0);
-
+
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
-
+
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, STRev_compute_next_data_frame);
self->mode_func_ptr = STRev_setProcMode;
static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
-
+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
Py_RETURN_NONE;
Py_XDECREF(self->mainSplitter);
Py_INCREF(maintmp);
self->mainSplitter = (STReverb *)maintmp;
-
+
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-
+
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
+
(*self->mode_func_ptr)(self);
return (PyObject *)self;
@@ -1987,10 +1987,10 @@ STRev_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * STRev_getServer(STRev* self) { GET_SERVER };
static PyObject * STRev_getStream(STRev* self) { GET_STREAM };
-static PyObject * STRev_setMul(STRev *self, PyObject *arg) { SET_MUL };
-static PyObject * STRev_setAdd(STRev *self, PyObject *arg) { SET_ADD };
-static PyObject * STRev_setSub(STRev *self, PyObject *arg) { SET_SUB };
-static PyObject * STRev_setDiv(STRev *self, PyObject *arg) { SET_DIV };
+static PyObject * STRev_setMul(STRev *self, PyObject *arg) { SET_MUL };
+static PyObject * STRev_setAdd(STRev *self, PyObject *arg) { SET_ADD };
+static PyObject * STRev_setSub(STRev *self, PyObject *arg) { SET_SUB };
+static PyObject * STRev_setDiv(STRev *self, PyObject *arg) { SET_DIV };
static PyObject * STRev_play(STRev *self, PyObject *args, PyObject *kwds) { PLAY };
static PyObject * STRev_out(STRev *self, PyObject *args, PyObject *kwds) { OUT };
@@ -2108,4 +2108,4 @@ STRev_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
STRev_new, /* tp_new */
-};
+};
\ No newline at end of file
diff --git a/utils/E-Pyo.py b/utils/E-Pyo.py
index 87656d1..87d556a 100755
--- a/utils/E-Pyo.py
+++ b/utils/E-Pyo.py
@@ -3,13 +3,28 @@
"""
E-Pyo is a simple text editor especially configured to edit pyo audio programs.
-You can do absolutely everything you want to with this piece of software.
+You can do absolutely everything you want with this piece of software.
Olivier Belanger - 2012
+TODO:
+ - Fix printing to pdf
+ - Output panel close button on OSX (display only)
"""
from __future__ import with_statement
-import sys, os, string, inspect, keyword, wx, codecs, subprocess, unicodedata, contextlib, StringIO, shutil, copy, pprint, random, time, threading
+import sys
+import __builtin__
+__builtin__.EPYO_APP_OPENED = True
+
+if sys.platform == "linux2":
+ import wxversion
+ if wxversion.checkInstalled("3.0"):
+ wxversion.select("3.0")
+ elif wxversion.checkInstalled("2.8"):
+ wxversion.select("2.8")
+
+import os, string, inspect, keyword, wx, codecs, subprocess, unicodedata
+import contextlib, StringIO, shutil, copy, pprint, random, time, threading
from types import UnicodeType, MethodType, ListType
from wx.lib.wordwrap import wordwrap
from wx.lib.embeddedimage import PyEmbeddedImage
@@ -17,8 +32,8 @@ import wx.lib.colourselect as csel
import wx.lib.scrolledpanel as scrolled
import wx.lib.dialogs
import wx.combo
-import wx.stc as stc
-import FlatNotebook as FNB
+import wx.stc as stc
+import wx.lib.agw.flatnotebook as FNB
from pyo import *
from PyoDoc import ManualFrame
@@ -30,10 +45,13 @@ PLATFORM = sys.platform
DEFAULT_ENCODING = sys.getdefaultencoding()
ENCODING = sys.getfilesystemencoding()
ENCODING_LIST = ["utf_8", "latin_1", "mac_roman", "cp1252", "cp1250", "utf_16"]
-ENCODING_DICT = {'cp-1250': 'cp1250', 'cp-1251': 'cp1251', 'cp-1252': 'cp1252', 'latin-1': 'latin_1',
- 'mac-roman': 'mac_roman', 'utf-8': 'utf_8', 'utf-16': 'utf_16', 'utf-16 (Big Endian)': 'utf_16_be',
- 'utf-16 (Little Endian)': 'utf_16_le', 'utf-32': 'utf_32', 'utf-32 (Big Endian)':
- 'utf_32_be', 'utf-32 (Little Endian)': 'utf_32_le'}
+ENCODING_DICT = {'cp-1250': 'cp1250', 'cp-1251': 'cp1251', 'cp-1252': 'cp1252',
+ 'latin-1': 'latin_1', 'mac-roman': 'mac_roman',
+ 'utf-8': 'utf_8', 'utf-16': 'utf_16',
+ 'utf-16 (Big Endian)': 'utf_16_be',
+ 'utf-16 (Little Endian)': 'utf_16_le', 'utf-32': 'utf_32',
+ 'utf-32 (Big Endian)': 'utf_32_be',
+ 'utf-32 (Little Endian)': 'utf_32_le'}
APP_NAME = 'E-Pyo'
APP_VERSION = PYO_VERSION
@@ -104,6 +122,7 @@ def hex_to_rgb(value):
lv = len(value)
return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3))
+################## Paths ##################
TEMP_PATH = os.path.join(os.path.expanduser('~'), '.epyo')
if not os.path.isdir(TEMP_PATH):
os.mkdir(TEMP_PATH)
@@ -113,6 +132,7 @@ if not os.path.isfile(PREFERENCES_PATH):
with open(PREFERENCES_PATH, "w") as f:
f.write("epyo_prefs = {}")
+epyo_prefs = {}
with open(PREFERENCES_PATH, "r") as f:
text = f.read()
exec text in locals()
@@ -139,7 +159,8 @@ if PLATFORM == "darwin" and '/%s.app' % APP_NAME in os.getcwd():
# Check for which Python to use #
if PLATFORM == "win32":
- WHICH_PYTHON = PREFERENCES.get("which_python", "C:\Python%d%d\python.exe" % sys.version_info[:2])
+ WHICH_PYTHON = PREFERENCES.get("which_python",
+ "C:\Python%d%d\python.exe" % sys.version_info[:2])
else:
WHICH_PYTHON = PREFERENCES.get("which_python", "")
INSTALLATION_ERROR_MESSAGE = ""
@@ -147,13 +168,16 @@ CALLER_NEED_TO_INVOKE_32_BIT = False
SET_32_BIT_ARCH = "export VERSIONER_PYTHON_PREFER_32_BIT=yes;"
if WHICH_PYTHON == "":
if OSX_APP_BUNDLED:
- proc = subprocess.Popen(["export PATH=/usr/local/bin:$PATH;which python"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc = subprocess.Popen(["export PATH=/usr/local/bin:$PATH;which python"],
+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
WHICH_PYTHON = proc.communicate()[0][:-1]
elif PLATFORM == "darwin":
- proc = subprocess.Popen(["which python"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc = subprocess.Popen(["which python"], shell=True,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
WHICH_PYTHON = proc.communicate()[0][:-1]
elif PLATFORM == "linux2":
- proc = subprocess.Popen(["which python"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc = subprocess.Popen(["which python"], shell=True,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
WHICH_PYTHON = proc.communicate()[0][:-1]
else:
### No more used on Windows ###
@@ -378,7 +402,7 @@ class MyFrame(wx.Frame):
self.frTxt.SetLabel("Freq: %.2f" % x)
self.freqPort.value = x
-app = wx.PySimpleApp()
+app = wx.App(False)
mainFrame = MyFrame(None, title='Simple App', pos=(100,100), size=(500,300))
mainFrame.Show()
app.MainLoop()
@@ -396,14 +420,92 @@ class MyFrame(wx.Frame):
if __name__ == "__main__":
- app = wx.PySimpleApp()
+ app = wx.App(False)
mainFrame = MyFrame(None, title='Simple App', pos=(100,100), size=(500,300))
mainFrame.Show()
app.MainLoop()
'''
-TEMPLATE_NAMES = {93: "Header", 94: "Pyo", 95: "WxPython", 96: "Cecilia5", 97: "Zyne", 98: "Audio Interface"}
-TEMPLATE_DICT = {93: HEADER_TEMPLATE, 94: PYO_TEMPLATE, 95: WXPYTHON_TEMPLATE, 96: CECILIA5_TEMPLATE,
- 97: ZYNE_TEMPLATE, 98: AUDIO_INTERFACE_TEMPLATE}
+
+RADIOPYO_TEMPLATE = '''#!/usr/bin/env python
+# encoding: utf-8
+"""
+Template for a RadioPyo song (version 1.0).
+
+A RadioPyo song is a musical python script using the python-pyo
+module to create the audio processing chain. You can connect to
+the radio here : http://radiopyo.acaia.ca/
+
+There is only a few rules:
+ 1 - It must be a one-page script.
+ 2 - No soundfile, only synthesis.
+ 3 - The script must be finite in time, with fade-in and fade-out
+ to avoid clicks between pieces. Use the DURATION variable.
+
+belangeo - 2014
+
+"""
+from pyo import *
+
+################### USER-DEFINED VARIABLES ###################
+### READY is used to manage the server behaviour depending ###
+### of the context. Set this variable to True when the ###
+### music is ready for the radio. TITLE and ARTIST are the ###
+### infos shown by the radio player. DURATION set the ###
+### duration of the audio file generated for the streaming.###
+##############################################################
+READY = False # Set to True when ready for the radio
+TITLE = "Song Title" # The title of the music
+ARTIST = "Artist Name" # Your artist name
+DURATION = 300 # The duration of the music in seconds
+##################### These are optional #####################
+GENRE = "Electronic" # Kind of your music, if there is any
+DATE = 2014 # Year of creation
+
+####################### SERVER CREATION ######################
+if READY:
+ s = Server(duplex=0, audio="offline").boot()
+ s.recordOptions(dur=DURATION, filename="radiopyo.ogg", fileformat=7)
+else:
+ s = Server(duplex=0).boot()
+
+
+##################### PROCESSING SECTION #####################
+# global volume (should be used to control the overall sound)
+fade = Fader(fadein=0.001, fadeout=10, dur=DURATION).play()
+
+
+###
+### Insert your algorithms here...
+###
+
+
+#################### START THE PROCESSING ###################
+s.start()
+if not READY:
+ s.gui(locals())
+'''
+
+TEMPLATE_NAMES = {98: "Header", 97: "Pyo", 96: "WxPython", 95: "Cecilia5",
+ 94: "Zyne", 93: "Audio Interface", 92: "RadioPyo"}
+TEMPLATE_DICT = {98: HEADER_TEMPLATE, 97: PYO_TEMPLATE, 96: WXPYTHON_TEMPLATE,
+ 95: CECILIA5_TEMPLATE, 94: ZYNE_TEMPLATE,
+ 93: AUDIO_INTERFACE_TEMPLATE, 92: RADIOPYO_TEMPLATE}
+
+TEMPLATE_PATH = os.path.join(RESOURCES_PATH, "templates")
+if not os.path.isdir(TEMPLATE_PATH):
+ os.mkdir(TEMPLATE_PATH)
+
+templateid = 91
+template_files = sorted([f for f in os.listdir(TEMPLATE_PATH) if f.endswith(".py")])
+for f in template_files:
+ try:
+ with open(os.path.join(TEMPLATE_PATH, f)) as ftemp:
+ ftext = ftemp.read()
+ TEMPLATE_NAMES[templateid] = f.replace(".py", "")
+ TEMPLATE_DICT[templateid] = ftext
+ templateid -= 1
+ except:
+ pass
################## BUILTIN KEYWORDS COMPLETION ##################
FROM_COMP = ''' `module` import `*`
@@ -443,8 +545,10 @@ WHILE_COMP = """ `i` `>` `0`:
"""
ASSERT_COMP = ''' `expression` `>` `0`, "`expression should be positive`"
'''
-BUILTINS_DICT = {"from": FROM_COMP, "try": TRY_COMP, "if": IF_COMP, "def": DEF_COMP, "class": CLASS_COMP,
- "for": FOR_COMP, "while": WHILE_COMP, "exec": EXEC_COMP, "raise": RAISE_COMP, "assert": ASSERT_COMP}
+BUILTINS_DICT = {"from": FROM_COMP, "try": TRY_COMP, "if": IF_COMP,
+ "def": DEF_COMP, "class": CLASS_COMP, "for": FOR_COMP,
+ "while": WHILE_COMP, "exec": EXEC_COMP, "raise": RAISE_COMP,
+ "assert": ASSERT_COMP}
################## Interface Bitmaps ##################
catalog = {}
@@ -523,6 +627,34 @@ folder_add_icon_png = PyEmbeddedImage(
"P36+7719TjKZnJPvXwAAAP//AwDmNHbvm7mEowAAAABJRU5ErkJggg==")
catalog['folder_add_icon.png'] = folder_add_icon_png
+refresh_tree_icon_png = PyEmbeddedImage(
+ "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAA"
+ "CXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wIHETgo92WyxQAABKJJREFUSMfdlVtsVFUY"
+ "hb9zmTNnZtoOLRel3ATkASiYQMI1YkTxQVMaxMQbCGJCAiY8KAY0aIQYb5CoJEo0RlEgaUwD"
+ "clOUWwABBZFIgVKQi3RaZnqdmXbOOXPO2Wf7gFTRQcFH19NO9v7X+ve/VvLDP+C56qP/dM3U"
+ "dfX8GxRuAh/Xtox3jGhFxqNnxlXcDtu9KOpPH/hk3qR2gNtX15FcNJzZH+1n3fwpACzdepI3"
+ "KysKEy7bcwGAlYcb7n73XL72pTqRmfeT8KoO+fKefV4wZqdnD9/htg6qblv1zsSrTQ5+eccf"
+ "9VtrhxX8weI9F1k1dTAvbj0e0vv0W5qP9VhxNguXuyBpSbI5sC0QdgCuABmgOdaRUGvrDOe9"
+ "iibK3jImfDpvX7mae3tj5R2bCo5o+f7LPbqKSjekstaDZxqa6xoz+UxrVkbcrDZM2mYUoYMS"
+ "BTUGgQAEqmefCucS89yS0hfkbUWPxPymys4VE7cB6NeI+wwZw1MffmEmUsnX6r6srj935MBb"
+ "ttQbLMu2AmGEVE/cpvSf9ozoMWqBVDXQwlDcDzSTgNBIO9J/F64fI2HjZdqUgiPqXzE5nk6c"
+ "G9CVbq4DRKFQGKPnTveGzfxM6uE4KlBUDpEykBIUAYog3Fhbla+ZvgVA/XN14uTBTFe6+eQN"
+ "yAGke2LtZr1p3yxFc9JENJApIAU9NCg1oWcUQlp34yr/Ad7hVdvMY2umKyUh6F0MPRUozkJf"
+ "A8ojEOue/B8e3Az6DRlJ44VT9L5nTrh93KxXZWkcYhEwQxDSIepDvARKQ9f/4KHH59yUQOOF"
+ "U5RULYt33FVVE8SLpyphUMij+A6K70C+k7iaJQjcgiarQPgBwAYMIPS7GT7QXoSWGzreuZhs"
+ "N2WvgZNkJKqg6QI9JAgZgpAhZMgQpWUxmbnYWh8c/Cx9ncAr247NzI8bU7MrKchmBOm0oLMj"
+ "T77NQqa7UFsbftXPfTPJ/XZl062MtduDEyk3+LEZMi0BVspDpFxosSDroLZdOqEdWT3XPb+9"
+ "6VYD0S1Q36XK9mawExqyKYCOALpAcXzM0xsWWue3H/8vieuOacLWpNXgI68EkDHAVsGXSFTs"
+ "0YtqYlWfDwKIzFhfkCg+4dnu84BR9/1dwGsLIOVChwOWA0KA9EFYyEDcbkf6fxWdsX6UvWnW"
+ "VcKqDwDoe+8iADLfv8/AKQuifcfNDjfU7v67AHYg6XAgZ6PkLfByELigKBDkCQJvhKWXHQo/"
+ "XL0EILN5IQBX9q4GwJy8+Mlkp7eqvbHOLLhwzPnfVTrGgC1qrvOwmdz/ut1nYrUUfowgfzWs"
+ "0gPhgCJRpe+o0tmJyDfj5gYGrjVN5tqv6Gc3VXotZ44VNFn6gaH57bVm8uijua8XNpgPvHe/"
+ "WzJ0XRCIO8EHLQRGFIwwgaabAVSiBODbaIkfdoZ+2fR8vuVM7V+90a4dSkY8KGTnlTXW1qeT"
+ "AP75HQkjHN2oGGaRDPJjCRxQFTAMMIuguAxN11v1hsNLOL52uZequ3TDndzrsXW0Vs8GoOfw"
+ "qbTV7bnuUUnvQeX5itlPiOLysUTiUUXTknrq573O7jd2SEjzv8ZvVwomHyvQ89AAAAAASUVO"
+ "RK5CYII=")
+catalog['refresh_tree_icon.png'] = refresh_tree_icon_png
+
file_delete_icon_png = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAABEZJREFU"
"eJyMVG1MW1UYfm57b1vogNLSdbotdJNkyAp+TOrYogZd4uJ+6GaYyg81auLHj7lEEpdFjfqH"
@@ -639,17 +771,23 @@ KEY_COMMANDS = {
"23. Alt + Shift + BACK": "Delete the word to the right of the caret",
"24. Ctrl/Cmd + BACK": "Delete back from the current position to the start of the line",
"25. Ctrl/Cmd + Shift + BACK": "Delete forwards from the current position to the end of the line",
-"26. TAB": "If selection is empty or all on one line replace the selection with a tab character. If more than one line selected, indent the lines. In the middle of a word, trig the AutoCompletion of pyo keywords. Just after a complete pyo keyword, insert its default arguments. Just after a complete python builtin keyword, insert a default structure snippet. Just after a variable name, representing a pyo object, followed by a dot, trig the AutoCompletion of the object's attributes.",
+"26. TAB": "If selection is empty or all on one line replace the selection with a tab character. If more than one line selected, indent the lines. In the middle of a word, trig the AutoCompletion of pyo keywords. Just after an open brace following a pyo keyword, insert its default arguments. Just after a complete python builtin keyword, insert a default structure snippet. Just after a variable name, representing a pyo object, followed by a dot, trig the AutoCompletion of the object's attributes.",
"27. Shift + TAB": "Dedent the selected lines",
"28. Alt + 'C'": "Line Copy",
"29. Alt + 'D'": "Line Duplicate",
"30. Alt + 'X'": "Line Cut",
"31. Alt + 'V'": "Line Paste",
-"32. Alt + CLICK + DRAG": "Rectangular selection"
+"32. Alt + CLICK + DRAG": "Rectangular selection",
+"33. Shit + Return": "Show the init line of a pyo object in a tooltip",
+"34. Ctrl/Cmd + Return": "Show the __doc__ string of a python object, module or function",
+"35. CLICK in the most left margin": "Add a marker to the corresponding line",
+"36. Shift + CLICK on a marker": "Delete the marker"
}
############## Allowed Extensions ##############
-ALLOWED_EXT = PREFERENCES.get("allowed_ext", ["py", "c5", "txt", "", "c", "h", "cpp", "hpp", "sh", "rst", "iss"])
+ALLOWED_EXT = PREFERENCES.get("allowed_ext",
+ ["py", "c5", "txt", "", "c", "h", "cpp", "hpp", "zy",
+ "sh", "rst", "iss", "sg", "md", "jsfx-inc", "lua", "css"])
############## Pyo keywords ##############
tree = OBJECTS_TREE
@@ -689,15 +827,23 @@ else:
STYLES_GENERALS = ['default', 'background', 'selback', 'caret']
-STYLES_TEXT_COMP = ['comment', 'commentblock', 'number', 'operator', 'string', 'triple', 'keyword', 'pyokeyword',
- 'class', 'function', 'linenumber']
-STYLES_INTER_COMP = ['marginback', 'foldmarginback', 'markerfg', 'markerbg', 'bracelight', 'bracebad', 'lineedge']
-STYLES_LABELS = {'default': 'Foreground', 'background': 'Background', 'selback': 'Selection', 'caret': 'Caret',
- 'comment': 'Comment', 'commentblock': 'Comment Block', 'number': 'Number', 'string': 'String',
- 'triple': 'Triple String', 'keyword': 'Python Keyword', 'pyokeyword': 'Pyo Keyword', 'class': 'Class Name',
- 'function': 'Function Name', 'linenumber': 'Line Number', 'operator': 'Operator', 'foldmarginback': 'Folding Margin Background',
- 'marginback': 'Number Margin Background', 'markerfg': 'Marker Foreground', 'markerbg': 'Marker Background',
- 'bracelight': 'Brace Match', 'bracebad': 'Brace Mismatch', 'lineedge': 'Line Edge'}
+STYLES_TEXT_COMP = ['comment', 'commentblock', 'number', 'operator', 'string',
+ 'triple', 'keyword', 'pyokeyword', 'class', 'function',
+ 'linenumber']
+STYLES_INTER_COMP = ['marginback', 'foldmarginback', 'markerfg', 'markerbg',
+ 'bracelight', 'bracebad', 'lineedge']
+STYLES_LABELS = {'default': 'Foreground', 'background': 'Background',
+ 'selback': 'Selection', 'caret': 'Caret', 'comment': 'Comment',
+ 'commentblock': 'Comment Block', 'number': 'Number',
+ 'string': 'String', 'triple': 'Triple String',
+ 'keyword': 'Python Keyword', 'pyokeyword': 'Pyo Keyword',
+ 'class': 'Class Name', 'function': 'Function Name',
+ 'linenumber': 'Line Number', 'operator': 'Operator',
+ 'foldmarginback': 'Folding Margin Background',
+ 'marginback': 'Number Margin Background',
+ 'markerfg': 'Marker Foreground', 'markerbg': 'Marker Background',
+ 'bracelight': 'Brace Match', 'bracebad': 'Brace Mismatch',
+ 'lineedge': 'Line Edge'}
with open(PREF_STYLE) as f:
text = f.read()
@@ -763,7 +909,6 @@ class DataEvent(wx.PyEvent):
def Clone (self):
self.__class__ (self.GetId())
-
class RunningThread(threading.Thread):
def __init__(self, path, cwd, event_receiver):
threading.Thread.__init__(self)
@@ -796,30 +941,44 @@ class RunningThread(threading.Thread):
vars_to_remove = "PYTHONHOME PYTHONPATH EXECUTABLEPATH RESOURCEPATH ARGVZERO PYTHONOPTIMIZE"
prelude = "export -n %s;export PATH=/usr/local/bin:/usr/local/lib:$PATH;" % vars_to_remove
if CALLER_NEED_TO_INVOKE_32_BIT:
- self.proc = subprocess.Popen(['%s%s%s "%s"' % (prelude, SET_32_BIT_ARCH, WHICH_PYTHON, self.path)],
- shell=True, cwd=self.cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ self.proc = subprocess.Popen(['%s%s%s -u "%s"' % (prelude, SET_32_BIT_ARCH, WHICH_PYTHON, self.path)],
+ shell=True, cwd=self.cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
- self.proc = subprocess.Popen(['%s%s "%s"' % (prelude, WHICH_PYTHON, self.path)], cwd=self.cwd,
- shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ self.proc = subprocess.Popen(['%s%s -u "%s"' % (prelude, WHICH_PYTHON, self.path)], cwd=self.cwd,
+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
elif PLATFORM == "darwin":
if CALLER_NEED_TO_INVOKE_32_BIT:
- self.proc = subprocess.Popen(['%s%s "%s"' % (SET_32_BIT_ARCH, WHICH_PYTHON, self.path)],
- shell=True, cwd=self.cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ self.proc = subprocess.Popen(['%s%s -u "%s"' % (SET_32_BIT_ARCH, WHICH_PYTHON, self.path)],
+ shell=True, cwd=self.cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
- self.proc = subprocess.Popen(['%s "%s"' % (WHICH_PYTHON, self.path)], cwd=self.cwd,
- shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ self.proc = subprocess.Popen(['%s -u "%s"' % (WHICH_PYTHON, self.path)], cwd=self.cwd,
+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
elif PLATFORM == "win32":
- self.proc = subprocess.Popen([WHICH_PYTHON, self.path], cwd=self.cwd, shell=False,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ self.proc = subprocess.Popen([WHICH_PYTHON, "-u", self.path], cwd=self.cwd, shell=False,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
- self.proc = subprocess.Popen([WHICH_PYTHON, self.path], cwd=self.cwd,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ self.proc = subprocess.Popen([WHICH_PYTHON, "-u", self.path], cwd=self.cwd,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ header = '=== Output log of process "%s", launched: %s ===\n' % (self.filename, time.strftime('"%d %b %Y %H:%M:%S"', time.localtime()))
+ data_event = DataEvent({"log": header, "pid": self.pid, "filename": self.filename, "active": True})
+ wx.PostEvent(self.event_receiver, data_event)
while self.proc.poll() == None and not self.terminated:
- time.sleep(.25)
+ log = ""
+ for line in self.proc.stdout.readline():
+ log = log + line
+ log = log.replace(">>> ", "").replace("... ", "")
+ data_event = DataEvent({"log": log, "pid": self.pid, "filename": self.filename, "active": True})
+ wx.PostEvent(self.event_receiver, data_event)
+ sys.stdout.flush()
+ time.sleep(.025)
stdout, stderr = self.proc.communicate()
- header = '=== Output log of process "%s", launched: %s ===\n' % (self.filename, time.strftime('"%d %b %Y %H:%M:%S"', time.localtime()))
- output = header + stdout + stderr
+ output = ""
+ if stdout is not None:
+ output = output + stdout
+ if stderr is not None:
+ output = output + stderr
+ output = output.replace(">>> ", "").replace("... ", "")
if "StartNotification name = default" in output:
output = output.replace("StartNotification name = default", "")
if "epyo_tempfile.py" in output:
@@ -841,17 +1000,107 @@ class RunningThread(threading.Thread):
pos += 1
elinepos = pos
linenum = int(output[slinepos:elinepos].strip())
- output = output[:slinepos] + str(linenum-2) + output[elinepos:]
+ output = output[:slinepos] + str(linenum-3) + output[elinepos:]
except:
pass
if self.terminated:
output = output + "\n=== Process killed. ==="
- data_event = DataEvent({"log": output, "pid": self.pid, "filename": self.filename})
+ data_event = DataEvent({"log": output, "pid": self.pid,
+ "filename": self.filename, "active": False})
+ wx.PostEvent(self.event_receiver, data_event)
+
+class BackgroundServerThread(threading.Thread):
+ def __init__(self, cwd, event_receiver):
+ threading.Thread.__init__(self)
+ self.cwd = cwd
+ self.event_receiver = event_receiver
+ self.terminated = False
+ self.pid = None
+
+ def setPID(self, pid):
+ self.pid = pid
+
+ def kill(self):
+ self.terminated = True
+ self.proc.stdin.write("_quit_()\n")
+ if self.proc.poll() == None:
+ self.proc.kill()
+
+ def sendText(self, text):
+ for line in text.splitlines():
+ self.proc.stdin.write(line + "\n")
+ self.proc.stdin.write("\n")
+
+ def run(self):
+ if PLATFORM == "win32":
+ self.proc = subprocess.Popen(
+ [WHICH_PYTHON, '-i', os.path.join(TEMP_PATH, "background_server.py")],
+ shell=True, cwd=self.cwd, stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
+ else:
+ self.proc = subprocess.Popen(
+ ["%s -i -u %s" % (WHICH_PYTHON, os.path.join(TEMP_PATH, "background_server.py"))],
+ cwd=self.cwd, shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, stdin=subprocess.PIPE)
+
+ header = '=== Output log of background server, launched: %s ===\n' % time.strftime('"%d %b %Y %H:%M:%S"', time.localtime())
+ data_event = DataEvent({"log": header, "pid": self.pid,
+ "filename": 'background_server.py',
+ "active": True})
+ wx.PostEvent(self.event_receiver, data_event)
+ while self.proc.poll() == None and not self.terminated:
+ log = ""
+ for line in self.proc.stdout.readline():
+ log = log + line
+ log = log.replace(">>> ", "").replace("... ", "")
+ data_event = DataEvent({"log": log, "pid": self.pid,
+ "filename": 'background_server.py',
+ "active": True})
+ wx.PostEvent(self.event_receiver, data_event)
+ sys.stdout.flush()
+ time.sleep(.025)
+ stdout, stderr = self.proc.communicate()
+ output = ""
+ if stdout is not None:
+ output = output + stdout
+ if stderr is not None:
+ output = output + stderr
+ output = output.replace(">>> ", "").replace("... ", "")
+ if "StartNotification name = default" in output:
+ output = output.replace("StartNotification name = default", "")
+ if "background_server.py" in output:
+ try:
+ findpos = output.find("background_server.py")
+ pos = findpos
+ while (output[pos] != '"'):
+ pos -= 1
+ startpos = pos + 1
+ pos = findpos
+ while (output[pos] != '"'):
+ pos += 1
+ endpos = pos
+ output = output[:startpos] + self.filename + output[endpos:]
+ pos = startpos + len(self.filename)
+ slinepos = pos + 8
+ pos = slinepos
+ while (output[pos] != ',' and output[pos] != '\n'):
+ pos += 1
+ elinepos = pos
+ linenum = int(output[slinepos:elinepos].strip())
+ output = output[:slinepos] + str(linenum-3) + output[elinepos:]
+ except:
+ pass
+ if self.terminated:
+ output = output + "\n=== Process killed. ==="
+ data_event = DataEvent({"log": output, "pid": self.pid,
+ "filename": 'background_server.py',
+ "active": False})
wx.PostEvent(self.event_receiver, data_event)
class KeyCommandsFrame(wx.Frame):
def __init__(self, parent):
- wx.Frame.__init__(self, parent, wx.ID_ANY, title="Editor Key Commands List", size=(650,550))
+ wx.Frame.__init__(self, parent, wx.ID_ANY,
+ title="Editor Key Commands List", size=(650,550))
self.menuBar = wx.MenuBar()
menu1 = wx.Menu()
menu1.Append(351, "Close\tCtrl+W")
@@ -881,7 +1130,8 @@ class KeyCommandsFrame(wx.Frame):
self.Hide()
class EditorPreview(stc.StyledTextCtrl):
- def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style= wx.SUNKEN_BORDER | wx.WANTS_CHARS):
+ def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize,
+ style= wx.SUNKEN_BORDER | wx.WANTS_CHARS):
stc.StyledTextCtrl.__init__(self, parent, ID, pos, size, style)
self.SetSTCCursor(2)
@@ -985,6 +1235,9 @@ class EditorPreview(stc.StyledTextCtrl):
self.SetFoldMarginHiColour(True, STYLES['foldmarginback']['colour'])
self.SetEdgeColumn(60)
+ # WxPython 3 needs the lexer to be set before folding property
+ self.SetProperty("fold", "1")
+
class ComponentPanel(scrolled.ScrolledPanel):
def __init__(self, parent, size):
scrolled.ScrolledPanel.__init__(self, parent, wx.ID_ANY, pos=(0,0), size=size, style=wx.SUNKEN_BORDER)
@@ -998,17 +1251,17 @@ class ComponentPanel(scrolled.ScrolledPanel):
box = wx.BoxSizer(wx.HORIZONTAL)
label = wx.StaticText(self, wx.ID_ANY, label=STYLES_LABELS[component])
box.Add(label, 1, wx.EXPAND|wx.TOP|wx.LEFT, 3)
- btog = wx.ToggleButton(self, wx.ID_ANY, label="B", size=(20,20))
+ btog = wx.ToggleButton(self, wx.ID_ANY, label="B", size=(24,20))
btog.SetValue(STYLES[component]['bold'])
box.Add(btog, 0, wx.TOP|wx.ALIGN_RIGHT, 1)
btog.Bind(wx.EVT_TOGGLEBUTTON, self.OnBToggleButton)
self.bTogRefs[btog] = component
- itog = wx.ToggleButton(self, wx.ID_ANY, label="I", size=(20,20))
+ itog = wx.ToggleButton(self, wx.ID_ANY, label="I", size=(24,20))
itog.SetValue(STYLES[component]['italic'])
box.Add(itog, 0, wx.TOP|wx.ALIGN_RIGHT, 1)
itog.Bind(wx.EVT_TOGGLEBUTTON, self.OnIToggleButton)
self.iTogRefs[itog] = component
- utog = wx.ToggleButton(self, wx.ID_ANY, label="U", size=(20,20))
+ utog = wx.ToggleButton(self, wx.ID_ANY, label="U", size=(24,20))
utog.SetValue(STYLES[component]['underline'])
box.Add(utog, 0, wx.TOP|wx.ALIGN_RIGHT, 1)
utog.Bind(wx.EVT_TOGGLEBUTTON, self.OnUToggleButton)
@@ -1092,7 +1345,12 @@ class ColourEditor(wx.Frame):
self.cur_style = ""
- toolbar = self.CreateToolBar()
+ self.panel = wx.Panel(self)
+ self.panel.SetAutoLayout(True)
+ mainSizer = wx.BoxSizer(wx.VERTICAL)
+ self.panel.SetSizer(mainSizer)
+
+ toolbar = wx.ToolBar(self.panel, -1)
saveButton = wx.Button(toolbar, wx.ID_ANY, label="Save Style")
saveButton.Bind(wx.EVT_BUTTON, self.OnSave)
toolbar.AddControl(saveButton)
@@ -1109,25 +1367,22 @@ class ColourEditor(wx.Frame):
toolbar.AddControl(deleteButton)
toolbar.Realize()
- self.panel = wx.Panel(self)
- self.panel.SetAutoLayout(True)
- mainSizer = wx.BoxSizer(wx.VERTICAL)
- self.panel.SetSizer(mainSizer)
+ mainSizer.Add(toolbar, 0, wx.EXPAND)
enum = wx.FontEnumerator()
enum.EnumerateFacenames(fixedWidthOnly=True)
facelist = enum.GetFacenames()
facelist.sort()
- buttonData = [ (STYLES_GENERALS[0], STYLES['default']['colour'], (50, 20), STYLES_LABELS['default']),
- (STYLES_GENERALS[1], STYLES['background']['colour'], (50, 20), STYLES_LABELS['background']),
- (STYLES_GENERALS[2], STYLES['selback']['colour'], (50, 20), STYLES_LABELS['selback']),
- (STYLES_GENERALS[3], STYLES['caret']['colour'], (50, 20), STYLES_LABELS['caret']) ]
+ buttonData = [ (STYLES_GENERALS[0], STYLES['default']['colour'], (50, 24), STYLES_LABELS['default']),
+ (STYLES_GENERALS[1], STYLES['background']['colour'], (50, 24), STYLES_LABELS['background']),
+ (STYLES_GENERALS[2], STYLES['selback']['colour'], (50, 24), STYLES_LABELS['selback']),
+ (STYLES_GENERALS[3], STYLES['caret']['colour'], (50, 24), STYLES_LABELS['caret']) ]
self.buttonRefs = {}
section1Sizer = wx.BoxSizer(wx.HORIZONTAL)
- buttonSizer1 = wx.FlexGridSizer(1, 2, 25, 5)
+ buttonSizer1 = wx.FlexGridSizer(0, 2, 25, 5)
for name, color, size, label in buttonData[:2]:
b = csel.ColourSelect(self.panel, -1, "", hex_to_rgb(color), size=size)
b.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour)
@@ -1136,7 +1391,7 @@ class ColourEditor(wx.Frame):
(b, 0, wx.LEFT|wx.RIGHT, 5)])
section1Sizer.Add(buttonSizer1, 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP|wx.ALIGN_LEFT, 10)
section1Sizer.AddSpacer(110)
- buttonSizer2 = wx.FlexGridSizer(1, 2, 25, 5)
+ buttonSizer2 = wx.FlexGridSizer(0, 2, 25, 5)
for name, color, size, label in buttonData[2:4]:
b = csel.ColourSelect(self.panel, -1, "", hex_to_rgb(color), size=size)
b.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour)
@@ -1292,6 +1547,7 @@ class SearchProjectPanel(scrolled.ScrolledPanel):
class SearchProjectFrame(wx.Frame):
def __init__(self, parent, root, dict, size=(500,500)):
wx.Frame.__init__(self, parent, wx.ID_ANY, size=size)
+ self.SetTitle('Search Results in Project "%s"' % os.path.split(root)[1])
self.menuBar = wx.MenuBar()
menu1 = wx.Menu()
menu1.Append(351, "Close\tCtrl+W")
@@ -1318,7 +1574,7 @@ class SnippetTree(wx.Panel):
self.sizer = wx.BoxSizer(wx.VERTICAL)
toolbarbox = wx.BoxSizer(wx.HORIZONTAL)
- self.toolbar = wx.ToolBar(self, -1, size=(-1,36))
+ self.toolbar = wx.ToolBar(self, -1)
self.toolbar.SetToolBitmapSize(tsize)
self.toolbar.AddLabelTool(SNIPPET_ADD_FOLDER_ID, "Add Category", folder_add_bmp, shortHelp="Add a New Category")
self.toolbar.AddLabelTool(SNIPPET_DEL_FILE_ID, "Delete", file_add_bmp, shortHelp="Delete Snippet or Category")
@@ -1436,7 +1692,7 @@ class SnippetTree(wx.Panel):
name = self.tree.GetItemText(item)
ritem = self.tree.GetItemParent(item)
category = self.tree.GetItemText(ritem)
- self.GetParent().GetParent().onLoad(name, category)
+ self.GetParent().GetParent().onLoad(name, category)
def select(self, item):
self.tree.SelectItem(item)
@@ -1531,13 +1787,12 @@ class SnippetFrame(wx.Frame):
saveButton = wx.Button(self.toolbar, wx.ID_ANY, label="Save Snippet")
self.toolbar.AddControl(saveButton)
self.Bind(wx.EVT_BUTTON, self.onSave, id=saveButton.GetId())
-
+ self.toolbar.Realize()
+
toolbarBox.Add(self.toolbar, 1, wx.ALIGN_LEFT|wx.EXPAND|wx.LEFT, 5)
toolbar2 = wx.ToolBar(self.panel, -1)
self.tagButton = wx.Button(toolbar2, wx.ID_ANY, label="Tag Selection")
- X = self.tagButton.GetSize()[0]
- toolbar2.SetSize((X+8, 40))
toolbar2.AddControl(self.tagButton)
self.Bind(wx.EVT_BUTTON, self.onTagSelection, id=self.tagButton.GetId())
toolbar2.Realize()
@@ -1594,6 +1849,7 @@ class SnippetFrame(wx.Frame):
def onSave(self, evt):
dlg = wx.SingleChoiceDialog(self, 'Choose the Snippet Category',
'Snippet Category', SNIPPETS_CATEGORIES, wx.OK)
+ dlg.SetSize((250,300))
dlg.CenterOnParent()
if dlg.ShowModal() == wx.ID_OK:
category = dlg.GetStringSelection()
@@ -1789,6 +2045,14 @@ class MainFrame(wx.Frame):
EVT_DATA_EVENT(self, self.format_outputLog)
+ if sys.platform == "darwin":
+ accel_ctrl = wx.ACCEL_CMD
+ else:
+ accel_ctrl = wx.ACCEL_CTRL
+ # To set up an accelerator key
+ #aEntry = wx.AcceleratorEntry(accel_ctrl|wx.ACCEL_SHIFT, wx.WXK_UP, 602)
+ # "\t%s" % aEntry.ToString()
+
self.snippet_frame = SnippetFrame(self, title='Snippet Editor', pos=(25,25), size=(700,450))
self.style_frame = ColourEditor(self, title='Style Editor', pos=(100,100), size=(500,550))
self.style_frame.setCurrentStyle(PREF_STYLE)
@@ -1797,6 +2061,7 @@ class MainFrame(wx.Frame):
self.server_pipe = None
self.back_server_started = False
+ self.master_document = None
self.processID = 0
self.processes = {}
self.filters = {}
@@ -1813,7 +2078,7 @@ class MainFrame(wx.Frame):
menu1.Append(wx.ID_NEW, "New\tCtrl+N")
self.Bind(wx.EVT_MENU, self.new, id=wx.ID_NEW)
self.submenu1 = wx.Menu()
- for key, name in sorted(TEMPLATE_NAMES.items()):
+ for key, name in sorted(TEMPLATE_NAMES.items(), reverse=True):
self.submenu1.Append(key, "%s Template" % name)
menu1.AppendMenu(99, "New From Template", self.submenu1)
self.Bind(wx.EVT_MENU, self.newFromTemplate, id=min(TEMPLATE_NAMES.keys()), id2=max(TEMPLATE_NAMES.keys()))
@@ -1849,11 +2114,14 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.save, id=wx.ID_SAVE)
menu1.Append(wx.ID_SAVEAS, "Save As...\tShift+Ctrl+S")
self.Bind(wx.EVT_MENU, self.saveas, id=wx.ID_SAVEAS)
- menu1.AppendSeparator()
- menu1.Append(wx.ID_PREVIEW, "Print Preview")
- self.Bind(wx.EVT_MENU, self.OnPrintPreview, id=wx.ID_PREVIEW)
- menu1.Append(wx.ID_PRINT, "Print\tCtrl+P")
- self.Bind(wx.EVT_MENU, self.OnPrint, id=wx.ID_PRINT)
+ menu1.Append(100, "Save As Template...")
+ self.Bind(wx.EVT_MENU, self.saveasTemplate, id=100)
+ # TODO : printing not working well enough
+ #menu1.AppendSeparator()
+ #menu1.Append(wx.ID_PREVIEW, "Print Preview")
+ #self.Bind(wx.EVT_MENU, self.OnPrintPreview, id=wx.ID_PREVIEW)
+ #menu1.Append(wx.ID_PRINT, "Print\tCtrl+P")
+ #self.Bind(wx.EVT_MENU, self.OnPrint, id=wx.ID_PRINT)
if sys.platform != "darwin":
menu1.AppendSeparator()
prefItem = menu1.Append(wx.ID_PREFERENCES, "Preferences...\tCtrl+;")
@@ -1892,20 +2160,35 @@ class MainFrame(wx.Frame):
menu2.Append(107, "Remove Trailing White Space")
self.Bind(wx.EVT_MENU, self.removeTrailingWhiteSpace, id=107)
menu2.AppendSeparator()
- menu2.Append(103, "Collapse/Expand\tCtrl+I")
+ menu2.Append(103, "Fold All\tCtrl+I")
self.Bind(wx.EVT_MENU, self.fold, id=103)
+ menu2.Append(104, "Expand All\tShift+Ctrl+I")
+ self.Bind(wx.EVT_MENU, self.fold, id=104)
+ menu2.Append(105, "Fold/Expand Current Scope\tCtrl+8")
+ self.Bind(wx.EVT_MENU, self.foldExpandScope, id=105)
menu2.Append(108, "Un/Comment Selection\tCtrl+J")
self.Bind(wx.EVT_MENU, self.OnComment, id=108)
- menu2.Append(114, "Show AutoCompletion\tCtrl+K")
- self.Bind(wx.EVT_MENU, self.autoComp, id=114)
menu2.Append(121, "Insert File Path...\tShift+Ctrl+P")
self.Bind(wx.EVT_MENU, self.insertPath, id=121)
menu2.AppendSeparator()
- menu2.Append(170, "Convert Selection to Uppercase\tCtrl+U")
- menu2.Append(171, "Convert Selection to Lowercase\tShift+Ctrl+U")
+ submenublk = wx.Menu()
+ submenublk.Append(400, "Insert Code Block Head\tCtrl+B")
+ submenublk.Append(401, "Insert Code Block Tail\tShift+Ctrl+B")
+ submenublk.Append(402, "Select Code Block\tCtrl+,")
+ self.Bind(wx.EVT_MENU, self.onCodeBlock, id=400, id2=402)
+ menu2.AppendMenu(-1, "Code Blocks", submenublk)
+ menu2.AppendSeparator()
+ menu2.Append(114, "Auto Complete container syntax", kind=wx.ITEM_CHECK)
+ self.Bind(wx.EVT_MENU, self.autoCompContainer, id=114)
+ menu2.Check(114, PREFERENCES.get("auto_comp_container", 0))
+ menu2.AppendSeparator()
+ submenu2 = wx.Menu()
+ submenu2.Append(170, "Convert Selection to Uppercase\tCtrl+U")
+ submenu2.Append(171, "Convert Selection to Lowercase\tShift+Ctrl+U")
self.Bind(wx.EVT_MENU, self.upperLower, id=170, id2=171)
- menu2.Append(172, "Convert Tabs to Spaces")
+ submenu2.Append(172, "Convert Tabs to Spaces")
self.Bind(wx.EVT_MENU, self.tabsToSpaces, id=172)
+ menu2.AppendMenu(-1, "Text Converters", submenu2)
menu2.AppendSeparator()
menu2.Append(140, "Goto line...\tCtrl+L")
self.Bind(wx.EVT_MENU, self.gotoLine, id=140)
@@ -1922,22 +2205,25 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.showFind, id=wx.ID_FIND)
self.menuBar.Append(menu2, 'Code')
- menu3 = wx.Menu()
- menu3.Append(300, "Run\tCtrl+R")
+ self.menu3 = wx.Menu()
+ self.menu3.Append(299, "Set Current Document as Master")
+ self.Bind(wx.EVT_MENU, self.setMasterDocument, id=299)
+ self.menu3.AppendSeparator()
+ self.menu3.Append(300, "Run\tCtrl+R")
self.Bind(wx.EVT_MENU, self.runner, id=300)
- menu3.Append(301, "Run Selection\tShift+Ctrl+R")
+ self.menu3.Append(301, "Run Selection\tShift+Ctrl+R")
self.Bind(wx.EVT_MENU, self.runSelection, id=301)
- menu3.Append(302, "Run Line/Selection as Pyo\tCtrl+E")
+ self.menu3.Append(302, "Run Line/Selection as Pyo\tCtrl+E")
self.Bind(wx.EVT_MENU, self.runSelectionAsPyo, id=302)
- menu3.Append(303, "Execute Line/Selection as Python\tShift+Ctrl+E")
+ self.menu3.Append(303, "Execute Line/Selection as Python\tShift+Ctrl+E")
self.Bind(wx.EVT_MENU, self.execSelection, id=303)
- menu3.AppendSeparator()
- self.backServerItem = menu3.Append(304, "Start Pyo Background Server")
+ self.menu3.AppendSeparator()
+ self.backServerItem = self.menu3.Append(304, "Start Pyo Background Server")
self.Bind(wx.EVT_MENU, self.startStopBackgroundServer, id=304)
- self.sendToServerItem = menu3.Append(305, "Send Line/Selection to Pyo Background Server\tCtrl+T")
+ self.sendToServerItem = self.menu3.Append(305, "Send Line/Selection to Pyo Background Server\tCtrl+.")
self.sendToServerItem.Enable(False)
self.Bind(wx.EVT_MENU, self.sendSelectionToBackgroundServer, id=305)
- self.menuBar.Append(menu3, 'Process')
+ self.menuBar.Append(self.menu3, 'Process')
menu4 = wx.Menu()
menu4.Append(wx.ID_ZOOM_IN, "Zoom in\tCtrl+=")
@@ -1965,6 +2251,10 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.showDocFrame, id=190)
menu4.Append(180, "Open Documentation for Pyo Object Under Caret\tCtrl+D")
self.Bind(wx.EVT_MENU, self.showDoc, id=180)
+ menu4.Append(181, "Show args for Pyo Object Under Caret\tShift+Return")
+ self.Bind(wx.EVT_MENU, self.showArgs, id=181)
+ menu4.Append(182, "Show __doc__ String for Word Under Caret\tCtrl+Return")
+ self.Bind(wx.EVT_MENU, self.showDocString, id=182)
menu4.AppendSeparator()
menu4.Append(185, "Rebuild Documentation")
self.Bind(wx.EVT_MENU, self.rebuildDoc, id=185)
@@ -1987,11 +2277,6 @@ class MainFrame(wx.Frame):
self.makeSnippetMenu()
self.menuBar.Append(self.menu7, "Snippets")
- if sys.platform == "darwin":
- accel_ctrl = wx.ACCEL_CMD
- else:
- accel_ctrl = wx.ACCEL_CTRL
-
menu8 = wx.Menu()
menu8.Append(600, "Add Marker to Current Line\tShift+Ctrl+M")
self.Bind(wx.EVT_MENU, self.addMarker, id=600)
@@ -2000,17 +2285,15 @@ class MainFrame(wx.Frame):
menu8.Append(604, "Delete All Markers")
self.Bind(wx.EVT_MENU, self.deleteAllMarkers, id=604)
menu8.AppendSeparator()
- aEntry = wx.AcceleratorEntry(accel_ctrl|wx.ACCEL_SHIFT, wx.WXK_UP, 602)
- menu8.Append(602, 'Navigate Markers Upward\t%s' % aEntry.ToString())
- aEntry = wx.AcceleratorEntry(accel_ctrl|wx.ACCEL_SHIFT, wx.WXK_DOWN, 603)
- menu8.Append(603, 'Navigate Markers Downward\t%s' % aEntry.ToString())
+ menu8.Append(602, 'Navigate Markers Upward\tCtrl+9')
+ menu8.Append(603, 'Navigate Markers Downward\tCtrl+0')
self.Bind(wx.EVT_MENU, self.navigateMarkers, id=602, id2=603)
self.menuBar.Append(menu8, "Markers")
self.menu6 = wx.Menu()
ID_EXAMPLE = 1000
for folder in EXAMPLE_FOLDERS:
- exmenu = wx.Menu(title=folder.lower())
+ exmenu = wx.Menu(folder.lower())
for ex in sorted([exp for exp in os.listdir(os.path.join(EXAMPLE_PATH, folder.lower())) if exp[0] != "." and not exp.endswith("pyc")]):
exmenu.Append(ID_EXAMPLE, ex)
ID_EXAMPLE += 1
@@ -2052,22 +2335,23 @@ class MainFrame(wx.Frame):
self.SetMenuBar(self.menuBar)
+ self.status = self.CreateStatusBar()
+ self.status.Bind(wx.EVT_SIZE, self.StatusOnSize)
+ self.status.SetFieldsCount(3)
+
if PLATFORM == "darwin":
ststyle = wx.TE_PROCESS_ENTER|wx.NO_BORDER
- sth = 17
+ sth = self.status.GetSize()[1] #16
cch = -1
elif PLATFORM == "linux2":
ststyle = wx.TE_PROCESS_ENTER|wx.SIMPLE_BORDER
- sth = 20
- cch = 21
+ sth = self.status.GetSize()[1]+1 #20
+ cch = self.status.GetSize()[1] #21
elif PLATFORM == "win32":
ststyle = wx.TE_PROCESS_ENTER|wx.SIMPLE_BORDER
sth = 20
cch = 20
- self.status = self.CreateStatusBar()
- self.status.Bind(wx.EVT_SIZE, self.StatusOnSize)
- self.status.SetFieldsCount(3)
self.field1X, field1Y = self.status.GetTextExtent("Quick Search:")
self.status.SetStatusWidths([self.field1X+9,-1,-2])
self.status.SetStatusText("Quick Search:", 0)
@@ -2104,11 +2388,11 @@ class MainFrame(wx.Frame):
yoff1 = -1
yoff2 = -5
elif PLATFORM == "linux2":
- yoff1 = 1
- yoff2 = 0
- elif PLATFORM == "win32":
yoff1 = -2
- yoff2 = -2
+ yoff2 = -1
+ elif PLATFORM == "win32":
+ yoff1 = 0
+ yoff2 = -1
self.status.SetStatusText("Quick Search:", 0)
rect = self.status.GetFieldRect(1)
@@ -2117,6 +2401,22 @@ class MainFrame(wx.Frame):
if rect.x > self.field1X+160:
self.cc.SetPosition((rect.x, rect.y+yoff2))
+ def onCodeBlock(self, evt):
+ if evt.GetId() == 400:
+ self.panel.editor.insertBlockHead()
+ elif evt.GetId() == 401:
+ self.panel.editor.insertBlockTail()
+ elif evt.GetId() == 402:
+ self.panel.editor.selectCodeBlock()
+
+ def setMasterDocument(self, evt):
+ if self.master_document == None:
+ self.master_document = self.panel.editor.path
+ self.menu3.SetLabel(299, "Revert Master Document to None")
+ else:
+ self.master_document = None
+ self.menu3.SetLabel(299, "Set Current Document as Master")
+
def StatusOnSize(self, evt):
self.Reposition()
@@ -2142,6 +2442,7 @@ class MainFrame(wx.Frame):
def makeSnippetMenu(self):
itemId = 30000
+ accel_entries = []
for cat in SNIPPETS_CATEGORIES:
submenu = wx.Menu(title=cat)
files = [f for f in os.listdir(os.path.join(SNIPPETS_PATH, cat))]
@@ -2171,6 +2472,7 @@ class MainFrame(wx.Frame):
short = short.replace("-", "")
if short != "":
accel_tuple = wx.AcceleratorEntry(accel, ord(short), itemId)
+ accel_entries.append(accel_tuple)
short = accel_tuple.ToString()
submenu.Append(itemId, "%s\t%s" % (file, short))
else:
@@ -2179,6 +2481,10 @@ class MainFrame(wx.Frame):
itemId += 1
self.menu7.AppendMenu(itemId, cat, submenu)
itemId += 1
+ if accel_entries != []:
+ accel_table = wx.AcceleratorTable(accel_entries)
+ self.SetAcceleratorTable(accel_table)
+
self.menu7.AppendSeparator()
self.menu7.Append(51, "Open Snippet Editor")
self.Bind(wx.EVT_MENU, self.showSnippetEditor, id=51)
@@ -2318,7 +2624,6 @@ class MainFrame(wx.Frame):
def addMarker(self, evt):
line = self.panel.editor.GetCurrentLine()
self.panel.editor.addMarker(line)
- self.panel.editor.addMarkerComment(line)
def deleteMarker(self, evt):
line = self.panel.editor.GetCurrentLine()
@@ -2341,25 +2646,37 @@ class MainFrame(wx.Frame):
val = int(dlg.GetValue())
except:
val = -1
- dlg.Destroy()
+ dlg.Destroy()
if val != -1:
- pos = self.panel.editor.FindColumn(val-1, 0)
- self.panel.editor.SetCurrentPos(pos)
- self.panel.editor.EnsureVisible(val)
- self.panel.editor.EnsureCaretVisible()
+ val -= 1
+ pos = self.panel.editor.FindColumn(val, 0)
+ self.panel.editor.GotoLine(val)
+ first = self.panel.editor.GetFirstVisibleLine()
+ if val == first:
+ self.panel.editor.LineScroll(0, -self.panel.editor.LinesOnScreen()/2)
+ else:
+ self.panel.editor.LineScroll(0, self.panel.editor.LinesOnScreen()/2)
+ #self.panel.editor.SetCurrentPos(pos)
+ #self.panel.editor.EnsureVisible(val)
+ #self.panel.editor.EnsureCaretVisible()
wx.CallAfter(self.panel.editor.SetAnchor, pos)
def OnComment(self, evt):
self.panel.editor.OnComment()
def fold(self, event):
- self.panel.editor.FoldAll()
+ if event.GetId() == 103:
+ self.panel.editor.FoldAll()
+ else:
+ self.panel.editor.ExpandAll()
- def autoComp(self, evt):
- try:
- self.panel.editor.showAutoComp()
- except AttributeError:
- pass
+ def foldExpandScope(self, evt):
+ self.panel.editor.foldExpandCurrentScope()
+
+ def autoCompContainer(self, evt):
+ state = evt.GetInt()
+ PREFERENCES["auto_comp_container"] = state
+ self.panel.editor.showAutoCompContainer(state)
def showFind(self, evt):
self.panel.editor.OnShowFindReplace()
@@ -2481,7 +2798,7 @@ class MainFrame(wx.Frame):
def insertSnippet(self, evt):
id = evt.GetId()
- menu = self.menu7 #event.GetEventObject()
+ menu = self.menu7
item = menu.FindItemById(id)
name = item.GetLabel()
category = item.GetMenu().GetTitle()
@@ -2735,12 +3052,28 @@ class MainFrame(wx.Frame):
PREFERENCES["save_file_path"] = os.path.split(path)[0]
dlg.Destroy()
+ def saveasTemplate(self, event):
+ dlg = wx.TextEntryDialog(self, 'Give a name to your template:', 'Save file as template...')
+ if dlg.ShowModal() == wx.ID_OK:
+ fname = dlg.GetValue()
+ if not fname.endswith(".py"):
+ fname = fname + ".py"
+ try:
+ text = self.panel.editor.GetTextUTF8()
+ except:
+ text = self.panel.editor.GetText()
+ with open(os.path.join(TEMPLATE_PATH, fname), "w") as f:
+ f.write(text)
+ dlg.Destroy()
+
def close(self, event):
action = self.panel.editor.close()
if action == 'delete':
+ self.panel.close_from_menu = True
self.panel.deletePage()
else:
pass
+ self.panel.close_from_menu = False
def closeAll(self, event):
count = self.panel.notebook.GetPageCount()
@@ -2751,7 +3084,10 @@ class MainFrame(wx.Frame):
### Run actions ###
def getCurrentWorkingDirectory(self):
- path = ensureNFD(self.panel.editor.path)
+ if self.master_document != None:
+ path = ensureNFD(self.master_document)
+ else:
+ path = ensureNFD(self.panel.editor.path)
cwd = os.path.expanduser("~")
if os.path.isfile(path):
try:
@@ -2773,13 +3109,16 @@ class MainFrame(wx.Frame):
def format_outputLog(self, evt):
data = evt.data
- self.panel.outputlog.setLog(data["log"])
- self.panel.outputlog.removeProcess(data["pid"], data["filename"])
+ self.panel.outputlog.appendToLog(data["log"])
+ if not data["active"]:
+ self.panel.outputlog.removeProcess(data["pid"], data["filename"])
def run(self, path):
cwd = self.getCurrentWorkingDirectory()
th = RunningThread(path, cwd, self)
- if "Untitled-" in self.panel.editor.path:
+ if self.master_document != None:
+ filename = os.path.split(self.master_document)[1]
+ elif "Untitled-" in self.panel.editor.path:
filename = self.panel.editor.path
else:
filename = os.path.split(self.panel.editor.path)[1]
@@ -2791,7 +3130,11 @@ class MainFrame(wx.Frame):
th.start()
def runner(self, event):
- text = self.panel.editor.GetTextUTF8()
+ if self.master_document != None:
+ with open(self.master_document, "r") as f:
+ text = f.read()
+ else:
+ text = self.panel.editor.GetTextUTF8()
if text != "":
text = self.addCwdToSysPath(text)
with open(TEMP_FILE, "w") as f:
@@ -2837,72 +3180,94 @@ class MainFrame(wx.Frame):
exec text
self.panel.editor.addText(s.getvalue())
+ def prepareBackgroundServer(self):
+ outDriverIndex = -1
+ preferedDriver = PREFERENCES.get("background_server_out_device", "")
+ if preferedDriver != "":
+ driverList, driverIndexes = pa_get_output_devices()
+ driverList = [ensureNFD(driver) for driver in driverList]
+ if preferedDriver and preferedDriver in driverList:
+ outDriverIndex = driverIndexes[driverList.index(preferedDriver)]
+
+ inDriverIndex = -1
+ preferedDriver = PREFERENCES.get("background_server_in_device", "")
+ if preferedDriver != "":
+ driverList, driverIndexes = pa_get_input_devices()
+ driverList = [ensureNFD(driver) for driver in driverList]
+ if preferedDriver and preferedDriver in driverList:
+ inDriverIndex = driverIndexes[driverList.index(preferedDriver)]
+
+ midiOutDriverIndex = -1
+ preferedDriver = PREFERENCES.get("background_server_midiout_device", "")
+ if preferedDriver != "":
+ driverList, driverIndexes = pm_get_output_devices()
+ driverList = [ensureNFD(driver) for driver in driverList]
+ if preferedDriver and preferedDriver in driverList:
+ midiOutDriverIndex = driverIndexes[driverList.index(preferedDriver)]
+
+ midiInDriverIndex = -1
+ preferedDriver = PREFERENCES.get("background_server_midiin_device", "")
+ if preferedDriver != "":
+ driverList, driverIndexes = pm_get_input_devices()
+ driverList = [ensureNFD(driver) for driver in driverList]
+ if preferedDriver and preferedDriver in driverList:
+ midiInDriverIndex = driverIndexes[driverList.index(preferedDriver)]
+
+ with open(os.path.join(TEMP_PATH, "background_server.py"), "w") as f:
+ f.write("print 'Starting background server...'\nimport time\nfrom pyo import *\n")
+ f.write("s = Server(%s)\n" % BACKGROUND_SERVER_ARGS)
+ if outDriverIndex != -1:
+ f.write("s.setOutputDevice(%d)\n" % outDriverIndex)
+ if inDriverIndex != -1:
+ f.write("s.setInputDevice(%d)\n" % inDriverIndex)
+ if midiOutDriverIndex != -1:
+ f.write("s.setMidiOutputDevice(%d)\n" % midiOutDriverIndex)
+ if midiInDriverIndex != -1:
+ f.write("s.setMidiInputDevice(%d)\n" % midiInDriverIndex)
+ f.write("s.boot()\ns.start()\n\n")
+ f.write("def _quit_():\n s.stop()\n time.sleep(0.25)\n exit()\n")
+
+ def resetBackgroundServerMenu(self):
+ self.back_server_started = False
+ self.backServerItem.SetItemLabel("Start Pyo Background Server")
+ self.sendToServerItem.Enable(False)
+
def startStopBackgroundServer(self, evt):
if not self.back_server_started:
- outDriverIndex = -1
- preferedDriver = PREFERENCES.get("background_server_out_device", "")
- if preferedDriver != "":
- driverList, driverIndexes = pa_get_output_devices()
- driverList = [ensureNFD(driver) for driver in driverList]
- if preferedDriver and preferedDriver in driverList:
- outDriverIndex = driverIndexes[driverList.index(preferedDriver)]
-
- inDriverIndex = -1
- preferedDriver = PREFERENCES.get("background_server_in_device", "")
- if preferedDriver != "":
- driverList, driverIndexes = pa_get_input_devices()
- driverList = [ensureNFD(driver) for driver in driverList]
- if preferedDriver and preferedDriver in driverList:
- inDriverIndex = driverIndexes[driverList.index(preferedDriver)]
-
- midiInDriverIndex = -1
- preferedDriver = PREFERENCES.get("background_server_midiin_device", "")
- if preferedDriver != "":
- driverList, driverIndexes = pm_get_input_devices()
- driverList = [ensureNFD(driver) for driver in driverList]
- if preferedDriver and preferedDriver in driverList:
- midiInDriverIndex = driverIndexes[driverList.index(preferedDriver)]
-
- with open(os.path.join(TEMP_PATH, "background_server.py"), "w") as f:
- f.write("print 'Starting background server...'\nimport time\nfrom pyo import *\n")
- f.write("s = Server(%s)\n" % BACKGROUND_SERVER_ARGS)
- if outDriverIndex != -1:
- f.write("s.setOutputDevice(%d)\n" % outDriverIndex)
- if inDriverIndex != -1:
- f.write("s.setInputDevice(%d)\n" % inDriverIndex)
- if midiInDriverIndex != -1:
- f.write("s.setMidiInputDevice(%d)\n" % midiInDriverIndex)
- f.write("s.boot()\ns.start()\n")
- if PLATFORM == "win32":
- self.server_pipe = subprocess.Popen([WHICH_PYTHON, '-i', 'background_server.py'],
- shell=True, cwd=TEMP_PATH, stdin=subprocess.PIPE).stdin
- else:
- self.server_pipe = subprocess.Popen(["%s -i %s" % (WHICH_PYTHON, os.path.join(TEMP_PATH, "background_server.py"))],
- shell=True, stdin=subprocess.PIPE).stdin
+ self.prepareBackgroundServer()
+ cwd = self.getCurrentWorkingDirectory()
+ th = BackgroundServerThread(cwd, self)
+ th.setPID(1000)
+ self.processes[1000] = [th, 'background_server.py']
+ self.panel.outputlog.addProcess(1000, 'background_server.py')
+ th.start()
self.back_server_started = True
self.backServerItem.SetItemLabel("Stop Pyo Background Server")
self.sendToServerItem.Enable(True)
else:
- try:
- self.server_pipe.write("print 'Closing background server...'\ns.stop()\ntime.sleep(0.25)\n")
- self.server_pipe.close()
- except IOError:
- pass
- self.server_pipe = None
+ self.processes[1000][0].kill()
self.back_server_started = False
self.backServerItem.SetItemLabel("Start Pyo Background Server")
self.sendToServerItem.Enable(False)
def sendSelectionToBackgroundServer(self, evt):
+ end = None
text = self.panel.editor.GetSelectedTextUTF8()
if text == "":
pos = self.panel.editor.GetCurrentPos()
line = self.panel.editor.LineFromPosition(pos)
text = self.panel.editor.GetLineUTF8(line)
- if self.server_pipe != None:
- for line in text.splitlines():
- self.server_pipe.write(line + "\n")
- self.server_pipe.write("\n")
+ else:
+ end = self.panel.editor.GetSelectionEnd()
+ if self.back_server_started:
+ self.processes[1000][0].sendText(text)
+ if end != None:
+ self.panel.editor.SetCurrentPos(end)
+ self.panel.editor.LineDown()
+ line = self.panel.editor.GetCurrentLine()
+ pos = self.panel.editor.PositionFromLine(line)
+ self.panel.editor.SetCurrentPos(pos)
+ self.panel.editor.SetSelectionEnd(pos)
def buildDoc(self):
self.doc_frame = ManualFrame(osx_app_bundled=OSX_APP_BUNDLED, which_python=WHICH_PYTHON,
@@ -2927,6 +3292,12 @@ class MainFrame(wx.Frame):
except:
pass
self.buildDoc()
+
+ def showArgs(self, evt):
+ self.panel.editor.onShowTip()
+
+ def showDocString(self, evt):
+ self.panel.editor.onShowDocString()
def onShowEditorKeyCommands(self, evt):
if not self.keyCommandsFrame.IsShown():
@@ -3008,6 +3379,7 @@ class MainPanel(wx.Panel):
wx.Panel.__init__(self, parent, size=size, style=wx.SUNKEN_BORDER)
self.new_inc = 0
+ self.close_from_menu = False
self.mainFrame = parent
mainBox = wx.BoxSizer(wx.HORIZONTAL)
@@ -3016,13 +3388,12 @@ class MainPanel(wx.Panel):
self.left_splitter = wx.SplitterWindow(self.splitter, -1, style=wx.SP_LIVE_UPDATE|wx.SP_3DSASH)
self.right_splitter = wx.SplitterWindow(self.splitter, -1, style=wx.SP_LIVE_UPDATE|wx.SP_3DSASH)
- #self.right_splitter.SetMinimumPaneSize(150)
self.project = ProjectTree(self.left_splitter, self, (-1, -1))
self.markers = MarkersPanel(self.left_splitter, self, (-1, -1))
- self.notebook = FNB.FlatNotebook(self.right_splitter, size=(-1,-1),
- style=FNB.FNB_FF2|FNB.FNB_X_ON_TAB|FNB.FNB_NO_X_BUTTON|FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_HIDE_ON_SINGLE_TAB)
+ self.notebook = FNB.FlatNotebook(self.right_splitter, size=(-1,-1))
+ self.notebook.SetAGWWindowStyleFlag(FNB.FNB_FF2|FNB.FNB_X_ON_TAB|FNB.FNB_NO_X_BUTTON|FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_HIDE_ON_SINGLE_TAB)
self.addNewPage()
self.outputlog = OutputLogPanel(self.right_splitter, self, size=(-1,150))
@@ -3034,8 +3405,8 @@ class MainPanel(wx.Panel):
mainBox.Add(self.splitter, 1, wx.EXPAND)
self.SetSizer(mainBox)
- self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.onPageChange)
- self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.onClosingPage)
+ self.notebook.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.onPageChange)
+ self.notebook.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.onClosingPage)
def addNewPage(self):
title = "Untitled-%i.py" % self.new_inc
@@ -3063,6 +3434,11 @@ class MainPanel(wx.Panel):
except:
continue
editor.setText(ensureNFD(text))
+
+ # Scan the entire document (needed for FoldAll to fold everything)
+ editor.GotoLine(editor.GetLineCount())
+ wx.CallAfter(editor.GotoLine, 0)
+
editor.path = file
editor.saveMark = True
editor.EmptyUndoBuffer()
@@ -3085,7 +3461,10 @@ class MainPanel(wx.Panel):
self.editor.setMarkers(copy.deepcopy(markers))
def onClosingPage(self, evt):
- action = self.editor.closeNoCancel()
+ if not self.close_from_menu:
+ action = self.editor.close()
+ if action == "keep":
+ evt.Veto()
def deletePage(self):
select = self.notebook.GetSelection()
@@ -3125,9 +3504,25 @@ class MainPanel(wx.Panel):
ed = self.notebook.GetPage(i)
ed.Close()
+#######################################################
+### The idea of EditorPanel is to allow multiple views
+### at the same time in a single notebook page.
+### Also: A tree view of classes and functions of the file
+### Not yet implemented... ( TODO )
+#######################################################
+class EditorPanel(wx.Panel):
+ def __init__(self, parent):
+ wx.Panel.__init__(self, parent, -1)
+ self.editor = Editor(parent, -1, size=(0, -1))
+ self.editor2 = Editor(parent, -1, size=(0, -1))
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(self.editor, 1, wx.ALL|wx.EXPAND, 5)
+ box.Add(self.editor2, 1, wx.ALL|wx.EXPAND, 5)
+ self.SetSizerAndFit(box)
+
class Editor(stc.StyledTextCtrl):
- def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style= wx.NO_BORDER | wx.WANTS_CHARS,
- setTitle=None, getTitle=None):
+ def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize,
+ style= wx.NO_BORDER | wx.WANTS_CHARS, setTitle=None, getTitle=None):
stc.StyledTextCtrl.__init__(self, parent, ID, pos, size, style)
dt = MyFileDropTarget(self)
@@ -3150,6 +3545,8 @@ class Editor(stc.StyledTextCtrl):
self.markers_dict = {}
self.current_marker = -1
self.objs_attr_dict = {}
+ self.auto_comp_container = PREFERENCES.get("auto_comp_container", 0)
+
self.alphaStr = string.lowercase + string.uppercase + '0123456789'
@@ -3196,22 +3593,17 @@ class Editor(stc.StyledTextCtrl):
self.SetMarginSensitive(2, True)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
+ self.Bind(wx.EVT_CHAR, self.OnChar)
self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI)
self.Bind(stc.EVT_STC_MARGINCLICK, self.OnMarginClick)
self.Bind(wx.EVT_CLOSE, self.OnClose)
- self.Bind(wx.EVT_FIND, self.OnFind)
- self.Bind(wx.EVT_FIND_NEXT, self.OnFind)
- self.Bind(wx.EVT_FIND_REPLACE, self.OnFind)
- self.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnFind)
- self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
+ self.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)
self.EmptyUndoBuffer()
self.SetFocus()
self.setStyle()
# Remove unwanted KeyCommands
- self.CmdKeyClear(stc.STC_KEY_UP, stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(stc.STC_KEY_DOWN, stc.STC_SCMOD_CTRL)
self.CmdKeyClear(stc.STC_KEY_RIGHT, stc.STC_SCMOD_ALT)
self.CmdKeyClear(stc.STC_KEY_LEFT, stc.STC_SCMOD_ALT)
self.CmdKeyClear(stc.STC_KEY_RIGHT, stc.STC_SCMOD_SHIFT | stc.STC_SCMOD_ALT)
@@ -3220,20 +3612,10 @@ class Editor(stc.StyledTextCtrl):
self.CmdKeyClear(stc.STC_KEY_LEFT, stc.STC_SCMOD_CTRL)
self.CmdKeyClear(stc.STC_KEY_RIGHT, stc.STC_SCMOD_SHIFT | stc.STC_SCMOD_CTRL)
self.CmdKeyClear(stc.STC_KEY_LEFT, stc.STC_SCMOD_SHIFT | stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(stc.STC_KEY_HOME, 0)
- self.CmdKeyClear(stc.STC_KEY_HOME, stc.STC_SCMOD_ALT)
- self.CmdKeyClear(stc.STC_KEY_HOME, stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(stc.STC_KEY_HOME, stc.STC_SCMOD_SHIFT)
- self.CmdKeyClear(stc.STC_KEY_HOME, stc.STC_SCMOD_ALT | stc.STC_SCMOD_SHIFT)
- self.CmdKeyClear(stc.STC_KEY_HOME, stc.STC_SCMOD_CTRL | stc.STC_SCMOD_SHIFT)
- self.CmdKeyClear(stc.STC_KEY_END, 0)
- self.CmdKeyClear(stc.STC_KEY_END, stc.STC_SCMOD_ALT)
- self.CmdKeyClear(stc.STC_KEY_END, stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(stc.STC_KEY_END, stc.STC_SCMOD_SHIFT)
- self.CmdKeyClear(stc.STC_KEY_END, stc.STC_SCMOD_ALT | stc.STC_SCMOD_SHIFT)
- self.CmdKeyClear(stc.STC_KEY_END, stc.STC_SCMOD_CTRL | stc.STC_SCMOD_SHIFT)
self.CmdKeyClear(stc.STC_KEY_DELETE, 0)
self.CmdKeyClear(stc.STC_KEY_DELETE, stc.STC_SCMOD_SHIFT)
+ self.CmdKeyClear(stc.STC_KEY_DELETE, stc.STC_SCMOD_CTRL)
+ self.CmdKeyClear(stc.STC_KEY_DELETE, stc.STC_SCMOD_SHIFT | stc.STC_SCMOD_CTRL)
self.CmdKeyClear(stc.STC_KEY_BACK, stc.STC_SCMOD_ALT)
self.CmdKeyClear(stc.STC_KEY_BACK, stc.STC_SCMOD_SHIFT)
self.CmdKeyClear(stc.STC_KEY_BACK, stc.STC_SCMOD_CTRL)
@@ -3241,22 +3623,19 @@ class Editor(stc.StyledTextCtrl):
self.CmdKeyClear(stc.STC_KEY_INSERT, 0)
self.CmdKeyClear(stc.STC_KEY_INSERT, stc.STC_SCMOD_SHIFT)
self.CmdKeyClear(stc.STC_KEY_INSERT, stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(ord('Z'), stc.STC_SCMOD_CTRL)
self.CmdKeyClear(ord('Y'), stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(ord('X'), stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(ord('C'), stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(ord('V'), stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(ord('A'), stc.STC_SCMOD_CTRL)
+ self.CmdKeyClear(ord('D'), stc.STC_SCMOD_CTRL)
self.CmdKeyClear(ord('L'), stc.STC_SCMOD_CTRL)
self.CmdKeyClear(ord('T'), stc.STC_SCMOD_CTRL)
- self.CmdKeyClear(ord('U'), stc.STC_SCMOD_CTRL)
self.CmdKeyClear(ord('L'), stc.STC_SCMOD_CTRL | stc.STC_SCMOD_SHIFT)
- self.CmdKeyClear(ord('U'), stc.STC_SCMOD_CTRL | stc.STC_SCMOD_SHIFT)
self.CmdKeyClear(stc.STC_KEY_RETURN, stc.STC_SCMOD_SHIFT)
self.CmdKeyClear(stc.STC_KEY_ADD, stc.STC_SCMOD_CTRL)
self.CmdKeyClear(stc.STC_KEY_SUBTRACT, stc.STC_SCMOD_CTRL)
self.CmdKeyClear(stc.STC_KEY_DIVIDE, stc.STC_SCMOD_CTRL)
+ self.CmdKeyAssign(ord('U'), stc.STC_SCMOD_CTRL, stc.STC_CMD_UPPERCASE)
+ self.CmdKeyAssign(ord('U'), stc.STC_SCMOD_CTRL | stc.STC_SCMOD_SHIFT, stc.STC_CMD_LOWERCASE)
+
wx.CallAfter(self.SetAnchor, 0)
self.Refresh()
@@ -3276,6 +3655,7 @@ class Editor(stc.StyledTextCtrl):
if STYLES[forekey]['underline']:
st += ",underline"
return st
+
self.StyleSetSpec(stc.STC_STYLE_DEFAULT, buildStyle('default', 'background'))
self.StyleClearAll() # Reset all to be like the default
@@ -3294,8 +3674,23 @@ class Editor(stc.StyledTextCtrl):
self.StyleSetSpec(stc.STC_STYLE_BRACEBAD, buildStyle('default', 'bracebad') + ",bold")
ext = os.path.splitext(self.path)[1].strip(".")
+ if ext == "":
+ try:
+ with open(self.path, "r") as f:
+ fline = f.readline()
+ if fline.startswith("#!"):
+ fline = fline.replace("/", " ")
+ last = fline.split()[-1]
+ ext = {"python": "py", "bash": "sh", "sh": "sh"}.get(last, "")
+ else:
+ text = f.read()
+ if "desc:" in text:
+ ext = "jsfx"
+ except:
+ pass
if ext in ["py", "pyw", "c5"]:
self.SetLexer(stc.STC_LEX_PYTHON)
+ self.SetStyleBits(self.GetStyleBitsNeeded())
self.SetKeyWords(0, " ".join(keyword.kwlist) + " None True False ")
self.SetKeyWords(1, " ".join(PYO_WORDLIST))
self.StyleSetSpec(stc.STC_P_DEFAULT, buildStyle('default'))
@@ -3314,6 +3709,11 @@ class Editor(stc.StyledTextCtrl):
self.StyleSetSpec(stc.STC_P_COMMENTBLOCK, buildStyle('commentblock'))
elif ext in ["c", "cc", "cpp", "cxx", "cs", "h", "hh", "hpp", "hxx"]:
self.SetLexer(stc.STC_LEX_CPP)
+ self.SetStyleBits(self.GetStyleBitsNeeded())
+ self.SetProperty('fold.comment', '1')
+ self.SetProperty('fold.preprocessor', '1')
+ self.SetProperty('fold.compact', '1')
+ self.SetProperty('styling.within.preprocessor', '0')
self.SetKeyWords(0, "auto break case char const continue default do double else enum extern float for goto if int long \
register return short signed sizeof static struct switch typedef union unsigned void volatile while ")
self.StyleSetSpec(stc.STC_C_DEFAULT, buildStyle('default'))
@@ -3330,6 +3730,7 @@ class Editor(stc.StyledTextCtrl):
self.StyleSetSpec(stc.STC_C_PREPROCESSOR, buildStyle('commentblock'))
elif ext == "sh":
self.SetLexer(stc.STC_LEX_BASH)
+ self.SetStyleBits(self.GetStyleBitsNeeded())
self.SetKeyWords(0, "! [[ ]] case do done elif else esac fi for function if in select then time until while { } \
alias bg bind break builtin caller cd command compgen complete compopt continue declare dirs disown echo enable \
eval exec exit export fc fg getopts hash help history jobs kill let local logout mapfile popd printf pushd pwd \
@@ -3344,12 +3745,155 @@ class Editor(stc.StyledTextCtrl):
self.StyleSetSpec(stc.STC_SH_IDENTIFIER, buildStyle('default'))
self.StyleSetSpec(stc.STC_SH_PARAM, buildStyle('default'))
self.StyleSetSpec(stc.STC_SH_SCALAR, buildStyle('function'))
+ elif ext in ["jsfx", "jsfx-inc"]:
+ self.SetLexer(stc.STC_LEX_CPP)
+ self.SetStyleBits(self.GetStyleBitsNeeded())
+ self.SetProperty('fold.comment', '1')
+ self.SetProperty('fold.preprocessor', '1')
+ self.SetProperty('fold.compact', '1')
+ self.SetProperty('styling.within.preprocessor', '0')
+ self.SetKeyWords(1, "abs acos asin atan atan2 atexit ceil convolve_c cos defer eval exp fclose feof fflush \
+ fft fft_ipermute fft_permute fgetc floor fopen fprintf fread freembuf fseek ftell fwrite \
+ gfx_aaaaa gfx_arc gfx_blit gfx_blit gfx_blitext gfx_blurto gfx_circle gfx_deltablit \
+ gfx_drawchar gfx_drawnumber gfx_drawstr gfx_getchar gfx_getfont gfx_getimgdim gfx_getpixel \
+ gfx_gradrect gfx_init gfx_line gfx_lineto gfx_loadimg gfx_measurestr gfx_muladdrect gfx_printf \
+ gfx_quit gfx_rect gfx_rectto gfx_roundrect gfx_setfont gfx_setimgdim gfx_setpixel gfx_transformblit \
+ gfx_update ifft invsqrt log log10 match matchi max memcpy memset min pow printf rand sign sin sleep \
+ sprintf sqr sqrt stack_exch stack_peek stack_pop stack_push str_delsub str_getchar str_insert \
+ str_setchar str_setlen strcat strcmp strcpy strcpy_from strcpy_substr stricmp strlen strncat strncmp \
+ strncpy strnicmp tan tcp_close tcp_connect tcp_listen tcp_listen_end tcp_recv tcp_send tcp_set_block \
+ time time_precise")
+ self.SetKeyWords(0, "loop while function local static instance this global globals _global gfx_r gfx_g gfx_b gfx_a gfx_w \
+ gfx_h gfx_x gfx_y gfx_mode gfx_clear gfx_dest gfx_texth mouse_x mouse_y mouse_cap mouse_wheel mouse_hwheel \
+ @init @slider @sample @block @serialize @gfx import desc slider1 slider2 slider3 slider4 slider5 \
+ slider6 slider7 slider8 slider9 slider10 slider11 slider12 slider13 slider14 slider15 slider16 in_pin \
+ out_pin filename ")
+ self.StyleSetSpec(stc.STC_C_DEFAULT, buildStyle('default'))
+ self.StyleSetSpec(stc.STC_C_COMMENT, buildStyle('comment'))
+ self.StyleSetSpec(stc.STC_C_COMMENTDOC, buildStyle('comment'))
+ self.StyleSetSpec(stc.STC_C_COMMENTLINE, buildStyle('comment'))
+ self.StyleSetSpec(stc.STC_C_COMMENTLINEDOC, buildStyle('comment'))
+ self.StyleSetSpec(stc.STC_C_NUMBER, buildStyle('number'))
+ self.StyleSetSpec(stc.STC_C_STRING, buildStyle('string'))
+ self.StyleSetSpec(stc.STC_C_CHARACTER, buildStyle('string'))
+ self.StyleSetSpec(stc.STC_C_WORD, buildStyle('keyword'))
+ self.StyleSetSpec(stc.STC_C_WORD2, buildStyle('pyokeyword'))
+ self.StyleSetSpec(stc.STC_C_OPERATOR, buildStyle('operator'))
+ self.StyleSetSpec(stc.STC_C_IDENTIFIER, buildStyle('default'))
+ self.StyleSetSpec(stc.STC_C_PREPROCESSOR, buildStyle('commentblock'))
+ elif ext == "md":
+ self.SetLexer(stc.STC_LEX_MARKDOWN)
+ self.SetStyleBits(self.GetStyleBitsNeeded())
+ self.StyleSetSpec(stc.STC_MARKDOWN_DEFAULT, buildStyle('default'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_LINE_BEGIN, buildStyle('default'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_STRONG1, buildStyle('default') + ",italic,bold")
+ self.StyleSetSpec(stc.STC_MARKDOWN_STRONG2, buildStyle('default') + ",italic,bold")
+ self.StyleSetSpec(stc.STC_MARKDOWN_EM1, buildStyle('default') + ",italic")
+ self.StyleSetSpec(stc.STC_MARKDOWN_EM2, buildStyle('default') + ",italic")
+ self.StyleSetSpec(stc.STC_MARKDOWN_HEADER1, buildStyle('comment') + ", bold")
+ self.StyleSetSpec(stc.STC_MARKDOWN_HEADER2, buildStyle('comment'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_HEADER3, buildStyle('commentblock') + ", bold")
+ self.StyleSetSpec(stc.STC_MARKDOWN_HEADER4, buildStyle('commentblock') + ", bold")
+ self.StyleSetSpec(stc.STC_MARKDOWN_HEADER5, buildStyle('commentblock'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_HEADER6, buildStyle('commentblock'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_PRECHAR, buildStyle('default'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_ULIST_ITEM, buildStyle('string'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_OLIST_ITEM, buildStyle('triple'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_BLOCKQUOTE, buildStyle('string'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_STRIKEOUT, buildStyle('string'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_HRULE, buildStyle('triple'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_LINK, buildStyle('function'))
+ self.StyleSetSpec(stc.STC_MARKDOWN_CODE, buildStyle('default') + ",italic,bold")
+ self.StyleSetSpec(stc.STC_MARKDOWN_CODE2, buildStyle('default') + ",italic,bold")
+ self.StyleSetSpec(stc.STC_MARKDOWN_CODEBK, buildStyle('default') + ",italic,bold")
+ elif ext == "lua":
+ self.SetLexer(stc.STC_LEX_LUA)
+ self.SetStyleBits(self.GetStyleBitsNeeded())
+ self.SetKeyWords(0, "and break do else elseif for if in nil not or \
+ repeat then until while function local end return true false ")
+ self.StyleSetSpec(stc.STC_LUA_DEFAULT, buildStyle('default'))
+ self.StyleSetSpec(stc.STC_LUA_COMMENT, buildStyle('comment'))
+ self.StyleSetSpec(stc.STC_LUA_COMMENTLINE, buildStyle('comment'))
+ self.StyleSetSpec(stc.STC_LUA_COMMENTDOC, buildStyle('commentblock'))
+ self.StyleSetSpec(stc.STC_LUA_NUMBER, buildStyle('number'))
+ self.StyleSetSpec(stc.STC_LUA_WORD, buildStyle('keyword'))
+ self.StyleSetSpec(stc.STC_LUA_STRING, buildStyle('string'))
+ self.StyleSetSpec(stc.STC_LUA_CHARACTER, buildStyle('string'))
+ self.StyleSetSpec(stc.STC_LUA_LITERALSTRING, buildStyle('triple'))
+ self.StyleSetSpec(stc.STC_LUA_PREPROCESSOR, buildStyle('default') + ",italic")
+ self.StyleSetSpec(stc.STC_LUA_OPERATOR, buildStyle('operator'))
+ self.StyleSetSpec(stc.STC_LUA_IDENTIFIER, buildStyle('default'))
+ self.StyleSetSpec(stc.STC_LUA_STRINGEOL, buildStyle('default') + ",bold")
+ self.StyleSetSpec(stc.STC_LUA_WORD2, buildStyle('pyokeyword'))
+ self.StyleSetSpec(stc.STC_LUA_WORD3, buildStyle('pyokeyword'))
+ self.StyleSetSpec(stc.STC_LUA_WORD4, buildStyle('pyokeyword'))
+ self.StyleSetSpec(stc.STC_LUA_WORD5, buildStyle('pyokeyword'))
+ self.StyleSetSpec(stc.STC_LUA_WORD6, buildStyle('pyokeyword'))
+ self.StyleSetSpec(stc.STC_LUA_WORD7, buildStyle('pyokeyword'))
+ self.StyleSetSpec(stc.STC_LUA_WORD8, buildStyle('pyokeyword'))
+ self.StyleSetSpec(stc.STC_LUA_LABEL, buildStyle('default') + ",italic,bold")
self.SetEdgeColour(STYLES["lineedge"]['colour'])
self.SetCaretForeground(STYLES['caret']['colour'])
self.SetSelBackground(1, STYLES['selback']['colour'])
self.SetFoldMarginColour(True, STYLES['foldmarginback']['colour'])
self.SetFoldMarginHiColour(True, STYLES['foldmarginback']['colour'])
+ self.CallTipSetForeground(STYLES['default']['colour'])
+ self.CallTipSetBackground(STYLES['background']['colour'])
+
+ # WxPython 3 needs the lexer to be set before folding property
+ self.SetProperty("fold", "1")
+
+ def insertBlockHead(self):
+ pos = self.PositionFromLine(self.GetCurrentLine())
+ if self.GetLine(self.GetCurrentLine()).strip() == "":
+ self.InsertText(pos, "#-->")
+ else:
+ self.InsertText(pos, "#-->\n")
+
+ def insertBlockTail(self):
+ pos = self.GetLineEndPosition(self.GetCurrentLine())
+ if self.GetLine(self.GetCurrentLine()).strip() == "":
+ self.InsertText(pos, "#<--")
+ else:
+ self.InsertText(pos, "\n#<--")
+
+ def selectCodeBlock(self):
+ self.OnDoubleClick(None)
+
+ def OnDoubleClick(self, evt):
+ """
+ Double-click used to select chunk of code between #--> and #<--
+ """
+ if "#-->" in self.GetLine(self.GetCurrentLine()):
+ first = self.GetCurrentLine()
+ last = self.GetLineCount()
+ self.LineDown()
+ while (self.GetCurrentLine() < self.GetLineCount()):
+ if "#<--" in self.GetLine(self.GetCurrentLine()):
+ last = self.GetCurrentLine() - 1
+ break
+ self.LineDown()
+ self.SetSelection(self.GetLineEndPosition(first)+1,
+ self.GetLineEndPosition(last)+1)
+ if evt is not None:
+ evt.StopPropagation()
+ elif "#<--" in self.GetLine(self.GetCurrentLine()):
+ first = 0
+ last = self.GetCurrentLine() - 1
+ self.LineUp()
+ while (self.GetCurrentLine() > 0):
+ if "#-->" in self.GetLine(self.GetCurrentLine()):
+ first = self.GetCurrentLine()
+ break
+ self.LineUp()
+ self.SetSelection(self.GetLineEndPosition(first)+1,
+ self.GetLineEndPosition(last)+1)
+ if evt is not None:
+ evt.StopPropagation()
+ else:
+ if evt is not None:
+ evt.Skip()
def OnQuickSearch(self, str, next=True):
if self.GetSelection() != (0,0):
@@ -3376,10 +3920,14 @@ class Editor(stc.StyledTextCtrl):
self.ScrollToLine(line - halfNumLinesOnScreen)
def OnShowFindReplace(self):
- data = wx.FindReplaceData()
- self.findReplace = wx.FindReplaceDialog(self, data, "Find & Replace", wx.FR_REPLACEDIALOG | wx.FR_NOUPDOWN)
- self.findReplace.data = data # save a reference to it...
- self.findReplace.Show(True)
+ self.data = wx.FindReplaceData()
+ dlg = wx.FindReplaceDialog(self, self.data, "Find & Replace", wx.FR_REPLACEDIALOG | wx.FR_NOUPDOWN)
+ dlg.Bind(wx.EVT_FIND, self.OnFind)
+ dlg.Bind(wx.EVT_FIND_NEXT, self.OnFind)
+ dlg.Bind(wx.EVT_FIND_REPLACE, self.OnFind)
+ dlg.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnFind)
+ dlg.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
+ dlg.Show(True)
def OnFind(self, evt):
map = { wx.wxEVT_COMMAND_FIND : "FIND",
@@ -3387,41 +3935,50 @@ class Editor(stc.StyledTextCtrl):
wx.wxEVT_COMMAND_FIND_REPLACE : "REPLACE",
wx.wxEVT_COMMAND_FIND_REPLACE_ALL : "REPLACE_ALL" }
- et = evt.GetEventType()
+ evtType = evt.GetEventType()
findTxt = evt.GetFindString()
+ newTxt = evt.GetReplaceString()
+ findStrLen = len(findTxt)
+ newStrLen = len(newTxt)
+ diffLen = newStrLen - findStrLen
selection = self.GetSelection()
if selection[0] == selection[1]:
selection = (0, self.GetLength())
- if map[et] == 'FIND':
+ if map[evtType] == 'FIND':
startpos = self.FindText(selection[0], selection[1], findTxt, evt.GetFlags())
endpos = startpos+len(findTxt)
self.anchor1 = endpos
self.anchor2 = selection[1]
self.SetSelection(startpos, endpos)
- elif map[et] == 'FIND_NEXT':
+ elif map[evtType] == 'FIND_NEXT':
startpos = self.FindText(self.anchor1, self.anchor2, findTxt, evt.GetFlags())
endpos = startpos+len(findTxt)
self.anchor1 = endpos
self.SetSelection(startpos, endpos)
- elif map[et] == 'REPLACE':
- startpos = self.FindText(selection[0], selection[1], findTxt)
- endpos = startpos+len(findTxt)
+ elif map[evtType] == 'REPLACE':
+ startpos = self.FindText(selection[0], selection[1], findTxt, evt.GetFlags())
if startpos != -1:
+ endpos = startpos+len(findTxt)
self.SetSelection(startpos, endpos)
- self.ReplaceSelection(evt.GetReplaceString())
- elif map[et] == 'REPLACE_ALL':
- self.anchor1 = selection[0]
+ self.ReplaceSelection(newTxt)
+ self.anchor1 = startpos + newStrLen + 1
+ self.anchor2 += diffLen
+ elif map[evtType] == 'REPLACE_ALL':
+ self.anchor1 = startpos = selection[0]
self.anchor2 = selection[1]
- startpos = selection[0]
while startpos != -1:
- startpos = self.FindText(self.anchor1, self.anchor2, findTxt)
- endpos = startpos+len(findTxt)
- self.anchor1 = endpos
+ startpos = self.FindText(self.anchor1, self.anchor2, findTxt, evt.GetFlags())
if startpos != -1:
+ endpos = startpos+len(findTxt)
self.SetSelection(startpos, endpos)
- self.ReplaceSelection(evt.GetReplaceString())
+ self.ReplaceSelection(newTxt)
+ self.anchor1 = startpos + newStrLen + 1
+ self.anchor2 += diffLen
+ line = self.GetCurrentLine()
+ halfNumLinesOnScreen = self.LinesOnScreen() / 2
+ self.ScrollToLine(line - halfNumLinesOnScreen)
def OnFindClose(self, evt):
evt.GetDialog().Destroy()
@@ -3480,30 +4037,6 @@ class Editor(stc.StyledTextCtrl):
for line in lines:
f.write("%s=%s\n" % (line[0], line[1]))
- def closeNoCancel(self):
- if self.GetModify():
- if not self.path: f = "Untitled"
- else: f = self.path
- dlg = wx.MessageDialog(None, 'file ' + f + ' has been modified. Do you want to save?',
- 'Warning!', wx.YES | wx.NO)
- but = dlg.ShowModal()
- if but == wx.ID_YES:
- dlg.Destroy()
- if not self.path or "Untitled-" in self.path:
- dlg2 = wx.FileDialog(None, message="Save file as ... (the file will be closed even if you pressed Cancel!)", defaultDir=os.getcwd(),
- defaultFile="", style=wx.SAVE|wx.FD_OVERWRITE_PROMPT)
- dlg2.SetFilterIndex(0)
- if dlg2.ShowModal() == wx.ID_OK:
- path = dlg2.GetPath()
- self.SaveFile(path)
- dlg2.Destroy()
- else:
- dlg2.Destroy()
- else:
- self.SaveFile(self.path)
- elif but == wx.ID_NO:
- dlg.Destroy()
-
def close(self):
if self.GetModify():
if not self.path: f = "Untitled"
@@ -3623,6 +4156,9 @@ class Editor(stc.StyledTextCtrl):
currentword = self.GetTextRangeUTF8(startpos, endpos)
return currentword
+ def showAutoCompContainer(self, state):
+ self.auto_comp_container = state
+
def showAutoComp(self):
propagate = True
charBefore = " "
@@ -3640,15 +4176,27 @@ class Editor(stc.StyledTextCtrl):
propagate = False
return propagate
- def insertDefArgs(self, currentword):
+ def insertDefArgs(self, currentword, charat):
propagate = True
+ braceend = True
+ currentword = ""
+ if charat == ord("("):
+ pos = self.GetCurrentPos()
+ if chr(self.GetCharAt(pos)) == ')':
+ braceend = False
+ startpos = self.WordStartPosition(pos-2, True)
+ endpos = self.WordEndPosition(pos-2, True)
+ currentword = self.GetTextRangeUTF8(startpos, endpos)
for word in PYO_WORDLIST:
if word == currentword:
text = class_args(eval(word)).replace(word, "")
self.args_buffer = text.replace("(", "").replace(")", "").split(",")
self.args_buffer = [arg.strip() for arg in self.args_buffer]
self.args_line_number = [self.GetCurrentLine(), self.GetCurrentLine()+1]
- self.insertText(self.GetCurrentPos(), text, False)
+ if braceend:
+ self.insertText(self.GetCurrentPos(), text[1:], False)
+ else:
+ self.insertText(self.GetCurrentPos(), text[1:-1], False)
self.selection = self.GetSelectedText()
wx.CallAfter(self.navigateArgs)
propagate = False
@@ -3788,7 +4336,7 @@ class Editor(stc.StyledTextCtrl):
def processTab(self, currentword, autoCompActive, charat, pos):
propagate = self.showAutoComp()
if propagate:
- propagate = self.insertDefArgs(currentword)
+ propagate = self.insertDefArgs(currentword, charat)
if propagate:
propagate = self.checkForBuiltinComp()
if propagate:
@@ -3803,30 +4351,64 @@ class Editor(stc.StyledTextCtrl):
except:
pass
- def navigateMarkers(self, down=True):
- if self.markers_dict != {}:
- llen = len(self.markers_dict)
- keys = sorted(self.markers_dict.keys())
- if down:
- self.current_marker += 1
- else:
- self.current_marker -= 1
- if self.current_marker < 0:
- self.current_marker = llen - 1
- elif self.current_marker >= llen:
- self.current_marker = 0
- line = keys[self.current_marker]
- self.GotoLine(line)
- halfNumLinesOnScreen = self.LinesOnScreen() / 2
- self.ScrollToLine(line - halfNumLinesOnScreen)
- self.GetParent().GetParent().GetParent().GetParent().markers.setSelected(self.current_marker)
+ def onShowDocString(self):
+ if self.GetSelectedText() != "":
+ currentword = self.GetSelectedText()
+ else:
+ currentword = self.getWordUnderCaret()
+ firstCaretPos = self.GetCurrentPos()
+ caretPos = self.GetCurrentPos()
+ startpos = self.WordStartPosition(caretPos, True)
+ while chr(self.GetCharAt(startpos-1)) == ".":
+ self.GotoPos(startpos-2)
+ parent = self.getWordUnderCaret()
+ currentword = parent + "." + currentword
+ caretPos = self.GetCurrentPos()
+ startpos = self.WordStartPosition(caretPos, True)
+ self.GotoPos(firstCaretPos)
+ lineCount = self.GetLineCount()
+ text = ""
+ for i in range(lineCount):
+ line = self.GetLine(i)
+ if "import " in line:
+ text = text + line
+ try:
+ exec text in locals()
+ docstr = eval(currentword).__doc__
+ dlg = wx.lib.dialogs.ScrolledMessageDialog(self, docstr, "__doc__ string for %s" % currentword, size=(700,500))
+ dlg.CenterOnParent()
+ dlg.ShowModal()
+ except:
+ pass
+
+ def OnChar(self, evt):
+ propagate = True
+ if chr(evt.GetKeyCode()) in ['[', '{', '(', '"', '`'] and self.auto_comp_container:
+ if chr(evt.GetKeyCode()) == '[':
+ self.AddText('[]')
+ elif chr(evt.GetKeyCode()) == '{':
+ self.AddText('{}')
+ elif chr(evt.GetKeyCode()) == '(':
+ self.AddText('()')
+ elif chr(evt.GetKeyCode()) == '"':
+ self.AddText('""')
+ elif chr(evt.GetKeyCode()) == '`':
+ self.AddText('``')
+ self.CharLeft()
+ propagate = False
+
+ if propagate:
+ evt.Skip()
+ else:
+ evt.StopPropagation()
+
def OnKeyDown(self, evt):
if PLATFORM == "darwin":
ControlDown = evt.CmdDown
else:
ControlDown = evt.ControlDown
-
+
propagate = True
# Stop propagation on markers navigation --- Shift+Ctrl+Arrows up/down
if evt.GetKeyCode() in [wx.WXK_DOWN,wx.WXK_UP] and evt.ShiftDown() and ControlDown():
@@ -3835,6 +4417,10 @@ class Editor(stc.StyledTextCtrl):
elif evt.GetKeyCode() == wx.WXK_RETURN and evt.ShiftDown():
self.onShowTip()
propagate = False
+ # Stop propagation on Tip Show of __doc__ string --- Ctrl+Return
+ elif evt.GetKeyCode() == wx.WXK_RETURN and ControlDown():
+ self.onShowDocString()
+ propagate = False
# Move and/or Select one word left or right --- (Shift+)Alt+Arrows left/right
elif evt.GetKeyCode() == wx.WXK_LEFT and evt.AltDown() and evt.ShiftDown():
@@ -3860,6 +4446,11 @@ class Editor(stc.StyledTextCtrl):
self.CmdKeyExecute(stc.STC_CMD_LINEEND)
propagate = False
+ # Delete forward DELETE
+ elif evt.GetKeyCode() == wx.WXK_DELETE:
+ self.CmdKeyExecute(stc.STC_CMD_CHARRIGHT)
+ self.CmdKeyExecute(stc.STC_CMD_DELETEBACK)
+ propagate = False
# Delete the word to the right of the caret --- Shift+Alt+BACK
elif evt.GetKeyCode() == wx.WXK_BACK and evt.AltDown() and evt.ShiftDown():
self.DelWordRight()
@@ -3891,6 +4482,15 @@ class Editor(stc.StyledTextCtrl):
self.Paste()
propagate = False
+ # Show documentation for pyo object under the caret
+ elif evt.GetKeyCode() == ord('D') and ControlDown():
+ self.GetParent().GetParent().GetParent().GetParent().GetParent().showDoc(None)
+ propagate = False
+ # Goto line
+ elif evt.GetKeyCode() == ord('L') and ControlDown():
+ self.GetParent().GetParent().GetParent().GetParent().GetParent().gotoLine(None)
+ propagate = False
+
# Process Return key --- automatic indentation
elif evt.GetKeyCode() == wx.WXK_RETURN:
wx.CallAfter(self.processReturn)
@@ -3970,7 +4570,8 @@ class Editor(stc.StyledTextCtrl):
# for i in range(self.GetLineCount()):
# pos = self.GetLineEndPosition(i)
# if self.GetCharAt(pos-1) != 172:
- # self.InsertTextUTF8(pos, "¬")
+ # self.InsertTextUTF8(pos, "¬")
+ self.moveMarkers()
self.checkScrollbar()
self.OnModified()
evt.Skip()
@@ -3998,96 +4599,129 @@ class Editor(stc.StyledTextCtrl):
self.GotoPos(pos+1)
self.DelWordLeft()
+ def navigateMarkers(self, down=True):
+ if self.markers_dict != {}:
+ llen = len(self.markers_dict)
+ swap = [(x[1], x[0]) for x in self.markers_dict.items()]
+ handles = [x[1] for x in sorted(swap)]
+ if down:
+ self.current_marker += 1
+ else:
+ self.current_marker -= 1
+ if self.current_marker < 0:
+ self.current_marker = llen - 1
+ elif self.current_marker >= llen:
+ self.current_marker = 0
+ handle = handles[self.current_marker]
+ line = self.markers_dict[handle][0]
+ self.GotoLine(line)
+ halfNumLinesOnScreen = self.LinesOnScreen() / 2
+ self.ScrollToLine(line - halfNumLinesOnScreen)
+ self.GetParent().GetParent().GetParent().GetParent().markers.setSelected(handle)
+
def setMarkers(self, dic):
+ try:
+ key = dic.keys()[0]
+ except:
+ return
+ if type(dic[key]) != ListType:
+ return
self.markers_dict = dic
- for line in self.markers_dict.keys():
+ for handle in self.markers_dict.keys():
+ line = self.markers_dict[handle][0]
self.MarkerAdd(line, 0)
self.GetParent().GetParent().GetParent().GetParent().markers.setDict(self.markers_dict)
- def addMarker(self, line):
- if line not in self.markers_dict.keys():
- self.MarkerAdd(line, 0)
- self.markers_dict[line] = ""
+ def moveMarkers(self):
+ dict = {}
+ for handle in self.markers_dict.keys():
+ line = self.MarkerLineFromHandle(handle)
+ comment = self.markers_dict[handle][1]
+ dict[handle] = [line, comment]
+ if dict != self.markers_dict:
+ self.markers_dict = dict
self.GetParent().GetParent().GetParent().GetParent().markers.setDict(self.markers_dict)
- return True
+
+ def addMarker(self, line):
+ if not self.MarkerGet(line):
+ handle = self.MarkerAdd(line, 0)
+ self.markers_dict[handle] = [line, ""]
+ comment = ""
+ dlg = wx.TextEntryDialog(self, 'Enter a comment for that marker:', 'Marker Comment')
+ if dlg.ShowModal() == wx.ID_OK:
+ comment = dlg.GetValue()
+ dlg.Destroy()
else:
- return False
+ dlg.Destroy()
+ return
+ self.markers_dict[handle][1] = comment
+ self.GetParent().GetParent().GetParent().GetParent().markers.setDict(self.markers_dict)
def deleteMarker(self, line):
- if line in self.markers_dict.keys():
- del self.markers_dict[line]
- self.MarkerDelete(line, 0)
- self.GetParent().GetParent().GetParent().GetParent().markers.setDict(self.markers_dict)
+ for handle in self.markers_dict.keys():
+ if line == self.markers_dict[handle][0]:
+ del self.markers_dict[handle]
+ self.MarkerDeleteHandle(handle)
+ self.GetParent().GetParent().GetParent().GetParent().markers.setDict(self.markers_dict)
def deleteAllMarkers(self):
self.markers_dict = {}
self.MarkerDeleteAll(0)
self.GetParent().GetParent().GetParent().GetParent().markers.setDict(self.markers_dict)
- def addMarkerComment(self, line):
- if line in self.markers_dict.keys():
- comment = ""
- dlg = wx.TextEntryDialog(self, 'Enter a comment for that marker:', 'Marker Comment')
- if dlg.ShowModal() == wx.ID_OK:
- comment = dlg.GetValue()
- dlg.Destroy()
- else:
- dlg.Destroy()
- return
- self.markers_dict[line] = comment
- self.GetParent().GetParent().GetParent().GetParent().markers.setDict(self.markers_dict)
-
def OnMarginClick(self, evt):
if evt.GetMargin() == 0:
- if PLATFORM == "darwin":
- modif = evt.GetAlt
- else:
- modif = evt.GetControl
lineClicked = self.LineFromPosition(evt.GetPosition())
- if modif():
+ if evt.GetShift():
self.deleteMarker(lineClicked)
- elif evt.GetShift():
- self.addMarkerComment(lineClicked)
else:
- ok = self.addMarker(lineClicked)
- if ok:
- self.addMarkerComment(lineClicked)
+ self.addMarker(lineClicked)
elif evt.GetMargin() == 2:
if evt.GetShift() and evt.GetControl():
- self.FoldAll()
+ self.ToggleFoldAll()
else:
lineClicked = self.LineFromPosition(evt.GetPosition())
-
if self.GetFoldLevel(lineClicked) & stc.STC_FOLDLEVELHEADERFLAG:
- if evt.GetShift():
- self.SetFoldExpanded(lineClicked, True)
- self.Expand(lineClicked, True, True, 1)
- elif evt.GetControl():
- if self.GetFoldExpanded(lineClicked):
- self.SetFoldExpanded(lineClicked, False)
- self.Expand(lineClicked, False, True, 0)
- else:
- self.SetFoldExpanded(lineClicked, True)
- self.Expand(lineClicked, True, True, 100)
- else:
- self.ToggleFold(lineClicked)
+ self.ToggleFold(lineClicked)
def FoldAll(self):
lineCount = self.GetLineCount()
- expanding = True
+ lineNum = 0
+ while lineNum < lineCount:
+ level = self.GetFoldLevel(lineNum)
+ if level & stc.STC_FOLDLEVELHEADERFLAG and \
+ (level & stc.STC_FOLDLEVELNUMBERMASK) == stc.STC_FOLDLEVELBASE:
+ lastChild = self.GetLastChild(lineNum, -1)
+ self.SetFoldExpanded(lineNum, False)
+ if lastChild > lineNum:
+ self.HideLines(lineNum+1, lastChild)
+ lineNum = lineNum + 1
+
+ def ExpandAll(self):
+ lineCount = self.GetLineCount()
+ lineNum = 0
+ while lineNum < lineCount:
+ level = self.GetFoldLevel(lineNum)
+ if level & stc.STC_FOLDLEVELHEADERFLAG and \
+ (level & stc.STC_FOLDLEVELNUMBERMASK) == stc.STC_FOLDLEVELBASE:
+ self.SetFoldExpanded(lineNum, True)
+ lineNum = self.Expand(lineNum, True)
+ lineNum = lineNum - 1
+ lineNum = lineNum + 1
+ def ToggleFoldAll(self):
+ lineCount = self.GetLineCount()
+ expanding = True
# find out if we are folding or unfolding
for lineNum in range(lineCount):
if self.GetFoldLevel(lineNum) & stc.STC_FOLDLEVELHEADERFLAG:
expanding = not self.GetFoldExpanded(lineNum)
break
-
lineNum = 0
while lineNum < lineCount:
level = self.GetFoldLevel(lineNum)
if level & stc.STC_FOLDLEVELHEADERFLAG and \
(level & stc.STC_FOLDLEVELNUMBERMASK) == stc.STC_FOLDLEVELBASE:
-
if expanding:
self.SetFoldExpanded(lineNum, True)
lineNum = self.Expand(lineNum, True)
@@ -4099,6 +4733,16 @@ class Editor(stc.StyledTextCtrl):
self.HideLines(lineNum+1, lastChild)
lineNum = lineNum + 1
+ def foldExpandCurrentScope(self):
+ line = self.GetCurrentLine()
+ while (line >= 0):
+ level = self.GetFoldLevel(line)
+ if level & stc.STC_FOLDLEVELHEADERFLAG and (level & stc.STC_FOLDLEVELNUMBERMASK) == stc.STC_FOLDLEVELBASE:
+ self.ToggleFold(line)
+ self.GotoLine(line)
+ break
+ line -= 1
+
def Expand(self, line, doExpand, force=False, visLevels=0, level=-1):
lastChild = self.GetLastChild(line, level)
line = line + 1
@@ -4195,6 +4839,12 @@ class OutputLogEditor(SimpleEditor):
def __init__(self, parent, ID=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style= wx.NO_BORDER):
SimpleEditor.__init__(self, parent=parent, ID=ID, pos=pos, size=size, style=style)
+ def appendToLog(self, text):
+ self.SetReadOnly(False)
+ self.AppendText(text)
+ self.GotoLine(self.GetLineCount())
+ self.SetReadOnly(True)
+
def setLog(self, text):
self.SetReadOnly(False)
self.SetText(text)
@@ -4212,7 +4862,7 @@ class OutputLogPanel(wx.Panel):
self.sizer = wx.BoxSizer(wx.VERTICAL)
toolbarbox = wx.BoxSizer(wx.HORIZONTAL)
- self.toolbar = wx.ToolBar(self, -1, size=(-1,36))
+ self.toolbar = wx.ToolBar(self, -1)
self.toolbar.SetMargins((5, 0))
font, psize = self.toolbar.GetFont(), self.toolbar.GetFont().GetPointSize()
if PLATFORM == "darwin":
@@ -4221,7 +4871,7 @@ class OutputLogPanel(wx.Panel):
if PLATFORM == "win32":
self.toolbar.AddSeparator()
- title = wx.StaticText(self.toolbar, -1, "Output panel")
+ title = wx.StaticText(self.toolbar, -1, " Output panel")
title.SetFont(font)
self.toolbar.AddControl(title)
self.toolbar.AddSeparator()
@@ -4232,17 +4882,17 @@ class OutputLogPanel(wx.Panel):
self.toolbar.AddControl(self.processPopup)
if PLATFORM == "win32":
self.toolbar.AddSeparator()
- self.processKill = wx.Button(self.toolbar, -1, label="Kill", size=(40,-1))
+ self.processKill = wx.Button(self.toolbar, -1, label="Kill", size=(40,self.processPopup.GetSize()[1]))
self.processKill.SetFont(font)
self.toolbar.AddControl(self.processKill)
self.processKill.Bind(wx.EVT_BUTTON, self.killProcess)
if PLATFORM == "win32":
self.toolbar.AddSeparator()
- self.runningLabel = wx.StaticText(self.toolbar, -1, "Running: 0")
+ self.runningLabel = wx.StaticText(self.toolbar, -1, " Running: 0")
self.runningLabel.SetFont(font)
self.toolbar.AddControl(self.runningLabel)
self.toolbar.AddSeparator()
- self.copyLog = wx.Button(self.toolbar, -1, label="Copy log", size=(70,-1))
+ self.copyLog = wx.Button(self.toolbar, -1, label="Copy log", size=(70,self.processPopup.GetSize()[1]))
self.copyLog.SetFont(font)
self.toolbar.AddControl(self.copyLog)
self.copyLog.Bind(wx.EVT_BUTTON, self.onCopy)
@@ -4259,8 +4909,10 @@ class OutputLogPanel(wx.Panel):
self.toolbar.Realize()
toolbarbox.Add(self.toolbar, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
- tb2 = wx.ToolBar(self, -1, size=(-1,36))
- tb2.SetToolBitmapSize(tsize)
+ tb2 = wx.ToolBar(self, -1, size=(-1,32))
+ if PLATFORM == "darwin":
+ tb2.SetToolBitmapSize(tsize)
+ tb2.AddSeparator()
tb2.AddLabelTool(17, "Close Panel", close_panel_bmp, shortHelp="Close Panel")
tb2.Realize()
toolbarbox.Add(tb2, 0, wx.ALIGN_RIGHT, 0)
@@ -4286,14 +4938,15 @@ class OutputLogPanel(wx.Panel):
self.processPopup.Append("%d :: %s" % (procID, filename))
self.processPopup.SetStringSelection("%d :: %s" % (procID, filename))
self.running += 1
- self.runningLabel.SetLabel("Running: %d" % self.running)
+ self.runningLabel.SetLabel(" Running: %d" % self.running)
+ self.editor.setLog("")
def removeProcess(self, procID, filename):
str = "%d :: %s" % (procID, filename)
del self.mainPanel.mainFrame.processes[procID]
self.processPopup.Delete(self.processPopup.GetItems().index(str))
self.running -= 1
- self.runningLabel.SetLabel("Running: %d" % self.running)
+ self.runningLabel.SetLabel(" Running: %d" % self.running)
def killProcess(self, evt):
str = self.processPopup.GetStringSelection()
@@ -4301,6 +4954,11 @@ class OutputLogPanel(wx.Panel):
procID = int(str.split("::")[0].strip())
thread = self.mainPanel.mainFrame.processes[procID][0]
thread.kill()
+ if procID == 1000:
+ self.mainPanel.mainFrame.resetBackgroundServerMenu()
+
+ def appendToLog(self, text):
+ self.editor.appendToLog(text)
def setLog(self, text):
self.editor.setLog(text)
@@ -4365,69 +5023,83 @@ class PastingListEditorFrame(wx.Frame):
TOOL_ADD_FILE_ID = 10
TOOL_ADD_FOLDER_ID = 11
+TOOL_REFRESH_TREE_ID = 12
class ProjectTree(wx.Panel):
"""Project panel"""
def __init__(self, parent, mainPanel, size):
- wx.Panel.__init__(self, parent, -1, size=size, style=wx.WANTS_CHARS | wx.SUNKEN_BORDER | wx.EXPAND)
+ wx.Panel.__init__(self, parent, -1, size=size,
+ style=wx.WANTS_CHARS|wx.SUNKEN_BORDER|wx.EXPAND)
self.SetMinSize((150, -1))
self.mainPanel = mainPanel
self.projectDict = {}
- self.selected = None
+ self.selectedItem = None
self.edititem = self.editfolder = self.itempath = self.scope = None
tsize = (24, 24)
file_add_bmp = catalog['file_add_icon.png'].GetBitmap()
folder_add_bmp = catalog['folder_add_icon.png'].GetBitmap()
close_panel_bmp = catalog['close_panel_icon.png'].GetBitmap()
+ refresh_tree_bmp = catalog['refresh_tree_icon.png'].GetBitmap()
self.sizer = wx.BoxSizer(wx.VERTICAL)
toolbarbox = wx.BoxSizer(wx.HORIZONTAL)
self.toolbar = wx.ToolBar(self, -1, size=(-1,36))
self.toolbar.SetToolBitmapSize(tsize)
- self.toolbar.AddLabelTool(TOOL_ADD_FILE_ID, "Add File", file_add_bmp, shortHelp="Add File")
+ self.toolbar.AddLabelTool(TOOL_ADD_FILE_ID, "Add File",
+ file_add_bmp, shortHelp="Add File")
+ self.toolbar.AddLabelTool(TOOL_ADD_FOLDER_ID, "Add Folder",
+ folder_add_bmp, shortHelp="Add Folder")
+ self.toolbar.AddLabelTool(TOOL_REFRESH_TREE_ID, "Refresh Tree",
+ refresh_tree_bmp, shortHelp="Refresh Tree")
self.toolbar.EnableTool(TOOL_ADD_FILE_ID, False)
- self.toolbar.AddLabelTool(TOOL_ADD_FOLDER_ID, "Add Folder", folder_add_bmp, shortHelp="Add Folder")
self.toolbar.Realize()
toolbarbox.Add(self.toolbar, 1, wx.ALIGN_LEFT | wx.EXPAND, 0)
tb2 = wx.ToolBar(self, -1, size=(-1,36))
tb2.SetToolBitmapSize(tsize)
- tb2.AddLabelTool(15, "Close Panel", close_panel_bmp, shortHelp="Close Panel")
+ tb2.AddLabelTool(15, "Close Panel", close_panel_bmp,
+ shortHelp="Close Panel")
tb2.Realize()
toolbarbox.Add(tb2, 0, wx.ALIGN_RIGHT, 0)
wx.EVT_TOOL(self, TOOL_ADD_FILE_ID, self.onAdd)
wx.EVT_TOOL(self, TOOL_ADD_FOLDER_ID, self.onAdd)
+ wx.EVT_TOOL(self, TOOL_REFRESH_TREE_ID, self.onRefresh)
wx.EVT_TOOL(self, 15, self.onCloseProjectPanel)
self.sizer.Add(toolbarbox, 0, wx.EXPAND)
- self.tree = wx.TreeCtrl(self, -1, (0, 26), size, wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT|wx.SUNKEN_BORDER|wx.EXPAND)
+ stls = wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT|wx.SUNKEN_BORDER|wx.EXPAND
+ self.tree = wx.TreeCtrl(self, -1, (0, 26), size, stls)
self.tree.SetBackgroundColour(STYLES['background']['colour'])
if PLATFORM == 'darwin':
- self.tree.SetFont(wx.Font(11, wx.ROMAN, wx.NORMAL, wx.NORMAL, face=STYLES['face']))
- elif PLATFORM == 'win32':
- self.tree.SetFont(wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL, face=STYLES['face']))
+ pt = 11
else:
- self.tree.SetFont(wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL, face=STYLES['face']))
+ pt = 8
+ fnt = wx.Font(pt, wx.ROMAN, wx.NORMAL, wx.NORMAL, face=STYLES['face'])
+ self.tree.SetFont(fnt)
self.sizer.Add(self.tree, 1, wx.EXPAND)
self.SetSizer(self.sizer)
isz = (12,12)
self.il = wx.ImageList(isz[0], isz[1])
- self.fldridx = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz))
- self.fldropenidx = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz))
- self.fileidx = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, isz))
+ bmp = wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)
+ self.fldridx = self.il.Add(bmp)
+ bmp = wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)
+ self.fldropenidx = self.il.Add(bmp)
+ bmp = wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, isz)
+ self.fileidx = self.il.Add(bmp)
self.tree.SetImageList(self.il)
self.tree.SetSpacing(12)
self.tree.SetIndent(6)
- self.root = self.tree.AddRoot("EPyo_Project_tree", self.fldridx, self.fldropenidx, None)
+ self.root = self.tree.AddRoot("EPyo_Project_tree", self.fldridx,
+ self.fldropenidx, None)
self.tree.SetItemTextColour(self.root, STYLES['default']['colour'])
self.tree.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndEdit)
@@ -4435,65 +5107,82 @@ class ProjectTree(wx.Panel):
self.tree.Bind(wx.EVT_LEFT_DOWN, self.OnLeftClick)
self.tree.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
+ def _tree_analyze(self, item, expanded_list):
+ if self.tree.ItemHasChildren(item):
+ it, cookie = self.tree.GetFirstChild(item)
+ while it.IsOk():
+ if self.tree.ItemHasChildren(it) and self.tree.IsExpanded(it):
+ parent = self.tree.GetItemText(self.tree.GetItemParent(it))
+ expanded_list.append((parent, self.tree.GetItemText(it)))
+ self._tree_analyze(it, expanded_list)
+ it, cookie = self.tree.GetNextChild(item, cookie)
+
+ def _tree_restore(self, item, expanded_list):
+ if self.tree.ItemHasChildren(item):
+ it, cookie = self.tree.GetFirstChild(item)
+ while it.IsOk():
+ if self.tree.ItemHasChildren(it):
+ parent = self.tree.GetItemText(self.tree.GetItemParent(it))
+ if (parent, self.tree.GetItemText(it)) in expanded_list:
+ self.tree.Expand(it)
+ self._tree_restore(it, expanded_list)
+ it, cookie = self.tree.GetNextChild(item, cookie)
+
+ def onRefresh(self, evt):
+ expanded = []
+ self._tree_analyze(self.root, expanded)
+ self.tree.DeleteAllItems()
+ self.root = self.tree.AddRoot("EPyo_Project_tree", self.fldridx,
+ self.fldropenidx, None)
+ for folder, path in self.projectDict.items():
+ self.loadFolder(path)
+ self._tree_restore(self.root, expanded)
+
def loadFolder(self, dirPath):
folderName = os.path.split(dirPath)[1]
self.projectDict[folderName] = dirPath
- projectDir = {}
self.mainPanel.mainFrame.showProjectTree(True)
- for root, dirs, files in os.walk(dirPath):
- if os.path.split(root)[1][0] != '.' and os.path.split(root)[1] != "build":
- if root == dirPath:
- child = self.tree.AppendItem(self.root, folderName, self.fldridx, self.fldropenidx, None)
- self.tree.SetItemTextColour(child, STYLES['default']['colour'])
- if dirs:
- ddirs = [dir for dir in dirs if dir[0] != '.' and dir != "build"]
- for dir in sorted(ddirs):
- subfol = self.tree.AppendItem(child, "%s" % dir, self.fldridx, self.fldropenidx, None)
- projectDir[dir] = subfol
- self.tree.SetItemTextColour(subfol, STYLES['default']['colour'])
- if files:
- ffiles = [file for file in files if file[0] != '.' and not file.endswith("~") and os.path.splitext(file)[1].strip(".") in ALLOWED_EXT]
- for file in sorted(ffiles):
- item = self.tree.AppendItem(child, "%s" % file, self.fileidx, self.fileidx, None)
- self.tree.SetItemTextColour(item, STYLES['default']['colour'])
- else:
- if os.path.split(root)[1] in projectDir.keys():
- parent = projectDir[os.path.split(root)[1]]
- if dirs:
- ddirs = [dir for dir in dirs if dir[0] != '.' and "build/" not in root]
- for dir in sorted(ddirs):
- subfol = self.tree.AppendItem(parent, "%s" % dir, self.fldridx, self.fldropenidx, None)
- projectDir[dir] = subfol
- self.tree.SetItemTextColour(subfol, STYLES['default']['colour'])
- if files:
- ffiles = [file for file in files if file[0] != '.' and not file.endswith("~") and os.path.splitext(file)[1].strip(".") in ALLOWED_EXT]
- for file in sorted(ffiles):
- item = self.tree.AppendItem(parent, "%s" % file, self.fileidx, self.fileidx, None)
- self.tree.SetItemTextColour(item, STYLES['default']['colour'])
- self.tree.SortChildren(self.root)
- self.tree.SortChildren(child)
+ item = self.tree.AppendItem(self.root, folderName, self.fldridx,
+ self.fldropenidx, None)
+ self.tree.SetPyData(item, dirPath)
+ self.tree.SetItemTextColour(item, STYLES['default']['colour'])
+ self.buildRecursiveTree(dirPath, item)
+
+ def buildRecursiveTree(self, dir, item):
+ elems = [f for f in os.listdir(dir) if f[0] != "."]
+ for elem in sorted(elems):
+ child = None
+ path = os.path.join(dir, elem)
+ if os.path.isfile(path):
+ if not path.endswith("~") and \
+ os.path.splitext(path)[1].strip(".") in ALLOWED_EXT:
+ child = self.tree.AppendItem(item, elem, self.fileidx,
+ self.fileidx)
+ self.tree.SetPyData(child, os.path.join(dir, path))
+ elif os.path.isdir(path):
+ if elem != "build":
+ child = self.tree.AppendItem(item, elem, self.fldridx,
+ self.fldropenidx)
+ self.tree.SetPyData(child, os.path.join(dir, path))
+ self.buildRecursiveTree(path, child)
+ if child is not None:
+ self.tree.SetItemTextColour(child, STYLES['default']['colour'])
def onAdd(self, evt):
id = evt.GetId()
treeItemId = self.tree.GetSelection()
- if self.selected != None:
- for dirPath in self.projectDict.keys():
- for root, dirs, files in os.walk(self.projectDict[dirPath]):
- if self.selected == os.path.split(root)[1]:
- self.scope = root
- break
- elif self.selected in dirs:
- self.scope = os.path.join(root, self.selected)
- break
- elif self.selected in files:
- self.scope = root
- treeItemId = self.tree.GetItemParent(treeItemId)
- break
- if self.scope != None:
- break
- elif self.selected == None and id == TOOL_ADD_FOLDER_ID:
- dlg = wx.DirDialog(self, "Choose a directory where to save your folder:",
- defaultPath=os.path.expanduser("~"), style=wx.DD_DEFAULT_STYLE)
+ if self.selectedItem != None:
+ selPath = self.tree.GetPyData(self.selectedItem)
+ if os.path.isdir(selPath):
+ self.scope = selPath
+ elif os.path.isfile(selPath):
+ treeItemId = self.tree.GetItemParent(treeItemId)
+ self.scope = self.tree.GetPyData(treeItemId)
+ elif self.selectedItem == None and id == TOOL_ADD_FOLDER_ID:
+ dlg = wx.DirDialog(self,
+ "Choose directory where to save your folder:",
+ defaultPath=os.path.expanduser("~"),
+ style=wx.DD_DEFAULT_STYLE)
if dlg.ShowModal() == wx.ID_OK:
self.scope = dlg.GetPath()
dlg.Destroy()
@@ -4502,11 +5191,14 @@ class ProjectTree(wx.Panel):
return
treeItemId = self.tree.GetRootItem()
if id == TOOL_ADD_FILE_ID:
- item = self.tree.AppendItem(treeItemId, "Untitled", self.fileidx, self.fileidx, None)
+ item = self.tree.AppendItem(treeItemId, "Untitled", self.fileidx,
+ self.fileidx, None)
self.edititem = item
else:
- item = self.tree.AppendItem(treeItemId, "Untitled", self.fldridx, self.fldropenidx, None)
+ item = self.tree.AppendItem(treeItemId, "Untitled", self.fldridx,
+ self.fldropenidx, None)
self.editfolder = item
+ self.tree.SetPyData(item, os.path.join(self.scope, "Untitled"))
self.tree.SetItemTextColour(item, STYLES['default']['colour'])
self.tree.EnsureVisible(item)
if PLATFORM == "darwin":
@@ -4535,14 +5227,8 @@ class ProjectTree(wx.Panel):
def OnRightDown(self, event):
pt = event.GetPosition();
self.edititem, flags = self.tree.HitTest(pt)
- item = self.edititem
- if item:
- itemlist = []
- while self.tree.GetItemText(item) not in self.projectDict.keys():
- itemlist.insert(0, self.tree.GetItemText(item))
- item = self.tree.GetItemParent(item)
- itemlist.insert(0, self.projectDict[self.tree.GetItemText(item)])
- self.itempath = os.path.join(*itemlist)
+ if self.edititem:
+ self.itempath = self.tree.GetPyData(self.edititem)
self.select(self.edititem)
self.tree.EditLabel(self.edititem)
else:
@@ -4552,14 +5238,18 @@ class ProjectTree(wx.Panel):
if self.edititem and self.itempath:
self.select(self.edititem)
head, tail = os.path.split(self.itempath)
- newpath = os.path.join(head, event.GetLabel())
- os.rename(self.itempath, newpath)
+ newlabel = event.GetLabel()
+ if newlabel != "":
+ newpath = os.path.join(head, event.GetLabel())
+ os.rename(self.itempath, newpath)
+ self.tree.SetPyData(self.edititem, newpath)
elif self.edititem and self.scope:
newitem = event.GetLabel()
if not newitem:
newitem = "Untitled"
wx.CallAfter(self.tree.SetItemText, self.edititem, newitem)
newpath = os.path.join(self.scope, newitem)
+ self.tree.SetPyData(self.edititem, newpath)
f = open(newpath, "w")
f.close()
self.mainPanel.addPage(newpath)
@@ -4569,8 +5259,9 @@ class ProjectTree(wx.Panel):
newitem = "Untitled"
wx.CallAfter(self.tree.SetItemText, self.editfolder, newitem)
newpath = os.path.join(self.scope, newitem)
+ self.tree.SetPyData(self.editfolder, newpath)
os.mkdir(newpath)
- if self.selected == None:
+ if self.selectedItem == None:
self.projectDict[newitem] = self.scope
self.edititem = self.editfolder = self.itempath = self.scope = None
@@ -4596,30 +5287,17 @@ class ProjectTree(wx.Panel):
def openPage(self, item):
hasChild = self.tree.ItemHasChildren(item)
if not hasChild:
- parent = None
- ritem = item
- filename = self.tree.GetItemText(ritem)
- while self.tree.GetItemParent(ritem) != self.tree.GetRootItem():
- ritem = self.tree.GetItemParent(ritem)
- parent = self.tree.GetItemText(ritem)
- filename = os.path.join(parent, filename)
- dirPath = os.path.split(self.projectDict[parent])[0]
- path = os.path.join(dirPath, filename)
-# for root, dirs, files in os.walk(dirPath):
-# if files:
-# for file in files:
-# if file == self.tree.GetItemText(item):
-# path = os.path.join(root, file)
+ path = self.tree.GetPyData(item)
self.mainPanel.addPage(path)
def select(self, item):
self.tree.SelectItem(item)
- self.selected = self.tree.GetItemText(item)
+ self.selectedItem = item
self.toolbar.EnableTool(TOOL_ADD_FILE_ID, True)
def unselect(self):
self.tree.UnselectAll()
- self.selected = None
+ self.selectedItem = None
self.toolbar.EnableTool(TOOL_ADD_FILE_ID, False)
def onCloseProjectPanel(self, evt):
@@ -4627,7 +5305,8 @@ class ProjectTree(wx.Panel):
class MarkersListScroll(scrolled.ScrolledPanel):
def __init__(self, parent, id=-1, pos=(25,25), size=(500,400)):
- scrolled.ScrolledPanel.__init__(self, parent, wx.ID_ANY, pos=(0,0), size=size, style=wx.SUNKEN_BORDER)
+ scrolled.ScrolledPanel.__init__(self, parent, wx.ID_ANY, pos=(0,0),
+ size=size, style=wx.SUNKEN_BORDER)
self.parent = parent
self.SetBackgroundColour(STYLES['background']['colour'])
self.arrow_bit = catalog['left_arrow.png'].GetBitmap()
@@ -4651,16 +5330,18 @@ class MarkersListScroll(scrolled.ScrolledPanel):
def setDict(self, dic):
self.row_dict = dic
self.box.Clear(True)
- for i, key in enumerate(sorted(self.row_dict.keys())):
+ swap = [(x[1], x[0]) for x in self.row_dict.items()]
+ handles = [x[1] for x in sorted(swap)]
+ for i in handles:
label = wx.StaticBitmap(self, wx.ID_ANY)
label.SetBitmap(self.arrow_bit)
- self.box.Add(label, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 2, userData=(i,key))
- line = wx.StaticText(self, wx.ID_ANY, label=str(key+1))
+ self.box.Add(label, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 2, userData=(i,self.row_dict[i][0]))
+ line = wx.StaticText(self, wx.ID_ANY, label=str(self.row_dict[i][0]+1))
line.SetFont(self.font)
- self.box.Add(line, 0, wx.ALIGN_LEFT|wx.TOP, 3, userData=(i,key))
- comment = wx.StaticText(self, wx.ID_ANY, label=self.row_dict[key])
+ self.box.Add(line, 0, wx.ALIGN_LEFT|wx.TOP, 3, userData=(i,self.row_dict[i][0]))
+ comment = wx.StaticText(self, wx.ID_ANY, label=self.row_dict[i][1])
comment.SetFont(self.font)
- self.box.Add(comment, 1, wx.EXPAND|wx.ALIGN_LEFT|wx.TOP, 3, userData=(i,key))
+ self.box.Add(comment, 1, wx.EXPAND|wx.ALIGN_LEFT|wx.TOP, 3, userData=(i,self.row_dict[i][0]))
self.box.Layout()
label.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
line.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
@@ -4683,13 +5364,14 @@ class MarkersListScroll(scrolled.ScrolledPanel):
halfNumLinesOnScreen = editor.LinesOnScreen() / 2
editor.ScrollToLine(line - halfNumLinesOnScreen)
else:
- line = sorted(self.row_dict.keys())[self.selected]
+ line = self.row_dict[self.selected][0]
self.selected2 = item.GetUserData()[0]
line2 = item.GetUserData()[1]
- editor.GotoLine(line)
+ l1, l2 = min(line, line2), max(line, line2)
+ editor.GotoLine(l1)
halfNumLinesOnScreen = editor.LinesOnScreen() / 2
- editor.ScrollToLine(line - halfNumLinesOnScreen)
- editor.SetSelection(editor.PositionFromLine(line), editor.PositionFromLine(line2+1))
+ editor.ScrollToLine(l1 - halfNumLinesOnScreen)
+ editor.SetSelection(editor.PositionFromLine(l1), editor.PositionFromLine(l2+1))
break
self.setColour()
@@ -4769,7 +5451,7 @@ class PreferencesDialog(wx.Dialog):
font.SetWeight(wx.BOLD)
if PLATFORM == "linux2":
- entryfont.SetPointSize(pointsize-1)
+ entryfont.SetPointSize(pointsize)
elif PLATFORM == "win32":
entryfont.SetPointSize(pointsize)
else:
@@ -4813,7 +5495,7 @@ class PreferencesDialog(wx.Dialog):
mainSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, 5)
- lbl = wx.StaticText(self, label="Background Pyo Server")
+ lbl = wx.StaticText(self, label="=== Background Pyo Server ===")
lbl.SetFont(font)
mainSizer.Add(lbl, 0, wx.BOTTOM|wx.LEFT|wx.RIGHT, 10)
@@ -4824,59 +5506,76 @@ class PreferencesDialog(wx.Dialog):
self.server_args = wx.TextCtrl(self, size=(500,-1), value=BACKGROUND_SERVER_ARGS)
self.server_args.SetFont(entryfont)
ctrlSizer.Add(self.server_args, 0, wx.ALL|wx.EXPAND, 5)
- but = wx.Button(self, id=wx.ID_ANY, label="Restore default args")
+ but = wx.Button(self, id=wx.ID_ANY, label=" Restore default args ")
but.Bind(wx.EVT_BUTTON, self.setServerDefaultArgs)
ctrlSizer.Add(but, 0, wx.ALL, 5)
mainSizer.Add(ctrlSizer, 0, wx.BOTTOM|wx.LEFT|wx.RIGHT, 5)
- popupSizer = wx.FlexGridSizer(2, 3, 5, 10)
- for label in ["Output Driver", "Input Driver", "Midi Interface"]:
+ popupSizer = wx.FlexGridSizer(2, 4, 5, 10)
+ for label in ["Input Driver", "Output Driver", "Midi Input", "Midi Output"]:
lbl = wx.StaticText(self, label=label)
lbl.SetFont(font)
popupSizer.Add(lbl)
- preferedDriver = PREFERENCES.get("background_server_out_device", "")
- driverList, driverIndexes = pa_get_output_devices()
- driverList = [ensureNFD(driver) for driver in driverList]
- defaultDriver = pa_get_default_output()
- self.popupOutDriver = wx.Choice(self, choices=driverList)
- popupSizer.Add(self.popupOutDriver)
- if preferedDriver and preferedDriver in driverList:
- driverIndex = driverIndexes[driverList.index(preferedDriver)]
- self.popupOutDriver.SetStringSelection(preferedDriver)
- elif defaultDriver:
- self.popupOutDriver.SetSelection(driverIndexes.index(defaultDriver))
-
+ cX = 160
preferedDriver = PREFERENCES.get("background_server_in_device", "")
driverList, driverIndexes = pa_get_input_devices()
driverList = [ensureNFD(driver) for driver in driverList]
defaultDriver = pa_get_default_input()
- self.popupInDriver = wx.Choice(self, choices=driverList)
- popupSizer.Add(self.popupInDriver)
+ self.popupInDriver = wx.Choice(self, choices=driverList, size=(cX,-1))
+ popupSizer.Add(self.popupInDriver, 1, wx.EXPAND, 5)
if preferedDriver and preferedDriver in driverList:
driverIndex = driverIndexes[driverList.index(preferedDriver)]
self.popupInDriver.SetStringSelection(preferedDriver)
elif defaultDriver:
self.popupInDriver.SetSelection(driverIndexes.index(defaultDriver))
+ preferedDriver = PREFERENCES.get("background_server_out_device", "")
+ driverList, driverIndexes = pa_get_output_devices()
+ driverList = [ensureNFD(driver) for driver in driverList]
+ defaultDriver = pa_get_default_output()
+ self.popupOutDriver = wx.Choice(self, choices=driverList, size=(cX,-1))
+ popupSizer.Add(self.popupOutDriver, 1, wx.EXPAND, 5)
+ if preferedDriver and preferedDriver in driverList:
+ driverIndex = driverIndexes[driverList.index(preferedDriver)]
+ self.popupOutDriver.SetStringSelection(preferedDriver)
+ elif defaultDriver:
+ self.popupOutDriver.SetSelection(driverIndexes.index(defaultDriver))
+
+ # TODO: Added "all" interfaces option in input and output
preferedDriver = PREFERENCES.get("background_server_midiin_device", "")
driverList, driverIndexes = pm_get_input_devices()
driverList = [ensureNFD(driver) for driver in driverList]
if driverList != []:
defaultDriver = pm_get_default_input()
- self.popupMidiInDriver = wx.Choice(self, choices=driverList)
- popupSizer.Add(self.popupMidiInDriver)
+ self.popupMidiInDriver = wx.Choice(self, choices=driverList, size=(cX,-1))
if preferedDriver and preferedDriver in driverList:
driverIndex = driverIndexes[driverList.index(preferedDriver)]
self.popupMidiInDriver.SetStringSelection(preferedDriver)
- elif defaultDriver:
+ elif defaultDriver >= 0:
self.popupMidiInDriver.SetSelection(driverIndexes.index(defaultDriver))
else:
self.popupMidiInDriver = wx.Choice(self, choices=["No Interface"])
- popupSizer.Add(self.popupMidiInDriver)
self.popupMidiInDriver.SetSelection(0)
+ popupSizer.Add(self.popupMidiInDriver, 1, wx.EXPAND, 5)
- mainSizer.Add(popupSizer, 0, wx.BOTTOM|wx.LEFT|wx.RIGHT, 10)
+ preferedDriver = PREFERENCES.get("background_server_midiout_device", "")
+ driverList, driverIndexes = pm_get_output_devices()
+ driverList = [ensureNFD(driver) for driver in driverList]
+ if driverList != []:
+ defaultDriver = pm_get_default_output()
+ self.popupMidiOutDriver = wx.Choice(self, choices=driverList, size=(cX,-1))
+ if preferedDriver and preferedDriver in driverList:
+ driverIndex = driverIndexes[driverList.index(preferedDriver)]
+ self.popupMidiOutDriver.SetStringSelection(preferedDriver)
+ elif defaultDriver >= 0:
+ self.popupMidiOutDriver.SetSelection(driverIndexes.index(defaultDriver))
+ else:
+ self.popupMidiOutDriver = wx.Choice(self, choices=["No Interface"])
+ self.popupMidiOutDriver.SetSelection(0)
+ popupSizer.Add(self.popupMidiOutDriver, 1, wx.EXPAND, 5)
+
+ mainSizer.Add(popupSizer, 0, wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, 10)
mainSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, 5)
@@ -4886,8 +5585,8 @@ class PreferencesDialog(wx.Dialog):
ctrlSizer = wx.BoxSizer(wx.HORIZONTAL)
self.entry_ext = wx.TextCtrl(self, size=(500,-1), value=", ".join(ALLOWED_EXT))
self.entry_ext.SetFont(entryfont)
- ctrlSizer.Add(self.entry_ext, 0, wx.ALL|wx.EXPAND, 5)
- mainSizer.Add(ctrlSizer, 0, wx.BOTTOM|wx.LEFT|wx.RIGHT, 5)
+ ctrlSizer.Add(self.entry_ext, 1, wx.ALL|wx.EXPAND, 5)
+ mainSizer.Add(ctrlSizer, 0, wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, 5)
btnSizer = self.CreateButtonSizer(wx.CANCEL|wx.OK)
@@ -4968,6 +5667,9 @@ class PreferencesDialog(wx.Dialog):
midiDevice = self.popupMidiInDriver.GetStringSelection()
if midiDevice != "No Interface":
PREFERENCES["background_server_midiin_device"] = midiDevice
+ midiDevice = self.popupMidiOutDriver.GetStringSelection()
+ if midiDevice != "No Interface":
+ PREFERENCES["background_server_midiout_device"] = midiDevice
class STCPrintout(wx.Printout):
"""Specific printing support of the wx.StyledTextCtrl for the wxPython
@@ -4987,9 +5689,10 @@ class STCPrintout(wx.Printout):
a wrapped line, so it may be a difficult task to ever implement printing
with line wrapping using the wx.StyledTextCtrl.FormatRange method.
"""
- debuglevel = 0
+ debuglevel = 1
- def __init__(self, stc, page_setup_data=None, print_mode=None, title=None, border=False, lines_per_page=None, output_point_size=None):
+ def __init__(self, stc, page_setup_data=None, print_mode=None, title=None,
+ border=False, lines_per_page=None, output_point_size=None):
"""Constructor.
@param stc: wx.StyledTextCtrl to print
@@ -5050,6 +5753,7 @@ class STCPrintout(wx.Printout):
except (TypeError, ValueError):
self.user_lines_per_page = None
+ self.page_count = 2
self.border_around_text = border
self.setHeaderFont()
@@ -5379,7 +6083,8 @@ class STCPrintout(wx.Printout):
if self.border_around_text:
dc.SetPen(wx.BLACK_PEN)
dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.DrawRectangle(self.x1, self.y1, self.x2 - self.x1 + 1, self.y2 - self.y1 + 1)
+ dc.DrawRectangle(self.x1, self.y1, self.x2 - self.x1 + 1,
+ self.y2 - self.y1 + 1)
class MyFileDropTarget(wx.FileDropTarget):
def __init__(self, window):
@@ -5396,6 +6101,38 @@ class MyFileDropTarget(wx.FileDropTarget):
else:
pass
+class EPyoApp(wx.App):
+ def __init__(self, *args, **kwargs):
+ wx.App.__init__(self, *args, **kwargs)
+
+ def OnInit(self):
+ X = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
+ Y = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
+ if X < 850: X -= 50
+ else: X = 850
+ if Y < 750: Y -= 50
+ else: Y = 750
+ self.frame = MainFrame(None, -1, title='E-Pyo Editor',
+ pos=(10,25), size=(X, Y))
+ self.frame.Show()
+ return True
+
+ def MacOpenFiles(self, filenames):
+ if type(filenames) != ListType:
+ filenames = [filenames]
+ for filename in filenames:
+ if os.path.isdir(filename):
+ self.frame.panel.project.loadFolder(filename)
+ sys.path.append(filename)
+ elif os.path.isfile(filename):
+ self.frame.panel.addPage(filename)
+
+ def MacReopenApp(self):
+ try:
+ self.frame.Raise()
+ except:
+ pass
+
if __name__ == '__main__':
filesToOpen = []
foldersToOpen = []
@@ -5409,12 +6146,5 @@ if __name__ == '__main__':
else:
pass
- app = wx.App(False)
- X,Y = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X), wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
- if X < 850: X -= 50
- else: X = 850
- if Y < 750: Y -= 50
- else: Y = 750
- frame = MainFrame(None, -1, title='E-Pyo Editor', pos=(10,25), size=(X, Y))
- frame.Show()
+ app = EPyoApp(redirect=False)
app.MainLoop()
diff --git a/utils/FlatNotebook.py b/utils/FlatNotebook.py
deleted file mode 100755
index f4c7d34..0000000
--- a/utils/FlatNotebook.py
+++ /dev/null
@@ -1,4940 +0,0 @@
-# --------------------------------------------------------------------------- #
-# FLATNOTEBOOK Widget wxPython IMPLEMENTATION
-#
-# Original C++ Code From Eran. You Can Find It At:
-#
-# http://wxforum.shadonet.com/viewtopic.php?t=5761&start=0
-#
-# License: wxWidgets license
-#
-#
-# Python Code By:
-#
-# Andrea Gavana, @ 02 Oct 2006
-# Latest Revision: 30 May 2008, 23.00 GMT
-#
-#
-# For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
-# Write To Me At:
-#
-# andrea.gavana at gmail.com
-# gavana at kpo.kz
-#
-# Or, Obviously, To The wxPython Mailing List!!!
-#
-#
-# End Of Comments
-# --------------------------------------------------------------------------- #
-
-"""
-The FlatNotebook is a full implementation of the wx.Notebook, and designed to be
-a drop-in replacement for wx.Notebook. The API functions are similar so one can
-expect the function to behave in the same way.
-
-Some features:
-
- - The buttons are highlighted a la Firefox style
- - The scrolling is done for bulks of tabs (so, the scrolling is faster and better)
- - The buttons area is never overdrawn by tabs (unlike many other implementations I saw)
- - It is a generic control
- - Currently there are 5 differnt styles - VC8, VC 71, Standard, Fancy and Firefox 2;
- - Mouse middle click can be used to close tabs
- - A function to add right click menu for tabs (simple as SetRightClickMenu)
- - All styles has bottom style as well (they can be drawn in the bottom of screen)
- - An option to hide 'X' button or navigation buttons (separately)
- - Gradient coloring of the selected tabs and border
- - Support for drag 'n' drop of tabs, both in the same notebook or to another notebook
- - Possibility to have closing button on the active tab directly
- - Support for disabled tabs
- - Colours for active/inactive tabs, and captions
- - Background of tab area can be painted in gradient (VC8 style only)
- - Colourful tabs - a random gentle colour is generated for each new tab (very cool, VC8 style only)
-
-
-And much more.
-
-
-License And Version:
-
-FlatNotebook Is Freeware And Distributed Under The wxPython License.
-
-Latest Revision: Andrea Gavana @ 30 May 2008, 23.00 GMT
-
-Version 2.5.
-
- at undocumented: FNB_HEIGHT_SPACER, VERTICAL_BORDER_PADDING, VC8_SHAPE_LEN,
- wxEVT*, left_arrow_*, right_arrow*, x_button*, down_arrow*,
- FNBDragInfo, FNBDropTarget, GetMondrian*
-"""
-
-__docformat__ = "epytext"
-
-
-#----------------------------------------------------------------------
-# Beginning Of FLATNOTEBOOK wxPython Code
-#----------------------------------------------------------------------
-
-import wx
-import random
-import math
-import weakref
-import cPickle
-
-if wx.Platform == '__WXMAC__':
- import Carbon.Appearance
-
-# Check for the new method in 2.7 (not present in 2.6.3.3)
-if wx.VERSION_STRING < "2.7":
- wx.Rect.Contains = lambda self, point: wx.Rect.Inside(self, point)
-
-FNB_HEIGHT_SPACER = 10
-
-# Use Visual Studio 2003 (VC7.1) style for tabs
-FNB_VC71 = 1
-"""Use Visual Studio 2003 (VC7.1) style for tabs"""
-
-# Use fancy style - square tabs filled with gradient coloring
-FNB_FANCY_TABS = 2
-"""Use fancy style - square tabs filled with gradient coloring"""
-
-# Draw thin border around the page
-FNB_TABS_BORDER_SIMPLE = 4
-"""Draw thin border around the page"""
-
-# Do not display the 'X' button
-FNB_NO_X_BUTTON = 8
-"""Do not display the 'X' button"""
-
-# Do not display the Right / Left arrows
-FNB_NO_NAV_BUTTONS = 16
-"""Do not display the right/left arrows"""
-
-# Use the mouse middle button for cloing tabs
-FNB_MOUSE_MIDDLE_CLOSES_TABS = 32
-"""Use the mouse middle button for cloing tabs"""
-
-# Place tabs at bottom - the default is to place them
-# at top
-FNB_BOTTOM = 64
-"""Place tabs at bottom - the default is to place them at top"""
-
-# Disable dragging of tabs
-FNB_NODRAG = 128
-"""Disable dragging of tabs"""
-
-# Use Visual Studio 2005 (VC8) style for tabs
-FNB_VC8 = 256
-"""Use Visual Studio 2005 (VC8) style for tabs"""
-
-# Firefox 2 tabs style
-FNB_FF2 = 131072
-"""Use Firefox 2 style for tabs"""
-
-# Place 'X' on a tab
-FNB_X_ON_TAB = 512
-"""Place 'X' close button on the active tab"""
-
-FNB_BACKGROUND_GRADIENT = 1024
-"""Use gradients to paint the tabs background"""
-
-FNB_COLORFUL_TABS = 2048
-"""Use colourful tabs (VC8 style only)"""
-
-# Style to close tab using double click - styles 1024, 2048 are reserved
-FNB_DCLICK_CLOSES_TABS = 4096
-"""Style to close tab using double click"""
-
-FNB_SMART_TABS = 8192
-"""Use Smart Tabbing, like Alt+Tab on Windows"""
-
-FNB_DROPDOWN_TABS_LIST = 16384
-"""Use a dropdown menu on the left in place of the arrows"""
-
-FNB_ALLOW_FOREIGN_DND = 32768
-"""Allows drag 'n' drop operations between different L{FlatNotebook}s"""
-
-FNB_HIDE_ON_SINGLE_TAB = 65536
-"""Hides the Page Container when there is one or fewer tabs"""
-
-VERTICAL_BORDER_PADDING = 4
-
-# Button size is a 16x16 xpm bitmap
-BUTTON_SPACE = 16
-"""Button size is a 16x16 xpm bitmap"""
-
-VC8_SHAPE_LEN = 16
-
-MASK_COLOR = wx.Colour(0, 128, 128)
-"""Mask colour for the arrow bitmaps"""
-
-# Button status
-FNB_BTN_PRESSED = 2
-"""Navigation button is pressed"""
-FNB_BTN_HOVER = 1
-"""Navigation button is hovered"""
-FNB_BTN_NONE = 0
-"""No navigation"""
-
-# Hit Test results
-FNB_TAB = 1 # On a tab
-"""Indicates mouse coordinates inside a tab"""
-FNB_X = 2 # On the X button
-"""Indicates mouse coordinates inside the I{X} region"""
-FNB_TAB_X = 3 # On the 'X' button (tab's X button)
-"""Indicates mouse coordinates inside the I{X} region in a tab"""
-FNB_LEFT_ARROW = 4 # On the rotate left arrow button
-"""Indicates mouse coordinates inside the left arrow region"""
-FNB_RIGHT_ARROW = 5 # On the rotate right arrow button
-"""Indicates mouse coordinates inside the right arrow region"""
-FNB_DROP_DOWN_ARROW = 6 # On the drop down arrow button
-"""Indicates mouse coordinates inside the drop down arrow region"""
-FNB_NOWHERE = 0 # Anywhere else
-"""Indicates mouse coordinates not on any tab of the notebook"""
-
-FNB_DEFAULT_STYLE = FNB_MOUSE_MIDDLE_CLOSES_TABS | FNB_HIDE_ON_SINGLE_TAB
-"""L{FlatNotebook} default style"""
-
-# FlatNotebook Events:
-# wxEVT_FLATNOTEBOOK_PAGE_CHANGED: Event Fired When You Switch Page;
-# wxEVT_FLATNOTEBOOK_PAGE_CHANGING: Event Fired When You Are About To Switch
-# Pages, But You Can Still "Veto" The Page Changing By Avoiding To Call
-# event.Skip() In Your Event Handler;
-# wxEVT_FLATNOTEBOOK_PAGE_CLOSING: Event Fired When A Page Is Closing, But
-# You Can Still "Veto" The Page Changing By Avoiding To Call event.Skip()
-# In Your Event Handler;
-# wxEVT_FLATNOTEBOOK_PAGE_CLOSED: Event Fired When A Page Is Closed.
-# wxEVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU: Event Fired When A Menu Pops-up In A Tab.
-
-wxEVT_FLATNOTEBOOK_PAGE_CHANGED = wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
-wxEVT_FLATNOTEBOOK_PAGE_CHANGING = wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
-wxEVT_FLATNOTEBOOK_PAGE_CLOSING = wx.NewEventType()
-wxEVT_FLATNOTEBOOK_PAGE_CLOSED = wx.NewEventType()
-wxEVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU = wx.NewEventType()
-
-#-----------------------------------#
-# FlatNotebookEvent
-#-----------------------------------#
-
-EVT_FLATNOTEBOOK_PAGE_CHANGED = wx.EVT_NOTEBOOK_PAGE_CHANGED
-"""Notify client objects when the active page in L{FlatNotebook}
-has changed."""
-EVT_FLATNOTEBOOK_PAGE_CHANGING = wx.EVT_NOTEBOOK_PAGE_CHANGING
-"""Notify client objects when the active page in L{FlatNotebook}
-is about to change."""
-EVT_FLATNOTEBOOK_PAGE_CLOSING = wx.PyEventBinder(wxEVT_FLATNOTEBOOK_PAGE_CLOSING, 1)
-"""Notify client objects when a page in L{FlatNotebook} is closing."""
-EVT_FLATNOTEBOOK_PAGE_CLOSED = wx.PyEventBinder(wxEVT_FLATNOTEBOOK_PAGE_CLOSED, 1)
-"""Notify client objects when a page in L{FlatNotebook} has been closed."""
-EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU = wx.PyEventBinder(wxEVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU, 1)
-"""Notify client objects when a pop-up menu should appear next to a tab."""
-
-
-# Some icons in XPM format
-
-left_arrow_disabled_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #555555",
- "# c #000000",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````.```````",
- "```````..```````",
- "``````.`.```````",
- "`````.``.```````",
- "````.```.```````",
- "`````.``.```````",
- "``````.`.```````",
- "```````..```````",
- "````````.```````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````"
- ]
-
-x_button_pressed_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #4766e0",
- "# c #9e9ede",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "`..............`",
- "`.############.`",
- "`.############.`",
- "`.############.`",
- "`.###aa####aa#.`",
- "`.####aa##aa##.`",
- "`.#####aaaa###.`",
- "`.######aa####.`",
- "`.#####aaaa###.`",
- "`.####aa##aa##.`",
- "`.###aa####aa#.`",
- "`.############.`",
- "`..............`",
- "````````````````",
- "````````````````"
- ]
-
-
-left_arrow_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #555555",
- "# c #000000",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````.```````",
- "```````..```````",
- "``````...```````",
- "`````....```````",
- "````.....```````",
- "`````....```````",
- "``````...```````",
- "```````..```````",
- "````````.```````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````"
- ]
-
-x_button_hilite_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #4766e0",
- "# c #c9dafb",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "`..............`",
- "`.############.`",
- "`.############.`",
- "`.##aa####aa##.`",
- "`.###aa##aa###.`",
- "`.####aaaa####.`",
- "`.#####aa#####.`",
- "`.####aaaa####.`",
- "`.###aa##aa###.`",
- "`.##aa####aa##.`",
- "`.############.`",
- "`.############.`",
- "`..............`",
- "````````````````",
- "````````````````"
- ]
-
-x_button_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #555555",
- "# c #000000",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````..````..````",
- "`````..``..`````",
- "``````....``````",
- "```````..```````",
- "``````....``````",
- "`````..``..`````",
- "````..````..````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````"
- ]
-
-left_arrow_pressed_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #4766e0",
- "# c #9e9ede",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "`..............`",
- "`.############.`",
- "`.############.`",
- "`.#######a####.`",
- "`.######aa####.`",
- "`.#####aaa####.`",
- "`.####aaaa####.`",
- "`.###aaaaa####.`",
- "`.####aaaa####.`",
- "`.#####aaa####.`",
- "`.######aa####.`",
- "`.#######a####.`",
- "`..............`",
- "````````````````",
- "````````````````"
- ]
-
-left_arrow_hilite_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #4766e0",
- "# c #c9dafb",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "`..............`",
- "`.############.`",
- "`.######a#####.`",
- "`.#####aa#####.`",
- "`.####aaa#####.`",
- "`.###aaaa#####.`",
- "`.##aaaaa#####.`",
- "`.###aaaa#####.`",
- "`.####aaa#####.`",
- "`.#####aa#####.`",
- "`.######a#####.`",
- "`.############.`",
- "`..............`",
- "````````````````",
- "````````````````"
- ]
-
-right_arrow_disabled_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #555555",
- "# c #000000",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "````````````````",
- "````````````````",
- "```````.````````",
- "```````..```````",
- "```````.`.``````",
- "```````.``.`````",
- "```````.```.````",
- "```````.``.`````",
- "```````.`.``````",
- "```````..```````",
- "```````.````````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````"
- ]
-
-right_arrow_hilite_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #4766e0",
- "# c #c9dafb",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "`..............`",
- "`.############.`",
- "`.####a#######.`",
- "`.####aa######.`",
- "`.####aaa#####.`",
- "`.####aaaa####.`",
- "`.####aaaaa###.`",
- "`.####aaaa####.`",
- "`.####aaa#####.`",
- "`.####aa######.`",
- "`.####a#######.`",
- "`.############.`",
- "`..............`",
- "````````````````",
- "````````````````"
- ]
-
-right_arrow_pressed_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #4766e0",
- "# c #9e9ede",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "`..............`",
- "`.############.`",
- "`.############.`",
- "`.#####a######.`",
- "`.#####aa#####.`",
- "`.#####aaa####.`",
- "`.#####aaaa###.`",
- "`.#####aaaaa##.`",
- "`.#####aaaa###.`",
- "`.#####aaa####.`",
- "`.#####aa#####.`",
- "`.#####a######.`",
- "`..............`",
- "````````````````",
- "````````````````"
- ]
-
-
-right_arrow_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #555555",
- "# c #000000",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "````````````````",
- "````````````````",
- "```````.````````",
- "```````..```````",
- "```````...``````",
- "```````....`````",
- "```````.....````",
- "```````....`````",
- "```````...``````",
- "```````..```````",
- "```````.````````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````"
- ]
-
-down_arrow_hilite_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #4766e0",
- "# c #c9dafb",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "``.............`",
- "``.###########.`",
- "``.###########.`",
- "``.###########.`",
- "``.#aaaaaaaaa#.`",
- "``.##aaaaaaa##.`",
- "``.###aaaaa###.`",
- "``.####aaa####.`",
- "``.#####a#####.`",
- "``.###########.`",
- "``.###########.`",
- "``.###########.`",
- "``.............`",
- "````````````````",
- "````````````````"
- ]
-
-down_arrow_pressed_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #4766e0",
- "# c #9e9ede",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "``.............`",
- "``.###########.`",
- "``.###########.`",
- "``.###########.`",
- "``.###########.`",
- "``.###########.`",
- "``.#aaaaaaaaa#.`",
- "``.##aaaaaaa##.`",
- "``.###aaaaa###.`",
- "``.####aaa####.`",
- "``.#####a#####.`",
- "``.###########.`",
- "``.............`",
- "````````````````",
- "````````````````"
- ]
-
-
-down_arrow_xpm = [
- " 16 16 8 1",
- "` c #008080",
- ". c #000000",
- "# c #000000",
- "a c #000000",
- "b c #000000",
- "c c #000000",
- "d c #000000",
- "e c #000000",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````.........```",
- "`````.......````",
- "``````.....`````",
- "```````...``````",
- "````````.```````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````",
- "````````````````"
- ]
-
-
-#----------------------------------------------------------------------
-def GetMondrianData():
- return \
-'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
-\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00qID\
-ATX\x85\xed\xd6;\n\x800\x10E\xd1{\xc5\x8d\xb9r\x97\x16\x0b\xad$\x8a\x82:\x16\
-o\xda\x84pB2\x1f\x81Fa\x8c\x9c\x08\x04Z{\xcf\xa72\xbcv\xfa\xc5\x08 \x80r\x80\
-\xfc\xa2\x0e\x1c\xe4\xba\xfaX\x1d\xd0\xde]S\x07\x02\xd8>\xe1wa-`\x9fQ\xe9\
-\x86\x01\x04\x10\x00\\(Dk\x1b-\x04\xdc\x1d\x07\x14\x98;\x0bS\x7f\x7f\xf9\x13\
-\x04\x10@\xf9X\xbe\x00\xc9 \x14K\xc1<={\x00\x00\x00\x00IEND\xaeB`\x82'
-
-
-def GetMondrianBitmap():
- return wx.BitmapFromImage(GetMondrianImage().Scale(16, 16))
-
-
-def GetMondrianImage():
- import cStringIO
- stream = cStringIO.StringIO(GetMondrianData())
- return wx.ImageFromStream(stream)
-
-
-def GetMondrianIcon():
- icon = wx.EmptyIcon()
- icon.CopyFromBitmap(GetMondrianBitmap())
- return icon
-#----------------------------------------------------------------------
-
-
-def LightColour(color, percent):
- """ Brighten input colour by percent. """
-
- end_color = wx.WHITE
-
- rd = end_color.Red() - color.Red()
- gd = end_color.Green() - color.Green()
- bd = end_color.Blue() - color.Blue()
-
- high = 100
-
- # We take the percent way of the color from color -. white
- i = percent
- r = color.Red() + ((i*rd*100)/high)/100
- g = color.Green() + ((i*gd*100)/high)/100
- b = color.Blue() + ((i*bd*100)/high)/100
- return wx.Colour(r, g, b)
-
-
-def RandomColour():
- """ Creates a random colour. """
-
- r = random.randint(0, 255) # Random value betweem 0-255
- g = random.randint(0, 255) # Random value betweem 0-255
- b = random.randint(0, 255) # Random value betweem 0-255
-
- return wx.Colour(r, g, b)
-
-
-def PaintStraightGradientBox(dc, rect, startColor, endColor, vertical=True):
- """ Draws a gradient colored box from startColor to endColor. """
-
- rd = endColor.Red() - startColor.Red()
- gd = endColor.Green() - startColor.Green()
- bd = endColor.Blue() - startColor.Blue()
-
- # Save the current pen and brush
- savedPen = dc.GetPen()
- savedBrush = dc.GetBrush()
-
- if vertical:
- high = rect.GetHeight()-1
- else:
- high = rect.GetWidth()-1
-
- if high < 1:
- return
-
- for i in xrange(high+1):
-
- r = startColor.Red() + ((i*rd*100)/high)/100
- g = startColor.Green() + ((i*gd*100)/high)/100
- b = startColor.Blue() + ((i*bd*100)/high)/100
-
- p = wx.Pen(wx.Colour(r, g, b))
- dc.SetPen(p)
-
- if vertical:
- dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i)
- else:
- dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height)
-
- # Restore the pen and brush
- dc.SetPen(savedPen)
- dc.SetBrush(savedBrush)
-
-
-
-# -----------------------------------------------------------------------------
-# Util functions
-# -----------------------------------------------------------------------------
-
-def DrawButton(dc, rect, focus, upperTabs):
-
- # Define the rounded rectangle base on the given rect
- # we need an array of 9 points for it
- regPts = [wx.Point() for indx in xrange(9)]
-
- if focus:
- if upperTabs:
- leftPt = wx.Point(rect.x, rect.y + (rect.height / 10)*8)
- rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height / 10)*8)
- else:
- leftPt = wx.Point(rect.x, rect.y + (rect.height / 10)*5)
- rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height / 10)*5)
- else:
- leftPt = wx.Point(rect.x, rect.y + (rect.height / 2))
- rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height / 2))
-
- # Define the top region
- top = wx.RectPP(rect.GetTopLeft(), rightPt)
- bottom = wx.RectPP(leftPt, rect.GetBottomRight())
-
- topStartColor = wx.WHITE
-
- if not focus:
- topStartColor = LightColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), 50)
-
- topEndColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)
- bottomStartColor = topEndColor
- bottomEndColor = topEndColor
-
- # Incase we use bottom tabs, switch the colors
- if upperTabs:
- if focus:
- PaintStraightGradientBox(dc, top, topStartColor, topEndColor)
- PaintStraightGradientBox(dc, bottom, bottomStartColor, bottomEndColor)
- else:
- PaintStraightGradientBox(dc, top, topEndColor , topStartColor)
- PaintStraightGradientBox(dc, bottom, bottomStartColor, bottomEndColor)
-
- else:
- if focus:
- PaintStraightGradientBox(dc, bottom, topEndColor, bottomEndColor)
- PaintStraightGradientBox(dc, top,topStartColor, topStartColor)
- else:
- PaintStraightGradientBox(dc, bottom, bottomStartColor, bottomEndColor)
- PaintStraightGradientBox(dc, top, topEndColor, topStartColor)
-
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
-
-
-# ---------------------------------------------------------------------------- #
-# Class FNBDropSource
-# Gives Some Custom UI Feedback during the DnD Operations
-# ---------------------------------------------------------------------------- #
-
-class FNBDropSource(wx.DropSource):
- """
- Give some custom UI feedback during the drag and drop operation in this
- function. It is called on each mouse move, so your implementation must
- not be too slow.
- """
-
- def __init__(self, win):
- """ Default class constructor. Used internally. """
-
- wx.DropSource.__init__(self, win)
- self._win = win
-
-
- def GiveFeedback(self, effect):
- """ Provides user with a nice feedback when tab is being dragged. """
-
- self._win.DrawDragHint()
- return False
-
-
-# ---------------------------------------------------------------------------- #
-# Class FNBDragInfo
-# Stores All The Information To Allow Drag And Drop Between Different
-# FlatNotebooks.
-# ---------------------------------------------------------------------------- #
-
-class FNBDragInfo:
-
- _map = weakref.WeakValueDictionary()
-
- def __init__(self, container, pageindex):
- """ Default class constructor. """
-
- self._id = id(container)
- FNBDragInfo._map[self._id] = container
- self._pageindex = pageindex
-
-
- def GetContainer(self):
- """ Returns the L{FlatNotebook} page (usually a panel). """
-
- return FNBDragInfo._map.get(self._id, None)
-
-
- def GetPageIndex(self):
- """ Returns the page index associated with a page. """
-
- return self._pageindex
-
-
-# ---------------------------------------------------------------------------- #
-# Class FNBDropTarget
-# Simply Used To Handle The OnDrop() Method When Dragging And Dropping Between
-# Different FlatNotebooks.
-# ---------------------------------------------------------------------------- #
-
-class FNBDropTarget(wx.DropTarget):
-
- def __init__(self, parent):
- """ Default class constructor. """
-
- wx.DropTarget.__init__(self)
-
- self._parent = parent
- self._dataobject = wx.CustomDataObject(wx.CustomDataFormat("FlatNotebook"))
- self.SetDataObject(self._dataobject)
-
-
- def OnData(self, x, y, dragres):
- """ Handles the OnData() method to call the real DnD routine. """
-
- if not self.GetData():
- return wx.DragNone
-
- draginfo = self._dataobject.GetData()
- drginfo = cPickle.loads(draginfo)
-
- return self._parent.OnDropTarget(x, y, drginfo.GetPageIndex(), drginfo.GetContainer())
-
-
-# ---------------------------------------------------------------------------- #
-# Class PageInfo
-# Contains parameters for every FlatNotebook page
-# ---------------------------------------------------------------------------- #
-
-class PageInfo:
- """
- This class holds all the information (caption, image, etc...) belonging to a
- single tab in L{FlatNotebook}.
- """
-
- def __init__(self, caption="", imageindex=-1, tabangle=0, enabled=True):
- """
- Default Class Constructor.
-
- Parameters:
- @param caption: the tab caption;
- @param imageindex: the tab image index based on the assigned (set) wx.ImageList (if any);
- @param tabangle: the tab angle (only on standard tabs, from 0 to 15 degrees);
- @param enabled: sets enabled or disabled the tab.
- """
-
- self._strCaption = caption
- self._TabAngle = tabangle
- self._ImageIndex = imageindex
- self._bEnabled = enabled
- self._pos = wx.Point(-1, -1)
- self._size = wx.Size(-1, -1)
- self._region = wx.Region()
- self._xRect = wx.Rect()
- self._color = None
- self._hasFocus = False
-
-
- def SetCaption(self, value):
- """ Sets the tab caption. """
-
- self._strCaption = value
-
-
- def GetCaption(self):
- """ Returns the tab caption. """
-
- return self._strCaption
-
-
- def SetPosition(self, value):
- """ Sets the tab position. """
-
- self._pos = value
-
-
- def GetPosition(self):
- """ Returns the tab position. """
-
- return self._pos
-
-
- def SetSize(self, value):
- """ Sets the tab size. """
-
- self._size = value
-
-
- def GetSize(self):
- """ Returns the tab size. """
-
- return self._size
-
-
- def SetTabAngle(self, value):
- """ Sets the tab header angle (0 <= tab <= 15 degrees). """
-
- self._TabAngle = min(45, value)
-
-
- def GetTabAngle(self):
- """ Returns the tab angle. """
-
- return self._TabAngle
-
-
- def SetImageIndex(self, value):
- """ Sets the tab image index. """
-
- self._ImageIndex = value
-
-
- def GetImageIndex(self):
- """ Returns the tab umage index. """
-
- return self._ImageIndex
-
-
- def GetEnabled(self):
- """ Returns whether the tab is enabled or not. """
-
- return self._bEnabled
-
-
- def EnableTab(self, enabled):
- """ Sets the tab enabled or disabled. """
-
- self._bEnabled = enabled
-
-
- def SetRegion(self, points=[]):
- """ Sets the tab region. """
-
- self._region = wx.RegionFromPoints(points)
-
-
- def GetRegion(self):
- """ Returns the tab region. """
-
- return self._region
-
-
- def SetXRect(self, xrect):
- """ Sets the button 'X' area rect. """
-
- self._xRect = xrect
-
-
- def GetXRect(self):
- """ Returns the button 'X' area rect. """
-
- return self._xRect
-
-
- def GetColour(self):
- """ Returns the tab colour. """
-
- return self._color
-
-
- def SetColour(self, color):
- """ Sets the tab colour. """
-
- self._color = color
-
-
-# ---------------------------------------------------------------------------- #
-# Class FlatNotebookEvent
-# ---------------------------------------------------------------------------- #
-
-class FlatNotebookEvent(wx.PyCommandEvent):
- """
- This events will be sent when a EVT_FLATNOTEBOOK_PAGE_CHANGED,
- EVT_FLATNOTEBOOK_PAGE_CHANGING, EVT_FLATNOTEBOOK_PAGE_CLOSING,
- EVT_FLATNOTEBOOK_PAGE_CLOSED and EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU is
- mapped in the parent.
- """
-
- def __init__(self, eventType, id=1, nSel=-1, nOldSel=-1):
- """ Default class constructor. """
-
- wx.PyCommandEvent.__init__(self, eventType, id)
- self._eventType = eventType
-
- self.notify = wx.NotifyEvent(eventType, id)
-
-
- def GetNotifyEvent(self):
- """Returns the actual wx.NotifyEvent."""
-
- return self.notify
-
-
- def IsAllowed(self):
- """Returns whether the event is allowed or not."""
-
- return self.notify.IsAllowed()
-
-
- def Veto(self):
- """Vetos the event."""
-
- self.notify.Veto()
-
-
- def Allow(self):
- """The event is allowed."""
-
- self.notify.Allow()
-
-
- def SetSelection(self, nSel):
- """ Sets event selection. """
-
- self._selection = nSel
-
-
- def SetOldSelection(self, nOldSel):
- """ Sets old event selection. """
-
- self._oldselection = nOldSel
-
-
- def GetSelection(self):
- """ Returns event selection. """
-
- return self._selection
-
-
- def GetOldSelection(self):
- """ Returns old event selection """
-
- return self._oldselection
-
-
-# ---------------------------------------------------------------------------- #
-# Class TabNavigatorWindow
-# ---------------------------------------------------------------------------- #
-
-class TabNavigatorWindow(wx.Dialog):
- """
- This class is used to create a modal dialog that enables "Smart Tabbing",
- similar to what you would get by hitting Alt+Tab on Windows.
- """
-
- def __init__(self, parent=None, icon=None):
- """ Default class constructor. Used internally."""
-
- wx.Dialog.__init__(self, parent, wx.ID_ANY, "", style=0)
-
- self._selectedItem = -1
- self._indexMap = []
-
- if icon is None:
- self._bmp = GetMondrianBitmap()
- else:
- self._bmp = icon
-
- sz = wx.BoxSizer(wx.VERTICAL)
-
- self._listBox = wx.ListBox(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(200, 150), [], wx.LB_SINGLE | wx.NO_BORDER)
-
- mem_dc = wx.MemoryDC()
- mem_dc.SelectObject(wx.EmptyBitmap(1,1))
- font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- font.SetWeight(wx.BOLD)
- mem_dc.SetFont(font)
-
- panelHeight = mem_dc.GetCharHeight()
- panelHeight += 4 # Place a spacer of 2 pixels
-
- # Out signpost bitmap is 24 pixels
- if panelHeight < 24:
- panelHeight = 24
-
- self._panel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(200, panelHeight))
-
- sz.Add(self._panel)
- sz.Add(self._listBox, 1, wx.EXPAND)
-
- self.SetSizer(sz)
-
- # Connect events to the list box
- self._listBox.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
- self._listBox.Bind(wx.EVT_NAVIGATION_KEY, self.OnNavigationKey)
- self._listBox.Bind(wx.EVT_LISTBOX_DCLICK, self.OnItemSelected)
-
- # Connect paint event to the panel
- self._panel.Bind(wx.EVT_PAINT, self.OnPanelPaint)
- self._panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnPanelEraseBg)
-
- self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
- self._listBox.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
- self.PopulateListControl(parent)
-
- self.GetSizer().Fit(self)
- self.GetSizer().SetSizeHints(self)
- self.GetSizer().Layout()
- self.Centre()
-
- # Set focus on the list box to avoid having to click on it to change
- # the tab selection under GTK.
- self._listBox.SetFocus()
-
-
- def OnKeyUp(self, event):
- """Handles the wx.EVT_KEY_UP for the L{TabNavigatorWindow}."""
-
- if event.GetKeyCode() == wx.WXK_CONTROL:
- self.CloseDialog()
-
-
- def OnNavigationKey(self, event):
- """Handles the wx.EVT_NAVIGATION_KEY for the L{TabNavigatorWindow}. """
-
- selected = self._listBox.GetSelection()
- bk = self.GetParent()
- maxItems = bk.GetPageCount()
-
- if event.GetDirection():
-
- # Select next page
- if selected == maxItems - 1:
- itemToSelect = 0
- else:
- itemToSelect = selected + 1
-
- else:
-
- # Previous page
- if selected == 0:
- itemToSelect = maxItems - 1
- else:
- itemToSelect = selected - 1
-
- self._listBox.SetSelection(itemToSelect)
-
-
- def PopulateListControl(self, book):
- """Populates the L{TabNavigatorWindow} listbox with a list of tabs."""
-
- selection = book.GetSelection()
- count = book.GetPageCount()
-
- self._listBox.Append(book.GetPageText(selection))
- self._indexMap.append(selection)
-
- prevSel = book.GetPreviousSelection()
-
- if prevSel != wx.NOT_FOUND:
-
- # Insert the previous selection as second entry
- self._listBox.Append(book.GetPageText(prevSel))
- self._indexMap.append(prevSel)
-
- for c in xrange(count):
-
- # Skip selected page
- if c == selection:
- continue
-
- # Skip previous selected page as well
- if c == prevSel:
- continue
-
- self._listBox.Append(book.GetPageText(c))
- self._indexMap.append(c)
-
- # Select the next entry after the current selection
- self._listBox.SetSelection(0)
- dummy = wx.NavigationKeyEvent()
- dummy.SetDirection(True)
- self.OnNavigationKey(dummy)
-
-
- def OnItemSelected(self, event):
- """Handles the wx.EVT_LISTBOX_DCLICK event for the wx.ListBox inside L{TabNavigatorWindow}. """
-
- self.CloseDialog()
-
-
- def CloseDialog(self):
- """Closes the L{TabNavigatorWindow} dialog, setting selection in L{FlatNotebook}."""
-
- bk = self.GetParent()
- self._selectedItem = self._listBox.GetSelection()
- iter = self._indexMap[self._selectedItem]
- self.EndModal(wx.ID_OK)
- wx.CallAfter(bk._pages.FireEvent, iter)
- self.Destroy()
-
-
- def OnPanelPaint(self, event):
- """Handles the wx.EVT_PAINT event for L{TabNavigatorWindow} top panel. """
-
- dc = wx.PaintDC(self._panel)
- rect = self._panel.GetClientRect()
-
- bmp = wx.EmptyBitmap(rect.width, rect.height)
-
- mem_dc = wx.MemoryDC()
- mem_dc.SelectObject(bmp)
-
- endColour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)
- startColour = LightColour(endColour, 50)
- PaintStraightGradientBox(mem_dc, rect, startColour, endColour)
-
- # Draw the caption title and place the bitmap
- # get the bitmap optimal position, and draw it
- bmpPt, txtPt = wx.Point(), wx.Point()
- bmpPt.y = (rect.height - self._bmp.GetHeight())/2
- bmpPt.x = 3
- mem_dc.DrawBitmap(self._bmp, bmpPt.x, bmpPt.y, True)
-
- # get the text position, and draw it
- font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- font.SetWeight(wx.BOLD)
- mem_dc.SetFont(font)
- fontHeight = mem_dc.GetCharHeight()
-
- txtPt.x = bmpPt.x + self._bmp.GetWidth() + 4
- txtPt.y = (rect.height - fontHeight)/2
- mem_dc.SetTextForeground(wx.WHITE)
- mem_dc.DrawText("Opened tabs:", txtPt.x, txtPt.y)
- mem_dc.SelectObject(wx.NullBitmap)
-
- dc.DrawBitmap(bmp, 0, 0)
-
-
- def OnPanelEraseBg(self, event):
- """Handles the wx.EVT_ERASE_BACKGROUND event for L{TabNavigatorWindow} top panel. """
-
- pass
-
-
-# ---------------------------------------------------------------------------- #
-# Class FNBRenderer
-# ---------------------------------------------------------------------------- #
-
-class FNBRenderer:
- """
- Parent class for the 4 renderers defined: I{Standard}, I{VC71}, I{Fancy}
- and I{VC8}. This class implements the common methods of all 4 renderers.
- """
-
- def __init__(self):
- """Default class constructor. """
-
- self._tabHeight = None
-
- if wx.Platform == "__WXMAC__":
- # Hack to get proper highlight color for focus rectangle from
- # current theme by creating a theme brush and getting its color.
- # kThemeBrushFocusHighlight is available on Mac OS 8.5 and higher
- brush = wx.BLACK_BRUSH
- brush.MacSetTheme(Carbon.Appearance.kThemeBrushFocusHighlight)
- self._focusPen = wx.Pen(brush.GetColour(), 2, wx.SOLID)
- else:
- self._focusPen = wx.Pen(wx.BLACK, 1, wx.USER_DASH)
- self._focusPen.SetDashes([1, 1])
- self._focusPen.SetCap(wx.CAP_BUTT)
-
-
- def GetLeftButtonPos(self, pageContainer):
- """ Returns the left button position in the navigation area. """
-
- pc = pageContainer
- style = pc.GetParent().GetWindowStyleFlag()
- rect = pc.GetClientRect()
- clientWidth = rect.width
-
- if style & FNB_NO_X_BUTTON and (style & FNB_DROPDOWN_TABS_LIST != FNB_DROPDOWN_TABS_LIST):
- return clientWidth - 38
- else:
- return clientWidth - 54
-
-
- def GetRightButtonPos(self, pageContainer):
- """ Returns the right button position in the navigation area. """
-
- pc = pageContainer
- style = pc.GetParent().GetWindowStyleFlag()
- rect = pc.GetClientRect()
- clientWidth = rect.width
-
- if style & FNB_NO_X_BUTTON and (style & FNB_DROPDOWN_TABS_LIST != FNB_DROPDOWN_TABS_LIST):
- return clientWidth - 22
- else:
- return clientWidth - 38
-
-
- def GetDropArrowButtonPos(self, pageContainer):
- """ Returns the drop down button position in the navigation area. """
-
- pc = pageContainer
- style = pc.GetParent().GetWindowStyleFlag()
- rect = pc.GetClientRect()
- clientWidth = rect.width
-
- if style & FNB_DROPDOWN_TABS_LIST != FNB_DROPDOWN_TABS_LIST:
- return clientWidth
- else:
- return clientWidth - 22
-
-
- def GetXPos(self, pageContainer):
- """ Returns the 'X' button position in the navigation area. """
-
- pc = pageContainer
- style = pc.GetParent().GetWindowStyleFlag()
- rect = pc.GetClientRect()
- clientWidth = rect.width
-
- if style & FNB_NO_X_BUTTON:
- return clientWidth
- else:
- return clientWidth - 22
-
-
- def GetButtonsAreaLength(self, pageContainer):
- """ Returns the navigation area width. """
-
- pc = pageContainer
- style = pc.GetParent().GetWindowStyleFlag()
-
- # ''
- if style & FNB_NO_NAV_BUTTONS and style & FNB_NO_X_BUTTON and not style & FNB_DROPDOWN_TABS_LIST:
- return 0
-
- # 'x'
- elif style & FNB_NO_NAV_BUTTONS and not style & FNB_NO_X_BUTTON and not style & FNB_DROPDOWN_TABS_LIST:
- return 22
-
- # '<>'
- if not style & FNB_NO_NAV_BUTTONS and style & FNB_NO_X_BUTTON and not style & FNB_DROPDOWN_TABS_LIST:
- return 53 - 16
-
- # 'vx'
- if style & FNB_DROPDOWN_TABS_LIST and not style & FNB_NO_X_BUTTON:
- return 22 + 16
-
- # 'v'
- if style & FNB_DROPDOWN_TABS_LIST and style & FNB_NO_X_BUTTON and style & FNB_NO_NAV_BUTTONS:
- return 22
-
- # '<>v'
- if style & FNB_DROPDOWN_TABS_LIST and style & FNB_NO_X_BUTTON and not style & FNB_NO_NAV_BUTTONS:
- return 53
-
- # '<>x'
- return 53
-
-
- def DrawArrowAccordingToState(self, dc, pc, rect):
-
- lightFactor = (pc.HasFlag(FNB_BACKGROUND_GRADIENT) and [70] or [0])[0]
- PaintStraightGradientBox(dc, rect, pc._tabAreaColor, LightColour(pc._tabAreaColor, lightFactor))
-
-
- def DrawLeftArrow(self, pageContainer, dc):
- """ Draw the left navigation arrow. """
-
- pc = pageContainer
-
- style = pc.GetParent().GetWindowStyleFlag()
- if style & FNB_NO_NAV_BUTTONS:
- return
-
- # Make sure that there are pages in the container
- if not pc._pagesInfoVec:
- return
-
- # Set the bitmap according to the button status
- if pc._nLeftButtonStatus == FNB_BTN_HOVER:
- arrowBmp = wx.BitmapFromXPMData(left_arrow_hilite_xpm)
- elif pc._nLeftButtonStatus == FNB_BTN_PRESSED:
- arrowBmp = wx.BitmapFromXPMData(left_arrow_pressed_xpm)
- else:
- arrowBmp = wx.BitmapFromXPMData(left_arrow_xpm)
-
- if pc._nFrom == 0:
- # Handle disabled arrow
- arrowBmp = wx.BitmapFromXPMData(left_arrow_disabled_xpm)
-
- arrowBmp.SetMask(wx.Mask(arrowBmp, MASK_COLOR))
-
- # Erase old bitmap
- posx = self.GetLeftButtonPos(pc)
- self.DrawArrowAccordingToState(dc, pc, wx.Rect(posx, 6, 16, 14))
-
- # Draw the new bitmap
- dc.DrawBitmap(arrowBmp, posx, 6, True)
-
-
- def DrawRightArrow(self, pageContainer, dc):
- """ Draw the right navigation arrow. """
-
- pc = pageContainer
-
- style = pc.GetParent().GetWindowStyleFlag()
- if style & FNB_NO_NAV_BUTTONS:
- return
-
- # Make sure that there are pages in the container
- if not pc._pagesInfoVec:
- return
-
- # Set the bitmap according to the button status
- if pc._nRightButtonStatus == FNB_BTN_HOVER:
- arrowBmp = wx.BitmapFromXPMData(right_arrow_hilite_xpm)
- elif pc._nRightButtonStatus == FNB_BTN_PRESSED:
- arrowBmp = wx.BitmapFromXPMData(right_arrow_pressed_xpm)
- else:
- arrowBmp = wx.BitmapFromXPMData(right_arrow_xpm)
-
- # Check if the right most tab is visible, if it is
- # don't rotate right anymore
- if pc._pagesInfoVec[-1].GetPosition() != wx.Point(-1, -1):
- arrowBmp = wx.BitmapFromXPMData(right_arrow_disabled_xpm)
-
- arrowBmp.SetMask(wx.Mask(arrowBmp, MASK_COLOR))
-
- # erase old bitmap
- posx = self.GetRightButtonPos(pc)
- self.DrawArrowAccordingToState(dc, pc, wx.Rect(posx, 6, 16, 14))
-
- # Draw the new bitmap
- dc.DrawBitmap(arrowBmp, posx, 6, True)
-
-
- def DrawDropDownArrow(self, pageContainer, dc):
- """ Draws the drop-down arrow in the navigation area. """
-
- pc = pageContainer
-
- # Check if this style is enabled
- style = pc.GetParent().GetWindowStyleFlag()
- if not style & FNB_DROPDOWN_TABS_LIST:
- return
-
- # Make sure that there are pages in the container
- if not pc._pagesInfoVec:
- return
-
- if pc._nArrowDownButtonStatus == FNB_BTN_HOVER:
- downBmp = wx.BitmapFromXPMData(down_arrow_hilite_xpm)
- elif pc._nArrowDownButtonStatus == FNB_BTN_PRESSED:
- downBmp = wx.BitmapFromXPMData(down_arrow_pressed_xpm)
- else:
- downBmp = wx.BitmapFromXPMData(down_arrow_xpm)
-
- downBmp.SetMask(wx.Mask(downBmp, MASK_COLOR))
-
- # erase old bitmap
- posx = self.GetDropArrowButtonPos(pc)
- self.DrawArrowAccordingToState(dc, pc, wx.Rect(posx, 6, 16, 14))
-
- # Draw the new bitmap
- dc.DrawBitmap(downBmp, posx, 6, True)
-
-
- def DrawX(self, pageContainer, dc):
- """ Draw the 'X' navigation button in the navigation area. """
-
- pc = pageContainer
-
- # Check if this style is enabled
- style = pc.GetParent().GetWindowStyleFlag()
- if style & FNB_NO_X_BUTTON:
- return
-
- # Make sure that there are pages in the container
- if not pc._pagesInfoVec:
- return
-
- # Set the bitmap according to the button status
- if pc._nXButtonStatus == FNB_BTN_HOVER:
- xbmp = wx.BitmapFromXPMData(x_button_hilite_xpm)
- elif pc._nXButtonStatus == FNB_BTN_PRESSED:
- xbmp = wx.BitmapFromXPMData(x_button_pressed_xpm)
- else:
- xbmp = wx.BitmapFromXPMData(x_button_xpm)
-
- xbmp.SetMask(wx.Mask(xbmp, MASK_COLOR))
-
- # erase old bitmap
- posx = self.GetXPos(pc)
- self.DrawArrowAccordingToState(dc, pc, wx.Rect(posx, 6, 16, 14))
-
- # Draw the new bitmap
- dc.DrawBitmap(xbmp, posx, 6, True)
-
-
- def DrawTabX(self, pageContainer, dc, rect, tabIdx, btnStatus):
- """ Draws the 'X' in the selected tab. """
-
- pc = pageContainer
- if not pc.HasFlag(FNB_X_ON_TAB):
- return
-
- # We draw the 'x' on the active tab only
- if tabIdx != pc.GetSelection() or tabIdx < 0:
- return
-
- # Set the bitmap according to the button status
-
- if btnStatus == FNB_BTN_HOVER:
- xBmp = wx.BitmapFromXPMData(x_button_hilite_xpm)
- elif btnStatus == FNB_BTN_PRESSED:
- xBmp = wx.BitmapFromXPMData(x_button_pressed_xpm)
- else:
- xBmp = wx.BitmapFromXPMData(x_button_xpm)
-
- # Set the masking
- xBmp.SetMask(wx.Mask(xBmp, MASK_COLOR))
-
- # Draw the new bitmap
- dc.DrawBitmap(xBmp, rect.x, rect.y, True)
-
- # Update the vector
- rr = wx.Rect(rect.x, rect.y, 14, 13)
- pc._pagesInfoVec[tabIdx].SetXRect(rr)
-
-
- def DrawTabsLine(self, pageContainer, dc, selTabX1=-1, selTabX2=-1):
- """ Draws a line over the tabs. """
-
- pc = pageContainer
-
- clntRect = pc.GetClientRect()
- clientRect3 = wx.Rect(0, 0, clntRect.width, clntRect.height)
-
- if pc.HasFlag(FNB_FF2):
- if not pc.HasFlag(FNB_BOTTOM):
- fillColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)
- else:
- fillColor = wx.WHITE
-
- dc.SetPen(wx.Pen(fillColor))
-
- if pc.HasFlag(FNB_BOTTOM):
-
- dc.DrawLine(1, 0, clntRect.width-1, 0)
- dc.DrawLine(1, 1, clntRect.width-1, 1)
-
- dc.SetPen(wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)))
- dc.DrawLine(1, 2, clntRect.width-1, 2)
-
- dc.SetPen(wx.Pen(fillColor))
- dc.DrawLine(selTabX1 + 2, 2, selTabX2 - 1, 2)
-
- else:
-
- dc.DrawLine(1, clntRect.height, clntRect.width-1, clntRect.height)
- dc.DrawLine(1, clntRect.height-1, clntRect.width-1, clntRect.height-1)
-
- dc.SetPen(wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)))
- dc.DrawLine(1, clntRect.height-2, clntRect.width-1, clntRect.height-2)
-
- dc.SetPen(wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)))
- dc.DrawLine(selTabX1 + 2, clntRect.height-2, selTabX2-1, clntRect.height-2)
-
- else:
-
- if pc.HasFlag(FNB_BOTTOM):
-
- clientRect = wx.Rect(0, 2, clntRect.width, clntRect.height - 2)
- clientRect2 = wx.Rect(0, 1, clntRect.width, clntRect.height - 1)
-
- else:
-
- clientRect = wx.Rect(0, 0, clntRect.width, clntRect.height - 2)
- clientRect2 = wx.Rect(0, 0, clntRect.width, clntRect.height - 1)
-
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.SetPen(wx.Pen(pc.GetSingleLineBorderColour()))
- dc.DrawRectangleRect(clientRect2)
- dc.DrawRectangleRect(clientRect3)
-
- dc.SetPen(wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)))
- dc.DrawRectangleRect(clientRect)
-
- if not pc.HasFlag(FNB_TABS_BORDER_SIMPLE):
-
- dc.SetPen(wx.Pen((pc.HasFlag(FNB_VC71) and [wx.Colour(247, 243, 233)] or [pc._tabAreaColor])[0]))
- dc.DrawLine(0, 0, 0, clientRect.height+1)
-
- if pc.HasFlag(FNB_BOTTOM):
-
- dc.DrawLine(0, clientRect.height+1, clientRect.width, clientRect.height+1)
-
- else:
-
- dc.DrawLine(0, 0, clientRect.width, 0)
-
- dc.DrawLine(clientRect.width - 1, 0, clientRect.width - 1, clientRect.height+1)
-
-
- def CalcTabWidth(self, pageContainer, tabIdx, tabHeight):
- """ Calculates the width of the input tab. """
-
- pc = pageContainer
- dc = wx.MemoryDC()
- dc.SelectObject(wx.EmptyBitmap(1,1))
-
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
-
- if pc.IsDefaultTabs():
- shapePoints = int(tabHeight*math.tan(float(pc._pagesInfoVec[tabIdx].GetTabAngle())/180.0*math.pi))
-
- # Calculate the text length using the bold font, so when selecting a tab
- # its width will not change
- dc.SetFont(boldFont)
- width, pom = dc.GetTextExtent(pc.GetPageText(tabIdx))
-
- # Set a minimum size to a tab
- if width < 20:
- width = 20
-
- tabWidth = 2*pc._pParent.GetPadding() + width
-
- # Style to add a small 'x' button on the top right
- # of the tab
- if pc.HasFlag(FNB_X_ON_TAB) and tabIdx == pc.GetSelection():
- # The xpm image that contains the 'x' button is 9 pixels
- spacer = 9
- if pc.HasFlag(FNB_VC8):
- spacer = 4
-
- tabWidth += pc._pParent.GetPadding() + spacer
-
- if pc.IsDefaultTabs():
- # Default style
- tabWidth += 2*shapePoints
-
- hasImage = pc._ImageList != None and pc._pagesInfoVec[tabIdx].GetImageIndex() != -1
-
- # For VC71 style, we only add the icon size (16 pixels)
- if hasImage:
-
- if not pc.IsDefaultTabs():
- tabWidth += 16 + pc._pParent.GetPadding()
- else:
- # Default style
- tabWidth += 16 + pc._pParent.GetPadding() + shapePoints/2
-
- return tabWidth
-
-
- def CalcTabHeight(self, pageContainer):
- """ Calculates the height of the input tab. """
-
- if self._tabHeight:
- return self._tabHeight
-
- pc = pageContainer
- dc = wx.MemoryDC()
- dc.SelectObject(wx.EmptyBitmap(1,1))
-
- # For GTK it seems that we must do this steps in order
- # for the tabs will get the proper height on initialization
- # on MSW, preforming these steps yields wierd results
- normalFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont = normalFont
-
- if "__WXGTK__" in wx.PlatformInfo:
- boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
- dc.SetFont(boldFont)
-
- height = dc.GetCharHeight()
-
- tabHeight = height + FNB_HEIGHT_SPACER # We use 8 pixels as padding
- if "__WXGTK__" in wx.PlatformInfo:
- # On GTK the tabs are should be larger
- tabHeight += 6
-
- self._tabHeight = tabHeight
-
- return tabHeight
-
-
- def DrawTabs(self, pageContainer, dc):
- """ Actually draws the tabs in L{FlatNotebook}."""
-
- pc = pageContainer
- if "__WXMAC__" in wx.PlatformInfo:
- # Works well on MSW & GTK, however this lines should be skipped on MAC
- if not pc._pagesInfoVec or pc._nFrom >= len(pc._pagesInfoVec):
- pc.Hide()
- return
-
- # Get the text hight
- tabHeight = self.CalcTabHeight(pageContainer)
- style = pc.GetParent().GetWindowStyleFlag()
-
- # Calculate the number of rows required for drawing the tabs
- rect = pc.GetClientRect()
- clientWidth = rect.width
-
- # Set the maximum client size
- pc.SetSizeHints(self.GetButtonsAreaLength(pc), tabHeight)
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
-
- if style & FNB_VC71:
- backBrush = wx.Brush(wx.Colour(247, 243, 233))
- else:
- backBrush = wx.Brush(pc._tabAreaColor)
-
- noselBrush = wx.Brush(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE))
- selBrush = wx.Brush(pc._activeTabColor)
-
- size = pc.GetSize()
-
- # Background
- dc.SetTextBackground((style & FNB_VC71 and [wx.Colour(247, 243, 233)] or [pc.GetBackgroundColour()])[0])
- dc.SetTextForeground(pc._activeTextColor)
- dc.SetBrush(backBrush)
-
- # If border style is set, set the pen to be border pen
- if pc.HasFlag(FNB_TABS_BORDER_SIMPLE):
- dc.SetPen(borderPen)
- else:
- colr = (pc.HasFlag(FNB_VC71) and [wx.Colour(247, 243, 233)] or [pc.GetBackgroundColour()])[0]
- dc.SetPen(wx.Pen(colr))
-
- if pc.HasFlag(FNB_FF2):
- lightFactor = (pc.HasFlag(FNB_BACKGROUND_GRADIENT) and [70] or [0])[0]
- PaintStraightGradientBox(dc, pc.GetClientRect(), pc._tabAreaColor, LightColour(pc._tabAreaColor, lightFactor))
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
-
- dc.DrawRectangle(0, 0, size.x, size.y)
-
- # We always draw the bottom/upper line of the tabs
- # regradless the style
- dc.SetPen(borderPen)
-
- if not pc.HasFlag(FNB_FF2):
- self.DrawTabsLine(pc, dc)
-
- # Restore the pen
- dc.SetPen(borderPen)
-
- if pc.HasFlag(FNB_VC71):
-
- greyLineYVal = (pc.HasFlag(FNB_BOTTOM) and [0] or [size.y - 2])[0]
- whiteLineYVal = (pc.HasFlag(FNB_BOTTOM) and [3] or [size.y - 3])[0]
-
- pen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
- dc.SetPen(pen)
-
- # Draw thik grey line between the windows area and
- # the tab area
- for num in xrange(3):
- dc.DrawLine(0, greyLineYVal + num, size.x, greyLineYVal + num)
-
- wbPen = (pc.HasFlag(FNB_BOTTOM) and [wx.BLACK_PEN] or [wx.WHITE_PEN])[0]
- dc.SetPen(wbPen)
- dc.DrawLine(1, whiteLineYVal, size.x - 1, whiteLineYVal)
-
- # Restore the pen
- dc.SetPen(borderPen)
-
- # Draw labels
- normalFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
- dc.SetFont(boldFont)
-
- posx = pc._pParent.GetPadding()
-
- # Update all the tabs from 0 to 'pc._nFrom' to be non visible
- for i in xrange(pc._nFrom):
-
- pc._pagesInfoVec[i].SetPosition(wx.Point(-1, -1))
- pc._pagesInfoVec[i].GetRegion().Clear()
-
- count = pc._nFrom
-
- #----------------------------------------------------------
- # Go over and draw the visible tabs
- #----------------------------------------------------------
- x1 = x2 = -1
- for i in xrange(pc._nFrom, len(pc._pagesInfoVec)):
-
- dc.SetPen(borderPen)
-
- if not pc.HasFlag(FNB_FF2):
- dc.SetBrush((i==pc.GetSelection() and [selBrush] or [noselBrush])[0])
-
- # Now set the font to the correct font
- dc.SetFont((i==pc.GetSelection() and [boldFont] or [normalFont])[0])
-
- # Add the padding to the tab width
- # Tab width:
- # +-----------------------------------------------------------+
- # | PADDING | IMG | IMG_PADDING | TEXT | PADDING | x |PADDING |
- # +-----------------------------------------------------------+
- tabWidth = self.CalcTabWidth(pageContainer, i, tabHeight)
-
- # Check if we can draw more
- if posx + tabWidth + self.GetButtonsAreaLength(pc) >= clientWidth:
- break
-
- count = count + 1
-
- # By default we clean the tab region
- pc._pagesInfoVec[i].GetRegion().Clear()
-
- # Clean the 'x' buttn on the tab.
- # A 'Clean' rectangle, is a rectangle with width or height
- # with values lower than or equal to 0
- pc._pagesInfoVec[i].GetXRect().SetSize(wx.Size(-1, -1))
-
- # Draw the tab (border, text, image & 'x' on tab)
- self.DrawTab(pc, dc, posx, i, tabWidth, tabHeight, pc._nTabXButtonStatus)
-
- if pc.GetSelection() == i:
- x1 = posx
- x2 = posx + tabWidth + 2
-
- # Restore the text forground
- dc.SetTextForeground(pc._activeTextColor)
-
- # Update the tab position & size
- posy = (pc.HasFlag(FNB_BOTTOM) and [0] or [VERTICAL_BORDER_PADDING])[0]
-
- pc._pagesInfoVec[i].SetPosition(wx.Point(posx, posy))
- pc._pagesInfoVec[i].SetSize(wx.Size(tabWidth, tabHeight))
- self.DrawFocusRectangle(dc, pc, pc._pagesInfoVec[i])
-
- posx += tabWidth
-
- # Update all tabs that can not fit into the screen as non-visible
- for i in xrange(count, len(pc._pagesInfoVec)):
- pc._pagesInfoVec[i].SetPosition(wx.Point(-1, -1))
- pc._pagesInfoVec[i].GetRegion().Clear()
-
- # Draw the left/right/close buttons
- # Left arrow
- self.DrawLeftArrow(pc, dc)
- self.DrawRightArrow(pc, dc)
- self.DrawX(pc, dc)
- self.DrawDropDownArrow(pc, dc)
-
- if pc.HasFlag(FNB_FF2):
- self.DrawTabsLine(pc, dc, x1, x2)
-
-
- def DrawFocusRectangle(self, dc, pageContainer, page):
- """ Draws a focus rectangle like the native Notebooks. """
-
- if not page._hasFocus:
- return
-
- tabPos = wx.Point(*page.GetPosition())
- if pageContainer.GetParent().GetWindowStyleFlag() & FNB_VC8:
- vc8ShapeLen = self.CalcTabHeight(pageContainer) - VERTICAL_BORDER_PADDING - 2
- tabPos.x += vc8ShapeLen
-
- rect = wx.RectPS(tabPos, page.GetSize())
- rect = wx.Rect(rect.x+2, rect.y+2, rect.width-4, rect.height-8)
-
- if wx.Platform == '__WXMAC__':
- rect.SetWidth(rect.GetWidth() + 1)
-
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.SetPen(self._focusPen)
- dc.DrawRoundedRectangleRect(rect, 2)
-
-
- def DrawDragHint(self, pc, tabIdx):
- """
- Draws tab drag hint, the default implementation is to do nothing.
- You can override this function to provide a nice feedback to user.
- """
-
- pass
-
-
- def NumberTabsCanFit(self, pageContainer, fr=-1):
-
- pc = pageContainer
-
- rect = pc.GetClientRect()
- clientWidth = rect.width
-
- vTabInfo = []
-
- tabHeight = self.CalcTabHeight(pageContainer)
-
- # The drawing starts from posx
- posx = pc._pParent.GetPadding()
-
- if fr < 0:
- fr = pc._nFrom
-
- for i in xrange(fr, len(pc._pagesInfoVec)):
-
- tabWidth = self.CalcTabWidth(pageContainer, i, tabHeight)
- if posx + tabWidth + self.GetButtonsAreaLength(pc) >= clientWidth:
- break;
-
- # Add a result to the returned vector
- tabRect = wx.Rect(posx, VERTICAL_BORDER_PADDING, tabWidth , tabHeight)
- vTabInfo.append(tabRect)
-
- # Advance posx
- posx += tabWidth + FNB_HEIGHT_SPACER
-
- return vTabInfo
-
-
-# ---------------------------------------------------------------------------- #
-# Class FNBRendererMgr
-# A manager that handles all the renderers defined below and calls the
-# appropriate one when drawing is needed
-# ---------------------------------------------------------------------------- #
-
-class FNBRendererMgr:
- """
- This class represents a manager that handles all the 4 renderers defined
- and calls the appropriate one when drawing is needed.
- """
-
- def __init__(self):
- """ Default class constructor. """
-
- # register renderers
-
- self._renderers = {}
- self._renderers.update({-1: FNBRendererDefault()})
- self._renderers.update({FNB_VC71: FNBRendererVC71()})
- self._renderers.update({FNB_FANCY_TABS: FNBRendererFancy()})
- self._renderers.update({FNB_VC8: FNBRendererVC8()})
- self._renderers.update({FNB_FF2: FNBRendererFirefox2()})
-
-
- def GetRenderer(self, style):
- """ Returns the current renderer based on the style selected. """
-
- if style & FNB_VC71:
- return self._renderers[FNB_VC71]
-
- if style & FNB_FANCY_TABS:
- return self._renderers[FNB_FANCY_TABS]
-
- if style & FNB_VC8:
- return self._renderers[FNB_VC8]
-
- if style & FNB_FF2:
- return self._renderers[FNB_FF2]
-
- # the default is to return the default renderer
- return self._renderers[-1]
-
-
-#------------------------------------------
-# Default renderer
-#------------------------------------------
-
-class FNBRendererDefault(FNBRenderer):
- """
- This class handles the drawing of tabs using the I{Standard} renderer.
- """
-
- def __init__(self):
- """ Default class constructor. """
-
- FNBRenderer.__init__(self)
-
-
- def DrawTab(self, pageContainer, dc, posx, tabIdx, tabWidth, tabHeight, btnStatus):
- """ Draws a tab using the I{Standard} style. """
-
- # Default style
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
- pc = pageContainer
-
- tabPoints = [wx.Point() for ii in xrange(7)]
- tabPoints[0].x = posx
- tabPoints[0].y = (pc.HasFlag(FNB_BOTTOM) and [2] or [tabHeight - 2])[0]
-
- tabPoints[1].x = int(posx+(tabHeight-2)*math.tan(float(pc._pagesInfoVec[tabIdx].GetTabAngle())/180.0*math.pi))
- tabPoints[1].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - (VERTICAL_BORDER_PADDING+2)] or [(VERTICAL_BORDER_PADDING+2)])[0]
-
- tabPoints[2].x = tabPoints[1].x+2
- tabPoints[2].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - VERTICAL_BORDER_PADDING] or [VERTICAL_BORDER_PADDING])[0]
-
- tabPoints[3].x = int(posx+tabWidth-(tabHeight-2)*math.tan(float(pc._pagesInfoVec[tabIdx].GetTabAngle())/180.0*math.pi))-2
- tabPoints[3].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - VERTICAL_BORDER_PADDING] or [VERTICAL_BORDER_PADDING])[0]
-
- tabPoints[4].x = tabPoints[3].x+2
- tabPoints[4].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - (VERTICAL_BORDER_PADDING+2)] or [(VERTICAL_BORDER_PADDING+2)])[0]
-
- tabPoints[5].x = int(tabPoints[4].x+(tabHeight-2)*math.tan(float(pc._pagesInfoVec[tabIdx].GetTabAngle())/180.0*math.pi))
- tabPoints[5].y = (pc.HasFlag(FNB_BOTTOM) and [2] or [tabHeight - 2])[0]
-
- tabPoints[6].x = tabPoints[0].x
- tabPoints[6].y = tabPoints[0].y
-
- if tabIdx == pc.GetSelection():
-
- # Draw the tab as rounded rectangle
- dc.DrawPolygon(tabPoints)
-
- else:
-
- if tabIdx != pc.GetSelection() - 1:
-
- # Draw a vertical line to the right of the text
- pt1x = tabPoints[5].x
- pt1y = (pc.HasFlag(FNB_BOTTOM) and [4] or [tabHeight - 6])[0]
- pt2x = tabPoints[5].x
- pt2y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - 4] or [4])[0]
- dc.DrawLine(pt1x, pt1y, pt2x, pt2y)
-
- if tabIdx == pc.GetSelection():
-
- savePen = dc.GetPen()
- whitePen = wx.Pen(wx.WHITE)
- whitePen.SetWidth(1)
- dc.SetPen(whitePen)
-
- secPt = wx.Point(tabPoints[5].x + 1, tabPoints[5].y)
- dc.DrawLine(tabPoints[0].x, tabPoints[0].y, secPt.x, secPt.y)
-
- # Restore the pen
- dc.SetPen(savePen)
-
- # -----------------------------------
- # Text and image drawing
- # -----------------------------------
-
- # Text drawing offset from the left border of the
- # rectangle
-
- # The width of the images are 16 pixels
- padding = pc.GetParent().GetPadding()
- shapePoints = int(tabHeight*math.tan(float(pc._pagesInfoVec[tabIdx].GetTabAngle())/180.0*math.pi))
- hasImage = pc._pagesInfoVec[tabIdx].GetImageIndex() != -1
- imageYCoord = (pc.HasFlag(FNB_BOTTOM) and [6] or [8])[0]
-
- if hasImage:
- textOffset = 2*pc._pParent._nPadding + 16 + shapePoints/2
- else:
- textOffset = pc._pParent._nPadding + shapePoints/2
-
- textOffset += 2
-
- if tabIdx != pc.GetSelection():
-
- # Set the text background to be like the vertical lines
- dc.SetTextForeground(pc._pParent.GetNonActiveTabTextColour())
-
- if hasImage:
-
- imageXOffset = textOffset - 16 - padding
- pc._ImageList.Draw(pc._pagesInfoVec[tabIdx].GetImageIndex(), dc,
- posx + imageXOffset, imageYCoord,
- wx.IMAGELIST_DRAW_TRANSPARENT, True)
-
- dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
-
- # draw 'x' on tab (if enabled)
- if pc.HasFlag(FNB_X_ON_TAB) and tabIdx == pc.GetSelection():
-
- textWidth, textHeight = dc.GetTextExtent(pc.GetPageText(tabIdx))
- tabCloseButtonXCoord = posx + textOffset + textWidth + 1
-
- # take a bitmap from the position of the 'x' button (the x on tab button)
- # this bitmap will be used later to delete old buttons
- tabCloseButtonYCoord = imageYCoord
- x_rect = wx.Rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16)
-
- # Draw the tab
- self.DrawTabX(pc, dc, x_rect, tabIdx, btnStatus)
-
-
-#------------------------------------------
-# Firefox2 renderer
-#------------------------------------------
-class FNBRendererFirefox2(FNBRenderer):
- """
- This class handles the drawing of tabs using the I{Firefox 2} renderer.
- """
-
- def __init__(self):
- """ Default class constructor. """
-
- FNBRenderer.__init__(self)
-
-
- def DrawTab(self, pageContainer, dc, posx, tabIdx, tabWidth, tabHeight, btnStatus):
- """ Draws a tab using the I{Firefox 2} style. """
-
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
- pc = pageContainer
-
- tabPoints = [wx.Point() for indx in xrange(7)]
- tabPoints[0].x = posx + 2
- tabPoints[0].y = (pc.HasFlag(FNB_BOTTOM) and [2] or [tabHeight - 2])[0]
-
- tabPoints[1].x = tabPoints[0].x
- tabPoints[1].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - (VERTICAL_BORDER_PADDING+2)] or [(VERTICAL_BORDER_PADDING+2)])[0]
-
- tabPoints[2].x = tabPoints[1].x+2
- tabPoints[2].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - VERTICAL_BORDER_PADDING] or [VERTICAL_BORDER_PADDING])[0]
-
- tabPoints[3].x = posx + tabWidth - 2
- tabPoints[3].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - VERTICAL_BORDER_PADDING] or [VERTICAL_BORDER_PADDING])[0]
-
- tabPoints[4].x = tabPoints[3].x + 2
- tabPoints[4].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - (VERTICAL_BORDER_PADDING+2)] or [(VERTICAL_BORDER_PADDING+2)])[0]
-
- tabPoints[5].x = tabPoints[4].x
- tabPoints[5].y = (pc.HasFlag(FNB_BOTTOM) and [2] or [tabHeight - 2])[0]
-
- tabPoints[6].x = tabPoints[0].x
- tabPoints[6].y = tabPoints[0].y
-
- #------------------------------------
- # Paint the tab with gradient
- #------------------------------------
- rr = wx.RectPP(tabPoints[2], tabPoints[5])
- DrawButton(dc, rr, pc.GetSelection() == tabIdx , not pc.HasFlag(FNB_BOTTOM))
-
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.SetPen(borderPen)
-
- # Draw the tab as rounded rectangle
- dc.DrawPolygon(tabPoints)
-
- # -----------------------------------
- # Text and image drawing
- # -----------------------------------
-
- # The width of the images are 16 pixels
- padding = pc.GetParent().GetPadding()
- shapePoints = int(tabHeight*math.tan(float(pc._pagesInfoVec[tabIdx].GetTabAngle())/180.0*math.pi))
- hasImage = pc._pagesInfoVec[tabIdx].GetImageIndex() != -1
- imageYCoord = (pc.HasFlag(FNB_BOTTOM) and [6] or [8])[0]
-
- if hasImage:
- textOffset = 2*padding + 16 + shapePoints/2
- else:
- textOffset = padding + shapePoints/2
-
- textOffset += 2
-
- if tabIdx != pc.GetSelection():
-
- # Set the text background to be like the vertical lines
- dc.SetTextForeground(pc._pParent.GetNonActiveTabTextColour())
-
- if hasImage:
- imageXOffset = textOffset - 16 - padding
- pc._ImageList.Draw(pc._pagesInfoVec[tabIdx].GetImageIndex(), dc,
- posx + imageXOffset, imageYCoord,
- wx.IMAGELIST_DRAW_TRANSPARENT, True)
-
- dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
-
- # draw 'x' on tab (if enabled)
- if pc.HasFlag(FNB_X_ON_TAB) and tabIdx == pc.GetSelection():
-
- textWidth, textHeight = dc.GetTextExtent(pc.GetPageText(tabIdx))
- tabCloseButtonXCoord = posx + textOffset + textWidth + 1
-
- # take a bitmap from the position of the 'x' button (the x on tab button)
- # this bitmap will be used later to delete old buttons
- tabCloseButtonYCoord = imageYCoord
- x_rect = wx.Rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16)
-
- # Draw the tab
- self.DrawTabX(pc, dc, x_rect, tabIdx, btnStatus)
-
-
-#------------------------------------------------------------------
-# Visual studio 7.1
-#------------------------------------------------------------------
-
-class FNBRendererVC71(FNBRenderer):
- """
- This class handles the drawing of tabs using the I{VC71} renderer.
- """
-
- def __init__(self):
- """ Default class constructor. """
-
- FNBRenderer.__init__(self)
-
-
- def DrawTab(self, pageContainer, dc, posx, tabIdx, tabWidth, tabHeight, btnStatus):
- """ Draws a tab using the I{VC71} style. """
-
- # Visual studio 7.1 style
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
- pc = pageContainer
-
- dc.SetPen((tabIdx == pc.GetSelection() and [wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))] or [borderPen])[0])
- dc.SetBrush((tabIdx == pc.GetSelection() and [wx.Brush(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))] or [wx.Brush(wx.Colour(247, 243, 233))])[0])
-
- if tabIdx == pc.GetSelection():
-
- posy = (pc.HasFlag(FNB_BOTTOM) and [0] or [VERTICAL_BORDER_PADDING])[0]
- tabH = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - 5] or [tabHeight - 3])[0]
- dc.DrawRectangle(posx, posy, tabWidth, tabH)
-
- # Draw a black line on the left side of the
- # rectangle
- dc.SetPen(wx.BLACK_PEN)
-
- blackLineY1 = VERTICAL_BORDER_PADDING
- blackLineY2 = tabH
- dc.DrawLine(posx + tabWidth, blackLineY1, posx + tabWidth, blackLineY2)
-
- # To give the tab more 3D look we do the following
- # Incase the tab is on top,
- # Draw a thik white line on topof the rectangle
- # Otherwise, draw a thin (1 pixel) black line at the bottom
-
- pen = wx.Pen((pc.HasFlag(FNB_BOTTOM) and [wx.BLACK] or [wx.WHITE])[0])
- dc.SetPen(pen)
- whiteLinePosY = (pc.HasFlag(FNB_BOTTOM) and [blackLineY2] or [VERTICAL_BORDER_PADDING ])[0]
- dc.DrawLine(posx , whiteLinePosY, posx + tabWidth + 1, whiteLinePosY)
-
- # Draw a white vertical line to the left of the tab
- dc.SetPen(wx.WHITE_PEN)
- if not pc.HasFlag(FNB_BOTTOM):
- blackLineY2 += 1
-
- dc.DrawLine(posx, blackLineY1, posx, blackLineY2)
-
- else:
-
- # We dont draw a rectangle for non selected tabs, but only
- # vertical line on the left
-
- blackLineY1 = (pc.HasFlag(FNB_BOTTOM) and [VERTICAL_BORDER_PADDING + 2] or [VERTICAL_BORDER_PADDING + 1])[0]
- blackLineY2 = pc.GetSize().y - 5
- dc.DrawLine(posx + tabWidth, blackLineY1, posx + tabWidth, blackLineY2)
-
- # -----------------------------------
- # Text and image drawing
- # -----------------------------------
-
- # Text drawing offset from the left border of the
- # rectangle
-
- # The width of the images are 16 pixels
- padding = pc.GetParent().GetPadding()
- hasImage = pc._pagesInfoVec[tabIdx].GetImageIndex() != -1
- imageYCoord = (pc.HasFlag(FNB_BOTTOM) and [5] or [8])[0]
-
- if hasImage:
- textOffset = 2*pc._pParent._nPadding + 16
- else:
- textOffset = pc._pParent._nPadding
-
- if tabIdx != pc.GetSelection():
-
- # Set the text background to be like the vertical lines
- dc.SetTextForeground(pc._pParent.GetNonActiveTabTextColour())
-
- if hasImage:
-
- imageXOffset = textOffset - 16 - padding
- pc._ImageList.Draw(pc._pagesInfoVec[tabIdx].GetImageIndex(), dc,
- posx + imageXOffset, imageYCoord,
- wx.IMAGELIST_DRAW_TRANSPARENT, True)
-
- dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
-
- # draw 'x' on tab (if enabled)
- if pc.HasFlag(FNB_X_ON_TAB) and tabIdx == pc.GetSelection():
-
- textWidth, textHeight = dc.GetTextExtent(pc.GetPageText(tabIdx))
- tabCloseButtonXCoord = posx + textOffset + textWidth + 1
-
- # take a bitmap from the position of the 'x' button (the x on tab button)
- # this bitmap will be used later to delete old buttons
- tabCloseButtonYCoord = imageYCoord
- x_rect = wx.Rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16)
-
- # Draw the tab
- self.DrawTabX(pc, dc, x_rect, tabIdx, btnStatus)
-
-
-#------------------------------------------------------------------
-# Fancy style
-#------------------------------------------------------------------
-
-class FNBRendererFancy(FNBRenderer):
- """
- This class handles the drawing of tabs using the I{Fancy} renderer.
- """
-
- def __init__(self):
- """ Default class constructor. """
-
- FNBRenderer.__init__(self)
-
-
- def DrawTab(self, pageContainer, dc, posx, tabIdx, tabWidth, tabHeight, btnStatus):
- """ Draws a tab using the I{Fancy} style, similar to VC71 but with gradients. """
-
- # Fancy tabs - like with VC71 but with the following differences:
- # - The Selected tab is colored with gradient color
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
- pc = pageContainer
-
- pen = (tabIdx == pc.GetSelection() and [wx.Pen(pc._pParent.GetBorderColour())] or [wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))])[0]
-
- if tabIdx == pc.GetSelection():
-
- posy = (pc.HasFlag(FNB_BOTTOM) and [2] or [VERTICAL_BORDER_PADDING])[0]
- th = tabHeight - 5
-
- rect = wx.Rect(posx, posy, tabWidth, th)
-
- col2 = (pc.HasFlag(FNB_BOTTOM) and [pc._pParent.GetGradientColourTo()] or [pc._pParent.GetGradientColourFrom()])[0]
- col1 = (pc.HasFlag(FNB_BOTTOM) and [pc._pParent.GetGradientColourFrom()] or [pc._pParent.GetGradientColourTo()])[0]
-
- PaintStraightGradientBox(dc, rect, col1, col2)
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.SetPen(pen)
- dc.DrawRectangleRect(rect)
-
- # erase the bottom/top line of the rectangle
- dc.SetPen(wx.Pen(pc._pParent.GetGradientColourFrom()))
- if pc.HasFlag(FNB_BOTTOM):
- dc.DrawLine(rect.x, 2, rect.x + rect.width, 2)
- else:
- dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1)
-
- else:
-
- # We dont draw a rectangle for non selected tabs, but only
- # vertical line on the left
- dc.SetPen(borderPen)
- dc.DrawLine(posx + tabWidth, VERTICAL_BORDER_PADDING + 3, posx + tabWidth, tabHeight - 4)
-
-
- # -----------------------------------
- # Text and image drawing
- # -----------------------------------
-
- # Text drawing offset from the left border of the
- # rectangle
-
- # The width of the images are 16 pixels
- padding = pc.GetParent().GetPadding()
- hasImage = pc._pagesInfoVec[tabIdx].GetImageIndex() != -1
- imageYCoord = (pc.HasFlag(FNB_BOTTOM) and [6] or [8])[0]
-
- if hasImage:
- textOffset = 2*pc._pParent._nPadding + 16
- else:
- textOffset = pc._pParent._nPadding
-
- textOffset += 2
-
- if tabIdx != pc.GetSelection():
-
- # Set the text background to be like the vertical lines
- dc.SetTextForeground(pc._pParent.GetNonActiveTabTextColour())
-
- if hasImage:
-
- imageXOffset = textOffset - 16 - padding
- pc._ImageList.Draw(pc._pagesInfoVec[tabIdx].GetImageIndex(), dc,
- posx + imageXOffset, imageYCoord,
- wx.IMAGELIST_DRAW_TRANSPARENT, True)
-
- dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
-
- # draw 'x' on tab (if enabled)
- if pc.HasFlag(FNB_X_ON_TAB) and tabIdx == pc.GetSelection():
-
- textWidth, textHeight = dc.GetTextExtent(pc.GetPageText(tabIdx))
- tabCloseButtonXCoord = posx + textOffset + textWidth + 1
-
- # take a bitmap from the position of the 'x' button (the x on tab button)
- # this bitmap will be used later to delete old buttons
- tabCloseButtonYCoord = imageYCoord
- x_rect = wx.Rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16)
-
- # Draw the tab
- self.DrawTabX(pc, dc, x_rect, tabIdx, btnStatus)
-
-
-#------------------------------------------------------------------
-# Visual studio 2005 (VS8)
-#------------------------------------------------------------------
-class FNBRendererVC8(FNBRenderer):
- """
- This class handles the drawing of tabs using the I{VC8} renderer.
- """
-
- def __init__(self):
- """ Default class constructor. """
-
- FNBRenderer.__init__(self)
- self._first = True
- self._factor = 1
-
-
- def DrawTabs(self, pageContainer, dc):
- """ Draws all the tabs using VC8 style. Overloads The DrawTabs method in parent class. """
-
- pc = pageContainer
-
- if "__WXMAC__" in wx.PlatformInfo:
- # Works well on MSW & GTK, however this lines should be skipped on MAC
- if not pc._pagesInfoVec or pc._nFrom >= len(pc._pagesInfoVec):
- pc.Hide()
- return
-
- # Get the text hight
- tabHeight = self.CalcTabHeight(pageContainer)
-
- # Set the font for measuring the tab height
- normalFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
-
- # Calculate the number of rows required for drawing the tabs
- rect = pc.GetClientRect()
-
- # Set the maximum client size
- pc.SetSizeHints(self.GetButtonsAreaLength(pc), tabHeight)
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
-
- # Create brushes
- backBrush = wx.Brush(pc._tabAreaColor)
- noselBrush = wx.Brush(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE))
- selBrush = wx.Brush(pc._activeTabColor)
- size = pc.GetSize()
-
- # Background
- dc.SetTextBackground(pc.GetBackgroundColour())
- dc.SetTextForeground(pc._activeTextColor)
-
- # If border style is set, set the pen to be border pen
- if pc.HasFlag(FNB_TABS_BORDER_SIMPLE):
- dc.SetPen(borderPen)
- else:
- dc.SetPen(wx.TRANSPARENT_PEN)
-
- lightFactor = (pc.HasFlag(FNB_BACKGROUND_GRADIENT) and [70] or [0])[0]
-
- # For VC8 style, we color the tab area in gradient coloring
- lightcolour = LightColour(pc._tabAreaColor, lightFactor)
- PaintStraightGradientBox(dc, pc.GetClientRect(), pc._tabAreaColor, lightcolour)
-
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.DrawRectangle(0, 0, size.x, size.y)
-
- # We always draw the bottom/upper line of the tabs
- # regradless the style
- dc.SetPen(borderPen)
- self.DrawTabsLine(pc, dc)
-
- # Restore the pen
- dc.SetPen(borderPen)
-
- # Draw labels
- dc.SetFont(boldFont)
-
- # Update all the tabs from 0 to 'pc.self._nFrom' to be non visible
- for i in xrange(pc._nFrom):
-
- pc._pagesInfoVec[i].SetPosition(wx.Point(-1, -1))
- pc._pagesInfoVec[i].GetRegion().Clear()
-
- # Draw the visible tabs, in VC8 style, we draw them from right to left
- vTabsInfo = self.NumberTabsCanFit(pc)
-
- activeTabPosx = 0
- activeTabWidth = 0
- activeTabHeight = 0
-
- for cur in xrange(len(vTabsInfo)-1, -1, -1):
-
- # 'i' points to the index of the currently drawn tab
- # in pc.GetPageInfoVector() vector
- i = pc._nFrom + cur
- dc.SetPen(borderPen)
- dc.SetBrush((i==pc.GetSelection() and [selBrush] or [noselBrush])[0])
-
- # Now set the font to the correct font
- dc.SetFont((i==pc.GetSelection() and [boldFont] or [normalFont])[0])
-
- # Add the padding to the tab width
- # Tab width:
- # +-----------------------------------------------------------+
- # | PADDING | IMG | IMG_PADDING | TEXT | PADDING | x |PADDING |
- # +-----------------------------------------------------------+
-
- tabWidth = self.CalcTabWidth(pageContainer, i, tabHeight)
- posx = vTabsInfo[cur].x
-
- # By default we clean the tab region
- # incase we use the VC8 style which requires
- # the region, it will be filled by the function
- # drawVc8Tab
- pc._pagesInfoVec[i].GetRegion().Clear()
-
- # Clean the 'x' buttn on the tab
- # 'Clean' rectanlge is a rectangle with width or height
- # with values lower than or equal to 0
- pc._pagesInfoVec[i].GetXRect().SetSize(wx.Size(-1, -1))
-
- # Draw the tab
- # Incase we are drawing the active tab
- # we need to redraw so it will appear on top
- # of all other tabs
-
- # when using the vc8 style, we keep the position of the active tab so we will draw it again later
- if i == pc.GetSelection() and pc.HasFlag(FNB_VC8):
-
- activeTabPosx = posx
- activeTabWidth = tabWidth
- activeTabHeight = tabHeight
-
- else:
-
- self.DrawTab(pc, dc, posx, i, tabWidth, tabHeight, pc._nTabXButtonStatus)
-
- # Restore the text forground
- dc.SetTextForeground(pc._activeTextColor)
-
- # Update the tab position & size
- pc._pagesInfoVec[i].SetPosition(wx.Point(posx, VERTICAL_BORDER_PADDING))
- pc._pagesInfoVec[i].SetSize(wx.Size(tabWidth, tabHeight))
-
- # Incase we are in VC8 style, redraw the active tab (incase it is visible)
- if pc.GetSelection() >= pc._nFrom and pc.GetSelection() < pc._nFrom + len(vTabsInfo):
-
- self.DrawTab(pc, dc, activeTabPosx, pc.GetSelection(), activeTabWidth, activeTabHeight, pc._nTabXButtonStatus)
-
- # Update all tabs that can not fit into the screen as non-visible
- for xx in xrange(pc._nFrom + len(vTabsInfo), len(pc._pagesInfoVec)):
-
- pc._pagesInfoVec[xx].SetPosition(wx.Point(-1, -1))
- pc._pagesInfoVec[xx].GetRegion().Clear()
-
- # Draw the left/right/close buttons
- # Left arrow
- self.DrawLeftArrow(pc, dc)
- self.DrawRightArrow(pc, dc)
- self.DrawX(pc, dc)
- self.DrawDropDownArrow(pc, dc)
-
-
- def DrawTab(self, pageContainer, dc, posx, tabIdx, tabWidth, tabHeight, btnStatus):
- """ Draws a tab using VC8 style. """
-
- pc = pageContainer
- borderPen = wx.Pen(pc._pParent.GetBorderColour())
- tabPoints = [wx.Point() for ii in xrange(8)]
-
- # If we draw the first tab or the active tab,
- # we draw a full tab, else we draw a truncated tab
- #
- # X(2) X(3)
- # X(1) X(4)
- #
- # X(5)
- #
- # X(0),(7) X(6)
- #
- #
-
- tabPoints[0].x = (pc.HasFlag(FNB_BOTTOM) and [posx] or [posx+self._factor])[0]
- tabPoints[0].y = (pc.HasFlag(FNB_BOTTOM) and [2] or [tabHeight - 3])[0]
-
- tabPoints[1].x = tabPoints[0].x + tabHeight - VERTICAL_BORDER_PADDING - 3 - self._factor
- tabPoints[1].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - (VERTICAL_BORDER_PADDING+2)] or [(VERTICAL_BORDER_PADDING+2)])[0]
-
- tabPoints[2].x = tabPoints[1].x + 4
- tabPoints[2].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - VERTICAL_BORDER_PADDING] or [VERTICAL_BORDER_PADDING])[0]
-
- tabPoints[3].x = tabPoints[2].x + tabWidth - 2
- tabPoints[3].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - VERTICAL_BORDER_PADDING] or [VERTICAL_BORDER_PADDING])[0]
-
- tabPoints[4].x = tabPoints[3].x + 1
- tabPoints[4].y = (pc.HasFlag(FNB_BOTTOM) and [tabPoints[3].y - 1] or [tabPoints[3].y + 1])[0]
-
- tabPoints[5].x = tabPoints[4].x + 1
- tabPoints[5].y = (pc.HasFlag(FNB_BOTTOM) and [(tabPoints[4].y - 1)] or [tabPoints[4].y + 1])[0]
-
- tabPoints[6].x = tabPoints[2].x + tabWidth
- tabPoints[6].y = tabPoints[0].y
-
- tabPoints[7].x = tabPoints[0].x
- tabPoints[7].y = tabPoints[0].y
-
- pc._pagesInfoVec[tabIdx].SetRegion(tabPoints)
-
- # Draw the polygon
- br = dc.GetBrush()
- dc.SetBrush(wx.Brush((tabIdx == pc.GetSelection() and [pc._activeTabColor] or [pc._colorTo])[0]))
- dc.SetPen(wx.Pen((tabIdx == pc.GetSelection() and [wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)] or [pc._colorBorder])[0]))
- dc.DrawPolygon(tabPoints)
-
- # Restore the brush
- dc.SetBrush(br)
- rect = pc.GetClientRect()
-
- if tabIdx != pc.GetSelection() and not pc.HasFlag(FNB_BOTTOM):
-
- # Top default tabs
- dc.SetPen(wx.Pen(pc._pParent.GetBorderColour()))
- lineY = rect.height
- curPen = dc.GetPen()
- curPen.SetWidth(1)
- dc.SetPen(curPen)
- dc.DrawLine(posx, lineY, posx+rect.width, lineY)
-
- # Incase we are drawing the selected tab, we draw the border of it as well
- # but without the bottom (upper line incase of wxBOTTOM)
- if tabIdx == pc.GetSelection():
-
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
- dc.SetPen(borderPen)
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.DrawPolygon(tabPoints)
-
- # Delete the bottom line (or the upper one, incase we use wxBOTTOM)
- dc.SetPen(wx.WHITE_PEN)
- dc.DrawLine(tabPoints[0].x, tabPoints[0].y, tabPoints[6].x, tabPoints[6].y)
-
- self.FillVC8GradientColour(pc, dc, tabPoints, tabIdx == pc.GetSelection(), tabIdx)
-
- # Draw a thin line to the right of the non-selected tab
- if tabIdx != pc.GetSelection():
-
- dc.SetPen(wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)))
- dc.DrawLine(tabPoints[4].x-1, tabPoints[4].y, tabPoints[5].x-1, tabPoints[5].y)
- dc.DrawLine(tabPoints[5].x-1, tabPoints[5].y, tabPoints[6].x-1, tabPoints[6].y)
-
- # Text drawing offset from the left border of the
- # rectangle
-
- # The width of the images are 16 pixels
- vc8ShapeLen = tabHeight - VERTICAL_BORDER_PADDING - 2
- if pc.TabHasImage(tabIdx):
- textOffset = 2*pc._pParent.GetPadding() + 16 + vc8ShapeLen
- else:
- textOffset = pc._pParent.GetPadding() + vc8ShapeLen
-
- # Draw the image for the tab if any
- imageYCoord = (pc.HasFlag(FNB_BOTTOM) and [6] or [8])[0]
-
- if pc.TabHasImage(tabIdx):
-
- imageXOffset = textOffset - 16 - pc._pParent.GetPadding()
- pc._ImageList.Draw(pc._pagesInfoVec[tabIdx].GetImageIndex(), dc,
- posx + imageXOffset, imageYCoord,
- wx.IMAGELIST_DRAW_TRANSPARENT, True)
-
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
-
- # if selected tab, draw text in bold
- if tabIdx == pc.GetSelection():
- boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
-
- dc.SetFont(boldFont)
- dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
-
- # draw 'x' on tab (if enabled)
- if pc.HasFlag(FNB_X_ON_TAB) and tabIdx == pc.GetSelection():
-
- textWidth, textHeight = dc.GetTextExtent(pc.GetPageText(tabIdx))
- tabCloseButtonXCoord = posx + textOffset + textWidth + 1
-
- # take a bitmap from the position of the 'x' button (the x on tab button)
- # this bitmap will be used later to delete old buttons
- tabCloseButtonYCoord = imageYCoord
- x_rect = wx.Rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16)
- # Draw the tab
- self.DrawTabX(pc, dc, x_rect, tabIdx, btnStatus)
-
- self.DrawFocusRectangle(dc, pc, pc._pagesInfoVec[tabIdx])
-
-
- def FillVC8GradientColour(self, pageContainer, dc, tabPoints, bSelectedTab, tabIdx):
- """ Fills a tab with a gradient shading. """
-
- # calculate gradient coefficients
- pc = pageContainer
-
- if self._first:
- self._first = False
- pc._colorTo = LightColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), 0)
- pc._colorFrom = LightColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), 60)
-
- col2 = pc._pParent.GetGradientColourTo()
- col1 = pc._pParent.GetGradientColourFrom()
-
- # If colorful tabs style is set, override the tab color
- if pc.HasFlag(FNB_COLORFUL_TABS):
-
- if not pc._pagesInfoVec[tabIdx].GetColour():
-
- # First time, generate color, and keep it in the vector
- tabColor = RandomColour()
- pc._pagesInfoVec[tabIdx].SetColour(tabColor)
-
- if pc.HasFlag(FNB_BOTTOM):
-
- col2 = LightColour(pc._pagesInfoVec[tabIdx].GetColour(), 50)
- col1 = LightColour(pc._pagesInfoVec[tabIdx].GetColour(), 80)
-
- else:
-
- col1 = LightColour(pc._pagesInfoVec[tabIdx].GetColour(), 50)
- col2 = LightColour(pc._pagesInfoVec[tabIdx].GetColour(), 80)
-
- size = abs(tabPoints[2].y - tabPoints[0].y) - 1
-
- rf, gf, bf = 0, 0, 0
- rstep = float(col2.Red() - col1.Red())/float(size)
- gstep = float(col2.Green() - col1.Green())/float(size)
- bstep = float(col2.Blue() - col1.Blue())/float(size)
-
- y = tabPoints[0].y
-
- # If we are drawing the selected tab, we need also to draw a line
- # from 0.tabPoints[0].x and tabPoints[6].x . end, we achieve this
- # by drawing the rectangle with transparent brush
- # the line under the selected tab will be deleted by the drwaing loop
- if bSelectedTab:
- self.DrawTabsLine(pc, dc)
-
- while 1:
-
- if pc.HasFlag(FNB_BOTTOM):
-
- if y > tabPoints[0].y + size:
- break
-
- else:
-
- if y < tabPoints[0].y - size:
- break
-
- currCol = wx.Colour(col1.Red() + rf, col1.Green() + gf, col1.Blue() + bf)
-
- dc.SetPen((bSelectedTab and [wx.Pen(pc._activeTabColor)] or [wx.Pen(currCol)])[0])
- startX = self.GetStartX(tabPoints, y, pc.GetParent().GetWindowStyleFlag())
- endX = self.GetEndX(tabPoints, y, pc.GetParent().GetWindowStyleFlag())
- dc.DrawLine(startX, y, endX, y)
-
- # Draw the border using the 'edge' point
- dc.SetPen(wx.Pen((bSelectedTab and [wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)] or [pc._colorBorder])[0]))
-
- dc.DrawPoint(startX, y)
- dc.DrawPoint(endX, y)
-
- # Progress the color
- rf += rstep
- gf += gstep
- bf += bstep
-
- if pc.HasFlag(FNB_BOTTOM):
- y = y + 1
- else:
- y = y - 1
-
-
- def GetStartX(self, tabPoints, y, style):
- """ Returns the x start position of a tab. """
-
- x1, x2, y1, y2 = 0.0, 0.0, 0.0, 0.0
-
- # We check the 3 points to the left
-
- bBottomStyle = (style & FNB_BOTTOM and [True] or [False])[0]
- match = False
-
- if bBottomStyle:
-
- for i in xrange(3):
-
- if y >= tabPoints[i].y and y < tabPoints[i+1].y:
-
- x1 = tabPoints[i].x
- x2 = tabPoints[i+1].x
- y1 = tabPoints[i].y
- y2 = tabPoints[i+1].y
- match = True
- break
-
- else:
-
- for i in xrange(3):
-
- if y <= tabPoints[i].y and y > tabPoints[i+1].y:
-
- x1 = tabPoints[i].x
- x2 = tabPoints[i+1].x
- y1 = tabPoints[i].y
- y2 = tabPoints[i+1].y
- match = True
- break
-
- if not match:
- return tabPoints[2].x
-
- # According to the equation y = ax + b => x = (y-b)/a
- # We know the first 2 points
-
- if x2 == x1:
- return x2
- else:
- a = (y2 - y1)/(x2 - x1)
-
- b = y1 - ((y2 - y1)/(x2 - x1))*x1
-
- if a == 0:
- return int(x1)
-
- x = (y - b)/a
-
- return int(x)
-
-
- def GetEndX(self, tabPoints, y, style):
- """ Returns the x end position of a tab. """
-
- x1, x2, y1, y2 = 0.0, 0.0, 0.0, 0.0
-
- # We check the 3 points to the left
- bBottomStyle = (style & FNB_BOTTOM and [True] or [False])[0]
- match = False
-
- if bBottomStyle:
-
- for i in xrange(7, 3, -1):
-
- if y >= tabPoints[i].y and y < tabPoints[i-1].y:
-
- x1 = tabPoints[i].x
- x2 = tabPoints[i-1].x
- y1 = tabPoints[i].y
- y2 = tabPoints[i-1].y
- match = True
- break
-
- else:
-
- for i in xrange(7, 3, -1):
-
- if y <= tabPoints[i].y and y > tabPoints[i-1].y:
-
- x1 = tabPoints[i].x
- x2 = tabPoints[i-1].x
- y1 = tabPoints[i].y
- y2 = tabPoints[i-1].y
- match = True
- break
-
- if not match:
- return tabPoints[3].x
-
- # According to the equation y = ax + b => x = (y-b)/a
- # We know the first 2 points
-
- # Vertical line
- if x1 == x2:
- return int(x1)
-
- a = (y2 - y1)/(x2 - x1)
- b = y1 - ((y2 - y1)/(x2 - x1))*x1
-
- if a == 0:
- return int(x1)
-
- x = (y - b)/a
-
- return int(x)
-
-
- def NumberTabsCanFit(self, pageContainer, fr=-1):
- """ Returns the number of tabs that can fit in the visible area. """
-
- pc = pageContainer
-
- rect = pc.GetClientRect()
- clientWidth = rect.width
-
- # Empty results
- vTabInfo = []
- tabHeight = self.CalcTabHeight(pageContainer)
-
- # The drawing starts from posx
- posx = pc._pParent.GetPadding()
-
- if fr < 0:
- fr = pc._nFrom
-
- for i in xrange(fr, len(pc._pagesInfoVec)):
-
- vc8glitch = tabHeight + FNB_HEIGHT_SPACER
- tabWidth = self.CalcTabWidth(pageContainer, i, tabHeight)
-
- if posx + tabWidth + vc8glitch + self.GetButtonsAreaLength(pc) >= clientWidth:
- break
-
- # Add a result to the returned vector
- tabRect = wx.Rect(posx, VERTICAL_BORDER_PADDING, tabWidth, tabHeight)
- vTabInfo.append(tabRect)
-
- # Advance posx
- posx += tabWidth + FNB_HEIGHT_SPACER
-
- return vTabInfo
-
-
-# ---------------------------------------------------------------------------- #
-# Class FlatNotebook
-# ---------------------------------------------------------------------------- #
-
-class FlatNotebook(wx.PyPanel):
- """
- Display one or more windows in a notebook.
-
- B{Events}:
- - B{EVT_FLATNOTEBOOK_PAGE_CHANGING}: sent when the active
- page in the notebook is changing
- - B{EVT_FLATNOTEBOOK_PAGE_CHANGED}: sent when the active
- page in the notebook has changed
- - B{EVT_FLATNOTEBOOK_PAGE_CLOSING}: sent when a page in the
- notebook is closing
- - B{EVT_FLATNOTEBOOK_PAGE_CLOSED}: sent when a page in the
- notebook has been closed
- - B{EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU}: sent when the user
- clicks a tab in the notebook with the right mouse
- button
- """
-
- def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
- style=0, name="FlatNotebook"):
- """
- Default class constructor.
-
- All the parameters are as in wxPython class construction, except the
- 'style': this can be assigned to whatever combination of FNB_* styles.
-
- """
-
- self._bForceSelection = False
- self._nPadding = 6
- self._nFrom = 0
- style |= wx.TAB_TRAVERSAL
- self._pages = None
- self._windows = []
- self._popupWin = None
- self._naviIcon = None
-
- wx.PyPanel.__init__(self, parent, id, pos, size, style)
-
- self._pages = PageContainer(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, style)
-
- self.Bind(wx.EVT_NAVIGATION_KEY, self.OnNavigationKey)
-
- self.Init()
-
-
- def Init(self):
- """ Initializes all the class attributes. """
-
- self._pages._colorBorder = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)
-
- self._mainSizer = wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(self._mainSizer)
-
- # The child panels will inherit this bg color, so leave it at the default value
- #self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_APPWORKSPACE))
-
- # Set default page height
- dc = wx.ClientDC(self)
-
- if "__WXGTK__" in wx.PlatformInfo:
- # For GTK it seems that we must do this steps in order
- # for the tabs will get the proper height on initialization
- # on MSW, preforming these steps yields wierd results
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
- dc.SetFont(boldFont)
-
- height = dc.GetCharHeight()
-
- tabHeight = height + FNB_HEIGHT_SPACER # We use 8 pixels as padding
-
- if "__WXGTK__" in wx.PlatformInfo:
- tabHeight += 6
-
- self._pages.SetSizeHints(-1, tabHeight)
- # Add the tab container to the sizer
- self._mainSizer.Insert(0, self._pages, 0, wx.EXPAND)
- self._mainSizer.Layout()
-
- self._pages._nFrom = self._nFrom
- self._pDropTarget = FNBDropTarget(self)
- self.SetDropTarget(self._pDropTarget)
-
-
- def DoGetBestSize(self):
- """ Overrides DoGetBestSize to handle sizers nicely. """
-
- if not self._windows:
- # Something is better than nothing... no pages!
- return wx.Size(20, 20)
-
- maxWidth = maxHeight = 0
- tabHeight = self.GetPageBestSize().height
-
- for win in self._windows:
- # Loop over all the windows to get their best size
- width, height = win.GetBestSize()
- maxWidth, maxHeight = max(maxWidth, width), max(maxHeight, height)
-
- return wx.Size(maxWidth, maxHeight+tabHeight)
-
-
- def SetActiveTabTextColour(self, textColour):
- """ Sets the text colour for the active tab. """
-
- self._pages._activeTextColor = textColour
-
-
- def OnDropTarget(self, x, y, nTabPage, wnd_oldContainer):
- """ Handles the drop action from a DND operation. """
-
- return self._pages.OnDropTarget(x, y, nTabPage, wnd_oldContainer)
-
-
- def GetPreviousSelection(self):
- """ Returns the previous selection. """
-
- return self._pages._iPreviousActivePage
-
-
- def AddPage(self, page, text, select=True, imageId=-1):
- """
- Add a page to the L{FlatNotebook}.
-
- @param page: Specifies the new page.
- @param text: Specifies the text for the new page.
- @param select: Specifies whether the page should be selected.
- @param imageId: Specifies the optional image index for the new page.
-
- Return value:
- True if successful, False otherwise.
- """
-
- # sanity check
- if not page:
- return False
-
- # reparent the window to us
- page.Reparent(self)
-
- # Add tab
- bSelected = select or len(self._windows) == 0
-
- if bSelected:
-
- bSelected = False
-
- # Check for selection and send events
- oldSelection = self._pages._iActivePage
- tabIdx = len(self._windows)
-
- event = FlatNotebookEvent(wxEVT_FLATNOTEBOOK_PAGE_CHANGING, self.GetId())
- event.SetSelection(tabIdx)
- event.SetOldSelection(oldSelection)
- event.SetEventObject(self)
-
- if not self.GetEventHandler().ProcessEvent(event) or event.IsAllowed() or len(self._windows) == 0:
- bSelected = True
-
- curSel = self._pages.GetSelection()
-
- if not self._pages.IsShown():
- self._pages.Show()
-
- self._pages.AddPage(text, bSelected, imageId)
- self._windows.append(page)
-
- self.Freeze()
-
- # Check if a new selection was made
- if bSelected:
-
- if curSel >= 0:
-
- # Remove the window from the main sizer
- self._mainSizer.Detach(self._windows[curSel])
- self._windows[curSel].Hide()
-
- if self.GetWindowStyleFlag() & FNB_BOTTOM:
-
- self._mainSizer.Insert(0, page, 1, wx.EXPAND)
-
- else:
-
- # We leave a space of 1 pixel around the window
- self._mainSizer.Add(page, 1, wx.EXPAND)
-
- # Fire a wxEVT_FLATNOTEBOOK_PAGE_CHANGED event
- event.SetEventType(wxEVT_FLATNOTEBOOK_PAGE_CHANGED)
- event.SetOldSelection(oldSelection)
- self.GetEventHandler().ProcessEvent(event)
-
- else:
-
- # Hide the page
- page.Hide()
-
- self.Thaw()
- self._mainSizer.Layout()
- self.Refresh()
-
- return True
-
-
- def SetImageList(self, imageList):
- """ Sets the image list for the page control. """
-
- self._pages.SetImageList(imageList)
-
-
- def AssignImageList(self, imageList):
- """ Assigns the image list for the page control. """
-
- self._pages.AssignImageList(imageList)
-
-
- def GetImageList(self):
- """ Returns the associated image list. """
-
- return self._pages.GetImageList()
-
-
- def InsertPage(self, indx, page, text, select=True, imageId=-1):
- """
- Inserts a new page at the specified position.
-
- @param indx: Specifies the position of the new page.
- @param page: Specifies the new page.
- @param text: Specifies the text for the new page.
- @param select: Specifies whether the page should be selected.
- @param imageId: Specifies the optional image index for the new page.
-
- Return value:
- True if successful, False otherwise.
- """
-
- # sanity check
- if not page:
- return False
-
- # reparent the window to us
- page.Reparent(self)
-
- if not self._windows:
-
- self.AddPage(page, text, select, imageId)
- return True
-
- # Insert tab
- bSelected = select or not self._windows
- curSel = self._pages.GetSelection()
-
- indx = max(0, min(indx, len(self._windows)))
-
- if indx <= len(self._windows):
-
- self._windows.insert(indx, page)
-
- else:
-
- self._windows.append(page)
-
- if bSelected:
-
- bSelected = False
-
- # Check for selection and send events
- oldSelection = self._pages._iActivePage
-
- event = FlatNotebookEvent(wxEVT_FLATNOTEBOOK_PAGE_CHANGING, self.GetId())
- event.SetSelection(indx)
- event.SetOldSelection(oldSelection)
- event.SetEventObject(self)
-
- if not self.GetEventHandler().ProcessEvent(event) or event.IsAllowed() or len(self._windows) == 0:
- bSelected = True
-
- self._pages.InsertPage(indx, text, bSelected, imageId)
-
- if indx <= curSel:
- curSel = curSel + 1
-
- self.Freeze()
-
- # Check if a new selection was made
- if bSelected:
-
- if curSel >= 0:
-
- # Remove the window from the main sizer
- self._mainSizer.Detach(self._windows[curSel])
- self._windows[curSel].Hide()
-
- self._pages.SetSelection(indx)
-
- # Fire a wxEVT_FLATNOTEBOOK_PAGE_CHANGED event
- event.SetEventType(wxEVT_FLATNOTEBOOK_PAGE_CHANGED)
- event.SetOldSelection(oldSelection)
- self.GetEventHandler().ProcessEvent(event)
-
- else:
-
- # Hide the page
- page.Hide()
-
- self.Thaw()
- self._mainSizer.Layout()
- self.Refresh()
-
- return True
-
-
- def SetSelection(self, page):
- """
- Sets the selection for the given page.
- The call to this function generates the page changing events
- """
-
- if page >= len(self._windows) or not self._windows:
- return
-
- # Support for disabed tabs
- if not self._pages.GetEnabled(page) and len(self._windows) > 1 and not self._bForceSelection:
- return
-
- curSel = self._pages.GetSelection()
-
- # program allows the page change
- self.Freeze()
- if curSel >= 0:
-
- # Remove the window from the main sizer
- self._mainSizer.Detach(self._windows[curSel])
- self._windows[curSel].Hide()
-
- if self.GetWindowStyleFlag() & FNB_BOTTOM:
-
- self._mainSizer.Insert(0, self._windows[page], 1, wx.EXPAND)
-
- else:
-
- # We leave a space of 1 pixel around the window
- self._mainSizer.Add(self._windows[page], 1, wx.EXPAND)
-
- self._windows[page].Show()
- self.Thaw()
-
- self._mainSizer.Layout()
-
- if page != self._pages._iActivePage:
- # there is a real page changing
- self._pages._iPreviousActivePage = self._pages._iActivePage
-
- self._pages._iActivePage = page
- self._pages.DoSetSelection(page)
-
- def DeletePage(self, page):
- """
- Deletes the specified page, and the associated window.
- The call to this function generates the page changing events.
- """
-
- if page >= len(self._windows) or page < 0:
- return
-
- # Fire a closing event
- event = FlatNotebookEvent(wxEVT_FLATNOTEBOOK_PAGE_CLOSING, self.GetId())
- event.SetSelection(page)
- event.SetEventObject(self)
- self.GetEventHandler().ProcessEvent(event)
-
- # The event handler allows it?
- if not event.IsAllowed():
- return
-
- self.Freeze()
-
- # Delete the requested page
- pageRemoved = self._windows[page]
-
- # If the page is the current window, remove it from the sizer
- # as well
- if page == self._pages.GetSelection():
- self._mainSizer.Detach(pageRemoved)
-
- # Remove it from the array as well
- self._windows.pop(page)
-
- # Now we can destroy it in wxWidgets use Destroy instead of delete
- pageRemoved.Destroy()
-
- self.Thaw()
-
- self._pages.DoDeletePage(page)
- self.Refresh()
- self.Update()
-
- # Fire a closed event
- closedEvent = FlatNotebookEvent(wxEVT_FLATNOTEBOOK_PAGE_CLOSED, self.GetId())
- closedEvent.SetSelection(page)
- closedEvent.SetEventObject(self)
- self.GetEventHandler().ProcessEvent(closedEvent)
-
-
- def DeleteAllPages(self):
- """ Deletes all the pages. """
-
- if not self._windows:
- return False
-
- self.Freeze()
-
- for page in self._windows:
- page.Destroy()
-
- self._windows = []
- self.Thaw()
-
- # Clear the container of the tabs as well
- self._pages.DeleteAllPages()
- return True
-
-
- def GetCurrentPage(self):
- """ Returns the currently selected notebook page or None. """
-
- sel = self._pages.GetSelection()
- if sel < 0:
- return None
-
- return self._windows[sel]
-
-
- def GetPage(self, page):
- """ Returns the window at the given page position, or None. """
-
- if page >= len(self._windows):
- return None
-
- return self._windows[page]
-
-
- def GetPageIndex(self, win):
- """ Returns the index at which the window is found. """
-
- try:
- return self._windows.index(win)
- except:
- return -1
-
-
- def GetSelection(self):
- """ Returns the currently selected page, or -1 if none was selected. """
-
- return self._pages.GetSelection()
-
-
- def AdvanceSelection(self, forward=True):
- """
- Cycles through the tabs.
- The call to this function generates the page changing events.
- """
-
- self._pages.AdvanceSelection(forward)
-
-
- def GetPageCount(self):
- """ Returns the number of pages in the L{FlatNotebook} control. """
-
- return self._pages.GetPageCount()
-
- def SetNavigatorIcon(self, bmp):
- """ Set the icon used by the L{TabNavigatorWindow} """
- if isinstance(bmp, wx.Bitmap) and bmp.IsOk():
- # Make sure image is proper size
- if bmp.GetSize() != (16, 16):
- img = bmp.ConvertToImage()
- img.Rescale(16, 16, wx.IMAGE_QUALITY_HIGH)
- bmp = wx.BitmapFromImage(img)
- self._naviIcon = bmp
- else:
- raise TypeError, "SetNavigatorIcon requires a valid bitmap"
-
- def Navigation(self, direction=True):
- if len(self._windows) >= 1:
- if not self._popupWin:
- self._popupWin = TabNavigatorWindow(self, self._naviIcon)
- self._popupWin.SetReturnCode(wx.ID_OK)
- self._popupWin.ShowModal()
- self._popupWin.Destroy()
- self._popupWin = None
- else:
- # a dialog is already opened
- self._popupWin.Navigation(direction)
-
- def OnNavigationKey(self, event):
- """ Handles the wx.EVT_NAVIGATION_KEY event for L{FlatNotebook}. """
-
- if event.IsWindowChange():
- if len(self._windows) == 0:
- return
- # change pages
- if self.HasFlag(FNB_SMART_TABS):
- if not self._popupWin:
- self._popupWin = TabNavigatorWindow(self, self._naviIcon)
- self._popupWin.SetReturnCode(wx.ID_OK)
- self._popupWin.ShowModal()
- self._popupWin.Destroy()
- self._popupWin = None
- else:
- # a dialog is already opened
- self._popupWin.OnNavigationKey(event)
- return
- else:
- # change pages
- self.AdvanceSelection(event.GetDirection())
-
- else:
- event.Skip()
-
-
- def GetPageShapeAngle(self, page_index):
- """ Returns the angle associated to a tab. """
-
- if page_index < 0 or page_index >= len(self._pages._pagesInfoVec):
- return None, False
-
- result = self._pages._pagesInfoVec[page_index].GetTabAngle()
- return result, True
-
-
- def SetPageShapeAngle(self, page_index, angle):
- """ Sets the angle associated to a tab. """
-
- if page_index < 0 or page_index >= len(self._pages._pagesInfoVec):
- return
-
- if angle > 15:
- return
-
- self._pages._pagesInfoVec[page_index].SetTabAngle(angle)
-
-
- def SetAllPagesShapeAngle(self, angle):
- """ Sets the angle associated to all the tab. """
-
- if angle > 15:
- return
-
- for ii in xrange(len(self._pages._pagesInfoVec)):
- self._pages._pagesInfoVec[ii].SetTabAngle(angle)
-
- self.Refresh()
-
-
- def GetPageBestSize(self):
- """ Return the page best size. """
-
- return self._pages.GetClientSize()
-
-
- def SetPageText(self, page, text):
- """ Sets the text for the given page. """
-
- bVal = self._pages.SetPageText(page, text)
- self._pages.EnsureVisible(page, False)
- self._pages.Refresh()
-
- return bVal
-
-
- def SetPadding(self, padding):
- """
- Sets the amount of space around each page's icon and label, in pixels.
- NB: only the horizontal padding is considered.
- """
-
- self._nPadding = padding.GetWidth()
-
-
- def GetTabArea(self):
- """ Returns the associated page. """
-
- return self._pages
-
-
- def GetPadding(self):
- """ Returns the amount of space around each page's icon and label, in pixels. """
-
- return self._nPadding
-
-
- def SetWindowStyleFlag(self, style):
- """ Sets the L{FlatNotebook} window style flags. """
-
- wx.PyPanel.SetWindowStyleFlag(self, style)
- renderer = self._pages._mgr.GetRenderer(self.GetWindowStyleFlag())
- renderer._tabHeight = None
-
- if self._pages:
-
- # For changing the tab position (i.e. placing them top/bottom)
- # refreshing the tab container is not enough
- self.SetSelection(self._pages._iActivePage)
-
- if not self._pages.HasFlag(FNB_HIDE_ON_SINGLE_TAB):
- #For Redrawing the Tabs once you remove the Hide tyle
- self._pages._ReShow()
-
-
- def RemovePage(self, page):
- """ Deletes the specified page, without deleting the associated window. """
-
- if page >= len(self._windows):
- return False
-
- # Fire a closing event
- event = FlatNotebookEvent(wxEVT_FLATNOTEBOOK_PAGE_CLOSING, self.GetId())
- event.SetSelection(page)
- event.SetEventObject(self)
- self.GetEventHandler().ProcessEvent(event)
-
- # The event handler allows it?
- if not event.IsAllowed():
- return False
-
- self.Freeze()
-
- # Remove the requested page
- pageRemoved = self._windows[page]
-
- # If the page is the current window, remove it from the sizer
- # as well
- if page == self._pages.GetSelection():
- self._mainSizer.Detach(pageRemoved)
-
- # Remove it from the array as well
- self._windows.pop(page)
- self.Thaw()
-
- self._pages.DoDeletePage(page)
-
- return True
-
-
- def SetRightClickMenu(self, menu):
- """ Sets the popup menu associated to a right click on a tab. """
-
- self._pages._pRightClickMenu = menu
-
-
- def GetPageText(self, nPage):
- """ Returns the tab caption. """
-
- return self._pages.GetPageText(nPage)
-
-
- def SetGradientColours(self, fr, to, border):
- """ Sets the gradient colours for the tab. """
-
- self._pages._colorFrom = fr
- self._pages._colorTo = to
- self._pages._colorBorder = border
-
-
- def SetGradientColourFrom(self, fr):
- """ Sets the starting colour for the gradient. """
-
- self._pages._colorFrom = fr
-
-
- def SetGradientColourTo(self, to):
- """ Sets the ending colour for the gradient. """
-
- self._pages._colorTo = to
-
-
- def SetGradientColourBorder(self, border):
- """ Sets the tab border colour. """
-
- self._pages._colorBorder = border
-
-
- def GetGradientColourFrom(self):
- """ Gets first gradient colour. """
-
- return self._pages._colorFrom
-
-
- def GetGradientColourTo(self):
- """ Gets second gradient colour. """
-
- return self._pages._colorTo
-
-
- def GetGradientColourBorder(self):
- """ Gets the tab border colour. """
-
- return self._pages._colorBorder
-
-
- def GetBorderColour(self):
- """ Returns the border colour. """
-
- return self._pages._colorBorder
-
-
- def GetActiveTabTextColour(self):
- """ Get the active tab text colour. """
-
- return self._pages._activeTextColor
-
-
- def SetPageImage(self, page, image):
- """
- Sets the image index for the given page. Image is an index into the
- image list which was set with SetImageList.
- """
-
- self._pages.SetPageImage(page, image)
-
-
- def GetPageImage(self, nPage):
- """
- Returns the image index for the given page. Image is an index into the
- image list which was set with SetImageList.
- """
-
- return self._pages.GetPageImage(nPage)
-
-
- def GetEnabled(self, page):
- """ Returns whether a tab is enabled or not. """
-
- return self._pages.GetEnabled(page)
-
-
- def EnableTab(self, page, enabled=True):
- """ Enables or disables a tab. """
-
- if page >= len(self._windows):
- return
-
- self._windows[page].Enable(enabled)
- self._pages.EnableTab(page, enabled)
-
-
- def GetNonActiveTabTextColour(self):
- """ Returns the non active tabs text colour. """
-
- return self._pages._nonActiveTextColor
-
-
- def SetNonActiveTabTextColour(self, color):
- """ Sets the non active tabs text colour. """
-
- self._pages._nonActiveTextColor = color
-
-
- def SetTabAreaColour(self, color):
- """ Sets the area behind the tabs colour. """
-
- self._pages._tabAreaColor = color
-
-
- def GetTabAreaColour(self):
- """ Returns the area behind the tabs colour. """
-
- return self._pages._tabAreaColor
-
-
- def SetActiveTabColour(self, color):
- """ Sets the active tab colour. """
-
- self._pages._activeTabColor = color
-
-
- def GetActiveTabColour(self):
- """ Returns the active tab colour. """
-
- return self._pages._activeTabColor
-
-
- def EnsureVisible(self, page):
- """ Ensures that a tab is visible. """
-
- self._pages.DoSetSelection(page)
-
-
-# ---------------------------------------------------------------------------- #
-# Class PageContainer
-# Acts as a container for the pages you add to FlatNotebook
-# ---------------------------------------------------------------------------- #
-
-class PageContainer(wx.Panel):
- """
- This class acts as a container for the pages you add to L{FlatNotebook}.
- """
-
- def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
- size=wx.DefaultSize, style=0):
- """ Default class constructor. """
-
- self._ImageList = None
- self._iActivePage = -1
- self._pDropTarget = None
- self._nLeftClickZone = FNB_NOWHERE
- self._iPreviousActivePage = -1
-
- self._pRightClickMenu = None
- self._nXButtonStatus = FNB_BTN_NONE
- self._nArrowDownButtonStatus = FNB_BTN_NONE
- self._pParent = parent
- self._nRightButtonStatus = FNB_BTN_NONE
- self._nLeftButtonStatus = FNB_BTN_NONE
- self._nTabXButtonStatus = FNB_BTN_NONE
-
- self._pagesInfoVec = []
-
- self._colorTo = wx.SystemSettings_GetColour(wx.SYS_COLOUR_ACTIVECAPTION)
- self._colorFrom = wx.WHITE
- self._activeTabColor = wx.WHITE
- self._activeTextColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNTEXT)
- self._nonActiveTextColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNTEXT)
- self._tabAreaColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE)
-
- self._nFrom = 0
- self._isdragging = False
-
- # Set default page height, this is done according to the system font
- memDc = wx.MemoryDC()
- memDc.SelectObject(wx.EmptyBitmap(1,1))
-
- if "__WXGTK__" in wx.PlatformInfo:
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont.SetWeight(wx.BOLD)
- memDc.SetFont(boldFont)
-
- height = memDc.GetCharHeight()
- tabHeight = height + FNB_HEIGHT_SPACER # We use 10 pixels as padding
-
- wx.Panel.__init__(self, parent, id, pos, wx.Size(size.x, tabHeight),
- style|wx.NO_BORDER|wx.NO_FULL_REPAINT_ON_RESIZE|wx.WANTS_CHARS)
-
- self._pDropTarget = FNBDropTarget(self)
- self.SetDropTarget(self._pDropTarget)
- self._mgr = FNBRendererMgr()
-
- self.Bind(wx.EVT_PAINT, self.OnPaint)
- self.Bind(wx.EVT_SIZE, self.OnSize)
- self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
- self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
- self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
- self.Bind(wx.EVT_MIDDLE_DOWN, self.OnMiddleDown)
- self.Bind(wx.EVT_MOTION, self.OnMouseMove)
- self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
- self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)
- self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnterWindow)
- self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
- self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
- self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
- self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
-
-
- def OnEraseBackground(self, event):
- """ Handles the wx.EVT_ERASE_BACKGROUND event for L{PageContainer} (does nothing)."""
-
- pass
-
-
- def _ReShow(self):
- """ Handles the Redraw of the tabs when the FNB_HIDE_ON_SINGLE_TAB has been removed """
- self.Show()
- self.GetParent()._mainSizer.Layout()
- self.Refresh()
-
-
- def OnPaint(self, event):
- """ Handles the wx.EVT_PAINT event for L{PageContainer}."""
-
- dc = wx.BufferedPaintDC(self)
- renderer = self._mgr.GetRenderer(self.GetParent().GetWindowStyleFlag())
- renderer.DrawTabs(self, dc)
-
- if self.HasFlag(FNB_HIDE_ON_SINGLE_TAB) and len(self._pagesInfoVec) <= 1:
- self.Hide()
- self.GetParent()._mainSizer.Layout()
- self.Refresh()
-
-
- def AddPage(self, caption, selected=True, imgindex=-1):
- """
- Add a page to the L{FlatNotebook}.
-
- @param window: Specifies the new page.
- @param caption: Specifies the text for the new page.
- @param selected: Specifies whether the page should be selected.
- @param imgindex: Specifies the optional image index for the new page.
-
- Return value:
- True if successful, False otherwise.
- """
-
- if selected:
-
- self._iPreviousActivePage = self._iActivePage
- self._iActivePage = len(self._pagesInfoVec)
-
- # Create page info and add it to the vector
- pageInfo = PageInfo(caption, imgindex)
- self._pagesInfoVec.append(pageInfo)
- self.Refresh()
-
-
- def InsertPage(self, indx, text, selected=True, imgindex=-1):
- """
- Inserts a new page at the specified position.
-
- @param indx: Specifies the position of the new page.
- @param page: Specifies the new page.
- @param text: Specifies the text for the new page.
- @param select: Specifies whether the page should be selected.
- @param imgindex: Specifies the optional image index for the new page.
-
- Return value:
- True if successful, False otherwise.
- """
-
- if selected:
-
- self._iPreviousActivePage = self._iActivePage
- self._iActivePage = len(self._pagesInfoVec)
-
- self._pagesInfoVec.insert(indx, PageInfo(text, imgindex))
-
- self.Refresh()
- return True
-
-
- def OnSize(self, event):
- """ Handles the wx.EVT_SIZE events for L{PageContainer}. """
-
- # When resizing the control, try to fit to screen as many tabs as we can
- style = self.GetParent().GetWindowStyleFlag()
- renderer = self._mgr.GetRenderer(style)
-
- fr = 0
- page = self.GetSelection()
-
- for fr in xrange(self._nFrom):
- vTabInfo = renderer.NumberTabsCanFit(self, fr)
- if page - fr >= len(vTabInfo):
- continue
- break
-
- self._nFrom = fr
-
- self.EnsureVisible(page, False)
- self.Refresh() # Call on paint
- event.Skip()
-
-
- def OnMiddleDown(self, event):
- """ Handles the wx.EVT_MIDDLE_DOWN events for L{PageContainer}. """
-
- # Test if this style is enabled
- style = self.GetParent().GetWindowStyleFlag()
-
- if not style & FNB_MOUSE_MIDDLE_CLOSES_TABS:
- return
-
- where, tabIdx = self.HitTest(event.GetPosition())
-
- if where == FNB_TAB:
- self.DeletePage(tabIdx)
-
- event.Skip()
-
-
- def OnRightDown(self, event):
- """ Handles the wx.EVT_RIGHT_DOWN events for L{PageContainer}. """
-
- where, tabIdx = self.HitTest(event.GetPosition())
-
- if where in [FNB_TAB, FNB_TAB_X]:
-
- if self._pagesInfoVec[tabIdx].GetEnabled():
- # Fire events and eventually (if allowed) change selection
- self.FireEvent(tabIdx)
-
- # send a message to popup a custom menu
- event = FlatNotebookEvent(wxEVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU, self.GetParent().GetId())
- event.SetSelection(tabIdx)
- event.SetOldSelection(self._iActivePage)
- event.SetEventObject(self.GetParent())
- self.GetParent().GetEventHandler().ProcessEvent(event)
-
- if self._pRightClickMenu:
- self.PopupMenu(self._pRightClickMenu)
-
- event.Skip()
-
-
- def OnLeftDown(self, event):
- """ Handles the wx.EVT_LEFT_DOWN events for L{PageContainer}. """
-
- # Reset buttons status
- self._nXButtonStatus = FNB_BTN_NONE
- self._nLeftButtonStatus = FNB_BTN_NONE
- self._nRightButtonStatus = FNB_BTN_NONE
- self._nTabXButtonStatus = FNB_BTN_NONE
- self._nArrowDownButtonStatus = FNB_BTN_NONE
-
- self._nLeftClickZone, tabIdx = self.HitTest(event.GetPosition())
-
- if self._nLeftClickZone == FNB_DROP_DOWN_ARROW:
- self._nArrowDownButtonStatus = FNB_BTN_PRESSED
- self.Refresh()
- elif self._nLeftClickZone == FNB_LEFT_ARROW:
- self._nLeftButtonStatus = FNB_BTN_PRESSED
- self.Refresh()
- elif self._nLeftClickZone == FNB_RIGHT_ARROW:
- self._nRightButtonStatus = FNB_BTN_PRESSED
- self.Refresh()
- elif self._nLeftClickZone == FNB_X:
- self._nXButtonStatus = FNB_BTN_PRESSED
- self.Refresh()
- elif self._nLeftClickZone == FNB_TAB_X:
- self._nTabXButtonStatus = FNB_BTN_PRESSED
- self.Refresh()
-
- elif self._nLeftClickZone == FNB_TAB:
-
- if self._iActivePage != tabIdx:
-
- # In case the tab is disabled, we dont allow to choose it
- if self._pagesInfoVec[tabIdx].GetEnabled():
- self.FireEvent(tabIdx)
-
-
- def RotateLeft(self):
-
- if self._nFrom == 0:
- return
-
- # Make sure that the button was pressed before
- if self._nLeftButtonStatus != FNB_BTN_PRESSED:
- return
-
- self._nLeftButtonStatus = FNB_BTN_HOVER
-
- # We scroll left with bulks of 5
- scrollLeft = self.GetNumTabsCanScrollLeft()
-
- self._nFrom -= scrollLeft
- if self._nFrom < 0:
- self._nFrom = 0
-
- self.Refresh()
-
-
- def RotateRight(self):
-
- if self._nFrom >= len(self._pagesInfoVec) - 1:
- return
-
- # Make sure that the button was pressed before
- if self._nRightButtonStatus != FNB_BTN_PRESSED:
- return
-
- self._nRightButtonStatus = FNB_BTN_HOVER
-
- # Check if the right most tab is visible, if it is
- # don't rotate right anymore
- if self._pagesInfoVec[len(self._pagesInfoVec)-1].GetPosition() != wx.Point(-1, -1):
- return
-
- self._nFrom += 1
- self.Refresh()
-
-
- def OnLeftUp(self, event):
- """ Handles the wx.EVT_LEFT_UP events for L{PageContainer}. """
-
- # forget the zone that was initially clicked
- self._nLeftClickZone = FNB_NOWHERE
-
- where, tabIdx = self.HitTest(event.GetPosition())
-
- # Make sure selected tab has focus
-# self.SetFocus()
-
- if where == FNB_LEFT_ARROW:
- self.RotateLeft()
-
- elif where == FNB_RIGHT_ARROW:
- self.RotateRight()
-
- elif where == FNB_X:
-
- # Make sure that the button was pressed before
- if self._nXButtonStatus != FNB_BTN_PRESSED:
- return
-
- self._nXButtonStatus = FNB_BTN_HOVER
-
- self.DeletePage(self._iActivePage)
-
- elif where == FNB_TAB_X:
-
- # Make sure that the button was pressed before
- if self._nTabXButtonStatus != FNB_BTN_PRESSED:
- return
-
- self._nTabXButtonStatus = FNB_BTN_HOVER
-
- self.DeletePage(self._iActivePage)
-
- elif where == FNB_DROP_DOWN_ARROW:
-
- # Make sure that the button was pressed before
- if self._nArrowDownButtonStatus != FNB_BTN_PRESSED:
- return
-
- self._nArrowDownButtonStatus = FNB_BTN_NONE
-
- # Refresh the button status
- renderer = self._mgr.GetRenderer(self.GetParent().GetWindowStyleFlag())
- dc = wx.ClientDC(self)
- renderer.DrawDropDownArrow(self, dc)
-
- self.PopupTabsMenu()
-
- event.Skip()
-
-
- def HitTest(self, pt):
- """
- HitTest method for L{PageContainer}.
- Returns the flag (if any) and the hit page (if any).
- """
-
- style = self.GetParent().GetWindowStyleFlag()
- render = self._mgr.GetRenderer(style)
-
- fullrect = self.GetClientRect()
- btnLeftPos = render.GetLeftButtonPos(self)
- btnRightPos = render.GetRightButtonPos(self)
- btnDropdownPos = render.GetDropArrowButtonPos(self)
- btnXPos = render.GetXPos(self)
-
- tabIdx = -1
-
- if len(self._pagesInfoVec) == 0:
- return FNB_NOWHERE, tabIdx
-
- rect = wx.Rect(btnXPos, 8, 16, 16)
- if rect.Contains(pt):
- return (style & FNB_NO_X_BUTTON and [FNB_NOWHERE] or [FNB_X])[0], tabIdx
-
- rect = wx.Rect(btnDropdownPos, 8, 16, 16)
- if style & FNB_DROPDOWN_TABS_LIST:
- rect = wx.Rect(render.GetDropArrowButtonPos(self), 8, 16, 16)
- if rect.Contains(pt):
- return FNB_DROP_DOWN_ARROW, tabIdx
-
- rect = wx.Rect(btnRightPos, 8, 16, 16)
- if rect.Contains(pt):
- return (style & FNB_NO_NAV_BUTTONS and [FNB_NOWHERE] or [FNB_RIGHT_ARROW])[0], tabIdx
-
- rect = wx.Rect(btnLeftPos, 8, 16, 16)
- if rect.Contains(pt):
- return (style & FNB_NO_NAV_BUTTONS and [FNB_NOWHERE] or [FNB_LEFT_ARROW])[0], tabIdx
-
- # Test whether a left click was made on a tab
- bFoundMatch = False
-
- for cur in xrange(self._nFrom, len(self._pagesInfoVec)):
-
- pgInfo = self._pagesInfoVec[cur]
-
- if pgInfo.GetPosition() == wx.Point(-1, -1):
- continue
-
- if style & FNB_X_ON_TAB and cur == self.GetSelection():
- # 'x' button exists on a tab
- if self._pagesInfoVec[cur].GetXRect().Contains(pt):
- return FNB_TAB_X, cur
-
- if style & FNB_VC8:
-
- if self._pagesInfoVec[cur].GetRegion().Contains(pt.x, pt.y):
- if bFoundMatch or cur == self.GetSelection():
- return FNB_TAB, cur
-
- tabIdx = cur
- bFoundMatch = True
-
- else:
-
- tabRect = wx.Rect(pgInfo.GetPosition().x, pgInfo.GetPosition().y,
- pgInfo.GetSize().x, pgInfo.GetSize().y)
-
- if tabRect.Contains(pt):
- # We have a match
- return FNB_TAB, cur
-
- if bFoundMatch:
- return FNB_TAB, tabIdx
-
- if self._isdragging:
- # We are doing DND, so check also the region outside the tabs
- # try before the first tab
- pgInfo = self._pagesInfoVec[0]
- tabRect = wx.Rect(0, pgInfo.GetPosition().y, pgInfo.GetPosition().x, self.GetParent().GetSize().y)
- if tabRect.Contains(pt):
- return FNB_TAB, 0
-
- # try after the last tab
- pgInfo = self._pagesInfoVec[-1]
- startpos = pgInfo.GetPosition().x+pgInfo.GetSize().x
- tabRect = wx.Rect(startpos, pgInfo.GetPosition().y, fullrect.width-startpos, self.GetParent().GetSize().y)
-
- if tabRect.Contains(pt):
- return FNB_TAB, len(self._pagesInfoVec)
-
- # Default
- return FNB_NOWHERE, -1
-
-
- def SetSelection(self, page):
- """ Sets the selected page. """
-
- book = self.GetParent()
- book.SetSelection(page)
- self.DoSetSelection(page)
-
-
- def DoSetSelection(self, page):
- """ Does the actual selection of a page. """
-
- if page < len(self._pagesInfoVec):
- #! fix for tabfocus
- da_page = self._pParent.GetPage(page)
-
-# if da_page != None:
-# da_page.SetFocus()
-#
- self.EnsureVisible(page)
-
- def EnsureVisible(self, page, refresh=True):
- if not self.IsTabVisible(page):
- # Try to remove one tab from start and try again
-
- if not self.CanFitToScreen(page):
-
- if self._nFrom > page:
- self._nFrom = page
- else:
- while self._nFrom < page:
- self._nFrom += 1
- if self.CanFitToScreen(page):
- break
- if refresh:
- self.Refresh()
-
-
- def DeletePage(self, page):
- """ Delete the specified page from L{FlatNotebook}. """
-
- book = self.GetParent()
- book.DeletePage(page)
- book.Refresh()
-
-
- def IsTabVisible(self, page):
- """ Returns whether a tab is visible or not. """
-
- iLastVisiblePage = self.GetLastVisibleTab()
- return page <= iLastVisiblePage and page >= self._nFrom
-
-
- def DoDeletePage(self, page):
- """ Does the actual page deletion. """
-
- # Remove the page from the vector
- book = self.GetParent()
- self._pagesInfoVec.pop(page)
-
- # Thanks to Yiaanis AKA Mandrav
- if self._iActivePage >= page:
- self._iActivePage = self._iActivePage - 1
- self._iPreviousActivePage = -1
-
- # The delete page was the last first on the array,
- # but the book still has more pages, so we set the
- # active page to be the first one (0)
- if self._iActivePage < 0 and len(self._pagesInfoVec) > 0:
- self._iActivePage = 0
- self._iPreviousActivePage = -1
-
- # Refresh the tabs
- if self._iActivePage >= 0:
-
- book._bForceSelection = True
-
- # Check for selection and send event
- event = FlatNotebookEvent(wxEVT_FLATNOTEBOOK_PAGE_CHANGING, self.GetParent().GetId())
- event.SetSelection(self._iActivePage)
- event.SetOldSelection(self._iPreviousActivePage)
- event.SetEventObject(self.GetParent())
- self.GetParent().GetEventHandler().ProcessEvent(event)
-
- book.SetSelection(self._iActivePage)
- book._bForceSelection = False
-
- # Fire a wxEVT_FLATNOTEBOOK_PAGE_CHANGED event
- event.SetEventType(wxEVT_FLATNOTEBOOK_PAGE_CHANGED)
- event.SetOldSelection(self._iPreviousActivePage)
- self.GetParent().GetEventHandler().ProcessEvent(event)
-
- if not self._pagesInfoVec:
- # Erase the page container drawings
- dc = wx.ClientDC(self)
- dc.Clear()
-
-
- def DeleteAllPages(self):
- """ Deletes all the pages. """
-
- self._iActivePage = -1
- self._iPreviousActivePage = -1
- self._nFrom = 0
- self._pagesInfoVec = []
-
- # Erase the page container drawings
- dc = wx.ClientDC(self)
- dc.Clear()
-
-
- def OnMouseMove(self, event):
- """ Handles the wx.EVT_MOTION for L{PageContainer}. """
-
- if self._pagesInfoVec and self.IsShown():
-
- xButtonStatus = self._nXButtonStatus
- xTabButtonStatus = self._nTabXButtonStatus
- rightButtonStatus = self._nRightButtonStatus
- leftButtonStatus = self._nLeftButtonStatus
- dropDownButtonStatus = self._nArrowDownButtonStatus
-
- style = self.GetParent().GetWindowStyleFlag()
-
- self._nXButtonStatus = FNB_BTN_NONE
- self._nRightButtonStatus = FNB_BTN_NONE
- self._nLeftButtonStatus = FNB_BTN_NONE
- self._nTabXButtonStatus = FNB_BTN_NONE
- self._nArrowDownButtonStatus = FNB_BTN_NONE
-
- where, tabIdx = self.HitTest(event.GetPosition())
-
- if where == FNB_X:
- if event.LeftIsDown():
-
- self._nXButtonStatus = (self._nLeftClickZone==FNB_X and [FNB_BTN_PRESSED] or [FNB_BTN_NONE])[0]
-
- else:
-
- self._nXButtonStatus = FNB_BTN_HOVER
-
- elif where == FNB_DROP_DOWN_ARROW:
- if event.LeftIsDown():
-
- self._nArrowDownButtonStatus = (self._nLeftClickZone==FNB_DROP_DOWN_ARROW and [FNB_BTN_PRESSED] or [FNB_BTN_NONE])[0]
-
- else:
-
- self._nArrowDownButtonStatus = FNB_BTN_HOVER
-
- elif where == FNB_TAB_X:
- if event.LeftIsDown():
-
- self._nTabXButtonStatus = (self._nLeftClickZone==FNB_TAB_X and [FNB_BTN_PRESSED] or [FNB_BTN_NONE])[0]
-
- else:
-
- self._nTabXButtonStatus = FNB_BTN_HOVER
-
- elif where == FNB_RIGHT_ARROW:
- if event.LeftIsDown():
-
- self._nRightButtonStatus = (self._nLeftClickZone==FNB_RIGHT_ARROW and [FNB_BTN_PRESSED] or [FNB_BTN_NONE])[0]
-
- else:
-
- self._nRightButtonStatus = FNB_BTN_HOVER
-
- elif where == FNB_LEFT_ARROW:
- if event.LeftIsDown():
-
- self._nLeftButtonStatus = (self._nLeftClickZone==FNB_LEFT_ARROW and [FNB_BTN_PRESSED] or [FNB_BTN_NONE])[0]
-
- else:
-
- self._nLeftButtonStatus = FNB_BTN_HOVER
-
- elif where == FNB_TAB:
- # Call virtual method for showing tooltip
- self.ShowTabTooltip(tabIdx)
-
- if not self.GetEnabled(tabIdx):
- # Set the cursor to be 'No-entry'
- wx.SetCursor(wx.StockCursor(wx.CURSOR_NO_ENTRY))
-
- # Support for drag and drop
- if event.Dragging() and not (style & FNB_NODRAG):
-
- self._isdragging = True
- draginfo = FNBDragInfo(self, tabIdx)
- drginfo = cPickle.dumps(draginfo)
- dataobject = wx.CustomDataObject(wx.CustomDataFormat("FlatNotebook"))
- dataobject.SetData(drginfo)
- dragSource = FNBDropSource(self)
- dragSource.SetData(dataobject)
- dragSource.DoDragDrop(wx.Drag_DefaultMove)
-
- bRedrawX = self._nXButtonStatus != xButtonStatus
- bRedrawRight = self._nRightButtonStatus != rightButtonStatus
- bRedrawLeft = self._nLeftButtonStatus != leftButtonStatus
- bRedrawTabX = self._nTabXButtonStatus != xTabButtonStatus
- bRedrawDropArrow = self._nArrowDownButtonStatus != dropDownButtonStatus
-
- render = self._mgr.GetRenderer(style)
-
- if (bRedrawX or bRedrawRight or bRedrawLeft or bRedrawTabX or bRedrawDropArrow):
-
- dc = wx.ClientDC(self)
-
- if bRedrawX:
-
- render.DrawX(self, dc)
-
- if bRedrawLeft:
-
- render.DrawLeftArrow(self, dc)
-
- if bRedrawRight:
-
- render.DrawRightArrow(self, dc)
-
- if bRedrawTabX:
-
- self.Refresh()
-
- if bRedrawDropArrow:
-
- render.DrawDropDownArrow(self, dc)
-
- event.Skip()
-
-
- def GetLastVisibleTab(self):
- """ Returns the last visible tab. """
-
- if self._nFrom < 0:
- return -1
-
- ii = 0
-
- for ii in xrange(self._nFrom, len(self._pagesInfoVec)):
-
- if self._pagesInfoVec[ii].GetPosition() == wx.Point(-1, -1):
- break
-
- return ii-1
-
-
- def GetNumTabsCanScrollLeft(self):
- """ Returns the number of tabs than can be scrolled left. """
-
- if self._nFrom - 1 >= 0:
- return 1
-
- return 0
-
-
- def IsDefaultTabs(self):
- """ Returns whether a tab has a default style. """
-
- style = self.GetParent().GetWindowStyleFlag()
- res = (style & FNB_VC71) or (style & FNB_FANCY_TABS) or (style & FNB_VC8)
- return not res
-
-
- def AdvanceSelection(self, bForward=True):
- """
- Cycles through the tabs.
- The call to this function generates the page changing events.
- """
-
- nSel = self.GetSelection()
-
- if nSel < 0:
- return
-
- nMax = self.GetPageCount() - 1
-
- if bForward:
- newSelection = (nSel == nMax and [0] or [nSel + 1])[0]
- else:
- newSelection = (nSel == 0 and [nMax] or [nSel - 1])[0]
-
- if not self._pagesInfoVec[newSelection].GetEnabled():
- return
-
- self.FireEvent(newSelection)
-
-
- def OnMouseLeave(self, event):
- """ Handles the wx.EVT_LEAVE_WINDOW event for L{PageContainer}. """
-
- self._nLeftButtonStatus = FNB_BTN_NONE
- self._nXButtonStatus = FNB_BTN_NONE
- self._nRightButtonStatus = FNB_BTN_NONE
- self._nTabXButtonStatus = FNB_BTN_NONE
- self._nArrowDownButtonStatus = FNB_BTN_NONE
-
- style = self.GetParent().GetWindowStyleFlag()
- render = self._mgr.GetRenderer(style)
-
- dc = wx.ClientDC(self)
-
- render.DrawX(self, dc)
- render.DrawLeftArrow(self, dc)
- render.DrawRightArrow(self, dc)
-
- selection = self.GetSelection()
-
- if selection == -1:
- event.Skip()
- return
-
- if not self.IsTabVisible(selection):
- if selection == len(self._pagesInfoVec) - 1:
- if not self.CanFitToScreen(selection):
- event.Skip()
- return
- else:
- event.Skip()
- return
-
- render.DrawTabX(self, dc, self._pagesInfoVec[selection].GetXRect(), selection, self._nTabXButtonStatus)
- render.DrawFocusRectangle(dc, self, self._pagesInfoVec[selection])
-
- event.Skip()
-
-
- def OnMouseEnterWindow(self, event):
- """ Handles the wx.EVT_ENTER_WINDOW event for L{PageContainer}. """
-
- self._nLeftButtonStatus = FNB_BTN_NONE
- self._nXButtonStatus = FNB_BTN_NONE
- self._nRightButtonStatus = FNB_BTN_NONE
- self._nLeftClickZone = FNB_BTN_NONE
- self._nArrowDownButtonStatus = FNB_BTN_NONE
-
- event.Skip()
-
-
- def ShowTabTooltip(self, tabIdx):
- """ Shows a tab tooltip. """
-
- pWindow = self._pParent.GetPage(tabIdx)
-
- if pWindow:
- pToolTip = pWindow.GetToolTip()
- if pToolTip and pToolTip.GetWindow() == pWindow:
- self.SetToolTipString(pToolTip.GetTip())
-
-
- def SetPageImage(self, page, imgindex):
- """ Sets the image index associated to a page. """
-
- if page < len(self._pagesInfoVec):
-
- self._pagesInfoVec[page].SetImageIndex(imgindex)
- self.Refresh()
-
-
- def GetPageImage(self, page):
- """ Returns the image index associated to a page. """
-
- if page < len(self._pagesInfoVec):
-
- return self._pagesInfoVec[page].GetImageIndex()
-
- return -1
-
-
- def OnDropTarget(self, x, y, nTabPage, wnd_oldContainer):
- """ Handles the drop action from a DND operation. """
-
- # Disable drag'n'drop for disabled tab
- if not wnd_oldContainer._pagesInfoVec[nTabPage].GetEnabled():
- return wx.DragCancel
-
- self._isdragging = True
- oldContainer = wnd_oldContainer
- nIndex = -1
-
- where, nIndex = self.HitTest(wx.Point(x, y))
-
- oldNotebook = oldContainer.GetParent()
- newNotebook = self.GetParent()
-
- if oldNotebook == newNotebook:
-
- if nTabPage >= 0:
-
- if where == FNB_TAB:
- self.MoveTabPage(nTabPage, nIndex)
-
- elif self.GetParent().GetWindowStyleFlag() & FNB_ALLOW_FOREIGN_DND:
-
- if wx.Platform in ["__WXMSW__", "__WXGTK__", "__WXMAC__"]:
- if nTabPage >= 0:
-
- window = oldNotebook.GetPage(nTabPage)
-
- if window:
- where, nIndex = newNotebook._pages.HitTest(wx.Point(x, y))
- caption = oldContainer.GetPageText(nTabPage)
- imageindex = oldContainer.GetPageImage(nTabPage)
- oldNotebook.RemovePage(nTabPage)
- window.Reparent(newNotebook)
-
- if imageindex >= 0:
-
- bmp = oldNotebook.GetImageList().GetBitmap(imageindex)
- newImageList = newNotebook.GetImageList()
-
- if not newImageList:
- xbmp, ybmp = bmp.GetWidth(), bmp.GetHeight()
- newImageList = wx.ImageList(xbmp, ybmp)
- imageindex = 0
- else:
- imageindex = newImageList.GetImageCount()
-
- newImageList.Add(bmp)
- newNotebook.SetImageList(newImageList)
-
- newNotebook.InsertPage(nIndex, window, caption, True, imageindex)
-
- self._isdragging = False
-
- return wx.DragMove
-
-
- def MoveTabPage(self, nMove, nMoveTo):
- """ Moves a tab inside the same L{FlatNotebook}. """
-
- if nMove == nMoveTo:
- return
-
- elif nMoveTo < len(self._pParent._windows):
- nMoveTo = nMoveTo + 1
-
- self._pParent.Freeze()
-
- # Remove the window from the main sizer
- nCurSel = self._pParent._pages.GetSelection()
- self._pParent._mainSizer.Detach(self._pParent._windows[nCurSel])
- self._pParent._windows[nCurSel].Hide()
-
- pWindow = self._pParent._windows[nMove]
- self._pParent._windows.pop(nMove)
- self._pParent._windows.insert(nMoveTo-1, pWindow)
-
- pgInfo = self._pagesInfoVec[nMove]
-
- self._pagesInfoVec.pop(nMove)
- self._pagesInfoVec.insert(nMoveTo - 1, pgInfo)
-
- # Add the page according to the style
- pSizer = self._pParent._mainSizer
- style = self.GetParent().GetWindowStyleFlag()
-
- if style & FNB_BOTTOM:
-
- pSizer.Insert(0, pWindow, 1, wx.EXPAND)
-
- else:
-
- # We leave a space of 1 pixel around the window
- pSizer.Add(pWindow, 1, wx.EXPAND)
-
- pWindow.Show()
-
- pSizer.Layout()
- self._iActivePage = nMoveTo - 1
- self._iPreviousActivePage = -1
- self.DoSetSelection(self._iActivePage)
- self.Refresh()
- self._pParent.Thaw()
-
-
- def CanFitToScreen(self, page):
- """ Returns wheter a tab can fit in the left space in the screen or not. """
-
- # Incase the from is greater than page,
- # we need to reset the self._nFrom, so in order
- # to force the caller to do so, we return false
- if self._nFrom > page:
- return False
-
- style = self.GetParent().GetWindowStyleFlag()
- render = self._mgr.GetRenderer(style)
-
- vTabInfo = render.NumberTabsCanFit(self)
-
- if page - self._nFrom >= len(vTabInfo):
- return False
-
- return True
-
-
- def GetNumOfVisibleTabs(self):
- """ Returns the number of visible tabs. """
-
- count = 0
- for ii in xrange(self._nFrom, len(self._pagesInfoVec)):
- if self._pagesInfoVec[ii].GetPosition() == wx.Point(-1, -1):
- break
- count = count + 1
-
- return count
-
-
- def GetEnabled(self, page):
- """ Returns whether a tab is enabled or not. """
-
- if page >= len(self._pagesInfoVec):
- return True # Seems strange, but this is the default
-
- return self._pagesInfoVec[page].GetEnabled()
-
-
- def EnableTab(self, page, enabled=True):
- """ Enables or disables a tab. """
-
- if page >= len(self._pagesInfoVec):
- return
-
- self._pagesInfoVec[page].EnableTab(enabled)
-
-
- def GetSingleLineBorderColour(self):
- """ Returns the colour for the single line border. """
-
- if self.HasFlag(FNB_FANCY_TABS):
- return self._colorFrom
-
- return wx.WHITE
-
-
- def HasFlag(self, flag):
- """ Returns whether a flag is present in the L{FlatNotebook} style. """
-
- style = self.GetParent().GetWindowStyleFlag()
- res = (style & flag and [True] or [False])[0]
- return res
-
-
- def ClearFlag(self, flag):
- """ Deletes a flag from the L{FlatNotebook} style. """
-
- style = self.GetParent().GetWindowStyleFlag()
- style &= ~flag
- self.SetWindowStyleFlag(style)
-
-
- def TabHasImage(self, tabIdx):
- """ Returns whether a tab has an associated image index or not. """
-
- if self._ImageList:
- return self._pagesInfoVec[tabIdx].GetImageIndex() != -1
-
- return False
-
-
- def OnLeftDClick(self, event):
- """ Handles the wx.EVT_LEFT_DCLICK event for L{PageContainer}. """
-
- where, tabIdx = self.HitTest(event.GetPosition())
-
- if where == FNB_RIGHT_ARROW:
- self.RotateRight()
-
- elif where == FNB_LEFT_ARROW:
- self.RotateLeft()
-
- elif self.HasFlag(FNB_DCLICK_CLOSES_TABS):
-
- if where == FNB_TAB:
- self.DeletePage(tabIdx)
-
- else:
-
- event.Skip()
-
-
- def OnSetFocus(self, event):
- """ Handles the wx.EVT_SET_FOCUS event for L{PageContainer}. """
-
- if self._iActivePage < 0:
- event.Skip()
- return
-
- self.SetFocusedPage(self._iActivePage)
-
-
- def OnKillFocus(self, event):
- """ Handles the wx.EVT_KILL_FOCUS event for L{PageContainer}. """
-
- self.SetFocusedPage()
-
-
- def OnKeyDown(self, event):
- """
- When the PageContainer has the focus tabs can be changed with
- the left/right arrow keys.
- """
- key = event.GetKeyCode()
- if key == wx.WXK_LEFT:
- self.GetParent().AdvanceSelection(False)
- elif key == wx.WXK_RIGHT:
- self.GetParent().AdvanceSelection(True)
- elif key == wx.WXK_TAB and not event.ControlDown():
- flags = 0
- if not event.ShiftDown(): flags |= wx.NavigationKeyEvent.IsForward
- if event.CmdDown(): flags |= wx.NavigationKeyEvent.WinChange
- self.Navigate(flags)
- else:
- event.Skip()
-
-
- def SetFocusedPage(self, pageIndex=-1):
- """
- Sets/Unsets the focus on the appropriate page.
- If pageIndex is defaulted, we have lost focus and no focus indicator is drawn.
- """
-
- for indx, page in enumerate(self._pagesInfoVec):
- if indx == pageIndex:
- page._hasFocus = True
- else:
- page._hasFocus = False
-
- self.Refresh()
-
-
- def PopupTabsMenu(self):
- """ Pops up the menu activated with the drop down arrow in the navigation area. """
-
- popupMenu = wx.Menu()
-
- for i in xrange(len(self._pagesInfoVec)):
- pi = self._pagesInfoVec[i]
- item = wx.MenuItem(popupMenu, i+1, pi.GetCaption(), pi.GetCaption(), wx.ITEM_NORMAL)
- self.Bind(wx.EVT_MENU, self.OnTabMenuSelection, item)
-
- # There is an alignment problem with wx2.6.3 & Menus so only use
- # images for versions above 2.6.3
- if wx.VERSION > (2, 6, 3, 0) and self.TabHasImage(i):
- item.SetBitmap(self.GetImageList().GetBitmap(pi.GetImageIndex()))
-
- popupMenu.AppendItem(item)
- item.Enable(pi.GetEnabled())
-
- self.PopupMenu(popupMenu)
-
-
- def OnTabMenuSelection(self, event):
- """ Handles the wx.EVT_MENU event for L{PageContainer}. """
-
- selection = event.GetId() - 1
- self.FireEvent(selection)
-
-
- def FireEvent(self, selection):
- """
- Fires the wxEVT_FLATNOTEBOOK_PAGE_CHANGING and wxEVT_FLATNOTEBOOK_PAGE_CHANGED events
- called from other methods (from menu selection or Smart Tabbing).
- Utility function.
- """
-
- if selection == self._iActivePage:
- # No events for the same selection
- return
-
- oldSelection = self._iActivePage
-
- event = FlatNotebookEvent(wxEVT_FLATNOTEBOOK_PAGE_CHANGING, self.GetParent().GetId())
- event.SetSelection(selection)
- event.SetOldSelection(oldSelection)
- event.SetEventObject(self.GetParent())
-
- if not self.GetParent().GetEventHandler().ProcessEvent(event) or event.IsAllowed():
-
- self.SetSelection(selection)
-
- # Fire a wxEVT_FLATNOTEBOOK_PAGE_CHANGED event
- event.SetEventType(wxEVT_FLATNOTEBOOK_PAGE_CHANGED)
- event.SetOldSelection(oldSelection)
- self.GetParent().GetEventHandler().ProcessEvent(event)
-# self.SetFocus()
-
-
- def SetImageList(self, imglist):
- """ Sets the image list for the page control. """
-
- self._ImageList = imglist
-
-
- def AssignImageList(self, imglist):
- """ Assigns the image list for the page control. """
-
- self._ImageList = imglist
-
-
- def GetImageList(self):
- """ Returns the image list for the page control. """
-
- return self._ImageList
-
-
- def GetSelection(self):
- """ Returns the current selected page. """
-
- return self._iActivePage
-
-
- def GetPageCount(self):
- """ Returns the number of tabs in the L{FlatNotebook} control. """
-
- return len(self._pagesInfoVec)
-
-
- def GetPageText(self, page):
- """ Returns the tab caption of the page. """
-
- return self._pagesInfoVec[page].GetCaption()
-
-
- def SetPageText(self, page, text):
- """ Sets the tab caption of the page. """
-
- self._pagesInfoVec[page].SetCaption(text)
- return True
-
-
- def DrawDragHint(self):
- """ Draws small arrow at the place that the tab will be placed. """
-
- # get the index of tab that will be replaced with the dragged tab
- pt = wx.GetMousePosition()
- client_pt = self.ScreenToClient(pt)
- where, tabIdx = self.HitTest(client_pt)
- self._mgr.GetRenderer(self.GetParent().GetWindowStyleFlag()).DrawDragHint(self, tabIdx)
-
-
diff --git a/utils/PyoDoc.py b/utils/PyoDoc.py
index 737c317..9628f9a 100644
--- a/utils/PyoDoc.py
+++ b/utils/PyoDoc.py
@@ -23,7 +23,7 @@ DOC_STYLES = {'Default': {'default': '#000000', 'comment': '#007F7F', 'commentbl
'number': '#005000', 'string': '#7F007F', 'triple': '#7F0000', 'keyword': '#00007F', 'keyword2': '#007F9F',
'class': '#0000FF', 'function': '#007F7F', 'identifier': '#000000', 'caret': '#00007E',
'background': '#EEEEEE', 'linenumber': '#000000', 'marginback': '#B0B0B0', 'markerfg': '#CCCCCC',
- 'markerbg': '#000000', 'bracelight': '#AABBDD', 'bracebad': '#DD0000', 'lineedge': '#CCCCCC'}}
+ 'markerbg': '#000000', 'bracelight': '#AABBDD', 'bracebad': '#DD0000', 'lineedge': '#CCCCCC'}}
if wx.Platform == '__WXMSW__':
DOC_FACES = {'face': 'Verdana', 'size' : 8, 'size2': 7}
@@ -928,7 +928,8 @@ class ManualFrame(wx.Frame):
self.searchMenu.Append(id, txt)
self.Bind(wx.EVT_MENU, self.onSearchScope, id=id)
- self.search = wx.SearchCtrl(self.toolbar, 200, size=(200,-1), style=wx.WANTS_CHARS | wx.TE_PROCESS_ENTER)
+ tw, th = self.GetTextExtent("Q")
+ self.search = wx.SearchCtrl(self.toolbar, 200, size=(200,th+6), style=wx.WANTS_CHARS | wx.TE_PROCESS_ENTER)
self.search.ShowCancelButton(True)
self.search.SetMenu(self.searchMenu)
self.toolbar.AddControl(self.search)
diff --git a/utils/epyo_builder_OSX.sh b/utils/epyo_builder_OSX.sh
index a715ead..463cbf8 100755
--- a/utils/epyo_builder_OSX.sh
+++ b/utils/epyo_builder_OSX.sh
@@ -1,6 +1,5 @@
mkdir Resources
cp PyoDoc.py Resources/
-cp FlatNoteBook.py Resources/
cp Tutorial_01_RingMod.py Resources/
cp Tutorial_02_Flanger.py Resources/
cp Tutorial_03_TriTable.py Resources/
@@ -27,20 +26,19 @@ else
exit;
fi
-ditto --rsrc --arch i386 E-Pyo.app E-Pyo-i386.app
+# keep only 64-bit arch
+ditto --rsrc --arch x86_64 E-Pyo.app E-Pyo-x86_64.app
rm -rf E-Pyo.app
-mv E-Pyo-i386.app E-Pyo.app
+mv E-Pyo-x86_64.app E-Pyo.app
cd ..
cp -R E-Pyo_OSX/E-Pyo.app .
-# Fixed wrong path in Info.plist
-cd E-Pyo.app/Contents
-awk '{gsub("Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python", "@executable_path/../Frameworks/Python.framework/Versions/2.6/Python")}1' Info.plist > Info.plist_tmp && mv Info.plist_tmp Info.plist
+# Fixed wrong path in Info.plist (no more needed python 2.7.8, py2app 0.9)
+#cd E-Pyo.app/Contents
+#awk '{gsub("Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python", "@executable_path/../Frameworks/Python.framework/Versions/2.7/Python")}1' Info.plist > Info.plist_tmp && mv Info.plist_tmp Info.plist
+#cd ../..
-cd ../..
-#tar -cjvf E-Pyo_OSX-0.6.1.tar.bz2 E-Pyo.app
-#rm -rf E-Pyo.app
rm -rf E-Pyo_OSX
rm -rf Resources
rm -rf examples
diff --git a/utils/epyo_builder_win32.py b/utils/epyo_builder_win32.py
index e4265c3..8241966 100644
--- a/utils/epyo_builder_win32.py
+++ b/utils/epyo_builder_win32.py
@@ -4,7 +4,6 @@ version = sys.version_info[:2]
os.mkdir("Resources")
shutil.copy("PyoDoc.py", "Resources")
-shutil.copy("FlatNoteBook.py", "Resources")
shutil.copy("Tutorial_01_RingMod.py", "Resources")
shutil.copy("Tutorial_02_Flanger.py", "Resources")
shutil.copy("Tutorial_03_TriTable.py", "Resources")
@@ -15,9 +14,9 @@ os.system("svn export ../examples Resources/examples/")
os.system("svn export snippets Resources/snippets/")
os.system("svn export styles Resources/styles/")
-os.system("C:\Python%d%d\python ..\..\pyinstaller\Configure.py" % version)
-os.system('C:\Python%d%d\python ..\..\pyinstaller\Makespec.py -F -c --icon=Resources\E-PyoIcon.ico "E-Pyo.py"' % version)
-os.system('C:\Python%d%d\python ..\..\pyinstaller\Build.py "E-Pyo.spec"' % version)
+#os.system("C:\Python%d%d\python ..\..\pyinstaller\Configure.py" % version)
+os.system('C:\Python%d%d\Scripts\pyi-makespec -F -c --icon=Resources\E-PyoIcon.ico "E-Pyo.py"' % version)
+os.system('C:\Python%d%d\Scripts\pyi-build "E-Pyo.spec"' % version)
os.mkdir("E-Pyo_py%d%d" % version)
shutil.copytree("Resources", "E-Pyo_py%d%d/Resources" % version)
diff --git a/utils/info.plist b/utils/info.plist
index cc6108e..70c56f7 100644
--- a/utils/info.plist
+++ b/utils/info.plist
@@ -32,17 +32,17 @@
<key>CFBundleIdentifier</key>
<string>org.pythonmac.unspecified.E-Pyo</string>
<key>CFBundleInfoDictionaryVersion</key>
- <string>0.6.9</string>
+ <string>0.7.6</string>
<key>CFBundleName</key>
<string>E-Pyo</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>0.6.9</string>
+ <string>0.7.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>0.6.9</string>
+ <string>0.7.6</string>
<key>LSHasLocalizedDisplayName</key>
<false/>
<key>NSAppleScriptEnabled</key>
@@ -78,17 +78,16 @@
<array/>
<key>PyRuntimeLocations</key>
<array>
- <string>@executable_path/../Frameworks/Python.framework/Versions/2.6/Python</string>
+ <string>@executable_path/../Frameworks/Python.framework/Versions/2.7/Python</string>
</array>
<key>PythonInfoDict</key>
<dict>
<key>PythonExecutable</key>
- <string>@executable_path/../Frameworks/Python.framework/Versions/2.6/Python</string>
+ <string>@executable_path/../Frameworks/Python.framework/Versions/2.7/Python</string>
<key>PythonLongVersion</key>
- <string>2.6.5 (r265:79359, Mar 24 2010, 01:32:55)
-[GCC 4.0.1 (Apple Inc. build 5493)]</string>
+ <string>2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35) \n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]</string>
<key>PythonShortVersion</key>
- <string>2.6</string>
+ <string>2.7</string>
<key>py2app</key>
<dict>
<key>alias</key>
@@ -96,7 +95,7 @@
<key>template</key>
<string>app</string>
<key>version</key>
- <string>0.4.4</string>
+ <string>0.9</string>
</dict>
</dict>
</dict>
--
python-pyo packaging
More information about the pkg-multimedia-commits
mailing list